Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
57d92ff
Video: public API additions for defect fixes
BjornSAIM Oct 2, 2026
218dad8
Validation: video checks for defect fixes
BjornSAIM Oct 2, 2026
2d447a3
Shared: fix AV1 header reconstruction and H.264 SPS cropping
BjornSAIM Oct 2, 2026
8641aaf
VK: fix video decode/encode defects
BjornSAIM Oct 2, 2026
af45e72
D3D12: fix video decode/encode defects
BjornSAIM Oct 2, 2026
c43fe9e
Validation: GetVideoPictureState accepts DPB roles for coincide decod…
BjornSAIM Oct 14, 2026
8ef36da
VK: pass the encode setup slot for non-reference pictures
BjornSAIM Oct 14, 2026
76169b1
VK: keep the video decode picture structures alive until the command …
BjornSAIM Oct 14, 2026
b2f2aaa
VK: always pass the QP range for CBR and VBR encode
BjornSAIM Oct 14, 2026
bf858ed
VK: H.264 slice offsets point at the start code
BjornSAIM Oct 14, 2026
3e5e10a
Shared: AV1 CDEF secondary strengths are passed as coded
claude Oct 14, 2026
6e304e1
D3D12: encode GOP structure follows the application's SPS
BjornSAIM Oct 14, 2026
19d52cb
D3D12: request num_ref_idx_active_override_flag when the active refer…
BjornSAIM Oct 14, 2026
83b952d
VK: IDR pictures keep the earlier pictures that are waiting for output
claude Oct 14, 2026
2c29330
VK: omitted CBR/VBR QP bounds use the codec range of the implementation
claude Oct 14, 2026
7ca6703
Validation: encode requires reconstructedPicture in sessions with DPB…
claude Oct 14, 2026
5e8c45c
Validation: H.265 'generalLevelIdc' must be a Table A.8 level
BjornSAIM Oct 21, 2026
f3b6638
Validation: H.265 Annex B parameter sets require a Table A.8 level
BjornSAIM Oct 21, 2026
f737634
Validation: H.264 'levelIdc' must be a Table A-1 level
BjornSAIM Oct 21, 2026
9011264
VK: work around NVIDIA encode feedback query copy hang
BjornSAIM Oct 2, 2026
ac4265e
D3D12: distinct decode output and reference-only DPB pictures
BjornSAIM Oct 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 38 additions & 21 deletions Include/Extensions/NRIVideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ NriBits(VideoH264SequenceParameterSetBits, uint16_t,
DELTA_PIC_ORDER_ALWAYS_ZERO = NriBit(9),
SEPARATE_COLOUR_PLANE = NriBit(10),
GAPS_IN_FRAME_NUM_ALLOWED = NriBit(11),
QPPRIME_Y_ZERO_TRANSFORM_BYPASS = NriBit(12)
QPPRIME_Y_ZERO_TRANSFORM_BYPASS = NriBit(12),
FRAME_CROPPING = NriBit(13)
);

