question

tqk2811 avatar image
0 Votes"
tqk2811 asked tqk2811 edited

DirectX11 crash on Nvidia VGA

My laptop have two card: intel hd graphics 4600 and nvidia geforce gtx 950M
My code just convert nv12 to rgba, and it work well on intel hd graphics.
But when i change to nvidia card on graphic setting.

 D3D11_MAPPED_SUBRESOURCE ms;
 hr = this->_d3d11_deviceCtx->Map(this->_texture_rgba_copy.Get(), 0, D3D11_MAP_READ, 0, &ms);
 if (FAILED(hr))
     return false;

it crash at Map to subresource

 Exception thrown at 0x00007FF8B1E4AAFB (nvwgf2umx.dll) in TestConsole.exe: 0xC0000005: Access violation reading location 0x0000000000000068.

Can someone look for something wrong in my code? Thank.
https://gist.github.com/tqk2811/9dc56339499fb0355e1e114a49596214 (sorry, i'm new on directx and code just copy and edit. )

My system infomations:
-Window 10 21H2
-Nvidia driver version 512.77 (lasted)
-dxdiag Nvidia feature level: 11_0, 10_1, ....
-dxdiag DirectX 12

Shader compile with Shader model Shader Model 4 Level 9_3 (/4_0_level_9_3)


c++
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

tqk2811 avatar image
0 Votes"
tqk2811 answered tqk2811 edited

After turn on debug i found bropblem.
It because ID3D11DeviceContext::CopySubresourceRegion copy between two devices.
Then i remove create device and using ffmpeg device.


AVCodecContext* _codec_ctx = avcodec_alloc_context3(_codec);
av_hwdevice_ctx_create(
    &_codec_ctx->hw_device_ctx,
    AV_HWDEVICE_TYPE_D3D11VA,
    nullptr,
    nullptr,
    0);
AVHWDeviceContext* hw_device_ctx = reinterpret_cast<AVHWDeviceContext*>(_codec_ctx->hw_device_ctx->data);
AVD3D11VADeviceContext* d3d11va_device_ctx = reinterpret_cast<AVD3D11VADeviceContext*>(hw_device_ctx->hwctx);
_d3d11_device = d3d11va_device_ctx->device;
_d3d11_deviceCtx = d3d11va_device_ctx->device_context;
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.