src/render/direct3d11/SDL_render_d3d11.c
author David Ludwig <dludwig@pobox.com>
Tue, 14 Oct 2014 09:53:46 -0400
changeset 9158 8fa5ff95c410
parent 8969 7fb90df60b99
child 9335 3eb0896ecb91
permissions -rw-r--r--
WinRT: fixed bug whereby offscreen-rendered content could get improperly rotated Attributes on the host device's rotation were getting applied to offscreen textures in an invalid manner. This was causing some apps to look different, depending on how the device was rotated.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     1
/*
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     2
  Simple DirectMedia Layer
8615
097646deaef2 Fixed the copyright date on files contributed by David Ludwig
Sam Lantinga <slouken@libsdl.org>
parents: 8612
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     4
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     7
  arising from the use of this software.
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     8
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    12
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    16
     appreciated but is not required.
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    18
     misrepresented as being the original software.
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    20
*/
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    21
#include "../../SDL_internal.h"
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    22
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    23
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    24
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    25
#define COBJMACROS
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    26
#include "../../core/windows/SDL_windows.h"
8533
89cf2a2635d1 WinRT: made the Direct3D 11.x 'Debug Layer' be enable-able in any app via a hint
David Ludwig <dludwig@pobox.com>
parents: 8526
diff changeset
    27
#include "SDL_hints.h"
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    28
#include "SDL_loadso.h"
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    29
#include "SDL_syswm.h"
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    30
#include "../SDL_sysrender.h"
8599
532cd234e923 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga <slouken@libsdl.org>
parents: 8598
diff changeset
    31
#include "../SDL_d3dmath.h"
8755
f2fc45874b9c Fixed rendering-alignment issues on WinPhone 8.1, when the device was rotated
David Ludwig <dludwig@pobox.com>
parents: 8748
diff changeset
    32
/* #include "SDL_log.h" */
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    33
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    34
#include <d3d11_1.h>
8559
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    35
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    36
8608
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    37
#ifdef __WINRT__
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    38
8679
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8674
diff changeset
    39
#if NTDDI_VERSION > NTDDI_WIN8
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8674
diff changeset
    40
#include <DXGI1_3.h>
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8674
diff changeset
    41
#endif
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8674
diff changeset
    42
8609
d59f0f12bf07 Fixed compiling Windows RT code on Visual Studio 2013
Sam Lantinga <slouken@libsdl.org>
parents: 8608
diff changeset
    43
#include "SDL_render_winrt.h"
8608
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    44
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    45
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    46
#include <windows.ui.xaml.media.dxinterop.h>
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    47
/* TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var */
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    48
extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative;
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    49
#endif  /* WINAPI_FAMILY == WINAPI_FAMILY_APP */
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    50
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    51
#endif  /* __WINRT__ */
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    52
c5d603f7094e Fixed compiler errors in the D3D11 renderer when building for WinRT
David Ludwig <dludwig@pobox.com>
parents: 8607
diff changeset
    53
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
    54
#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; }
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    55
8540
724af2cd53b8 WinRT: added support for SDL_HINT_RENDER_SCALE_QUALITY
David Ludwig <dludwig@pobox.com>
parents: 8533
diff changeset
    56
8559
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    57
/* Vertex shader, common values */
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    58
typedef struct
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
    59
{
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    60
    Float4X4 model;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    61
    Float4X4 projectionAndView;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    62
} VertexShaderConstants;
8559
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    63
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    64
/* Per-vertex data */
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    65
typedef struct
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
    66
{
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    67
    Float3 pos;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    68
    Float2 tex;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    69
    Float4 color;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    70
} VertexPositionColor;
8559
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    71
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    72
/* Per-texture data */
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    73
typedef struct
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    74
{
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    75
    ID3D11Texture2D *mainTexture;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    76
    ID3D11ShaderResourceView *mainTextureResourceView;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    77
    ID3D11RenderTargetView *mainTextureRenderTargetView;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    78
    ID3D11Texture2D *stagingTexture;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    79
    int lockedTexturePositionX;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    80
    int lockedTexturePositionY;
8559
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    81
    D3D11_FILTER scaleMode;
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    82
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    83
    /* YV12 texture support */
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    84
    SDL_bool yuv;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    85
    ID3D11Texture2D *mainTextureU;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    86
    ID3D11ShaderResourceView *mainTextureResourceViewU;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    87
    ID3D11Texture2D *mainTextureV;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    88
    ID3D11ShaderResourceView *mainTextureResourceViewV;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    89
    Uint8 *pixels;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    90
    int pitch;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
    91
    SDL_Rect locked_rect;
8559
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    92
} D3D11_TextureData;
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    93
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    94
/* Private renderer data */
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    95
typedef struct
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
    96
{
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
    97
    void *hDXGIMod;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
    98
    void *hD3D11Mod;
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
    99
    IDXGIFactory2 *dxgiFactory;
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   100
    IDXGIAdapter *dxgiAdapter;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   101
    ID3D11Device1 *d3dDevice;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   102
    ID3D11DeviceContext1 *d3dContext;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   103
    IDXGISwapChain1 *swapChain;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   104
    DXGI_SWAP_EFFECT swapEffect;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   105
    ID3D11RenderTargetView *mainRenderTargetView;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   106
    ID3D11RenderTargetView *currentOffscreenRenderTargetView;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   107
    ID3D11InputLayout *inputLayout;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   108
    ID3D11Buffer *vertexBuffer;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   109
    ID3D11VertexShader *vertexShader;
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   110
    ID3D11PixelShader *colorPixelShader;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   111
    ID3D11PixelShader *texturePixelShader;
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   112
    ID3D11PixelShader *yuvPixelShader;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   113
    ID3D11BlendState *blendModeBlend;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   114
    ID3D11BlendState *blendModeAdd;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   115
    ID3D11BlendState *blendModeMod;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   116
    ID3D11SamplerState *nearestPixelSampler;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   117
    ID3D11SamplerState *linearSampler;
8569
0c593385f446 WinRT: implemented SDL_RenderSetClipRect for the d3d11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8568
diff changeset
   118
    D3D_FEATURE_LEVEL featureLevel;
0c593385f446 WinRT: implemented SDL_RenderSetClipRect for the d3d11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8568
diff changeset
   119
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   120
    /* Rasterizers */
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   121
    ID3D11RasterizerState *mainRasterizer;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   122
    ID3D11RasterizerState *clippedRasterizer;
8559
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
   123
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   124
    /* Vertex buffer constants */
8560
5e14c111f2f9 WinRT: renamed d3d11-internal struct, SDL_VertexShaderConstants, to just VertexShaderConstants
David Ludwig <dludwig@pobox.com>
parents: 8559
diff changeset
   125
    VertexShaderConstants vertexShaderConstantsData;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   126
    ID3D11Buffer *vertexShaderConstants;
8559
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
   127
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   128
    /* Cached renderer properties */
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   129
    DXGI_MODE_ROTATION rotation;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   130
    ID3D11RenderTargetView *currentRenderTargetView;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   131
    ID3D11RasterizerState *currentRasterizerState;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   132
    ID3D11BlendState *currentBlendState;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   133
    ID3D11PixelShader *currentShader;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   134
    ID3D11ShaderResourceView *currentShaderResource;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   135
    ID3D11SamplerState *currentSampler;
8559
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
   136
} D3D11_RenderData;
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
   137
