DirectX11 crash on Nvidia VGA

tqk2811 1 Reputation point
2022-05-12T16:39:01.817+00:00

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++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,781 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. tqk2811 1 Reputation point
    2022-05-16T19:58:24.993+00:00

    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;
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.