Mesa (main): d3d12: Align output buffer offset access to D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOURCE_REQUIREMENTS.CompressedBitstreamBufferAccessAlignment

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 2 17:12:08 UTC 2022


Module: Mesa
Branch: main
Commit: 65b3decd5b83c1ff9729585a3c1d5067b88f6bfd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=65b3decd5b83c1ff9729585a3c1d5067b88f6bfd

Author: Sil Vilerino <sivileri at microsoft.com>
Date:   Fri May 20 07:38:48 2022 -0700

d3d12: Align output buffer offset access to D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOURCE_REQUIREMENTS.CompressedBitstreamBufferAccessAlignment

Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16644>

---

 src/gallium/drivers/d3d12/d3d12_video_enc.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/gallium/drivers/d3d12/d3d12_video_enc.cpp b/src/gallium/drivers/d3d12/d3d12_video_enc.cpp
index ddf232cc702..0bf72b7debe 100644
--- a/src/gallium/drivers/d3d12/d3d12_video_enc.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_video_enc.cpp
@@ -1311,6 +1311,15 @@ d3d12_video_encoder_encode_bitstream(struct pipe_video_codec * codec,
 
    uint32_t prefixGeneratedHeadersByteSize = d3d12_video_encoder_build_codec_headers(pD3D12Enc);
 
+   // If driver needs offset alignment for bitstream resource, we will pad zeroes on the codec header to this end.
+   if (
+      (pD3D12Enc->m_currentEncodeCapabilities.m_ResourceRequirementsCaps.CompressedBitstreamBufferAccessAlignment > 1)
+      && ((prefixGeneratedHeadersByteSize % pD3D12Enc->m_currentEncodeCapabilities.m_ResourceRequirementsCaps.CompressedBitstreamBufferAccessAlignment) != 0)
+   ) {
+      prefixGeneratedHeadersByteSize = ALIGN(prefixGeneratedHeadersByteSize, pD3D12Enc->m_currentEncodeCapabilities.m_ResourceRequirementsCaps.CompressedBitstreamBufferAccessAlignment);
+      pD3D12Enc->m_BitstreamHeadersBuffer.resize(prefixGeneratedHeadersByteSize, 0);
+   }
+
    const D3D12_VIDEO_ENCODER_ENCODEFRAME_INPUT_ARGUMENTS inputStreamArguments = {
       // D3D12_VIDEO_ENCODER_SEQUENCE_CONTROL_DESC
       { // D3D12_VIDEO_ENCODER_SEQUENCE_CONTROL_FLAGS
@@ -1402,6 +1411,7 @@ d3d12_video_encoder_encode_bitstream(struct pipe_video_codec * codec,
    };
 
    const D3D12_VIDEO_ENCODER_RESOLVE_METADATA_OUTPUT_ARGUMENTS outputMetadataCmd = {
+      /*If offset were to change, has to be aligned to pD3D12Enc->m_currentEncodeCapabilities.m_ResourceRequirementsCaps.EncoderMetadataBufferAccessAlignment*/
       { pD3D12Enc->m_spResolvedMetadataBuffer.Get(), 0 }
    };
    pD3D12Enc->m_spEncodeCommandList->ResolveEncoderOutputMetadata(&inputMetadataCmd, &outputMetadataCmd);



More information about the mesa-commit mailing list