9429f36bca22 WinRT: moved contents of the d3d11 renderer's header file into its implementation file
David Ludwig <dludwig@pobox.com>
parents: 8558
diff changeset
   138
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   139
/* Defined here so we don't have to include uuid.lib */
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   140
static const GUID IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } };
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   141
static const GUID IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
8679
dd52820b7f5c WinRT: Call IDXGIDevice3::Trim before app-suspend, as required on Windows 8.1
David Ludwig <dludwig@pobox.com>
parents: 8674
diff changeset
   142
static const GUID IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } };
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   143
static const GUID IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } };
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   144
static const GUID IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } };
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   145
static const GUID IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } };
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   146
static const GUID IID_ID3D11Debug = { 0x79cf2233, 0x7536, 0x4948, { 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60 } };
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   147
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   148
/* Direct3D 11.x shaders
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   149
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   150
   SDL's shaders are compiled into SDL itself, to simplify distribution.
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   151
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   152
   All Direct3D 11.x shaders were compiled with the following:
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   153
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   154
   fxc /E"main" /T "<TYPE>" /Fo"<OUTPUT FILE>" "<INPUT FILE>"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   155
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   156
     Variables:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   157
     - <TYPE>: the type of shader.  A table of utilized shader types is
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   158
       listed below.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   159
     - <OUTPUT FILE>: where to store compiled output
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   160
     - <INPUT FILE>: where to read shader source code from
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   161
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   162
     Shader types:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   163
     - ps_4_0_level_9_1: Pixel shader for Windows 8+, including Windows RT
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   164
     - vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   165
     - ps_4_0_level_9_3: Pixel shader for Windows Phone 8
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   166
     - vs_4_0_level_9_3: Vertex shader for Windows Phone 8
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   167
   
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   168
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   169
   Shader object code was converted to a list of DWORDs via the following
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   170
   *nix style command (available separately from Windows + MSVC):
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   171
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   172
     hexdump -v -e '6/4 "0x%08.8x, " "\n"' <FILE>
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   173
  */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   174
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   175
#define D3D11_USE_SHADER_MODEL_4_0_level_9_3
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   176
#else
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   177
#define D3D11_USE_SHADER_MODEL_4_0_level_9_1
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   178
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   179
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   180
/* The color-only-rendering pixel shader:
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   181
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   182
   --- D3D11_PixelShader_Colors.hlsl ---
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   183
   struct PixelShaderInput
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   184
   {
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   185
       float4 pos : SV_POSITION;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   186
       float2 tex : TEXCOORD0;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   187
       float4 color : COLOR0;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   188
   };
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   189
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   190
   float4 main(PixelShaderInput input) : SV_TARGET
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   191
   {
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   192
       return input.color;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   193
   }
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   194
*/
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   195
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   196
static const DWORD D3D11_PixelShader_Colors[] = {
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   197
    0x43425844, 0xd74c28fe, 0xa1eb8804, 0x269d512a, 0x7699723d, 0x00000001,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   198
    0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   199
    0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   200
    0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   201
    0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   202
    0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   203
    0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   204
    0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   205
    0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   206
    0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   207
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   208
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   209
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   210
    0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   211
    0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   212
    0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   213
    0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   214
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   215
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   216
    0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   217
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   218
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   219
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   220
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   221
};
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   222
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   223
static const DWORD D3D11_PixelShader_Colors[] = {
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   224
    0x43425844, 0x93f6ccfc, 0x5f919270, 0x7a11aa4f, 0x9148e931, 0x00000001,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   225
    0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   226
    0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   227
    0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   228
    0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   229
    0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   230
    0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   231
    0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   232
    0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   233
    0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   234
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   235
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   236
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   237
    0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   238
    0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   239
    0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   240
    0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   241
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   242
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   243
    0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   244
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   245
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   246
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   247
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   248
};
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   249
#else
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   250
#error "An appropriate 'colors' pixel shader is not defined."
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   251
#endif
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   252
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   253
/* The texture-rendering pixel shader:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   254
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   255
    --- D3D11_PixelShader_Textures.hlsl ---
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   256
    Texture2D theTexture : register(t0);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   257
    SamplerState theSampler : register(s0);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   258
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   259
    struct PixelShaderInput
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   260
    {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   261
        float4 pos : SV_POSITION;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   262
        float2 tex : TEXCOORD0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   263
        float4 color : COLOR0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   264
    };
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   265
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   266
    float4 main(PixelShaderInput input) : SV_TARGET
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   267
    {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   268
        return theTexture.Sample(theSampler, input.tex) * input.color;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   269
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   270
*/
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   271
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   272
static const DWORD D3D11_PixelShader_Textures[] = {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   273
    0x43425844, 0x6299b59f, 0x155258f2, 0x873ab86a, 0xfcbb6dcd, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   274
    0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   275
    0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   276
    0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   277
    0x00280000, 0x00000000, 0xffff0200, 0x0200001f, 0x80000000, 0xb0030000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   278
    0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   279
    0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   280
    0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   281
    0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   282
    0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   283
    0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   284
    0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   285
    0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   286
    0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   287
    0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   288
    0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   289
    0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   290
    0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   291
    0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   292
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   293
    0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   294
    0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   295
    0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   296
    0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   297
    0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   298
    0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   299
    0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   300
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   301
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   302
    0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   303
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   304
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   305
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   306
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   307
};
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   308
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   309
static const DWORD D3D11_PixelShader_Textures[] = {
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   310
    0x43425844, 0x5876569a, 0x01b6c87e, 0x8447454f, 0xc7f3ef10, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   311
    0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   312
    0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   313
    0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   314
    0x00280000, 0x00000000, 0xffff0201, 0x0200001f, 0x80000000, 0xb0030000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   315
    0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   316
    0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   317
    0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   318
    0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   319
    0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   320
    0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   321
    0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   322
    0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   323
    0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   324
    0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   325
    0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   326
    0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   327
    0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   328
    0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   329
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   330
    0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   331
    0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   332
    0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   333
    0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   334
    0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   335
    0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   336
    0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   337
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   338
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   339
    0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   340
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   341
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   342
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   343
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   344
};
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   345
#else
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   346
#error "An appropriate 'textures' pixel shader is not defined"
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   347
#endif
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   348
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   349
/* The yuv-rendering pixel shader:
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   350
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   351
    --- D3D11_PixelShader_YUV.hlsl ---
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   352
    Texture2D theTextureY : register(t0);
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   353
    Texture2D theTextureU : register(t1);
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   354
    Texture2D theTextureV : register(t2);
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   355
    SamplerState theSampler : register(s0);
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   356
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   357
    struct PixelShaderInput
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   358
    {
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   359
        float4 pos : SV_POSITION;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   360
        float2 tex : TEXCOORD0;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   361
        float4 color : COLOR0;
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   362
    };
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   363
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   364
    float4 main(PixelShaderInput input) : SV_TARGET
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   365
    {
8969
7fb90df60b99 The YUV offset is 16 / 255, not 16 / 256
Alfred Reynolds <alfred@valvesoftware.com>
parents: 8755
diff changeset
   366
        const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   367
        const float3 Rcoeff = {1.164,  0.000,  1.596};
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   368
        const float3 Gcoeff = {1.164, -0.391, -0.813};
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   369
        const float3 Bcoeff = {1.164,  2.018,  0.000};
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   370
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   371
        float4 Output;
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   372
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   373
        float3 yuv;
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   374
        yuv.x = theTextureY.Sample(theSampler, input.tex).r;
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   375
        yuv.y = theTextureU.Sample(theSampler, input.tex).r;
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   376
        yuv.z = theTextureV.Sample(theSampler, input.tex).r;
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   377
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   378
        yuv += offset;
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   379
        Output.r = dot(yuv, Rcoeff);
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   380
        Output.g = dot(yuv, Gcoeff);
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   381
        Output.b = dot(yuv, Bcoeff);
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   382
        Output.a = 1.0f;
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   383
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   384
        return Output * input.color;
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   385
    }
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   386
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   387
*/
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   388
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   389
static const DWORD D3D11_PixelShader_YUV[] = {
8969
7fb90df60b99 The YUV offset is 16 / 255, not 16 / 256
Alfred Reynolds <alfred@valvesoftware.com>
parents: 8755
diff changeset
   390
    0x43425844, 0x2321c6c6, 0xf14df2d1, 0xc79d068d, 0x8e672abf, 0x00000001,
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   391
    0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   392
    0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   393
    0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   394
    0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
8969
7fb90df60b99 The YUV offset is 16 / 255, not 16 / 256
Alfred Reynolds <alfred@valvesoftware.com>
parents: 8755
diff changeset
   395
    0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051,
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   396
    0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   397
    0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x05000051,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   398
    0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x0200001f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   399
    0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   400
    0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   401
    0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   402
    0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   403
    0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   404
    0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   405
    0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   406
    0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   407
    0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   408
    0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   409
    0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   410
    0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   411
    0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   412
    0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   413
    0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   414
    0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   415
    0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   416
    0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   417
    0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   418
    0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   419
    0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   420
    0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   421
    0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
8969
7fb90df60b99 The YUV offset is 16 / 255, not 16 / 256
Alfred Reynolds <alfred@valvesoftware.com>
parents: 8755
diff changeset
   422
    0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012,
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   423
    0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f94fdf4, 0x3fcc49ba,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   424
    0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   425
    0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   426
    0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   427
    0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x05000036, 0x00100082,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   428
    0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   429
    0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   430
    0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   431
    0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   432
    0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   433
    0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   434
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   435
    0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   436
    0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   437
    0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   438
    0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   439
    0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   440
    0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   441
    0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   442
    0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   443
    0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   444
    0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   445
    0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   446
    0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   447
    0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   448
    0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   449
    0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   450
    0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   451
    0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   452
    0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   453
};
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   454
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   455
static const DWORD D3D11_PixelShader_YUV[] = {
8969
7fb90df60b99 The YUV offset is 16 / 255, not 16 / 256
Alfred Reynolds <alfred@valvesoftware.com>
parents: 8755
diff changeset
   456
    0x43425844, 0x6ede7360, 0x45ff5f8a, 0x34ac92ba, 0xb865f5e0, 0x00000001,
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   457
    0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   458
    0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   459
    0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   460
    0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
8969
7fb90df60b99 The YUV offset is 16 / 255, not 16 / 256
Alfred Reynolds <alfred@valvesoftware.com>
parents: 8755
diff changeset
   461
    0xa00f0000, 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051,
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   462
    0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x400126e9, 0x05000051,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   463
    0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x0200001f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   464
    0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   465
    0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   466
    0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   467
    0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   468
    0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   469
    0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   470
    0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   471
    0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   472
    0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   473
    0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   474
    0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   475
    0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   476
    0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   477
    0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   478
    0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   479
    0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   480
    0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   481
    0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   482
    0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   483
    0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   484
    0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   485
    0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
8969
7fb90df60b99 The YUV offset is 16 / 255, not 16 / 256
Alfred Reynolds <alfred@valvesoftware.com>
parents: 8755
diff changeset
   486
    0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000,
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   487
    0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   488
    0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   489
    0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   490
    0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   491
    0x00000000, 0x00004002, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   492
    0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   493
    0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   494
    0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   495
    0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   496
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   497
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   498
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   499
    0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   500
    0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   501
    0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   502
    0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   503
    0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   504
    0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   505
    0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   506
    0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   507
    0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   508
    0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   509
    0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   510
    0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   511
    0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   512
    0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   513
    0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   514
    0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   515
    0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   516
    0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   517
    0x45475241, 0xabab0054
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   518
};
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   519
#else
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   520
#error "An appropriate 'yuv' pixel shader is not defined."
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   521
#endif
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   522
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   523
/* The sole vertex shader:
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   524
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   525
   --- D3D11_VertexShader.hlsl ---
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   526
   #pragma pack_matrix( row_major )
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   527
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   528
   cbuffer VertexShaderConstants : register(b0)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   529
   {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   530
       matrix model;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   531
       matrix projectionAndView;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   532
   };
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   533
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   534
   struct VertexShaderInput
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   535
   {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   536
       float3 pos : POSITION;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   537
       float2 tex : TEXCOORD0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   538
       float4 color : COLOR0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   539
   };
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   540
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   541
   struct VertexShaderOutput
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   542
   {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   543
       float4 pos : SV_POSITION;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   544
       float2 tex : TEXCOORD0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   545
       float4 color : COLOR0;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   546
   };
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   547
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   548
   VertexShaderOutput main(VertexShaderInput input)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   549
   {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   550
       VertexShaderOutput output;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   551
       float4 pos = float4(input.pos, 1.0f);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   552
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   553
       // Transform the vertex position into projected space.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   554
       pos = mul(pos, model);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   555
       pos = mul(pos, projectionAndView);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   556
       output.pos = pos;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   557
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   558
       // Pass through texture coordinates and color values without transformation
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   559
       output.tex = input.tex;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   560
       output.color = input.color;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   561
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   562
       return output;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   563
   }
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   564
*/
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   565
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   566
static const DWORD D3D11_VertexShader[] = {
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   567
    0x43425844, 0x62dfae5f, 0x3e8bd8df, 0x9ec97127, 0x5044eefb, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   568
    0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   569
    0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   570
    0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   571
    0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0200,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   572
    0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   573
    0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   574
    0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   575
    0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   576
    0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   577
    0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   578
    0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   579
    0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   580
    0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   581
    0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   582
    0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   583
    0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   584
    0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   585
    0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   586
    0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   587
    0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   588
    0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   589
    0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   590
    0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   591
    0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   592
    0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   593
    0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   594
    0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   595
    0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   596
    0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   597
    0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   598
    0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   599
    0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   600
    0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   601
    0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   602
    0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   603
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   604
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   605
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   606
    0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   607
    0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   608
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   609
    0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   610
    0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   611
    0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   612
    0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   613
    0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   614
    0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   615
    0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   616
    0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   617
    0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   618
    0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   619
    0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   620
    0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   621
    0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   622
    0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   623
    0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   624
    0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   625
    0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
8570
b509e789b6a3 WinRT: simplified the d3d11 vertex shader a bit
David Ludwig <dludwig@pobox.com>
parents: 8569
diff changeset
   626
    0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   627
};
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   628
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   629
static const DWORD D3D11_VertexShader[] = {
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   630
    0x43425844, 0x01a24e41, 0x696af551, 0x4b2a87d1, 0x82ea03f6, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   631
    0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   632
    0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   633
    0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   634
    0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0201,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   635
    0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   636
    0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   637
    0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   638
    0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   639
    0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   640
    0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   641
    0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   642
    0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   643
    0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   644
    0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   645
    0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   646
    0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   647
    0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   648
    0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   649
    0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   650
    0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   651
    0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   652
    0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   653
    0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   654
    0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   655
    0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   656
    0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   657
    0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   658
    0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   659
    0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   660
    0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   661
    0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   662
    0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   663
    0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   664
    0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   665
    0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   666
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   667
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   668
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   669
    0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   670
    0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   671
    0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   672
    0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   673
    0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   674
    0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   675
    0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   676
    0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   677
    0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   678
    0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   679
    0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   680
    0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   681
    0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   682
    0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   683
    0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   684
    0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   685
    0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   686
    0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   687
    0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   688
    0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   689
    0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
8563
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   690
};
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   691
#else
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   692
#error "An appropriate vertex shader is not defined."
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   693
#endif
c0e68f3b6bbb WinRT: compiled the d3d11 renderer's shaders into SDL itself
David Ludwig <dludwig@pobox.com>
parents: 8561
diff changeset
   694
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   695
8410
ba725b3a0c87 WinRT: more code-moving from SDL_winrtrenderer* to SDL_render_d3d11*
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   696
/* Direct3D 11.1 renderer implementation */
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   697
static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags);
8415
91977f5b2135 WinRT: added SDL_WINDOWEVENT_RESIZED support, and moved window-resize-handling code from WinRT rendering code to D3D 11.1 code
David Ludwig <dludwig@pobox.com>
parents: 8414
diff changeset
   698
