diff options
Diffstat (limited to 'servers/rendering/renderer_rd/pipeline_cache_rd.cpp')
-rw-r--r-- | servers/rendering/renderer_rd/pipeline_cache_rd.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/servers/rendering/renderer_rd/pipeline_cache_rd.cpp b/servers/rendering/renderer_rd/pipeline_cache_rd.cpp index 22888ddbe5..2bdd523920 100644 --- a/servers/rendering/renderer_rd/pipeline_cache_rd.cpp +++ b/servers/rendering/renderer_rd/pipeline_cache_rd.cpp @@ -31,14 +31,30 @@ #include "pipeline_cache_rd.h" #include "core/os/memory.h" -RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass) { +RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass, uint32_t p_bool_specializations) { RD::PipelineMultisampleState multisample_state_version = multisample_state; multisample_state_version.sample_count = RD::get_singleton()->framebuffer_format_get_texture_samples(p_framebuffer_format_id, p_render_pass); RD::PipelineRasterizationState raster_state_version = rasterization_state; raster_state_version.wireframe = p_wireframe; - RID pipeline = RD::get_singleton()->render_pipeline_create(shader, p_framebuffer_format_id, p_vertex_format_id, render_primitive, raster_state_version, multisample_state_version, depth_stencil_state, blend_state, dynamic_state_flags, p_render_pass); + Vector<RD::PipelineSpecializationConstant> specialization_constants = base_specialization_constants; + + uint32_t bool_index = 0; + uint32_t bool_specializations = p_bool_specializations; + while (bool_specializations) { + if (bool_specializations & (1 << bool_index)) { + RD::PipelineSpecializationConstant sc; + sc.bool_value = true; + sc.constant_id = bool_index; + sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL; + specialization_constants.push_back(sc); + bool_specializations &= ~(1 << bool_index); + } + bool_index++; + } + + RID pipeline = RD::get_singleton()->render_pipeline_create(shader, p_framebuffer_format_id, p_vertex_format_id, render_primitive, raster_state_version, multisample_state_version, depth_stencil_state, blend_state, dynamic_state_flags, p_render_pass, specialization_constants); ERR_FAIL_COND_V(pipeline.is_null(), RID()); versions = (Version *)memrealloc(versions, sizeof(Version) * (version_count + 1)); versions[version_count].framebuffer_id = p_framebuffer_format_id; @@ -46,6 +62,7 @@ RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD versions[version_count].wireframe = p_wireframe; versions[version_count].pipeline = pipeline; versions[version_count].render_pass = p_render_pass; + versions[version_count].bool_specializations = p_bool_specializations; version_count++; return pipeline; } @@ -64,7 +81,7 @@ void PipelineCacheRD::_clear() { } } -void PipelineCacheRD::setup(RID p_shader, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags) { +void PipelineCacheRD::setup(RID p_shader, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags, const Vector<RD::PipelineSpecializationConstant> &p_base_specialization_constants) { ERR_FAIL_COND(p_shader.is_null()); _clear(); shader = p_shader; @@ -75,6 +92,7 @@ void PipelineCacheRD::setup(RID p_shader, RD::RenderPrimitive p_primitive, const depth_stencil_state = p_depth_stencil_state; blend_state = p_blend_state; dynamic_state_flags = p_dynamic_state_flags; + base_specialization_constants = p_base_specialization_constants; } void PipelineCacheRD::update_shader(RID p_shader) { |