diff --git a/src/vulkan/runtime/vk_shader.c b/src/vulkan/runtime/vk_shader.c index 40d76cab79c..84e68a88002 100644 --- a/src/vulkan/runtime/vk_shader.c +++ b/src/vulkan/runtime/vk_shader.c @@ -377,6 +377,24 @@ vk_common_GetShaderBinaryDataEXT(VkDevice _device, */ #define VK_MAX_LINKED_SHADER_STAGES MESA_VK_MAX_GRAPHICS_PIPELINE_STAGES +const struct vk_pipeline_robustness_state vk_robustness_disabled = { + .storage_buffers = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, + .uniform_buffers = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, + .vertex_inputs = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, + .images = VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DISABLED_EXT, + /* From the Vulkan 1.3.292 spec: + * + * "This extension [VK_EXT_robustness2] also adds support for “null + * descriptors”, where VK_NULL_HANDLE can be used instead of a valid + * handle. Accesses to null descriptors have well-defined behavior, + * and do not rely on robustness." + * + * For now, default these to true. + */ + .null_uniform_buffer_descriptor = true, + .null_storage_buffer_descriptor = true, +}; + VKAPI_ATTR VkResult VKAPI_CALL vk_common_CreateShadersEXT(VkDevice _device, uint32_t createInfoCount, @@ -388,24 +406,6 @@ vk_common_CreateShadersEXT(VkDevice _device, const struct vk_device_shader_ops *ops = device->shader_ops; VkResult first_fail_or_success = VK_SUCCESS; - struct vk_pipeline_robustness_state rs = { - .storage_buffers = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, - .uniform_buffers = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, - .vertex_inputs = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, - .images = VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DISABLED_EXT, - /* From the Vulkan 1.3.292 spec: - * - * "This extension [VK_EXT_robustness2] also adds support for “null - * descriptors”, where VK_NULL_HANDLE can be used instead of a valid - * handle. Accesses to null descriptors have well-defined behavior, - * and do not rely on robustness." - * - * For now, default these to true. - */ - .null_uniform_buffer_descriptor = true, - .null_storage_buffer_descriptor = true, - }; - /* From the Vulkan 1.3.274 spec: * * "When this function returns, whether or not it succeeds, it is @@ -463,7 +463,8 @@ vk_common_CreateShadersEXT(VkDevice _device, .idx = i, }; } else { - nir_shader *nir = vk_shader_to_nir(device, vk_info, &rs); + nir_shader *nir = vk_shader_to_nir(device, vk_info, + &vk_robustness_disabled); if (nir == NULL) { result = vk_errorf(device, VK_ERROR_UNKNOWN, "Failed to compile shader to NIR"); @@ -473,7 +474,7 @@ vk_common_CreateShadersEXT(VkDevice _device, struct vk_shader_compile_info info; struct set_layouts set_layouts; vk_shader_compile_info_init(&info, &set_layouts, - vk_info, &rs, nir); + vk_info, &vk_robustness_disabled, nir); struct vk_shader *shader; result = ops->compile(device, 1, &info, NULL /* state */, @@ -508,7 +509,8 @@ vk_common_CreateShadersEXT(VkDevice _device, for (uint32_t l = 0; l < linked_count; l++) { const VkShaderCreateInfoEXT *vk_info = &pCreateInfos[linked[l].idx]; - nir_shader *nir = vk_shader_to_nir(device, vk_info, &rs); + nir_shader *nir = vk_shader_to_nir(device, vk_info, + &vk_robustness_disabled); if (nir == NULL) { result = vk_errorf(device, VK_ERROR_UNKNOWN, "Failed to compile shader to NIR"); @@ -516,7 +518,7 @@ vk_common_CreateShadersEXT(VkDevice _device, } vk_shader_compile_info_init(&infos[l], &set_layouts[l], - vk_info, &rs, nir); + vk_info, &vk_robustness_disabled, nir); } if (result == VK_SUCCESS) { diff --git a/src/vulkan/runtime/vk_shader.h b/src/vulkan/runtime/vk_shader.h index 8fb5090b129..cf4282a2a50 100644 --- a/src/vulkan/runtime/vk_shader.h +++ b/src/vulkan/runtime/vk_shader.h @@ -253,6 +253,8 @@ struct vk_device_shader_ops { const struct vk_dynamic_graphics_state *state); }; +extern const struct vk_pipeline_robustness_state vk_robustness_disabled; + #ifdef __cplusplus } #endif