diff --git a/src/vulkan/runtime/vk_device.c b/src/vulkan/runtime/vk_device.c index bfeb37971c3..1b422dc8a6c 100644 --- a/src/vulkan/runtime/vk_device.c +++ b/src/vulkan/runtime/vk_device.c @@ -131,6 +131,30 @@ vk_device_memory_report_init(struct vk_device *device, return VK_SUCCESS; } +static VkPipelineRobustnessBufferBehaviorEXT +vk_device_default_robust_buffer_behavior(const struct vk_device *device) +{ + if (device->enabled_features.robustBufferAccess2) { + return VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_2_EXT; + } else if (device->enabled_features.robustBufferAccess) { + return VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT; + } else { + return VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT; + } +} + +static VkPipelineRobustnessImageBehaviorEXT +vk_device_default_robust_image_behavior(const struct vk_device *device) +{ + if (device->enabled_features.robustImageAccess2) { + return VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_2_EXT; + } else if (device->enabled_features.robustImageAccess) { + return VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_EXT; + } else { + return VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DISABLED_EXT; + } +} + VkResult vk_device_init(struct vk_device *device, struct vk_physical_device *physical_device, @@ -271,6 +295,15 @@ vk_device_init(struct vk_device *device, if (result != VK_SUCCESS) return result; + device->robustness_state = (struct vk_pipeline_robustness_state) { + .uniform_buffers = vk_device_default_robust_buffer_behavior(device), + .storage_buffers = vk_device_default_robust_buffer_behavior(device), + .vertex_inputs = vk_device_default_robust_buffer_behavior(device), + .images = vk_device_default_robust_image_behavior(device), + .null_uniform_buffer_descriptor = device->enabled_features.nullDescriptor, + .null_storage_buffer_descriptor = device->enabled_features.nullDescriptor, + }; + device->disable_lto = false; return VK_SUCCESS; diff --git a/src/vulkan/runtime/vk_device.h b/src/vulkan/runtime/vk_device.h index 88bb7e22139..ceb8f636daf 100644 --- a/src/vulkan/runtime/vk_device.h +++ b/src/vulkan/runtime/vk_device.h @@ -28,6 +28,7 @@ #include "vk_extensions.h" #include "vk_object.h" #include "vk_physical_device_features.h" +#include "vk_pipeline.h" #include "util/list.h" #include "util/simple_mtx.h" @@ -318,6 +319,8 @@ struct vk_device { struct vk_device_memory_report *memory_reports; uint32_t memory_report_count; + + struct vk_pipeline_robustness_state robustness_state; }; VK_DEFINE_HANDLE_CASTS(vk_device, base, VkDevice, diff --git a/src/vulkan/runtime/vk_pipeline.c b/src/vulkan/runtime/vk_pipeline.c index 2c18f4cc26d..d4ff9999281 100644 --- a/src/vulkan/runtime/vk_pipeline.c +++ b/src/vulkan/runtime/vk_pipeline.c @@ -328,44 +328,14 @@ vk_pipeline_hash_shader_stage(VkPipelineCreateFlags2KHR pipeline_flags, _mesa_blake3_compute(blake_hash, sizeof(blake_hash), stage_blake3); } -static VkPipelineRobustnessBufferBehaviorEXT -vk_device_default_robust_buffer_behavior(const struct vk_device *device) -{ - if (device->enabled_features.robustBufferAccess2) { - return VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_2_EXT; - } else if (device->enabled_features.robustBufferAccess) { - return VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT; - } else { - return VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT; - } -} - -static VkPipelineRobustnessImageBehaviorEXT -vk_device_default_robust_image_behavior(const struct vk_device *device) -{ - if (device->enabled_features.robustImageAccess2) { - return VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_2_EXT; - } else if (device->enabled_features.robustImageAccess) { - return VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_EXT; - } else { - return VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DISABLED_EXT; - } -} - void vk_pipeline_robustness_state_fill(const struct vk_device *device, struct vk_pipeline_robustness_state *rs, const void *pipeline_pNext, const void *shader_stage_pNext) { - *rs = (struct vk_pipeline_robustness_state) { - .uniform_buffers = vk_device_default_robust_buffer_behavior(device), - .storage_buffers = vk_device_default_robust_buffer_behavior(device), - .vertex_inputs = vk_device_default_robust_buffer_behavior(device), - .images = vk_device_default_robust_image_behavior(device), - .null_uniform_buffer_descriptor = device->enabled_features.nullDescriptor, - .null_storage_buffer_descriptor = device->enabled_features.nullDescriptor, - }; + /* Use the device robustness state by default. */ + *rs = device->robustness_state; const VkPipelineRobustnessCreateInfoEXT *shader_info = vk_find_struct_const(shader_stage_pNext,