diff --git a/src/gallium/drivers/d3d12/d3d12_interop_public.h b/src/gallium/drivers/d3d12/d3d12_interop_public.h index 27ece99261c..0f7521e7eb5 100644 --- a/src/gallium/drivers/d3d12/d3d12_interop_public.h +++ b/src/gallium/drivers/d3d12/d3d12_interop_public.h @@ -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; diff --git a/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp b/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp index 44aa326c637..5c4121a97f8 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp @@ -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; diff --git a/src/gallium/drivers/d3d12/d3d12_video_buffer.h b/src/gallium/drivers/d3d12/d3d12_video_buffer.h index 378bfb85bba..20291ed77fc 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_buffer.h +++ b/src/gallium/drivers/d3d12/d3d12_video_buffer.h @@ -30,6 +30,7 @@ #include "vl/vl_defines.h" #include #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 m_spVideoTexArrayDPBPoolInUse; + struct d3d12_interop_video_buffer_associated_data d3d12_video_buffer_associated_data = {}; }; ///