Browse Source

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
Pedro J. Estébanez 3 years ago
parent
commit
309f7965c7
1 changed files with 5 additions and 1 deletions
  1. 5 1
      drivers/vulkan/rendering_device_vulkan.cpp

+ 5 - 1
drivers/vulkan/rendering_device_vulkan.cpp

@@ -4731,7 +4731,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;
 					}
@@ -4758,6 +4758,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;