diff --git a/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp b/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp index 24872beff7c..62a1d2725d1 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp @@ -62,6 +62,7 @@ d3d12_video_buffer_create_impl(struct pipe_context *pipe, // Fill vtable pD3D12VideoBuffer->base.destroy = d3d12_video_buffer_destroy; + pD3D12VideoBuffer->base.get_resources = d3d12_video_buffer_resources; pD3D12VideoBuffer->base.get_sampler_view_planes = d3d12_video_buffer_get_sampler_view_planes; pD3D12VideoBuffer->base.get_sampler_view_components = d3d12_video_buffer_get_sampler_view_components; pD3D12VideoBuffer->base.get_surfaces = d3d12_video_buffer_get_surfaces; @@ -233,6 +234,32 @@ error: return nullptr; } +/** + * get an individual resource for each plane, + * only returns existing resources by reference + */ +void +d3d12_video_buffer_resources(struct pipe_video_buffer *buffer, + struct pipe_resource **resources) +{ + struct d3d12_video_buffer *pD3D12VideoBuffer = (struct d3d12_video_buffer *) buffer; + assert(pD3D12VideoBuffer); + + // pCurPlaneResource refers to the planar resource, not the overall resource. + // in d3d12_resource this is handled by having a linked list of planes with + // d3dRes->base.next ptr to next plane resource + // starting with the plane 0 being the overall resource + struct pipe_resource *pCurPlaneResource = &pD3D12VideoBuffer->texture->base.b; + + for (uint i = 0; i < pD3D12VideoBuffer->num_planes; ++i) { + assert(pCurPlaneResource); // the d3d12_resource has a linked list with the exact name of number of elements + // as planes + + resources[i] = pCurPlaneResource; + pCurPlaneResource = pCurPlaneResource->next; + } +} + /** * get an individual sampler view for each plane */ diff --git a/src/gallium/drivers/d3d12/d3d12_video_buffer.h b/src/gallium/drivers/d3d12/d3d12_video_buffer.h index 292ac128a6e..c608b99495c 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_buffer.h +++ b/src/gallium/drivers/d3d12/d3d12_video_buffer.h @@ -53,6 +53,14 @@ d3d12_video_buffer_from_handle( struct pipe_context *pipe, void d3d12_video_buffer_destroy(struct pipe_video_buffer *buffer); +/** + * get an individual resource for each plane, + * only returns existing resources by reference + */ +void +d3d12_video_buffer_resources(struct pipe_video_buffer *buffer, + struct pipe_resource **resources); + /** * get an individual sampler view for each plane */