Unified · Split
| @@ -28,6 +28,9 @@ · 27 unmodified lines | ||
| 28 | 28 | #if CONFIG_D3D11VA |
| 29 | 29 | #include "libavutil/hwcontext_d3d11va.h" |
| 30 | 30 | #endif |
| 31 | +#if CONFIG_D3D12VA | |
| 32 | +#include "libavutil/hwcontext_d3d12va.h" | |
| 33 | +#endif | |
| 31 | 34 | #if CONFIG_DXVA2 |
| 32 | 35 | #define COBJMACROS |
| 33 | 36 | #include "libavutil/hwcontext_dxva2.h" |
| @@ -146,6 +149,9 @@ static const enum AVPixelFormat supported_formats[] = { · 112 unmodified lines | ||
| 146 | 149 | #if CONFIG_D3D11VA |
| 147 | 150 | AV_PIX_FMT_D3D11, |
| 148 | 151 | #endif |
| 152 | +#if CONFIG_D3D12VA | |
| 153 | + AV_PIX_FMT_D3D12, | |
| 154 | +#endif | |
| 149 | 155 | #if CONFIG_DXVA2 |
| 150 | 156 | AV_PIX_FMT_DXVA2_VLD, |
| 151 | 157 | #endif |
| @@ -555,10 +561,33 @@ static int amf_init_from_d3d11_device(AVAMFDeviceContext* amf_ctx, AVD3D11VADevi · 403 unmodified lines | ||
| 555 | 561 | av_log(hwctx, AV_LOG_ERROR, "AMF failed to initialise on the given D3D11 device: %d.\n", res); |
| 556 | 562 | return AVERROR(ENODEV); |
| 557 | 563 | } |
| 564 | + av_log(hwctx, AV_LOG_ERROR, "AMF via D3D11"); | |
| 558 | 565 | return 0; |
| 559 | 566 | } |
| 560 | 567 | #endif |
| 561 | 568 | |
| 569 | +#if CONFIG_D3D12VA | |
| 570 | +static int amf_init_from_d3d12_device(AVAMFDeviceContext* amf_ctx, AVD3D12VADeviceContext *hwctx) | |
| 571 | +{ | |
| 572 | + AMF_RESULT res; | |
| 573 | + AMFContext2 *context2 = NULL; | |
| 574 | + AMFGuid guid = IID_AMFContext2(); | |
| 575 | + res = amf_ctx->context->pVtbl->QueryInterface(amf_ctx->context, &guid, (void**)&context2); | |
| 576 | + AMF_RETURN_IF_FALSE(hwctx, res == AMF_OK, AVERROR_UNKNOWN, "CreateContext2() failed with error %d\n", res); | |
| 577 | + res = context2->pVtbl->InitDX12(context2, hwctx->device, AMF_DX12); | |
| 578 | + context2->pVtbl->Release(context2); | |
| 579 | + if (res != AMF_OK && res != AMF_ALREADY_INITIALIZED) { | |
| 580 | + if (res == AMF_NOT_SUPPORTED) | |
| 581 | + av_log(hwctx, AV_LOG_ERROR, "AMF via D3D12 is not supported on the given device.\n"); | |
| 582 | + else | |
| 583 | + av_log(hwctx, AV_LOG_ERROR, "AMF failed to initialise on the given D3D12 device: %d.\n", res); | |
| 584 | + return AVERROR(ENODEV); | |
| 585 | + } | |
| 586 | + return 0; | |
| 587 | +} | |
| 588 | +#endif | |
| 589 | + | |
| 590 | + | |
| 562 | 591 | static int amf_device_derive(AVHWDeviceContext *device_ctx, |
| 563 | 592 | AVHWDeviceContext *child_device_ctx, AVDictionary *opts, |
| 564 | 593 | int flags) |
| @@ -588,6 +617,13 @@ static int amf_device_derive(AVHWDeviceContext *device_ctx, · 23 unmodified lines | ||
| 588 | 617 | return amf_init_from_d3d11_device(amf_ctx, child_device_hwctx); |
| 589 | 618 | } |
| 590 | 619 | break; |
| 620 | +#endif | |
| 621 | +#if CONFIG_D3D12VA | |
| 622 | + case AV_HWDEVICE_TYPE_D3D12VA: { | |
| 623 | + AVD3D12VADeviceContext *child_device_hwctx = child_device_ctx->hwctx; | |
| 624 | + return amf_init_from_d3d12_device(amf_ctx, child_device_hwctx); | |
| 625 | + } | |
| 626 | + break; | |
| 591 | 627 | #endif |
| 592 | 628 | default: { |
| 593 | 629 | av_log(child_device_ctx, AV_LOG_ERROR, "AMF initialisation from a %s device is not supported.\n", |