radv: Enable rayTracingPipelineShaderGroupHandleCaptureReplay[Mixed].
authorTatsuyuki Ishi <ishitatsuyuki@gmail.com>
Wed, 23 Nov 2022 01:50:18 +0000 (10:50 +0900)
committerMarge Bot <emma+marge@anholt.net>
Sat, 26 Nov 2022 13:57:56 +0000 (13:57 +0000)
Tested that a q2rtx gfxr capture replays correctly and without the
capture/replay feature warning.

I ran the CTS too, but it seems to be just giving out a pass without
testing the code path.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19949>

src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_pipeline_rt.c

index e2abbf5..95f91ef 100644 (file)
@@ -1784,8 +1784,8 @@ radv_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
          VkPhysicalDeviceRayTracingPipelineFeaturesKHR *features =
             (VkPhysicalDeviceRayTracingPipelineFeaturesKHR *)ext;
          features->rayTracingPipeline = true;
-         features->rayTracingPipelineShaderGroupHandleCaptureReplay = false;
-         features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed = false;
+         features->rayTracingPipelineShaderGroupHandleCaptureReplay = true;
+         features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed = true;
          features->rayTracingPipelineTraceRaysIndirect = true;
          features->rayTraversalPrimitiveCulling = true;
          break;
@@ -2620,7 +2620,7 @@ radv_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
          props->maxRayRecursionDepth = 31;    /* Minimum allowed for DXR. */
          props->maxShaderGroupStride = 16384; /* dummy */
          props->shaderGroupBaseAlignment = 16;
-         props->shaderGroupHandleCaptureReplaySize = 16;
+         props->shaderGroupHandleCaptureReplaySize = RADV_RT_HANDLE_SIZE;
          props->maxRayDispatchInvocationCount = 1024 * 1024 * 64;
          props->shaderGroupHandleAlignment = 16;
          props->maxRayHitAttributeSize = RADV_MAX_HIT_ATTRIB_SIZE;
index 49653f8..aac5d7a 100644 (file)
@@ -368,6 +368,16 @@ radv_rt_pipeline_create(VkDevice _device, VkPipelineCache _cache,
       case VK_SHADER_GROUP_SHADER_MAX_ENUM_KHR:
          unreachable("VK_SHADER_GROUP_SHADER_MAX_ENUM_KHR");
       }
+
+      if (pCreateInfo->flags &
+          VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
+         if (group_info->pShaderGroupCaptureReplayHandle &&
+             memcmp(group_info->pShaderGroupCaptureReplayHandle, &rt_pipeline->group_handles[i],
+                    sizeof(rt_pipeline->group_handles[i])) != 0) {
+            result = VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS;
+            goto shader_fail;
+         }
+      }
    }
 
    *pPipeline = radv_pipeline_to_handle(&rt_pipeline->base.base);
@@ -450,11 +460,10 @@ radv_GetRayTracingShaderGroupStackSizeKHR(VkDevice device, VkPipeline _pipeline,
 }
 
 VKAPI_ATTR VkResult VKAPI_CALL
-radv_GetRayTracingCaptureReplayShaderGroupHandlesKHR(VkDevice _device, VkPipeline pipeline,
+radv_GetRayTracingCaptureReplayShaderGroupHandlesKHR(VkDevice device, VkPipeline pipeline,
                                                      uint32_t firstGroup, uint32_t groupCount,
                                                      size_t dataSize, void *pData)
 {
-   RADV_FROM_HANDLE(radv_device, device, _device);
-   unreachable("Unimplemented");
-   return vk_error(device, VK_ERROR_FEATURE_NOT_PRESENT);
+   return radv_GetRayTracingShaderGroupHandlesKHR(device, pipeline, firstGroup, groupCount,
+                                                  dataSize, pData);
 }