static void D3D11_WindowEvent(SDL_Renderer * renderer,
91977f5b2135 WinRT: added SDL_WINDOWEVENT_RESIZED support, and moved window-resize-handling code from WinRT rendering code to D3D 11.1 code
David Ludwig <dludwig@pobox.com>
parents: 8414
diff changeset
   699
                            const SDL_WindowEvent *event);
8416
17040ce2693d WinRT: moved texture management code from SDL_winrtrenderer to the D3D 11.1 SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents: 8415
diff changeset
   700
static int D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
17040ce2693d WinRT: moved texture management code from SDL_winrtrenderer to the D3D 11.1 SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents: 8415
diff changeset
   701
static int D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
8459
1178e27580c7 WinRT: added render-to-texture support for D3D 11.1, via SDL_SetRenderTarget
David Ludwig <dludwig@pobox.com>
parents: 8458
diff changeset
   702
                             const SDL_Rect * rect, const void *srcPixels,
1178e27580c7 WinRT: added render-to-texture support for D3D 11.1, via SDL_SetRenderTarget
David Ludwig <dludwig@pobox.com>
parents: 8458
diff changeset
   703
                             int srcPitch);
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   704
static int D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   705
                                  const SDL_Rect * rect,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   706
                                  const Uint8 *Yplane, int Ypitch,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   707
                                  const Uint8 *Uplane, int Upitch,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   708
                                  const Uint8 *Vplane, int Vpitch);
