d3d12: d3d12_video_buffer - Expose associated data with subresource idx

Reviewed-by: Pohsiang (John) Hsu <pohhsu@microsoft.com>
Reviewed-by: Yubo Xie <yuboxie@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38144>
This commit is contained in:
Silvio Vilerino 2025-10-26 10:36:53 -04:00 committed by Marge Bot
parent db5d42d437
commit 0aba51691b
3 changed files with 16 additions and 1 deletions

View file

@ -34,6 +34,18 @@ struct ID3D12Device;
struct ID3D12CommandQueue;
struct ID3D12Resource;
struct d3d12_interop_video_buffer_associated_data
{
/*
* Subresource index within the underlying ID3D12Resource
* representing this video buffer.
*
* This is useful when the underlying resource is a texture array
* and each video buffer maps to a different subresource within it.
*/
uint32_t subresource_index;
};
struct d3d12_interop_device_info {
uint64_t adapter_luid;
ID3D12Device *device;

View file

@ -65,7 +65,7 @@ d3d12_video_buffer_create_impl(struct pipe_context *pipe,
pD3D12VideoBuffer->base.height = tmpl->height;
pD3D12VideoBuffer->base.interlaced = tmpl->interlaced;
pD3D12VideoBuffer->base.contiguous_planes = true;
pD3D12VideoBuffer->base.associated_data = nullptr;
pD3D12VideoBuffer->base.associated_data = &pD3D12VideoBuffer->d3d12_video_buffer_associated_data;
pD3D12VideoBuffer->idx_texarray_slots = 0;
pD3D12VideoBuffer->m_spVideoTexArrayDPBPoolInUse.reset();
@ -535,6 +535,7 @@ d3d12_video_create_dpb_buffer_texarray(struct pipe_video_codec *codec,
if (((*pD3D12Enc->m_spVideoTexArrayDPBPoolInUse) & (1 << i)) == 0)
{
buf->idx_texarray_slots = i;
buf->d3d12_video_buffer_associated_data.subresource_index = i;
(*pD3D12Enc->m_spVideoTexArrayDPBPoolInUse) |= (1 << buf->idx_texarray_slots); // Mark i-th bit as used
bFoundEmptySlot = true;
break;

View file

@ -30,6 +30,7 @@
#include "vl/vl_defines.h"
#include <vector>
#include "d3d12_video_types.h"
#include "d3d12_interop_public.h"
///
/// Pipe video buffer interface starts
@ -107,6 +108,7 @@ struct d3d12_video_buffer
// in the function d3d12_video_enc::d3d12_video_create_dpb_buffer()
// Points to the same address as d3d12_video_encoder::m_spVideoTexArrayDPBPoolInUse
std::shared_ptr<uint32_t> m_spVideoTexArrayDPBPoolInUse;
struct d3d12_interop_video_buffer_associated_data d3d12_video_buffer_associated_data = {};
};
///