From 77a525168d91411dca63bbe02fc55124a6def935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Mon, 18 Jul 2022 14:45:36 +0200 Subject: Improve versioning of shader binary data files - Include Godot version and commit hash in shader cache key - Reject files when format doesn't match, even if it's lower, since we don't have backwards compatibility here --- drivers/vulkan/rendering_device_vulkan.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/vulkan') diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index 9b491be128..d95d93fd42 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -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" @@ -4556,7 +4557,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector &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); -- cgit v1.2.3 From 309f7965c75a7459a211b61820c291012f91c05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Sat, 9 Jul 2022 12:57:53 +0200 Subject: Enhance determination of uniform writability in Vulkan RD - Check block decoration in addition to type decoration to be sure to find `readonly` decorators - Verify uniforms have same writability across all shader stages in Vulkan RD --- drivers/vulkan/rendering_device_vulkan.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/vulkan') diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index d95d93fd42..54f80cfc76 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -4731,7 +4731,7 @@ Vector 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; } @@ -4758,6 +4758,10 @@ Vector RenderingDeviceVulkan::shader_compile_binary_from_spirv(const Ve ERR_FAIL_COND_V_MSG(uniform_info[set][k].length != info.length, Vector(), "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(), + "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; -- cgit v1.2.3