8451
092ea651523a WinRT: added SDL_LockTexture and SDL_UnlockTexture support to the D3D 11.1 renderer
David Ludwig <dludwig@pobox.com>
parents: 8450
diff changeset
   709
static int D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
092ea651523a WinRT: added SDL_LockTexture and SDL_UnlockTexture support to the D3D 11.1 renderer
David Ludwig <dludwig@pobox.com>
parents: 8450
diff changeset
   710
                             const SDL_Rect * rect, void **pixels, int *pitch);
092ea651523a WinRT: added SDL_LockTexture and SDL_UnlockTexture support to the D3D 11.1 renderer
David Ludwig <dludwig@pobox.com>
parents: 8450
diff changeset
   711
static void D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
8459
1178e27580c7 WinRT: added render-to-texture support for D3D 11.1, via SDL_SetRenderTarget
David Ludwig <dludwig@pobox.com>
parents: 8458
diff changeset
   712
static int D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   713
static int D3D11_UpdateViewport(SDL_Renderer * renderer);
8482
eb0b00e7519e WinRT: added a stub implementation of UpdateClipRect to the D3D 11.1 renderer
David Ludwig <dludwig@pobox.com>
parents: 8463
diff changeset
   714
static int D3D11_UpdateClipRect(SDL_Renderer * renderer);
8416
17040ce2693d WinRT: moved texture management code from SDL_winrtrenderer to the D3D 11.1 SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents: 8415
diff changeset
   715
