Merge pull request #62848 from RandomShaper/shader_writability_improvement
This commit is contained in:
commit
5bea531228
3 changed files with 14 additions and 7 deletions
|
@ -36,6 +36,7 @@
|
|||
#include "core/io/marshalls.h"
|
||||
#include "core/os/os.h"
|
||||
#include "core/templates/hashfuncs.h"
|
||||
#include "core/version.h"
|
||||
#include "drivers/vulkan/vulkan_context.h"
|
||||
|
||||
#include "thirdparty/misc/smolv.h"
|
||||
|
@ -4656,7 +4657,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
|
|||
#define SHADER_BINARY_VERSION 3
|
||||
|
||||
String RenderingDeviceVulkan::shader_get_binary_cache_key() const {
|
||||
return "Vulkan-SV" + itos(SHADER_BINARY_VERSION);
|
||||
return "Vulkan-SV" + itos(SHADER_BINARY_VERSION) + "-" + String(VERSION_NUMBER) + "-" + String(VERSION_HASH);
|
||||
}
|
||||
|
||||
struct RenderingDeviceVulkanShaderBinaryDataBinding {
|
||||
|
@ -4830,7 +4831,7 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve
|
|||
}
|
||||
|
||||
if (may_be_writable) {
|
||||
info.writable = !(bool)(binding.type_description->decoration_flags & SPV_REFLECT_DECORATION_NON_WRITABLE);
|
||||
info.writable = !(binding.type_description->decoration_flags & SPV_REFLECT_DECORATION_NON_WRITABLE) && !(binding.block.decoration_flags & SPV_REFLECT_DECORATION_NON_WRITABLE);
|
||||
} else {
|
||||
info.writable = false;
|
||||
}
|
||||
|
@ -4857,6 +4858,10 @@ Vector<uint8_t> RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve
|
|||
ERR_FAIL_COND_V_MSG(uniform_info[set][k].length != info.length, Vector<uint8_t>(),
|
||||
"On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to re-use location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different uniform size.");
|
||||
|
||||
//also, verify that it has the same writability
|
||||
ERR_FAIL_COND_V_MSG(uniform_info[set][k].writable != info.writable, Vector<uint8_t>(),
|
||||
"On shader stage '" + String(shader_stage_names[stage]) + "', uniform '" + binding.name + "' trying to re-use location for set=" + itos(set) + ", binding=" + itos(info.binding) + " with different writability.");
|
||||
|
||||
//just append stage mask and return
|
||||
uniform_info.write[set].write[k].stages |= 1 << stage;
|
||||
exists = true;
|
||||
|
@ -5156,7 +5161,7 @@ RID RenderingDeviceVulkan::shader_create_from_bytecode(const Vector<uint8_t> &p_
|
|||
ERR_FAIL_COND_V(binptr[0] != 'G' || binptr[1] != 'V' || binptr[2] != 'B' || binptr[3] != 'D', RID());
|
||||
|
||||
uint32_t bin_version = decode_uint32(binptr + 4);
|
||||
ERR_FAIL_COND_V(bin_version > SHADER_BINARY_VERSION, RID());
|
||||
ERR_FAIL_COND_V(bin_version != SHADER_BINARY_VERSION, RID());
|
||||
|
||||
uint32_t bin_data_size = decode_uint32(binptr + 8);
|
||||
|
||||
|
|
|
@ -810,7 +810,8 @@ void GI::SDFGI::create(RendererSceneEnvironmentRD *p_env, const Vector3 &p_world
|
|||
uniforms.push_back(u);
|
||||
}
|
||||
|
||||
cascade.sdf_direct_light_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.direct_light.version_get_shader(gi->sdfgi_shader.direct_light_shader, 0), 0);
|
||||
cascade.sdf_direct_light_static_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.direct_light.version_get_shader(gi->sdfgi_shader.direct_light_shader, SDFGIShader::DIRECT_LIGHT_MODE_STATIC), 0);
|
||||
cascade.sdf_direct_light_dynamic_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, gi->sdfgi_shader.direct_light.version_get_shader(gi->sdfgi_shader.direct_light_shader, SDFGIShader::DIRECT_LIGHT_MODE_DYNAMIC), 0);
|
||||
}
|
||||
|
||||
//preprocess initialize uniform set
|
||||
|
@ -1259,7 +1260,7 @@ void GI::SDFGI::update_light() {
|
|||
}
|
||||
cascades[i].all_dynamic_lights_dirty = false;
|
||||
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascade.sdf_direct_light_uniform_set, 0);
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cascade.sdf_direct_light_dynamic_uniform_set, 0);
|
||||
RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(SDFGIShader::DirectLightPushConstant));
|
||||
RD::get_singleton()->compute_list_dispatch_indirect(compute_list, cascade.solid_cell_dispatch_buffer, 0);
|
||||
}
|
||||
|
@ -2413,7 +2414,7 @@ void GI::SDFGI::render_static_lights(RID p_render_buffers, uint32_t p_cascade_co
|
|||
dl_push_constant.cascade = p_cascade_indices[i];
|
||||
|
||||
if (dl_push_constant.light_count > 0) {
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cc.sdf_direct_light_uniform_set, 0);
|
||||
RD::get_singleton()->compute_list_bind_uniform_set(compute_list, cc.sdf_direct_light_static_uniform_set, 0);
|
||||
RD::get_singleton()->compute_list_set_push_constant(compute_list, &dl_push_constant, sizeof(SDFGIShader::DirectLightPushConstant));
|
||||
RD::get_singleton()->compute_list_dispatch_indirect(compute_list, cc.solid_cell_dispatch_buffer, 0);
|
||||
}
|
||||
|
|
|
@ -541,7 +541,8 @@ public:
|
|||
Vector3i dirty_regions; //(0,0,0 is not dirty, negative is refresh from the end, DIRTY_ALL is refresh all.
|
||||
|
||||
RID sdf_store_uniform_set;
|
||||
RID sdf_direct_light_uniform_set;
|
||||
RID sdf_direct_light_static_uniform_set;
|
||||
RID sdf_direct_light_dynamic_uniform_set;
|
||||
RID scroll_uniform_set;
|
||||
RID scroll_occlusion_uniform_set;
|
||||
RID integrate_uniform_set;
|
||||
|
|
Loading…
Reference in a new issue