Validate that in OpenGL env block variables have Binding (#2685)
* Add spvIsOpenGLEnv helper * Validate that in OpenGL env block variables have Binding
This commit is contained in:
Родитель
e6e3e2ccc6
Коммит
9702d47c6f
|
@ -234,6 +234,36 @@ bool spvIsWebGPUEnv(spv_target_env env) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool spvIsOpenGLEnv(spv_target_env env) {
|
||||
switch (env) {
|
||||
case SPV_ENV_UNIVERSAL_1_0:
|
||||
case SPV_ENV_VULKAN_1_0:
|
||||
case SPV_ENV_UNIVERSAL_1_1:
|
||||
case SPV_ENV_UNIVERSAL_1_2:
|
||||
case SPV_ENV_UNIVERSAL_1_3:
|
||||
case SPV_ENV_VULKAN_1_1:
|
||||
case SPV_ENV_OPENCL_1_2:
|
||||
case SPV_ENV_OPENCL_EMBEDDED_1_2:
|
||||
case SPV_ENV_OPENCL_2_0:
|
||||
case SPV_ENV_OPENCL_EMBEDDED_2_0:
|
||||
case SPV_ENV_OPENCL_EMBEDDED_2_1:
|
||||
case SPV_ENV_OPENCL_EMBEDDED_2_2:
|
||||
case SPV_ENV_OPENCL_2_1:
|
||||
case SPV_ENV_OPENCL_2_2:
|
||||
case SPV_ENV_WEBGPU_0:
|
||||
case SPV_ENV_UNIVERSAL_1_4:
|
||||
case SPV_ENV_VULKAN_1_1_SPIRV_1_4:
|
||||
return false;
|
||||
case SPV_ENV_OPENGL_4_0:
|
||||
case SPV_ENV_OPENGL_4_1:
|
||||
case SPV_ENV_OPENGL_4_2:
|
||||
case SPV_ENV_OPENGL_4_3:
|
||||
case SPV_ENV_OPENGL_4_5:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool spvIsVulkanOrWebGPUEnv(spv_target_env env) {
|
||||
return spvIsVulkanEnv(env) || spvIsWebGPUEnv(env);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,9 @@ bool spvIsOpenCLEnv(spv_target_env env);
|
|||
// Returns true if |env| is an WEBGPU environment, false otherwise.
|
||||
bool spvIsWebGPUEnv(spv_target_env env);
|
||||
|
||||
// Returns true if |env| is an OPENGL environment, false otherwise.
|
||||
bool spvIsOpenGLEnv(spv_target_env env);
|
||||
|
||||
// Returns true if |env| is a VULKAN or WEBGPU environment, false otherwise.
|
||||
bool spvIsVulkanOrWebGPUEnv(spv_target_env env);
|
||||
|
||||
|
|
|
@ -910,6 +910,25 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) {
|
|||
}
|
||||
}
|
||||
|
||||
if (spvIsOpenGLEnv(vstate.context()->target_env)) {
|
||||
bool has_block = hasDecoration(var_id, SpvDecorationBlock, vstate);
|
||||
bool has_buffer_block =
|
||||
hasDecoration(var_id, SpvDecorationBufferBlock, vstate);
|
||||
if ((uniform && (has_block || has_buffer_block)) ||
|
||||
(storage_buffer && has_block)) {
|
||||
auto entry_points = vstate.EntryPointReferences(var_id);
|
||||
if (!entry_points.empty() &&
|
||||
!hasDecoration(var_id, SpvDecorationBinding, vstate)) {
|
||||
return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(var_id))
|
||||
<< (uniform ? "Uniform" : "Storage Buffer") << " id '"
|
||||
<< var_id << "' is missing Binding decoration.\n"
|
||||
<< "From ARB_gl_spirv extension:\n"
|
||||
<< "Uniform and shader storage block variables must "
|
||||
<< "also be decorated with a *Binding*.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bool phys_storage_buffer =
|
||||
storageClass == SpvStorageClassPhysicalStorageBufferEXT;
|
||||
if (uniform || push_constant || storage_buffer || phys_storage_buffer) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче