diff options
Diffstat (limited to 'drivers')
21 files changed, 231 insertions, 178 deletions
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 09e4f48204..20cd8dd26c 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -43,17 +43,17 @@ extern int initialize_pulse(int verbose); } #endif -Error AudioDriverALSA::init_device() { +Error AudioDriverALSA::init_output_device() { mix_rate = GLOBAL_GET("audio/driver/mix_rate"); speaker_mode = SPEAKER_MODE_STEREO; channels = 2; - // If there is a specified device check that it is really present - if (device_name != "Default") { - PackedStringArray list = get_device_list(); - if (list.find(device_name) == -1) { - device_name = "Default"; - new_device = "Default"; + // If there is a specified output device check that it is really present + if (output_device_name != "Default") { + PackedStringArray list = get_output_device_list(); + if (list.find(output_device_name) == -1) { + output_device_name = "Default"; + new_output_device = "Default"; } } @@ -75,10 +75,10 @@ Error AudioDriverALSA::init_device() { //6 chans - "plug:surround51" //4 chans - "plug:surround40"; - if (device_name == "Default") { + if (output_device_name == "Default") { status = snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); } else { - String device = device_name; + String device = output_device_name; int pos = device.find(";"); if (pos != -1) { device = device.substr(0, pos); @@ -171,7 +171,7 @@ Error AudioDriverALSA::init() { active.clear(); exit_thread.clear(); - Error err = init_device(); + Error err = init_output_device(); if (err == OK) { thread.start(AudioDriverALSA::thread_func, this); } @@ -227,18 +227,18 @@ void AudioDriverALSA::thread_func(void *p_udata) { } } - // User selected a new device, finish the current one so we'll init the new device - if (ad->device_name != ad->new_device) { - ad->device_name = ad->new_device; - ad->finish_device(); + // User selected a new output device, finish the current one so we'll init the new device. + if (ad->output_device_name != ad->new_output_device) { + ad->output_device_name = ad->new_output_device; + ad->finish_output_device(); - Error err = ad->init_device(); + Error err = ad->init_output_device(); if (err != OK) { - ERR_PRINT("ALSA: init_device error"); - ad->device_name = "Default"; - ad->new_device = "Default"; + ERR_PRINT("ALSA: init_output_device error"); + ad->output_device_name = "Default"; + ad->new_output_device = "Default"; - err = ad->init_device(); + err = ad->init_output_device(); if (err != OK) { ad->active.clear(); ad->exit_thread.set(); @@ -263,7 +263,7 @@ AudioDriver::SpeakerMode AudioDriverALSA::get_speaker_mode() const { return speaker_mode; } -PackedStringArray AudioDriverALSA::get_device_list() { +PackedStringArray AudioDriverALSA::get_output_device_list() { PackedStringArray list; list.push_back("Default"); @@ -298,13 +298,13 @@ PackedStringArray AudioDriverALSA::get_device_list() { return list; } -String AudioDriverALSA::get_device() { - return device_name; +String AudioDriverALSA::get_output_device() { + return output_device_name; } -void AudioDriverALSA::set_device(String device) { +void AudioDriverALSA::set_output_device(const String &p_name) { lock(); - new_device = device; + new_output_device = p_name; unlock(); } @@ -316,7 +316,7 @@ void AudioDriverALSA::unlock() { mutex.unlock(); } -void AudioDriverALSA::finish_device() { +void AudioDriverALSA::finish_output_device() { if (pcm_handle) { snd_pcm_close(pcm_handle); pcm_handle = nullptr; @@ -327,7 +327,7 @@ void AudioDriverALSA::finish() { exit_thread.set(); thread.wait_to_finish(); - finish_device(); + finish_output_device(); } #endif // ALSA_ENABLED diff --git a/drivers/alsa/audio_driver_alsa.h b/drivers/alsa/audio_driver_alsa.h index 6e9cf4dba9..821ba1d145 100644 --- a/drivers/alsa/audio_driver_alsa.h +++ b/drivers/alsa/audio_driver_alsa.h @@ -46,14 +46,14 @@ class AudioDriverALSA : public AudioDriver { snd_pcm_t *pcm_handle = nullptr; - String device_name = "Default"; - String new_device = "Default"; + String output_device_name = "Default"; + String new_output_device = "Default"; Vector<int32_t> samples_in; Vector<int16_t> samples_out; - Error init_device(); - void finish_device(); + Error init_output_device(); + void finish_output_device(); static void thread_func(void *p_udata); @@ -69,20 +69,22 @@ class AudioDriverALSA : public AudioDriver { SafeFlag exit_thread; public: - const char *get_name() const { + virtual const char *get_name() const override { return "ALSA"; - }; - - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const; - virtual SpeakerMode get_speaker_mode() const; - virtual PackedStringArray get_device_list(); - virtual String get_device(); - virtual void set_device(String device); - virtual void lock(); - virtual void unlock(); - virtual void finish(); + } + + virtual Error init() override; + virtual void start() override; + virtual int get_mix_rate() const override; + virtual SpeakerMode get_speaker_mode() const override; + + virtual void lock() override; + virtual void unlock() override; + virtual void finish() override; + + virtual PackedStringArray get_output_device_list() override; + virtual String get_output_device() override; + virtual void set_output_device(const String &p_name) override; AudioDriverALSA() {} ~AudioDriverALSA() {} diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index c454da8e23..2c959bb07b 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.cpp @@ -158,7 +158,7 @@ Error AudioDriverCoreAudio::init() { ERR_FAIL_COND_V(result != noErr, FAILED); if (GLOBAL_GET("audio/driver/enable_input")) { - return capture_init(); + return init_input_device(); } return OK; } @@ -287,7 +287,7 @@ bool AudioDriverCoreAudio::try_lock() { } void AudioDriverCoreAudio::finish() { - capture_finish(); + finish_input_device(); if (audio_unit) { OSStatus result; @@ -337,7 +337,7 @@ void AudioDriverCoreAudio::finish() { } } -Error AudioDriverCoreAudio::capture_init() { +Error AudioDriverCoreAudio::init_input_device() { AudioComponentDescription desc; memset(&desc, 0, sizeof(desc)); desc.componentType = kAudioUnitType_Output; @@ -433,7 +433,7 @@ Error AudioDriverCoreAudio::capture_init() { return OK; } -void AudioDriverCoreAudio::capture_finish() { +void AudioDriverCoreAudio::finish_input_device() { if (input_unit) { lock(); @@ -471,7 +471,7 @@ void AudioDriverCoreAudio::capture_finish() { } } -Error AudioDriverCoreAudio::capture_start() { +Error AudioDriverCoreAudio::input_start() { input_buffer_init(buffer_frames); OSStatus result = AudioOutputUnitStart(input_unit); @@ -482,7 +482,7 @@ Error AudioDriverCoreAudio::capture_start() { return OK; } -Error AudioDriverCoreAudio::capture_stop() { +Error AudioDriverCoreAudio::input_stop() { if (input_unit) { OSStatus result = AudioOutputUnitStop(input_unit); if (result != noErr) { @@ -647,20 +647,13 @@ String AudioDriverCoreAudio::get_output_device() { return output_device_name; } -void AudioDriverCoreAudio::set_output_device(String output_device) { - output_device_name = output_device; +void AudioDriverCoreAudio::set_output_device(const String &p_name) { + output_device_name = p_name; if (active) { _set_device(output_device_name); } } -void AudioDriverCoreAudio::set_input_device(const String &p_name) { - input_device_name = p_name; - if (active) { - _set_device(input_device_name, true); - } -} - PackedStringArray AudioDriverCoreAudio::get_input_device_list() { return _get_device_list(true); } @@ -669,6 +662,13 @@ String AudioDriverCoreAudio::get_input_device() { return input_device_name; } +void AudioDriverCoreAudio::set_input_device(const String &p_name) { + input_device_name = p_name; + if (active) { + _set_device(input_device_name, true); + } +} + #endif AudioDriverCoreAudio::AudioDriverCoreAudio() { diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h index 2b192e630e..67ff3f3efc 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.h +++ b/drivers/coreaudio/audio_driver_coreaudio.h @@ -83,39 +83,39 @@ class AudioDriverCoreAudio : public AudioDriver { UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData); - Error capture_init(); - void capture_finish(); + Error init_input_device(); + void finish_input_device(); public: - const char *get_name() const { + virtual const char *get_name() const override { return "CoreAudio"; }; - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const; - virtual SpeakerMode get_speaker_mode() const; + virtual Error init() override; + virtual void start() override; + virtual int get_mix_rate() const override; + virtual SpeakerMode get_speaker_mode() const override; - virtual void lock(); - virtual void unlock(); - virtual void finish(); - - virtual Error capture_start(); - virtual Error capture_stop(); - - bool try_lock(); - void stop(); + virtual void lock() override; + virtual void unlock() override; + virtual void finish() override; #ifdef MACOS_ENABLED - virtual PackedStringArray get_output_device_list(); - virtual String get_output_device(); - virtual void set_output_device(String output_device); + virtual PackedStringArray get_output_device_list() override; + virtual String get_output_device() override; + virtual void set_output_device(const String &p_name) override; - virtual PackedStringArray get_input_device_list(); - virtual void set_input_device(const String &p_name); - virtual String get_input_device(); + virtual PackedStringArray get_input_device_list() override; + virtual String get_input_device() override; + virtual void set_input_device(const String &p_name) override; #endif + virtual Error input_start() override; + virtual Error input_stop() override; + + bool try_lock(); + void stop(); + AudioDriverCoreAudio(); ~AudioDriverCoreAudio() {} }; diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index d08f7ba7b6..3c5441f3c4 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1128,6 +1128,12 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend state.canvas_instance_batches[state.current_batch_index].tex = mm->texture; state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_INSTANCED; + if (GLES3::MeshStorage::get_singleton()->multimesh_uses_colors(mm->multimesh)) { + state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_COLORS; + } + if (GLES3::MeshStorage::get_singleton()->multimesh_uses_custom_data(mm->multimesh)) { + state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_CUSTOM_DATA; + } } else if (c->type == Item::Command::TYPE_PARTICLES) { GLES3::ParticlesStorage *particles_storage = GLES3::ParticlesStorage::get_singleton(); GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton(); @@ -1136,6 +1142,8 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, RID p_rend RID particles = pt->particles; state.canvas_instance_batches[state.current_batch_index].tex = pt->texture; state.canvas_instance_batches[state.current_batch_index].shader_variant = CanvasShaderGLES3::MODE_INSTANCED; + state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_COLORS; + state.instance_data_array[r_index].flags |= FLAGS_INSTANCING_HAS_CUSTOM_DATA; if (particles_storage->particles_has_collision(particles) && texture_storage->render_target_is_sdf_enabled(p_render_target)) { // Pass collision information. @@ -2251,6 +2259,7 @@ void RasterizerCanvasGLES3::reset_canvas() { glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); glActiveTexture(GL_TEXTURE0 + GLES3::Config::get_singleton()->max_texture_image_units - 2); @@ -2684,6 +2693,7 @@ RasterizerCanvasGLES3::RasterizerCanvasGLES3() { // Default CanvasGroup shader. shader_type canvas_item; +render_mode unshaded; uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; @@ -2711,6 +2721,7 @@ void fragment() { // Default clip children shader. shader_type canvas_item; +render_mode unshaded; uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 672dcacd88..2e3e6263ed 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -179,7 +179,8 @@ typedef void (*DEBUGPROCARB)(GLenum source, typedef void (*DebugMessageCallbackARB)(DEBUGPROCARB callback, const void *userParam); void RasterizerGLES3::initialize() { - print_line("OpenGL Renderer: " + RS::get_singleton()->get_video_adapter_name()); + // NVIDIA suffixes all GPU model names with "/PCIe/SSE2" in OpenGL (but not Vulkan). This isn't necessary to display nowadays, so it can be trimmed. + print_line(vformat("OpenGL API %s - Compatibility - Using Device: %s - %s", RS::get_singleton()->get_video_adapter_api_version(), RS::get_singleton()->get_video_adapter_vendor(), RS::get_singleton()->get_video_adapter_name().trim_suffix("/PCIe/SSE2"))); } void RasterizerGLES3::finalize() { diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index 1631c65385..ea0a0b660d 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -162,9 +162,13 @@ void main() { vec2 uv = uv_attrib; #ifdef USE_INSTANCING - vec4 instance_color = vec4(unpackHalf2x16(instance_color_custom_data.x), unpackHalf2x16(instance_color_custom_data.y)); - color *= instance_color; - instance_custom = vec4(unpackHalf2x16(instance_color_custom_data.z), unpackHalf2x16(instance_color_custom_data.w)); + if (bool(read_draw_data_flags & FLAGS_INSTANCING_HAS_COLORS)) { + vec4 instance_color = vec4(unpackHalf2x16(instance_color_custom_data.x), unpackHalf2x16(instance_color_custom_data.y)); + color *= instance_color; + } + if (bool(read_draw_data_flags & FLAGS_INSTANCING_HAS_CUSTOM_DATA)) { + instance_custom = vec4(unpackHalf2x16(instance_color_custom_data.z), unpackHalf2x16(instance_color_custom_data.w)); + } #endif #else @@ -645,7 +649,7 @@ void main() { #ifdef MODE_LIGHT_ONLY color = vec4(0.0); -#else +#elif !defined(MODE_UNSHADED) color *= canvas_modulation; #endif diff --git a/drivers/gles3/shaders/stdlib_inc.glsl b/drivers/gles3/shaders/stdlib_inc.glsl index 8d4a24cc1f..0b76c4334a 100644 --- a/drivers/gles3/shaders/stdlib_inc.glsl +++ b/drivers/gles3/shaders/stdlib_inc.glsl @@ -2,13 +2,23 @@ #ifdef USE_GLES_OVER_GL // Floating point pack/unpack functions are part of the GLSL ES 300 specification used by web and mobile. uint float2half(uint f) { - return ((f >> uint(16)) & uint(0x8000)) | - ((((f & uint(0x7f800000)) - uint(0x38000000)) >> uint(13)) & uint(0x7c00)) | - ((f >> uint(13)) & uint(0x03ff)); + uint e = f & uint(0x7f800000); + if (e <= uint(0x38000000)) { + return uint(0); + } else { + return ((f >> uint(16)) & uint(0x8000)) | + (((e - uint(0x38000000)) >> uint(13)) & uint(0x7c00)) | + ((f >> uint(13)) & uint(0x03ff)); + } } uint half2float(uint h) { - return ((h & uint(0x8000)) << uint(16)) | (((h & uint(0x7c00)) + uint(0x1c000)) << uint(13)) | ((h & uint(0x03ff)) << uint(13)); + uint h_e = h & uint(0x7c00); + if (h_e == uint(0x0000)) { + return uint(0); + } else { + return ((h & uint(0x8000)) << uint(16)) | ((h_e + uint(0x1c000)) << uint(13)) | ((h & uint(0x03ff)) << uint(13)); + } } uint packHalf2x16(vec2 v) { diff --git a/drivers/gles3/storage/light_storage.cpp b/drivers/gles3/storage/light_storage.cpp index 138498220d..026f7467a8 100644 --- a/drivers/gles3/storage/light_storage.cpp +++ b/drivers/gles3/storage/light_storage.cpp @@ -311,6 +311,13 @@ uint64_t LightStorage::light_get_version(RID p_light) const { return light->version; } +uint32_t LightStorage::light_get_cull_mask(RID p_light) const { + const Light *light = light_owner.get_or_null(p_light); + ERR_FAIL_COND_V(!light, 0); + + return light->cull_mask; +} + AABB LightStorage::light_get_aabb(RID p_light) const { const Light *light = light_owner.get_or_null(p_light); ERR_FAIL_COND_V(!light, AABB()); diff --git a/drivers/gles3/storage/light_storage.h b/drivers/gles3/storage/light_storage.h index f6f7628a90..8e6480869b 100644 --- a/drivers/gles3/storage/light_storage.h +++ b/drivers/gles3/storage/light_storage.h @@ -239,13 +239,6 @@ public: return light->color; } - _FORCE_INLINE_ uint32_t light_get_cull_mask(RID p_light) { - const Light *light = light_owner.get_or_null(p_light); - ERR_FAIL_COND_V(!light, 0); - - return light->cull_mask; - } - _FORCE_INLINE_ bool light_is_distance_fade_enabled(RID p_light) { const Light *light = light_owner.get_or_null(p_light); return light->distance_fade; @@ -297,6 +290,7 @@ public: virtual RS::LightBakeMode light_get_bake_mode(RID p_light) override; virtual uint32_t light_get_max_sdfgi_cascade(RID p_light) override { return 0; } virtual uint64_t light_get_version(RID p_light) const override; + virtual uint32_t light_get_cull_mask(RID p_light) const override; /* LIGHT INSTANCE API */ diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index 3f8fddacff..36b34dd8a2 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -1835,8 +1835,12 @@ void MeshStorage::multimesh_set_visible_instances(RID p_multimesh, int p_visible } if (multimesh->data_cache.size()) { - //there is a data cache.. + // There is a data cache, but we may need to update some sections. _multimesh_mark_all_dirty(multimesh, false, true); + int start = multimesh->visible_instances >= 0 ? multimesh->visible_instances : multimesh->instances; + for (int i = start; i < p_visible; i++) { + _multimesh_mark_dirty(multimesh, i, true); + } } multimesh->visible_instances = p_visible; @@ -1868,7 +1872,7 @@ void MeshStorage::_update_dirty_multimeshes() { if (multimesh->data_cache_used_dirty_regions > 32 || multimesh->data_cache_used_dirty_regions > visible_region_count / 2) { // If there too many dirty regions, or represent the majority of regions, just copy all, else transfer cost piles up too much glBindBuffer(GL_ARRAY_BUFFER, multimesh->buffer); - glBufferData(GL_ARRAY_BUFFER, MIN(visible_region_count * region_size, multimesh->instances * multimesh->stride_cache * sizeof(float)), data, GL_STATIC_DRAW); + glBufferSubData(GL_ARRAY_BUFFER, 0, MIN(visible_region_count * region_size, multimesh->instances * multimesh->stride_cache * sizeof(float)), data); glBindBuffer(GL_ARRAY_BUFFER, 0); } else { // Not that many regions? update them all diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h index 017e74fc4d..fedda6b260 100644 --- a/drivers/gles3/storage/texture_storage.h +++ b/drivers/gles3/storage/texture_storage.h @@ -585,6 +585,7 @@ public: virtual void decal_set_normal_fade(RID p_decal, float p_fade) override; virtual AABB decal_get_aabb(RID p_decal) const override; + virtual uint32_t decal_get_cull_mask(RID p_decal) const override { return 0; } virtual void texture_add_to_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) override {} virtual void texture_remove_from_decal_atlas(RID p_texture, bool p_panorama_to_dp = false) override {} diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index f96247a473..0246af4fea 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -631,9 +631,9 @@ String AudioDriverPulseAudio::get_output_device() { return output_device_name; } -void AudioDriverPulseAudio::set_output_device(String output_device) { +void AudioDriverPulseAudio::set_output_device(const String &p_name) { lock(); - new_output_device = output_device; + new_output_device = p_name; unlock(); } @@ -761,12 +761,6 @@ Error AudioDriverPulseAudio::input_stop() { return OK; } -void AudioDriverPulseAudio::set_input_device(const String &p_name) { - lock(); - new_input_device = p_name; - unlock(); -} - void AudioDriverPulseAudio::pa_sourcelist_cb(pa_context *c, const pa_source_info *l, int eol, void *userdata) { AudioDriverPulseAudio *ad = static_cast<AudioDriverPulseAudio *>(userdata); @@ -821,6 +815,12 @@ String AudioDriverPulseAudio::get_input_device() { return name; } +void AudioDriverPulseAudio::set_input_device(const String &p_name) { + lock(); + new_input_device = p_name; + unlock(); +} + AudioDriverPulseAudio::AudioDriverPulseAudio() { samples_in.clear(); samples_out.clear(); diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h index 68df03cb60..f4ff44d361 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.h +++ b/drivers/pulseaudio/audio_driver_pulseaudio.h @@ -94,31 +94,30 @@ class AudioDriverPulseAudio : public AudioDriver { static void thread_func(void *p_udata); public: - const char *get_name() const { + virtual const char *get_name() const override { return "PulseAudio"; }; - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const; - virtual SpeakerMode get_speaker_mode() const; + virtual Error init() override; + virtual void start() override; + virtual int get_mix_rate() const override; + virtual SpeakerMode get_speaker_mode() const override; + virtual float get_latency() override; - virtual PackedStringArray get_output_device_list(); - virtual String get_output_device(); - virtual void set_output_device(String output_device); + virtual void lock() override; + virtual void unlock() override; + virtual void finish() override; - virtual PackedStringArray get_input_device_list(); - virtual void set_input_device(const String &p_name); - virtual String get_input_device(); + virtual PackedStringArray get_output_device_list() override; + virtual String get_output_device() override; + virtual void set_output_device(const String &p_name) override; - virtual void lock(); - virtual void unlock(); - virtual void finish(); + virtual Error input_start() override; + virtual Error input_stop() override; - virtual float get_latency(); - - virtual Error input_start(); - virtual Error input_stop(); + virtual PackedStringArray get_input_device_list() override; + virtual String get_input_device() override; + virtual void set_input_device(const String &p_name) override; AudioDriverPulseAudio(); ~AudioDriverPulseAudio() {} diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 58569dc69e..91a746636a 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -5927,7 +5927,7 @@ Error RenderingDeviceVulkan::buffer_clear(RID p_buffer, uint32_t p_offset, uint3 return OK; } -Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { +Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer, uint32_t p_offset, uint32_t p_size) { _THREAD_SAFE_METHOD_ // It could be this buffer was just created. @@ -5944,12 +5944,20 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { VkCommandBuffer command_buffer = frames[frame].setup_command_buffer; + // Size of buffer to retrieve. + if (!p_size) { + p_size = buffer->size; + } else { + ERR_FAIL_COND_V_MSG(p_size + p_offset > buffer->size, Vector<uint8_t>(), + "Size is larger than the buffer."); + } + Buffer tmp_buffer; - _buffer_allocate(&tmp_buffer, buffer->size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VMA_MEMORY_USAGE_AUTO_PREFER_HOST, VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT); + _buffer_allocate(&tmp_buffer, p_size, VK_BUFFER_USAGE_TRANSFER_DST_BIT, VMA_MEMORY_USAGE_AUTO_PREFER_HOST, VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT); VkBufferCopy region; - region.srcOffset = 0; + region.srcOffset = p_offset; region.dstOffset = 0; - region.size = buffer->size; + region.size = p_size; vkCmdCopyBuffer(command_buffer, buffer->buffer, tmp_buffer.buffer, 1, ®ion); // Dst buffer is in CPU, but I wonder if src buffer needs a barrier for this. // Flush everything so memory can be safely mapped. _flush(true); @@ -5960,9 +5968,9 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { Vector<uint8_t> buffer_data; { - buffer_data.resize(buffer->size); + buffer_data.resize(p_size); uint8_t *w = buffer_data.ptrw(); - memcpy(w, buffer_mem, buffer->size); + memcpy(w, buffer_mem, p_size); } vmaUnmapMemory(allocator, tmp_buffer.allocation); @@ -8454,14 +8462,17 @@ void RenderingDeviceVulkan::set_resource_name(RID p_id, const String p_name) { } void RenderingDeviceVulkan::draw_command_begin_label(String p_label_name, const Color p_color) { + _THREAD_SAFE_METHOD_ context->command_begin_label(frames[frame].draw_command_buffer, p_label_name, p_color); } void RenderingDeviceVulkan::draw_command_insert_label(String p_label_name, const Color p_color) { + _THREAD_SAFE_METHOD_ context->command_insert_label(frames[frame].draw_command_buffer, p_label_name, p_color); } void RenderingDeviceVulkan::draw_command_end_label() { + _THREAD_SAFE_METHOD_ context->command_end_label(frames[frame].draw_command_buffer); } diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index 63c6b97515..91a09fa970 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -1122,7 +1122,7 @@ public: virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS); // Works for any buffer. virtual Error buffer_clear(RID p_buffer, uint32_t p_offset, uint32_t p_size, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS); - virtual Vector<uint8_t> buffer_get_data(RID p_buffer); + virtual Vector<uint8_t> buffer_get_data(RID p_buffer, uint32_t p_offset = 0, uint32_t p_size = 0); /*************************/ /**** RENDER PIPELINE ****/ diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index d1391cb53e..179de8227a 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -1299,8 +1299,15 @@ Error VulkanContext::_create_physical_device(VkSurfaceKHR p_surface) { // Get device version device_api_version = gpu_props.apiVersion; + String rendering_method; + if (OS::get_singleton()->get_current_rendering_method() == "mobile") { + rendering_method = "Forward Mobile"; + } else { + rendering_method = "Forward+"; + } + // Output our device version - print_line("Vulkan API " + get_device_api_version() + " - " + "Using Vulkan Device #" + itos(device_index) + ": " + device_vendor + " - " + device_name); + print_line(vformat("Vulkan API %s - %s - Using Vulkan Device #%d: %s - %s", get_device_api_version(), rendering_method, device_index, device_vendor, device_name)); { Error _err = _initialize_device_extensions(); @@ -2264,7 +2271,7 @@ Error VulkanContext::prepare_buffers() { print_verbose("Vulkan: Early suboptimal swapchain."); break; } else if (err != VK_SUCCESS) { - ERR_BREAK_MSG(err != VK_SUCCESS, "Vulkan: Did not create swapchain successfully."); + ERR_BREAK_MSG(err != VK_SUCCESS, "Vulkan: Did not create swapchain successfully. Error code: " + String(string_VkResult(err))); } else { w->semaphore_acquired = true; } @@ -2341,7 +2348,7 @@ Error VulkanContext::swap_buffers() { submit_info.signalSemaphoreCount = 1; submit_info.pSignalSemaphores = &draw_complete_semaphores[frame_index]; err = vkQueueSubmit(graphics_queue, 1, &submit_info, fences[frame_index]); - ERR_FAIL_COND_V(err, ERR_CANT_CREATE); + ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Vulkan: Cannot submit graphics queue. Error code: " + String(string_VkResult(err))); command_buffer_queue.write[0] = nullptr; command_buffer_count = 1; @@ -2372,7 +2379,7 @@ Error VulkanContext::swap_buffers() { submit_info.signalSemaphoreCount = 1; submit_info.pSignalSemaphores = &image_ownership_semaphores[frame_index]; err = vkQueueSubmit(present_queue, 1, &submit_info, nullFence); - ERR_FAIL_COND_V(err, ERR_CANT_CREATE); + ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Vulkan: Cannot submit present queue. Error code: " + String(string_VkResult(err))); } // If we are using separate queues, we have to wait for image ownership, @@ -2481,14 +2488,14 @@ Error VulkanContext::swap_buffers() { if (err == VK_ERROR_OUT_OF_DATE_KHR) { // Swapchain is out of date (e.g. the window was resized) and // must be recreated. - print_verbose("Vulkan: Swapchain is out of date, recreating."); + print_verbose("Vulkan queue submit: Swapchain is out of date, recreating."); resize_notify(); } else if (err == VK_SUBOPTIMAL_KHR) { // Swapchain is not as optimal as it could be, but the platform's // presentation engine will still present the image correctly. - print_verbose("Vulkan: Swapchain is suboptimal."); + print_verbose("Vulkan queue submit: Swapchain is suboptimal."); } else { - ERR_FAIL_COND_V(err, ERR_CANT_CREATE); + ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Error code: " + String(string_VkResult(err))); } buffers_prepared = false; diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index 42a2b85200..72ec0c19ab 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -634,9 +634,9 @@ String AudioDriverWASAPI::get_output_device() { return name; } -void AudioDriverWASAPI::set_output_device(String output_device) { +void AudioDriverWASAPI::set_output_device(const String &p_name) { lock(); - audio_output.new_device = output_device; + audio_output.new_device = p_name; unlock(); } @@ -964,12 +964,6 @@ Error AudioDriverWASAPI::input_stop() { return FAILED; } -void AudioDriverWASAPI::set_input_device(const String &p_name) { - lock(); - audio_input.new_device = p_name; - unlock(); -} - PackedStringArray AudioDriverWASAPI::get_input_device_list() { return audio_device_get_list(true); } @@ -982,6 +976,12 @@ String AudioDriverWASAPI::get_input_device() { return name; } +void AudioDriverWASAPI::set_input_device(const String &p_name) { + lock(); + audio_input.new_device = p_name; + unlock(); +} + AudioDriverWASAPI::AudioDriverWASAPI() { samples_in.clear(); } diff --git a/drivers/wasapi/audio_driver_wasapi.h b/drivers/wasapi/audio_driver_wasapi.h index bf18ba8c99..367c30607a 100644 --- a/drivers/wasapi/audio_driver_wasapi.h +++ b/drivers/wasapi/audio_driver_wasapi.h @@ -94,27 +94,30 @@ class AudioDriverWASAPI : public AudioDriver { PackedStringArray audio_device_get_list(bool p_input); public: - virtual const char *get_name() const { + virtual const char *get_name() const override { return "WASAPI"; } - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const; - virtual float get_latency(); - virtual SpeakerMode get_speaker_mode() const; - virtual PackedStringArray get_output_device_list(); - virtual String get_output_device(); - virtual void set_output_device(String output_device); - virtual void lock(); - virtual void unlock(); - virtual void finish(); - - virtual Error input_start(); - virtual Error input_stop(); - virtual PackedStringArray get_input_device_list(); - virtual void set_input_device(const String &p_name); - virtual String get_input_device(); + virtual Error init() override; + virtual void start() override; + virtual int get_mix_rate() const override; + virtual SpeakerMode get_speaker_mode() const override; + virtual float get_latency() override; + + virtual void lock() override; + virtual void unlock() override; + virtual void finish() override; + + virtual PackedStringArray get_output_device_list() override; + virtual String get_output_device() override; + virtual void set_output_device(const String &p_name) override; + + virtual Error input_start() override; + virtual Error input_stop() override; + + virtual PackedStringArray get_input_device_list() override; + virtual String get_input_device() override; + virtual void set_input_device(const String &p_name) override; AudioDriverWASAPI(); }; diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp index cd1b29e17d..44ce01d4d7 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.cpp +++ b/drivers/xaudio2/audio_driver_xaudio2.cpp @@ -33,10 +33,6 @@ #include "core/config/project_settings.h" #include "core/os/os.h" -const char *AudioDriverXAudio2::get_name() const { - return "XAudio2"; -} - Error AudioDriverXAudio2::init() { active.clear(); exit_thread.clear(); diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h index df5ef52e88..c659b6ffdc 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.h +++ b/drivers/xaudio2/audio_driver_xaudio2.h @@ -91,16 +91,19 @@ class AudioDriverXAudio2 : public AudioDriver { XAudio2DriverVoiceCallback voice_callback; public: - const char *get_name() const; - - virtual Error init(); - virtual void start(); - virtual int get_mix_rate() const; - virtual SpeakerMode get_speaker_mode() const; - virtual float get_latency(); - virtual void lock(); - virtual void unlock(); - virtual void finish(); + virtual const char *get_name() const override { + return "XAudio2"; + } + + virtual Error init() override; + virtual void start() override; + virtual int get_mix_rate() const override; + virtual SpeakerMode get_speaker_mode() const override; + virtual float get_latency() override; + + virtual void lock() override; + virtual void unlock() override; + virtual void finish() override; AudioDriverXAudio2(); ~AudioDriverXAudio2() {} |