diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/unix/os_unix.cpp | 10 | ||||
-rw-r--r-- | drivers/vulkan/rendering_device_vulkan.cpp | 84 | ||||
-rw-r--r-- | drivers/vulkan/vulkan_context.cpp | 36 |
3 files changed, 44 insertions, 86 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index d21b095037..458488f3e9 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -32,6 +32,8 @@ #ifdef UNIX_ENABLED +#include "core/debugger/engine_debugger.h" +#include "core/debugger/script_debugger.h" #include "core/os/thread_dummy.h" #include "core/project_settings.h" #include "drivers/unix/dir_access_unix.h" @@ -94,16 +96,16 @@ void OS_Unix::debug_break() { }; static void handle_interrupt(int sig) { - if (ScriptDebugger::get_singleton() == NULL) + if (!EngineDebugger::is_active()) return; - ScriptDebugger::get_singleton()->set_depth(-1); - ScriptDebugger::get_singleton()->set_lines_left(1); + EngineDebugger::get_script_debugger()->set_depth(-1); + EngineDebugger::get_script_debugger()->set_lines_left(1); } void OS_Unix::initialize_debugging() { - if (ScriptDebugger::get_singleton() != NULL) { + if (EngineDebugger::is_active()) { struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = handle_interrupt; diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 3b0d1f6ac3..361982b28d 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -1252,7 +1252,7 @@ Error RenderingDeviceVulkan::_buffer_allocate(Buffer *p_buffer, uint32_t p_size, allocInfo.pUserData = NULL; VkResult err = vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &p_buffer->buffer, &p_buffer->allocation, NULL); - ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Can't create buffer of size: " + itos(p_size)); + ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "Can't create buffer of size: " + itos(p_size) + ", error " + itos(err) + "."); p_buffer->size = p_size; p_buffer->buffer_info.buffer = p_buffer->buffer; p_buffer->buffer_info.offset = 0; @@ -1296,7 +1296,7 @@ Error RenderingDeviceVulkan::_insert_staging_block() { StagingBufferBlock block; VkResult err = vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &block.buffer, &block.allocation, NULL); - ERR_FAIL_COND_V(err, ERR_CANT_CREATE); + ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vmaCreateBuffer failed with error " + itos(err) + "."); block.frame_used = 0; block.fill_amount = 0; @@ -1462,9 +1462,7 @@ Error RenderingDeviceVulkan::_buffer_update(Buffer *p_buffer, size_t p_offset, c void *data_ptr = NULL; { VkResult vkerr = vmaMapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation, &data_ptr); - if (vkerr) { - ERR_FAIL_V(ERR_CANT_CREATE); - } + ERR_FAIL_COND_V_MSG(vkerr, ERR_CANT_CREATE, "vmaMapMemory failed with error " + itos(vkerr) + "."); } //copy to staging buffer @@ -1752,7 +1750,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T Texture texture; VkResult err = vmaCreateImage(allocator, &image_create_info, &allocInfo, &texture.image, &texture.allocation, &texture.allocation_info); - ERR_FAIL_COND_V(err, RID()); + ERR_FAIL_COND_V_MSG(err, RID(), "vmaCreateImage failed with error " + itos(err) + "."); texture.type = p_format.type; texture.format = p_format.format; @@ -1858,7 +1856,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T if (err) { vmaDestroyImage(allocator, texture.image, texture.allocation); - ERR_FAIL_V(RID()); + ERR_FAIL_V_MSG(RID(), "vkCreateImageView failed with error " + itos(err) + "."); } //barrier to set layout @@ -1964,10 +1962,7 @@ RID RenderingDeviceVulkan::texture_create_shared(const TextureView &p_view, RID } VkResult err = vkCreateImageView(device, &image_view_create_info, NULL, &texture.view); - - if (err) { - ERR_FAIL_V(RID()); - } + ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateImageView failed with error " + itos(err) + "."); texture.owner = p_with_texture; RID id = texture_owner.make_rid(texture); @@ -2065,10 +2060,7 @@ RID RenderingDeviceVulkan::texture_create_shared_from_slice(const TextureView &p } VkResult err = vkCreateImageView(device, &image_view_create_info, NULL, &texture.view); - - if (err) { - ERR_FAIL_V(RID()); - } + ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateImageView failed with error " + itos(err) + "."); texture.owner = p_with_texture; RID id = texture_owner.make_rid(texture); @@ -2179,9 +2171,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con { //map void *data_ptr = NULL; VkResult vkerr = vmaMapMemory(allocator, staging_buffer_blocks[staging_buffer_current].allocation, &data_ptr); - if (vkerr) { - ERR_FAIL_V(ERR_CANT_CREATE); - } + ERR_FAIL_COND_V_MSG(vkerr, ERR_CANT_CREATE, "vmaMapMemory failed with error " + itos(vkerr) + "."); write_ptr = (uint8_t *)data_ptr; write_ptr += alloc_offset; } @@ -2468,9 +2458,7 @@ Vector<uint8_t> RenderingDeviceVulkan::texture_get_data(RID p_texture, uint32_t void *buffer_mem; VkResult vkerr = vmaMapMemory(allocator, tmp_buffer.allocation, &buffer_mem); - if (vkerr) { - ERR_FAIL_V(Vector<uint8_t>()); - } + ERR_FAIL_COND_V_MSG(vkerr, Vector<uint8_t>(), "vmaMapMemory failed with error " + itos(vkerr) + "."); Vector<uint8_t> buffer_data; { @@ -2977,7 +2965,7 @@ VkRenderPass RenderingDeviceVulkan::_render_pass_create(const Vector<AttachmentF VkRenderPass render_pass; VkResult res = vkCreateRenderPass(device, &render_pass_create_info, NULL, &render_pass); - ERR_FAIL_COND_V(res, VK_NULL_HANDLE); + ERR_FAIL_COND_V_MSG(res, VK_NULL_HANDLE, "vkCreateRenderPass failed with error " + itos(res) + "."); if (r_color_attachment_count) { *r_color_attachment_count = color_references.size(); @@ -3126,7 +3114,7 @@ RID RenderingDeviceVulkan::sampler_create(const SamplerState &p_state) { VkSampler sampler; VkResult res = vkCreateSampler(device, &sampler_create_info, NULL, &sampler); - ERR_FAIL_COND_V(res, RID()); + ERR_FAIL_COND_V_MSG(res, RID(), "vkCreateSampler failed with error " + itos(res) + "."); return sampler_owner.make_rid(sampler); } @@ -3880,7 +3868,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages VkResult res = vkCreateShaderModule(device, &shader_module_create_info, NULL, &module); if (res) { success = false; - error_text = "Error creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage]); + error_text = "Error (" + itos(res) + ") creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage]); break; } @@ -3920,7 +3908,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages VkDescriptorSetLayout layout; VkResult res = vkCreateDescriptorSetLayout(device, &layout_create_info, NULL, &layout); if (res) { - error_text = "Error creating descriptor set layout for set " + itos(i); + error_text = "Error (" + itos(res) + ") creating descriptor set layout for set " + itos(i); success = false; break; } @@ -3983,7 +3971,7 @@ RID RenderingDeviceVulkan::shader_create(const Vector<ShaderStageData> &p_stages VkResult err = vkCreatePipelineLayout(device, &pipeline_layout_create_info, NULL, &shader.pipeline_layout); if (err) { - error_text = "Error creating pipeline layout."; + error_text = "Error (" + itos(err) + ") creating pipeline layout."; success = false; } } @@ -4088,7 +4076,7 @@ RID RenderingDeviceVulkan::texture_buffer_create(uint32_t p_size_elements, DataF VkResult res = vkCreateBufferView(device, &view_create_info, NULL, &texture_buffer.view); if (res) { _buffer_free(&texture_buffer.buffer); - ERR_FAIL_V_MSG(RID(), "Unable to create buffer view"); + ERR_FAIL_V_MSG(RID(), "Unable to create buffer view, error " + itos(res) + "."); } //allocate the view @@ -4184,7 +4172,7 @@ RenderingDeviceVulkan::DescriptorPool *RenderingDeviceVulkan::_descriptor_pool_a VkResult res = vkCreateDescriptorPool(device, &descriptor_pool_create_info, NULL, &pool->pool); if (res) { memdelete(pool); - ERR_FAIL_COND_V(res, NULL); + ERR_FAIL_COND_V_MSG(res, NULL, "vkCreateDescriptorPool failed with error " + itos(res) + "."); } descriptor_pools[p_key].insert(pool); } @@ -4600,7 +4588,7 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, VkResult res = vkAllocateDescriptorSets(device, &descriptor_set_allocate_info, &descriptor_set); if (res) { _descriptor_pool_free(pool_key, pool); // meh - ERR_FAIL_V_MSG(RID(), "Cannot allocate descriptor sets."); + ERR_FAIL_V_MSG(RID(), "Cannot allocate descriptor sets, error " + itos(res) + "."); } UniformSet uniform_set; @@ -4722,9 +4710,7 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) { void *buffer_mem; VkResult vkerr = vmaMapMemory(allocator, tmp_buffer.allocation, &buffer_mem); - if (vkerr) { - ERR_FAIL_V(Vector<uint8_t>()); - } + ERR_FAIL_COND_V_MSG(vkerr, Vector<uint8_t>(), "vmaMapMemory failed with error " + itos(vkerr) + "."); Vector<uint8_t> buffer_data; { @@ -5067,7 +5053,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma RenderPipeline pipeline; VkResult err = vkCreateGraphicsPipelines(device, NULL, 1, &graphics_pipeline_create_info, NULL, &pipeline.pipeline); - ERR_FAIL_COND_V(err, RID()); + ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateGraphicsPipelines failed with error " + itos(err) + "."); pipeline.set_formats = shader->set_formats; pipeline.push_constant_stages = shader->push_constant.push_constants_vk_stage; @@ -5140,7 +5126,7 @@ RID RenderingDeviceVulkan::compute_pipeline_create(RID p_shader) { ComputePipeline pipeline; VkResult err = vkCreateComputePipelines(device, NULL, 1, &compute_pipeline_create_info, NULL, &pipeline.pipeline); - ERR_FAIL_COND_V(err, RID()); + ERR_FAIL_COND_V_MSG(err, RID(), "vkCreateComputePipelines failed with error " + itos(err) + "."); pipeline.set_formats = shader->set_formats; pipeline.push_constant_stages = shader->push_constant.push_constants_vk_stage; @@ -5300,7 +5286,7 @@ Error RenderingDeviceVulkan::_draw_list_setup_framebuffer(Framebuffer *p_framebu framebuffer_create_info.layers = 1; VkResult err = vkCreateFramebuffer(device, &framebuffer_create_info, NULL, &version.framebuffer); - ERR_FAIL_COND_V(err, ERR_CANT_CREATE); + ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vkCreateFramebuffer failed with error " + itos(err) + "."); p_framebuffer->framebuffers.insert(vk, version); } @@ -5561,7 +5547,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; VkResult res = vkCreateCommandPool(device, &cmd_pool_info, NULL, &split_draw_list_allocators.write[i].command_pool); - ERR_FAIL_COND_V(res, ERR_CANT_CREATE); + ERR_FAIL_COND_V_MSG(res, ERR_CANT_CREATE, "vkCreateCommandPool failed with error " + itos(res) + "."); for (int j = 0; j < frame_count; j++) { @@ -5576,7 +5562,7 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p cmdbuf.commandBufferCount = 1; VkResult err = vkAllocateCommandBuffers(device, &cmdbuf, &command_buffer); - ERR_FAIL_COND_V(err, ERR_CANT_CREATE); + ERR_FAIL_COND_V_MSG(err, ERR_CANT_CREATE, "vkAllocateCommandBuffers failed with error " + itos(err) + "."); split_draw_list_allocators.write[i].command_buffers.push_back(command_buffer); } @@ -5625,14 +5611,14 @@ Error RenderingDeviceVulkan::draw_list_begin_split(RID p_framebuffer, uint32_t p if (res) { memdelete_arr(draw_list); draw_list = NULL; - ERR_FAIL_V(ERR_CANT_CREATE); + ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkResetCommandBuffer failed with error " + itos(res) + "."); } res = vkBeginCommandBuffer(command_buffer, &cmdbuf_begin); if (res) { memdelete_arr(draw_list); draw_list = NULL; - ERR_FAIL_V(ERR_CANT_CREATE); + ERR_FAIL_V_MSG(ERR_CANT_CREATE, "vkBeginCommandBuffer failed with error " + itos(res) + "."); } draw_list[i].command_buffer = command_buffer; @@ -6566,13 +6552,13 @@ void RenderingDeviceVulkan::swap_buffers() { cmdbuf_begin.pInheritanceInfo = NULL; VkResult err = vkResetCommandBuffer(frames[frame].setup_command_buffer, 0); - ERR_FAIL_COND(err); + ERR_FAIL_COND_MSG(err, "vkResetCommandBuffer failed with error " + itos(err) + "."); err = vkBeginCommandBuffer(frames[frame].setup_command_buffer, &cmdbuf_begin); - ERR_FAIL_COND(err); + ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); context->set_setup_buffer(frames[frame].setup_command_buffer); //append now so it's added before everything else err = vkBeginCommandBuffer(frames[frame].draw_command_buffer, &cmdbuf_begin); - ERR_FAIL_COND(err); + ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); context->append_command_buffer(frames[frame].draw_command_buffer); } @@ -6727,7 +6713,7 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) { cmdbuf_begin.pInheritanceInfo = NULL; VkResult err = vkBeginCommandBuffer(frames[frame].setup_command_buffer, &cmdbuf_begin); - ERR_FAIL_COND(err); + ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); context->set_setup_buffer(frames[frame].setup_command_buffer); //append now so it's added before everything else } @@ -6739,7 +6725,7 @@ void RenderingDeviceVulkan::_flush(bool p_current_frame) { cmdbuf_begin.pInheritanceInfo = NULL; VkResult err = vkBeginCommandBuffer(frames[frame].draw_command_buffer, &cmdbuf_begin); - ERR_FAIL_COND(err); + ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); context->append_command_buffer(frames[frame].draw_command_buffer); } } @@ -6776,7 +6762,7 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) { cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; VkResult res = vkCreateCommandPool(device, &cmd_pool_info, NULL, &frames[i].command_pool); - ERR_FAIL_COND(res); + ERR_FAIL_COND_MSG(res, "vkCreateCommandPool failed with error " + itos(res) + "."); } { //create command buffers @@ -6790,10 +6776,10 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) { cmdbuf.commandBufferCount = 1; VkResult err = vkAllocateCommandBuffers(device, &cmdbuf, &frames[i].setup_command_buffer); - ERR_CONTINUE(err); + ERR_CONTINUE_MSG(err, "vkAllocateCommandBuffers failed with error " + itos(err) + "."); err = vkAllocateCommandBuffers(device, &cmdbuf, &frames[i].draw_command_buffer); - ERR_CONTINUE(err); + ERR_CONTINUE_MSG(err, "vkAllocateCommandBuffers failed with error " + itos(err) + "."); } { @@ -6828,11 +6814,11 @@ void RenderingDeviceVulkan::initialize(VulkanContext *p_context) { cmdbuf_begin.pInheritanceInfo = NULL; VkResult err = vkBeginCommandBuffer(frames[0].setup_command_buffer, &cmdbuf_begin); - ERR_FAIL_COND(err); + ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); context->set_setup_buffer(frames[0].setup_command_buffer); //append now so it's added before everything else err = vkBeginCommandBuffer(frames[0].draw_command_buffer, &cmdbuf_begin); - ERR_FAIL_COND(err); + ERR_FAIL_COND_MSG(err, "vkBeginCommandBuffer failed with error " + itos(err) + "."); context->append_command_buffer(frames[0].draw_command_buffer); } diff --git a/drivers/vulkan/vulkan_context.cpp b/drivers/vulkan/vulkan_context.cpp index 038cae7f96..c8ff342713 100644 --- a/drivers/vulkan/vulkan_context.cpp +++ b/drivers/vulkan/vulkan_context.cpp @@ -356,39 +356,8 @@ Error VulkanContext::_create_physical_device() { free(physical_devices); ERR_FAIL_V(ERR_CANT_CREATE); } - - /*Find the first discrete GPU with the most VRAM.*/ - { - print_line("Selecting primary GPU."); - VkPhysicalDeviceProperties device_properties; - VkPhysicalDeviceMemoryProperties memory_properties; - gpu = physical_devices[0]; - uint32_t largest_vram_size = 0; - VkPhysicalDeviceType gpu_type = VK_PHYSICAL_DEVICE_TYPE_OTHER; - for (uint32_t i = 0; i < gpu_count; i++) { - vkGetPhysicalDeviceProperties(physical_devices[i], &device_properties); - - /*Skip virtual and CPU devices for now.*/ - if (device_properties.deviceType > VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) { - continue; - } - - vkGetPhysicalDeviceMemoryProperties(physical_devices[i], &memory_properties); - - /*Total all heaps in case of 3GB+1GB configurations and similar.*/ - uint32_t memory_size = 0; - for (uint32_t j = 0; j < memory_properties.memoryHeapCount; j++) { - memory_size += memory_properties.memoryHeaps[j].size; - } - - if ((device_properties.deviceType >= gpu_type) || (device_properties.deviceType == gpu_type && memory_size > largest_vram_size)) { - gpu = physical_devices[i]; - gpu_type = device_properties.deviceType; - largest_vram_size = memory_size; - print_line(device_properties.deviceName); - } - } - } + /* for now, just grab the first physical device */ + gpu = physical_devices[0]; free(physical_devices); /* Look for device extensions */ @@ -1514,6 +1483,7 @@ VkPhysicalDeviceLimits VulkanContext::get_device_limits() const { } VulkanContext::VulkanContext() { + queue_props = NULL; command_buffer_count = 0; instance_validation_layers = NULL; use_validation_layers = true; |