d3d12: Remove max_references usage from frontend to reserve barriers array

Reviewed-By: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31017>
This commit is contained in:
Sil Vilerino 2024-09-04 07:12:41 -04:00 committed by Marge Bot
parent 7c8ffc34aa
commit 72f4b7f01b

View file

@ -2089,12 +2089,9 @@ d3d12_video_encoder_encode_bitstream(struct pipe_video_codec * codec,
D3D12_VIDEO_ENCODER_PICTURE_CONTROL_FLAGS picCtrlFlags = D3D12_VIDEO_ENCODER_PICTURE_CONTROL_FLAG_NONE;
// Transition DPB reference pictures to read mode
uint32_t maxReferences = d3d12_video_encoder_get_current_max_dpb_capacity(pD3D12Enc);
std::vector<D3D12_RESOURCE_BARRIER> rgReferenceTransitions(maxReferences);
std::vector<D3D12_RESOURCE_BARRIER> rgReferenceTransitions;
if ((referenceFramesDescriptor.NumTexture2Ds > 0) ||
(pD3D12Enc->m_upDPBManager->is_current_frame_used_as_reference())) {
rgReferenceTransitions.clear();
rgReferenceTransitions.reserve(maxReferences);
if (reconPicOutputTextureDesc.pReconstructedPicture != nullptr)
picCtrlFlags |= D3D12_VIDEO_ENCODER_PICTURE_CONTROL_FLAG_USED_AS_REFERENCE_PICTURE;
@ -2103,6 +2100,10 @@ d3d12_video_encoder_encode_bitstream(struct pipe_video_codec * codec,
if (referenceFramesDescriptor.pSubresources == nullptr) {
// Reserve allocation for AoT transitions count
rgReferenceTransitions.reserve(static_cast<size_t>(referenceFramesDescriptor.NumTexture2Ds +
((reconPicOutputTextureDesc.pReconstructedPicture != nullptr) ? 1u : 0u)));
// Array of resources mode for reference pictures
// Transition all subresources of each reference frame independent resource allocation
@ -2142,6 +2143,10 @@ d3d12_video_encoder_encode_bitstream(struct pipe_video_codec * codec,
}
#endif
// Reserve allocation for texture array transitions count
rgReferenceTransitions.reserve(
static_cast<size_t>(pD3D12Enc->m_currentEncodeConfig.m_encodeFormatInfo.PlaneCount * referencesTexArrayDesc.DepthOrArraySize));
for (uint32_t referenceSubresource = 0; referenceSubresource < referencesTexArrayDesc.DepthOrArraySize;
referenceSubresource++) {