- Timestamp:
- Mar 17, 2025 3:17:37 PM (8 weeks ago)
- svn:sync-xref-src-repo-rev:
- 167982
- Location:
- trunk/src/libs/dxvk-2.3.1/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/dxvk-2.3.1/src/d3d11/d3d11_device.cpp
r108423 r108577 3114 3114 || dxvkDevice->queues().videoDecode.queueHandle == VK_NULL_HANDLE) 3115 3115 return; 3116 3117 /* Filter out profiles that do not work well. */ 3118 std::vector<VkVideoCodecOperationFlagBitsKHR> vulkanVideoDecodeBlacklist; 3119 3120 if (dxvkDevice->adapter()->matchesDriver(VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA, 0, 0)) { 3121 /* H265: decoded picture consists of multiple small tiles with garbled content. */ 3122 vulkanVideoDecodeBlacklist.push_back(VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR); 3123 3124 /* AV1: crash. VideoSessionMemory is allocated from DEVICE_LOCAL memory type, but 3125 * anv_init_av1_cdf_tables maps ANV_VID_MEM_AV1_CDF_DEFAULTS_* buffers in order to 3126 * initialize them. The mapped pointer is inaccessible. 3127 * Tested on Intel Arc B570 discrete GPU. 3128 */ 3129 vulkanVideoDecodeBlacklist.push_back(VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR); 3130 } 3131 else if (dxvkDevice->adapter()->matchesDriver(VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS, 0, 0)) { 3132 /* H265: same as VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA. */ 3133 vulkanVideoDecodeBlacklist.push_back(VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR); 3134 } 3116 3135 3117 3136 /* … … 3205 3224 }; 3206 3225 3226 const struct D3D11VideoDecoderProfile profile_ModeAV1_VLD_Profile0 = { 3227 /* .guid = */ DXVA_ModeAV1_VLD_Profile0, /* D3D11_DECODER_PROFILE_AV1_VLD_PROFILE0 */ 3228 /* .decoderConfigs = */ std::vector<D3D11_VIDEO_DECODER_CONFIG> { 3229 { 3230 /* .guidConfigBitstreamEncryption = */ DXVA2_NoEncrypt, 3231 /* .guidConfigMBcontrolEncryption = */ DXVA2_NoEncrypt, 3232 /* .guidConfigResidDiffEncryption = */ DXVA2_NoEncrypt, 3233 /* .ConfigBitstreamRaw = */ 1, 3234 /* .ConfigMBcontrolRasterOrder = */ 0, 3235 /* .ConfigResidDiffHost = */ 0, 3236 /* .ConfigSpatialResid8 = */ 0, 3237 /* .ConfigResid8Subtraction = */ 0, 3238 /* .ConfigSpatialHost8or9Clipping = */ 0, 3239 /* .ConfigSpatialResidInterleaved = */ 0, 3240 /* .ConfigIntraResidUnsigned = */ 0, 3241 /* .ConfigResidDiffAccelerator = */ 0, 3242 /* .ConfigHostInverseScan = */ 0, 3243 /* .ConfigSpecificIDCT = */ 0, 3244 /* .Config4GroupedCoefs = */ 0, 3245 /* .ConfigMinRenderTargetBuffCount = */ 3, 3246 /* .ConfigDecoderSpecific = */ 0 3247 } 3248 }, 3249 /* .supportedFormats = */ std::vector<DXGI_FORMAT> { 3250 DXGI_FORMAT_NV12 3251 } 3252 }; 3253 3207 3254 /* 3208 3255 * Add desired Vulkan profile descriptions to the 'mappings'. … … 3237 3284 }; 3238 3285 m_vulkanDecodeProfiles[1].profileInfo = 3239 { VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR, &m_vulkanDecodeProfiles[1].h26 4ProfileInfo,3286 { VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR, &m_vulkanDecodeProfiles[1].h265ProfileInfo, 3240 3287 VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, 3241 3288 VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR, … … 3253 3300 mappings.back().d3dProfiles.push_back(profile_ModeHEVC_VLD_Main); 3254 3301 3255 /// @todo More Vulkan profiles: AV1 3302 m_vulkanDecodeProfiles[2].profileName = "AV1"; 3303 m_vulkanDecodeProfiles[2].av1ProfileInfo = 3304 { VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR, nullptr, 3305 STD_VIDEO_AV1_PROFILE_MAIN, 3306 VK_TRUE /* filmGrainSupport */ 3307 }; 3308 m_vulkanDecodeProfiles[2].profileInfo = 3309 { VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR, &m_vulkanDecodeProfiles[2].av1ProfileInfo, 3310 VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR, 3311 VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR, 3312 VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR, 3313 VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR 3314 }; 3315 m_vulkanDecodeProfiles[2].decodeAV1Capabilities = 3316 { VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR }; 3317 m_vulkanDecodeProfiles[2].decodeCapabilities = 3318 { VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR, &m_vulkanDecodeProfiles[2].decodeAV1Capabilities }; 3319 m_vulkanDecodeProfiles[2].videoCapabilities = 3320 { VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR, &m_vulkanDecodeProfiles[2].decodeCapabilities }; 3321 3322 mappings.push_back({ m_vulkanDecodeProfiles[2] }); 3323 mappings.back().d3dProfiles.push_back(profile_ModeAV1_VLD_Profile0); 3256 3324 3257 3325 /* … … 3262 3330 3263 3331 for (auto& m: mappings) { 3332 const auto it = std::find_if(vulkanVideoDecodeBlacklist.begin(), vulkanVideoDecodeBlacklist.end(), 3333 [ op = m.dxvkProfile.profileInfo.videoCodecOperation ](VkVideoCodecOperationFlagBitsKHR v) -> bool 3334 { return v == op; }); 3335 if (it != vulkanVideoDecodeBlacklist.end()) 3336 continue; 3337 3264 3338 VkResult vr = vki->vkGetPhysicalDeviceVideoCapabilitiesKHR(physicalDevice, 3265 3339 &m.dxvkProfile.profileInfo, &m.dxvkProfile.videoCapabilities); -
trunk/src/libs/dxvk-2.3.1/src/d3d11/d3d11_device.h
r108419 r108577 703 703 704 704 /* Vulkan video profiles, supported by DxvkVideoDecoder. Not necessarily supported by hardware. */ 705 std::array<DxvkVideoDecodeProfileInfo, 2> m_vulkanDecodeProfiles;705 std::array<DxvkVideoDecodeProfileInfo, 3> m_vulkanDecodeProfiles; 706 706 707 707 /* Supported D3D11 profiles with a reference to the underlaying Vulkan profile (m_vulkanDecodeProfiles). -
trunk/src/libs/dxvk-2.3.1/src/d3d11/d3d11_video.cpp
r108423 r108577 25 25 26 26 /* Arbitrary. Sufficiently big for a compressed frame (usually). */ 27 m_bitstreamBufferSize = align(m_desc.SampleWidth * m_desc.SampleHeight / 5, 1024 * 1024);27 m_bitstreamBufferSize = align(m_desc.SampleWidth * m_desc.SampleHeight, 1024 * 1024); 28 28 29 29 m_videoDecoder = m_device->createVideoDecoder(profile, … … 92 92 cbBuffer = m_bitstreamBufferSize; 93 93 break; 94 case D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL: 95 if (m_videoDecoder->GetVideoCodecOperation() == VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR) 96 cbBuffer = 64 * 64 * sizeof(DXVA_Tile_AV1); 97 else 98 cbBuffer = 65536; 99 break; 94 100 default: 95 101 cbBuffer = 65536; … … 117 123 118 124 template<typename DXVA_Slice_T> 119 static bool GetSliceOffsets AndNALType(125 static bool GetSliceOffsets( 120 126 DxvkVideoDecodeInputParameters *pParms, 121 127 const D3D11_VIDEO_DECODER_BUFFER_DESC* pSliceDesc, … … 128 134 /* D3D11VideoDecoder::GetVideoDecodeInputParameters checks that 'pSliceDesc->DataSize' is less than 129 135 * the size of D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL buffer that is assigned in 130 * D3D11VideoDecoder::GetDecoderBuffer. I.e. 'cSlices' is lim uted too.136 * D3D11VideoDecoder::GetDecoderBuffer. I.e. 'cSlices' is limited too. 131 137 */ 132 pParms->sliceOffsets.resize(cSlices); 138 if (cSlices == 0) 139 return false; 140 141 pParms->sliceOrTileOffsets.resize(cSlices); 142 pParms->sliceOrTileSizes.resize(cSlices); 133 143 134 144 for (uint32_t i = 0; i < cSlices; ++i) { … … 147 157 Logger::warn(str::format("D3D11VideoDecoder::GetH264: Ignored slice with wBadSliceChopping ", 148 158 slice.wBadSliceChopping)); 149 return false; /// @todo not supported yet159 return false; 150 160 } 151 161 152 pParms->sliceOffsets[i] = slice.BSNALunitDataLocation; 153 154 const uint8_t *pu8NALHdr = pBitStream + slice.BSNALunitDataLocation; 155 const uint8_t nal_unit_type = pu8NALHdr[3] & 0x1F; 156 157 Logger::debug(str::format("NAL[", i, "]=", (uint32_t)nal_unit_type, " at ", 158 slice.BSNALunitDataLocation, "/", slice.SliceBytesInBuffer)); 159 160 if (i == 0) 161 pParms->nal_unit_type = nal_unit_type; 162 pParms->sliceOrTileOffsets[i] = slice.BSNALunitDataLocation; 163 pParms->sliceOrTileSizes[i] = slice.SliceBytesInBuffer; 162 164 } 163 165 … … 291 293 /* Fetch slice offsets. */ 292 294 bool fSuccess = config.ConfigBitstreamRaw == 2 293 ? GetSliceOffsets AndNALType<DXVA_Slice_H264_Short>(&p, pSliceDesc, pSlices, pBitStream, pBitStreamDesc->DataSize)294 : GetSliceOffsets AndNALType<DXVA_Slice_H264_Long>(&p, pSliceDesc, pSlices, pBitStream, pBitStreamDesc->DataSize);295 ? GetSliceOffsets<DXVA_Slice_H264_Short>(&p, pSliceDesc, pSlices, pBitStream, pBitStreamDesc->DataSize) 296 : GetSliceOffsets<DXVA_Slice_H264_Long>(&p, pSliceDesc, pSlices, pBitStream, pBitStreamDesc->DataSize); 295 297 if (!fSuccess) 296 298 return false; 297 299 300 const uint8_t *pu8NALHdr = pBitStream + pParms->sliceOrTileOffsets[0]; 301 pParms->h264.nal_unit_type = pu8NALHdr[3] & 0x1F; 302 Logger::debug(str::format("NAL=", (uint32_t)pParms->h264.nal_unit_type, " at ", 303 pParms->sliceOrTileOffsets[0], "/", pParms->sliceOrTileSizes[0])); 304 298 305 p.h264.stdH264PictureInfo.flags.field_pic_flag = pPicParams->field_pic_flag; 299 306 p.h264.stdH264PictureInfo.flags.is_intra = pPicParams->IntraPicFlag; 300 p.h264.stdH264PictureInfo.flags.IdrPicFlag = p. nal_unit_type == 5 ? 1 : 0;307 p.h264.stdH264PictureInfo.flags.IdrPicFlag = p.h264.nal_unit_type == 5 ? 1 : 0; 301 308 p.h264.stdH264PictureInfo.flags.bottom_field_flag = pPicParams->CurrPic.AssociatedFlag; /* flag is bottom field flag */ 302 309 p.h264.stdH264PictureInfo.flags.is_reference = pPicParams->RefPicFlag; … … 325 332 p.idSurface = pPicParams->CurrPic.Index7Bits; 326 333 327 if (pPicParams->IntraPicFlag) { 328 p.refFramesCount = 0; 329 } 330 else { 331 /* Reference frame surfaces. */ 332 uint32_t idxRefFrame = 0; 333 for (uint32_t i = 0; i < 16; ++i) { 334 const DXVA_PicEntry_H264& r = pPicParams->RefFrameList[i]; 335 if (r.bPicEntry == 0xFF) 336 continue; 337 338 DxvkRefFrameInfo& refFrameInfo = p.refFrames[idxRefFrame]; 339 refFrameInfo.idSurface = r.Index7Bits; 340 refFrameInfo.longTermReference = r.AssociatedFlag; 341 refFrameInfo.usedForReference = (uint8_t)(pPicParams->UsedForReferenceFlags >> (2 * i)) & 0x3; 342 refFrameInfo.nonExistingFrame = (uint8_t)(pPicParams->NonExistingFrameFlags >> i) & 0x1; 343 refFrameInfo.frame_num = pPicParams->FrameNumList[i]; 344 refFrameInfo.PicOrderCnt[0] = pPicParams->FieldOrderCntList[i][0]; 345 refFrameInfo.PicOrderCnt[1] = pPicParams->FieldOrderCntList[i][1]; 346 347 ++idxRefFrame; 348 } 349 350 p.refFramesCount = idxRefFrame; 351 } 334 /* Reference frame surfaces. */ 335 uint32_t idxRefFrame = 0; 336 for (uint32_t i = 0; i < 16; ++i) { 337 const DXVA_PicEntry_H264& r = pPicParams->RefFrameList[i]; 338 if (r.bPicEntry == 0xFF) 339 continue; 340 341 DxvkRefFrameInfo& refFrameInfo = p.refFrames[idxRefFrame]; 342 refFrameInfo.idSurface = r.Index7Bits; 343 refFrameInfo.h264.longTermReference = r.AssociatedFlag; 344 refFrameInfo.h264.usedForReference = (uint8_t)(pPicParams->UsedForReferenceFlags >> (2 * i)) & 0x3; 345 refFrameInfo.h264.nonExistingFrame = (uint8_t)(pPicParams->NonExistingFrameFlags >> i) & 0x1; 346 refFrameInfo.h264.frame_num = pPicParams->FrameNumList[i]; 347 refFrameInfo.h264.PicOrderCnt[0] = pPicParams->FieldOrderCntList[i][0]; 348 refFrameInfo.h264.PicOrderCnt[1] = pPicParams->FieldOrderCntList[i][1]; 349 350 ++idxRefFrame; 351 } 352 353 p.refFramesCount = idxRefFrame; 352 354 353 355 return true; … … 413 415 p.h265.vpsProfileTierLevel.general_level_idc = STD_VIDEO_H265_LEVEL_IDC_6_2; /* Unknown, set to maxLevelIdc by Dxvk decoder. */ 414 416 415 p.h265.sps.flags.sps_temporal_id_nesting_flag = 0; / // @todo Unknown417 p.h265.sps.flags.sps_temporal_id_nesting_flag = 0; /* Unused */ 416 418 p.h265.sps.flags.separate_colour_plane_flag = pPicParams->separate_colour_plane_flag; 417 419 p.h265.sps.flags.conformance_window_flag = 0; /* Unknown */ 418 p.h265.sps.flags.sps_sub_layer_ordering_info_present_flag = 0; / // @todo Unknown420 p.h265.sps.flags.sps_sub_layer_ordering_info_present_flag = 0; /* spsDecPicBufMgr applies to all sub-layers */ 419 421 p.h265.sps.flags.scaling_list_enabled_flag = pPicParams->scaling_list_enabled_flag; 420 p.h265.sps.flags.sps_scaling_list_data_present_flag = 0; / // @todo pps?422 p.h265.sps.flags.sps_scaling_list_data_present_flag = 0; /* Part of pps */ 421 423 p.h265.sps.flags.amp_enabled_flag = pPicParams->amp_enabled_flag; 422 424 p.h265.sps.flags.sample_adaptive_offset_enabled_flag = pPicParams->sample_adaptive_offset_enabled_flag; … … 427 429 p.h265.sps.flags.strong_intra_smoothing_enabled_flag = pPicParams->strong_intra_smoothing_enabled_flag; 428 430 p.h265.sps.flags.vui_parameters_present_flag = 0; /* Unused */ 429 p.h265.sps.flags.sps_extension_present_flag = 0; / // @todo unknown430 p.h265.sps.flags.sps_range_extension_flag = 0; / // @todo unknown431 p.h265.sps.flags.transform_skip_rotation_enabled_flag = pPicParams->transform_skip_enabled_flag;432 p.h265.sps.flags.transform_skip_context_enabled_flag = pPicParams->transform_skip_enabled_flag;433 p.h265.sps.flags.implicit_rdpcm_enabled_flag = 0; / // @todo unknown434 p.h265.sps.flags.explicit_rdpcm_enabled_flag = 0; / // @todo unknown435 p.h265.sps.flags.extended_precision_processing_flag = 0; / // @todo unknown436 p.h265.sps.flags.intra_smoothing_disabled_flag = 0; / // @todo unknown437 p.h265.sps.flags.high_precision_offsets_enabled_flag = 0; / // @todo unknown438 p.h265.sps.flags.persistent_rice_adaptation_enabled_flag = 0; / // @todo unknown439 p.h265.sps.flags.cabac_bypass_alignment_enabled_flag = 0; / // @todo unknown440 p.h265.sps.flags.sps_scc_extension_flag = 0; / // @todo unknown441 p.h265.sps.flags.sps_curr_pic_ref_enabled_flag = 0; /// @todo unknown431 p.h265.sps.flags.sps_extension_present_flag = 0; /* Unused */ 432 p.h265.sps.flags.sps_range_extension_flag = 0; /* Unused */ 433 p.h265.sps.flags.transform_skip_rotation_enabled_flag = 0; /* Unused */ 434 p.h265.sps.flags.transform_skip_context_enabled_flag = 0; /* Unused */ 435 p.h265.sps.flags.implicit_rdpcm_enabled_flag = 0; /* Unused */ 436 p.h265.sps.flags.explicit_rdpcm_enabled_flag = 0; /* Unused */ 437 p.h265.sps.flags.extended_precision_processing_flag = 0; /* Unused */ 438 p.h265.sps.flags.intra_smoothing_disabled_flag = 0; /* Unused */ 439 p.h265.sps.flags.high_precision_offsets_enabled_flag = 0; /* Unused. 0 for 8 bits processing. */ 440 p.h265.sps.flags.persistent_rice_adaptation_enabled_flag = 0; /* Unused */ 441 p.h265.sps.flags.cabac_bypass_alignment_enabled_flag = 0; /* Unused */ 442 p.h265.sps.flags.sps_scc_extension_flag = 0; /* Unused */ 443 p.h265.sps.flags.sps_curr_pic_ref_enabled_flag = 1; /* Unknown. */ 442 444 p.h265.sps.flags.palette_mode_enabled_flag = 0; /* Unused */ 443 445 p.h265.sps.flags.sps_palette_predictor_initializers_present_flag = 0; /* Unused */ 444 p.h265.sps.flags.intra_boundary_filtering_disabled_flag = 0; / // @todo unknown446 p.h265.sps.flags.intra_boundary_filtering_disabled_flag = 0; /* Unused */ 445 447 p.h265.sps.chroma_format_idc = StdVideoH265ChromaFormatIdc(pPicParams->chroma_format_idc); 446 448 p.h265.sps.pic_width_in_luma_samples = pPicParams->PicWidthInMinCbsY * MinCbSizeY; 447 449 p.h265.sps.pic_height_in_luma_samples = pPicParams->PicHeightInMinCbsY * MinCbSizeY; 448 450 p.h265.sps.sps_video_parameter_set_id = 0; /* Unknown, will be inferred by the Dxvk decoder. */ 449 p.h265.sps.sps_max_sub_layers_minus1 = 0; / // @todo unknown451 p.h265.sps.sps_max_sub_layers_minus1 = 0; /* Unknown, one sub-layer. */ 450 452 p.h265.sps.sps_seq_parameter_set_id = 0; /* Unknown, will be inferred by the Dxvk decoder. */ 451 453 p.h265.sps.bit_depth_luma_minus8 = pPicParams->bit_depth_luma_minus8; … … 468 470 p.h265.sps.palette_max_size = 0; /* Unused */ 469 471 p.h265.sps.delta_palette_max_predictor_size = 0; /* Unused */ 470 p.h265.sps.motion_vector_resolution_control_idc = 0; / // @todo unknown472 p.h265.sps.motion_vector_resolution_control_idc = 0; /* Unused */ 471 473 p.h265.sps.sps_num_palette_predictor_initializers_minus1 = 0; /* Unused */ 472 474 p.h265.sps.conf_win_left_offset = 0; /* Unused */ … … 474 476 p.h265.sps.conf_win_top_offset = 0; /* Unused */ 475 477 p.h265.sps.conf_win_bottom_offset = 0; /* Unused */ 476 p.h265.sps.pProfileTierLevel = nullptr; / // @todo unknown StdVideoH265ProfileTierLevel477 p.h265.sps.pDecPicBufMgr = nullptr; / // @todo unknown StdVideoH265DecPicBufMgr478 p.h265.sps.pProfileTierLevel = nullptr; /* &p.h265.vpsProfileTierLevel */ 479 p.h265.sps.pDecPicBufMgr = nullptr; /* &p.h265.spsDecPicBufMgr */ 478 480 p.h265.sps.pScalingLists = nullptr; /* Part of pps */ 479 481 p.h265.sps.pShortTermRefPicSet = nullptr; /// @todo unknown StdVideoH265ShortTermRefPicSet … … 481 483 p.h265.sps.pSequenceParameterSetVui = nullptr; /* Unused StdVideoH265SequenceParameterSetVui */ 482 484 p.h265.sps.pPredictorPaletteEntries = nullptr; /* Unused StdVideoH265PredictorPaletteEntries */ 485 486 for (uint32_t i = 0; i < STD_VIDEO_H265_SUBLAYERS_LIST_SIZE; ++i) { 487 p.h265.spsDecPicBufMgr.max_latency_increase_plus1[i] = 0; 488 } 489 for (uint32_t i = 0; i < STD_VIDEO_H265_SUBLAYERS_LIST_SIZE; ++i) { 490 p.h265.spsDecPicBufMgr.max_dec_pic_buffering_minus1[i] = std::min(pPicParams->sps_max_dec_pic_buffering_minus1, 491 (uint8_t)(STD_VIDEO_H265_MAX_DPB_SIZE - 1)); 492 } 493 for (uint32_t i = 0; i < STD_VIDEO_H265_SUBLAYERS_LIST_SIZE; ++i) { 494 p.h265.spsDecPicBufMgr.max_num_reorder_pics[i] = STD_VIDEO_H265_MAX_DPB_SIZE - 1; 495 } 483 496 484 497 p.h265.pps.flags.dependent_slice_segments_enabled_flag = pPicParams->dependent_slice_segments_enabled_flag; … … 498 511 p.h265.pps.flags.loop_filter_across_tiles_enabled_flag = pPicParams->loop_filter_across_tiles_enabled_flag; 499 512 p.h265.pps.flags.pps_loop_filter_across_slices_enabled_flag = pPicParams->pps_loop_filter_across_slices_enabled_flag; 500 p.h265.pps.flags.deblocking_filter_control_present_flag = 0; /// @todo unknown513 p.h265.pps.flags.deblocking_filter_control_present_flag = 1; /* Present */ 501 514 p.h265.pps.flags.deblocking_filter_override_enabled_flag = pPicParams->deblocking_filter_override_enabled_flag; 502 515 p.h265.pps.flags.pps_deblocking_filter_disabled_flag = pPicParams->pps_deblocking_filter_disabled_flag; … … 504 517 p.h265.pps.flags.lists_modification_present_flag = pPicParams->lists_modification_present_flag; 505 518 p.h265.pps.flags.slice_segment_header_extension_present_flag = pPicParams->slice_segment_header_extension_present_flag; 506 p.h265.pps.flags.pps_extension_present_flag = 0; / // @todo unknown507 p.h265.pps.flags.cross_component_prediction_enabled_flag = 0; / // @todo unknown508 p.h265.pps.flags.chroma_qp_offset_list_enabled_flag = pPicParams->pps_slice_chroma_qp_offsets_present_flag; /// @todo is it?509 p.h265.pps.flags.pps_curr_pic_ref_enabled_flag = 0; /// @todo unknown510 p.h265.pps.flags.residual_adaptive_colour_transform_enabled_flag = 0; / // @todo unknown511 p.h265.pps.flags.pps_slice_act_qp_offsets_present_flag = 0; / // @todo unknown519 p.h265.pps.flags.pps_extension_present_flag = 0; /* Unused */ 520 p.h265.pps.flags.cross_component_prediction_enabled_flag = 0; /* Unused */ 521 p.h265.pps.flags.chroma_qp_offset_list_enabled_flag = 0; /* Unused */ 522 p.h265.pps.flags.pps_curr_pic_ref_enabled_flag = 1; /* Unknown */ 523 p.h265.pps.flags.residual_adaptive_colour_transform_enabled_flag = 0; /* Unused */ 524 p.h265.pps.flags.pps_slice_act_qp_offsets_present_flag = 0; /* Unused */ 512 525 p.h265.pps.flags.pps_palette_predictor_initializers_present_flag = 0; /* Unused */ 513 526 p.h265.pps.flags.monochrome_palette_flag = 0; /* Unused */ 514 p.h265.pps.flags.pps_range_extension_flag = 0; / // @todo unknown527 p.h265.pps.flags.pps_range_extension_flag = 0; /* Unused */ 515 528 p.h265.pps.pps_pic_parameter_set_id = 0; /* Unknown, will be inferred by the Dxvk decoder. */ 516 529 p.h265.pps.pps_seq_parameter_set_id = 0; /* Unknown, will be inferred by the Dxvk decoder. */ … … 526 539 p.h265.pps.pps_tc_offset_div2 = pPicParams->pps_tc_offset_div2; 527 540 p.h265.pps.log2_parallel_merge_level_minus2 = pPicParams->log2_parallel_merge_level_minus2; 528 p.h265.pps.log2_max_transform_skip_block_size_minus2 = 0; /// @todo unknown 529 p.h265.pps.diff_cu_chroma_qp_offset_depth = 0; /// @todo unknown 530 p.h265.pps.chroma_qp_offset_list_len_minus1 = 0; /// @todo unknown 541 p.h265.pps.log2_max_transform_skip_block_size_minus2 = pPicParams->log2_min_transform_block_size_minus2 542 + pPicParams->log2_diff_max_min_transform_block_size; 543 p.h265.pps.diff_cu_chroma_qp_offset_depth = 0; /* Unused */ 544 p.h265.pps.chroma_qp_offset_list_len_minus1 = 0; /* Unused */ 531 545 for (uint32_t i = 0; i < STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE; ++i) { 532 p.h265.pps.cb_qp_offset_list[i] = 0; /// @todo unknown546 p.h265.pps.cb_qp_offset_list[i] = 0; /* Unused */ 533 547 } 534 548 for (uint32_t i = 0; i < STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE; ++i) { 535 p.h265.pps.cr_qp_offset_list[i] = 0; /// @todo unknown536 } 537 p.h265.pps.log2_sao_offset_scale_luma = 0; / // @todo unknown538 p.h265.pps.log2_sao_offset_scale_chroma = 0; / // @todo unknown539 p.h265.pps.pps_act_y_qp_offset_plus5 = 0; / // @todo unknown540 p.h265.pps.pps_act_cb_qp_offset_plus5 = 0; / // @todo unknown541 p.h265.pps.pps_act_cr_qp_offset_plus3 = 0; / // @todo unknown549 p.h265.pps.cr_qp_offset_list[i] = 0; /* Unused */ 550 } 551 p.h265.pps.log2_sao_offset_scale_luma = 0; /* "not present, the value ... is inferred to be equal to 0." */ 552 p.h265.pps.log2_sao_offset_scale_chroma = 0; /* "not present, the value ... is inferred to be equal to 0." */ 553 p.h265.pps.pps_act_y_qp_offset_plus5 = 0; /* Unused */ 554 p.h265.pps.pps_act_cb_qp_offset_plus5 = 0; /* Unused */ 555 p.h265.pps.pps_act_cr_qp_offset_plus3 = 0; /* Unused */ 542 556 p.h265.pps.pps_num_palette_predictor_initializers = 0; /* Unused */ 543 p.h265.pps.luma_bit_depth_entry_minus8 = 0; / // @todo unknown544 p.h265.pps.chroma_bit_depth_entry_minus8 = 0; / // @todo unknown557 p.h265.pps.luma_bit_depth_entry_minus8 = 0; /* Unused */ 558 p.h265.pps.chroma_bit_depth_entry_minus8 = 0; /* Unused */ 545 559 p.h265.pps.num_tile_columns_minus1 = pPicParams->num_tile_columns_minus1; 546 560 p.h265.pps.num_tile_rows_minus1 = pPicParams->num_tile_rows_minus1; … … 562 576 } 563 577 564 bool fSuccess = GetSliceOffsets AndNALType<DXVA_Slice_HEVC_Short>(578 bool fSuccess = GetSliceOffsets<DXVA_Slice_HEVC_Short>( 565 579 &p, pSliceDesc, pSlices, pBitStream, pBitStreamDesc->DataSize); 566 580 if (!fSuccess) … … 605 619 } 606 620 607 p.h265.stdReferenceInfo.flags.used_for_long_term_reference = 0; / // @todo unknown608 p.h265.stdReferenceInfo.flags.unused_for_reference = 0; / // @todo unknown621 p.h265.stdReferenceInfo.flags.used_for_long_term_reference = 0; /* Unknown, will be set later by Dxvk decoder. */ 622 p.h265.stdReferenceInfo.flags.unused_for_reference = 0; /* Unknown, will be set later by Dxvk decoder. */ 609 623 p.h265.stdReferenceInfo.PicOrderCntVal = pPicParams->CurrPicOrderCntVal; 610 611 /* How many pictures to keep. */612 p.h265.sps_max_dec_pic_buffering = pPicParams->sps_max_dec_pic_buffering_minus1 + 1;613 624 614 625 /* The picture identifier of destination uncompressed surface. */ 615 626 p.idSurface = pPicParams->CurrPic.Index7Bits; 616 627 617 if (pPicParams->IntraPicFlag) { 618 p.refFramesCount = 0; 619 } 620 else { 621 /* Reference frame surfaces. */ 622 uint32_t idxRefFrame = 0; 623 for (uint32_t i = 0; i < 15; ++i) { 624 const DXVA_PicEntry_HEVC& r = pPicParams->RefPicList[i]; 625 if (r.Index7Bits == 0x7F) 626 continue; 627 628 DxvkRefFrameInfo& refFrameInfo = p.refFrames[idxRefFrame]; 629 refFrameInfo.idSurface = r.Index7Bits; 630 refFrameInfo.longTermReference = r.AssociatedFlag; 631 refFrameInfo.usedForReference = 0x3; 632 refFrameInfo.nonExistingFrame = 0; 633 refFrameInfo.frame_num = 0; /* Unused */ 634 refFrameInfo.PicOrderCnt[0] = pPicParams->PicOrderCntValList[i]; 635 refFrameInfo.PicOrderCnt[1] = refFrameInfo.PicOrderCnt[0]; 636 637 ++idxRefFrame; 628 /* Reference frame surfaces. */ 629 uint32_t idxRefFrame = 0; 630 for (uint32_t i = 0; i < 15; ++i) { 631 const DXVA_PicEntry_HEVC& r = pPicParams->RefPicList[i]; 632 if (r.Index7Bits == 0x7F) 633 continue; 634 635 DxvkRefFrameInfo& refFrameInfo = p.refFrames[idxRefFrame]; 636 refFrameInfo.idSurface = r.Index7Bits; 637 refFrameInfo.h265.longTermReference = r.AssociatedFlag; 638 refFrameInfo.h265.PicOrderCntVal = pPicParams->PicOrderCntValList[i]; 639 640 ++idxRefFrame; 641 } 642 643 p.refFramesCount = idxRefFrame; 644 645 return true; 646 } 647 648 649 static uint8_t highestBitSet(UINT v) { 650 /* An obvious method. Intentionally returns 0 for v=0. */ 651 UINT r = 0; 652 if (v > 0xFFFF) { 653 r += 16; 654 v >>= 16; 655 } 656 if (v > 0xFF) { 657 r += 8; 658 v >>= 8; 659 } 660 if (v > 0xF) { 661 r += 4; 662 v >>= 4; 663 } 664 if (v > 0x3) { 665 r += 2; 666 v >>= 2; 667 } 668 if (v > 0x1) { 669 r += 1; 670 } 671 return (uint8_t)r; 672 } 673 674 675 static bool GetVideoDecodeAV1InputParameters( 676 const DXVA_PicParams_AV1* pPicParams, 677 const D3D11_VIDEO_DECODER_BUFFER_DESC* pPicParamsDesc, 678 const DXVA_Tile_AV1* pTiles, 679 const D3D11_VIDEO_DECODER_BUFFER_DESC* pTilesDesc, 680 const uint8_t* pBitStream, 681 const D3D11_VIDEO_DECODER_BUFFER_DESC* pBitStreamDesc, 682 DxvkVideoDecodeInputParameters *pParms) { 683 if (pPicParams == nullptr || pTiles == nullptr || pBitStream == nullptr) { 684 Logger::warn(str::format("DXVK: Video Decode: Not enough data:" 685 " PicParams ", (uint32_t)(pPicParams != nullptr), 686 " Tiles ", (uint32_t)(pTiles != nullptr), 687 " BitStream ", (uint32_t)(pBitStream != nullptr))); 688 return false; 689 } 690 691 if (pPicParamsDesc->DataSize < sizeof(DXVA_PicParams_AV1)) { 692 Logger::warn(str::format("DXVK: Video Decode: PicParams buffer size is too small: ", pPicParamsDesc->DataSize)); 693 return false; 694 } 695 696 const uint32_t cTiles = pTilesDesc->DataSize / sizeof(DXVA_Tile_AV1); 697 698 struct DxvkVideoDecodeInputParameters &p = *pParms; 699 700 const uint32_t superblockSize = pPicParams->coding.use_128x128_superblock ? 128 : 64; 701 702 p.av1.stdSequenceHeader.flags.still_picture = 0; 703 p.av1.stdSequenceHeader.flags.reduced_still_picture_header = 0; 704 p.av1.stdSequenceHeader.flags.use_128x128_superblock = pPicParams->coding.use_128x128_superblock; 705 p.av1.stdSequenceHeader.flags.enable_filter_intra = pPicParams->coding.filter_intra; 706 p.av1.stdSequenceHeader.flags.enable_intra_edge_filter = pPicParams->coding.intra_edge_filter; 707 p.av1.stdSequenceHeader.flags.enable_interintra_compound = pPicParams->coding.interintra_compound; 708 p.av1.stdSequenceHeader.flags.enable_masked_compound = pPicParams->coding.masked_compound; 709 p.av1.stdSequenceHeader.flags.enable_warped_motion = pPicParams->coding.warped_motion; 710 p.av1.stdSequenceHeader.flags.enable_dual_filter = pPicParams->coding.dual_filter; 711 p.av1.stdSequenceHeader.flags.enable_order_hint = pPicParams->order_hint_bits > 0 ? 1 : 0; 712 p.av1.stdSequenceHeader.flags.enable_jnt_comp = pPicParams->coding.jnt_comp; 713 p.av1.stdSequenceHeader.flags.enable_ref_frame_mvs = pPicParams->coding.enable_ref_frame_mvs; 714 p.av1.stdSequenceHeader.flags.frame_id_numbers_present_flag = 0; /* No frame ids. */ 715 p.av1.stdSequenceHeader.flags.enable_superres = pPicParams->coding.superres; 716 p.av1.stdSequenceHeader.flags.enable_cdef = pPicParams->coding.cdef; 717 p.av1.stdSequenceHeader.flags.enable_restoration = pPicParams->coding.restoration; 718 p.av1.stdSequenceHeader.flags.film_grain_params_present = pPicParams->coding.film_grain; 719 p.av1.stdSequenceHeader.flags.timing_info_present_flag = 0; 720 p.av1.stdSequenceHeader.flags.initial_display_delay_present_flag = 0; 721 p.av1.stdSequenceHeader.flags.reserved = 0; 722 p.av1.stdSequenceHeader.seq_profile = StdVideoAV1Profile(pPicParams->seq_profile); 723 p.av1.stdSequenceHeader.frame_width_bits_minus_1 = highestBitSet(pPicParams->width); 724 p.av1.stdSequenceHeader.frame_height_bits_minus_1 = highestBitSet(pPicParams->height); 725 p.av1.stdSequenceHeader.max_frame_width_minus_1 = uint16_t(pPicParams->max_width - 1); 726 p.av1.stdSequenceHeader.max_frame_height_minus_1 = uint16_t(pPicParams->max_height - 1); 727 p.av1.stdSequenceHeader.delta_frame_id_length_minus_2 = 0; /* No frame ids. */ 728 p.av1.stdSequenceHeader.additional_frame_id_length_minus_1 = 0; /* No frame ids. */ 729 p.av1.stdSequenceHeader.order_hint_bits_minus_1 = p.av1.stdSequenceHeader.flags.enable_order_hint 730 ? pPicParams->order_hint_bits - 1 731 : 0; 732 p.av1.stdSequenceHeader.seq_force_integer_mv = STD_VIDEO_AV1_SELECT_INTEGER_MV; 733 p.av1.stdSequenceHeader.seq_force_screen_content_tools = STD_VIDEO_AV1_SELECT_SCREEN_CONTENT_TOOLS; 734 memset(p.av1.stdSequenceHeader.reserved1, 0, sizeof(p.av1.stdSequenceHeader.reserved1)); 735 p.av1.stdSequenceHeader.pColorConfig = nullptr; /* &p.av1.stdColorConfig StdVideoAV1ColorConfig */ 736 p.av1.stdSequenceHeader.pTimingInfo = nullptr; /* Unused StdVideoAV1TimingInfo */ 737 738 p.av1.stdColorConfig.flags.mono_chrome = pPicParams->format.mono_chrome; 739 p.av1.stdColorConfig.flags.color_range = 0; 740 p.av1.stdColorConfig.flags.separate_uv_delta_q = 1; 741 p.av1.stdColorConfig.flags.color_description_present_flag = 0; 742 p.av1.stdColorConfig.flags.reserved = 0; 743 p.av1.stdColorConfig.BitDepth = pPicParams->bitdepth; 744 p.av1.stdColorConfig.subsampling_x = pPicParams->format.subsampling_x; 745 p.av1.stdColorConfig.subsampling_y = pPicParams->format.subsampling_y; 746 p.av1.stdColorConfig.reserved1 = 0; 747 p.av1.stdColorConfig.color_primaries = STD_VIDEO_AV1_COLOR_PRIMARIES_BT_UNSPECIFIED; 748 p.av1.stdColorConfig.transfer_characteristics = STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_UNSPECIFIED; 749 p.av1.stdColorConfig.matrix_coefficients = STD_VIDEO_AV1_MATRIX_COEFFICIENTS_UNSPECIFIED; 750 p.av1.stdColorConfig.chroma_sample_position = STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_UNKNOWN; 751 752 p.av1.stdPictureInfo.flags.error_resilient_mode = 1; 753 p.av1.stdPictureInfo.flags.disable_cdf_update = pPicParams->coding.disable_cdf_update; 754 p.av1.stdPictureInfo.flags.use_superres = pPicParams->coding.superres; 755 p.av1.stdPictureInfo.flags.render_and_frame_size_different = 0; 756 p.av1.stdPictureInfo.flags.allow_screen_content_tools = pPicParams->coding.screen_content_tools; 757 p.av1.stdPictureInfo.flags.is_filter_switchable = StdVideoAV1InterpolationFilter(pPicParams->interp_filter) 758 == STD_VIDEO_AV1_INTERPOLATION_FILTER_SWITCHABLE; 759 p.av1.stdPictureInfo.flags.force_integer_mv = pPicParams->coding.integer_mv; 760 p.av1.stdPictureInfo.flags.frame_size_override_flag = 0; 761 p.av1.stdPictureInfo.flags.buffer_removal_time_present_flag = 0; 762 p.av1.stdPictureInfo.flags.allow_intrabc = pPicParams->coding.intrabc; 763 p.av1.stdPictureInfo.flags.frame_refs_short_signaling = 0; 764 p.av1.stdPictureInfo.flags.allow_high_precision_mv = pPicParams->coding.high_precision_mv; 765 p.av1.stdPictureInfo.flags.is_motion_mode_switchable = pPicParams->coding.switchable_motion_mode; 766 p.av1.stdPictureInfo.flags.use_ref_frame_mvs = pPicParams->coding.use_ref_frame_mvs; 767 p.av1.stdPictureInfo.flags.disable_frame_end_update_cdf = pPicParams->coding.disable_frame_end_update_cdf; 768 p.av1.stdPictureInfo.flags.allow_warped_motion = pPicParams->coding.warped_motion; 769 p.av1.stdPictureInfo.flags.reduced_tx_set = pPicParams->coding.reduced_tx_set; 770 p.av1.stdPictureInfo.flags.reference_select = pPicParams->coding.reference_mode; 771 p.av1.stdPictureInfo.flags.skip_mode_present = pPicParams->coding.skip_mode; 772 p.av1.stdPictureInfo.flags.delta_q_present = pPicParams->quantization.delta_q_present; 773 p.av1.stdPictureInfo.flags.delta_lf_present = pPicParams->loop_filter.delta_lf_present; 774 p.av1.stdPictureInfo.flags.delta_lf_multi = pPicParams->loop_filter.delta_lf_multi; 775 p.av1.stdPictureInfo.flags.segmentation_enabled = pPicParams->segmentation.enabled; 776 p.av1.stdPictureInfo.flags.segmentation_update_map = pPicParams->segmentation.update_map; 777 p.av1.stdPictureInfo.flags.segmentation_temporal_update = pPicParams->segmentation.temporal_update; 778 p.av1.stdPictureInfo.flags.segmentation_update_data = pPicParams->segmentation.update_data; 779 p.av1.stdPictureInfo.flags.usesChromaLr = !pPicParams->format.mono_chrome 780 && (pPicParams->loop_filter.frame_restoration_type[1] != 0 781 || pPicParams->loop_filter.frame_restoration_type[2] != 0); 782 p.av1.stdPictureInfo.flags.UsesLr = p.av1.stdPictureInfo.flags.usesChromaLr 783 || pPicParams->loop_filter.frame_restoration_type[0] != 0; 784 p.av1.stdPictureInfo.flags.apply_grain = pPicParams->film_grain.apply_grain; 785 p.av1.stdPictureInfo.flags.reserved = 0; 786 787 p.av1.stdPictureInfo.frame_type = StdVideoAV1FrameType(pPicParams->format.frame_type); 788 p.av1.stdPictureInfo.current_frame_id = 0; /* No frame ids. */ 789 p.av1.stdPictureInfo.OrderHint = p.av1.stdSequenceHeader.flags.enable_order_hint 790 ? pPicParams->order_hint 791 : 0; 792 p.av1.stdPictureInfo.primary_ref_frame = pPicParams->primary_ref_frame; 793 p.av1.stdPictureInfo.refresh_frame_flags = 0xff; 794 p.av1.stdPictureInfo.reserved1 = 0; 795 p.av1.stdPictureInfo.interpolation_filter = StdVideoAV1InterpolationFilter(pPicParams->interp_filter); 796 p.av1.stdPictureInfo.TxMode = StdVideoAV1TxMode(pPicParams->coding.tx_mode); 797 p.av1.stdPictureInfo.delta_q_res = pPicParams->quantization.delta_q_res; 798 p.av1.stdPictureInfo.delta_lf_res = pPicParams->loop_filter.delta_lf_res; 799 p.av1.stdPictureInfo.SkipModeFrame[0] = 0; /* Computed by dxvk decoder. */ 800 p.av1.stdPictureInfo.SkipModeFrame[1] = 0; /* Computed by dxvk decoder. */ 801 p.av1.stdPictureInfo.coded_denom = pPicParams->coding.superres 802 ? pPicParams->superres_denom - 9 803 : 0; 804 memset(p.av1.stdPictureInfo.reserved2, 0, sizeof(p.av1.stdPictureInfo.reserved2)); 805 for (uint32_t i = 0; i < STD_VIDEO_AV1_NUM_REF_FRAMES; ++i) { 806 p.av1.stdPictureInfo.OrderHints[i] = (uint8_t)0; /* Filled by dxvk decoder */ 807 } 808 for (uint32_t i = 0; i < STD_VIDEO_AV1_NUM_REF_FRAMES; ++i) { 809 p.av1.stdPictureInfo.expectedFrameId[i] = (uint32_t)0; /* No frame ids. */ 810 } 811 p.av1.stdPictureInfo.pTileInfo = nullptr; /* &p.av1.stdTileInfo StdVideoAV1TileInfo */ 812 p.av1.stdPictureInfo.pQuantization = nullptr; /* &p.av1.stdQuantization StdVideoAV1Quantization */ 813 p.av1.stdPictureInfo.pSegmentation = nullptr; /* &p.av1.stdSegmentation StdVideoAV1Segmentation */ 814 p.av1.stdPictureInfo.pLoopFilter = nullptr; /* &p.av1.stdLoopFilter StdVideoAV1LoopFilter */ 815 p.av1.stdPictureInfo.pCDEF = nullptr; /* &p.av1.stdCDEF StdVideoAV1CDEF */ 816 p.av1.stdPictureInfo.pLoopRestoration = nullptr; /* &p.av1.stdLoopRestoration StdVideoAV1LoopRestoration */ 817 p.av1.stdPictureInfo.pGlobalMotion = nullptr; /* &p.av1.stdGlobalMotion StdVideoAV1GlobalMotion */ 818 p.av1.stdPictureInfo.pFilmGrain = nullptr; /* &p.av1.stdFilmGrain StdVideoAV1FilmGrain */ 819 820 bool uniform_tile_spacing_flag = true; 821 uint16_t MaxTileDimension = 0; 822 int TileDimension = -1; 823 uint16_t MiColStart = 0; /* MiColStart in superblocks */ 824 for (uint32_t i = 0; i < std::min(pPicParams->tiles.cols, (UCHAR)64); ++i) { 825 const USHORT width = pPicParams->tiles.widths[i]; 826 p.av1.MiColStarts[i] = MiColStart; 827 p.av1.WidthInSbsMinus1[i] = width - 1; 828 MiColStart += width; 829 if (MaxTileDimension < width) 830 MaxTileDimension = width; 831 if (TileDimension == -1) 832 TileDimension = width; 833 else if (i < std::min(pPicParams->tiles.cols, (UCHAR)64) - 1) { /* The rightmost column does not count. */ 834 if (TileDimension != width) 835 uniform_tile_spacing_flag = false; 638 836 } 639 640 p.refFramesCount = idxRefFrame; 641 } 837 } 838 TileDimension = -1; 839 uint16_t MiRowStart = 0; /* MiRowStart in superblocks */ 840 for (uint32_t i = 0; i < std::min(pPicParams->tiles.rows, (UCHAR)64); ++i) { 841 const USHORT height = pPicParams->tiles.heights[i]; 842 p.av1.MiRowStarts[i] = MiRowStart; 843 p.av1.HeightInSbsMinus1[i] = height - 1; 844 MiRowStart += height; 845 if (MaxTileDimension < height) 846 MaxTileDimension = height; 847 if (TileDimension == -1) 848 TileDimension = height; 849 else if (i < std::min(pPicParams->tiles.rows, (UCHAR)64) - 1) { /* The bottom row does not count. */ 850 if (TileDimension != height) 851 uniform_tile_spacing_flag = false; 852 } 853 } 854 p.av1.stdTileInfo.flags.uniform_tile_spacing_flag = uniform_tile_spacing_flag ? 1 : 0; 855 p.av1.stdTileInfo.flags.reserved = 0; 856 p.av1.stdTileInfo.TileCols = pPicParams->tiles.cols; 857 p.av1.stdTileInfo.TileRows = pPicParams->tiles.rows; 858 p.av1.stdTileInfo.context_update_tile_id = pPicParams->tiles.context_update_id; 859 p.av1.stdTileInfo.tile_size_bytes_minus_1 = highestBitSet(MaxTileDimension) / 8; 860 memset(p.av1.stdTileInfo.reserved1, 0, sizeof(p.av1.stdTileInfo.reserved1)); 861 p.av1.stdTileInfo.pMiColStarts = nullptr; /* &p.av1.MiColStarts */ 862 p.av1.stdTileInfo.pMiRowStarts = nullptr; /* &p.av1.MiRowStarts */ 863 p.av1.stdTileInfo.pWidthInSbsMinus1 = nullptr; /* &p.av1.WidthInSbsMinus1 */ 864 p.av1.stdTileInfo.pHeightInSbsMinus1 = nullptr; /* &p.av1.HeightInSbsMinus1 */ 865 866 p.av1.stdQuantization.flags.using_qmatrix = pPicParams->quantization.qm_y != 0xFF; 867 p.av1.stdQuantization.flags.diff_uv_delta = 1; /* "U and V delta quantizer values are coded separately" */ 868 p.av1.stdQuantization.flags.reserved = 0; 869 p.av1.stdQuantization.base_q_idx = pPicParams->quantization.base_qindex; 870 p.av1.stdQuantization.DeltaQYDc = pPicParams->quantization.y_dc_delta_q; 871 p.av1.stdQuantization.DeltaQUDc = pPicParams->quantization.u_dc_delta_q; 872 p.av1.stdQuantization.DeltaQUAc = pPicParams->quantization.u_ac_delta_q; 873 p.av1.stdQuantization.DeltaQVDc = pPicParams->quantization.v_dc_delta_q; 874 p.av1.stdQuantization.DeltaQVAc = pPicParams->quantization.v_ac_delta_q; 875 p.av1.stdQuantization.qm_y = p.av1.stdQuantization.flags.using_qmatrix 876 ? pPicParams->quantization.qm_y 877 : 0; 878 p.av1.stdQuantization.qm_u = p.av1.stdQuantization.flags.using_qmatrix 879 ? pPicParams->quantization.qm_u 880 : 0; 881 p.av1.stdQuantization.qm_v = p.av1.stdQuantization.flags.using_qmatrix 882 ? pPicParams->quantization.qm_v 883 : 0; 884 885 memcpy(p.av1.stdSegmentation.FeatureEnabled, pPicParams->segmentation.feature_mask, sizeof(p.av1.stdSegmentation.FeatureEnabled)); 886 memcpy(p.av1.stdSegmentation.FeatureData, pPicParams->segmentation.feature_data, sizeof(p.av1.stdSegmentation.FeatureData)); 887 888 p.av1.stdLoopFilter.flags.loop_filter_delta_enabled = pPicParams->loop_filter.mode_ref_delta_enabled; 889 p.av1.stdLoopFilter.flags.loop_filter_delta_update = pPicParams->loop_filter.mode_ref_delta_update; 890 p.av1.stdLoopFilter.flags.reserved = 0; 891 p.av1.stdLoopFilter.loop_filter_level[0] = pPicParams->loop_filter.filter_level[0]; 892 p.av1.stdLoopFilter.loop_filter_level[1] = pPicParams->loop_filter.filter_level[1]; 893 p.av1.stdLoopFilter.loop_filter_level[2] = pPicParams->loop_filter.filter_level_u; 894 p.av1.stdLoopFilter.loop_filter_level[3] = pPicParams->loop_filter.filter_level_v; 895 p.av1.stdLoopFilter.loop_filter_sharpness = pPicParams->loop_filter.sharpness_level; 896 p.av1.stdLoopFilter.update_ref_delta = 0xff; /* 8 elements, "loop_filter_ref_delta is present" */ 897 memcpy(p.av1.stdLoopFilter.loop_filter_ref_deltas, pPicParams->loop_filter.ref_deltas, sizeof(p.av1.stdLoopFilter.loop_filter_ref_deltas)); 898 p.av1.stdLoopFilter.update_mode_delta = 0x3; /* 2 elements, "update_mode_delta" */ 899 memcpy(p.av1.stdLoopFilter.loop_filter_mode_deltas, pPicParams->loop_filter.mode_deltas, sizeof(p.av1.stdLoopFilter.loop_filter_mode_deltas)); 900 901 p.av1.stdCDEF.cdef_damping_minus_3 = pPicParams->cdef.damping; 902 p.av1.stdCDEF.cdef_bits = pPicParams->cdef.bits; 903 for (uint32_t i = 0; i < 8; ++i) { 904 p.av1.stdCDEF.cdef_y_pri_strength[i] = pPicParams->cdef.y_strengths[i].primary; 905 p.av1.stdCDEF.cdef_y_sec_strength[i] = pPicParams->cdef.y_strengths[i].secondary; 906 p.av1.stdCDEF.cdef_uv_pri_strength[i] = pPicParams->cdef.uv_strengths[i].primary; 907 p.av1.stdCDEF.cdef_uv_sec_strength[i] = pPicParams->cdef.uv_strengths[i].secondary; 908 } 909 910 for (uint32_t i = 0; i < 3; ++i) { 911 p.av1.stdLoopRestoration.FrameRestorationType[i] = StdVideoAV1FrameRestorationType(pPicParams->loop_filter.frame_restoration_type[i]); 912 if (pPicParams->loop_filter.log2_restoration_unit_size[i] >= 5 913 && pPicParams->loop_filter.log2_restoration_unit_size[i] <= 8) { 914 p.av1.stdLoopRestoration.LoopRestorationSize[i] = pPicParams->loop_filter.log2_restoration_unit_size[i] - 5; 915 } 916 else { 917 p.av1.stdLoopRestoration.LoopRestorationSize[i] = 3; 918 } 919 } 920 921 /* INTRA_FRAME(0) (current frame). */ 922 p.av1.stdGlobalMotion.GmType[0] = 0; 923 p.av1.stdGlobalMotion.gm_params[0][0] = 0; 924 p.av1.stdGlobalMotion.gm_params[0][1] = 0; 925 p.av1.stdGlobalMotion.gm_params[0][2] = 0; 926 p.av1.stdGlobalMotion.gm_params[0][3] = 0; 927 p.av1.stdGlobalMotion.gm_params[0][4] = 0; 928 p.av1.stdGlobalMotion.gm_params[0][5] = 0; 929 /* LAST_FRAME(1) to ALTREF_FRAME(7) */ 930 for (uint32_t i = 1; i < 8; ++i) { 931 const DXVA_PicEntry_AV1& picEntry = pPicParams->frame_refs[i - 1]; 932 933 if (picEntry.wminvalid) { 934 /* Pass default parameters as defined in AV1 spec 5.9.24. Global motion params syntax */ 935 p.av1.stdGlobalMotion.GmType[i] = 0; 936 for (uint32_t j = 0; j < 6; ++j) { 937 p.av1.stdGlobalMotion.gm_params[i][j] = (j % 3 == 2) ? 0x10000 : 0; 938 } 939 continue; 940 } 941 942 p.av1.stdGlobalMotion.GmType[i] = picEntry.wmtype; 943 p.av1.stdGlobalMotion.gm_params[i][0] = picEntry.wmmat[0]; 944 p.av1.stdGlobalMotion.gm_params[i][1] = picEntry.wmmat[1]; 945 p.av1.stdGlobalMotion.gm_params[i][2] = picEntry.wmmat[2]; 946 p.av1.stdGlobalMotion.gm_params[i][3] = picEntry.wmmat[3]; 947 p.av1.stdGlobalMotion.gm_params[i][4] = picEntry.wmmat[4]; 948 p.av1.stdGlobalMotion.gm_params[i][5] = picEntry.wmmat[5]; 949 } 950 951 p.av1.stdFilmGrain.flags.chroma_scaling_from_luma = pPicParams->film_grain.chroma_scaling_from_luma; 952 p.av1.stdFilmGrain.flags.overlap_flag = pPicParams->film_grain.overlap_flag; 953 p.av1.stdFilmGrain.flags.clip_to_restricted_range = pPicParams->film_grain.clip_to_restricted_range; 954 p.av1.stdFilmGrain.flags.update_grain = 0; /* "ignored by AV1 decode operations" */ 955 p.av1.stdFilmGrain.flags.reserved = 0; 956 p.av1.stdFilmGrain.grain_scaling_minus_8 = pPicParams->film_grain.scaling_shift_minus8; 957 p.av1.stdFilmGrain.ar_coeff_lag = pPicParams->film_grain.ar_coeff_lag; 958 p.av1.stdFilmGrain.ar_coeff_shift_minus_6 = pPicParams->film_grain.ar_coeff_shift_minus6; 959 p.av1.stdFilmGrain.grain_scale_shift = pPicParams->film_grain.grain_scale_shift; 960 p.av1.stdFilmGrain.grain_seed = pPicParams->film_grain.grain_seed; 961 p.av1.stdFilmGrain.film_grain_params_ref_idx = 0; /* "ignored by AV1 decode operations" */ 962 p.av1.stdFilmGrain.num_y_points = std::min(pPicParams->film_grain.num_y_points, 963 (uint8_t)STD_VIDEO_AV1_MAX_NUM_Y_POINTS); 964 for (uint32_t i = 0; i < p.av1.stdFilmGrain.num_y_points; ++i) { 965 p.av1.stdFilmGrain.point_y_value[i] = pPicParams->film_grain.scaling_points_y[i][0]; 966 p.av1.stdFilmGrain.point_y_scaling[i] = pPicParams->film_grain.scaling_points_y[i][1]; 967 } 968 p.av1.stdFilmGrain.num_cb_points = std::min(pPicParams->film_grain.num_cb_points, 969 (uint8_t)STD_VIDEO_AV1_MAX_NUM_CB_POINTS); 970 for (uint32_t i = 0; i < p.av1.stdFilmGrain.num_cb_points; ++i) { 971 p.av1.stdFilmGrain.point_cb_value[i] = pPicParams->film_grain.scaling_points_cb[i][0]; 972 p.av1.stdFilmGrain.point_cb_scaling[i] = pPicParams->film_grain.scaling_points_cb[i][1]; 973 } 974 p.av1.stdFilmGrain.num_cr_points = std::min(pPicParams->film_grain.num_cr_points, 975 (uint8_t)STD_VIDEO_AV1_MAX_NUM_CR_POINTS); 976 for (uint32_t i = 0; i < p.av1.stdFilmGrain.num_cr_points; ++i) { 977 p.av1.stdFilmGrain.point_cr_value[i] = pPicParams->film_grain.scaling_points_cr[i][0]; 978 p.av1.stdFilmGrain.point_cr_scaling[i] = pPicParams->film_grain.scaling_points_cr[i][1]; 979 } 980 memcpy(p.av1.stdFilmGrain.ar_coeffs_y_plus_128, pPicParams->film_grain.ar_coeffs_y, sizeof(p.av1.stdFilmGrain.ar_coeffs_y_plus_128)); 981 memcpy(p.av1.stdFilmGrain.ar_coeffs_cb_plus_128, pPicParams->film_grain.ar_coeffs_cb, sizeof(p.av1.stdFilmGrain.ar_coeffs_cb_plus_128)); 982 memcpy(p.av1.stdFilmGrain.ar_coeffs_cr_plus_128, pPicParams->film_grain.ar_coeffs_cr, sizeof(p.av1.stdFilmGrain.ar_coeffs_cr_plus_128)); 983 p.av1.stdFilmGrain.cb_mult = pPicParams->film_grain.cb_mult; 984 p.av1.stdFilmGrain.cb_luma_mult = pPicParams->film_grain.cb_luma_mult; 985 p.av1.stdFilmGrain.cb_offset = pPicParams->film_grain.cb_offset; 986 p.av1.stdFilmGrain.cr_mult = pPicParams->film_grain.cr_mult; 987 p.av1.stdFilmGrain.cr_luma_mult = pPicParams->film_grain.cr_luma_mult; 988 p.av1.stdFilmGrain.cr_offset = pPicParams->film_grain.cr_offset; 989 990 p.av1.tileCount = cTiles; 991 p.sliceOrTileOffsets.resize(cTiles); 992 p.sliceOrTileSizes.resize(cTiles); 993 for (uint32_t i = 0; i < p.av1.tileCount; ++i) { 994 p.sliceOrTileOffsets[i] = pTiles[i].DataOffset; 995 p.sliceOrTileSizes[i] = pTiles[i].DataSize; 996 } 997 998 p.av1.stdReferenceInfo.flags.disable_frame_end_update_cdf = pPicParams->coding.disable_frame_end_update_cdf; 999 p.av1.stdReferenceInfo.flags.segmentation_enabled = pPicParams->segmentation.enabled; 1000 p.av1.stdReferenceInfo.flags.reserved = 0; 1001 p.av1.stdReferenceInfo.frame_type = pPicParams->format.frame_type; 1002 p.av1.stdReferenceInfo.RefFrameSignBias = 0; /* Computed by dxvk decoder */ 1003 p.av1.stdReferenceInfo.OrderHint = p.av1.stdSequenceHeader.flags.enable_order_hint 1004 ? pPicParams->order_hint 1005 : 0; 1006 for (uint32_t i = 0; i < STD_VIDEO_AV1_NUM_REF_FRAMES; ++i) { 1007 p.av1.stdReferenceInfo.SavedOrderHints[i] = 0; /* Filled by dxvk decoder */ 1008 } 1009 1010 /* The picture identifier of destination uncompressed surface. */ 1011 p.idSurface = pPicParams->CurrPicTextureIndex; 1012 1013 /* Reference frame surfaces. */ 1014 uint32_t idxRefFrame = 0; 1015 for (uint32_t i = 0; i < 7; ++i) { /* Elements in ref_frames, from LAST_FRAME to ALTREF_FRAME */ 1016 const DXVA_PicEntry_AV1& r = pPicParams->frame_refs[i]; 1017 if (r.Index >= 8) /* Elements in RefFrameMapTextureIndex */ 1018 continue; 1019 1020 DxvkRefFrameInfo& refFrameInfo = p.refFrames[idxRefFrame]; 1021 refFrameInfo.idSurface = pPicParams->RefFrameMapTextureIndex[r.Index]; 1022 refFrameInfo.av1.frame_name = i + 1; /* The frame name from LAST_FRAME to ALTREF_FRAME */ 1023 1024 ++idxRefFrame; 1025 } 1026 1027 p.refFramesCount = idxRefFrame; 1028 1029 memcpy(p.av1.RefFrameMapTextureIndex, pPicParams->RefFrameMapTextureIndex, sizeof(p.av1.RefFrameMapTextureIndex)); 1030 1031 /* Whether this is a reference frame. */ 1032 p.av1.reference_frame_update = pPicParams->coding.reference_frame_update; 642 1033 643 1034 return true; … … 730 1121 return true; 731 1122 } 1123 else if (videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1124 if (GetVideoDecodeAV1InputParameters( 1125 (DXVA_PicParams_AV1*)pPicParams, pPicParamsDesc, 1126 (DXVA_Tile_AV1*)pSlices, pSliceDesc, 1127 (uint8_t*)pBitStream, pBitStreamDesc, 1128 pParms)) 1129 return true; 1130 } 1131 732 1132 return false; 733 1133 } -
trunk/src/libs/dxvk-2.3.1/src/dxvk/dxvk_adapter.cpp
r108420 r108577 1062 1062 &devExtensions.khrVideoDecodeH264, 1063 1063 &devExtensions.khrVideoDecodeH265, 1064 &devExtensions.khrVideoDecodeAV1, 1064 1065 #endif 1065 1066 }}; -
trunk/src/libs/dxvk-2.3.1/src/dxvk/dxvk_extensions.h
r108420 r108577 334 334 DxvkExt khrVideoDecodeH264 = { VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME, DxvkExtMode::Optional }; 335 335 DxvkExt khrVideoDecodeH265 = { VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME, DxvkExtMode::Optional }; 336 DxvkExt khrVideoDecodeAV1 = { VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME, DxvkExtMode::Optional }; 336 337 #endif 337 338 }; -
trunk/src/libs/dxvk-2.3.1/src/dxvk/dxvk_video_decoder.cpp
r108423 r108577 39 39 40 40 DxvkVideoSessionHandle::~DxvkVideoSessionHandle() { 41 m_device->vkd()->vkDestroyVideoSessionKHR(m_device->handle(), m_videoSession, nullptr); 42 m_videoSession = VK_NULL_HANDLE; 41 if (m_videoSession != VK_NULL_HANDLE) { 42 m_device->vkd()->vkDestroyVideoSessionKHR(m_device->handle(), m_videoSession, nullptr); 43 } 43 44 } 44 45 … … 60 61 61 62 DxvkVideoSessionParametersHandle::~DxvkVideoSessionParametersHandle() { 62 m_device->vkd()->vkDestroyVideoSessionParametersKHR(m_device->handle(), m_videoSessionParameters, nullptr); 63 m_videoSessionParameters = VK_NULL_HANDLE; 63 if (m_videoSessionParameters != VK_NULL_HANDLE) { 64 m_device->vkd()->vkDestroyVideoSessionParametersKHR(m_device->handle(), m_videoSessionParameters, nullptr); 65 } 64 66 } 65 67 … … 87 89 DxvkMemoryAllocator& memAlloc) 88 90 : m_device(device), 89 m_memAlloc(memAlloc) {91 m_memAlloc(memAlloc) { 90 92 } 91 93 92 94 93 95 DxvkVideoBitstreamBuffer::~DxvkVideoBitstreamBuffer() { 94 m_device->vkd()->vkDestroyBuffer(m_device->vkd()->device(), m_buffer.buffer, nullptr); 96 if (m_buffer.buffer != VK_NULL_HANDLE) { 97 m_device->vkd()->vkDestroyBuffer(m_device->vkd()->device(), m_buffer.buffer, nullptr); 98 } 95 99 } 96 100 … … 163 167 /* Fetch data for quicker access. */ 164 168 m_mapPtr = (uint8_t *)m_buffer.memory.mapPtr(0); 165 m_length = m_buffer.memory.length();169 m_length = bufferCreateInfo.size; 166 170 } 167 171 … … 196 200 m_profile.decodeCapabilities.pNext = &m_profile.decodeH265Capabilities; 197 201 } 202 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 203 m_profile.profileInfo.pNext = &m_profile.av1ProfileInfo; 204 m_profile.decodeCapabilities.pNext = &m_profile.decodeAV1Capabilities; 205 } 198 206 else { 199 207 throw DxvkError(str::format("DxvkVideoDecoder: videoCodecOperation ", m_profile.profileInfo.videoCodecOperation, … … 202 210 m_profile.videoCapabilities.pNext = &m_profile.decodeCapabilities; 203 211 212 /* Size of DPB and decode destination images. */ 213 m_DPB.decodedPictureExtent = { m_sampleWidth, m_sampleHeight, 1 }; 214 215 /* Align the decoder picture size to the macroblock/codingblock/superblock granularity. */ 216 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) { 217 /* To the macroblock */ 218 m_DPB.decodedPictureExtent.width = align(m_DPB.decodedPictureExtent.width, 16); 219 m_DPB.decodedPictureExtent.height = align(m_DPB.decodedPictureExtent.height, 16); 220 } 221 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { 222 /* To the max coding block size */ 223 m_DPB.decodedPictureExtent.width = align(m_DPB.decodedPictureExtent.width, 64); 224 m_DPB.decodedPictureExtent.height = align(m_DPB.decodedPictureExtent.height, 64); 225 } 226 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 227 /* To the largest superblock granularity */ 228 m_DPB.decodedPictureExtent.width = align(m_DPB.decodedPictureExtent.width, 128); 229 m_DPB.decodedPictureExtent.height = align(m_DPB.decodedPictureExtent.height, 128); 230 } 231 204 232 /* 205 233 * Assess capabilities. 206 234 */ 207 235 /* Check that video resolution is supported. */ 208 if (m_ sampleWidth > m_profile.videoCapabilities.maxCodedExtent.width209 || m_ sampleHeight > m_profile.videoCapabilities.maxCodedExtent.height)236 if (m_DPB.decodedPictureExtent.width > m_profile.videoCapabilities.maxCodedExtent.width 237 || m_DPB.decodedPictureExtent.height > m_profile.videoCapabilities.maxCodedExtent.height) 210 238 throw DxvkError(str::format("DxvkVideoDecoder: requested resolution exceeds maximum: ", 211 m_sampleWidth, "x", m_sampleHeight, " > ", 239 m_DPB.decodedPictureExtent.width, "x", m_DPB.decodedPictureExtent.height, " (", 240 m_sampleWidth, "x", m_sampleHeight, ") > ", 212 241 m_profile.videoCapabilities.maxCodedExtent.width, "x", m_profile.videoCapabilities.maxCodedExtent.height)); 213 242 … … 240 269 m_bitstreamBuffer->create(profileListInfo, bitstreamBufferSize); 241 270 242 /* Decoded Picture Buffer (DPB), i.e. array of decoded frames. */ 243 const uint32_t cMaxDPBSlots = std::max( 244 m_profile.videoCapabilities.maxActiveReferencePictures, m_profile.videoCapabilities.maxDpbSlots); 271 /* Decoded Picture Buffer (DPB), i.e. array of decoded frames. 272 * AMD mesa/vulkan driver asserts if the number of slots is greater than the spec requirement. 273 */ 274 uint32_t cMaxDPBSlots = m_profile.videoCapabilities.maxDpbSlots; 275 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) { 276 cMaxDPBSlots = std::min(cMaxDPBSlots, (uint32_t)16); 277 } 278 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { 279 cMaxDPBSlots = std::min(cMaxDPBSlots, (uint32_t)STD_VIDEO_H265_MAX_DPB_SIZE); 280 } 281 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 282 cMaxDPBSlots = std::min(cMaxDPBSlots, (uint32_t)(STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME + 1)); 283 } 245 284 m_DPB.slots.resize(cMaxDPBSlots); 246 285 … … 257 296 imgInfo.flags = 0; 258 297 imgInfo.sampleCount = VK_SAMPLE_COUNT_1_BIT; 259 imgInfo.extent = { m_sampleWidth, m_sampleHeight, 1 };298 imgInfo.extent = m_DPB.decodedPictureExtent; 260 299 imgInfo.numLayers = 1; 261 300 imgInfo.mipLevels = 1; … … 294 333 295 334 slot.imageView = m_device->createImageView(slot.image, viewInfo); 296 } 297 298 if (m_caps.distinctOutputImage) { 299 /* Create an additional output image. */ 335 336 slot.deactivate(); 337 } 338 339 if (m_caps.distinctOutputImage 340 || m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 341 /* Create an additional output image. Also for a possible usage of AV1 film grain feature. */ 300 342 DxvkImageCreateInfo imgInfo = {}; 301 343 imgInfo.pNext = &profileListInfo; … … 304 346 imgInfo.flags = 0; 305 347 imgInfo.sampleCount = VK_SAMPLE_COUNT_1_BIT; 306 imgInfo.extent = { m_sampleWidth, m_sampleHeight, 1 };348 imgInfo.extent = m_DPB.decodedPictureExtent; 307 349 imgInfo.numLayers = 1; 308 350 imgInfo.mipLevels = 1; … … 344 386 sessionCreateInfo.pVideoProfile = &m_profile.profileInfo; 345 387 sessionCreateInfo.pictureFormat = m_outputFormat; 346 sessionCreateInfo.maxCodedExtent.width = m_sampleWidth; 347 sessionCreateInfo.maxCodedExtent.height = m_sampleHeight; 388 sessionCreateInfo.maxCodedExtent = m_profile.videoCapabilities.maxCodedExtent; 348 389 sessionCreateInfo.referencePictureFormat = m_outputFormat; 349 390 sessionCreateInfo.maxDpbSlots = m_DPB.slots.size(); … … 422 463 423 464 m_videoSessionParameters->create(m_videoSession, &h265SessionParametersCreateInfo); 465 } 466 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 467 /* Session parameter will be (re-)created in Decode because "video session parameters objects cannot be 468 * updated using the vkUpdateVideoSessionParametersKHR command. When a new AV1 sequence header is decoded 469 * from the input video bitstream the application needs to create a new video session parameters object 470 * to store it.". 471 */ 424 472 } 425 473 else { … … 495 543 DxvkContext* ctx, 496 544 const Rc<DxvkImageView>& imageView) { 497 Logger::info(str::format("VDec: BeginFrame"));498 545 499 546 m_outputImageView = imageView; … … 518 565 void DxvkVideoDecoder::EndFrame( 519 566 DxvkContext* ctx) { 520 Logger::info(str::format("VDec: EndFrame"));521 567 522 568 if (m_profile.videoQueueHasTransfer) { … … 564 610 DXVK_VD_CMP_FIELD(vps, pProfileTierLevel->general_profile_idc); 565 611 DXVK_VD_CMP_FIELD(vps, pProfileTierLevel->general_level_idc); 612 return true; 613 } 614 615 616 static bool IsAV1SequenceHeaderEqual( 617 const StdVideoAV1SequenceHeader &sh1, 618 const StdVideoAV1SequenceHeader &sh2) { 619 DXVK_VD_CMP_FIELD(sh, flags.still_picture); 620 DXVK_VD_CMP_FIELD(sh, flags.reduced_still_picture_header); 621 DXVK_VD_CMP_FIELD(sh, flags.use_128x128_superblock); 622 DXVK_VD_CMP_FIELD(sh, flags.enable_filter_intra); 623 DXVK_VD_CMP_FIELD(sh, flags.enable_intra_edge_filter); 624 DXVK_VD_CMP_FIELD(sh, flags.enable_interintra_compound); 625 DXVK_VD_CMP_FIELD(sh, flags.enable_masked_compound); 626 DXVK_VD_CMP_FIELD(sh, flags.enable_warped_motion); 627 DXVK_VD_CMP_FIELD(sh, flags.enable_dual_filter); 628 DXVK_VD_CMP_FIELD(sh, flags.enable_order_hint); 629 DXVK_VD_CMP_FIELD(sh, flags.enable_jnt_comp); 630 DXVK_VD_CMP_FIELD(sh, flags.enable_ref_frame_mvs); 631 DXVK_VD_CMP_FIELD(sh, flags.frame_id_numbers_present_flag); 632 DXVK_VD_CMP_FIELD(sh, flags.enable_superres); 633 DXVK_VD_CMP_FIELD(sh, flags.enable_cdef); 634 DXVK_VD_CMP_FIELD(sh, flags.enable_restoration); 635 DXVK_VD_CMP_FIELD(sh, flags.film_grain_params_present); 636 DXVK_VD_CMP_FIELD(sh, flags.timing_info_present_flag); 637 DXVK_VD_CMP_FIELD(sh, flags.initial_display_delay_present_flag); 638 DXVK_VD_CMP_FIELD(sh, seq_profile); 639 DXVK_VD_CMP_FIELD(sh, frame_width_bits_minus_1); 640 DXVK_VD_CMP_FIELD(sh, frame_height_bits_minus_1); 641 DXVK_VD_CMP_FIELD(sh, max_frame_width_minus_1); 642 DXVK_VD_CMP_FIELD(sh, max_frame_height_minus_1); 643 DXVK_VD_CMP_FIELD(sh, delta_frame_id_length_minus_2); 644 DXVK_VD_CMP_FIELD(sh, additional_frame_id_length_minus_1); 645 DXVK_VD_CMP_FIELD(sh, order_hint_bits_minus_1); 646 DXVK_VD_CMP_FIELD(sh, seq_force_integer_mv); 647 DXVK_VD_CMP_FIELD(sh, seq_force_screen_content_tools); 566 648 return true; 567 649 } … … 793 875 /* Update internal pointer(s). */ 794 876 pParms->h264.sps.pOffsetForRefFrame = &pParms->h264.spsOffsetForRefFrame; 795 pParms->h264.pps.pScalingLists = &pParms->h264.ppsScalingLists;877 pParms->h264.pps.pScalingLists = &pParms->h264.ppsScalingLists; 796 878 797 879 /* Information about a possible update of session parameters. */ … … 863 945 pParms->h265.vps.pProfileTierLevel = &pParms->h265.vpsProfileTierLevel; 864 946 pParms->h265.sps.pProfileTierLevel = &pParms->h265.vpsProfileTierLevel; 865 pParms->h265.pps.pScalingLists = &pParms->h265.ppsScalingLists; 947 pParms->h265.sps.pDecPicBufMgr = &pParms->h265.spsDecPicBufMgr; 948 pParms->h265.pps.pScalingLists = &pParms->h265.ppsScalingLists; 866 949 867 950 /* Information about a possible update of session parameters. */ … … 994 1077 995 1078 1079 VkResult DxvkVideoDecoder::UpdateSessionParametersAV1( 1080 DxvkVideoDecodeInputParameters *pParms) { 1081 /* Update internal pointer(s). */ 1082 pParms->av1.stdSequenceHeader.pColorConfig = &pParms->av1.stdColorConfig; 1083 pParms->av1.stdPictureInfo.pTileInfo = &pParms->av1.stdTileInfo; 1084 pParms->av1.stdPictureInfo.pQuantization = &pParms->av1.stdQuantization; 1085 pParms->av1.stdPictureInfo.pSegmentation = &pParms->av1.stdSegmentation; 1086 pParms->av1.stdPictureInfo.pLoopFilter = &pParms->av1.stdLoopFilter; 1087 pParms->av1.stdPictureInfo.pCDEF = &pParms->av1.stdCDEF; 1088 pParms->av1.stdPictureInfo.pLoopRestoration = &pParms->av1.stdLoopRestoration; 1089 pParms->av1.stdPictureInfo.pGlobalMotion = &pParms->av1.stdGlobalMotion; 1090 pParms->av1.stdPictureInfo.pFilmGrain = pParms->av1.stdPictureInfo.flags.apply_grain 1091 ? &pParms->av1.stdFilmGrain 1092 : nullptr; 1093 pParms->av1.stdTileInfo.pMiColStarts = &pParms->av1.MiColStarts[0]; 1094 pParms->av1.stdTileInfo.pWidthInSbsMinus1 = &pParms->av1.WidthInSbsMinus1[0]; 1095 pParms->av1.stdTileInfo.pMiRowStarts = &pParms->av1.MiRowStarts[0]; 1096 pParms->av1.stdTileInfo.pHeightInSbsMinus1 = &pParms->av1.HeightInSbsMinus1[0]; 1097 1098 if (m_videoSessionParameters->handle() != VK_NULL_HANDLE 1099 && IsAV1SequenceHeaderEqual(pParms->av1.stdSequenceHeader, m_parameterSetCache.av1.stdSequenceHeader)) 1100 return VK_SUCCESS; 1101 1102 m_parameterSetCache.av1.stdSequenceHeader = pParms->av1.stdSequenceHeader; 1103 1104 /* Create videoSessionParameters with the new info. */ 1105 m_videoSessionParameters = new DxvkVideoSessionParametersHandle(m_device); 1106 1107 VkVideoDecodeAV1SessionParametersCreateInfoKHR av1SessionParametersCreateInfo = 1108 { VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR }; 1109 av1SessionParametersCreateInfo.pStdSequenceHeader = &pParms->av1.stdSequenceHeader; 1110 1111 m_videoSessionParameters->create(m_videoSession, &av1SessionParametersCreateInfo); 1112 1113 return VK_SUCCESS; 1114 } 1115 1116 1117 static int8_t av1_get_relative_dist(const DxvkVideoDecodeInputParameters &parms, 1118 uint8_t a, uint8_t b) { 1119 /* AV1 spec 5.9.3. Get relative distance function */ 1120 int8_t diff = a - b; 1121 const uint8_t m = 1 << parms.av1.stdSequenceHeader.order_hint_bits_minus_1; 1122 diff = (diff & (m - 1)) - (diff & m); 1123 return diff; 1124 } 1125 1126 1127 static void av1_RefFrameSignBias(DxvkVideoDecodeInputParameters &parms) { 1128 if (parms.av1.stdSequenceHeader.flags.enable_order_hint) { 1129 for (uint8_t i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; ++i) { 1130 const uint8_t refFrameName = STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME + i; 1131 const int8_t relativeDistance = av1_get_relative_dist(parms, 1132 parms.av1.stdPictureInfo.OrderHints[refFrameName], parms.av1.stdPictureInfo.OrderHint); 1133 1134 /* Vulkan uses bit mask as array. */ 1135 parms.av1.stdReferenceInfo.RefFrameSignBias |= (relativeDistance > 0) << refFrameName; 1136 } 1137 } 1138 } 1139 1140 1141 static void av1_skip_mode_params(DxvkVideoDecodeInputParameters &parms) { 1142 if (parms.av1.stdPictureInfo.frame_type == STD_VIDEO_AV1_FRAME_TYPE_KEY 1143 || parms.av1.stdPictureInfo.frame_type == STD_VIDEO_AV1_FRAME_TYPE_INTRA_ONLY 1144 || !parms.av1.stdPictureInfo.flags.reference_select 1145 || !parms.av1.stdSequenceHeader.flags.enable_order_hint) { 1146 return; 1147 } 1148 1149 int8_t forwardIdx = -1; 1150 int8_t backwardIdx = -1; 1151 uint8_t forwardHint; 1152 uint8_t backwardHint; 1153 1154 for (uint8_t i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; ++i) { 1155 const uint8_t refFrameName = STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME + i; 1156 const uint8_t refHint = parms.av1.stdPictureInfo.OrderHints[refFrameName]; 1157 1158 if (av1_get_relative_dist(parms, refHint, parms.av1.stdPictureInfo.OrderHint) < 0) { 1159 if (forwardIdx < 0 1160 || av1_get_relative_dist(parms, refHint, forwardHint) > 0) { 1161 forwardIdx = i; 1162 forwardHint = refHint; 1163 } 1164 } else if (av1_get_relative_dist(parms, refHint, parms.av1.stdPictureInfo.OrderHint) > 0) { 1165 if (backwardIdx < 0 1166 || av1_get_relative_dist(parms, refHint, backwardHint) < 0 ) { 1167 backwardIdx = i; 1168 backwardHint = refHint; 1169 } 1170 } 1171 } 1172 1173 if (forwardIdx < 0) { 1174 return; 1175 } 1176 1177 if (backwardIdx >= 0) { 1178 parms.av1.stdPictureInfo.SkipModeFrame[0] = STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME 1179 + std::min(forwardIdx, backwardIdx); 1180 parms.av1.stdPictureInfo.SkipModeFrame[1] = STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME 1181 + std::max(forwardIdx, backwardIdx); 1182 } 1183 else { 1184 int8_t secondForwardIdx = -1; 1185 uint8_t secondForwardHint; 1186 1187 for (uint8_t i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; ++i) { 1188 const uint8_t refFrameName = STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME + i; 1189 const uint8_t refHint = parms.av1.stdPictureInfo.OrderHints[refFrameName]; 1190 1191 if (av1_get_relative_dist(parms, refHint, forwardHint) < 0) { 1192 if (secondForwardIdx < 0 1193 || av1_get_relative_dist(parms, refHint, secondForwardHint) > 0) { 1194 secondForwardIdx = i; 1195 secondForwardHint = refHint; 1196 } 1197 } 1198 } 1199 1200 if (secondForwardIdx >= 0) { 1201 parms.av1.stdPictureInfo.SkipModeFrame[0] = STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME 1202 + std::min(forwardIdx, secondForwardIdx); 1203 parms.av1.stdPictureInfo.SkipModeFrame[1] = STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME 1204 + std::max(forwardIdx, secondForwardIdx); 1205 } 1206 } 1207 } 1208 1209 1210 static void av1ComputeParams(DxvkVideoDecodeInputParameters &parms) { 1211 /* Update various parameters as described in AV1 spec. */ 1212 1213 /* AV1 spec 5.9.2. Uncompressed header syntax */ 1214 av1_RefFrameSignBias(parms); 1215 1216 /* AV1 spec 5.9.22. Skip mode params syntax */ 1217 av1_skip_mode_params(parms); 1218 } 1219 1220 996 1221 void DxvkVideoDecoder::Decode( 997 1222 DxvkContext* ctx, … … 1007 1232 vr = this->UpdateSessionParametersH265(&parms); 1008 1233 } 1234 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1235 vr = this->UpdateSessionParametersAV1(&parms); 1236 } 1009 1237 if (vr != VK_SUCCESS) 1010 1238 return; 1239 1240 const bool fUseDistinctOutputImage = m_caps.distinctOutputImage 1241 || (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR 1242 && parms.av1.stdPictureInfo.flags.apply_grain); 1243 1244 VkExtent2D codedExtent = { m_sampleWidth, m_sampleHeight }; 1245 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1246 codedExtent.width = parms.av1.stdSequenceHeader.max_frame_width_minus_1 + 1; 1247 codedExtent.height = parms.av1.stdSequenceHeader.max_frame_height_minus_1 + 1; 1248 } 1249 1250 if (codedExtent.width > m_DPB.decodedPictureExtent.width 1251 || codedExtent.height > m_DPB.decodedPictureExtent.height) { 1252 Logger::err(str::format("DxvkVideoDecoder: frame size (", codedExtent.width, "x", codedExtent.height, ")", 1253 " exceeds DPB image size (", m_DPB.decodedPictureExtent.width, "x", m_DPB.decodedPictureExtent.height, ")")); 1254 return; 1255 } 1011 1256 1012 1257 /* … … 1045 1290 bool doIDR = false; 1046 1291 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) { 1047 doIDR = parms. nal_unit_type == 5;1292 doIDR = parms.h264.nal_unit_type == 5; 1048 1293 } 1049 1294 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { 1050 1295 doIDR = parms.h265.stdPictureInfo.flags.IdrPicFlag; 1051 1296 } 1297 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1298 doIDR = parms.av1.stdPictureInfo.frame_type == STD_VIDEO_AV1_FRAME_TYPE_KEY; 1299 } 1052 1300 if (doIDR) /* IDR, immediate decoder reset. */ 1053 1301 m_DPB.reset(); 1302 1303 if (m_DPB.fOverflow) 1304 return; 1054 1305 1055 1306 /* … … 1070 1321 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) { 1071 1322 StdVideoDecodeH264ReferenceInfo& stdRefInfo = m_DPB.slots[refFrame.dpbSlotIndex].h264.stdRefInfo; 1072 stdRefInfo.flags.used_for_long_term_reference = r. longTermReference;1073 stdRefInfo.flags.is_non_existing = r. nonExistingFrame;1074 stdRefInfo.FrameNum = r. frame_num;1075 stdRefInfo.PicOrderCnt[0] = r. PicOrderCnt[0];1076 stdRefInfo.PicOrderCnt[1] = r. PicOrderCnt[1];1323 stdRefInfo.flags.used_for_long_term_reference = r.h264.longTermReference; 1324 stdRefInfo.flags.is_non_existing = r.h264.nonExistingFrame; 1325 stdRefInfo.FrameNum = r.h264.frame_num; 1326 stdRefInfo.PicOrderCnt[0] = r.h264.PicOrderCnt[0]; 1327 stdRefInfo.PicOrderCnt[1] = r.h264.PicOrderCnt[1]; 1077 1328 } 1078 1329 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { 1079 1330 StdVideoDecodeH265ReferenceInfo& stdRefInfo = m_DPB.slots[refFrame.dpbSlotIndex].h265.stdRefInfo; 1080 stdRefInfo.flags.used_for_long_term_reference = r. longTermReference;1331 stdRefInfo.flags.used_for_long_term_reference = r.h265.longTermReference; 1081 1332 stdRefInfo.flags.unused_for_reference = 0; /* It is a ref frame. */ 1082 stdRefInfo.PicOrderCntVal = r. PicOrderCnt[0];1333 stdRefInfo.PicOrderCntVal = r.h265.PicOrderCntVal; 1083 1334 } 1084 } 1335 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1336 StdVideoDecodeAV1ReferenceInfo& stdRefInfo = m_DPB.slots[refFrame.dpbSlotIndex].av1.stdRefInfo; 1337 parms.av1.stdPictureInfo.OrderHints[r.av1.frame_name] = stdRefInfo.OrderHint; 1338 } 1339 } 1340 } 1341 1342 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1343 av1ComputeParams(parms); 1085 1344 } 1086 1345 … … 1105 1364 for (uint32_t i = 0; i < m_DPB.slots.size(); ++i) { 1106 1365 DxvkDPBSlot& slot = m_DPB.slots[m_DPB.idxCurrentDPBSlot]; 1107 bool isLongReference= false;1366 bool keepSlot = false; 1108 1367 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) { 1109 isLongReference = slot.h264.stdRefInfo.flags.used_for_long_term_reference != 0; 1368 keepSlot = slot.h264.stdRefInfo.flags.used_for_long_term_reference != 0; 1369 for (uint32_t i = 0; i < parms.refFramesCount && !keepSlot; ++i) { 1370 const DxvkRefFrameInfo& r = parms.refFrames[i]; 1371 keepSlot = r.idSurface == slot.idSurface; 1372 } 1110 1373 } 1111 1374 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { 1112 isLongReference = slot.h265.stdRefInfo.flags.used_for_long_term_reference != 0; 1375 keepSlot = slot.h265.stdRefInfo.flags.used_for_long_term_reference != 0; 1376 for (uint32_t i = 0; i < parms.refFramesCount && !keepSlot; ++i) { 1377 const DxvkRefFrameInfo& r = parms.refFrames[i]; 1378 keepSlot = r.idSurface == slot.idSurface; 1379 } 1380 } 1381 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1382 /* Keep frames those are included in RefFrameMapTextureIndex */ 1383 for (uint32_t i = 0; i < 8 && !keepSlot; ++i) { 1384 if (slot.idSurface == parms.av1.RefFrameMapTextureIndex[i]) { 1385 keepSlot = true; 1386 } 1387 } 1113 1388 } 1114 1389 if (slot.isActive 1115 && isLongReference) {1390 && keepSlot) { 1116 1391 m_DPB.idxCurrentDPBSlot = (m_DPB.idxCurrentDPBSlot + 1) % m_DPB.slots.size(); 1117 1392 continue; … … 1135 1410 /* No free slots. This can happen only if entire DPB is occupied by long-term references, 1136 1411 * which is probably due to an invalid video stream. 1137 * Try to recover by resetting the DPB.1412 * Skip frames until the next IDR frame. 1138 1413 */ 1139 m_DPB. reset();1140 dstSlotIndex = 0;1414 m_DPB.fOverflow = true; 1415 return; 1141 1416 } 1142 1417 … … 1149 1424 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { 1150 1425 dstDPBSlot.h265.stdRefInfo = parms.h265.stdReferenceInfo; 1426 } 1427 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1428 dstDPBSlot.av1.stdRefInfo = parms.av1.stdReferenceInfo; 1429 /* dstDPBSlot.av1.stdRefInfo.SavedOrderHints are updated after decoding of the frame. */ 1151 1430 } 1152 1431 dstDPBSlot.idSurface = DXVK_VIDEO_DECODER_SURFACE_INVALID; /* Reference picture will be associated later. */ … … 1181 1460 ctx->emitPipelineBarrier(DxvkCmdBuffer::VDecBuffer, &dependencyInfo); 1182 1461 1183 if ( m_caps.distinctOutputImage) {1462 if (fUseDistinctOutputImage) { 1184 1463 /* 1185 1464 * Prepare decode destination layout. … … 1211 1490 } 1212 1491 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { 1213 maxRefFrames = parms.h265.sps_max_dec_pic_buffering; 1492 maxRefFrames = parms.h265.spsDecPicBufMgr.max_dec_pic_buffering_minus1[0] + 1; 1493 } 1494 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1495 maxRefFrames = STD_VIDEO_AV1_REFS_PER_FRAME; 1214 1496 } 1215 1497 const uint32_t maxRefSlotsCount = std::min(parms.refFramesCount, maxRefFrames); … … 1218 1500 std::vector<VkVideoDecodeH264DpbSlotInfoKHR> h264DpbSlotInfo(maxRefSlotsCount + 1); 1219 1501 std::vector<VkVideoDecodeH265DpbSlotInfoKHR> h265DpbSlotInfo(maxRefSlotsCount + 1); 1502 std::vector<VkVideoDecodeAV1DpbSlotInfoKHR> av1DpbSlotInfo(maxRefSlotsCount + 1); 1220 1503 std::vector<VkVideoPictureResourceInfoKHR> pictureResourceInfo(maxRefSlotsCount + 1); 1221 1504 std::vector<VkVideoReferenceSlotInfoKHR> referenceSlotsInfo(maxRefSlotsCount + 1); … … 1238 1521 continue; 1239 1522 } 1523 1524 /* Skip if the frame id has been already added to referenceSlotsInfo. */ 1525 uint32_t j = 0; 1526 for (; j < refSlotsCount; ++j) { 1527 if (referenceSlotsInfo[j].slotIndex == dpbSlotIndex) { 1528 Logger::debug(str::format("DPBM: DPB[", dpbSlotIndex, "]: reference picture [", i, "]", 1529 " (added at ", refSlotsCount, ") already exists at ", j)); 1530 break; 1531 } 1532 } 1533 if (j < refSlotsCount) 1534 continue; 1240 1535 1241 1536 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) { … … 1251 1546 pNext = &h265DpbSlotInfo[refSlotsCount]; 1252 1547 } 1548 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1549 av1DpbSlotInfo[refSlotsCount] = 1550 { VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_DPB_SLOT_INFO_KHR }; 1551 av1DpbSlotInfo[refSlotsCount].pStdReferenceInfo = &m_DPB.slots[dpbSlotIndex].av1.stdRefInfo; 1552 pNext = &av1DpbSlotInfo[refSlotsCount]; 1553 } 1554 else { 1555 pNext = nullptr; 1556 } 1253 1557 1254 1558 pictureResourceInfo[refSlotsCount] = 1255 1559 { VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR }; 1256 1560 pictureResourceInfo[refSlotsCount].codedOffset = { 0, 0 }; 1257 pictureResourceInfo[refSlotsCount].codedExtent = { m_sampleWidth, m_sampleHeight };1561 pictureResourceInfo[refSlotsCount].codedExtent = codedExtent; 1258 1562 pictureResourceInfo[refSlotsCount].baseArrayLayer = 0; /* "relative to the image subresource range" of the view */ 1259 1563 pictureResourceInfo[refSlotsCount].imageViewBinding = m_DPB.slots[dpbSlotIndex].imageView->handle(); … … 1281 1585 pNext = &h265DpbSlotInfo[refSlotsCount]; 1282 1586 } 1587 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1588 av1DpbSlotInfo[refSlotsCount] = 1589 { VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_DPB_SLOT_INFO_KHR }; 1590 av1DpbSlotInfo[refSlotsCount].pStdReferenceInfo = &dstDPBSlot.av1.stdRefInfo; 1591 pNext = &av1DpbSlotInfo[refSlotsCount]; 1592 } 1283 1593 1284 1594 pictureResourceInfo[refSlotsCount] = 1285 1595 { VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR }; 1286 1596 pictureResourceInfo[refSlotsCount].codedOffset = { 0, 0 }; 1287 pictureResourceInfo[refSlotsCount].codedExtent = { m_sampleWidth, m_sampleHeight };1597 pictureResourceInfo[refSlotsCount].codedExtent = codedExtent; 1288 1598 pictureResourceInfo[refSlotsCount].baseArrayLayer = 0; /* "relative to the image subresource range" of the view */ 1289 1599 pictureResourceInfo[refSlotsCount].imageViewBinding = dstDPBSlot.imageView->handle(); … … 1305 1615 #ifdef DEBUG 1306 1616 Logger::debug(str::format("VREF: beginVideoCoding: dstSlotIndex=", dstSlotIndex, 1307 " ", m_sampleWidth, "x", m_sampleHeight));1617 " ", codedExtent.width, "x", codedExtent.height)); 1308 1618 for (uint32_t i = 0; i < beginCodingInfo.referenceSlotCount; ++i) { 1309 1619 auto &s = beginCodingInfo.pReferenceSlots[i]; 1310 1620 const DxvkDPBSlot& dpbSlot = m_DPB.slots[s.slotIndex == -1 ? dstSlotIndex : s.slotIndex]; 1311 int32_t FrameNum = 0; 1621 1622 int32_t FrameNum = -1; 1312 1623 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) 1313 1624 FrameNum = dpbSlot.h264.stdRefInfo.FrameNum; 1314 1625 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) 1315 1626 FrameNum = dpbSlot.h265.stdRefInfo.PicOrderCntVal; 1627 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) 1628 FrameNum = dpbSlot.av1.stdRefInfo.OrderHint; 1629 1316 1630 Logger::debug(str::format("VREF: RefSlot[", i, "]: slotIndex=", s.slotIndex, 1317 1631 ", FrameNum=", FrameNum, … … 1350 1664 VkVideoDecodeH265PictureInfoKHR h265PictureInfo = 1351 1665 { VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR }; 1666 VkVideoDecodeAV1PictureInfoKHR av1PictureInfo = 1667 { VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_KHR }; 1352 1668 1353 1669 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) { 1354 1670 h264PictureInfo.pStdPictureInfo = &parms.h264.stdH264PictureInfo; 1355 h264PictureInfo.sliceCount = parms.sliceO ffsets.size();1356 h264PictureInfo.pSliceOffsets = parms.sliceO ffsets.data();1671 h264PictureInfo.sliceCount = parms.sliceOrTileOffsets.size(); 1672 h264PictureInfo.pSliceOffsets = parms.sliceOrTileOffsets.data(); 1357 1673 pNext = &h264PictureInfo; 1358 1674 } 1359 1675 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) { 1360 1676 h265PictureInfo.pStdPictureInfo = &parms.h265.stdPictureInfo; 1361 h265PictureInfo.sliceSegmentCount = parms.sliceO ffsets.size();1362 h265PictureInfo.pSliceSegmentOffsets = parms.sliceO ffsets.data();1677 h265PictureInfo.sliceSegmentCount = parms.sliceOrTileOffsets.size(); 1678 h265PictureInfo.pSliceSegmentOffsets = parms.sliceOrTileOffsets.data(); 1363 1679 pNext = &h265PictureInfo; 1680 } 1681 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 1682 av1PictureInfo.pStdPictureInfo = &parms.av1.stdPictureInfo; 1683 for (uint32_t i = 0; i < VK_MAX_VIDEO_AV1_REFERENCES_PER_FRAME_KHR; ++i) { 1684 av1PictureInfo.referenceNameSlotIndices[i] = -1; 1685 if (i >= parms.refFramesCount) 1686 continue; 1687 1688 const DxvkRefFrameInfo& r = parms.refFrames[i]; 1689 1690 itRefFrame = m_DPB.refFrames.find(r.idSurface); 1691 if (itRefFrame == m_DPB.refFrames.end()) { 1692 /* Skip invalid reference frame. */ 1693 continue; 1694 } 1695 1696 const int32_t dpbSlotIndex = itRefFrame->second.dpbSlotIndex; 1697 if (dpbSlotIndex == -1) { 1698 /* Skip invalid reference frame. */ 1699 continue; 1700 } 1701 1702 av1PictureInfo.referenceNameSlotIndices[i] = dpbSlotIndex; 1703 } 1704 1705 av1PictureInfo.frameHeaderOffset = 0; 1706 av1PictureInfo.tileCount = parms.av1.tileCount; 1707 av1PictureInfo.pTileOffsets = parms.sliceOrTileOffsets.data(); 1708 av1PictureInfo.pTileSizes = parms.sliceOrTileSizes.data(); 1709 pNext = &av1PictureInfo; 1364 1710 } 1365 1711 … … 1373 1719 { VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR }; 1374 1720 decodeInfo.dstPictureResource.codedOffset = { 0, 0 }; 1375 decodeInfo.dstPictureResource.codedExtent = { m_sampleWidth, m_sampleHeight };1721 decodeInfo.dstPictureResource.codedExtent = codedExtent; 1376 1722 /* "baseArrayLayer relative to the image subresource range the image view specified in 1377 1723 * imageViewBinding was created with." 1378 1724 */ 1379 1725 decodeInfo.dstPictureResource.baseArrayLayer = 0; 1380 if ( m_caps.distinctOutputImage) {1726 if (fUseDistinctOutputImage) { 1381 1727 decodeInfo.dstPictureResource.imageViewBinding = m_imageViewDecodeDst->handle(); 1382 1728 } … … 1393 1739 auto &s = decodeInfo.pReferenceSlots[i]; 1394 1740 const DxvkDPBSlot& dpbSlot = m_DPB.slots[s.slotIndex]; 1395 int32_t FrameNum = 0; 1741 1742 int32_t FrameNum = -1; 1396 1743 if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) 1397 1744 FrameNum = dpbSlot.h264.stdRefInfo.FrameNum; 1398 1745 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) 1399 1746 FrameNum = dpbSlot.h265.stdRefInfo.PicOrderCntVal; 1747 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) 1748 FrameNum = dpbSlot.av1.stdRefInfo.OrderHint; 1749 1400 1750 Logger::debug(str::format("VREF: RefSlot[", i, "]: slotIndex=", s.slotIndex, 1401 1751 ", FrameNum=", FrameNum, … … 1407 1757 : (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) 1408 1758 ? dstDPBSlot.h265.stdRefInfo.PicOrderCntVal 1759 : (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) 1760 ? dstDPBSlot.av1.stdRefInfo.OrderHint 1409 1761 : -1), 1410 1762 ", is_ref=", (uint32_t)(m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR 1411 1763 ? parms.h264.stdH264PictureInfo.flags.is_reference 1764 : (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) 1765 ? parms.av1.reference_frame_update 1412 1766 : 0), 1413 1767 ", view=", dstDPBSlot.imageView->handle())); … … 1430 1784 uint32_t decodedArrayLayer; 1431 1785 VkImageLayout decodedPictureLayout; 1432 if ( m_caps.distinctOutputImage) {1786 if (fUseDistinctOutputImage) { 1433 1787 decodedPicture = m_imageDecodeDst; 1434 1788 decodedArrayLayer = 0; … … 1440 1794 decodedPictureLayout = VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR; 1441 1795 } 1796 1797 /* Prepare parameters for copying decoded image to the output view. */ 1798 VkExtent3D outputExtent = m_outputImageView->imageInfo().extent; 1799 VkExtent3D copyExtent = { 1800 std::min(outputExtent.width, m_DPB.decodedPictureExtent.width), 1801 std::min(outputExtent.height, m_DPB.decodedPictureExtent.height), 1802 1 }; 1803 1804 std::array<VkImageCopy2, 2> regions{{ 1805 { VK_STRUCTURE_TYPE_IMAGE_COPY_2 }, 1806 { VK_STRUCTURE_TYPE_IMAGE_COPY_2 }}}; 1807 /* Y plane. */ 1808 regions[0].srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; 1809 //regions[0].srcSubresource.mipLevel = 0; 1810 regions[0].srcSubresource.baseArrayLayer = decodedArrayLayer; 1811 regions[0].srcSubresource.layerCount = 1; 1812 //regions[0].srcOffset = { 0, 0, 0 }; 1813 regions[0].dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; 1814 //regions[0].dstSubresource.mipLevel = 0; 1815 regions[0].dstSubresource.baseArrayLayer = m_outputImageView->info().minLayer; 1816 regions[0].dstSubresource.layerCount = 1; 1817 //regions[0].dstOffset = { 0, 0, 0 }; 1818 regions[0].extent = copyExtent; 1819 1820 /* CbCr plane at half resolution. */ 1821 regions[1].srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; 1822 //regions[1].srcSubresource.mipLevel = 0; 1823 regions[1].srcSubresource.baseArrayLayer = decodedArrayLayer; 1824 regions[1].srcSubresource.layerCount = 1; 1825 //regions[1].srcOffset = { 0, 0, 0 }; 1826 regions[1].dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; 1827 //regions[1].dstSubresource.mipLevel = 0; 1828 regions[1].dstSubresource.baseArrayLayer = m_outputImageView->info().minLayer; 1829 regions[1].dstSubresource.layerCount = 1; 1830 //regions[1].dstOffset = { 0, 0, 0 }; 1831 regions[1].extent = { copyExtent.width / 2, copyExtent.height / 2, 1 }; 1832 1833 VkCopyImageInfo2 copyImageInfo = 1834 { VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2 }; 1835 copyImageInfo.srcImage = decodedPicture->handle(); 1836 copyImageInfo.srcImageLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; 1837 copyImageInfo.dstImage = m_outputImageView->imageHandle(); 1838 copyImageInfo.dstImageLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; 1839 copyImageInfo.regionCount = 2; 1840 copyImageInfo.pRegions = regions.data(); 1442 1841 1443 1842 if (m_profile.videoQueueHasTransfer) { … … 1467 1866 ctx->emitPipelineBarrier(DxvkCmdBuffer::VDecBuffer, &dependencyInfo); 1468 1867 1469 /* Copy decoded image -> output image. Y plane. */ 1470 std::array<VkImageCopy2, 2> regions{{ 1471 { VK_STRUCTURE_TYPE_IMAGE_COPY_2 }, 1472 { VK_STRUCTURE_TYPE_IMAGE_COPY_2 }}}; 1473 regions[0].srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; 1474 //regions[0].srcSubresource.mipLevel = 0; 1475 regions[0].srcSubresource.baseArrayLayer = decodedArrayLayer; 1476 regions[0].srcSubresource.layerCount = 1; 1477 //regions[0].srcOffset = { 0, 0, 0 }; 1478 regions[0].dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; 1479 //regions[0].dstSubresource.mipLevel = 0; 1480 regions[0].dstSubresource.baseArrayLayer = m_outputImageView->info().minLayer; 1481 regions[0].dstSubresource.layerCount = 1; 1482 //regions[0].dstOffset = { 0, 0, 0 }; 1483 regions[0].extent = { m_sampleWidth, m_sampleHeight, 1 }; 1484 1485 /* CbCr plane at half resolution. */ 1486 regions[1].srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; 1487 //regions[1].srcSubresource.mipLevel = 0; 1488 regions[1].srcSubresource.baseArrayLayer = decodedArrayLayer; 1489 regions[1].srcSubresource.layerCount = 1; 1490 //regions[1].srcOffset = { 0, 0, 0 }; 1491 regions[1].dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; 1492 //regions[1].dstSubresource.mipLevel = 0; 1493 regions[1].dstSubresource.baseArrayLayer = m_outputImageView->info().minLayer; 1494 regions[1].dstSubresource.layerCount = 1; 1495 //regions[1].dstOffset = { 0, 0, 0 }; 1496 regions[1].extent = { m_sampleWidth / 2, m_sampleHeight / 2, 1 }; 1497 1498 VkCopyImageInfo2 copyImageInfo = 1499 { VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2 }; 1500 copyImageInfo.srcImage = decodedPicture->handle(); 1501 copyImageInfo.srcImageLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; 1502 copyImageInfo.dstImage = m_outputImageView->imageHandle(); 1503 copyImageInfo.dstImageLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; 1504 copyImageInfo.regionCount = 2; 1505 copyImageInfo.pRegions = regions.data(); 1506 1868 /* Copy decoded image -> output image. */ 1507 1869 ctx->emitCopyImage(DxvkCmdBuffer::VDecBuffer, ©ImageInfo); 1508 1870 … … 1573 1935 ctx->emitPipelineBarrier(DxvkCmdBuffer::InitBuffer, &dependencyInfo); 1574 1936 1575 /* Copy decoded image -> output image. Y plane. */ 1576 std::array<VkImageCopy2, 2> regions{{ 1577 { VK_STRUCTURE_TYPE_IMAGE_COPY_2 }, 1578 { VK_STRUCTURE_TYPE_IMAGE_COPY_2 }}}; 1579 regions[0].srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; 1580 //regions[0].srcSubresource.mipLevel = 0; 1581 regions[0].srcSubresource.baseArrayLayer = decodedArrayLayer; 1582 regions[0].srcSubresource.layerCount = 1; 1583 //regions[0].srcOffset = { 0, 0, 0 }; 1584 regions[0].dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_0_BIT; 1585 //regions[0].dstSubresource.mipLevel = 0; 1586 regions[0].dstSubresource.baseArrayLayer = m_outputImageView->info().minLayer; 1587 regions[0].dstSubresource.layerCount = 1; 1588 //regions[0].dstOffset = { 0, 0, 0 }; 1589 regions[0].extent = { m_sampleWidth, m_sampleHeight, 1 }; 1590 1591 /* CbCr plane at half resolution. */ 1592 regions[1].srcSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; 1593 //regions[1].srcSubresource.mipLevel = 0; 1594 regions[1].srcSubresource.baseArrayLayer = decodedArrayLayer; 1595 regions[1].srcSubresource.layerCount = 1; 1596 //regions[1].srcOffset = { 0, 0, 0 }; 1597 regions[1].dstSubresource.aspectMask = VK_IMAGE_ASPECT_PLANE_1_BIT; 1598 //regions[1].dstSubresource.mipLevel = 0; 1599 regions[1].dstSubresource.baseArrayLayer = m_outputImageView->info().minLayer; 1600 regions[1].dstSubresource.layerCount = 1; 1601 //regions[1].dstOffset = { 0, 0, 0 }; 1602 regions[1].extent = { m_sampleWidth / 2, m_sampleHeight / 2, 1 }; 1603 1604 VkCopyImageInfo2 copyImageInfo = 1605 { VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2 }; 1606 copyImageInfo.srcImage = decodedPicture->handle(); 1607 copyImageInfo.srcImageLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; 1608 copyImageInfo.dstImage = m_outputImageView->imageHandle(); 1609 copyImageInfo.dstImageLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; 1610 copyImageInfo.regionCount = 2; 1611 copyImageInfo.pRegions = regions.data(); 1612 1937 /* Copy decoded image -> output image. */ 1613 1938 ctx->emitCopyImage(DxvkCmdBuffer::InitBuffer, ©ImageInfo); 1614 1939 … … 1662 1987 else 1663 1988 ctx->trackResource(DxvkAccess::Write, dstDPBSlot.image); /* Same image in every slot. */ 1664 if ( m_caps.distinctOutputImage)1989 if (fUseDistinctOutputImage) 1665 1990 ctx->trackResource(DxvkAccess::Write, m_imageDecodeDst); 1666 1991 ctx->trackResource(DxvkAccess::Read, m_bitstreamBuffer); 1667 1992 1668 1993 /* 1669 * Keep reference picture .1994 * Keep reference picture and update its information if necessary. 1670 1995 */ 1671 1996 bool activateSlot = false; … … 1676 2001 activateSlot = true; /* It is not known yet if the picture is a reference. */ 1677 2002 } 2003 else if (m_profile.profileInfo.videoCodecOperation == VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR) { 2004 activateSlot = parms.av1.reference_frame_update; 2005 if (activateSlot) { 2006 for (uint32_t i = 0; i < STD_VIDEO_AV1_NUM_REF_FRAMES; ++i) 2007 dstDPBSlot.av1.stdRefInfo.SavedOrderHints[i] = parms.av1.stdPictureInfo.OrderHints[i]; 2008 } 2009 } 1678 2010 if (activateSlot) { 1679 2011 dstDPBSlot.isActive = true; -
trunk/src/libs/dxvk-2.3.1/src/dxvk/dxvk_video_decoder.h
r108423 r108577 47 47 VkVideoDecodeH264ProfileInfoKHR h264ProfileInfo; 48 48 VkVideoDecodeH265ProfileInfoKHR h265ProfileInfo; 49 VkVideoDecodeAV1ProfileInfoKHR av1ProfileInfo; 49 50 }; 50 51 /* Vulkan profile info. */ … … 54 55 VkVideoDecodeH264CapabilitiesKHR decodeH264Capabilities; 55 56 VkVideoDecodeH265CapabilitiesKHR decodeH265Capabilities; 57 VkVideoDecodeAV1CapabilitiesKHR decodeAV1Capabilities; 56 58 }; 57 59 VkVideoDecodeCapabilitiesKHR decodeCapabilities; … … 65 67 66 68 struct DxvkRefFrameInfo { 67 uint8_t idSurface; 68 uint8_t longTermReference : 1; 69 uint8_t usedForReference : 2; 70 uint8_t nonExistingFrame : 1; 71 uint16_t frame_num; 72 int32_t PicOrderCnt[2]; 69 uint8_t idSurface; 70 union { 71 struct { 72 uint8_t longTermReference : 1; 73 uint8_t usedForReference : 2; 74 uint8_t nonExistingFrame : 1; 75 uint16_t frame_num; 76 int32_t PicOrderCnt[2]; 77 } h264; 78 struct { 79 uint8_t longTermReference : 1; 80 int32_t PicOrderCntVal; 81 } h265; 82 struct { 83 uint8_t frame_name; 84 } av1; 85 }; 73 86 }; 74 87 … … 85 98 StdVideoDecodeH264PictureInfo stdH264PictureInfo; 86 99 StdVideoDecodeH264ReferenceInfo stdH264ReferenceInfo; 100 101 uint8_t nal_unit_type; 87 102 } h264; 88 103 struct { … … 90 105 StdVideoH265ProfileTierLevel vpsProfileTierLevel; 91 106 StdVideoH265SequenceParameterSet sps; 107 StdVideoH265DecPicBufMgr spsDecPicBufMgr; 92 108 StdVideoH265PictureParameterSet pps; 93 109 StdVideoH265ScalingLists ppsScalingLists; … … 95 111 StdVideoDecodeH265PictureInfo stdPictureInfo; 96 112 StdVideoDecodeH265ReferenceInfo stdReferenceInfo; 97 98 uint8_t sps_max_dec_pic_buffering;99 113 } h265; 100 }; 101 102 uint8_t nal_unit_type; 103 104 std::vector<uint32_t> sliceOffsets; 114 struct { 115 StdVideoAV1SequenceHeader stdSequenceHeader; 116 StdVideoAV1ColorConfig stdColorConfig; 117 118 StdVideoDecodeAV1PictureInfo stdPictureInfo; 119 StdVideoAV1TileInfo stdTileInfo; 120 uint16_t MiColStarts[64]; 121 uint16_t MiRowStarts[64]; 122 uint16_t WidthInSbsMinus1[64]; 123 uint16_t HeightInSbsMinus1[64]; 124 StdVideoAV1Quantization stdQuantization; 125 StdVideoAV1Segmentation stdSegmentation; 126 StdVideoAV1LoopFilter stdLoopFilter; 127 StdVideoAV1CDEF stdCDEF; 128 StdVideoAV1LoopRestoration stdLoopRestoration; 129 StdVideoAV1GlobalMotion stdGlobalMotion; 130 StdVideoAV1FilmGrain stdFilmGrain; 131 132 uint32_t tileCount; 133 134 StdVideoDecodeAV1ReferenceInfo stdReferenceInfo; 135 136 uint8_t RefFrameMapTextureIndex[8]; 137 138 bool reference_frame_update; 139 } av1; 140 }; 141 142 std::vector<uint32_t> sliceOrTileOffsets; 143 std::vector<uint32_t> sliceOrTileSizes; 105 144 106 145 uint8_t idSurface; … … 282 321 */ 283 322 struct DxvkDPBSlot { 323 /* These fields will be assigned during video decoder initialization. */ 284 324 Rc<DxvkImage> image = nullptr; 285 325 Rc<DxvkImageView> imageView = nullptr; 286 326 uint32_t baseArrayLayer = 0; 287 bool isActive = false; 288 struct { 289 StdVideoDecodeH264ReferenceInfo stdRefInfo = {}; 290 } h264; 291 struct { 292 StdVideoDecodeH265ReferenceInfo stdRefInfo = {}; 293 } h265; 294 uint8_t idSurface = DXVK_VIDEO_DECODER_SURFACE_INVALID; 327 328 /* These fields are updated during decoding process. */ 329 bool isActive; 330 union { 331 struct { 332 StdVideoDecodeH264ReferenceInfo stdRefInfo; 333 } h264; 334 struct { 335 StdVideoDecodeH265ReferenceInfo stdRefInfo; 336 } h265; 337 struct { 338 StdVideoDecodeAV1ReferenceInfo stdRefInfo; 339 } av1; 340 uint8_t stdRefInfoData[ 341 std::max(sizeof(StdVideoDecodeH264ReferenceInfo), 342 std::max(sizeof(StdVideoDecodeH265ReferenceInfo), 343 sizeof(StdVideoDecodeAV1ReferenceInfo)))]; 344 }; 345 uint8_t idSurface; 295 346 296 347 void deactivate() { 297 this->isActive = false; 298 this->h264.stdRefInfo = {}; 299 this->h265.stdRefInfo = {}; 300 this->idSurface = DXVK_VIDEO_DECODER_SURFACE_INVALID; 348 this->isActive = false; 349 memset(this->stdRefInfoData, 0, sizeof(this->stdRefInfoData)); 350 this->idSurface = DXVK_VIDEO_DECODER_SURFACE_INVALID; 301 351 } 302 352 }; … … 311 361 std::vector<DxvkDPBSlot> slots; 312 362 int idxCurrentDPBSlot = 0; 363 bool fOverflow = false; 364 365 /* Size of DPB images. */ 366 VkExtent3D decodedPictureExtent = { 0, 0, 1 }; 313 367 314 368 /* Uncompressed surface id (idSurface) -> frame information. */ … … 319 373 slot.deactivate(); 320 374 this->idxCurrentDPBSlot = 0; 375 this->fOverflow = false; 321 376 this->refFrames.clear(); 322 377 } … … 344 399 std::array<StdVideoH265PictureParameterSet, 256> pps; 345 400 } h265; 401 struct { 402 StdVideoAV1SequenceHeader stdSequenceHeader; 403 } av1; 346 404 }; 347 405 DxvkParameterSetCache m_parameterSetCache; … … 357 415 358 416 VkResult UpdateSessionParametersH265( 417 DxvkVideoDecodeInputParameters *pParms); 418 419 VkResult UpdateSessionParametersAV1( 359 420 DxvkVideoDecodeInputParameters *pParms); 360 421
Note:
See TracChangeset
for help on using the changeset viewer.