static int D3D11_RenderClear(SDL_Renderer * renderer);
8450
6f34a798cb54 WinRT: added point drawing support to the Direct3D 11.1 rendering backend
David Ludwig <dludwig@pobox.com>
parents: 8449
diff changeset
   716
static int D3D11_RenderDrawPoints(SDL_Renderer * renderer,
6f34a798cb54 WinRT: added point drawing support to the Direct3D 11.1 rendering backend
David Ludwig <dludwig@pobox.com>
parents: 8449
diff changeset
   717
                                  const SDL_FPoint * points, int count);
8449
2e4e5085e5b1 WinRT: added line drawing support to the Direct3D 11.1 rendering backend
David Ludwig <dludwig@pobox.com>
parents: 8448
diff changeset
   718
static int D3D11_RenderDrawLines(SDL_Renderer * renderer,
2e4e5085e5b1 WinRT: added line drawing support to the Direct3D 11.1 rendering backend
David Ludwig <dludwig@pobox.com>
parents: 8448
diff changeset
   719
                                 const SDL_FPoint * points, int count);
8429
a8b45a923fbd WinRT: implemented SDL_RenderFillRect and SDL_RenderFillRects for the D3D 11.1 renderer
David Ludwig <dludwig@pobox.com>
parents: 8427
diff changeset
   720
static int D3D11_RenderFillRects(SDL_Renderer * renderer,
a8b45a923fbd WinRT: implemented SDL_RenderFillRect and SDL_RenderFillRects for the D3D 11.1 renderer
David Ludwig <dludwig@pobox.com>
parents: 8427
diff changeset
   721
                                 const SDL_FRect * rects, int count);
8416
17040ce2693d WinRT: moved texture management code from SDL_winrtrenderer to the D3D 11.1 SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents: 8415
diff changeset
   722
static int D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
17040ce2693d WinRT: moved texture management code from SDL_winrtrenderer to the D3D 11.1 SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents: 8415
diff changeset
   723
                            const SDL_Rect * srcrect, const SDL_FRect * dstrect);
8455
14d4b48cc07f WinRT: implemented SDL_RenderCopyEx, w/ SDL_RendererFlip support, in D3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8454
diff changeset
   724
static int D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
14d4b48cc07f WinRT: implemented SDL_RenderCopyEx, w/ SDL_RendererFlip support, in D3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8454
diff changeset
   725
                              const SDL_Rect * srcrect, const SDL_FRect * dstrect,
14d4b48cc07f WinRT: implemented SDL_RenderCopyEx, w/ SDL_RendererFlip support, in D3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8454
diff changeset
   726
                              const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
8454
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   727
static int D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   728
                                  Uint32 format, void * pixels, int pitch);
8401
29ecd2eca4af WinRT: moved a bit more Direct3D 11.1 code into the SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents: 8400
diff changeset
   729
static void D3D11_RenderPresent(SDL_Renderer * renderer);
8416
17040ce2693d WinRT: moved texture management code from SDL_winrtrenderer to the D3D 11.1 SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents: 8415
diff changeset
   730
