author Sam Lantinga
Sun, 05 Apr 2020 08:58:47 -0700
changeset 13689 c3055b205671
parent 11381 2610f8f0a9c6
permissions -rw-r--r--
Fixed bug 5015 - SDL_RenderReadPixels on DirectX 11.1 backend seems to be broken


It appears that I cannot use SDL_RenderReadPixels on a bound framebuffer (SDL_Texture set as render target) as it simply results in gibberish data. However, drawing that framebuffer into the default target (window surface) does render it correctly. Other backends (OpenGL, software, Direct3D) do work fine.

It looks to me like D3D11_RenderReadPixels just gets the general backbuffer and not the current render target and its backbuffer.

Here is the patch which actually fetches the current render target and its underlying ID3D11Resource which is ID3D11Texture2D.
     1 Windows
     2 ================================================================================
     4 ================================================================================
     5 OpenGL ES 2.x support
     6 ================================================================================
     8 SDL has support for OpenGL ES 2.x under Windows via two alternative 
     9 implementations. 
    10 The most straightforward method consists in running your app in a system with 
    11 a graphic card paired with a relatively recent (as of November of 2013) driver 
    12 which supports the WGL_EXT_create_context_es2_profile extension. Vendors known 
    13 to ship said extension on Windows currently include nVidia and Intel.
    15 The other method involves using the ANGLE library (
    16 If an OpenGL ES 2.x context is requested and no WGL_EXT_create_context_es2_profile
    17 extension is found, SDL will try to load the libEGL.dll library provided by
    18 ANGLE.
    19 To obtain the ANGLE binaries, you can either compile from source from
    20 or copy the relevant binaries from
    21 a recent Chrome/Chromium install for Windows. The files you need are:
    23     * libEGL.dll
    24     * libGLESv2.dll
    25     * d3dcompiler_46.dll (supports Windows Vista or later, better shader compiler)
    26     or...
    27     * d3dcompiler_43.dll (supports Windows XP or later)
    29 If you compile ANGLE from source, you can configure it so it does not need the
    30 d3dcompiler_* DLL at all (for details on this, see their documentation). 
    31 However, by default SDL will try to preload the d3dcompiler_46.dll to
    32 comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to
    33 support Windows XP) or to skip this step at all, you can use the 
    34 SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details).
    36 Known Bugs:
    38     * SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
    39       that there's a bug in the library which prevents the window contents from
    40       refreshing if this is set to anything other than the default value.
    42 Vulkan Surface Support
    43 ==============
    45 Support for creating Vulkan surfaces is configured on by default. To disable it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You must install the [Vulkan SDK]( in order to use Vulkan graphics in your application.