Skip to content

Commit

Permalink
vkd3d: Implement and expose ID3D12GraphicsCommandListExt2 as supported.
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Bogacki <[email protected]>
  • Loading branch information
Saancreed committed May 2, 2024
1 parent 2676495 commit 2e09b7c
Show file tree
Hide file tree
Showing 4 changed files with 414 additions and 10 deletions.
4 changes: 4 additions & 0 deletions libs/vkd3d/breadcrumbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ static const char *vkd3d_breadcrumb_command_type_to_str(enum vkd3d_breadcrumb_co
return "copy_rtas";
case VKD3D_BREADCRUMB_COMMAND_EMIT_RTAS_POSTBUILD:
return "emit_rtas_postbuild";
case VKD3D_BREADCRUMB_COMMAND_BUILD_OMM:
return "build_omm";
case VKD3D_BREADCRUMB_COMMAND_EMIT_OMM_POSTBUILD:
return "emit_omm_postbuild";
case VKD3D_BREADCRUMB_COMMAND_TRACE_RAYS:
return "trace_rays";
case VKD3D_BREADCRUMB_COMMAND_BARRIER:
Expand Down
32 changes: 24 additions & 8 deletions libs/vkd3d/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ static VkImageLayout d3d12_command_list_get_depth_stencil_resource_layout(const
static void d3d12_command_list_decay_optimal_dsv_resource(struct d3d12_command_list *list,
const struct d3d12_resource *resource, uint32_t plane_optimal_mask,
struct d3d12_command_list_barrier_batch *batch);
static void d3d12_command_list_end_transfer_batch(struct d3d12_command_list *list);
static void d3d12_command_list_end_wbi_batch(struct d3d12_command_list *list);
static inline void d3d12_command_list_ensure_transfer_batch(struct d3d12_command_list *list, enum vkd3d_batch_type type);
static void d3d12_command_list_free_rtas_batch(struct d3d12_command_list *list);
static void d3d12_command_list_flush_rtas_batch(struct d3d12_command_list *list);
static void d3d12_command_list_clear_rtas_batch(struct d3d12_command_list *list);

static void d3d12_command_list_flush_query_resolves(struct d3d12_command_list *list);
Expand Down Expand Up @@ -5090,7 +5088,8 @@ HRESULT STDMETHODCALLTYPE d3d12_command_list_QueryInterface(d3d12_command_list_i
}

if (IsEqualGUID(iid, &IID_ID3D12GraphicsCommandListExt)
|| IsEqualGUID(iid, &IID_ID3D12GraphicsCommandListExt1))
|| IsEqualGUID(iid, &IID_ID3D12GraphicsCommandListExt1)
|| IsEqualGUID(iid, &IID_ID3D12GraphicsCommandListExt2))
{
struct d3d12_command_list *command_list = impl_from_ID3D12GraphicsCommandList(iface);
d3d12_command_list_vkd3d_ext_AddRef(&command_list->ID3D12GraphicsCommandListExt_iface);
Expand Down Expand Up @@ -8323,7 +8322,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyResource(d3d12_command_list
VKD3D_BREADCRUMB_COMMAND(COPY);
}

static void d3d12_command_list_end_transfer_batch(struct d3d12_command_list *list)
void d3d12_command_list_end_transfer_batch(struct d3d12_command_list *list)
{
struct d3d12_command_list_barrier_batch barriers;
size_t i;
Expand Down Expand Up @@ -15428,13 +15427,15 @@ static void d3d12_command_list_free_rtas_batch(struct d3d12_command_list *list)

vkd3d_free(rtas_batch->build_infos);
vkd3d_free(rtas_batch->geometry_infos);
vkd3d_free(rtas_batch->omm_infos);
vkd3d_free(rtas_batch->range_infos);
vkd3d_free(rtas_batch->range_ptrs);
}

static bool d3d12_command_list_allocate_rtas_build_info(struct d3d12_command_list *list, uint32_t geometry_count,
bool d3d12_command_list_allocate_rtas_build_info(struct d3d12_command_list *list, uint32_t geometry_count,
VkAccelerationStructureBuildGeometryInfoKHR **build_info,
VkAccelerationStructureGeometryKHR **geometry_infos,
VkAccelerationStructureTrianglesOpacityMicromapEXT **omm_infos,
VkAccelerationStructureBuildRangeInfoKHR **range_infos)
{
struct d3d12_rtas_batch_state *rtas_batch = &list->rtas_batch;
Expand All @@ -15453,6 +15454,13 @@ static bool d3d12_command_list_allocate_rtas_build_info(struct d3d12_command_lis
return false;
}

if (!vkd3d_array_reserve((void **)&rtas_batch->omm_infos, &rtas_batch->omm_info_size,
rtas_batch->geometry_info_count + geometry_count, sizeof(*rtas_batch->omm_infos)))
{
ERR("Failed to allocate opacity micromap info array.\n");
return false;
}

if (!vkd3d_array_reserve((void **)&rtas_batch->range_infos, &rtas_batch->range_info_size,
rtas_batch->geometry_info_count + geometry_count, sizeof(*rtas_batch->range_infos)))
{
Expand All @@ -15462,6 +15470,7 @@ static bool d3d12_command_list_allocate_rtas_build_info(struct d3d12_command_lis

*build_info = &rtas_batch->build_infos[rtas_batch->build_info_count];
*geometry_infos = &rtas_batch->geometry_infos[rtas_batch->geometry_info_count];
*omm_infos = &rtas_batch->omm_infos[rtas_batch->geometry_info_count];
*range_infos = &rtas_batch->range_infos[rtas_batch->geometry_info_count];

rtas_batch->build_info_count += 1;
Expand All @@ -15478,7 +15487,7 @@ static void d3d12_command_list_clear_rtas_batch(struct d3d12_command_list *list)
rtas_batch->geometry_info_count = 0;
}

static void d3d12_command_list_flush_rtas_batch(struct d3d12_command_list *list)
void d3d12_command_list_flush_rtas_batch(struct d3d12_command_list *list)
{
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
struct d3d12_rtas_batch_state *rtas_batch = &list->rtas_batch;
Expand Down Expand Up @@ -15526,6 +15535,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_BuildRaytracingAccelerationStru
struct d3d12_command_list *list = impl_from_ID3D12GraphicsCommandList(iface);
const struct vkd3d_vk_device_procs *vk_procs = &list->device->vk_procs;
struct d3d12_rtas_batch_state *rtas_batch = &list->rtas_batch;
VkAccelerationStructureTrianglesOpacityMicromapEXT *omm_infos;
VkAccelerationStructureBuildGeometryInfoKHR *build_info;
VkAccelerationStructureBuildRangeInfoKHR *range_infos;
VkAccelerationStructureGeometryKHR *geometry_infos;
Expand Down Expand Up @@ -15560,6 +15570,12 @@ static void STDMETHODCALLTYPE d3d12_command_list_BuildRaytracingAccelerationStru
vk_barrier.dstStageMask = VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR;
vk_barrier.dstAccessMask = VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_KHR | VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_KHR;

if (list->device->device_info.opacity_micromap_features.micromap)
{
vk_barrier.srcAccessMask |= VK_ACCESS_2_MICROMAP_READ_BIT_EXT;
vk_barrier.dstAccessMask |= VK_ACCESS_2_MICROMAP_READ_BIT_EXT;
}

memset(&dep_info, 0, sizeof(dep_info));
dep_info.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO;
dep_info.memoryBarrierCount = 1;
Expand All @@ -15578,7 +15594,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_BuildRaytracingAccelerationStru
#endif

if (!d3d12_command_list_allocate_rtas_build_info(list, geometry_count,
&build_info, &geometry_infos, &range_infos))
&build_info, &geometry_infos, &omm_infos, &range_infos))
return;

if (!vkd3d_acceleration_structure_convert_inputs(list->device, &desc->Inputs,
Expand Down Expand Up @@ -16580,7 +16596,7 @@ static struct d3d12_command_list *unsafe_impl_from_ID3D12CommandList(ID3D12Comma
return CONTAINING_RECORD(iface, struct d3d12_command_list, ID3D12GraphicsCommandList_iface);
}

extern CONST_VTBL struct ID3D12GraphicsCommandListExt1Vtbl d3d12_command_list_vkd3d_ext_vtbl;
extern CONST_VTBL struct ID3D12GraphicsCommandListExt2Vtbl d3d12_command_list_vkd3d_ext_vtbl;

static void d3d12_command_list_init_attachment_info(VkRenderingAttachmentInfo *attachment_info)
{
Expand Down
Loading

0 comments on commit 2e09b7c

Please sign in to comment.