MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / d3d12va_get_valid_command_allocator

Function d3d12va_get_valid_command_allocator

libavcodec/d3d12va_encode.c:94–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92} CommandAllocator;
93
94static int d3d12va_get_valid_command_allocator(AVCodecContext *avctx, ID3D12CommandAllocator **ppAllocator)
95{
96 HRESULT hr;
97 D3D12VAEncodeContext *ctx = avctx->priv_data;
98 CommandAllocator allocator;
99
100 if (av_fifo_peek(ctx->allocator_queue, &allocator, 1, 0) >= 0) {
101 uint64_t completion = ID3D12Fence_GetCompletedValue(ctx->sync_ctx.fence);
102 if (completion >= allocator.fence_value) {
103 *ppAllocator = allocator.command_allocator;
104 av_fifo_read(ctx->allocator_queue, &allocator, 1);
105 return 0;
106 }
107 }
108
109 hr = ID3D12Device_CreateCommandAllocator(ctx->hwctx->device, D3D12_COMMAND_LIST_TYPE_VIDEO_ENCODE,
110 &IID_ID3D12CommandAllocator, (void **)ppAllocator);
111 if (FAILED(hr)) {
112 av_log(avctx, AV_LOG_ERROR, "Failed to create a new command allocator!\n");
113 return AVERROR(EINVAL);
114 }
115
116 return 0;
117}
118
119static int d3d12va_discard_command_allocator(AVCodecContext *avctx, ID3D12CommandAllocator *pAllocator, uint64_t fence_value)
120{

Callers 2

d3d12va_encode_issueFunction · 0.85

Calls 3

av_fifo_peekFunction · 0.85
av_fifo_readFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected