Question / Help Question about directx capture - DXGI_FORMAT

poster91753

New Member
Hello,

I have a question about a specific behaviour of OBS studio, in particular directx capture functionality :

What affects the DXGI_FORMAT of the 'd3d11_data' received from the backbuffer, for example in method 'd3d11_copy_texture' in class 'd3d11-capture.cpp'. I tried to follow the 'format' variable but I got lost. What factor or factors would determine the choice of DXGI_FORMAT?

More specifically, with OBS version 19.0.3(built from source), when I capture 'Mass Effect Andromeda' I receive d3d11_data with DXGI_FORMAT = DXGI_FORMAT_R10G10B10A2_UNORM. I am pretty sure that, with an older version(16.x.x I think), I received DXGI_FORMAT_B8G8R8A8_UNORM (or some other 8-bit format), because at that time I could process the captured textures with a library function expecting an 8-bit format. Since this particular library(OpenCV) does not accept 10-bit formats (and I do not know how to do the conversion), I would appreciate suggestions about how I could tell OBS (or whichever entity determines the format) to give me data in DXGI_FORMAT_B8G8R8A8_UNORM.

For clarification, this is what I do inside 'd3d11_shtex_capture' in class d3d11-capture.cpp :
Code:
    d3d11_copy_texture(data.texture, backbuffer);
...
     hlog(toStr(data.format));  // prints 24 = DXGI_FORMAT_R10G10B10A2_UNORM
...
         ID3D11Texture2D* tex;
         bool success = create_d3d11_stage_surface(&tex);
         if (success) {
...
           HRESULT hr = data.context->Map(tex, subresource, D3D11_MAP_READ, 0, &mappedTex);
...
           Mat frame(data.cy, data.cx, CV_8UC4, mappedTex.pData, (int)mappedTex.RowPitch); //This creates an OpenCV Mat object.
                                                   //No support for 10-bits. Expects 8-bits (CV_8UC4 argument).
                                                   //When the resulting Mat is viewed, colours are jumbled (Probably because 10-bits did not fit into 8-bits).

I tried manually overriding 'data.format' without understanding what is going on, but it did not work...
 
Top