| 92 | } CommandAllocator; |
| 93 | |
| 94 | static 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 | |
| 119 | static int d3d12va_discard_command_allocator(AVCodecContext *avctx, ID3D12CommandAllocator *pAllocator, uint64_t fence_value) |
| 120 | { |
no test coverage detected