Fix #129265: Clearing depth attachments on AMD official driver

When using AMD official driver clearing depth attachments can fail.
I assume it is related to previous pipeline states and dynamic rendering
that don't require the correct pipeline state for clearing depth
attachments.

![image](/attachments/e5b97c3b-2551-4600-8cbe-4c8fc71d9feb)

Co-authored-by: jeroen@blender.org <Jeroen Bakker>
Pull Request: https://projects.blender.org/blender/blender/pulls/129852
This commit is contained in:
Jeroen Bakker 2024-11-05 12:44:17 +01:00
parent 6ba58a8303
commit b18a460ad7
3 changed files with 28 additions and 4 deletions

View File

@ -275,8 +275,8 @@ void VKBackend::platform_init(const VKDevice &device)
const VkPhysicalDeviceProperties &properties = device.physical_device_properties_get();
eGPUDeviceType device_type = device.device_type();
eGPUDriverType driver = device.driver_type();
eGPUOSType os = determine_os_type();
eGPUDriverType driver = GPU_DRIVER_ANY;
eGPUSupportLevel support_level = GPU_SUPPORT_LEVEL_SUPPORTED;
std::string vendor_name = device.vendor_name();

View File

@ -297,8 +297,27 @@ eGPUDeviceType VKDevice::device_type() const
eGPUDriverType VKDevice::driver_type() const
{
/* It is unclear how to determine the driver type, but it is required to extract the correct
* driver version. */
switch (vk_physical_device_driver_properties_.driverID) {
case VK_DRIVER_ID_AMD_PROPRIETARY:
case VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS:
case VK_DRIVER_ID_NVIDIA_PROPRIETARY:
case VK_DRIVER_ID_QUALCOMM_PROPRIETARY:
return GPU_DRIVER_OFFICIAL;
case VK_DRIVER_ID_MOLTENVK:
case VK_DRIVER_ID_AMD_OPEN_SOURCE:
case VK_DRIVER_ID_MESA_RADV:
case VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA:
case VK_DRIVER_ID_MESA_NVK:
return GPU_DRIVER_OPENSOURCE;
case VK_DRIVER_ID_MESA_LLVMPIPE:
return GPU_DRIVER_SOFTWARE;
default:
return GPU_DRIVER_ANY;
}
return GPU_DRIVER_ANY;
}

View File

@ -186,7 +186,12 @@ void VKFrameBuffer::clear(const eGPUFrameBufferBits buffers,
/* Clearing depth via vkCmdClearAttachments requires a render pass with write depth or stencil
* enabled. When not enabled, clearing should be done via texture directly. */
if ((context.state_manager_get().state.write_mask & needed_mask) == needed_mask) {
/* WORKAROUND: Clearing depth attachment when using dynamic rendering are not working on AMD
* official drivers.
* See #129265 */
if ((context.state_manager_get().state.write_mask & needed_mask) == needed_mask &&
!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_OFFICIAL))
{
build_clear_attachments_depth_stencil(
buffers, clear_depth, clear_stencil, clear_attachments);
}