static void D3D11_DestroyTexture(SDL_Renderer * renderer,
17040ce2693d WinRT: moved texture management code from SDL_winrtrenderer to the D3D 11.1 SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents: 8415
diff changeset
   731
                                 SDL_Texture * texture);
8413
4ae81c5dc55e WinRT: made the Direct3D 11.1 renderer directly initialize more of itself, rather than deferring to code in the WinRT video driver
David Ludwig <dludwig@pobox.com>
parents: 8412
diff changeset
   732
static void D3D11_DestroyRenderer(SDL_Renderer * renderer);
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   733
8410
ba725b3a0c87 WinRT: more code-moving from SDL_winrtrenderer* to SDL_render_d3d11*
David Ludwig <dludwig@pobox.com>
parents: 8401
diff changeset
   734
/* Direct3D 11.1 Internal Functions */
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   735
static HRESULT D3D11_CreateDeviceResources(SDL_Renderer * renderer);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   736
static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   737
static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   738
static HRESULT D3D11_HandleDeviceLost(SDL_Renderer * renderer);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   739
static void D3D11_ReleaseMainRenderTargetView(SDL_Renderer * renderer);
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   740
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   741
SDL_RenderDriver D3D11_RenderDriver = {
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   742
    D3D11_CreateRenderer,
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   743
    {
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   744
        "direct3d11",
8459
1178e27580c7 WinRT: added render-to-texture support for D3D 11.1, via SDL_SetRenderTarget
David Ludwig <dludwig@pobox.com>
parents: 8458
diff changeset
   745
        (
1178e27580c7 WinRT: added render-to-texture support for D3D 11.1, via SDL_SetRenderTarget
David Ludwig <dludwig@pobox.com>
parents: 8458
diff changeset
   746
            SDL_RENDERER_ACCELERATED |
1178e27580c7 WinRT: added render-to-texture support for D3D 11.1, via SDL_SetRenderTarget
David Ludwig <dludwig@pobox.com>
parents: 8458
diff changeset
   747
            SDL_RENDERER_PRESENTVSYNC |
1178e27580c7 WinRT: added render-to-texture support for D3D 11.1, via SDL_SetRenderTarget
David Ludwig <dludwig@pobox.com>
parents: 8458
diff changeset
   748
            SDL_RENDERER_TARGETTEXTURE
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   749
        ),                          /* flags.  see SDL_RendererFlags */
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   750
        4,                          /* num_texture_formats */
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   751
        {                           /* texture_formats */
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   752
            SDL_PIXELFORMAT_ARGB8888,
8442
7046465c646c WinRT: added support for alpha-blended texture rendering
David Ludwig <dludwig@pobox.com>
parents: 8434
diff changeset
   753
            SDL_PIXELFORMAT_RGB888,
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   754
            SDL_PIXELFORMAT_YV12,
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   755
            SDL_PIXELFORMAT_IYUV
8442
7046465c646c WinRT: added support for alpha-blended texture rendering
David Ludwig <dludwig@pobox.com>
parents: 8434
diff changeset
   756
        },
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   757
        0,                          /* max_texture_width: will be filled in later */
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   758
        0                           /* max_texture_height: will be filled in later */
8442
7046465c646c WinRT: added support for alpha-blended texture rendering
David Ludwig <dludwig@pobox.com>
parents: 8434
diff changeset
   759
    }
7046465c646c WinRT: added support for alpha-blended texture rendering
David Ludwig <dludwig@pobox.com>
parents: 8434
diff changeset
   760
};
7046465c646c WinRT: added support for alpha-blended texture rendering
David Ludwig <dludwig@pobox.com>
parents: 8434
diff changeset
   761
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   762
8454
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   763
static Uint32
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   764
DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) {
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   765
    switch (dxgiFormat) {
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   766
        case DXGI_FORMAT_B8G8R8A8_UNORM:
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   767
            return SDL_PIXELFORMAT_ARGB8888;
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   768
        case DXGI_FORMAT_B8G8R8X8_UNORM:
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   769
            return SDL_PIXELFORMAT_RGB888;
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   770
        default:
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   771
            return SDL_PIXELFORMAT_UNKNOWN;
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   772
    }
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   773
}
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   774
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   775
static DXGI_FORMAT
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   776
SDLPixelFormatToDXGIFormat(Uint32 sdlFormat)
ac6a37f54dc2 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1
David Ludwig <dludwig@pobox.com>
parents: 8452
diff changeset
   777
{
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   778
    switch (sdlFormat) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   779
        case SDL_PIXELFORMAT_ARGB8888:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   780
            return DXGI_FORMAT_B8G8R8A8_UNORM;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   781
        case SDL_PIXELFORMAT_RGB888:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   782
            return DXGI_FORMAT_B8G8R8X8_UNORM;
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   783
        case SDL_PIXELFORMAT_YV12:
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   784
        case SDL_PIXELFORMAT_IYUV:
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   785
            return DXGI_FORMAT_R8_UNORM;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   786
        default:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   787
            return DXGI_FORMAT_UNKNOWN;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   788
    }
