diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dummy/rasterizer_dummy.h | 2 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_canvas_gles2.cpp | 10 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.cpp | 2 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_storage_gles2.h | 2 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.cpp | 11 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 2 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.h | 2 | ||||
-rw-r--r-- | drivers/vulkan/rendering_device_vulkan.cpp | 84 | ||||
-rw-r--r-- | drivers/vulkan/rendering_device_vulkan.h | 14 |
9 files changed, 84 insertions, 45 deletions
diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index ea99655cb6..648a8f8d44 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -701,7 +701,7 @@ public: void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) {} void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {} bool render_target_was_used(RID p_render_target) { return false; } - void render_target_clear_used(RID p_render_target) {} + void render_target_clear_used_flag(RID p_render_target) {} void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) {} /* CANVAS SHADOW */ diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp index bdbe24524d..24927c4bb8 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.cpp +++ b/drivers/gles2/rasterizer_canvas_gles2.cpp @@ -1033,11 +1033,11 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur #ifdef GLES_OVER_GL if (polygon->antialiased) { glEnable(GL_LINE_SMOOTH); - if (polygon->antialiasing_use_indices) { - _draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1); - } else { - _draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1); - } + // FIXME: Removed during Vulkan rebase. + //if (polygon->antialiasing_use_indices) { + // _draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1); + //} else + _draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1); glDisable(GL_LINE_SMOOTH); } #endif diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 17f0565acf..0b44234173 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -5358,7 +5358,7 @@ bool RasterizerStorageGLES2::render_target_was_used(RID p_render_target) { return rt->used_in_frame; } -void RasterizerStorageGLES2::render_target_clear_used(RID p_render_target) { +void RasterizerStorageGLES2::render_target_clear_used_flag(RID p_render_target) { RenderTarget *rt = render_target_owner.getornull(p_render_target); ERR_FAIL_COND(!rt); diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index e8dde78760..de4dfe3f46 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -1247,7 +1247,7 @@ public: virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value); virtual bool render_target_was_used(RID p_render_target); - virtual void render_target_clear_used(RID p_render_target); + virtual void render_target_clear_used_flag(RID p_render_target); virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa); /* CANVAS SHADOW */ diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 9e1b302a03..0117d2b89b 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -901,11 +901,12 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur #ifdef GLES_OVER_GL if (polygon->antialiased) { glEnable(GL_LINE_SMOOTH); - if (polygon->antialiasing_use_indices) { - _draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1); - } else { - _draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1); - } + // FIXME: Removed during Vulkan rebase. + //if (polygon->antialiasing_use_indices) { + // _draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1); + //} else + _draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1); + glDisable(GL_LINE_SMOOTH); } #endif diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 0113c5335d..5542f06eb6 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -7594,7 +7594,7 @@ bool RasterizerStorageGLES3::render_target_was_used(RID p_render_target) { return rt->used_in_frame; } -void RasterizerStorageGLES3::render_target_clear_used(RID p_render_target) { +void RasterizerStorageGLES3::render_target_clear_used_flag(RID p_render_target) { RenderTarget *rt = render_target_owner.getornull(p_render_target); ERR_FAIL_COND(!rt); diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 7de19eb8a4..4137ab44fb 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -1404,7 +1404,7 @@ public: virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value); virtual bool render_target_was_used(RID p_render_target); - virtual void render_target_clear_used(RID p_render_target); + virtual void render_target_clear_used_flag(RID p_render_target); virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa); /* CANVAS SHADOW */ diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 7e9d40df19..d3ab21c43d 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -1023,7 +1023,7 @@ uint32_t RenderingDeviceVulkan::get_image_format_required_size(DataFormat p_form uint32_t blockw, blockh; get_compressed_image_format_block_dimensions(p_format, blockw, blockh); - for (uint32_t i = 0; i <= p_mipmaps; i++) { + for (uint32_t i = 0; i < p_mipmaps; i++) { uint32_t bw = w % blockw != 0 ? w + (blockw - w % blockw) : w; uint32_t bh = h % blockh != 0 ? h + (blockh - h % blockh) : h; @@ -2049,7 +2049,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con return OK; } -bool RenderingDeviceVulkan::texture_is_format_supported_for_usage(DataFormat p_format, TextureUsageBits p_usage) const { +bool RenderingDeviceVulkan::texture_is_format_supported_for_usage(DataFormat p_format, uint32_t p_usage) const { ERR_FAIL_INDEX_V(p_format, DATA_FORMAT_MAX, false); _THREAD_SAFE_METHOD_ @@ -2745,6 +2745,10 @@ static const char *shader_stage_names[RenderingDevice::SHADER_STAGE_MAX] = { "Compute" }; +static const char *shader_uniform_names[RenderingDevice::UNIFORM_TYPE_MAX] = { + "Sampler", "CombinedSampler", "Texture", "Image", "TextureBuffer", "SamplerTextureBuffer", "ImageBuffer", "UniformBuffer", "StorageBuffer", "InputAttachment" +}; + static VkShaderStageFlagBits shader_stage_masks[RenderingDevice::SHADER_STAGE_MAX] = { VK_SHADER_STAGE_VERTEX_BIT, VK_SHADER_STAGE_FRAGMENT_BIT, @@ -2758,26 +2762,24 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa VkDescriptorSetLayoutBinding layout_binding; Shader::UniformInfo info; - print_line("*** Stage " + itos(p_stage) + " uniform: " + reflection.name.c_str()); - switch (reflection.getType()->getBasicType()) { case glslang::EbtSampler: { - print_line("DEBUG: IsSampler"); + //print_line("DEBUG: IsSampler"); if (reflection.getType()->getSampler().dim == glslang::EsdBuffer) { //texture buffers if (reflection.getType()->getSampler().isCombined()) { layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; info.type = UNIFORM_TYPE_SAMPLER_WITH_TEXTURE_BUFFER; - print_line("DEBUG: texel combined"); + //print_line("DEBUG: SAMPLER: texel combined"); } else if (reflection.getType()->getSampler().isTexture()) { layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; info.type = UNIFORM_TYPE_TEXTURE_BUFFER; - print_line("DEBUG: texel alone"); + //print_line("DEBUG: SAMPLER: texel alone"); } else if (reflection.getType()->getSampler().isImage()) { layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; info.type = UNIFORM_TYPE_IMAGE_BUFFER; - print_line("DEBUG: texel buffer"); + //print_line("DEBUG: SAMPLER: texel buffer"); } else { if (r_error) { *r_error = "On shader stage '" + String(shader_stage_names[p_stage]) + "', uniform '" + reflection.name.c_str() + "' is of unsupported buffer type."; @@ -2787,21 +2789,21 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa } else if (reflection.getType()->getSampler().isCombined()) { layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; info.type = UNIFORM_TYPE_SAMPLER_WITH_TEXTURE; - print_line("DEBUG: combined"); + //print_line("DEBUG: SAMPLER: combined"); } else if (reflection.getType()->getSampler().isPureSampler()) { layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; info.type = UNIFORM_TYPE_SAMPLER; - print_line("DEBUG: sampler"); + //print_line("DEBUG: SAMPLER: sampler"); } else if (reflection.getType()->getSampler().isTexture()) { layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; info.type = UNIFORM_TYPE_TEXTURE; - print_line("DEBUG: image"); + //print_line("DEBUG: SAMPLER: image"); } else if (reflection.getType()->getSampler().isImage()) { layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; info.type = UNIFORM_TYPE_IMAGE; - print_line("DEBUG: storage image"); + //print_line("DEBUG: SAMPLER: storage image"); } else { - print_line("DEBUG: sampler unknown"); + //print_line("DEBUG: sampler unknown"); if (r_error) { *r_error = "On shader stage '" + String(shader_stage_names[p_stage]) + "', uniform '" + reflection.name.c_str() + "' is of unsupported sampler type."; } @@ -2810,7 +2812,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa if (reflection.getType()->isArray()) { layout_binding.descriptorCount = reflection.getType()->getArraySizes()->getCumulativeSize(); - print_line("DEBUG: array of size: " + itos(layout_binding.descriptorCount)); + //print_line("DEBUG: array of size: " + itos(layout_binding.descriptorCount)); } else { layout_binding.descriptorCount = 1; } @@ -2823,7 +2825,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa } break;*/ case glslang::EbtBlock: { - print_line("DEBUG: Block"); + //print_line("DEBUG: Block"); if (reflection.getType()->getQualifier().storage == glslang::EvqUniform) { if (reflection.getType()->getQualifier().layoutPushConstant) { uint32_t len = reflection.size; @@ -2835,13 +2837,13 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa push_constant.push_constants_vk_stage |= shader_stage_masks[p_stage]; return true; } - print_line("DEBUG: Uniform buffer"); + //print_line("DEBUG: Uniform buffer"); layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; info.type = UNIFORM_TYPE_UNIFORM_BUFFER; } else if (reflection.getType()->getQualifier().storage == glslang::EvqBuffer) { layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; info.type = UNIFORM_TYPE_STORAGE_BUFFER; - print_line("DEBUG: Storage buffer"); + //print_line("DEBUG: Storage buffer"); } else { if (r_error) { *r_error = "On shader stage '" + String(shader_stage_names[p_stage]) + "', uniform '" + reflection.name.c_str() + "' is of unsupported block type: (" + itos(reflection.getType()->getQualifier().storage) + ")."; @@ -2851,7 +2853,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa if (reflection.getType()->isArray()) { layout_binding.descriptorCount = reflection.getType()->getArraySizes()->getCumulativeSize(); - print_line("DEBUG: array of size: " + itos(layout_binding.descriptorCount)); + //print_line("DEBUG: array of size: " + itos(layout_binding.descriptorCount)); } else { layout_binding.descriptorCount = 1; } @@ -2935,14 +2937,16 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa bindings.resize(set + 1); uniform_infos.resize(set + 1); } - +#if 1 + print_line("stage: " + String(shader_stage_names[p_stage]) + " set: " + itos(set) + " binding: " + itos(info.binding) + " type:" + shader_uniform_names[info.type] + " length: " + itos(info.length)); +#endif bindings.write[set].push_back(layout_binding); uniform_infos.write[set].push_back(info); return true; } -RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSource> &p_stages, String *r_error, bool p_allow_cache) { +RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSource> &p_stages, String *r_error, ShaderStage *r_error_stage, bool p_allow_cache) { _THREAD_SAFE_METHOD_ @@ -3007,6 +3011,10 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou (*r_error) += shader.getInfoDebugLog(); } + if (r_error_stage) { + *r_error_stage = p_stages[i].shader_stage; + } + return RID(); } //set back.. @@ -3021,6 +3029,10 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou (*r_error) += "\n"; (*r_error) += shader.getInfoDebugLog(); } + if (r_error_stage) { + *r_error_stage = p_stages[i].shader_stage; + } + return RID(); } @@ -3035,13 +3047,17 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou (*r_error) += "\n"; (*r_error) += program.getInfoDebugLog(); } + if (r_error_stage) { + *r_error_stage = p_stages[i].shader_stage; + } + return RID(); } //obtain bindings for descriptor layout program.mapIO(); program.buildReflection(); - program.dumpReflection(); + //program.dumpReflection(); for (int j = 0; j < program.getNumUniformVariables(); j++) { if (!_uniform_add_binding(bindings, uniform_info, program.getUniform(j), p_stages[i].shader_stage, push_constant, r_error)) { @@ -3102,6 +3118,8 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou shader.fragment_outputs = fragment_outputs; shader.push_constant = push_constant; + String error_text; + bool success = true; for (int i = 0; i < p_stages.size(); i++) { VkShaderModuleCreateInfo shader_module_create_info; @@ -3115,7 +3133,7 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou VkResult res = vkCreateShaderModule(device, &shader_module_create_info, NULL, &module); if (res) { success = false; - ERR_PRINT("Error creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage])); + error_text = "Error creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage]); break; } @@ -3155,7 +3173,7 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou VkDescriptorSetLayout layout; VkResult res = vkCreateDescriptorSetLayout(device, &layout_create_info, NULL, &layout); if (res) { - ERR_PRINT("Error creating descriptor set layout for set " + itos(i)); + error_text = "Error creating descriptor set layout for set " + itos(i); success = false; break; } @@ -3212,7 +3230,7 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou VkResult err = vkCreatePipelineLayout(device, &pipeline_layout_create_info, NULL, &shader.pipeline_layout); if (err) { - ERR_PRINT("Error creating pipeline layout."); + error_text = "Error creating pipeline layout."; success = false; } } @@ -3227,12 +3245,25 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou vkDestroyDescriptorSetLayout(device, shader.sets[i].descriptor_set_layout, NULL); } + if (r_error) { + *r_error = error_text; + } + if (r_error_stage) { + *r_error_stage = SHADER_STAGE_MAX; + } + return RID(); } return shader_owner.make_rid(shader); } +Vector<int> RenderingDeviceVulkan::shader_get_vertex_input_locations_used(RID p_shader) { + const Shader *shader = shader_owner.getornull(p_shader); + ERR_FAIL_COND_V(!shader, Vector<int>()); + return shader->vertex_input_locations; +} + /******************/ /**** UNIFORMS ****/ /******************/ @@ -3789,6 +3820,10 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms, return id; } +bool RenderingDeviceVulkan::uniform_set_is_valid(RID p_uniform_set) { + return uniform_set_owner.owns(p_uniform_set); +} + Error RenderingDeviceVulkan::buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, void *p_data, bool p_sync_with_draw) { _THREAD_SAFE_METHOD_ @@ -4113,6 +4148,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma graphics_pipeline_create_info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; graphics_pipeline_create_info.pNext = NULL; + graphics_pipeline_create_info.flags = 0; graphics_pipeline_create_info.stageCount = shader->pipeline_stages.size(); graphics_pipeline_create_info.pStages = shader->pipeline_stages.ptr(); diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h index dd908df8f0..8a5a017e9f 100644 --- a/drivers/vulkan/rendering_device_vulkan.h +++ b/drivers/vulkan/rendering_device_vulkan.h @@ -680,7 +680,7 @@ public: virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture); virtual Error texture_update(RID p_texture, uint32_t p_layer, const PoolVector<uint8_t> &p_data, bool p_sync_with_draw = false); - virtual bool texture_is_format_supported_for_usage(DataFormat p_format, TextureUsageBits p_usage) const; + virtual bool texture_is_format_supported_for_usage(DataFormat p_format, uint32_t p_usage) const; /*********************/ /**** FRAMEBUFFER ****/ @@ -716,7 +716,8 @@ public: /**** SHADER ****/ /****************/ - virtual RID shader_create_from_source(const Vector<ShaderStageSource> &p_stages, String *r_error = NULL, bool p_allow_cache = true); + virtual RID shader_create_from_source(const Vector<ShaderStageSource> &p_stages, String *r_error = NULL, ShaderStage *r_error_stage = NULL, bool p_allow_cache = true); + virtual Vector<int> shader_get_vertex_input_locations_used(RID p_shader); /*****************/ /**** UNIFORM ****/ @@ -727,6 +728,7 @@ public: virtual RID texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>()); virtual RID uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set); + virtual bool uniform_set_is_valid(RID p_uniform_set); virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, void *p_data, bool p_sync_with_draw = false); //works for any buffer @@ -765,17 +767,17 @@ public: virtual void draw_list_end(); - virtual void free(RID p_id); - /**************/ /**** FREE ****/ /**************/ + virtual void free(RID p_id); + void initialize(VulkanContext *p_context); void finalize(); - void finalize_frame(); - void advance_frame(); + virtual void finalize_frame(); + virtual void advance_frame(); RenderingDeviceVulkan(); }; |