diff options
Diffstat (limited to 'servers/visual/rasterizer_rd')
-rw-r--r-- | servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp | 27 | ||||
-rw-r--r-- | servers/visual/rasterizer_rd/rasterizer_effects_rd.h | 1 | ||||
-rw-r--r-- | servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl | 12 |
3 files changed, 30 insertions, 10 deletions
diff --git a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp index be9f1901a7..f4d59e9e54 100644 --- a/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_effects_rd.cpp @@ -773,15 +773,26 @@ void RasterizerEffectsRD::cubemap_downsample(RID p_source_cubemap, bool p_source void RasterizerEffectsRD::cubemap_filter(RID p_source_cubemap, Vector<RID> p_dest_cubemap, bool p_use_array) { + Vector<RD::Uniform> uniforms; + for (int i = 0; i < p_dest_cubemap.size(); i++) { + RD::Uniform u; + u.type = RD::UNIFORM_TYPE_IMAGE; + u.binding = i; + u.ids.push_back(p_dest_cubemap[i]); + uniforms.push_back(u); + } + if (RD::get_singleton()->uniform_set_is_valid(filter.image_uniform_set)) { + RD::get_singleton()->free(filter.image_uniform_set); + } + filter.image_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, filter.shader.version_get_shader(filter.shader_version, 0), 2); + int pipeline = p_use_array ? FILTER_MODE_HIGH_QUALITY_ARRAY : FILTER_MODE_HIGH_QUALITY; pipeline = filter.use_high_quality ? pipeline : pipeline + 1; RD::ComputeListID compute_list = RD::get_singleton()->compute_list_begin(); RD::get_singleton()->compute_list_bind_compute_pipeline(compute_list, filter.pipelines[pipeline]); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_compute_uniform_set_from_texture(p_source_cubemap, true), 0); RD::get_singleton()->compute_list_bind_uniform_set(compute_list, filter.uniform_set, 1); - for (int i = 0; i < p_dest_cubemap.size(); i++) { - RD::get_singleton()->compute_list_bind_uniform_set(compute_list, _get_uniform_set_from_image(p_dest_cubemap[i]), i + 2); - } + RD::get_singleton()->compute_list_bind_uniform_set(compute_list, filter.image_uniform_set, 2); int x_groups = p_use_array ? 1792 : 342; // (128 * 128 * 7) / 64 : (128*128 + 64*64 + 32*32 + 16*16 + 8*8 + 4*4 + 2*2) / 64 @@ -1062,9 +1073,18 @@ RasterizerEffectsRD::RasterizerEffectsRD() { } RasterizerEffectsRD::~RasterizerEffectsRD() { + if (RD::get_singleton()->uniform_set_is_valid(filter.image_uniform_set)) { + RD::get_singleton()->free(filter.image_uniform_set); + } + + if (RD::get_singleton()->uniform_set_is_valid(filter.image_uniform_set)) { + RD::get_singleton()->free(filter.uniform_set); + } + RD::get_singleton()->free(default_sampler); RD::get_singleton()->free(default_mipmap_sampler); RD::get_singleton()->free(index_buffer); //array gets freed as dependency + RD::get_singleton()->free(filter.coefficient_buffer); blur.shader.version_free(blur.shader_version); roughness.shader.version_free(roughness.shader_version); sky.shader.version_free(sky.shader_version); @@ -1078,5 +1098,4 @@ RasterizerEffectsRD::~RasterizerEffectsRD() { roughness_limiter.shader.version_free(roughness_limiter.shader_version); cubemap_downsampler.shader.version_free(cubemap_downsampler.shader_version); filter.shader.version_free(filter.shader_version); - RD::get_singleton()->free(filter.coefficient_buffer); } diff --git a/servers/visual/rasterizer_rd/rasterizer_effects_rd.h b/servers/visual/rasterizer_rd/rasterizer_effects_rd.h index 003ea33516..8ec202c399 100644 --- a/servers/visual/rasterizer_rd/rasterizer_effects_rd.h +++ b/servers/visual/rasterizer_rd/rasterizer_effects_rd.h @@ -391,6 +391,7 @@ class RasterizerEffectsRD { RID shader_version; RID pipelines[FILTER_MODE_MAX]; RID uniform_set; + RID image_uniform_set; RID coefficient_buffer; bool use_high_quality; diff --git a/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl b/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl index 58c5af9c41..a7e51c1489 100644 --- a/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl +++ b/servers/visual/rasterizer_rd/shaders/cubemap_filter.glsl @@ -32,12 +32,12 @@ layout(local_size_x = GROUP_SIZE, local_size_y = 1, local_size_z = 1) in; layout(set = 0, binding = 0) uniform samplerCube source_cubemap; layout(rgba16f, set = 2, binding = 0) uniform restrict writeonly imageCube dest_cubemap0; -layout(rgba16f, set = 3, binding = 0) uniform restrict writeonly imageCube dest_cubemap1; -layout(rgba16f, set = 4, binding = 0) uniform restrict writeonly imageCube dest_cubemap2; -layout(rgba16f, set = 5, binding = 0) uniform restrict writeonly imageCube dest_cubemap3; -layout(rgba16f, set = 6, binding = 0) uniform restrict writeonly imageCube dest_cubemap4; -layout(rgba16f, set = 7, binding = 0) uniform restrict writeonly imageCube dest_cubemap5; -layout(rgba16f, set = 8, binding = 0) uniform restrict writeonly imageCube dest_cubemap6; +layout(rgba16f, set = 2, binding = 1) uniform restrict writeonly imageCube dest_cubemap1; +layout(rgba16f, set = 2, binding = 2) uniform restrict writeonly imageCube dest_cubemap2; +layout(rgba16f, set = 2, binding = 3) uniform restrict writeonly imageCube dest_cubemap3; +layout(rgba16f, set = 2, binding = 4) uniform restrict writeonly imageCube dest_cubemap4; +layout(rgba16f, set = 2, binding = 5) uniform restrict writeonly imageCube dest_cubemap5; +layout(rgba16f, set = 2, binding = 6) uniform restrict writeonly imageCube dest_cubemap6; #ifdef USE_HIGH_QUALITY #define NUM_TAPS 32 |