8566
7b4d9d694189 WinRT: removed a bit of dead d3d11 code
David Ludwig <dludwig@pobox.com>
parents: 8565
diff changeset
   789
}
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   790
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   791
SDL_Renderer *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   792
D3D11_CreateRenderer(SDL_Window * window, Uint32 flags)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   793
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   794
    SDL_Renderer *renderer;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   795
    D3D11_RenderData *data;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   796
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   797
    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   798
    if (!renderer) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   799
        SDL_OutOfMemory();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   800
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   801
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   802
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   803
    data = (D3D11_RenderData *) SDL_calloc(1, sizeof(*data));
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   804
    if (!data) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   805
        SDL_OutOfMemory();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   806
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   807
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   808
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   809
    renderer->WindowEvent = D3D11_WindowEvent;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   810
    renderer->CreateTexture = D3D11_CreateTexture;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   811
    renderer->UpdateTexture = D3D11_UpdateTexture;
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   812
    renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   813
    renderer->LockTexture = D3D11_LockTexture;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   814
    renderer->UnlockTexture = D3D11_UnlockTexture;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   815
    renderer->SetRenderTarget = D3D11_SetRenderTarget;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   816
    renderer->UpdateViewport = D3D11_UpdateViewport;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   817
    renderer->UpdateClipRect = D3D11_UpdateClipRect;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   818
    renderer->RenderClear = D3D11_RenderClear;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   819
    renderer->RenderDrawPoints = D3D11_RenderDrawPoints;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   820
    renderer->RenderDrawLines = D3D11_RenderDrawLines;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   821
    renderer->RenderFillRects = D3D11_RenderFillRects;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   822
    renderer->RenderCopy = D3D11_RenderCopy;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   823
    renderer->RenderCopyEx = D3D11_RenderCopyEx;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   824
    renderer->RenderReadPixels = D3D11_RenderReadPixels;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   825
    renderer->RenderPresent = D3D11_RenderPresent;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   826
    renderer->DestroyTexture = D3D11_DestroyTexture;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   827
    renderer->DestroyRenderer = D3D11_DestroyRenderer;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   828
    renderer->info = D3D11_RenderDriver.info;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   829
    renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   830
    renderer->driverdata = data;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   831
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   832
    if ((flags & SDL_RENDERER_PRESENTVSYNC)) {
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   833
        renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   834
    }
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   835
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   836
    /* HACK: make sure the SDL_Renderer references the SDL_Window data now, in
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   837
     * order to give init functions access to the underlying window handle:
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   838
     */
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   839
    renderer->window = window;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   840
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   841
    /* Initialize Direct3D resources */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   842
    if (FAILED(D3D11_CreateDeviceResources(renderer))) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   843
        D3D11_DestroyRenderer(renderer);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   844
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   845
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   846
    if (FAILED(D3D11_CreateWindowSizeDependentResources(renderer))) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   847
        D3D11_DestroyRenderer(renderer);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   848
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   849
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   850
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   851
    return renderer;
8400
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   852
}
1315402d9028 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   853
8413
4ae81c5dc55e WinRT: made the Direct3D 11.1 renderer directly initialize more of itself, rather than deferring to code in the WinRT video driver
David Ludwig <dludwig@pobox.com>
parents: 8412
diff changeset
   854
static void
8668
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   855
D3D11_ReleaseAll(SDL_Renderer * renderer)
8413
4ae81c5dc55e WinRT: made the Direct3D 11.1 renderer directly initialize more of itself, rather than deferring to code in the WinRT video driver
David Ludwig <dludwig@pobox.com>
parents: 8412
diff changeset
   856
{
4ae81c5dc55e WinRT: made the Direct3D 11.1 renderer directly initialize more of itself, rather than deferring to code in the WinRT video driver
David Ludwig <dludwig@pobox.com>
parents: 8412
diff changeset
   857
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
8668
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   858
    SDL_Texture *texture = NULL;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   859
8669
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   860
    /* Release all textures */
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   861
    for (texture = renderer->textures; texture; texture = texture->next) {
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   862
        D3D11_DestroyTexture(renderer, texture);
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   863
    }
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   864
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   865
    /* Release/reset everything else */
8413
4ae81c5dc55e WinRT: made the Direct3D 11.1 renderer directly initialize more of itself, rather than deferring to code in the WinRT video driver
David Ludwig <dludwig@pobox.com>
parents: 8412
diff changeset
   866
    if (data) {
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   867
        SAFE_RELEASE(data->dxgiFactory);
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   868
        SAFE_RELEASE(data->dxgiAdapter);
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   869
        SAFE_RELEASE(data->d3dDevice);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   870
        SAFE_RELEASE(data->d3dContext);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   871
        SAFE_RELEASE(data->swapChain);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   872
        SAFE_RELEASE(data->mainRenderTargetView);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   873
        SAFE_RELEASE(data->currentOffscreenRenderTargetView);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   874
        SAFE_RELEASE(data->inputLayout);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   875
        SAFE_RELEASE(data->vertexBuffer);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   876
        SAFE_RELEASE(data->vertexShader);
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   877
        SAFE_RELEASE(data->colorPixelShader);
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   878
        SAFE_RELEASE(data->texturePixelShader);
8595
c6fc94639f38 Implemented YV12 and IYUV texture support for the D3D11 renderer
Sam Lantinga <slouken@libsdl.org>
parents: 8592
diff changeset
   879
        SAFE_RELEASE(data->yuvPixelShader);
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   880
        SAFE_RELEASE(data->blendModeBlend);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   881
        SAFE_RELEASE(data->blendModeAdd);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   882
        SAFE_RELEASE(data->blendModeMod);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   883
        SAFE_RELEASE(data->nearestPixelSampler);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   884
        SAFE_RELEASE(data->linearSampler);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   885
        SAFE_RELEASE(data->mainRasterizer);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   886
        SAFE_RELEASE(data->clippedRasterizer);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   887
        SAFE_RELEASE(data->vertexShaderConstants);
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   888
8668
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   889
        data->swapEffect = (DXGI_SWAP_EFFECT) 0;
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   890
        data->rotation = DXGI_MODE_ROTATION_UNSPECIFIED;
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   891
        data->currentRenderTargetView = NULL;
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   892
        data->currentRasterizerState = NULL;
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   893
        data->currentBlendState = NULL;
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   894
        data->currentShader = NULL;
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   895
        data->currentShaderResource = NULL;
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   896
        data->currentSampler = NULL;
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   897
8669
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   898
        /* Unload the D3D libraries.  This should be done last, in order
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   899
         * to prevent IUnknown::Release() calls from crashing.
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   900
         */
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   901
        if (data->hD3D11Mod) {
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   902
            SDL_UnloadObject(data->hD3D11Mod);
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   903
            data->hD3D11Mod = NULL;
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   904
        }
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   905
        if (data->hDXGIMod) {
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   906
            SDL_UnloadObject(data->hDXGIMod);
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   907
            data->hDXGIMod = NULL;
62dfa45e5e08 D3D11: Fixed a crash after a GPU device-reset on Win32
David Ludwig <dludwig@pobox.com>
parents: 8668
diff changeset
   908
        }
8668
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   909
    }
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   910
}
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   911
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   912
static void
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   913
D3D11_DestroyRenderer(SDL_Renderer * renderer)
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   914
{
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   915
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   916
    D3D11_ReleaseAll(renderer);
07dce0097f29 D3D11: Added code to handle GPU-device-removed scenarios
David Ludwig <dludwig@pobox.com>
parents: 8620
diff changeset
   917
    if (data) {
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   918
        SDL_free(data);
8413
4ae81c5dc55e WinRT: made the Direct3D 11.1 renderer directly initialize more of itself, rather than deferring to code in the WinRT video driver
David Ludwig <dludwig@pobox.com>
parents: 8412
diff changeset
   919
    }
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   920
    SDL_free(renderer);
8413
4ae81c5dc55e WinRT: made the Direct3D 11.1 renderer directly initialize more of itself, rather than deferring to code in the WinRT video driver
David Ludwig <dludwig@pobox.com>
parents: 8412
diff changeset
   921
}
4ae81c5dc55e WinRT: made the Direct3D 11.1 renderer directly initialize more of itself, rather than deferring to code in the WinRT video driver
David Ludwig <dludwig@pobox.com>
parents: 8412
diff changeset
   922