NriBits(VideoH264PictureParameterSetBits, uint8_t,
Expand All @@ -109,7 +110,7 @@ NriBits(VideoH264DecodePictureBits, uint8_t,
COMPLEMENTARY_FIELD_PAIR = NriBit(5)
);

NriBits(VideoH264DecodeReferenceBits, uint8_t,
NriBits(VideoH264DecodeReferenceBits, uint8_t, // a frame reference sets neither or both of "TOP_FIELD" and "BOTTOM_FIELD"
NONE = 0,
TOP_FIELD = NriBit(0),
BOTTOM_FIELD = NriBit(1),
Expand Down Expand Up @@ -289,7 +290,7 @@ NriStruct(VideoCapabilities) {
uint32_t maxReferenceNum;
uint32_t bitstreamOffsetAlignment;
uint32_t bitstreamSizeAlignment;
uint64_t bitstreamSizeMax;
uint64_t bitstreamSizeMax; // maximum "bitstream.size" for decode and "dstBitstream.size" for encode
uint32_t metadataOffsetAlignment;
uint32_t resolvedMetadataOffsetAlignment;
uint32_t encodeFeedbackMaxPendingNum; // maximum per-session feedback ranges not yet consumed by "GetVideoEncodeFeedback"; reset by "ResetVideoSession"
Expand All @@ -300,7 +301,8 @@ NriStruct(VideoCapabilities) {
Nri(QueueType) resolvedMetadataQueueType; // queue used by the operation that writes resolved metadata
uint32_t dpbTextureArrayMinLayerNum; // minimum layer count when "dpbTextureArrayRequired" is true
bool decodeDpbAndOutputCoincide; // decode output and reconstructed/DPB setup may use the same texture subresource
bool decodeDpbAndOutputDistinct; // decode output and reconstructed/DPB setup may use different texture subresources
bool decodeDpbAndOutputDistinct; // decode output and reconstructed/DPB setup may use different texture subresources (textures with the session extent)
bool decodeReferenceOnlyRequired; // decode DPB pictures (setup and references) must use "VIDEO_REFERENCE_ONLY" textures, which only video decode can access
bool dpbTextureArrayRequired; // all decode or encode DPB pictures must use layers of one texture
bool decodeNativeArgumentsSupported;
bool encodeBitstreamRangeSizeSupported; // if false, encode output ranges must extend to the end of the buffer
Expand Down Expand Up @@ -368,7 +370,7 @@ NriStruct(VideoPictureState) {
NriStruct(VideoH264SequenceParameterSetDesc) {
Nri(VideoH264SequenceParameterSetBits) flags;
uint8_t profileIdc;
uint8_t levelIdc;
uint8_t levelIdc; // "level_idc" as coded in the bitstream: 10 times the level number (e.g. 41 = level 4.1), level 1b is not supported
uint8_t chromaFormatIdc;
uint8_t sequenceParameterSetId;
uint8_t bitDepthLumaMinus8;
Expand All @@ -381,6 +383,10 @@ NriStruct(VideoH264SequenceParameterSetDesc) {
uint8_t referenceFrameNum;
uint16_t pictureWidthInMbsMinus1;
uint16_t pictureHeightInMapUnitsMinus1;
uint16_t frameCropLeftOffset; // used with "FRAME_CROPPING", in "CropUnitX" units (2 luma samples for 4:2:0)
uint16_t frameCropRightOffset;
uint16_t frameCropTopOffset; // used with "FRAME_CROPPING", in "CropUnitY" units (2 luma samples for 4:2:0 progressive)
uint16_t frameCropBottomOffset;
};

NriStruct(VideoH264PictureParameterSetDesc) {
Expand Down Expand Up @@ -408,7 +414,7 @@ NriStruct(VideoH264SessionParametersDesc) {
NriStruct(VideoH265ProfileTierLevelDesc) {
Nri(VideoH265ProfileTierLevelBits) flags;
uint8_t generalProfileIdc;
uint8_t generalLevelIdc;
uint8_t generalLevelIdc; // "general_level_idc" as coded in the bitstream: 30 times the level number (e.g. 120 = level 4)
};

NriStruct(VideoH265DecPicBufMgrDesc) {
Expand Down Expand Up @@ -656,7 +662,7 @@ NriStruct(VideoEncodeRateControlDesc) {
uint8_t qpI;
uint8_t qpP;
uint8_t qpB;
NriOptional uint8_t qpMin;
NriOptional uint8_t qpMin; // CBR/VBR QP range (AV1: Q index), defaults to the codec range (VK: reported by the implementation, D3D12: 0..51, AV1 0..255), explicit bounds are clamped to it (VK)
NriOptional uint8_t qpMax;
uint32_t frameRateNumerator;
uint32_t frameRateDenominator;
Expand All @@ -682,6 +688,12 @@ NriStruct(VideoH264EncodePictureDesc) {
NriOptional uint32_t referenceNum;
};

NriStruct(VideoH265EncodePictureDesc) {
uint8_t videoParameterSetId;
uint8_t sequenceParameterSetId;
uint8_t pictureParameterSetId;
};

NriStruct(VideoAV1ReferenceDesc) {
Nri(VideoAV1ReferenceName) name; // NONE describes an AV1 DPB slot that is not mapped to a current-frame reference name
uint8_t refFrameIndex;
Expand All @@ -696,7 +708,7 @@ NriStruct(VideoAV1TileLayoutDesc) {
uint8_t columnNum;
uint8_t rowNum;
uint8_t tileSizeBytesMinus1;
uint8_t uniformSpacing;
uint8_t uniformSpacing; // if set, omitted arrays are derived from the frame size
uint16_t contextUpdateTileId;
NriOptional const uint16_t* miColumnStarts; // if provided, must include "columnNum + 1" entries
NriOptional const uint16_t* miRowStarts; // if provided, must include "rowNum + 1" entries
Expand Down Expand Up @@ -728,10 +740,10 @@ NriStruct(VideoAV1LoopFilterDesc) {
};

NriStruct(VideoAV1CdefDesc) {
uint8_t yPrimaryStrength[8];
uint8_t ySecondaryStrength[8];
uint8_t uvPrimaryStrength[8];
uint8_t uvSecondaryStrength[8];
uint8_t yPrimaryStrength[8]; // 0..15
uint8_t ySecondaryStrength[8]; // 0..3 as coded in "cdef_y_sec_strength" (3 stands for 4, the backends pass the coded value)
uint8_t uvPrimaryStrength[8]; // 0..15
uint8_t uvSecondaryStrength[8]; // 0..3 as coded in "cdef_uv_sec_strength"
};

NriStruct(VideoAV1SegmentationDesc) {
Expand Down Expand Up @@ -792,8 +804,8 @@ NriStruct(VideoAV1EncodePictureDesc) {
uint16_t renderWidthMinus1;
uint16_t renderHeightMinus1;
uint8_t codedDenom;
uint8_t interpolationFilter;
uint8_t txMode;
uint8_t interpolationFilter; // AV1 "interpolation_filter": 0..4 (4 = SWITCHABLE)
uint8_t txMode; // 0 selects the backend default, else AV1 "TxMode" 1..2 (LARGEST, SELECT); ONLY_4X4 is implied for lossless frames
uint8_t baseQIndex;
uint8_t cdefDampingMinus3;
uint8_t cdefBits;
Expand Down Expand Up @@ -832,8 +844,8 @@ NriStruct(VideoAV1DecodePictureDesc) {
uint8_t baseQIndex;
uint8_t superresDenom;
uint8_t codedDenom;
uint8_t interpolationFilter;
uint8_t txMode;
uint8_t interpolationFilter; // AV1 "interpolation_filter": 0..4 (4 = SWITCHABLE)
uint8_t txMode; // AV1 "TxMode": 0..2 (ONLY_4X4, LARGEST, SELECT)
uint8_t cdefDampingMinus3;
uint8_t cdefBits;
uint8_t deltaQRes;
Expand All @@ -846,7 +858,8 @@ NriStruct(VideoAV1DecodePictureDesc) {
NriOptional const NriPtr(VideoAV1LoopRestorationDesc) loopRestoration;
NriOptional const NriPtr(VideoAV1GlobalMotionDesc) globalMotion;
NriOptional const NriPtr(VideoAV1FilmGrainDesc) filmGrain; // used with "APPLY_GRAIN"; TODO: currently unsupported for decode
NriOptional const uint8_t* orderHints; // if provided, must include 8 entries
NriOptional const uint8_t* orderHints; // 8 entries indexed like AV1 "OrderHints[]" by reference frame name: 0 = INTRA_FRAME, 1..7 = LAST..ALTREF; named reference entries are overridden by "references[].orderHint"
Nri(VideoAV1ReferenceName) skipModeFrames[2]; // "SkipModeFrame[0..1]" used with "SKIP_MODE_PRESENT"
const NriPtr(VideoAV1DecodeTileDesc) tiles;
uint32_t tileNum;
NriOptional const NriPtr(VideoAV1ReferenceDesc) references;
Expand All @@ -861,7 +874,8 @@ NriStruct(VideoDecodeDesc) {
NriOptional NriPtr(VideoPicture) setupPicture; // reconstructed/DPB setup picture; required for distinct mode, may alias "dstPicture" in coincide mode
NriOptional const NriPtr(VideoReference) references;
NriOptional uint32_t referenceNum;
uint32_t dstSlot; // default reconstructed picture slot; neutral H.264 may override it with "referenceSlot"; native DXVA "CurrPic" must use "dstSlot" and reference "PicEntry" indices must match "VideoReference::slot"
uint32_t dstSlot; // default setup slot, always written; neutral H.264 may override it with "referenceSlot"; native DXVA "CurrPic" must use "dstSlot" and reference "PicEntry" indices must match "VideoReference::slot"
// for non-reference pictures, use a slot whose picture is no longer needed, never one referenced by this or a later decode
NriOptional const NriPtr(VideoDecodeArgument) arguments; // native DXVA frame arguments; if omitted, the neutral codec picture description is used
NriOptional uint32_t argumentNum;
NriOptional const NriPtr(VideoH264DecodePictureDesc) h264PictureDesc; // neutral H.264 picture description; required if "argumentNum" is 0
Expand All @@ -887,8 +901,10 @@ NriStruct(VideoAV1EncodeDecodeInfoDesc) {
const NriPtr(VideoAV1SequenceDesc) sequence;
NriOptional const uint8_t* encodedPayloadHeader; // first bytes of the encoded payload; returned bitstream ranges are bounded by "feedback"
uint64_t encodedPayloadHeaderSize;
NriOptional const NriPtr(VideoAV1ReferenceDesc) references; // previous AV1 DPB snapshot; required for inter frames
NriOptional const NriPtr(VideoAV1ReferenceDesc) references; // previous AV1 DPB snapshot; required for inter frames, without it the frame is a key frame (as encoded with "FORCE_KEY_FRAME")
NriOptional uint32_t referenceNum;
NriOptional const NriPtr(VideoEncodePictureDesc) pictureDesc; // submitted picture description; required if "encodedPayloadHeader" is not provided
NriOptional const NriPtr(VideoAV1EncodePictureDesc) av1PictureDesc; // submitted AV1 picture description; required if "encodedPayloadHeader" is not provided
};

NriStruct(VideoAV1EncodeDecodeInfo) {
Expand Down Expand Up @@ -920,7 +936,7 @@ NriStruct(VideoEncodeDesc) {
NriOptional const NriPtr(VideoEncodePictureDesc) pictureDesc;
NriOptional const NriPtr(VideoEncodeRateControlDesc) rateControlDesc;
Nri(VideoEncodeBits) flags;
NriOptional NriPtr(VideoPicture) reconstructedPicture;
NriOptional NriPtr(VideoPicture) reconstructedPicture; // reconstructed/DPB setup picture; required for sessions with DPB slots, also for non-reference pictures (B frames, AV1 "refreshFrameFlags = 0"): the slot is written, but not referenced afterwards
NriOptional NriPtr(Buffer) metadata; // backend encode metadata; required if "VideoCapabilities::metadataSize" is non-zero
uint64_t metadataOffset;
NriOptional NriPtr(Buffer) resolvedMetadata; // backend metadata consumed by "GetVideoEncodeFeedback" after the required resolve operation; a pending range must not be reused
Expand All @@ -929,6 +945,7 @@ NriStruct(VideoEncodeDesc) {
NriOptional uint32_t referenceNum;
uint32_t reconstructedSlot;
NriOptional const NriPtr(VideoH264EncodePictureDesc) h264PictureDesc;
NriOptional const NriPtr(VideoH265EncodePictureDesc) h265PictureDesc; // parameter set selection; all ids default to 0
NriOptional const NriPtr(VideoAV1EncodePictureDesc) av1PictureDesc;
NriOptional const NriPtr(VideoH265ReferenceDesc) h265ReferenceDescs;
};
Expand Down Expand Up @@ -964,7 +981,7 @@ NriStruct(VideoInterface) {
// Command buffer
// {
// Video decode/encode command buffers must be created from "QueueType::VIDEO_DECODE" or "QueueType::VIDEO_ENCODE" queues.
// VK: video session initialization is implicit on first recorded use, so commands for the same session must be recorded in submit order
// VK: video session initialization and rate control changes are applied on recorded use, so commands for the same session must be recorded in submit order
void (NRI_CALL *CmdDecodeVideo) (NriRef(CommandBuffer) commandBuffer, const NriRef(VideoDecodeDesc) videoDecodeDesc);
void (NRI_CALL *CmdEncodeVideo) (NriRef(CommandBuffer) commandBuffer, const NriRef(VideoEncodeDesc) videoEncodeDesc);

Expand Down
3 changes: 2 additions & 1 deletion Include/NRIDescs.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ NriBits(TextureUsageBits, uint16_t, // Min compatible access:
HOST_TRANSFER = NriBit(6), // HOST_READ/HOST_WRITE Synchronous copy between texture and host memory
VIDEO_DECODE = NriBit(7), // VIDEO_DECODE Video decode output / DPB picture
VIDEO_ENCODE = NriBit(8), // VIDEO_ENCODE Video encode input / DPB picture
VIDEO_REFERENCE_ONLY = NriBit(9) // VIDEO_* Video DPB/reference-only allocation
VIDEO_REFERENCE_ONLY = NriBit(9), // VIDEO_* Video DPB/reference-only allocation
VIDEO_OUTPUT_ONLY = NriBit(10) // VIDEO_* Video decode output / encode input never used as a DPB picture (required if "decodeDpbAndOutputCoincide" is false; encode: pair with "VIDEO_REFERENCE_ONLY" DPB textures, VK may not support the combined usage)
);

// https://docs.vulkan.org/refpages/latest/refpages/source/VkBufferUsageFlagBits.html
Expand Down
4 changes: 4 additions & 0 deletions Source/D3D12/BufferD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ struct BufferD3D12 final : public DebugNameBase {
return m_Device;
}

inline bool IsMapped() const {
return m_MappedMemory != nullptr;
}

Result Create(const BufferDesc& bufferDesc);
Result Create(const BufferD3D12Desc& bufferD3D12Desc);
Result Allocate(MemoryLocation memoryLocation, float priority, bool committed);
Expand Down
Loading