Compare commits

...

4 Commits

Author SHA1 Message Date
Robin Kertels 1a773cfb71 tests: Add test for indirect ray tracing. 2 months ago
Robin Kertels cdabda7805 vkd3d: Implement indirect ray tracing. 2 months ago
Robin Kertels 8ac7aaca99 vkd3d: Enable VK_KHR_ray_tracing_maintenance1. 2 months ago
Robin Kertels 7e7c472005 khronos: Update Vulkan headers 2 months ago
  1. 26
      libs/vkd3d/command.c
  2. 16
      libs/vkd3d/device.c
  3. 2
      libs/vkd3d/vkd3d_private.h
  4. 3
      libs/vkd3d/vulkan_procs.h
  5. 2
      subprojects/Vulkan-Headers
  6. 26
      tests/d3d12_raytracing.c
  7. 3
      tests/d3d12_test_utils.c

@ -9414,6 +9414,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_EndEvent(d3d12_command_list_ifa
STATIC_ASSERT(sizeof(VkDispatchIndirectCommand) == sizeof(D3D12_DISPATCH_ARGUMENTS));
STATIC_ASSERT(sizeof(VkDrawIndexedIndirectCommand) == sizeof(D3D12_DRAW_INDEXED_ARGUMENTS));
STATIC_ASSERT(sizeof(VkDrawIndirectCommand) == sizeof(D3D12_DRAW_ARGUMENTS));
STATIC_ASSERT(offsetof(VkTraceRaysIndirectCommand2KHR, depth) == offsetof(D3D12_DISPATCH_RAYS_DESC, Depth));
static void STDMETHODCALLTYPE d3d12_command_list_ExecuteIndirect(d3d12_command_list_iface *iface,
ID3D12CommandSignature *command_signature, UINT max_command_count, ID3D12Resource *arg_buffer,
@ -9483,11 +9484,13 @@ static void STDMETHODCALLTYPE d3d12_command_list_ExecuteIndirect(d3d12_command_l
{
scratch.buffer = count_impl->res.vk_buffer;
scratch.offset = count_impl->mem.offset + count_buffer_offset;
scratch.va = d3d12_resource_get_va(count_impl, count_buffer_offset);
}
else
{
scratch.buffer = arg_impl->res.vk_buffer;
scratch.offset = arg_impl->mem.offset + arg_buffer_offset;
scratch.va = d3d12_resource_get_va(arg_impl, arg_buffer_offset);
}
switch (arg_desc->Type)
@ -9556,6 +9559,28 @@ static void STDMETHODCALLTYPE d3d12_command_list_ExecuteIndirect(d3d12_command_l
VK_CALL(vkCmdDispatchIndirect(list->vk_command_buffer, scratch.buffer, scratch.offset));
break;
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS:
if (max_command_count != 1)
FIXME("Ignoring command count %u.\n", max_command_count);
if (count_buffer)
FIXME_ONCE("Count buffers not supported for indirect ray dispatch.\n");
if (!d3d12_command_list_update_raygen_state(list))
{
WARN("Failed to update raygen state, ignoring ray dispatch.\n");
return;
}
if (!list->device->device_info.ray_tracing_maintenance1_features.rayTracingPipelineTraceRaysIndirect2)
{
WARN("TraceRaysIndirect2 is not supported, ignoring ray dispatch.\n");
break;
}
VK_CALL(vkCmdTraceRaysIndirect2KHR(list->vk_command_buffer, scratch.va));
break;
default:
FIXME("Ignoring unhandled argument type %#x.\n", arg_desc->Type);
break;
@ -12261,6 +12286,7 @@ HRESULT d3d12_command_signature_create(struct d3d12_device *device, const D3D12_
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW:
case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED:
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH:
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS:
if (i != desc->NumArgumentDescs - 1)
{
WARN("Draw/dispatch must be the last element of a command signature.\n");

@ -70,6 +70,7 @@ static const struct vkd3d_optional_extension_info optional_device_extensions[] =
VK_EXTENSION_COND(KHR_DEFERRED_HOST_OPERATIONS, KHR_deferred_host_operations, VKD3D_CONFIG_FLAG_DXR),
VK_EXTENSION_COND(KHR_PIPELINE_LIBRARY, KHR_pipeline_library, VKD3D_CONFIG_FLAG_DXR),
VK_EXTENSION_COND(KHR_RAY_QUERY, KHR_ray_query, VKD3D_CONFIG_FLAG_DXR11),
VK_EXTENSION_COND(KHR_RAY_TRACING_MAINTENANCE_1, KHR_ray_tracing_maintenance1, VKD3D_CONFIG_FLAG_DXR11),
VK_EXTENSION(KHR_SPIRV_1_4, KHR_spirv_1_4),
VK_EXTENSION(KHR_SHADER_FLOAT_CONTROLS, KHR_shader_float_controls),
VK_EXTENSION(KHR_FRAGMENT_SHADING_RATE, KHR_fragment_shading_rate),
@ -1354,6 +1355,12 @@ static void vkd3d_physical_device_info_init(struct vkd3d_physical_device_info *i
vk_prepend_struct(&info->features2, &info->ray_query_features);
}
if (vulkan_info->KHR_ray_tracing_maintenance1)
{
info->ray_tracing_maintenance1_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MAINTENANCE_1_FEATURES_KHR;
vk_prepend_struct(&info->features2, &info->ray_tracing_maintenance1_features);
}
if (vulkan_info->KHR_shader_float_controls)
{
info->float_control_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR;
@ -5470,12 +5477,11 @@ static D3D12_RAYTRACING_TIER d3d12_device_determine_ray_tracing_tier(struct d3d1
}
if (tier == D3D12_RAYTRACING_TIER_1_0 && info->ray_query_features.rayQuery &&
info->ray_tracing_pipeline_features.rayTraversalPrimitiveCulling &&
info->ray_tracing_pipeline_features.rayTracingPipelineTraceRaysIndirect)
info->ray_tracing_pipeline_features.rayTraversalPrimitiveCulling)
{
/* Try to enable DXR 1.1. We can support everything from 1.1 with existing spec,
* except ExecuteIndirect DispatchRays().
* Hide this support behind a CONFIG flag for time being. */
/* Try to enable DXR 1.1.
* Hide this support behind a CONFIG flag for time being.
* TODO: require VK_KHR_ray_tracing_maintenance1. */
supports_vbo_formats = d3d12_device_supports_rtas_formats(device,
required_vbo_formats_tier_11, ARRAY_SIZE(required_vbo_formats_tier_11));

@ -133,6 +133,7 @@ struct vkd3d_vulkan_info
bool KHR_driver_properties;
bool KHR_uniform_buffer_standard_layout;
bool KHR_maintenance4;
bool KHR_ray_tracing_maintenance1;
/* EXT device extensions */
bool EXT_calibrated_timestamps;
bool EXT_conditional_rendering;
@ -3073,6 +3074,7 @@ struct vkd3d_physical_device_info
VkPhysicalDeviceDynamicRenderingFeaturesKHR dynamic_rendering_features;
VkPhysicalDeviceCoherentMemoryFeaturesAMD device_coherent_memory_features_amd;
VkPhysicalDeviceMaintenance4FeaturesKHR maintenance4_features;
VkPhysicalDeviceRayTracingMaintenance1FeaturesKHR ray_tracing_maintenance1_features;
VkPhysicalDeviceFeatures2 features2;

@ -280,6 +280,9 @@ VK_DEVICE_EXT_PFN(vkQueuePresentKHR)
VK_DEVICE_EXT_PFN(vkCmdBeginRenderingKHR)
VK_DEVICE_EXT_PFN(vkCmdEndRenderingKHR)
/* VK_KHR_ray_tracing_maintenance1 */
VK_DEVICE_EXT_PFN(vkCmdTraceRaysIndirect2KHR)
/* VK_AMD_buffer_marker */
VK_DEVICE_EXT_PFN(vkCmdWriteBufferMarkerAMD)

@ -1 +1 @@
Subproject commit 6eb8fc3598ed2a9777677fbe59038c8d0664a434
Subproject commit 33d4dd987fc8fc6475ff9ca2b4f0c3cc6e793337

@ -1442,6 +1442,7 @@ enum rt_test_mode
TEST_MODE_TRACE_RAY_SKIP_AABBS,
TEST_MODE_PSO_SKIP_TRIANGLES,
TEST_MODE_PSO_SKIP_AABBS,
TEST_MODE_INDIRECT,
};
static ID3D12StateObject *create_rt_collection(struct raytracing_test_context *context,
@ -1512,6 +1513,7 @@ static void test_raytracing_pipeline(enum rt_test_mode mode, D3D12_RAYTRACING_TI
D3D12_ROOT_SIGNATURE_DESC root_signature_desc;
D3D12_DESCRIPTOR_RANGE descriptor_ranges[2];
ID3D12GraphicsCommandList4 *command_list4;
ID3D12CommandSignature *command_signature;
ID3D12StateObject *rt_object_library_aabb;
ID3D12StateObject *rt_object_library_tri;
D3D12_ROOT_PARAMETER root_parameters[2];
@ -1526,6 +1528,7 @@ static void test_raytracing_pipeline(enum rt_test_mode mode, D3D12_RAYTRACING_TI
ID3D12Resource *postbuild_readback;
ID3D12Resource *sbt_colors_buffer;
ID3D12Resource *postbuild_buffer;
ID3D12Resource *indirect_buffer;
unsigned int i, descriptor_size;
ID3D12RootSignature *global_rs;
struct test_geometry test_geom;
@ -2002,6 +2005,13 @@ static void test_raytracing_pipeline(enum rt_test_mode mode, D3D12_RAYTRACING_TI
cpu_handle.ptr += descriptor_size;
}
indirect_buffer = NULL;
command_signature = NULL;
if (mode == TEST_MODE_INDIRECT)
{
command_signature = create_command_signature(device, D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS);
}
ID3D12GraphicsCommandList4_SetComputeRootSignature(command_list4, global_rs);
ID3D12GraphicsCommandList4_SetPipelineState1(command_list4, rt_pso);
ID3D12GraphicsCommandList4_SetDescriptorHeaps(command_list4, 1, &descriptor_heap);
@ -2030,7 +2040,16 @@ static void test_raytracing_pipeline(enum rt_test_mode mode, D3D12_RAYTRACING_TI
flags = test_mode_to_trace_flags(mode);
ID3D12GraphicsCommandList4_SetComputeRoot32BitConstant(command_list4, 1, flags, 0);
ID3D12GraphicsCommandList4_DispatchRays(command_list4, &desc);
if (mode != TEST_MODE_INDIRECT)
{
ID3D12GraphicsCommandList4_DispatchRays(command_list4, &desc);
}
else
{
indirect_buffer = create_upload_buffer(device, sizeof(D3D12_DISPATCH_RAYS_DESC), &desc);
ID3D12GraphicsCommandList_ExecuteIndirect(command_list, command_signature, 1, indirect_buffer, 0, NULL, 0);
}
}
transition_resource_state(command_list, ray_colors, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
@ -2176,6 +2195,10 @@ static void test_raytracing_pipeline(enum rt_test_mode mode, D3D12_RAYTRACING_TI
ID3D12Resource_Release(sbt);
ID3D12Resource_Release(postbuild_readback);
ID3D12Resource_Release(postbuild_buffer);
if (command_signature)
ID3D12CommandSignature_Release(command_signature);
if (indirect_buffer)
ID3D12Resource_Release(indirect_buffer);
destroy_raytracing_test_context(&context);
}
@ -2197,6 +2220,7 @@ void test_raytracing(void)
{ TEST_MODE_TRACE_RAY_SKIP_AABBS, D3D12_RAYTRACING_TIER_1_1, "TraceRaySkipAABBs" },
{ TEST_MODE_PSO_SKIP_TRIANGLES, D3D12_RAYTRACING_TIER_1_1, "PSOSkipTriangles" },
{ TEST_MODE_PSO_SKIP_AABBS, D3D12_RAYTRACING_TIER_1_1, "PSOSkipAABBs" },
{ TEST_MODE_INDIRECT, D3D12_RAYTRACING_TIER_1_1, "Indirect" },
};
unsigned int i;

@ -842,6 +842,9 @@ ID3D12CommandSignature *create_command_signature_(unsigned int line,
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH:
signature_desc.ByteStride = sizeof(D3D12_DISPATCH_ARGUMENTS);
break;
case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS:
signature_desc.ByteStride = sizeof(D3D12_DISPATCH_RAYS_DESC);
break;
default:
return NULL;
}

Loading…
Cancel
Save