8431
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   923
static HRESULT
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   924
D3D11_CreateBlendMode(SDL_Renderer * renderer,
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   925
                      BOOL enableBlending,
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   926
                      D3D11_BLEND srcBlend,
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   927
                      D3D11_BLEND destBlend,
8575
97a2e1b1a019 WinRT: d3d11 blend mode bug fixes
David Ludwig <dludwig@pobox.com>
parents: 8571
diff changeset
   928
                      D3D11_BLEND srcBlendAlpha,
97a2e1b1a019 WinRT: d3d11 blend mode bug fixes
David Ludwig <dludwig@pobox.com>
parents: 8571
diff changeset
   929
                      D3D11_BLEND destBlendAlpha,
8431
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   930
                      ID3D11BlendState ** blendStateOutput)
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   931
{
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   932
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   933
    HRESULT result = S_OK;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   934
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   935
    D3D11_BLEND_DESC blendDesc;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   936
    SDL_zero(blendDesc);
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   937
    blendDesc.AlphaToCoverageEnable = FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   938
    blendDesc.IndependentBlendEnable = FALSE;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   939
    blendDesc.RenderTarget[0].BlendEnable = enableBlending;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   940
    blendDesc.RenderTarget[0].SrcBlend = srcBlend;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   941
    blendDesc.RenderTarget[0].DestBlend = destBlend;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   942
    blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   943
    blendDesc.RenderTarget[0].SrcBlendAlpha = srcBlendAlpha;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   944
    blendDesc.RenderTarget[0].DestBlendAlpha = destBlendAlpha;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   945
    blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   946
    blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   947
    result = ID3D11Device_CreateBlendState(data->d3dDevice, &blendDesc, blendStateOutput);
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   948
    if (FAILED(result)) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   949
        WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBlendState", result);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   950
        return result;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   951
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   952
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   953
    return S_OK;
8431
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   954
}
2078dc4f4378 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix
David Ludwig <dludwig@pobox.com>
parents: 8430
diff changeset
   955
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   956
/* Create resources that depend on the device. */
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   957
static HRESULT
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   958
D3D11_CreateDeviceResources(SDL_Renderer * renderer)
8597
1479abb49773 Fixed line endings
Sam Lantinga <slouken@libsdl.org>
parents: 8596
diff changeset
   959
{
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   960
    typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory);
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   961
    PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc;
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8575
diff changeset
   962
    D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   963
    PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc;
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   964
    IDXGIAdapter *d3dAdapter = NULL;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   965
    ID3D11Device *d3dDevice = NULL;
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   966
    ID3D11DeviceContext *d3dContext = NULL;
8596
88fee9ded656 Fixed creating the rendering context on a specific device
Sam Lantinga <slouken@libsdl.org>
parents: 8595
diff changeset
   967
    IDXGIDevice1 *dxgiDevice = NULL;
8591
2228ae5a3ac6 Converted David Ludwig's D3D11 renderer to C and optimized it.
Sam Lantinga <slouken@libsdl.org>
parents: 8582
diff changeset
   968
    HRESULT result = S_OK;
8607
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   969
    UINT creationFlags;
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   970
    const char *hint;
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   971
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   972
    /* This array defines the set of DirectX hardware feature levels this app will support.
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   973
     * Note the ordering should be preserved.
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   974
     * Don't forget to declare your application's minimum required feature level in its
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   975
     * description.  All applications are assumed to support 9.1 unless otherwise stated.
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   976
     */
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   977
    D3D_FEATURE_LEVEL featureLevels[] = 
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   978
    {
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   979
        D3D_FEATURE_LEVEL_11_1,
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   980
        D3D_FEATURE_LEVEL_11_0,
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   981
        D3D_FEATURE_LEVEL_10_1,
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   982
        D3D_FEATURE_LEVEL_10_0,
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   983
        D3D_FEATURE_LEVEL_9_3,
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   984
        D3D_FEATURE_LEVEL_9_2,
ef23c9d08eed Made VS2012 build the D3D11 renderer
David Ludwig <dludwig@pobox.com>
parents: 8599
diff changeset
   985
        D3D_FEATURE_LEVEL_9_1
ef23c9d08eed Made VS2012 build the D3D11 renderer
<