Browse Source

Scale SDR content to SDR whitelevel when HDR is enabled

Sam Lantinga 1 năm trước cách đây
mục cha
commit
240158f3e8

+ 292 - 134
src/render/direct3d11/D3D11_PixelShader_Colors.h

@@ -1,134 +1,292 @@
-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
-//
-//
-//
-// Input signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_POSITION              0   xyzw        0      POS   float       
-// TEXCOORD                 0   xy          1     NONE   float       
-// COLOR                    0   xyzw        2     NONE   float   xyzw
-//
-//
-// Output signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
-//
-//
-// Level9 shader bytecode:
-//
-    ps_2_0
-    dcl t1
-    mov oC0, t1
-
-// approximately 1 instruction slot used
-ps_4_0
-dcl_input_ps linear v2.xyzw
-dcl_output o0.xyzw
-mov o0.xyzw, v2.xyzw
-ret 
-// Approximately 2 instruction slots used
-#endif
-
-const BYTE g_main[] =
-{
-     68,  88,  66,  67, 226, 124, 
-     10,  63, 141, 181,  49, 167, 
-    218, 135, 248, 147,  77, 222, 
-     95, 123,   1,   0,   0,   0, 
-     52,   2,   0,   0,   6,   0, 
-      0,   0,  56,   0,   0,   0, 
-    132,   0,   0,   0, 196,   0, 
-      0,   0,  64,   1,   0,   0, 
-    140,   1,   0,   0,   0,   2, 
-      0,   0,  65, 111, 110,  57, 
-     68,   0,   0,   0,  68,   0, 
-      0,   0,   0,   2, 255, 255, 
-     32,   0,   0,   0,  36,   0, 
-      0,   0,   0,   0,  36,   0, 
-      0,   0,  36,   0,   0,   0, 
-     36,   0,   0,   0,  36,   0, 
-      0,   0,  36,   0,   0,   2, 
-    255, 255,  31,   0,   0,   2, 
-      0,   0,   0, 128,   1,   0, 
-     15, 176,   1,   0,   0,   2, 
-      0,   8,  15, 128,   1,   0, 
-    228, 176, 255, 255,   0,   0, 
-     83,  72,  68,  82,  56,   0, 
-      0,   0,  64,   0,   0,   0, 
-     14,   0,   0,   0,  98,  16, 
-      0,   3, 242,  16,  16,   0, 
-      2,   0,   0,   0, 101,   0, 
-      0,   3, 242,  32,  16,   0, 
-      0,   0,   0,   0,  54,   0, 
-      0,   5, 242,  32,  16,   0, 
-      0,   0,   0,   0,  70,  30, 
-     16,   0,   2,   0,   0,   0, 
-     62,   0,   0,   1,  83,  84, 
-     65,  84, 116,   0,   0,   0, 
-      2,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      2,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  82,  68,  69,  70, 
-     68,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,  28,   0, 
-      0,   0,   0,   4, 255, 255, 
-      0,   1,   0,   0,  28,   0, 
-      0,   0,  77, 105,  99, 114, 
-    111, 115, 111, 102, 116,  32, 
-     40,  82,  41,  32,  72,  76, 
-     83,  76,  32,  83, 104,  97, 
-    100, 101, 114,  32,  67, 111, 
-    109, 112, 105, 108, 101, 114, 
-     32,  49,  48,  46,  49,   0, 
-     73,  83,  71,  78, 108,   0, 
-      0,   0,   3,   0,   0,   0, 
-      8,   0,   0,   0,  80,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   3,   0, 
-      0,   0,   0,   0,   0,   0, 
-     15,   0,   0,   0,  92,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   1,   0,   0,   0, 
-      3,   0,   0,   0, 101,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   2,   0,   0,   0, 
-     15,  15,   0,   0,  83,  86, 
-     95,  80,  79,  83,  73,  84, 
-     73,  79,  78,   0,  84,  69, 
-     88,  67,  79,  79,  82,  68, 
-      0,  67,  79,  76,  79,  82, 
-      0, 171,  79,  83,  71,  78, 
-     44,   0,   0,   0,   1,   0, 
-      0,   0,   8,   0,   0,   0, 
-     32,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,   0,   0, 
-      0,   0,  15,   0,   0,   0, 
-     83,  86,  95,  84,  65,  82, 
-     71,  69,  84,   0, 171, 171
-};
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Buffer Definitions: 
+//
+// cbuffer Constants
+// {
+//
+//   float scRGB_output;                // Offset:    0 Size:     4
+//   float SDR_whitelevel;              // Offset:    4 Size:     4
+//   float HDR_whitelevel;              // Offset:    8 Size:     4 [unused]
+//   float maxCLL;                      // Offset:   12 Size:     4 [unused]
+//   float4 Yoffset;                    // Offset:   16 Size:    16 [unused]
+//   float4 Rcoeff;                     // Offset:   32 Size:    16 [unused]
+//   float4 Gcoeff;                     // Offset:   48 Size:    16 [unused]
+//   float4 Bcoeff;                     // Offset:   64 Size:    16 [unused]
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim      HLSL Bind  Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// Constants                         cbuffer      NA          NA            cb0      1 
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION              0   xyzw        0      POS   float       
+// TEXCOORD                 0   xy          1     NONE   float       
+// COLOR                    0   xyzw        2     NONE   float   xyzw
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
+//
+//
+// Constant buffer to DX9 shader constant mappings:
+//
+// Target Reg Buffer  Start Reg # of Regs        Data Conversion
+// ---------- ------- --------- --------- ----------------------
+// c0         cb0             0         1  ( FLT, FLT, FLT, FLT)
+//
+//
+// Level9 shader bytecode:
+//
+    ps_2_0
+    def c1, 0.0125000002, 1, 0, 0
+    dcl t1
+    mul r0.w, c0.x, c0.x
+    mov r0.x, c1.x
+    mul r0.x, r0.x, c0.y
+    cmp r0.xyz, -r0.w, c1.y, r0.x
+    mov r0.w, c1.y
+    mul r0, r0, t1
+    mov oC0, r0
+
+// approximately 7 instruction slots used
+ps_4_0
+dcl_constantbuffer CB0[1], immediateIndexed
+dcl_input_ps linear v2.xyzw
+dcl_output o0.xyzw
+dcl_temps 1
+ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x
+mul r0.y, cb0[0].y, l(0.012500)
+movc r0.xyz, r0.xxxx, r0.yyyy, l(1.000000,1.000000,1.000000,0)
+mov r0.w, l(1.000000)
+mul o0.xyzw, r0.xyzw, v2.xyzw
+ret 
+// Approximately 6 instruction slots used
+#endif
+
+const BYTE g_main[] =
+{
+     68,  88,  66,  67, 132,  13, 
+    165,  35,  17, 157, 163, 217, 
+    158,  71, 117, 171,  46, 252, 
+      9, 215,   1,   0,   0,   0, 
+    224,   4,   0,   0,   6,   0, 
+      0,   0,  56,   0,   0,   0, 
+      4,   1,   0,   0, 244,   1, 
+      0,   0, 112,   2,   0,   0, 
+     56,   4,   0,   0, 172,   4, 
+      0,   0,  65, 111, 110,  57, 
+    196,   0,   0,   0, 196,   0, 
+      0,   0,   0,   2, 255, 255, 
+    148,   0,   0,   0,  48,   0, 
+      0,   0,   1,   0,  36,   0, 
+      0,   0,  48,   0,   0,   0, 
+     48,   0,   0,   0,  36,   0, 
+      0,   0,  48,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   2, 
+    255, 255,  81,   0,   0,   5, 
+      1,   0,  15, 160, 205, 204, 
+     76,  60,   0,   0, 128,  63, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  31,   0,   0,   2, 
+      0,   0,   0, 128,   1,   0, 
+     15, 176,   5,   0,   0,   3, 
+      0,   0,   8, 128,   0,   0, 
+      0, 160,   0,   0,   0, 160, 
+      1,   0,   0,   2,   0,   0, 
+      1, 128,   1,   0,   0, 160, 
+      5,   0,   0,   3,   0,   0, 
+      1, 128,   0,   0,   0, 128, 
+      0,   0,  85, 160,  88,   0, 
+      0,   4,   0,   0,   7, 128, 
+      0,   0, 255, 129,   1,   0, 
+     85, 160,   0,   0,   0, 128, 
+      1,   0,   0,   2,   0,   0, 
+      8, 128,   1,   0,  85, 160, 
+      5,   0,   0,   3,   0,   0, 
+     15, 128,   0,   0, 228, 128, 
+      1,   0, 228, 176,   1,   0, 
+      0,   2,   0,   8,  15, 128, 
+      0,   0, 228, 128, 255, 255, 
+      0,   0,  83,  72,  68,  82, 
+    232,   0,   0,   0,  64,   0, 
+      0,   0,  58,   0,   0,   0, 
+     89,   0,   0,   4,  70, 142, 
+     32,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,  98,  16, 
+      0,   3, 242,  16,  16,   0, 
+      2,   0,   0,   0, 101,   0, 
+      0,   3, 242,  32,  16,   0, 
+      0,   0,   0,   0, 104,   0, 
+      0,   2,   1,   0,   0,   0, 
+     57,   0,   0,  11,  18,   0, 
+     16,   0,   0,   0,   0,   0, 
+      2,  64,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  10, 128,  32,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  56,   0,   0,   8, 
+     34,   0,  16,   0,   0,   0, 
+      0,   0,  26, 128,  32,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,  64,   0,   0, 
+    205, 204,  76,  60,  55,   0, 
+      0,  12, 114,   0,  16,   0, 
+      0,   0,   0,   0,   6,   0, 
+     16,   0,   0,   0,   0,   0, 
+     86,   5,  16,   0,   0,   0, 
+      0,   0,   2,  64,   0,   0, 
+      0,   0, 128,  63,   0,   0, 
+    128,  63,   0,   0, 128,  63, 
+      0,   0,   0,   0,  54,   0, 
+      0,   5, 130,   0,  16,   0, 
+      0,   0,   0,   0,   1,  64, 
+      0,   0,   0,   0, 128,  63, 
+     56,   0,   0,   7, 242,  32, 
+     16,   0,   0,   0,   0,   0, 
+     70,  14,  16,   0,   0,   0, 
+      0,   0,  70,  30,  16,   0, 
+      2,   0,   0,   0,  62,   0, 
+      0,   1,  83,  84,  65,  84, 
+    116,   0,   0,   0,   6,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,   2,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     82,  68,  69,  70, 192,   1, 
+      0,   0,   1,   0,   0,   0, 
+     72,   0,   0,   0,   1,   0, 
+      0,   0,  28,   0,   0,   0, 
+      0,   4, 255, 255,   0,   1, 
+      0,   0, 149,   1,   0,   0, 
+     60,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,  67, 111, 110, 115, 
+    116,  97, 110, 116, 115,   0, 
+    171, 171,  60,   0,   0,   0, 
+      8,   0,   0,   0,  96,   0, 
+      0,   0,  80,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  32,   1,   0,   0, 
+      0,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+     48,   1,   0,   0,   0,   0, 
+      0,   0,  64,   1,   0,   0, 
+      4,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+     48,   1,   0,   0,   0,   0, 
+      0,   0,  79,   1,   0,   0, 
+      8,   0,   0,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+     48,   1,   0,   0,   0,   0, 
+      0,   0,  94,   1,   0,   0, 
+     12,   0,   0,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+     48,   1,   0,   0,   0,   0, 
+      0,   0, 101,   1,   0,   0, 
+     16,   0,   0,   0,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+    112,   1,   0,   0,   0,   0, 
+      0,   0, 128,   1,   0,   0, 
+     32,   0,   0,   0,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+    112,   1,   0,   0,   0,   0, 
+      0,   0, 135,   1,   0,   0, 
+     48,   0,   0,   0,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+    112,   1,   0,   0,   0,   0, 
+      0,   0, 142,   1,   0,   0, 
+     64,   0,   0,   0,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+    112,   1,   0,   0,   0,   0, 
+      0,   0, 115,  99,  82,  71, 
+     66,  95, 111, 117, 116, 112, 
+    117, 116,   0, 171, 171, 171, 
+      0,   0,   3,   0,   1,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  83,  68, 
+     82,  95, 119, 104, 105, 116, 
+    101, 108, 101, 118, 101, 108, 
+      0,  72,  68,  82,  95, 119, 
+    104, 105, 116, 101, 108, 101, 
+    118, 101, 108,   0, 109,  97, 
+    120,  67,  76,  76,   0,  89, 
+    111, 102, 102, 115, 101, 116, 
+      0, 171, 171, 171,   1,   0, 
+      3,   0,   1,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  82,  99, 111, 101, 
+    102, 102,   0,  71,  99, 111, 
+    101, 102, 102,   0,  66,  99, 
+    111, 101, 102, 102,   0,  77, 
+    105,  99, 114, 111, 115, 111, 
+    102, 116,  32,  40,  82,  41, 
+     32,  72,  76,  83,  76,  32, 
+     83, 104,  97, 100, 101, 114, 
+     32,  67, 111, 109, 112, 105, 
+    108, 101, 114,  32,  49,  48, 
+     46,  49,   0, 171, 171, 171, 
+     73,  83,  71,  78, 108,   0, 
+      0,   0,   3,   0,   0,   0, 
+      8,   0,   0,   0,  80,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+     15,   0,   0,   0,  92,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,   1,   0,   0,   0, 
+      3,   0,   0,   0, 101,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,   2,   0,   0,   0, 
+     15,  15,   0,   0,  83,  86, 
+     95,  80,  79,  83,  73,  84, 
+     73,  79,  78,   0,  84,  69, 
+     88,  67,  79,  79,  82,  68, 
+      0,  67,  79,  76,  79,  82, 
+      0, 171,  79,  83,  71,  78, 
+     44,   0,   0,   0,   1,   0, 
+      0,   0,   8,   0,   0,   0, 
+     32,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+     83,  86,  95,  84,  65,  82, 
+     71,  69,  84,   0, 171, 171
+};

+ 3 - 7
src/render/direct3d11/D3D11_PixelShader_Colors.hlsl

@@ -1,11 +1,7 @@
-struct PixelShaderInput
-{
-    float4 pos : SV_POSITION;
-    float2 tex : TEXCOORD0;
-    float4 color : COLOR0;
-};
+
+#include "D3D11_PixelShader_Common.incl"
 
 float4 main(PixelShaderInput input) : SV_TARGET
 {
-    return input.color;
+    return GetOutputColor(1.0) * input.color;
 }

+ 75 - 0
src/render/direct3d11/D3D11_PixelShader_Common.incl

@@ -0,0 +1,75 @@
+struct PixelShaderInput
+{
+    float4 pos : SV_POSITION;
+    float2 tex : TEXCOORD0;
+    float4 color : COLOR0;
+};
+
+cbuffer Constants : register(b0)
+{
+    float scRGB_output;
+    float SDR_whitelevel;
+    float HDR_whitelevel;
+    float maxCLL;
+
+    float4 Yoffset;
+    float4 Rcoeff;
+    float4 Gcoeff;
+    float4 Bcoeff;
+};
+
+float3 scRGBtoNits(float3 v)
+{
+    return v * 80.0;
+}
+
+float3 scRGBfromNits(float3 v)
+{
+    return v / 80.0;
+}
+
+float sRGBtoLinear(float v)
+{
+    if (v <= 0.04045) {
+        v = (v / 12.92);
+    } else {
+        v = pow(abs(v + 0.055) / 1.055, 2.4);
+    }
+    return v;
+}
+
+float sRGBfromLinear(float v)
+{
+    if (v <= 0.0031308) {
+        v = (v * 12.92);
+    } else {
+        v = (pow(abs(v), 1.0 / 2.4) * 1.055 - 0.055);
+    }
+    return v;
+}
+
+float4 GetOutputColor(float4 rgba)
+{
+    if (scRGB_output) {
+        rgba.rgb = scRGBfromNits(rgba.rgb * SDR_whitelevel);
+    }
+
+    return rgba;
+}
+
+float4 GetOutputColorFromSRGB(float3 rgb)
+{
+    float4 output;
+
+    if (scRGB_output) {
+        output.r = sRGBtoLinear(rgb.r);
+        output.g = sRGBtoLinear(rgb.g);
+        output.b = sRGBtoLinear(rgb.b);
+        rgb = scRGBfromNits(rgb * SDR_whitelevel);
+    } else {
+        output.rgb = rgb.rgb;
+    }
+    output.a = 1.0;
+
+    return output;
+}

+ 515 - 515
src/render/direct3d11/D3D11_PixelShader_HDR10.h

@@ -1,515 +1,515 @@
-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
-//
-//
-// Buffer Definitions: 
-//
-// cbuffer Constants
-// {
-//
-//   float4 Yoffset;                    // Offset:    0 Size:    16
-//   float4 Rcoeff;                     // Offset:   16 Size:    16
-//   float4 Gcoeff;                     // Offset:   32 Size:    16
-//   float4 Bcoeff;                     // Offset:   48 Size:    16
-//   float scRGB_output;                // Offset:   64 Size:     4
-//   float SDR_whitelevel;              // Offset:   68 Size:     4 [unused]
-//   float HDR_whitelevel;              // Offset:   72 Size:     4
-//   float maxCLL;                      // Offset:   76 Size:     4
-//
-// }
-//
-//
-// Resource Bindings:
-//
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// theSampler                        sampler      NA          NA             s0      1 
-// theTextureY                       texture  float4          2d             t0      1 
-// theTextureUV                      texture  float4          2d             t1      1 
-// Constants                         cbuffer      NA          NA            cb0      1 
-//
-//
-//
-// Input signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_POSITION              0   xyzw        0      POS   float       
-// TEXCOORD                 0   xy          1     NONE   float   xy  
-// COLOR                    0   xyzw        2     NONE   float   xyzw
-//
-//
-// Output signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
-//
-ps_5_0
-dcl_globalFlags refactoringAllowed
-dcl_constantbuffer CB0[5], immediateIndexed
-dcl_sampler s0, mode_default
-dcl_resource_texture2d (float,float,float,float) t0
-dcl_resource_texture2d (float,float,float,float) t1
-dcl_input_ps linear v1.xy
-dcl_input_ps linear v2.xyzw
-dcl_output o0.xyzw
-dcl_temps 4
-sample_indexable(texture2d)(float,float,float,float) r0.x, v1.xyxx, t0.xyzw, s0
-sample_indexable(texture2d)(float,float,float,float) r0.yz, v1.xyxx, t1.zxyw, s0
-add r0.xyz, r0.xyzx, cb0[0].xyzx
-dp3 r1.x, r0.xyzx, cb0[1].xyzx
-dp3 r1.y, r0.xyzx, cb0[2].xyzx
-dp3 r1.z, r0.xyzx, cb0[3].xyzx
-log r0.xyz, |r1.xyzx|
-mul r0.xyz, r0.xyzx, l(0.012683, 0.012683, 0.012683, 0.000000)
-exp r0.xyz, r0.xyzx
-add r1.xyz, r0.xyzx, l(-0.835938, -0.835938, -0.835938, 0.000000)
-max r1.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
-mad r0.xyz, -r0.xyzx, l(18.687500, 18.687500, 18.687500, 0.000000), l(18.851562, 18.851562, 18.851562, 0.000000)
-div r0.xyz, r1.xyzx, r0.xyzx
-log r0.xyz, |r0.xyzx|
-mul r0.xyz, r0.xyzx, l(6.277395, 6.277395, 6.277395, 0.000000)
-exp r0.xyz, r0.xyzx
-mul r0.xyz, r0.xyzx, l(10000.000000, 10000.000000, 10000.000000, 0.000000)
-dp3 r1.x, l(1.660496, -0.587656, -0.072840, 0.000000), r0.xyzx
-dp3 r1.y, l(-0.124547, 1.132895, -0.008348, 0.000000), r0.xyzx
-dp3 r1.z, l(-0.018154, -0.100597, 1.118751, 0.000000), r0.xyzx
-div r0.xyz, r1.xyzx, cb0[4].wwww
-mul r0.xyz, r0.xyzx, cb0[4].zzzz
-mul r1.xyz, r0.xyzx, l(0.012500, 0.012500, 0.012500, 0.000000)
-ne r0.w, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[4].x
-if_z r0.w
-  ge r2.xyz, l(0.250464, 0.250464, 0.250464, 0.000000), r0.xyzx
-  mul r0.xyz, r0.xyzx, l(0.161500, 0.161500, 0.161500, 0.000000)
-  log r3.xyz, |r1.xyzx|
-  mul r3.xyz, r3.xyzx, l(0.416667, 0.416667, 0.416667, 0.000000)
-  exp r3.xyz, r3.xyzx
-  mad r3.xyz, r3.xyzx, l(1.055000, 1.055000, 1.055000, 0.000000), l(-0.055000, -0.055000, -0.055000, 0.000000)
-  movc_sat r1.xyz, r2.xyzx, r0.xyzx, r3.xyzx
-endif 
-mov r1.w, l(1.000000)
-mul o0.xyzw, r1.xyzw, v2.xyzw
-ret 
-// Approximately 36 instruction slots used
-#endif
-
-const BYTE g_main[] =
-{
-     68,  88,  66,  67, 110, 205, 
-    144, 108,   2, 231, 108, 209, 
-    128, 137, 101, 210,  29,  69, 
-     41, 122,   1,   0,   0,   0, 
-    184,   9,   0,   0,   5,   0, 
-      0,   0,  52,   0,   0,   0, 
-     80,   3,   0,   0, 196,   3, 
-      0,   0, 248,   3,   0,   0, 
-     28,   9,   0,   0,  82,  68, 
-     69,  70,  20,   3,   0,   0, 
-      1,   0,   0,   0, 236,   0, 
-      0,   0,   4,   0,   0,   0, 
-     60,   0,   0,   0,   0,   5, 
-    255, 255,   0,   1,   0,   0, 
-    233,   2,   0,   0,  82,  68, 
-     49,  49,  60,   0,   0,   0, 
-     24,   0,   0,   0,  32,   0, 
-      0,   0,  40,   0,   0,   0, 
-     36,   0,   0,   0,  12,   0, 
-      0,   0,   0,   0,   0,   0, 
-    188,   0,   0,   0,   3,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   1,   0, 
-      0,   0, 199,   0,   0,   0, 
-      2,   0,   0,   0,   5,   0, 
-      0,   0,   4,   0,   0,   0, 
-    255, 255, 255, 255,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-     13,   0,   0,   0, 211,   0, 
-      0,   0,   2,   0,   0,   0, 
-      5,   0,   0,   0,   4,   0, 
-      0,   0, 255, 255, 255, 255, 
-      1,   0,   0,   0,   1,   0, 
-      0,   0,  13,   0,   0,   0, 
-    224,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   1,   0, 
-      0,   0, 116, 104, 101,  83, 
-     97, 109, 112, 108, 101, 114, 
-      0, 116, 104, 101,  84, 101, 
-    120, 116, 117, 114, 101,  89, 
-      0, 116, 104, 101,  84, 101, 
-    120, 116, 117, 114, 101,  85, 
-     86,   0,  67, 111, 110, 115, 
-    116,  97, 110, 116, 115,   0, 
-    171, 171, 224,   0,   0,   0, 
-      8,   0,   0,   0,   4,   1, 
-      0,   0,  80,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  68,   2,   0,   0, 
-      0,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     84,   2,   0,   0,   0,   0, 
-      0,   0, 255, 255, 255, 255, 
-      0,   0,   0,   0, 255, 255, 
-    255, 255,   0,   0,   0,   0, 
-    120,   2,   0,   0,  16,   0, 
-      0,   0,  16,   0,   0,   0, 
-      2,   0,   0,   0,  84,   2, 
-      0,   0,   0,   0,   0,   0, 
-    255, 255, 255, 255,   0,   0, 
-      0,   0, 255, 255, 255, 255, 
-      0,   0,   0,   0, 127,   2, 
-      0,   0,  32,   0,   0,   0, 
-     16,   0,   0,   0,   2,   0, 
-      0,   0,  84,   2,   0,   0, 
-      0,   0,   0,   0, 255, 255, 
-    255, 255,   0,   0,   0,   0, 
-    255, 255, 255, 255,   0,   0, 
-      0,   0, 134,   2,   0,   0, 
-     48,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     84,   2,   0,   0,   0,   0, 
-      0,   0, 255, 255, 255, 255, 
-      0,   0,   0,   0, 255, 255, 
-    255, 255,   0,   0,   0,   0, 
-    141,   2,   0,   0,  64,   0, 
-      0,   0,   4,   0,   0,   0, 
-      2,   0,   0,   0, 160,   2, 
-      0,   0,   0,   0,   0,   0, 
-    255, 255, 255, 255,   0,   0, 
-      0,   0, 255, 255, 255, 255, 
-      0,   0,   0,   0, 196,   2, 
-      0,   0,  68,   0,   0,   0, 
-      4,   0,   0,   0,   0,   0, 
-      0,   0, 160,   2,   0,   0, 
-      0,   0,   0,   0, 255, 255, 
-    255, 255,   0,   0,   0,   0, 
-    255, 255, 255, 255,   0,   0, 
-      0,   0, 211,   2,   0,   0, 
-     72,   0,   0,   0,   4,   0, 
-      0,   0,   2,   0,   0,   0, 
-    160,   2,   0,   0,   0,   0, 
-      0,   0, 255, 255, 255, 255, 
-      0,   0,   0,   0, 255, 255, 
-    255, 255,   0,   0,   0,   0, 
-    226,   2,   0,   0,  76,   0, 
-      0,   0,   4,   0,   0,   0, 
-      2,   0,   0,   0, 160,   2, 
-      0,   0,   0,   0,   0,   0, 
-    255, 255, 255, 255,   0,   0, 
-      0,   0, 255, 255, 255, 255, 
-      0,   0,   0,   0,  89, 111, 
-    102, 102, 115, 101, 116,   0, 
-    102, 108, 111,  97, 116,  52, 
-      0, 171,   1,   0,   3,   0, 
-      1,   0,   4,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,  76,   2, 
-      0,   0,  82,  99, 111, 101, 
-    102, 102,   0,  71,  99, 111, 
-    101, 102, 102,   0,  66,  99, 
-    111, 101, 102, 102,   0, 115, 
-     99,  82,  71,  66,  95, 111, 
-    117, 116, 112, 117, 116,   0, 
-    102, 108, 111,  97, 116,   0, 
-      0,   0,   3,   0,   1,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0, 154,   2,   0,   0, 
-     83,  68,  82,  95, 119, 104, 
-    105, 116, 101, 108, 101, 118, 
-    101, 108,   0,  72,  68,  82, 
-     95, 119, 104, 105, 116, 101, 
-    108, 101, 118, 101, 108,   0, 
-    109,  97, 120,  67,  76,  76, 
-      0,  77, 105,  99, 114, 111, 
-    115, 111, 102, 116,  32,  40, 
-     82,  41,  32,  72,  76,  83, 
-     76,  32,  83, 104,  97, 100, 
-    101, 114,  32,  67, 111, 109, 
-    112, 105, 108, 101, 114,  32, 
-     49,  48,  46,  49,   0, 171, 
-    171, 171,  73,  83,  71,  78, 
-    108,   0,   0,   0,   3,   0, 
-      0,   0,   8,   0,   0,   0, 
-     80,   0,   0,   0,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-      3,   0,   0,   0,   0,   0, 
-      0,   0,  15,   0,   0,   0, 
-     92,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,   1,   0, 
-      0,   0,   3,   3,   0,   0, 
-    101,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,   2,   0, 
-      0,   0,  15,  15,   0,   0, 
-     83,  86,  95,  80,  79,  83, 
-     73,  84,  73,  79,  78,   0, 
-     84,  69,  88,  67,  79,  79, 
-     82,  68,   0,  67,  79,  76, 
-     79,  82,   0, 171,  79,  83, 
-     71,  78,  44,   0,   0,   0, 
-      1,   0,   0,   0,   8,   0, 
-      0,   0,  32,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-      0,   0,   0,   0,  15,   0, 
-      0,   0,  83,  86,  95,  84, 
-     65,  82,  71,  69,  84,   0, 
-    171, 171,  83,  72,  69,  88, 
-     28,   5,   0,   0,  80,   0, 
-      0,   0,  71,   1,   0,   0, 
-    106,   8,   0,   1,  89,   0, 
-      0,   4,  70, 142,  32,   0, 
-      0,   0,   0,   0,   5,   0, 
-      0,   0,  90,   0,   0,   3, 
-      0,  96,  16,   0,   0,   0, 
-      0,   0,  88,  24,   0,   4, 
-      0, 112,  16,   0,   0,   0, 
-      0,   0,  85,  85,   0,   0, 
-     88,  24,   0,   4,   0, 112, 
-     16,   0,   1,   0,   0,   0, 
-     85,  85,   0,   0,  98,  16, 
-      0,   3,  50,  16,  16,   0, 
-      1,   0,   0,   0,  98,  16, 
-      0,   3, 242,  16,  16,   0, 
-      2,   0,   0,   0, 101,   0, 
-      0,   3, 242,  32,  16,   0, 
-      0,   0,   0,   0, 104,   0, 
-      0,   2,   4,   0,   0,   0, 
-     69,   0,   0, 139, 194,   0, 
-      0, 128,  67,  85,  21,   0, 
-     18,   0,  16,   0,   0,   0, 
-      0,   0,  70,  16,  16,   0, 
-      1,   0,   0,   0,  70, 126, 
-     16,   0,   0,   0,   0,   0, 
-      0,  96,  16,   0,   0,   0, 
-      0,   0,  69,   0,   0, 139, 
-    194,   0,   0, 128,  67,  85, 
-     21,   0,  98,   0,  16,   0, 
-      0,   0,   0,   0,  70,  16, 
-     16,   0,   1,   0,   0,   0, 
-     38, 125,  16,   0,   1,   0, 
-      0,   0,   0,  96,  16,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   8, 114,   0,  16,   0, 
-      0,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-     70, 130,  32,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-     16,   0,   0,   8,  18,   0, 
-     16,   0,   1,   0,   0,   0, 
-     70,   2,  16,   0,   0,   0, 
-      0,   0,  70, 130,  32,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,  16,   0,   0,   8, 
-     34,   0,  16,   0,   1,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  70, 130, 
-     32,   0,   0,   0,   0,   0, 
-      2,   0,   0,   0,  16,   0, 
-      0,   8,  66,   0,  16,   0, 
-      1,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-     70, 130,  32,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-     47,   0,   0,   6, 114,   0, 
-     16,   0,   0,   0,   0,   0, 
-     70,   2,  16, 128, 129,   0, 
-      0,   0,   1,   0,   0,   0, 
-     56,   0,   0,  10, 114,   0, 
-     16,   0,   0,   0,   0,   0, 
-     70,   2,  16,   0,   0,   0, 
-      0,   0,   2,  64,   0,   0, 
-    172, 205,  79,  60, 172, 205, 
-     79,  60, 172, 205,  79,  60, 
-      0,   0,   0,   0,  25,   0, 
-      0,   5, 114,   0,  16,   0, 
-      0,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-      0,   0,   0,  10, 114,   0, 
-     16,   0,   1,   0,   0,   0, 
-     70,   2,  16,   0,   0,   0, 
-      0,   0,   2,  64,   0,   0, 
-      0,   0,  86, 191,   0,   0, 
-     86, 191,   0,   0,  86, 191, 
-      0,   0,   0,   0,  52,   0, 
-      0,  10, 114,   0,  16,   0, 
-      1,   0,   0,   0,  70,   2, 
-     16,   0,   1,   0,   0,   0, 
-      2,  64,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  50,   0,   0,  16, 
-    114,   0,  16,   0,   0,   0, 
-      0,   0,  70,   2,  16, 128, 
-     65,   0,   0,   0,   0,   0, 
-      0,   0,   2,  64,   0,   0, 
-      0, 128, 149,  65,   0, 128, 
-    149,  65,   0, 128, 149,  65, 
-      0,   0,   0,   0,   2,  64, 
-      0,   0,   0, 208, 150,  65, 
-      0, 208, 150,  65,   0, 208, 
-    150,  65,   0,   0,   0,   0, 
-     14,   0,   0,   7, 114,   0, 
-     16,   0,   0,   0,   0,   0, 
-     70,   2,  16,   0,   1,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  47,   0, 
-      0,   6, 114,   0,  16,   0, 
-      0,   0,   0,   0,  70,   2, 
-     16, 128, 129,   0,   0,   0, 
-      0,   0,   0,   0,  56,   0, 
-      0,  10, 114,   0,  16,   0, 
-      0,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-      2,  64,   0,   0, 107, 224, 
-    200,  64, 107, 224, 200,  64, 
-    107, 224, 200,  64,   0,   0, 
-      0,   0,  25,   0,   0,   5, 
-    114,   0,  16,   0,   0,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  56,   0, 
-      0,  10, 114,   0,  16,   0, 
-      0,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-      2,  64,   0,   0,   0,  64, 
-     28,  70,   0,  64,  28,  70, 
-      0,  64,  28,  70,   0,   0, 
-      0,   0,  16,   0,   0,  10, 
-     18,   0,  16,   0,   1,   0, 
-      0,   0,   2,  64,   0,   0, 
-     34, 139, 212,  63, 160, 112, 
-     22, 191,  35,  45, 149, 189, 
-      0,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-     16,   0,   0,  10,  34,   0, 
-     16,   0,   1,   0,   0,   0, 
-      2,  64,   0,   0, 127,  18, 
-    255, 189, 180,   2, 145,  63, 
-     13, 198,   8, 188,   0,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  16,   0, 
-      0,  10,  66,   0,  16,   0, 
-      1,   0,   0,   0,   2,  64, 
-      0,   0, 179, 183, 148, 188, 
-    205,   5, 206, 189,  60,  51, 
-    143,  63,   0,   0,   0,   0, 
-     70,   2,  16,   0,   0,   0, 
-      0,   0,  14,   0,   0,   8, 
-    114,   0,  16,   0,   0,   0, 
-      0,   0,  70,   2,  16,   0, 
-      1,   0,   0,   0, 246, 143, 
-     32,   0,   0,   0,   0,   0, 
-      4,   0,   0,   0,  56,   0, 
-      0,   8, 114,   0,  16,   0, 
-      0,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-    166, 138,  32,   0,   0,   0, 
-      0,   0,   4,   0,   0,   0, 
-     56,   0,   0,  10, 114,   0, 
-     16,   0,   1,   0,   0,   0, 
-     70,   2,  16,   0,   0,   0, 
-      0,   0,   2,  64,   0,   0, 
-    205, 204,  76,  60, 205, 204, 
-     76,  60, 205, 204,  76,  60, 
-      0,   0,   0,   0,  57,   0, 
-      0,  11, 130,   0,  16,   0, 
-      0,   0,   0,   0,   2,  64, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-     10, 128,  32,   0,   0,   0, 
-      0,   0,   4,   0,   0,   0, 
-     31,   0,   0,   3,  58,   0, 
-     16,   0,   0,   0,   0,   0, 
-     29,   0,   0,  10, 114,   0, 
-     16,   0,   2,   0,   0,   0, 
-      2,  64,   0,   0, 209,  60, 
-    128,  62, 209,  60, 128,  62, 
-    209,  60, 128,  62,   0,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  56,   0, 
-      0,  10, 114,   0,  16,   0, 
-      0,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-      2,  64,   0,   0,  66,  96, 
-     37,  62,  66,  96,  37,  62, 
-     66,  96,  37,  62,   0,   0, 
-      0,   0,  47,   0,   0,   6, 
-    114,   0,  16,   0,   3,   0, 
-      0,   0,  70,   2,  16, 128, 
-    129,   0,   0,   0,   1,   0, 
-      0,   0,  56,   0,   0,  10, 
-    114,   0,  16,   0,   3,   0, 
-      0,   0,  70,   2,  16,   0, 
-      3,   0,   0,   0,   2,  64, 
-      0,   0,  85,  85, 213,  62, 
-     85,  85, 213,  62,  85,  85, 
-    213,  62,   0,   0,   0,   0, 
-     25,   0,   0,   5, 114,   0, 
-     16,   0,   3,   0,   0,   0, 
-     70,   2,  16,   0,   3,   0, 
-      0,   0,  50,   0,   0,  15, 
-    114,   0,  16,   0,   3,   0, 
-      0,   0,  70,   2,  16,   0, 
-      3,   0,   0,   0,   2,  64, 
-      0,   0,  61,  10, 135,  63, 
-     61,  10, 135,  63,  61,  10, 
-    135,  63,   0,   0,   0,   0, 
-      2,  64,   0,   0, 174,  71, 
-     97, 189, 174,  71,  97, 189, 
-    174,  71,  97, 189,   0,   0, 
-      0,   0,  55,  32,   0,   9, 
-    114,   0,  16,   0,   1,   0, 
-      0,   0,  70,   2,  16,   0, 
-      2,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-     70,   2,  16,   0,   3,   0, 
-      0,   0,  21,   0,   0,   1, 
-     54,   0,   0,   5, 130,   0, 
-     16,   0,   1,   0,   0,   0, 
-      1,  64,   0,   0,   0,   0, 
-    128,  63,  56,   0,   0,   7, 
-    242,  32,  16,   0,   0,   0, 
-      0,   0,  70,  14,  16,   0, 
-      1,   0,   0,   0,  70,  30, 
-     16,   0,   2,   0,   0,   0, 
-     62,   0,   0,   1,  83,  84, 
-     65,  84, 148,   0,   0,   0, 
-     36,   0,   0,   0,   4,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,  28,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   1,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   2,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   1,   0,   0,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0
-};
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Buffer Definitions: 
+//
+// cbuffer Constants
+// {
+//
+//   float scRGB_output;                // Offset:    0 Size:     4
+//   float SDR_whitelevel;              // Offset:    4 Size:     4 [unused]
+//   float HDR_whitelevel;              // Offset:    8 Size:     4
+//   float maxCLL;                      // Offset:   12 Size:     4
+//   float4 Yoffset;                    // Offset:   16 Size:    16
+//   float4 Rcoeff;                     // Offset:   32 Size:    16
+//   float4 Gcoeff;                     // Offset:   48 Size:    16
+//   float4 Bcoeff;                     // Offset:   64 Size:    16
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim      HLSL Bind  Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// theSampler                        sampler      NA          NA             s0      1 
+// theTextureY                       texture  float4          2d             t0      1 
+// theTextureUV                      texture  float4          2d             t1      1 
+// Constants                         cbuffer      NA          NA            cb0      1 
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION              0   xyzw        0      POS   float       
+// TEXCOORD                 0   xy          1     NONE   float   xy  
+// COLOR                    0   xyzw        2     NONE   float   xyzw
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
+//
+ps_5_0
+dcl_globalFlags refactoringAllowed
+dcl_constantbuffer CB0[5], immediateIndexed
+dcl_sampler s0, mode_default
+dcl_resource_texture2d (float,float,float,float) t0
+dcl_resource_texture2d (float,float,float,float) t1
+dcl_input_ps linear v1.xy
+dcl_input_ps linear v2.xyzw
+dcl_output o0.xyzw
+dcl_temps 4
+sample_indexable(texture2d)(float,float,float,float) r0.x, v1.xyxx, t0.xyzw, s0
+sample_indexable(texture2d)(float,float,float,float) r0.yz, v1.xyxx, t1.zxyw, s0
+add r0.xyz, r0.xyzx, cb0[1].xyzx
+dp3 r1.x, r0.xyzx, cb0[2].xyzx
+dp3 r1.y, r0.xyzx, cb0[3].xyzx
+dp3 r1.z, r0.xyzx, cb0[4].xyzx
+log r0.xyz, |r1.xyzx|
+mul r0.xyz, r0.xyzx, l(0.012683, 0.012683, 0.012683, 0.000000)
+exp r0.xyz, r0.xyzx
+add r1.xyz, r0.xyzx, l(-0.835938, -0.835938, -0.835938, 0.000000)
+max r1.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
+mad r0.xyz, -r0.xyzx, l(18.687500, 18.687500, 18.687500, 0.000000), l(18.851562, 18.851562, 18.851562, 0.000000)
+div r0.xyz, r1.xyzx, r0.xyzx
+log r0.xyz, |r0.xyzx|
+mul r0.xyz, r0.xyzx, l(6.277395, 6.277395, 6.277395, 0.000000)
+exp r0.xyz, r0.xyzx
+mul r0.xyz, r0.xyzx, l(10000.000000, 10000.000000, 10000.000000, 0.000000)
+dp3 r1.x, l(1.660496, -0.587656, -0.072840, 0.000000), r0.xyzx
+dp3 r1.y, l(-0.124547, 1.132895, -0.008348, 0.000000), r0.xyzx
+dp3 r1.z, l(-0.018154, -0.100597, 1.118751, 0.000000), r0.xyzx
+div r0.xyz, r1.xyzx, cb0[0].wwww
+mul r0.xyz, r0.xyzx, cb0[0].zzzz
+mul r1.xyz, r0.xyzx, l(0.012500, 0.012500, 0.012500, 0.000000)
+ne r0.w, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x
+if_z r0.w
+  ge r2.xyz, l(0.250464, 0.250464, 0.250464, 0.000000), r0.xyzx
+  mul r0.xyz, r0.xyzx, l(0.161500, 0.161500, 0.161500, 0.000000)
+  log r3.xyz, |r1.xyzx|
+  mul r3.xyz, r3.xyzx, l(0.416667, 0.416667, 0.416667, 0.000000)
+  exp r3.xyz, r3.xyzx
+  mad r3.xyz, r3.xyzx, l(1.055000, 1.055000, 1.055000, 0.000000), l(-0.055000, -0.055000, -0.055000, 0.000000)
+  movc_sat r1.xyz, r2.xyzx, r0.xyzx, r3.xyzx
+endif 
+mov r1.w, l(1.000000)
+mul o0.xyzw, r1.xyzw, v2.xyzw
+ret 
+// Approximately 36 instruction slots used
+#endif
+
+const BYTE g_main[] =
+{
+     68,  88,  66,  67,  39,  74, 
+    221, 114,  82,  86,  93, 130, 
+      9, 184,  52, 173, 245, 104, 
+     96, 202,   1,   0,   0,   0, 
+    184,   9,   0,   0,   5,   0, 
+      0,   0,  52,   0,   0,   0, 
+     80,   3,   0,   0, 196,   3, 
+      0,   0, 248,   3,   0,   0, 
+     28,   9,   0,   0,  82,  68, 
+     69,  70,  20,   3,   0,   0, 
+      1,   0,   0,   0, 236,   0, 
+      0,   0,   4,   0,   0,   0, 
+     60,   0,   0,   0,   0,   5, 
+    255, 255,   0,   1,   0,   0, 
+    233,   2,   0,   0,  82,  68, 
+     49,  49,  60,   0,   0,   0, 
+     24,   0,   0,   0,  32,   0, 
+      0,   0,  40,   0,   0,   0, 
+     36,   0,   0,   0,  12,   0, 
+      0,   0,   0,   0,   0,   0, 
+    188,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0, 199,   0,   0,   0, 
+      2,   0,   0,   0,   5,   0, 
+      0,   0,   4,   0,   0,   0, 
+    255, 255, 255, 255,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+     13,   0,   0,   0, 211,   0, 
+      0,   0,   2,   0,   0,   0, 
+      5,   0,   0,   0,   4,   0, 
+      0,   0, 255, 255, 255, 255, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,  13,   0,   0,   0, 
+    224,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0, 116, 104, 101,  83, 
+     97, 109, 112, 108, 101, 114, 
+      0, 116, 104, 101,  84, 101, 
+    120, 116, 117, 114, 101,  89, 
+      0, 116, 104, 101,  84, 101, 
+    120, 116, 117, 114, 101,  85, 
+     86,   0,  67, 111, 110, 115, 
+    116,  97, 110, 116, 115,   0, 
+    171, 171, 224,   0,   0,   0, 
+      8,   0,   0,   0,   4,   1, 
+      0,   0,  80,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  68,   2,   0,   0, 
+      0,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+     88,   2,   0,   0,   0,   0, 
+      0,   0, 255, 255, 255, 255, 
+      0,   0,   0,   0, 255, 255, 
+    255, 255,   0,   0,   0,   0, 
+    124,   2,   0,   0,   4,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0,  88,   2, 
+      0,   0,   0,   0,   0,   0, 
+    255, 255, 255, 255,   0,   0, 
+      0,   0, 255, 255, 255, 255, 
+      0,   0,   0,   0, 139,   2, 
+      0,   0,   8,   0,   0,   0, 
+      4,   0,   0,   0,   2,   0, 
+      0,   0,  88,   2,   0,   0, 
+      0,   0,   0,   0, 255, 255, 
+    255, 255,   0,   0,   0,   0, 
+    255, 255, 255, 255,   0,   0, 
+      0,   0, 154,   2,   0,   0, 
+     12,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+     88,   2,   0,   0,   0,   0, 
+      0,   0, 255, 255, 255, 255, 
+      0,   0,   0,   0, 255, 255, 
+    255, 255,   0,   0,   0,   0, 
+    161,   2,   0,   0,  16,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 176,   2, 
+      0,   0,   0,   0,   0,   0, 
+    255, 255, 255, 255,   0,   0, 
+      0,   0, 255, 255, 255, 255, 
+      0,   0,   0,   0, 212,   2, 
+      0,   0,  32,   0,   0,   0, 
+     16,   0,   0,   0,   2,   0, 
+      0,   0, 176,   2,   0,   0, 
+      0,   0,   0,   0, 255, 255, 
+    255, 255,   0,   0,   0,   0, 
+    255, 255, 255, 255,   0,   0, 
+      0,   0, 219,   2,   0,   0, 
+     48,   0,   0,   0,  16,   0, 
+      0,   0,   2,   0,   0,   0, 
+    176,   2,   0,   0,   0,   0, 
+      0,   0, 255, 255, 255, 255, 
+      0,   0,   0,   0, 255, 255, 
+    255, 255,   0,   0,   0,   0, 
+    226,   2,   0,   0,  64,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 176,   2, 
+      0,   0,   0,   0,   0,   0, 
+    255, 255, 255, 255,   0,   0, 
+      0,   0, 255, 255, 255, 255, 
+      0,   0,   0,   0, 115,  99, 
+     82,  71,  66,  95, 111, 117, 
+    116, 112, 117, 116,   0, 102, 
+    108, 111,  97, 116,   0, 171, 
+      0,   0,   3,   0,   1,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  81,   2,   0,   0, 
+     83,  68,  82,  95, 119, 104, 
+    105, 116, 101, 108, 101, 118, 
+    101, 108,   0,  72,  68,  82, 
+     95, 119, 104, 105, 116, 101, 
+    108, 101, 118, 101, 108,   0, 
+    109,  97, 120,  67,  76,  76, 
+      0,  89, 111, 102, 102, 115, 
+    101, 116,   0, 102, 108, 111, 
+     97, 116,  52,   0,   1,   0, 
+      3,   0,   1,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+    169,   2,   0,   0,  82,  99, 
+    111, 101, 102, 102,   0,  71, 
+     99, 111, 101, 102, 102,   0, 
+     66,  99, 111, 101, 102, 102, 
+      0,  77, 105,  99, 114, 111, 
+    115, 111, 102, 116,  32,  40, 
+     82,  41,  32,  72,  76,  83, 
+     76,  32,  83, 104,  97, 100, 
+    101, 114,  32,  67, 111, 109, 
+    112, 105, 108, 101, 114,  32, 
+     49,  48,  46,  49,   0, 171, 
+    171, 171,  73,  83,  71,  78, 
+    108,   0,   0,   0,   3,   0, 
+      0,   0,   8,   0,   0,   0, 
+     80,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+     92,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   1,   0, 
+      0,   0,   3,   3,   0,   0, 
+    101,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   2,   0, 
+      0,   0,  15,  15,   0,   0, 
+     83,  86,  95,  80,  79,  83, 
+     73,  84,  73,  79,  78,   0, 
+     84,  69,  88,  67,  79,  79, 
+     82,  68,   0,  67,  79,  76, 
+     79,  82,   0, 171,  79,  83, 
+     71,  78,  44,   0,   0,   0, 
+      1,   0,   0,   0,   8,   0, 
+      0,   0,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  83,  86,  95,  84, 
+     65,  82,  71,  69,  84,   0, 
+    171, 171,  83,  72,  69,  88, 
+     28,   5,   0,   0,  80,   0, 
+      0,   0,  71,   1,   0,   0, 
+    106,   8,   0,   1,  89,   0, 
+      0,   4,  70, 142,  32,   0, 
+      0,   0,   0,   0,   5,   0, 
+      0,   0,  90,   0,   0,   3, 
+      0,  96,  16,   0,   0,   0, 
+      0,   0,  88,  24,   0,   4, 
+      0, 112,  16,   0,   0,   0, 
+      0,   0,  85,  85,   0,   0, 
+     88,  24,   0,   4,   0, 112, 
+     16,   0,   1,   0,   0,   0, 
+     85,  85,   0,   0,  98,  16, 
+      0,   3,  50,  16,  16,   0, 
+      1,   0,   0,   0,  98,  16, 
+      0,   3, 242,  16,  16,   0, 
+      2,   0,   0,   0, 101,   0, 
+      0,   3, 242,  32,  16,   0, 
+      0,   0,   0,   0, 104,   0, 
+      0,   2,   4,   0,   0,   0, 
+     69,   0,   0, 139, 194,   0, 
+      0, 128,  67,  85,  21,   0, 
+     18,   0,  16,   0,   0,   0, 
+      0,   0,  70,  16,  16,   0, 
+      1,   0,   0,   0,  70, 126, 
+     16,   0,   0,   0,   0,   0, 
+      0,  96,  16,   0,   0,   0, 
+      0,   0,  69,   0,   0, 139, 
+    194,   0,   0, 128,  67,  85, 
+     21,   0,  98,   0,  16,   0, 
+      0,   0,   0,   0,  70,  16, 
+     16,   0,   1,   0,   0,   0, 
+     38, 125,  16,   0,   1,   0, 
+      0,   0,   0,  96,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   8, 114,   0,  16,   0, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+     70, 130,  32,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+     16,   0,   0,   8,  18,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,   2,  16,   0,   0,   0, 
+      0,   0,  70, 130,  32,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,  16,   0,   0,   8, 
+     34,   0,  16,   0,   1,   0, 
+      0,   0,  70,   2,  16,   0, 
+      0,   0,   0,   0,  70, 130, 
+     32,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,  16,   0, 
+      0,   8,  66,   0,  16,   0, 
+      1,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+     70, 130,  32,   0,   0,   0, 
+      0,   0,   4,   0,   0,   0, 
+     47,   0,   0,   6, 114,   0, 
+     16,   0,   0,   0,   0,   0, 
+     70,   2,  16, 128, 129,   0, 
+      0,   0,   1,   0,   0,   0, 
+     56,   0,   0,  10, 114,   0, 
+     16,   0,   0,   0,   0,   0, 
+     70,   2,  16,   0,   0,   0, 
+      0,   0,   2,  64,   0,   0, 
+    172, 205,  79,  60, 172, 205, 
+     79,  60, 172, 205,  79,  60, 
+      0,   0,   0,   0,  25,   0, 
+      0,   5, 114,   0,  16,   0, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+      0,   0,   0,  10, 114,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,   2,  16,   0,   0,   0, 
+      0,   0,   2,  64,   0,   0, 
+      0,   0,  86, 191,   0,   0, 
+     86, 191,   0,   0,  86, 191, 
+      0,   0,   0,   0,  52,   0, 
+      0,  10, 114,   0,  16,   0, 
+      1,   0,   0,   0,  70,   2, 
+     16,   0,   1,   0,   0,   0, 
+      2,  64,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  50,   0,   0,  16, 
+    114,   0,  16,   0,   0,   0, 
+      0,   0,  70,   2,  16, 128, 
+     65,   0,   0,   0,   0,   0, 
+      0,   0,   2,  64,   0,   0, 
+      0, 128, 149,  65,   0, 128, 
+    149,  65,   0, 128, 149,  65, 
+      0,   0,   0,   0,   2,  64, 
+      0,   0,   0, 208, 150,  65, 
+      0, 208, 150,  65,   0, 208, 
+    150,  65,   0,   0,   0,   0, 
+     14,   0,   0,   7, 114,   0, 
+     16,   0,   0,   0,   0,   0, 
+     70,   2,  16,   0,   1,   0, 
+      0,   0,  70,   2,  16,   0, 
+      0,   0,   0,   0,  47,   0, 
+      0,   6, 114,   0,  16,   0, 
+      0,   0,   0,   0,  70,   2, 
+     16, 128, 129,   0,   0,   0, 
+      0,   0,   0,   0,  56,   0, 
+      0,  10, 114,   0,  16,   0, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+      2,  64,   0,   0, 107, 224, 
+    200,  64, 107, 224, 200,  64, 
+    107, 224, 200,  64,   0,   0, 
+      0,   0,  25,   0,   0,   5, 
+    114,   0,  16,   0,   0,   0, 
+      0,   0,  70,   2,  16,   0, 
+      0,   0,   0,   0,  56,   0, 
+      0,  10, 114,   0,  16,   0, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+      2,  64,   0,   0,   0,  64, 
+     28,  70,   0,  64,  28,  70, 
+      0,  64,  28,  70,   0,   0, 
+      0,   0,  16,   0,   0,  10, 
+     18,   0,  16,   0,   1,   0, 
+      0,   0,   2,  64,   0,   0, 
+     34, 139, 212,  63, 160, 112, 
+     22, 191,  35,  45, 149, 189, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+     16,   0,   0,  10,  34,   0, 
+     16,   0,   1,   0,   0,   0, 
+      2,  64,   0,   0, 127,  18, 
+    255, 189, 180,   2, 145,  63, 
+     13, 198,   8, 188,   0,   0, 
+      0,   0,  70,   2,  16,   0, 
+      0,   0,   0,   0,  16,   0, 
+      0,  10,  66,   0,  16,   0, 
+      1,   0,   0,   0,   2,  64, 
+      0,   0, 179, 183, 148, 188, 
+    205,   5, 206, 189,  60,  51, 
+    143,  63,   0,   0,   0,   0, 
+     70,   2,  16,   0,   0,   0, 
+      0,   0,  14,   0,   0,   8, 
+    114,   0,  16,   0,   0,   0, 
+      0,   0,  70,   2,  16,   0, 
+      1,   0,   0,   0, 246, 143, 
+     32,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  56,   0, 
+      0,   8, 114,   0,  16,   0, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+    166, 138,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     56,   0,   0,  10, 114,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,   2,  16,   0,   0,   0, 
+      0,   0,   2,  64,   0,   0, 
+    205, 204,  76,  60, 205, 204, 
+     76,  60, 205, 204,  76,  60, 
+      0,   0,   0,   0,  57,   0, 
+      0,  11, 130,   0,  16,   0, 
+      0,   0,   0,   0,   2,  64, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     10, 128,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     31,   0,   0,   3,  58,   0, 
+     16,   0,   0,   0,   0,   0, 
+     29,   0,   0,  10, 114,   0, 
+     16,   0,   2,   0,   0,   0, 
+      2,  64,   0,   0, 209,  60, 
+    128,  62, 209,  60, 128,  62, 
+    209,  60, 128,  62,   0,   0, 
+      0,   0,  70,   2,  16,   0, 
+      0,   0,   0,   0,  56,   0, 
+      0,  10, 114,   0,  16,   0, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+      2,  64,   0,   0,  66,  96, 
+     37,  62,  66,  96,  37,  62, 
+     66,  96,  37,  62,   0,   0, 
+      0,   0,  47,   0,   0,   6, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16, 128, 
+    129,   0,   0,   0,   1,   0, 
+      0,   0,  56,   0,   0,  10, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16,   0, 
+      3,   0,   0,   0,   2,  64, 
+      0,   0,  85,  85, 213,  62, 
+     85,  85, 213,  62,  85,  85, 
+    213,  62,   0,   0,   0,   0, 
+     25,   0,   0,   5, 114,   0, 
+     16,   0,   3,   0,   0,   0, 
+     70,   2,  16,   0,   3,   0, 
+      0,   0,  50,   0,   0,  15, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16,   0, 
+      3,   0,   0,   0,   2,  64, 
+      0,   0,  61,  10, 135,  63, 
+     61,  10, 135,  63,  61,  10, 
+    135,  63,   0,   0,   0,   0, 
+      2,  64,   0,   0, 174,  71, 
+     97, 189, 174,  71,  97, 189, 
+    174,  71,  97, 189,   0,   0, 
+      0,   0,  55,  32,   0,   9, 
+    114,   0,  16,   0,   1,   0, 
+      0,   0,  70,   2,  16,   0, 
+      2,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+     70,   2,  16,   0,   3,   0, 
+      0,   0,  21,   0,   0,   1, 
+     54,   0,   0,   5, 130,   0, 
+     16,   0,   1,   0,   0,   0, 
+      1,  64,   0,   0,   0,   0, 
+    128,  63,  56,   0,   0,   7, 
+    242,  32,  16,   0,   0,   0, 
+      0,   0,  70,  14,  16,   0, 
+      1,   0,   0,   0,  70,  30, 
+     16,   0,   2,   0,   0,   0, 
+     62,   0,   0,   1,  83,  84, 
+     65,  84, 148,   0,   0,   0, 
+     36,   0,   0,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,  28,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   2,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0
+};

+ 3 - 37
src/render/direct3d11/D3D11_PixelShader_HDR10.hlsl

@@ -2,41 +2,7 @@ Texture2D theTextureY : register(t0);
 Texture2D theTextureUV : register(t1);
 SamplerState theSampler : register(s0);
 
-struct PixelShaderInput
-{
-    float4 pos : SV_POSITION;
-    float2 tex : TEXCOORD0;
-    float4 color : COLOR0;
-};
-
-cbuffer Constants : register(b0)
-{
-    float4 Yoffset;
-    float4 Rcoeff;
-    float4 Gcoeff;
-    float4 Bcoeff;
-
-    float scRGB_output;
-    float SDR_whitelevel;
-    float HDR_whitelevel;
-    float maxCLL;
-};
-
-
-float3 scRGBfromNits(float3 v)
-{
-    return v / 80.0;
-}
-
-float sRGBfromLinear(float v)
-{
-    if (v <= 0.0031308) {
-        v = (v * 12.92);
-    } else {
-        v = (pow(abs(v), 1.0 / 2.4) * 1.055 - 0.055);
-    }
-    return v;
-}
+#include "D3D11_PixelShader_Common.incl"
 
 float3 PQtoNits(float3 v)
 {
@@ -58,6 +24,7 @@ float4 main(PixelShaderInput input) : SV_TARGET
         -0.124547, 1.132895, -0.008348,
         -0.018154, -0.100597, 1.118751
     };
+    float4 Output;
 
     float3 yuv;
     yuv.x = theTextureY.Sample(theSampler, input.tex).r;
@@ -84,9 +51,8 @@ float4 main(PixelShaderInput input) : SV_TARGET
         rgb.rgb = clamp(rgb.rgb, 0.0, 1.0);
     }
 
-    float4 Output;
     Output.rgb = rgb.rgb;
-    Output.a = 1.0f;
+    Output.a = 1.0;
 
     return Output * input.color;
 }

+ 537 - 347
src/render/direct3d11/D3D11_PixelShader_NV12.h

@@ -1,347 +1,537 @@
-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
-//
-//
-// Buffer Definitions: 
-//
-// cbuffer Constants
-// {
-//
-//   float4 Yoffset;                    // Offset:    0 Size:    16
-//   float4 Rcoeff;                     // Offset:   16 Size:    16
-//   float4 Gcoeff;                     // Offset:   32 Size:    16
-//   float4 Bcoeff;                     // Offset:   48 Size:    16
-//
-// }
-//
-//
-// Resource Bindings:
-//
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// theSampler                        sampler      NA          NA             s0      1 
-// theTextureY                       texture  float4          2d             t0      1 
-// theTextureUV                      texture  float4          2d             t1      1 
-// Constants                         cbuffer      NA          NA            cb0      1 
-//
-//
-//
-// Input signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_POSITION              0   xyzw        0      POS   float       
-// TEXCOORD                 0   xy          1     NONE   float   xy  
-// COLOR                    0   xyzw        2     NONE   float   xyzw
-//
-//
-// Output signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
-//
-//
-// Constant buffer to DX9 shader constant mappings:
-//
-// Target Reg Buffer  Start Reg # of Regs        Data Conversion
-// ---------- ------- --------- --------- ----------------------
-// c0         cb0             0         4  ( FLT, FLT, FLT, FLT)
-//
-//
-// Sampler/Resource to DX9 shader sampler mappings:
-//
-// Target Sampler Source Sampler  Source Resource
-// -------------- --------------- ----------------
-// s0             s0              t0               
-// s1             s0              t1               
-//
-//
-// Level9 shader bytecode:
-//
-    ps_2_0
-    def c4, 1, 0, 0, 0
-    dcl t0.xy
-    dcl t1
-    dcl_2d s0
-    dcl_2d s1
-    texld r0, t0, s0
-    texld r1, t0, s1
-    mov r0.yz, r1.zxyw
-    add r0.xyz, r0, c0
-    dp3 r1.x, r0, c1
-    dp3 r1.y, r0, c2
-    dp3 r1.z, r0, c3
-    mov r1.w, c4.x
-    mul r0, r1, t1
-    mov oC0, r0
-
-// approximately 10 instruction slots used (2 texture, 8 arithmetic)
-ps_4_0
-dcl_constantbuffer CB0[4], immediateIndexed
-dcl_sampler s0, mode_default
-dcl_resource_texture2d (float,float,float,float) t0
-dcl_resource_texture2d (float,float,float,float) t1
-dcl_input_ps linear v1.xy
-dcl_input_ps linear v2.xyzw
-dcl_output o0.xyzw
-dcl_temps 2
-sample r0.xyzw, v1.xyxx, t0.xyzw, s0
-sample r1.xyzw, v1.xyxx, t1.xyzw, s0
-mov r0.yz, r1.xxyx
-add r0.xyz, r0.xyzx, cb0[0].xyzx
-dp3 r1.x, r0.xyzx, cb0[1].xyzx
-dp3 r1.y, r0.xyzx, cb0[2].xyzx
-dp3 r1.z, r0.xyzx, cb0[3].xyzx
-mov r1.w, l(1.000000)
-mul o0.xyzw, r1.xyzw, v2.xyzw
-ret 
-// Approximately 10 instruction slots used
-#endif
-
-const BYTE g_main[] =
-{
-     68,  88,  66,  67, 141, 213, 
-    118,  74,  78,  95, 162,   4, 
-    201,  30, 199,  78,  91, 203, 
-    113,   9,   1,   0,   0,   0, 
-    172,   5,   0,   0,   6,   0, 
-      0,   0,  56,   0,   0,   0, 
-     92,   1,   0,   0, 228,   2, 
-      0,   0,  96,   3,   0,   0, 
-      4,   5,   0,   0, 120,   5, 
-      0,   0,  65, 111, 110,  57, 
-     28,   1,   0,   0,  28,   1, 
-      0,   0,   0,   2, 255, 255, 
-    228,   0,   0,   0,  56,   0, 
-      0,   0,   1,   0,  44,   0, 
-      0,   0,  56,   0,   0,   0, 
-     56,   0,   2,   0,  36,   0, 
-      0,   0,  56,   0,   0,   0, 
-      0,   0,   1,   0,   1,   0, 
-      0,   0,   0,   0,   4,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   2, 255, 255,  81,   0, 
-      0,   5,   4,   0,  15, 160, 
-      0,   0, 128,  63,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,  31,   0, 
-      0,   2,   0,   0,   0, 128, 
-      0,   0,   3, 176,  31,   0, 
-      0,   2,   0,   0,   0, 128, 
-      1,   0,  15, 176,  31,   0, 
-      0,   2,   0,   0,   0, 144, 
-      0,   8,  15, 160,  31,   0, 
-      0,   2,   0,   0,   0, 144, 
-      1,   8,  15, 160,  66,   0, 
-      0,   3,   0,   0,  15, 128, 
-      0,   0, 228, 176,   0,   8, 
-    228, 160,  66,   0,   0,   3, 
-      1,   0,  15, 128,   0,   0, 
-    228, 176,   1,   8, 228, 160, 
-      1,   0,   0,   2,   0,   0, 
-      6, 128,   1,   0, 210, 128, 
-      2,   0,   0,   3,   0,   0, 
-      7, 128,   0,   0, 228, 128, 
-      0,   0, 228, 160,   8,   0, 
-      0,   3,   1,   0,   1, 128, 
-      0,   0, 228, 128,   1,   0, 
-    228, 160,   8,   0,   0,   3, 
-      1,   0,   2, 128,   0,   0, 
-    228, 128,   2,   0, 228, 160, 
-      8,   0,   0,   3,   1,   0, 
-      4, 128,   0,   0, 228, 128, 
-      3,   0, 228, 160,   1,   0, 
-      0,   2,   1,   0,   8, 128, 
-      4,   0,   0, 160,   5,   0, 
-      0,   3,   0,   0,  15, 128, 
-      1,   0, 228, 128,   1,   0, 
-    228, 176,   1,   0,   0,   2, 
-      0,   8,  15, 128,   0,   0, 
-    228, 128, 255, 255,   0,   0, 
-     83,  72,  68,  82, 128,   1, 
-      0,   0,  64,   0,   0,   0, 
-     96,   0,   0,   0,  89,   0, 
-      0,   4,  70, 142,  32,   0, 
-      0,   0,   0,   0,   4,   0, 
-      0,   0,  90,   0,   0,   3, 
-      0,  96,  16,   0,   0,   0, 
-      0,   0,  88,  24,   0,   4, 
-      0, 112,  16,   0,   0,   0, 
-      0,   0,  85,  85,   0,   0, 
-     88,  24,   0,   4,   0, 112, 
-     16,   0,   1,   0,   0,   0, 
-     85,  85,   0,   0,  98,  16, 
-      0,   3,  50,  16,  16,   0, 
-      1,   0,   0,   0,  98,  16, 
-      0,   3, 242,  16,  16,   0, 
-      2,   0,   0,   0, 101,   0, 
-      0,   3, 242,  32,  16,   0, 
-      0,   0,   0,   0, 104,   0, 
-      0,   2,   2,   0,   0,   0, 
-     69,   0,   0,   9, 242,   0, 
-     16,   0,   0,   0,   0,   0, 
-     70,  16,  16,   0,   1,   0, 
-      0,   0,  70, 126,  16,   0, 
-      0,   0,   0,   0,   0,  96, 
-     16,   0,   0,   0,   0,   0, 
-     69,   0,   0,   9, 242,   0, 
-     16,   0,   1,   0,   0,   0, 
-     70,  16,  16,   0,   1,   0, 
-      0,   0,  70, 126,  16,   0, 
-      1,   0,   0,   0,   0,  96, 
-     16,   0,   0,   0,   0,   0, 
-     54,   0,   0,   5,  98,   0, 
-     16,   0,   0,   0,   0,   0, 
-      6,   1,  16,   0,   1,   0, 
-      0,   0,   0,   0,   0,   8, 
-    114,   0,  16,   0,   0,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  70, 130, 
-     32,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,  16,   0, 
-      0,   8,  18,   0,  16,   0, 
-      1,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-     70, 130,  32,   0,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-     16,   0,   0,   8,  34,   0, 
-     16,   0,   1,   0,   0,   0, 
-     70,   2,  16,   0,   0,   0, 
-      0,   0,  70, 130,  32,   0, 
-      0,   0,   0,   0,   2,   0, 
-      0,   0,  16,   0,   0,   8, 
-     66,   0,  16,   0,   1,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  70, 130, 
-     32,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,  54,   0, 
-      0,   5, 130,   0,  16,   0, 
-      1,   0,   0,   0,   1,  64, 
-      0,   0,   0,   0, 128,  63, 
-     56,   0,   0,   7, 242,  32, 
-     16,   0,   0,   0,   0,   0, 
-     70,  14,  16,   0,   1,   0, 
-      0,   0,  70,  30,  16,   0, 
-      2,   0,   0,   0,  62,   0, 
-      0,   1,  83,  84,  65,  84, 
-    116,   0,   0,   0,  10,   0, 
-      0,   0,   2,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   5,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      2,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   2,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-     82,  68,  69,  70, 156,   1, 
-      0,   0,   1,   0,   0,   0, 
-    204,   0,   0,   0,   4,   0, 
-      0,   0,  28,   0,   0,   0, 
-      0,   4, 255, 255,   0,   1, 
-      0,   0, 113,   1,   0,   0, 
-    156,   0,   0,   0,   3,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   1,   0, 
-      0,   0, 167,   0,   0,   0, 
-      2,   0,   0,   0,   5,   0, 
-      0,   0,   4,   0,   0,   0, 
-    255, 255, 255, 255,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-     13,   0,   0,   0, 179,   0, 
-      0,   0,   2,   0,   0,   0, 
-      5,   0,   0,   0,   4,   0, 
-      0,   0, 255, 255, 255, 255, 
-      1,   0,   0,   0,   1,   0, 
-      0,   0,  13,   0,   0,   0, 
-    192,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   1,   0, 
-      0,   0, 116, 104, 101,  83, 
-     97, 109, 112, 108, 101, 114, 
-      0, 116, 104, 101,  84, 101, 
-    120, 116, 117, 114, 101,  89, 
-      0, 116, 104, 101,  84, 101, 
-    120, 116, 117, 114, 101,  85, 
-     86,   0,  67, 111, 110, 115, 
-    116,  97, 110, 116, 115,   0, 
-    171, 171, 192,   0,   0,   0, 
-      4,   0,   0,   0, 228,   0, 
-      0,   0,  64,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  68,   1,   0,   0, 
-      0,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     76,   1,   0,   0,   0,   0, 
-      0,   0,  92,   1,   0,   0, 
-     16,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     76,   1,   0,   0,   0,   0, 
-      0,   0,  99,   1,   0,   0, 
-     32,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     76,   1,   0,   0,   0,   0, 
-      0,   0, 106,   1,   0,   0, 
-     48,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     76,   1,   0,   0,   0,   0, 
-      0,   0,  89, 111, 102, 102, 
-    115, 101, 116,   0,   1,   0, 
-      3,   0,   1,   0,   4,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  82,  99, 111, 101, 
-    102, 102,   0,  71,  99, 111, 
-    101, 102, 102,   0,  66,  99, 
-    111, 101, 102, 102,   0,  77, 
-    105,  99, 114, 111, 115, 111, 
-    102, 116,  32,  40,  82,  41, 
-     32,  72,  76,  83,  76,  32, 
-     83, 104,  97, 100, 101, 114, 
-     32,  67, 111, 109, 112, 105, 
-    108, 101, 114,  32,  49,  48, 
-     46,  49,   0, 171, 171, 171, 
-     73,  83,  71,  78, 108,   0, 
-      0,   0,   3,   0,   0,   0, 
-      8,   0,   0,   0,  80,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   3,   0, 
-      0,   0,   0,   0,   0,   0, 
-     15,   0,   0,   0,  92,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   1,   0,   0,   0, 
-      3,   3,   0,   0, 101,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   2,   0,   0,   0, 
-     15,  15,   0,   0,  83,  86, 
-     95,  80,  79,  83,  73,  84, 
-     73,  79,  78,   0,  84,  69, 
-     88,  67,  79,  79,  82,  68, 
-      0,  67,  79,  76,  79,  82, 
-      0, 171,  79,  83,  71,  78, 
-     44,   0,   0,   0,   1,   0, 
-      0,   0,   8,   0,   0,   0, 
-     32,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,   0,   0, 
-      0,   0,  15,   0,   0,   0, 
-     83,  86,  95,  84,  65,  82, 
-     71,  69,  84,   0, 171, 171
-};
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Buffer Definitions: 
+//
+// cbuffer Constants
+// {
+//
+//   float scRGB_output;                // Offset:    0 Size:     4
+//   float SDR_whitelevel;              // Offset:    4 Size:     4 [unused]
+//   float HDR_whitelevel;              // Offset:    8 Size:     4 [unused]
+//   float maxCLL;                      // Offset:   12 Size:     4 [unused]
+//   float4 Yoffset;                    // Offset:   16 Size:    16
+//   float4 Rcoeff;                     // Offset:   32 Size:    16
+//   float4 Gcoeff;                     // Offset:   48 Size:    16
+//   float4 Bcoeff;                     // Offset:   64 Size:    16
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim      HLSL Bind  Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// theSampler                        sampler      NA          NA             s0      1 
+// theTextureY                       texture  float4          2d             t0      1 
+// theTextureUV                      texture  float4          2d             t1      1 
+// Constants                         cbuffer      NA          NA            cb0      1 
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION              0   xyzw        0      POS   float       
+// TEXCOORD                 0   xy          1     NONE   float   xy  
+// COLOR                    0   xyzw        2     NONE   float   xyzw
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
+//
+//
+// Constant buffer to DX9 shader constant mappings:
+//
+// Target Reg Buffer  Start Reg # of Regs        Data Conversion
+// ---------- ------- --------- --------- ----------------------
+// c0         cb0             0         5  ( FLT, FLT, FLT, FLT)
+//
+//
+// Sampler/Resource to DX9 shader sampler mappings:
+//
+// Target Sampler Source Sampler  Source Resource
+// -------------- --------------- ----------------
+// s0             s0              t0               
+// s1             s0              t1               
+//
+//
+// Level9 shader bytecode:
+//
+    ps_2_0
+    def c5, 0.0404499993, 0.0773993805, 0.0549999997, 0.947867334
+    def c6, 2.4000001, 1, 0, 0
+    dcl t0.xy
+    dcl t1
+    dcl_2d s0
+    dcl_2d s1
+    texld r0, t0, s0
+    texld r1, t0, s1
+    mov r0.yz, r1.zxyw
+    add r0.xyz, r0, c1
+    dp3 r1.x, r0, c2
+    add r0.w, r1.x, c5.z
+    abs r0.w, r0.w
+    mul r0.w, r0.w, c5.w
+    pow r1.w, r0.w, c6.x
+    add r0.w, -r1.x, c5.x
+    mul r2.w, r1.x, c5.y
+    cmp r2.x, r0.w, r2.w, r1.w
+    dp3 r1.y, r0, c3
+    dp3 r1.z, r0, c4
+    add r1.w, r1.y, c5.z
+    abs r1.w, r1.w
+    mul r1.w, r1.w, c5.w
+    pow r2.w, r1.w, c6.x
+    add r1.w, -r1.y, c5.x
+    mul r0.x, r1.y, c5.y
+    cmp r2.y, r1.w, r0.x, r2.w
+    add r1.w, r1.z, c5.z
+    abs r1.w, r1.w
+    mul r1.w, r1.w, c5.w
+    pow r2.w, r1.w, c6.x
+    add r1.w, -r1.z, c5.x
+    mul r0.x, r1.z, c5.y
+    cmp r2.z, r1.w, r0.x, r2.w
+    mul r1.w, c0.x, c0.x
+    cmp r0.xyz, -r1.w, r1, r2
+    mov r0.w, c6.y
+    mul r0, r0, t1
+    mov oC0, r0
+
+// approximately 39 instruction slots used (2 texture, 37 arithmetic)
+ps_4_0
+dcl_constantbuffer CB0[5], immediateIndexed
+dcl_sampler s0, mode_default
+dcl_resource_texture2d (float,float,float,float) t0
+dcl_resource_texture2d (float,float,float,float) t1
+dcl_input_ps linear v1.xy
+dcl_input_ps linear v2.xyzw
+dcl_output o0.xyzw
+dcl_temps 4
+sample r0.xyzw, v1.xyxx, t0.xyzw, s0
+sample r1.xyzw, v1.xyxx, t1.zxyw, s0
+mov r1.x, r0.x
+add r0.xyz, r1.xyzx, cb0[1].xyzx
+dp3 r1.x, r0.xyzx, cb0[2].xyzx
+dp3 r1.y, r0.xyzx, cb0[3].xyzx
+dp3 r1.z, r0.xyzx, cb0[4].xyzx
+ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x
+if_nz r0.x
+  ge r0.xyz, l(0.040450, 0.040450, 0.040450, 0.000000), r1.xyzx
+  mul r2.xyz, r1.xyzx, l(0.077399, 0.077399, 0.077399, 0.000000)
+  add r3.xyz, r1.xyzx, l(0.055000, 0.055000, 0.055000, 0.000000)
+  mul r3.xyz, |r3.xyzx|, l(0.947867, 0.947867, 0.947867, 0.000000)
+  log r3.xyz, r3.xyzx
+  mul r3.xyz, r3.xyzx, l(2.400000, 2.400000, 2.400000, 0.000000)
+  exp r3.xyz, r3.xyzx
+  movc r1.xyz, r0.xyzx, r2.xyzx, r3.xyzx
+endif 
+mov r1.w, l(1.000000)
+mul o0.xyzw, r1.xyzw, v2.xyzw
+ret 
+// Approximately 21 instruction slots used
+#endif
+
+const BYTE g_main[] =
+{
+     68,  88,  66,  67,  57, 206, 
+      5, 226, 160, 185, 110,  25, 
+     70, 167, 109,  22, 187, 226, 
+    244, 122,   1,   0,   0,   0, 
+     52,   9,   0,   0,   6,   0, 
+      0,   0,  56,   0,   0,   0, 
+    232,   2,   0,   0, 196,   5, 
+      0,   0,  64,   6,   0,   0, 
+    140,   8,   0,   0,   0,   9, 
+      0,   0,  65, 111, 110,  57, 
+    168,   2,   0,   0, 168,   2, 
+      0,   0,   0,   2, 255, 255, 
+    112,   2,   0,   0,  56,   0, 
+      0,   0,   1,   0,  44,   0, 
+      0,   0,  56,   0,   0,   0, 
+     56,   0,   2,   0,  36,   0, 
+      0,   0,  56,   0,   0,   0, 
+      0,   0,   1,   0,   1,   0, 
+      0,   0,   0,   0,   5,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   2, 255, 255,  81,   0, 
+      0,   5,   5,   0,  15, 160, 
+    230, 174,  37,  61, 145, 131, 
+    158,  61, 174,  71,  97,  61, 
+    111, 167, 114,  63,  81,   0, 
+      0,   5,   6,   0,  15, 160, 
+    154, 153,  25,  64,   0,   0, 
+    128,  63,   0,   0,   0,   0, 
+      0,   0,   0,   0,  31,   0, 
+      0,   2,   0,   0,   0, 128, 
+      0,   0,   3, 176,  31,   0, 
+      0,   2,   0,   0,   0, 128, 
+      1,   0,  15, 176,  31,   0, 
+      0,   2,   0,   0,   0, 144, 
+      0,   8,  15, 160,  31,   0, 
+      0,   2,   0,   0,   0, 144, 
+      1,   8,  15, 160,  66,   0, 
+      0,   3,   0,   0,  15, 128, 
+      0,   0, 228, 176,   0,   8, 
+    228, 160,  66,   0,   0,   3, 
+      1,   0,  15, 128,   0,   0, 
+    228, 176,   1,   8, 228, 160, 
+      1,   0,   0,   2,   0,   0, 
+      6, 128,   1,   0, 210, 128, 
+      2,   0,   0,   3,   0,   0, 
+      7, 128,   0,   0, 228, 128, 
+      1,   0, 228, 160,   8,   0, 
+      0,   3,   1,   0,   1, 128, 
+      0,   0, 228, 128,   2,   0, 
+    228, 160,   2,   0,   0,   3, 
+      0,   0,   8, 128,   1,   0, 
+      0, 128,   5,   0, 170, 160, 
+     35,   0,   0,   2,   0,   0, 
+      8, 128,   0,   0, 255, 128, 
+      5,   0,   0,   3,   0,   0, 
+      8, 128,   0,   0, 255, 128, 
+      5,   0, 255, 160,  32,   0, 
+      0,   3,   1,   0,   8, 128, 
+      0,   0, 255, 128,   6,   0, 
+      0, 160,   2,   0,   0,   3, 
+      0,   0,   8, 128,   1,   0, 
+      0, 129,   5,   0,   0, 160, 
+      5,   0,   0,   3,   2,   0, 
+      8, 128,   1,   0,   0, 128, 
+      5,   0,  85, 160,  88,   0, 
+      0,   4,   2,   0,   1, 128, 
+      0,   0, 255, 128,   2,   0, 
+    255, 128,   1,   0, 255, 128, 
+      8,   0,   0,   3,   1,   0, 
+      2, 128,   0,   0, 228, 128, 
+      3,   0, 228, 160,   8,   0, 
+      0,   3,   1,   0,   4, 128, 
+      0,   0, 228, 128,   4,   0, 
+    228, 160,   2,   0,   0,   3, 
+      1,   0,   8, 128,   1,   0, 
+     85, 128,   5,   0, 170, 160, 
+     35,   0,   0,   2,   1,   0, 
+      8, 128,   1,   0, 255, 128, 
+      5,   0,   0,   3,   1,   0, 
+      8, 128,   1,   0, 255, 128, 
+      5,   0, 255, 160,  32,   0, 
+      0,   3,   2,   0,   8, 128, 
+      1,   0, 255, 128,   6,   0, 
+      0, 160,   2,   0,   0,   3, 
+      1,   0,   8, 128,   1,   0, 
+     85, 129,   5,   0,   0, 160, 
+      5,   0,   0,   3,   0,   0, 
+      1, 128,   1,   0,  85, 128, 
+      5,   0,  85, 160,  88,   0, 
+      0,   4,   2,   0,   2, 128, 
+      1,   0, 255, 128,   0,   0, 
+      0, 128,   2,   0, 255, 128, 
+      2,   0,   0,   3,   1,   0, 
+      8, 128,   1,   0, 170, 128, 
+      5,   0, 170, 160,  35,   0, 
+      0,   2,   1,   0,   8, 128, 
+      1,   0, 255, 128,   5,   0, 
+      0,   3,   1,   0,   8, 128, 
+      1,   0, 255, 128,   5,   0, 
+    255, 160,  32,   0,   0,   3, 
+      2,   0,   8, 128,   1,   0, 
+    255, 128,   6,   0,   0, 160, 
+      2,   0,   0,   3,   1,   0, 
+      8, 128,   1,   0, 170, 129, 
+      5,   0,   0, 160,   5,   0, 
+      0,   3,   0,   0,   1, 128, 
+      1,   0, 170, 128,   5,   0, 
+     85, 160,  88,   0,   0,   4, 
+      2,   0,   4, 128,   1,   0, 
+    255, 128,   0,   0,   0, 128, 
+      2,   0, 255, 128,   5,   0, 
+      0,   3,   1,   0,   8, 128, 
+      0,   0,   0, 160,   0,   0, 
+      0, 160,  88,   0,   0,   4, 
+      0,   0,   7, 128,   1,   0, 
+    255, 129,   1,   0, 228, 128, 
+      2,   0, 228, 128,   1,   0, 
+      0,   2,   0,   0,   8, 128, 
+      6,   0,  85, 160,   5,   0, 
+      0,   3,   0,   0,  15, 128, 
+      0,   0, 228, 128,   1,   0, 
+    228, 176,   1,   0,   0,   2, 
+      0,   8,  15, 128,   0,   0, 
+    228, 128, 255, 255,   0,   0, 
+     83,  72,  68,  82, 212,   2, 
+      0,   0,  64,   0,   0,   0, 
+    181,   0,   0,   0,  89,   0, 
+      0,   4,  70, 142,  32,   0, 
+      0,   0,   0,   0,   5,   0, 
+      0,   0,  90,   0,   0,   3, 
+      0,  96,  16,   0,   0,   0, 
+      0,   0,  88,  24,   0,   4, 
+      0, 112,  16,   0,   0,   0, 
+      0,   0,  85,  85,   0,   0, 
+     88,  24,   0,   4,   0, 112, 
+     16,   0,   1,   0,   0,   0, 
+     85,  85,   0,   0,  98,  16, 
+      0,   3,  50,  16,  16,   0, 
+      1,   0,   0,   0,  98,  16, 
+      0,   3, 242,  16,  16,   0, 
+      2,   0,   0,   0, 101,   0, 
+      0,   3, 242,  32,  16,   0, 
+      0,   0,   0,   0, 104,   0, 
+      0,   2,   4,   0,   0,   0, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   0,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0,  70, 126,  16,   0, 
+      0,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0,  38, 125,  16,   0, 
+      1,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+     54,   0,   0,   5,  18,   0, 
+     16,   0,   1,   0,   0,   0, 
+     10,   0,  16,   0,   0,   0, 
+      0,   0,   0,   0,   0,   8, 
+    114,   0,  16,   0,   0,   0, 
+      0,   0,  70,   2,  16,   0, 
+      1,   0,   0,   0,  70, 130, 
+     32,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,  16,   0, 
+      0,   8,  18,   0,  16,   0, 
+      1,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+     70, 130,  32,   0,   0,   0, 
+      0,   0,   2,   0,   0,   0, 
+     16,   0,   0,   8,  34,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,   2,  16,   0,   0,   0, 
+      0,   0,  70, 130,  32,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,  16,   0,   0,   8, 
+     66,   0,  16,   0,   1,   0, 
+      0,   0,  70,   2,  16,   0, 
+      0,   0,   0,   0,  70, 130, 
+     32,   0,   0,   0,   0,   0, 
+      4,   0,   0,   0,  57,   0, 
+      0,  11,  18,   0,  16,   0, 
+      0,   0,   0,   0,   2,  64, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     10, 128,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     31,   0,   4,   3,  10,   0, 
+     16,   0,   0,   0,   0,   0, 
+     29,   0,   0,  10, 114,   0, 
+     16,   0,   0,   0,   0,   0, 
+      2,  64,   0,   0, 230, 174, 
+     37,  61, 230, 174,  37,  61, 
+    230, 174,  37,  61,   0,   0, 
+      0,   0,  70,   2,  16,   0, 
+      1,   0,   0,   0,  56,   0, 
+      0,  10, 114,   0,  16,   0, 
+      2,   0,   0,   0,  70,   2, 
+     16,   0,   1,   0,   0,   0, 
+      2,  64,   0,   0, 145, 131, 
+    158,  61, 145, 131, 158,  61, 
+    145, 131, 158,  61,   0,   0, 
+      0,   0,   0,   0,   0,  10, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16,   0, 
+      1,   0,   0,   0,   2,  64, 
+      0,   0, 174,  71,  97,  61, 
+    174,  71,  97,  61, 174,  71, 
+     97,  61,   0,   0,   0,   0, 
+     56,   0,   0,  11, 114,   0, 
+     16,   0,   3,   0,   0,   0, 
+     70,   2,  16, 128, 129,   0, 
+      0,   0,   3,   0,   0,   0, 
+      2,  64,   0,   0, 111, 167, 
+    114,  63, 111, 167, 114,  63, 
+    111, 167, 114,  63,   0,   0, 
+      0,   0,  47,   0,   0,   5, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16,   0, 
+      3,   0,   0,   0,  56,   0, 
+      0,  10, 114,   0,  16,   0, 
+      3,   0,   0,   0,  70,   2, 
+     16,   0,   3,   0,   0,   0, 
+      2,  64,   0,   0, 154, 153, 
+     25,  64, 154, 153,  25,  64, 
+    154, 153,  25,  64,   0,   0, 
+      0,   0,  25,   0,   0,   5, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16,   0, 
+      3,   0,   0,   0,  55,   0, 
+      0,   9, 114,   0,  16,   0, 
+      1,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+     70,   2,  16,   0,   2,   0, 
+      0,   0,  70,   2,  16,   0, 
+      3,   0,   0,   0,  21,   0, 
+      0,   1,  54,   0,   0,   5, 
+    130,   0,  16,   0,   1,   0, 
+      0,   0,   1,  64,   0,   0, 
+      0,   0, 128,  63,  56,   0, 
+      0,   7, 242,  32,  16,   0, 
+      0,   0,   0,   0,  70,  14, 
+     16,   0,   1,   0,   0,   0, 
+     70,  30,  16,   0,   2,   0, 
+      0,   0,  62,   0,   0,   1, 
+     83,  84,  65,  84, 116,   0, 
+      0,   0,  21,   0,   0,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+     12,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      2,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  82,  68, 
+     69,  70,  68,   2,   0,   0, 
+      1,   0,   0,   0, 204,   0, 
+      0,   0,   4,   0,   0,   0, 
+     28,   0,   0,   0,   0,   4, 
+    255, 255,   0,   1,   0,   0, 
+     25,   2,   0,   0, 156,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+    167,   0,   0,   0,   2,   0, 
+      0,   0,   5,   0,   0,   0, 
+      4,   0,   0,   0, 255, 255, 
+    255, 255,   0,   0,   0,   0, 
+      1,   0,   0,   0,  13,   0, 
+      0,   0, 179,   0,   0,   0, 
+      2,   0,   0,   0,   5,   0, 
+      0,   0,   4,   0,   0,   0, 
+    255, 255, 255, 255,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+     13,   0,   0,   0, 192,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+    116, 104, 101,  83,  97, 109, 
+    112, 108, 101, 114,   0, 116, 
+    104, 101,  84, 101, 120, 116, 
+    117, 114, 101,  89,   0, 116, 
+    104, 101,  84, 101, 120, 116, 
+    117, 114, 101,  85,  86,   0, 
+     67, 111, 110, 115, 116,  97, 
+    110, 116, 115,   0, 171, 171, 
+    192,   0,   0,   0,   8,   0, 
+      0,   0, 228,   0,   0,   0, 
+     80,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+    164,   1,   0,   0,   0,   0, 
+      0,   0,   4,   0,   0,   0, 
+      2,   0,   0,   0, 180,   1, 
+      0,   0,   0,   0,   0,   0, 
+    196,   1,   0,   0,   4,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 180,   1, 
+      0,   0,   0,   0,   0,   0, 
+    211,   1,   0,   0,   8,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 180,   1, 
+      0,   0,   0,   0,   0,   0, 
+    226,   1,   0,   0,  12,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 180,   1, 
+      0,   0,   0,   0,   0,   0, 
+    233,   1,   0,   0,  16,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 244,   1, 
+      0,   0,   0,   0,   0,   0, 
+      4,   2,   0,   0,  32,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 244,   1, 
+      0,   0,   0,   0,   0,   0, 
+     11,   2,   0,   0,  48,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 244,   1, 
+      0,   0,   0,   0,   0,   0, 
+     18,   2,   0,   0,  64,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 244,   1, 
+      0,   0,   0,   0,   0,   0, 
+    115,  99,  82,  71,  66,  95, 
+    111, 117, 116, 112, 117, 116, 
+      0, 171, 171, 171,   0,   0, 
+      3,   0,   1,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  83,  68,  82,  95, 
+    119, 104, 105, 116, 101, 108, 
+    101, 118, 101, 108,   0,  72, 
+     68,  82,  95, 119, 104, 105, 
+    116, 101, 108, 101, 118, 101, 
+    108,   0, 109,  97, 120,  67, 
+     76,  76,   0,  89, 111, 102, 
+    102, 115, 101, 116,   0, 171, 
+    171, 171,   1,   0,   3,   0, 
+      1,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     82,  99, 111, 101, 102, 102, 
+      0,  71,  99, 111, 101, 102, 
+    102,   0,  66,  99, 111, 101, 
+    102, 102,   0,  77, 105,  99, 
+    114, 111, 115, 111, 102, 116, 
+     32,  40,  82,  41,  32,  72, 
+     76,  83,  76,  32,  83, 104, 
+     97, 100, 101, 114,  32,  67, 
+    111, 109, 112, 105, 108, 101, 
+    114,  32,  49,  48,  46,  49, 
+      0, 171, 171, 171,  73,  83, 
+     71,  78, 108,   0,   0,   0, 
+      3,   0,   0,   0,   8,   0, 
+      0,   0,  80,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  92,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      1,   0,   0,   0,   3,   3, 
+      0,   0, 101,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      2,   0,   0,   0,  15,  15, 
+      0,   0,  83,  86,  95,  80, 
+     79,  83,  73,  84,  73,  79, 
+     78,   0,  84,  69,  88,  67, 
+     79,  79,  82,  68,   0,  67, 
+     79,  76,  79,  82,   0, 171, 
+     79,  83,  71,  78,  44,   0, 
+      0,   0,   1,   0,   0,   0, 
+      8,   0,   0,   0,  32,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+     15,   0,   0,   0,  83,  86, 
+     95,  84,  65,  82,  71,  69, 
+     84,   0, 171, 171
+};

+ 6 - 20
src/render/direct3d11/D3D11_PixelShader_NV12.hlsl

@@ -2,21 +2,7 @@ Texture2D theTextureY : register(t0);
 Texture2D theTextureUV : register(t1);
 SamplerState theSampler : register(s0);
 
-struct PixelShaderInput
-{
-    float4 pos : SV_POSITION;
-    float2 tex : TEXCOORD0;
-    float4 color : COLOR0;
-};
-
-cbuffer Constants : register(b0)
-{
-    float4 Yoffset;
-    float4 Rcoeff;
-    float4 Gcoeff;
-    float4 Bcoeff;
-};
-
+#include "D3D11_PixelShader_Common.incl"
 
 float4 main(PixelShaderInput input) : SV_TARGET
 {
@@ -26,11 +12,11 @@ float4 main(PixelShaderInput input) : SV_TARGET
     yuv.x = theTextureY.Sample(theSampler, input.tex).r;
     yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg;
 
+    float3 rgb;
     yuv += Yoffset.xyz;
-    Output.r = dot(yuv, Rcoeff.xyz);
-    Output.g = dot(yuv, Gcoeff.xyz);
-    Output.b = dot(yuv, Bcoeff.xyz);
-    Output.a = 1.0f;
+    rgb.r = dot(yuv, Rcoeff.xyz);
+    rgb.g = dot(yuv, Gcoeff.xyz);
+    rgb.b = dot(yuv, Bcoeff.xyz);
 
-    return Output * input.color;
+    return GetOutputColorFromSRGB(rgb) * input.color;
 }

+ 540 - 350
src/render/direct3d11/D3D11_PixelShader_NV21.h

@@ -1,350 +1,540 @@
-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
-//
-//
-// Buffer Definitions: 
-//
-// cbuffer Constants
-// {
-//
-//   float4 Yoffset;                    // Offset:    0 Size:    16
-//   float4 Rcoeff;                     // Offset:   16 Size:    16
-//   float4 Gcoeff;                     // Offset:   32 Size:    16
-//   float4 Bcoeff;                     // Offset:   48 Size:    16
-//
-// }
-//
-//
-// Resource Bindings:
-//
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// theSampler                        sampler      NA          NA             s0      1 
-// theTextureY                       texture  float4          2d             t0      1 
-// theTextureUV                      texture  float4          2d             t1      1 
-// Constants                         cbuffer      NA          NA            cb0      1 
-//
-//
-//
-// Input signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_POSITION              0   xyzw        0      POS   float       
-// TEXCOORD                 0   xy          1     NONE   float   xy  
-// COLOR                    0   xyzw        2     NONE   float   xyzw
-//
-//
-// Output signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
-//
-//
-// Constant buffer to DX9 shader constant mappings:
-//
-// Target Reg Buffer  Start Reg # of Regs        Data Conversion
-// ---------- ------- --------- --------- ----------------------
-// c0         cb0             0         4  ( FLT, FLT, FLT, FLT)
-//
-//
-// Sampler/Resource to DX9 shader sampler mappings:
-//
-// Target Sampler Source Sampler  Source Resource
-// -------------- --------------- ----------------
-// s0             s0              t0               
-// s1             s0              t1               
-//
-//
-// Level9 shader bytecode:
-//
-    ps_2_0
-    def c4, 1, 0, 0, 0
-    dcl t0.xy
-    dcl t1
-    dcl_2d s0
-    dcl_2d s1
-    texld r0, t0, s0
-    texld r1, t0, s1
-    mov r0.y, r1.y
-    mov r0.z, r1.x
-    add r0.xyz, r0, c0
-    dp3 r1.x, r0, c1
-    dp3 r1.y, r0, c2
-    dp3 r1.z, r0, c3
-    mov r1.w, c4.x
-    mul r0, r1, t1
-    mov oC0, r0
-
-// approximately 11 instruction slots used (2 texture, 9 arithmetic)
-ps_4_0
-dcl_constantbuffer CB0[4], immediateIndexed
-dcl_sampler s0, mode_default
-dcl_resource_texture2d (float,float,float,float) t0
-dcl_resource_texture2d (float,float,float,float) t1
-dcl_input_ps linear v1.xy
-dcl_input_ps linear v2.xyzw
-dcl_output o0.xyzw
-dcl_temps 2
-sample r0.xyzw, v1.xyxx, t0.xyzw, s0
-sample r1.xyzw, v1.xyxx, t1.xyzw, s0
-mov r0.yz, r1.yyxy
-add r0.xyz, r0.xyzx, cb0[0].xyzx
-dp3 r1.x, r0.xyzx, cb0[1].xyzx
-dp3 r1.y, r0.xyzx, cb0[2].xyzx
-dp3 r1.z, r0.xyzx, cb0[3].xyzx
-mov r1.w, l(1.000000)
-mul o0.xyzw, r1.xyzw, v2.xyzw
-ret 
-// Approximately 10 instruction slots used
-#endif
-
-const BYTE g_main[] =
-{
-     68,  88,  66,  67, 142, 144, 
-     79, 192, 175,  21,   0,   8, 
-      7, 119, 219, 202,  53,  69, 
-    174, 234,   1,   0,   0,   0, 
-    184,   5,   0,   0,   6,   0, 
-      0,   0,  56,   0,   0,   0, 
-    104,   1,   0,   0, 240,   2, 
-      0,   0, 108,   3,   0,   0, 
-     16,   5,   0,   0, 132,   5, 
-      0,   0,  65, 111, 110,  57, 
-     40,   1,   0,   0,  40,   1, 
-      0,   0,   0,   2, 255, 255, 
-    240,   0,   0,   0,  56,   0, 
-      0,   0,   1,   0,  44,   0, 
-      0,   0,  56,   0,   0,   0, 
-     56,   0,   2,   0,  36,   0, 
-      0,   0,  56,   0,   0,   0, 
-      0,   0,   1,   0,   1,   0, 
-      0,   0,   0,   0,   4,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   2, 255, 255,  81,   0, 
-      0,   5,   4,   0,  15, 160, 
-      0,   0, 128,  63,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,  31,   0, 
-      0,   2,   0,   0,   0, 128, 
-      0,   0,   3, 176,  31,   0, 
-      0,   2,   0,   0,   0, 128, 
-      1,   0,  15, 176,  31,   0, 
-      0,   2,   0,   0,   0, 144, 
-      0,   8,  15, 160,  31,   0, 
-      0,   2,   0,   0,   0, 144, 
-      1,   8,  15, 160,  66,   0, 
-      0,   3,   0,   0,  15, 128, 
-      0,   0, 228, 176,   0,   8, 
-    228, 160,  66,   0,   0,   3, 
-      1,   0,  15, 128,   0,   0, 
-    228, 176,   1,   8, 228, 160, 
-      1,   0,   0,   2,   0,   0, 
-      2, 128,   1,   0,  85, 128, 
-      1,   0,   0,   2,   0,   0, 
-      4, 128,   1,   0,   0, 128, 
-      2,   0,   0,   3,   0,   0, 
-      7, 128,   0,   0, 228, 128, 
-      0,   0, 228, 160,   8,   0, 
-      0,   3,   1,   0,   1, 128, 
-      0,   0, 228, 128,   1,   0, 
-    228, 160,   8,   0,   0,   3, 
-      1,   0,   2, 128,   0,   0, 
-    228, 128,   2,   0, 228, 160, 
-      8,   0,   0,   3,   1,   0, 
-      4, 128,   0,   0, 228, 128, 
-      3,   0, 228, 160,   1,   0, 
-      0,   2,   1,   0,   8, 128, 
-      4,   0,   0, 160,   5,   0, 
-      0,   3,   0,   0,  15, 128, 
-      1,   0, 228, 128,   1,   0, 
-    228, 176,   1,   0,   0,   2, 
-      0,   8,  15, 128,   0,   0, 
-    228, 128, 255, 255,   0,   0, 
-     83,  72,  68,  82, 128,   1, 
-      0,   0,  64,   0,   0,   0, 
-     96,   0,   0,   0,  89,   0, 
-      0,   4,  70, 142,  32,   0, 
-      0,   0,   0,   0,   4,   0, 
-      0,   0,  90,   0,   0,   3, 
-      0,  96,  16,   0,   0,   0, 
-      0,   0,  88,  24,   0,   4, 
-      0, 112,  16,   0,   0,   0, 
-      0,   0,  85,  85,   0,   0, 
-     88,  24,   0,   4,   0, 112, 
-     16,   0,   1,   0,   0,   0, 
-     85,  85,   0,   0,  98,  16, 
-      0,   3,  50,  16,  16,   0, 
-      1,   0,   0,   0,  98,  16, 
-      0,   3, 242,  16,  16,   0, 
-      2,   0,   0,   0, 101,   0, 
-      0,   3, 242,  32,  16,   0, 
-      0,   0,   0,   0, 104,   0, 
-      0,   2,   2,   0,   0,   0, 
-     69,   0,   0,   9, 242,   0, 
-     16,   0,   0,   0,   0,   0, 
-     70,  16,  16,   0,   1,   0, 
-      0,   0,  70, 126,  16,   0, 
-      0,   0,   0,   0,   0,  96, 
-     16,   0,   0,   0,   0,   0, 
-     69,   0,   0,   9, 242,   0, 
-     16,   0,   1,   0,   0,   0, 
-     70,  16,  16,   0,   1,   0, 
-      0,   0,  70, 126,  16,   0, 
-      1,   0,   0,   0,   0,  96, 
-     16,   0,   0,   0,   0,   0, 
-     54,   0,   0,   5,  98,   0, 
-     16,   0,   0,   0,   0,   0, 
-     86,   4,  16,   0,   1,   0, 
-      0,   0,   0,   0,   0,   8, 
-    114,   0,  16,   0,   0,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  70, 130, 
-     32,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,  16,   0, 
-      0,   8,  18,   0,  16,   0, 
-      1,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-     70, 130,  32,   0,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-     16,   0,   0,   8,  34,   0, 
-     16,   0,   1,   0,   0,   0, 
-     70,   2,  16,   0,   0,   0, 
-      0,   0,  70, 130,  32,   0, 
-      0,   0,   0,   0,   2,   0, 
-      0,   0,  16,   0,   0,   8, 
-     66,   0,  16,   0,   1,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  70, 130, 
-     32,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,  54,   0, 
-      0,   5, 130,   0,  16,   0, 
-      1,   0,   0,   0,   1,  64, 
-      0,   0,   0,   0, 128,  63, 
-     56,   0,   0,   7, 242,  32, 
-     16,   0,   0,   0,   0,   0, 
-     70,  14,  16,   0,   1,   0, 
-      0,   0,  70,  30,  16,   0, 
-      2,   0,   0,   0,  62,   0, 
-      0,   1,  83,  84,  65,  84, 
-    116,   0,   0,   0,  10,   0, 
-      0,   0,   2,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   5,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      2,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   2,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-     82,  68,  69,  70, 156,   1, 
-      0,   0,   1,   0,   0,   0, 
-    204,   0,   0,   0,   4,   0, 
-      0,   0,  28,   0,   0,   0, 
-      0,   4, 255, 255,   0,   1, 
-      0,   0, 113,   1,   0,   0, 
-    156,   0,   0,   0,   3,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   1,   0, 
-      0,   0, 167,   0,   0,   0, 
-      2,   0,   0,   0,   5,   0, 
-      0,   0,   4,   0,   0,   0, 
-    255, 255, 255, 255,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-     13,   0,   0,   0, 179,   0, 
-      0,   0,   2,   0,   0,   0, 
-      5,   0,   0,   0,   4,   0, 
-      0,   0, 255, 255, 255, 255, 
-      1,   0,   0,   0,   1,   0, 
-      0,   0,  13,   0,   0,   0, 
-    192,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   1,   0, 
-      0,   0, 116, 104, 101,  83, 
-     97, 109, 112, 108, 101, 114, 
-      0, 116, 104, 101,  84, 101, 
-    120, 116, 117, 114, 101,  89, 
-      0, 116, 104, 101,  84, 101, 
-    120, 116, 117, 114, 101,  85, 
-     86,   0,  67, 111, 110, 115, 
-    116,  97, 110, 116, 115,   0, 
-    171, 171, 192,   0,   0,   0, 
-      4,   0,   0,   0, 228,   0, 
-      0,   0,  64,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  68,   1,   0,   0, 
-      0,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     76,   1,   0,   0,   0,   0, 
-      0,   0,  92,   1,   0,   0, 
-     16,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     76,   1,   0,   0,   0,   0, 
-      0,   0,  99,   1,   0,   0, 
-     32,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     76,   1,   0,   0,   0,   0, 
-      0,   0, 106,   1,   0,   0, 
-     48,   0,   0,   0,  16,   0, 
-      0,   0,   2,   0,   0,   0, 
-     76,   1,   0,   0,   0,   0, 
-      0,   0,  89, 111, 102, 102, 
-    115, 101, 116,   0,   1,   0, 
-      3,   0,   1,   0,   4,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  82,  99, 111, 101, 
-    102, 102,   0,  71,  99, 111, 
-    101, 102, 102,   0,  66,  99, 
-    111, 101, 102, 102,   0,  77, 
-    105,  99, 114, 111, 115, 111, 
-    102, 116,  32,  40,  82,  41, 
-     32,  72,  76,  83,  76,  32, 
-     83, 104,  97, 100, 101, 114, 
-     32,  67, 111, 109, 112, 105, 
-    108, 101, 114,  32,  49,  48, 
-     46,  49,   0, 171, 171, 171, 
-     73,  83,  71,  78, 108,   0, 
-      0,   0,   3,   0,   0,   0, 
-      8,   0,   0,   0,  80,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   3,   0, 
-      0,   0,   0,   0,   0,   0, 
-     15,   0,   0,   0,  92,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   1,   0,   0,   0, 
-      3,   3,   0,   0, 101,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   2,   0,   0,   0, 
-     15,  15,   0,   0,  83,  86, 
-     95,  80,  79,  83,  73,  84, 
-     73,  79,  78,   0,  84,  69, 
-     88,  67,  79,  79,  82,  68, 
-      0,  67,  79,  76,  79,  82, 
-      0, 171,  79,  83,  71,  78, 
-     44,   0,   0,   0,   1,   0, 
-      0,   0,   8,   0,   0,   0, 
-     32,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,   0,   0, 
-      0,   0,  15,   0,   0,   0, 
-     83,  86,  95,  84,  65,  82, 
-     71,  69,  84,   0, 171, 171
-};
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Buffer Definitions: 
+//
+// cbuffer Constants
+// {
+//
+//   float scRGB_output;                // Offset:    0 Size:     4
+//   float SDR_whitelevel;              // Offset:    4 Size:     4 [unused]
+//   float HDR_whitelevel;              // Offset:    8 Size:     4 [unused]
+//   float maxCLL;                      // Offset:   12 Size:     4 [unused]
+//   float4 Yoffset;                    // Offset:   16 Size:    16
+//   float4 Rcoeff;                     // Offset:   32 Size:    16
+//   float4 Gcoeff;                     // Offset:   48 Size:    16
+//   float4 Bcoeff;                     // Offset:   64 Size:    16
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim      HLSL Bind  Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// theSampler                        sampler      NA          NA             s0      1 
+// theTextureY                       texture  float4          2d             t0      1 
+// theTextureUV                      texture  float4          2d             t1      1 
+// Constants                         cbuffer      NA          NA            cb0      1 
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION              0   xyzw        0      POS   float       
+// TEXCOORD                 0   xy          1     NONE   float   xy  
+// COLOR                    0   xyzw        2     NONE   float   xyzw
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
+//
+//
+// Constant buffer to DX9 shader constant mappings:
+//
+// Target Reg Buffer  Start Reg # of Regs        Data Conversion
+// ---------- ------- --------- --------- ----------------------
+// c0         cb0             0         5  ( FLT, FLT, FLT, FLT)
+//
+//
+// Sampler/Resource to DX9 shader sampler mappings:
+//
+// Target Sampler Source Sampler  Source Resource
+// -------------- --------------- ----------------
+// s0             s0              t0               
+// s1             s0              t1               
+//
+//
+// Level9 shader bytecode:
+//
+    ps_2_0
+    def c5, 0.0404499993, 0.0773993805, 0.0549999997, 0.947867334
+    def c6, 2.4000001, 1, 0, 0
+    dcl t0.xy
+    dcl t1
+    dcl_2d s0
+    dcl_2d s1
+    texld r0, t0, s0
+    texld r1, t0, s1
+    mov r0.y, r1.y
+    mov r0.z, r1.x
+    add r0.xyz, r0, c1
+    dp3 r1.x, r0, c2
+    add r0.w, r1.x, c5.z
+    abs r0.w, r0.w
+    mul r0.w, r0.w, c5.w
+    pow r1.w, r0.w, c6.x
+    add r0.w, -r1.x, c5.x
+    mul r2.w, r1.x, c5.y
+    cmp r2.x, r0.w, r2.w, r1.w
+    dp3 r1.y, r0, c3
+    dp3 r1.z, r0, c4
+    add r1.w, r1.y, c5.z
+    abs r1.w, r1.w
+    mul r1.w, r1.w, c5.w
+    pow r2.w, r1.w, c6.x
+    add r1.w, -r1.y, c5.x
+    mul r0.x, r1.y, c5.y
+    cmp r2.y, r1.w, r0.x, r2.w
+    add r1.w, r1.z, c5.z
+    abs r1.w, r1.w
+    mul r1.w, r1.w, c5.w
+    pow r2.w, r1.w, c6.x
+    add r1.w, -r1.z, c5.x
+    mul r0.x, r1.z, c5.y
+    cmp r2.z, r1.w, r0.x, r2.w
+    mul r1.w, c0.x, c0.x
+    cmp r0.xyz, -r1.w, r1, r2
+    mov r0.w, c6.y
+    mul r0, r0, t1
+    mov oC0, r0
+
+// approximately 40 instruction slots used (2 texture, 38 arithmetic)
+ps_4_0
+dcl_constantbuffer CB0[5], immediateIndexed
+dcl_sampler s0, mode_default
+dcl_resource_texture2d (float,float,float,float) t0
+dcl_resource_texture2d (float,float,float,float) t1
+dcl_input_ps linear v1.xy
+dcl_input_ps linear v2.xyzw
+dcl_output o0.xyzw
+dcl_temps 4
+sample r0.xyzw, v1.xyxx, t0.xyzw, s0
+sample r1.xyzw, v1.xyxx, t1.zyxw, s0
+mov r1.x, r0.x
+add r0.xyz, r1.xyzx, cb0[1].xyzx
+dp3 r1.x, r0.xyzx, cb0[2].xyzx
+dp3 r1.y, r0.xyzx, cb0[3].xyzx
+dp3 r1.z, r0.xyzx, cb0[4].xyzx
+ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x
+if_nz r0.x
+  ge r0.xyz, l(0.040450, 0.040450, 0.040450, 0.000000), r1.xyzx
+  mul r2.xyz, r1.xyzx, l(0.077399, 0.077399, 0.077399, 0.000000)
+  add r3.xyz, r1.xyzx, l(0.055000, 0.055000, 0.055000, 0.000000)
+  mul r3.xyz, |r3.xyzx|, l(0.947867, 0.947867, 0.947867, 0.000000)
+  log r3.xyz, r3.xyzx
+  mul r3.xyz, r3.xyzx, l(2.400000, 2.400000, 2.400000, 0.000000)
+  exp r3.xyz, r3.xyzx
+  movc r1.xyz, r0.xyzx, r2.xyzx, r3.xyzx
+endif 
+mov r1.w, l(1.000000)
+mul o0.xyzw, r1.xyzw, v2.xyzw
+ret 
+// Approximately 21 instruction slots used
+#endif
+
+const BYTE g_main[] =
+{
+     68,  88,  66,  67, 103, 251, 
+     56, 113, 174, 118,  96,  85, 
+    191,  91,  87, 213, 153, 143, 
+    217, 253,   1,   0,   0,   0, 
+     64,   9,   0,   0,   6,   0, 
+      0,   0,  56,   0,   0,   0, 
+    244,   2,   0,   0, 208,   5, 
+      0,   0,  76,   6,   0,   0, 
+    152,   8,   0,   0,  12,   9, 
+      0,   0,  65, 111, 110,  57, 
+    180,   2,   0,   0, 180,   2, 
+      0,   0,   0,   2, 255, 255, 
+    124,   2,   0,   0,  56,   0, 
+      0,   0,   1,   0,  44,   0, 
+      0,   0,  56,   0,   0,   0, 
+     56,   0,   2,   0,  36,   0, 
+      0,   0,  56,   0,   0,   0, 
+      0,   0,   1,   0,   1,   0, 
+      0,   0,   0,   0,   5,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   2, 255, 255,  81,   0, 
+      0,   5,   5,   0,  15, 160, 
+    230, 174,  37,  61, 145, 131, 
+    158,  61, 174,  71,  97,  61, 
+    111, 167, 114,  63,  81,   0, 
+      0,   5,   6,   0,  15, 160, 
+    154, 153,  25,  64,   0,   0, 
+    128,  63,   0,   0,   0,   0, 
+      0,   0,   0,   0,  31,   0, 
+      0,   2,   0,   0,   0, 128, 
+      0,   0,   3, 176,  31,   0, 
+      0,   2,   0,   0,   0, 128, 
+      1,   0,  15, 176,  31,   0, 
+      0,   2,   0,   0,   0, 144, 
+      0,   8,  15, 160,  31,   0, 
+      0,   2,   0,   0,   0, 144, 
+      1,   8,  15, 160,  66,   0, 
+      0,   3,   0,   0,  15, 128, 
+      0,   0, 228, 176,   0,   8, 
+    228, 160,  66,   0,   0,   3, 
+      1,   0,  15, 128,   0,   0, 
+    228, 176,   1,   8, 228, 160, 
+      1,   0,   0,   2,   0,   0, 
+      2, 128,   1,   0,  85, 128, 
+      1,   0,   0,   2,   0,   0, 
+      4, 128,   1,   0,   0, 128, 
+      2,   0,   0,   3,   0,   0, 
+      7, 128,   0,   0, 228, 128, 
+      1,   0, 228, 160,   8,   0, 
+      0,   3,   1,   0,   1, 128, 
+      0,   0, 228, 128,   2,   0, 
+    228, 160,   2,   0,   0,   3, 
+      0,   0,   8, 128,   1,   0, 
+      0, 128,   5,   0, 170, 160, 
+     35,   0,   0,   2,   0,   0, 
+      8, 128,   0,   0, 255, 128, 
+      5,   0,   0,   3,   0,   0, 
+      8, 128,   0,   0, 255, 128, 
+      5,   0, 255, 160,  32,   0, 
+      0,   3,   1,   0,   8, 128, 
+      0,   0, 255, 128,   6,   0, 
+      0, 160,   2,   0,   0,   3, 
+      0,   0,   8, 128,   1,   0, 
+      0, 129,   5,   0,   0, 160, 
+      5,   0,   0,   3,   2,   0, 
+      8, 128,   1,   0,   0, 128, 
+      5,   0,  85, 160,  88,   0, 
+      0,   4,   2,   0,   1, 128, 
+      0,   0, 255, 128,   2,   0, 
+    255, 128,   1,   0, 255, 128, 
+      8,   0,   0,   3,   1,   0, 
+      2, 128,   0,   0, 228, 128, 
+      3,   0, 228, 160,   8,   0, 
+      0,   3,   1,   0,   4, 128, 
+      0,   0, 228, 128,   4,   0, 
+    228, 160,   2,   0,   0,   3, 
+      1,   0,   8, 128,   1,   0, 
+     85, 128,   5,   0, 170, 160, 
+     35,   0,   0,   2,   1,   0, 
+      8, 128,   1,   0, 255, 128, 
+      5,   0,   0,   3,   1,   0, 
+      8, 128,   1,   0, 255, 128, 
+      5,   0, 255, 160,  32,   0, 
+      0,   3,   2,   0,   8, 128, 
+      1,   0, 255, 128,   6,   0, 
+      0, 160,   2,   0,   0,   3, 
+      1,   0,   8, 128,   1,   0, 
+     85, 129,   5,   0,   0, 160, 
+      5,   0,   0,   3,   0,   0, 
+      1, 128,   1,   0,  85, 128, 
+      5,   0,  85, 160,  88,   0, 
+      0,   4,   2,   0,   2, 128, 
+      1,   0, 255, 128,   0,   0, 
+      0, 128,   2,   0, 255, 128, 
+      2,   0,   0,   3,   1,   0, 
+      8, 128,   1,   0, 170, 128, 
+      5,   0, 170, 160,  35,   0, 
+      0,   2,   1,   0,   8, 128, 
+      1,   0, 255, 128,   5,   0, 
+      0,   3,   1,   0,   8, 128, 
+      1,   0, 255, 128,   5,   0, 
+    255, 160,  32,   0,   0,   3, 
+      2,   0,   8, 128,   1,   0, 
+    255, 128,   6,   0,   0, 160, 
+      2,   0,   0,   3,   1,   0, 
+      8, 128,   1,   0, 170, 129, 
+      5,   0,   0, 160,   5,   0, 
+      0,   3,   0,   0,   1, 128, 
+      1,   0, 170, 128,   5,   0, 
+     85, 160,  88,   0,   0,   4, 
+      2,   0,   4, 128,   1,   0, 
+    255, 128,   0,   0,   0, 128, 
+      2,   0, 255, 128,   5,   0, 
+      0,   3,   1,   0,   8, 128, 
+      0,   0,   0, 160,   0,   0, 
+      0, 160,  88,   0,   0,   4, 
+      0,   0,   7, 128,   1,   0, 
+    255, 129,   1,   0, 228, 128, 
+      2,   0, 228, 128,   1,   0, 
+      0,   2,   0,   0,   8, 128, 
+      6,   0,  85, 160,   5,   0, 
+      0,   3,   0,   0,  15, 128, 
+      0,   0, 228, 128,   1,   0, 
+    228, 176,   1,   0,   0,   2, 
+      0,   8,  15, 128,   0,   0, 
+    228, 128, 255, 255,   0,   0, 
+     83,  72,  68,  82, 212,   2, 
+      0,   0,  64,   0,   0,   0, 
+    181,   0,   0,   0,  89,   0, 
+      0,   4,  70, 142,  32,   0, 
+      0,   0,   0,   0,   5,   0, 
+      0,   0,  90,   0,   0,   3, 
+      0,  96,  16,   0,   0,   0, 
+      0,   0,  88,  24,   0,   4, 
+      0, 112,  16,   0,   0,   0, 
+      0,   0,  85,  85,   0,   0, 
+     88,  24,   0,   4,   0, 112, 
+     16,   0,   1,   0,   0,   0, 
+     85,  85,   0,   0,  98,  16, 
+      0,   3,  50,  16,  16,   0, 
+      1,   0,   0,   0,  98,  16, 
+      0,   3, 242,  16,  16,   0, 
+      2,   0,   0,   0, 101,   0, 
+      0,   3, 242,  32,  16,   0, 
+      0,   0,   0,   0, 104,   0, 
+      0,   2,   4,   0,   0,   0, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   0,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0,  70, 126,  16,   0, 
+      0,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0, 102, 124,  16,   0, 
+      1,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+     54,   0,   0,   5,  18,   0, 
+     16,   0,   1,   0,   0,   0, 
+     10,   0,  16,   0,   0,   0, 
+      0,   0,   0,   0,   0,   8, 
+    114,   0,  16,   0,   0,   0, 
+      0,   0,  70,   2,  16,   0, 
+      1,   0,   0,   0,  70, 130, 
+     32,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,  16,   0, 
+      0,   8,  18,   0,  16,   0, 
+      1,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+     70, 130,  32,   0,   0,   0, 
+      0,   0,   2,   0,   0,   0, 
+     16,   0,   0,   8,  34,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,   2,  16,   0,   0,   0, 
+      0,   0,  70, 130,  32,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,  16,   0,   0,   8, 
+     66,   0,  16,   0,   1,   0, 
+      0,   0,  70,   2,  16,   0, 
+      0,   0,   0,   0,  70, 130, 
+     32,   0,   0,   0,   0,   0, 
+      4,   0,   0,   0,  57,   0, 
+      0,  11,  18,   0,  16,   0, 
+      0,   0,   0,   0,   2,  64, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     10, 128,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     31,   0,   4,   3,  10,   0, 
+     16,   0,   0,   0,   0,   0, 
+     29,   0,   0,  10, 114,   0, 
+     16,   0,   0,   0,   0,   0, 
+      2,  64,   0,   0, 230, 174, 
+     37,  61, 230, 174,  37,  61, 
+    230, 174,  37,  61,   0,   0, 
+      0,   0,  70,   2,  16,   0, 
+      1,   0,   0,   0,  56,   0, 
+      0,  10, 114,   0,  16,   0, 
+      2,   0,   0,   0,  70,   2, 
+     16,   0,   1,   0,   0,   0, 
+      2,  64,   0,   0, 145, 131, 
+    158,  61, 145, 131, 158,  61, 
+    145, 131, 158,  61,   0,   0, 
+      0,   0,   0,   0,   0,  10, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16,   0, 
+      1,   0,   0,   0,   2,  64, 
+      0,   0, 174,  71,  97,  61, 
+    174,  71,  97,  61, 174,  71, 
+     97,  61,   0,   0,   0,   0, 
+     56,   0,   0,  11, 114,   0, 
+     16,   0,   3,   0,   0,   0, 
+     70,   2,  16, 128, 129,   0, 
+      0,   0,   3,   0,   0,   0, 
+      2,  64,   0,   0, 111, 167, 
+    114,  63, 111, 167, 114,  63, 
+    111, 167, 114,  63,   0,   0, 
+      0,   0,  47,   0,   0,   5, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16,   0, 
+      3,   0,   0,   0,  56,   0, 
+      0,  10, 114,   0,  16,   0, 
+      3,   0,   0,   0,  70,   2, 
+     16,   0,   3,   0,   0,   0, 
+      2,  64,   0,   0, 154, 153, 
+     25,  64, 154, 153,  25,  64, 
+    154, 153,  25,  64,   0,   0, 
+      0,   0,  25,   0,   0,   5, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16,   0, 
+      3,   0,   0,   0,  55,   0, 
+      0,   9, 114,   0,  16,   0, 
+      1,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+     70,   2,  16,   0,   2,   0, 
+      0,   0,  70,   2,  16,   0, 
+      3,   0,   0,   0,  21,   0, 
+      0,   1,  54,   0,   0,   5, 
+    130,   0,  16,   0,   1,   0, 
+      0,   0,   1,  64,   0,   0, 
+      0,   0, 128,  63,  56,   0, 
+      0,   7, 242,  32,  16,   0, 
+      0,   0,   0,   0,  70,  14, 
+     16,   0,   1,   0,   0,   0, 
+     70,  30,  16,   0,   2,   0, 
+      0,   0,  62,   0,   0,   1, 
+     83,  84,  65,  84, 116,   0, 
+      0,   0,  21,   0,   0,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+     12,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      2,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  82,  68, 
+     69,  70,  68,   2,   0,   0, 
+      1,   0,   0,   0, 204,   0, 
+      0,   0,   4,   0,   0,   0, 
+     28,   0,   0,   0,   0,   4, 
+    255, 255,   0,   1,   0,   0, 
+     25,   2,   0,   0, 156,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+    167,   0,   0,   0,   2,   0, 
+      0,   0,   5,   0,   0,   0, 
+      4,   0,   0,   0, 255, 255, 
+    255, 255,   0,   0,   0,   0, 
+      1,   0,   0,   0,  13,   0, 
+      0,   0, 179,   0,   0,   0, 
+      2,   0,   0,   0,   5,   0, 
+      0,   0,   4,   0,   0,   0, 
+    255, 255, 255, 255,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+     13,   0,   0,   0, 192,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+    116, 104, 101,  83,  97, 109, 
+    112, 108, 101, 114,   0, 116, 
+    104, 101,  84, 101, 120, 116, 
+    117, 114, 101,  89,   0, 116, 
+    104, 101,  84, 101, 120, 116, 
+    117, 114, 101,  85,  86,   0, 
+     67, 111, 110, 115, 116,  97, 
+    110, 116, 115,   0, 171, 171, 
+    192,   0,   0,   0,   8,   0, 
+      0,   0, 228,   0,   0,   0, 
+     80,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+    164,   1,   0,   0,   0,   0, 
+      0,   0,   4,   0,   0,   0, 
+      2,   0,   0,   0, 180,   1, 
+      0,   0,   0,   0,   0,   0, 
+    196,   1,   0,   0,   4,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 180,   1, 
+      0,   0,   0,   0,   0,   0, 
+    211,   1,   0,   0,   8,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 180,   1, 
+      0,   0,   0,   0,   0,   0, 
+    226,   1,   0,   0,  12,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0, 180,   1, 
+      0,   0,   0,   0,   0,   0, 
+    233,   1,   0,   0,  16,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 244,   1, 
+      0,   0,   0,   0,   0,   0, 
+      4,   2,   0,   0,  32,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 244,   1, 
+      0,   0,   0,   0,   0,   0, 
+     11,   2,   0,   0,  48,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 244,   1, 
+      0,   0,   0,   0,   0,   0, 
+     18,   2,   0,   0,  64,   0, 
+      0,   0,  16,   0,   0,   0, 
+      2,   0,   0,   0, 244,   1, 
+      0,   0,   0,   0,   0,   0, 
+    115,  99,  82,  71,  66,  95, 
+    111, 117, 116, 112, 117, 116, 
+      0, 171, 171, 171,   0,   0, 
+      3,   0,   1,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  83,  68,  82,  95, 
+    119, 104, 105, 116, 101, 108, 
+    101, 118, 101, 108,   0,  72, 
+     68,  82,  95, 119, 104, 105, 
+    116, 101, 108, 101, 118, 101, 
+    108,   0, 109,  97, 120,  67, 
+     76,  76,   0,  89, 111, 102, 
+    102, 115, 101, 116,   0, 171, 
+    171, 171,   1,   0,   3,   0, 
+      1,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     82,  99, 111, 101, 102, 102, 
+      0,  71,  99, 111, 101, 102, 
+    102,   0,  66,  99, 111, 101, 
+    102, 102,   0,  77, 105,  99, 
+    114, 111, 115, 111, 102, 116, 
+     32,  40,  82,  41,  32,  72, 
+     76,  83,  76,  32,  83, 104, 
+     97, 100, 101, 114,  32,  67, 
+    111, 109, 112, 105, 108, 101, 
+    114,  32,  49,  48,  46,  49, 
+      0, 171, 171, 171,  73,  83, 
+     71,  78, 108,   0,   0,   0, 
+      3,   0,   0,   0,   8,   0, 
+      0,   0,  80,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  92,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      1,   0,   0,   0,   3,   3, 
+      0,   0, 101,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      2,   0,   0,   0,  15,  15, 
+      0,   0,  83,  86,  95,  80, 
+     79,  83,  73,  84,  73,  79, 
+     78,   0,  84,  69,  88,  67, 
+     79,  79,  82,  68,   0,  67, 
+     79,  76,  79,  82,   0, 171, 
+     79,  83,  71,  78,  44,   0, 
+      0,   0,   1,   0,   0,   0, 
+      8,   0,   0,   0,  32,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+     15,   0,   0,   0,  83,  86, 
+     95,  84,  65,  82,  71,  69, 
+     84,   0, 171, 171
+};

+ 6 - 20
src/render/direct3d11/D3D11_PixelShader_NV21.hlsl

@@ -2,21 +2,7 @@ Texture2D theTextureY : register(t0);
 Texture2D theTextureUV : register(t1);
 SamplerState theSampler : register(s0);
 
-struct PixelShaderInput
-{
-    float4 pos : SV_POSITION;
-    float2 tex : TEXCOORD0;
-    float4 color : COLOR0;
-};
-
-cbuffer Constants : register(b0)
-{
-    float4 Yoffset;
-    float4 Rcoeff;
-    float4 Gcoeff;
-    float4 Bcoeff;
-};
-
+#include "D3D11_PixelShader_Common.incl"
 
 float4 main(PixelShaderInput input) : SV_TARGET
 {
@@ -26,11 +12,11 @@ float4 main(PixelShaderInput input) : SV_TARGET
     yuv.x = theTextureY.Sample(theSampler, input.tex).r;
     yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr;
 
+    float3 rgb;
     yuv += Yoffset.xyz;
-    Output.r = dot(yuv, Rcoeff.xyz);
-    Output.g = dot(yuv, Gcoeff.xyz);
-    Output.b = dot(yuv, Bcoeff.xyz);
-    Output.a = 1.0f;
+    rgb.r = dot(yuv, Rcoeff.xyz);
+    rgb.g = dot(yuv, Gcoeff.xyz);
+    rgb.b = dot(yuv, Bcoeff.xyz);
 
-    return Output * input.color;
+    return GetOutputColorFromSRGB(rgb) * input.color;
 }

+ 341 - 198
src/render/direct3d11/D3D11_PixelShader_Textures.h

@@ -1,198 +1,341 @@
-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
-//
-//
-// Resource Bindings:
-//
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// theSampler                        sampler      NA          NA             s0      1 
-// theTexture                        texture  float4          2d             t0      1 
-//
-//
-//
-// Input signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_POSITION              0   xyzw        0      POS   float       
-// TEXCOORD                 0   xy          1     NONE   float   xy  
-// COLOR                    0   xyzw        2     NONE   float   xyzw
-//
-//
-// Output signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
-//
-//
-// Sampler/Resource to DX9 shader sampler mappings:
-//
-// Target Sampler Source Sampler  Source Resource
-// -------------- --------------- ----------------
-// s0             s0              t0               
-//
-//
-// Level9 shader bytecode:
-//
-    ps_2_0
-    dcl t0.xy
-    dcl t1
-    dcl_2d s0
-    texld r0, t0, s0
-    mul r0, r0, t1
-    mov oC0, r0
-
-// approximately 3 instruction slots used (1 texture, 2 arithmetic)
-ps_4_0
-dcl_sampler s0, mode_default
-dcl_resource_texture2d (float,float,float,float) t0
-dcl_input_ps linear v1.xy
-dcl_input_ps linear v2.xyzw
-dcl_output o0.xyzw
-dcl_temps 1
-sample r0.xyzw, v1.xyxx, t0.xyzw, s0
-mul o0.xyzw, r0.xyzw, v2.xyzw
-ret 
-// Approximately 3 instruction slots used
-#endif
-
-const BYTE g_main[] =
-{
-     68,  88,  66,  67, 192, 209, 
-     41, 173, 243, 223, 145,  48, 
-    186, 133, 149, 213,   4, 163, 
-    174,  97,   1,   0,   0,   0, 
-     36,   3,   0,   0,   6,   0, 
-      0,   0,  56,   0,   0,   0, 
-    192,   0,   0,   0,  92,   1, 
-      0,   0, 216,   1,   0,   0, 
-    124,   2,   0,   0, 240,   2, 
-      0,   0,  65, 111, 110,  57, 
-    128,   0,   0,   0, 128,   0, 
-      0,   0,   0,   2, 255, 255, 
-     88,   0,   0,   0,  40,   0, 
-      0,   0,   0,   0,  40,   0, 
-      0,   0,  40,   0,   0,   0, 
-     40,   0,   1,   0,  36,   0, 
-      0,   0,  40,   0,   0,   0, 
-      0,   0,   0,   2, 255, 255, 
-     31,   0,   0,   2,   0,   0, 
-      0, 128,   0,   0,   3, 176, 
-     31,   0,   0,   2,   0,   0, 
-      0, 128,   1,   0,  15, 176, 
-     31,   0,   0,   2,   0,   0, 
-      0, 144,   0,   8,  15, 160, 
-     66,   0,   0,   3,   0,   0, 
-     15, 128,   0,   0, 228, 176, 
-      0,   8, 228, 160,   5,   0, 
-      0,   3,   0,   0,  15, 128, 
-      0,   0, 228, 128,   1,   0, 
-    228, 176,   1,   0,   0,   2, 
-      0,   8,  15, 128,   0,   0, 
-    228, 128, 255, 255,   0,   0, 
-     83,  72,  68,  82, 148,   0, 
-      0,   0,  64,   0,   0,   0, 
-     37,   0,   0,   0,  90,   0, 
-      0,   3,   0,  96,  16,   0, 
-      0,   0,   0,   0,  88,  24, 
-      0,   4,   0, 112,  16,   0, 
-      0,   0,   0,   0,  85,  85, 
-      0,   0,  98,  16,   0,   3, 
-     50,  16,  16,   0,   1,   0, 
-      0,   0,  98,  16,   0,   3, 
-    242,  16,  16,   0,   2,   0, 
-      0,   0, 101,   0,   0,   3, 
-    242,  32,  16,   0,   0,   0, 
-      0,   0, 104,   0,   0,   2, 
-      1,   0,   0,   0,  69,   0, 
-      0,   9, 242,   0,  16,   0, 
-      0,   0,   0,   0,  70,  16, 
-     16,   0,   1,   0,   0,   0, 
-     70, 126,  16,   0,   0,   0, 
-      0,   0,   0,  96,  16,   0, 
-      0,   0,   0,   0,  56,   0, 
-      0,   7, 242,  32,  16,   0, 
-      0,   0,   0,   0,  70,  14, 
-     16,   0,   0,   0,   0,   0, 
-     70,  30,  16,   0,   2,   0, 
-      0,   0,  62,   0,   0,   1, 
-     83,  84,  65,  84, 116,   0, 
-      0,   0,   3,   0,   0,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,  82,  68, 
-     69,  70, 156,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   2,   0,   0,   0, 
-     28,   0,   0,   0,   0,   4, 
-    255, 255,   0,   1,   0,   0, 
-    114,   0,   0,   0,  92,   0, 
-      0,   0,   3,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   1,   0,   0,   0, 
-    103,   0,   0,   0,   2,   0, 
-      0,   0,   5,   0,   0,   0, 
-      4,   0,   0,   0, 255, 255, 
-    255, 255,   0,   0,   0,   0, 
-      1,   0,   0,   0,  13,   0, 
-      0,   0, 116, 104, 101,  83, 
-     97, 109, 112, 108, 101, 114, 
-      0, 116, 104, 101,  84, 101, 
-    120, 116, 117, 114, 101,   0, 
-     77, 105,  99, 114, 111, 115, 
-    111, 102, 116,  32,  40,  82, 
-     41,  32,  72,  76,  83,  76, 
-     32,  83, 104,  97, 100, 101, 
-    114,  32,  67, 111, 109, 112, 
-    105, 108, 101, 114,  32,  49, 
-     48,  46,  49,   0, 171, 171, 
-     73,  83,  71,  78, 108,   0, 
-      0,   0,   3,   0,   0,   0, 
-      8,   0,   0,   0,  80,   0, 
-      0,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0,   3,   0, 
-      0,   0,   0,   0,   0,   0, 
-     15,   0,   0,   0,  92,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   1,   0,   0,   0, 
-      3,   3,   0,   0, 101,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   2,   0,   0,   0, 
-     15,  15,   0,   0,  83,  86, 
-     95,  80,  79,  83,  73,  84, 
-     73,  79,  78,   0,  84,  69, 
-     88,  67,  79,  79,  82,  68, 
-      0,  67,  79,  76,  79,  82, 
-      0, 171,  79,  83,  71,  78, 
-     44,   0,   0,   0,   1,   0, 
-      0,   0,   8,   0,   0,   0, 
-     32,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,   0,   0, 
-      0,   0,  15,   0,   0,   0, 
-     83,  86,  95,  84,  65,  82, 
-     71,  69,  84,   0, 171, 171
-};
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Buffer Definitions: 
+//
+// cbuffer Constants
+// {
+//
+//   float scRGB_output;                // Offset:    0 Size:     4
+//   float SDR_whitelevel;              // Offset:    4 Size:     4
+//   float HDR_whitelevel;              // Offset:    8 Size:     4 [unused]
+//   float maxCLL;                      // Offset:   12 Size:     4 [unused]
+//   float4 Yoffset;                    // Offset:   16 Size:    16 [unused]
+//   float4 Rcoeff;                     // Offset:   32 Size:    16 [unused]
+//   float4 Gcoeff;                     // Offset:   48 Size:    16 [unused]
+//   float4 Bcoeff;                     // Offset:   64 Size:    16 [unused]
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim      HLSL Bind  Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// theSampler                        sampler      NA          NA             s0      1 
+// theTexture                        texture  float4          2d             t0      1 
+// Constants                         cbuffer      NA          NA            cb0      1 
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION              0   xyzw        0      POS   float       
+// TEXCOORD                 0   xy          1     NONE   float   xy  
+// COLOR                    0   xyzw        2     NONE   float   xyzw
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
+//
+//
+// Constant buffer to DX9 shader constant mappings:
+//
+// Target Reg Buffer  Start Reg # of Regs        Data Conversion
+// ---------- ------- --------- --------- ----------------------
+// c0         cb0             0         1  ( FLT, FLT, FLT, FLT)
+//
+//
+// Sampler/Resource to DX9 shader sampler mappings:
+//
+// Target Sampler Source Sampler  Source Resource
+// -------------- --------------- ----------------
+// s0             s0              t0               
+//
+//
+// Level9 shader bytecode:
+//
+    ps_2_0
+    def c1, 0.0125000002, 0, 0, 0
+    dcl t0.xy
+    dcl t1
+    dcl_2d s0
+    texld r0, t0, s0
+    mul r1.w, c0.x, c0.x
+    mul r1.xyz, r0, c0.y
+    mul r1.xyz, r1, c1.x
+    cmp r0.xyz, -r1.w, r0, r1
+    mul r0, r0, t1
+    mov oC0, r0
+
+// approximately 7 instruction slots used (1 texture, 6 arithmetic)
+ps_4_0
+dcl_constantbuffer CB0[1], immediateIndexed
+dcl_sampler s0, mode_default
+dcl_resource_texture2d (float,float,float,float) t0
+dcl_input_ps linear v1.xy
+dcl_input_ps linear v2.xyzw
+dcl_output o0.xyzw
+dcl_temps 2
+ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x
+sample r1.xyzw, v1.xyxx, t0.xyzw, s0
+mul r0.yzw, r1.xxyz, cb0[0].yyyy
+mul r0.yzw, r0.yyzw, l(0.000000, 0.012500, 0.012500, 0.012500)
+movc r1.xyz, r0.xxxx, r0.yzwy, r1.xyzx
+mul o0.xyzw, r1.xyzw, v2.xyzw
+ret 
+// Approximately 7 instruction slots used
+#endif
+
+const BYTE g_main[] =
+{
+     68,  88,  66,  67, 129,  29, 
+    250,  77,  23, 118,   4, 254, 
+    122,  59, 184, 144, 253, 202, 
+    233, 166,   1,   0,   0,   0, 
+    172,   5,   0,   0,   6,   0, 
+      0,   0,  56,   0,   0,   0, 
+     40,   1,   0,   0, 108,   2, 
+      0,   0, 232,   2,   0,   0, 
+      4,   5,   0,   0, 120,   5, 
+      0,   0,  65, 111, 110,  57, 
+    232,   0,   0,   0, 232,   0, 
+      0,   0,   0,   2, 255, 255, 
+    180,   0,   0,   0,  52,   0, 
+      0,   0,   1,   0,  40,   0, 
+      0,   0,  52,   0,   0,   0, 
+     52,   0,   1,   0,  36,   0, 
+      0,   0,  52,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   2, 255, 255, 
+     81,   0,   0,   5,   1,   0, 
+     15, 160, 205, 204,  76,  60, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     31,   0,   0,   2,   0,   0, 
+      0, 128,   0,   0,   3, 176, 
+     31,   0,   0,   2,   0,   0, 
+      0, 128,   1,   0,  15, 176, 
+     31,   0,   0,   2,   0,   0, 
+      0, 144,   0,   8,  15, 160, 
+     66,   0,   0,   3,   0,   0, 
+     15, 128,   0,   0, 228, 176, 
+      0,   8, 228, 160,   5,   0, 
+      0,   3,   1,   0,   8, 128, 
+      0,   0,   0, 160,   0,   0, 
+      0, 160,   5,   0,   0,   3, 
+      1,   0,   7, 128,   0,   0, 
+    228, 128,   0,   0,  85, 160, 
+      5,   0,   0,   3,   1,   0, 
+      7, 128,   1,   0, 228, 128, 
+      1,   0,   0, 160,  88,   0, 
+      0,   4,   0,   0,   7, 128, 
+      1,   0, 255, 129,   0,   0, 
+    228, 128,   1,   0, 228, 128, 
+      5,   0,   0,   3,   0,   0, 
+     15, 128,   0,   0, 228, 128, 
+      1,   0, 228, 176,   1,   0, 
+      0,   2,   0,   8,  15, 128, 
+      0,   0, 228, 128, 255, 255, 
+      0,   0,  83,  72,  68,  82, 
+     60,   1,   0,   0,  64,   0, 
+      0,   0,  79,   0,   0,   0, 
+     89,   0,   0,   4,  70, 142, 
+     32,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,  90,   0, 
+      0,   3,   0,  96,  16,   0, 
+      0,   0,   0,   0,  88,  24, 
+      0,   4,   0, 112,  16,   0, 
+      0,   0,   0,   0,  85,  85, 
+      0,   0,  98,  16,   0,   3, 
+     50,  16,  16,   0,   1,   0, 
+      0,   0,  98,  16,   0,   3, 
+    242,  16,  16,   0,   2,   0, 
+      0,   0, 101,   0,   0,   3, 
+    242,  32,  16,   0,   0,   0, 
+      0,   0, 104,   0,   0,   2, 
+      2,   0,   0,   0,  57,   0, 
+      0,  11,  18,   0,  16,   0, 
+      0,   0,   0,   0,   2,  64, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     10, 128,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0,  70, 126,  16,   0, 
+      0,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+     56,   0,   0,   8, 226,   0, 
+     16,   0,   0,   0,   0,   0, 
+      6,   9,  16,   0,   1,   0, 
+      0,   0,  86, 133,  32,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  56,   0,   0,  10, 
+    226,   0,  16,   0,   0,   0, 
+      0,   0,  86,  14,  16,   0, 
+      0,   0,   0,   0,   2,  64, 
+      0,   0,   0,   0,   0,   0, 
+    205, 204,  76,  60, 205, 204, 
+     76,  60, 205, 204,  76,  60, 
+     55,   0,   0,   9, 114,   0, 
+     16,   0,   1,   0,   0,   0, 
+      6,   0,  16,   0,   0,   0, 
+      0,   0, 150,   7,  16,   0, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   1,   0,   0,   0, 
+     56,   0,   0,   7, 242,  32, 
+     16,   0,   0,   0,   0,   0, 
+     70,  14,  16,   0,   1,   0, 
+      0,   0,  70,  30,  16,   0, 
+      2,   0,   0,   0,  62,   0, 
+      0,   1,  83,  84,  65,  84, 
+    116,   0,   0,   0,   7,   0, 
+      0,   0,   2,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     82,  68,  69,  70,  20,   2, 
+      0,   0,   1,   0,   0,   0, 
+    156,   0,   0,   0,   3,   0, 
+      0,   0,  28,   0,   0,   0, 
+      0,   4, 255, 255,   0,   1, 
+      0,   0, 233,   1,   0,   0, 
+    124,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0, 135,   0,   0,   0, 
+      2,   0,   0,   0,   5,   0, 
+      0,   0,   4,   0,   0,   0, 
+    255, 255, 255, 255,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+     13,   0,   0,   0, 146,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   1,   0,   0,   0, 
+    116, 104, 101,  83,  97, 109, 
+    112, 108, 101, 114,   0, 116, 
+    104, 101,  84, 101, 120, 116, 
+    117, 114, 101,   0,  67, 111, 
+    110, 115, 116,  97, 110, 116, 
+    115,   0, 146,   0,   0,   0, 
+      8,   0,   0,   0, 180,   0, 
+      0,   0,  80,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0, 116,   1,   0,   0, 
+      0,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+    132,   1,   0,   0,   0,   0, 
+      0,   0, 148,   1,   0,   0, 
+      4,   0,   0,   0,   4,   0, 
+      0,   0,   2,   0,   0,   0, 
+    132,   1,   0,   0,   0,   0, 
+      0,   0, 163,   1,   0,   0, 
+      8,   0,   0,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+    132,   1,   0,   0,   0,   0, 
+      0,   0, 178,   1,   0,   0, 
+     12,   0,   0,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+    132,   1,   0,   0,   0,   0, 
+      0,   0, 185,   1,   0,   0, 
+     16,   0,   0,   0,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+    196,   1,   0,   0,   0,   0, 
+      0,   0, 212,   1,   0,   0, 
+     32,   0,   0,   0,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+    196,   1,   0,   0,   0,   0, 
+      0,   0, 219,   1,   0,   0, 
+     48,   0,   0,   0,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+    196,   1,   0,   0,   0,   0, 
+      0,   0, 226,   1,   0,   0, 
+     64,   0,   0,   0,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+    196,   1,   0,   0,   0,   0, 
+      0,   0, 115,  99,  82,  71, 
+     66,  95, 111, 117, 116, 112, 
+    117, 116,   0, 171, 171, 171, 
+      0,   0,   3,   0,   1,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  83,  68, 
+     82,  95, 119, 104, 105, 116, 
+    101, 108, 101, 118, 101, 108, 
+      0,  72,  68,  82,  95, 119, 
+    104, 105, 116, 101, 108, 101, 
+    118, 101, 108,   0, 109,  97, 
+    120,  67,  76,  76,   0,  89, 
+    111, 102, 102, 115, 101, 116, 
+      0, 171, 171, 171,   1,   0, 
+      3,   0,   1,   0,   4,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  82,  99, 111, 101, 
+    102, 102,   0,  71,  99, 111, 
+    101, 102, 102,   0,  66,  99, 
+    111, 101, 102, 102,   0,  77, 
+    105,  99, 114, 111, 115, 111, 
+    102, 116,  32,  40,  82,  41, 
+     32,  72,  76,  83,  76,  32, 
+     83, 104,  97, 100, 101, 114, 
+     32,  67, 111, 109, 112, 105, 
+    108, 101, 114,  32,  49,  48, 
+     46,  49,   0, 171, 171, 171, 
+     73,  83,  71,  78, 108,   0, 
+      0,   0,   3,   0,   0,   0, 
+      8,   0,   0,   0,  80,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+     15,   0,   0,   0,  92,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,   1,   0,   0,   0, 
+      3,   3,   0,   0, 101,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,   2,   0,   0,   0, 
+     15,  15,   0,   0,  83,  86, 
+     95,  80,  79,  83,  73,  84, 
+     73,  79,  78,   0,  84,  69, 
+     88,  67,  79,  79,  82,  68, 
+      0,  67,  79,  76,  79,  82, 
+      0, 171,  79,  83,  71,  78, 
+     44,   0,   0,   0,   1,   0, 
+      0,   0,   8,   0,   0,   0, 
+     32,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+     83,  86,  95,  84,  65,  82, 
+     71,  69,  84,   0, 171, 171
+};

+ 2 - 7
src/render/direct3d11/D3D11_PixelShader_Textures.hlsl

@@ -1,14 +1,9 @@
 Texture2D theTexture : register(t0);
 SamplerState theSampler : register(s0);
 
-struct PixelShaderInput
-{
-    float4 pos : SV_POSITION;
-    float2 tex : TEXCOORD0;
-    float4 color : COLOR0;
-};
+#include "D3D11_PixelShader_Common.incl"
 
 float4 main(PixelShaderInput input) : SV_TARGET
 {
-    return theTexture.Sample(theSampler, input.tex) * input.color;
+    return GetOutputColor(theTexture.Sample(theSampler, input.tex)) * input.color;
 }

+ 572 - 382
src/render/direct3d11/D3D11_PixelShader_YUV.h

@@ -1,382 +1,572 @@
-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
-//
-//
-// Buffer Definitions: 
-//
-// cbuffer Constants
-// {
-//
-//   float4 Yoffset;                    // Offset:    0 Size:    16
-//   float4 Rcoeff;                     // Offset:   16 Size:    16
-//   float4 Gcoeff;                     // Offset:   32 Size:    16
-//   float4 Bcoeff;                     // Offset:   48 Size:    16
-//
-// }
-//
-//
-// Resource Bindings:
-//
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// theSampler                        sampler      NA          NA             s0      1 
-// theTextureY                       texture  float4          2d             t0      1 
-// theTextureU                       texture  float4          2d             t1      1 
-// theTextureV                       texture  float4          2d             t2      1 
-// Constants                         cbuffer      NA          NA            cb0      1 
-//
-//
-//
-// Input signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_POSITION              0   xyzw        0      POS   float       
-// TEXCOORD                 0   xy          1     NONE   float   xy  
-// COLOR                    0   xyzw        2     NONE   float   xyzw
-//
-//
-// Output signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
-//
-//
-// Constant buffer to DX9 shader constant mappings:
-//
-// Target Reg Buffer  Start Reg # of Regs        Data Conversion
-// ---------- ------- --------- --------- ----------------------
-// c0         cb0             0         4  ( FLT, FLT, FLT, FLT)
-//
-//
-// Sampler/Resource to DX9 shader sampler mappings:
-//
-// Target Sampler Source Sampler  Source Resource
-// -------------- --------------- ----------------
-// s0             s0              t0               
-// s1             s0              t1               
-// s2             s0              t2               
-//
-//
-// Level9 shader bytecode:
-//
-    ps_2_0
-    def c4, 1, 0, 0, 0
-    dcl t0.xy
-    dcl t1
-    dcl_2d s0
-    dcl_2d s1
-    dcl_2d s2
-    texld r0, t0, s0
-    texld r1, t0, s1
-    texld r2, t0, s2
-    mov r0.y, r1.x
-    mov r0.z, r2.x
-    add r0.xyz, r0, c0
-    dp3 r1.x, r0, c1
-    dp3 r1.y, r0, c2
-    dp3 r1.z, r0, c3
-    mov r1.w, c4.x
-    mul r0, r1, t1
-    mov oC0, r0
-
-// approximately 12 instruction slots used (3 texture, 9 arithmetic)
-ps_4_0
-dcl_constantbuffer CB0[4], immediateIndexed
-dcl_sampler s0, mode_default
-dcl_resource_texture2d (float,float,float,float) t0
-dcl_resource_texture2d (float,float,float,float) t1
-dcl_resource_texture2d (float,float,float,float) t2
-dcl_input_ps linear v1.xy
-dcl_input_ps linear v2.xyzw
-dcl_output o0.xyzw
-dcl_temps 2
-sample r0.xyzw, v1.xyxx, t0.xyzw, s0
-sample r1.xyzw, v1.xyxx, t1.xyzw, s0
-mov r0.y, r1.x
-sample r1.xyzw, v1.xyxx, t2.xyzw, s0
-mov r0.z, r1.x
-add r0.xyz, r0.xyzx, cb0[0].xyzx
-dp3 r1.x, r0.xyzx, cb0[1].xyzx
-dp3 r1.y, r0.xyzx, cb0[2].xyzx
-dp3 r1.z, r0.xyzx, cb0[3].xyzx
-mov r1.w, l(1.000000)
-mul o0.xyzw, r1.xyzw, v2.xyzw
-ret 
-// Approximately 12 instruction slots used
-#endif
-
-const BYTE g_main[] =
-{
-     68,  88,  66,  67,  17,  27, 
-    202,  87,  93, 193, 186, 139, 
-    251, 175, 168, 151, 229, 182, 
-    100, 211,   1,   0,   0,   0, 
-     76,   6,   0,   0,   6,   0, 
-      0,   0,  56,   0,   0,   0, 
-    136,   1,   0,   0,  88,   3, 
-      0,   0, 212,   3,   0,   0, 
-    164,   5,   0,   0,  24,   6, 
-      0,   0,  65, 111, 110,  57, 
-     72,   1,   0,   0,  72,   1, 
-      0,   0,   0,   2, 255, 255, 
-     12,   1,   0,   0,  60,   0, 
-      0,   0,   1,   0,  48,   0, 
-      0,   0,  60,   0,   0,   0, 
-     60,   0,   3,   0,  36,   0, 
-      0,   0,  60,   0,   0,   0, 
-      0,   0,   1,   0,   1,   0, 
-      2,   0,   2,   0,   0,   0, 
-      0,   0,   4,   0,   0,   0, 
-      0,   0,   0,   0,   0,   2, 
-    255, 255,  81,   0,   0,   5, 
-      4,   0,  15, 160,   0,   0, 
-    128,  63,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  31,   0,   0,   2, 
-      0,   0,   0, 128,   0,   0, 
-      3, 176,  31,   0,   0,   2, 
-      0,   0,   0, 128,   1,   0, 
-     15, 176,  31,   0,   0,   2, 
-      0,   0,   0, 144,   0,   8, 
-     15, 160,  31,   0,   0,   2, 
-      0,   0,   0, 144,   1,   8, 
-     15, 160,  31,   0,   0,   2, 
-      0,   0,   0, 144,   2,   8, 
-     15, 160,  66,   0,   0,   3, 
-      0,   0,  15, 128,   0,   0, 
-    228, 176,   0,   8, 228, 160, 
-     66,   0,   0,   3,   1,   0, 
-     15, 128,   0,   0, 228, 176, 
-      1,   8, 228, 160,  66,   0, 
-      0,   3,   2,   0,  15, 128, 
-      0,   0, 228, 176,   2,   8, 
-    228, 160,   1,   0,   0,   2, 
-      0,   0,   2, 128,   1,   0, 
-      0, 128,   1,   0,   0,   2, 
-      0,   0,   4, 128,   2,   0, 
-      0, 128,   2,   0,   0,   3, 
-      0,   0,   7, 128,   0,   0, 
-    228, 128,   0,   0, 228, 160, 
-      8,   0,   0,   3,   1,   0, 
-      1, 128,   0,   0, 228, 128, 
-      1,   0, 228, 160,   8,   0, 
-      0,   3,   1,   0,   2, 128, 
-      0,   0, 228, 128,   2,   0, 
-    228, 160,   8,   0,   0,   3, 
-      1,   0,   4, 128,   0,   0, 
-    228, 128,   3,   0, 228, 160, 
-      1,   0,   0,   2,   1,   0, 
-      8, 128,   4,   0,   0, 160, 
-      5,   0,   0,   3,   0,   0, 
-     15, 128,   1,   0, 228, 128, 
-      1,   0, 228, 176,   1,   0, 
-      0,   2,   0,   8,  15, 128, 
-      0,   0, 228, 128, 255, 255, 
-      0,   0,  83,  72,  68,  82, 
-    200,   1,   0,   0,  64,   0, 
-      0,   0, 114,   0,   0,   0, 
-     89,   0,   0,   4,  70, 142, 
-     32,   0,   0,   0,   0,   0, 
-      4,   0,   0,   0,  90,   0, 
-      0,   3,   0,  96,  16,   0, 
-      0,   0,   0,   0,  88,  24, 
-      0,   4,   0, 112,  16,   0, 
-      0,   0,   0,   0,  85,  85, 
-      0,   0,  88,  24,   0,   4, 
-      0, 112,  16,   0,   1,   0, 
-      0,   0,  85,  85,   0,   0, 
-     88,  24,   0,   4,   0, 112, 
-     16,   0,   2,   0,   0,   0, 
-     85,  85,   0,   0,  98,  16, 
-      0,   3,  50,  16,  16,   0, 
-      1,   0,   0,   0,  98,  16, 
-      0,   3, 242,  16,  16,   0, 
-      2,   0,   0,   0, 101,   0, 
-      0,   3, 242,  32,  16,   0, 
-      0,   0,   0,   0, 104,   0, 
-      0,   2,   2,   0,   0,   0, 
-     69,   0,   0,   9, 242,   0, 
-     16,   0,   0,   0,   0,   0, 
-     70,  16,  16,   0,   1,   0, 
-      0,   0,  70, 126,  16,   0, 
-      0,   0,   0,   0,   0,  96, 
-     16,   0,   0,   0,   0,   0, 
-     69,   0,   0,   9, 242,   0, 
-     16,   0,   1,   0,   0,   0, 
-     70,  16,  16,   0,   1,   0, 
-      0,   0,  70, 126,  16,   0, 
-      1,   0,   0,   0,   0,  96, 
-     16,   0,   0,   0,   0,   0, 
-     54,   0,   0,   5,  34,   0, 
-     16,   0,   0,   0,   0,   0, 
-     10,   0,  16,   0,   1,   0, 
-      0,   0,  69,   0,   0,   9, 
-    242,   0,  16,   0,   1,   0, 
-      0,   0,  70,  16,  16,   0, 
-      1,   0,   0,   0,  70, 126, 
-     16,   0,   2,   0,   0,   0, 
-      0,  96,  16,   0,   0,   0, 
-      0,   0,  54,   0,   0,   5, 
-     66,   0,  16,   0,   0,   0, 
-      0,   0,  10,   0,  16,   0, 
-      1,   0,   0,   0,   0,   0, 
-      0,   8, 114,   0,  16,   0, 
-      0,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-     70, 130,  32,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-     16,   0,   0,   8,  18,   0, 
-     16,   0,   1,   0,   0,   0, 
-     70,   2,  16,   0,   0,   0, 
-      0,   0,  70, 130,  32,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,  16,   0,   0,   8, 
-     34,   0,  16,   0,   1,   0, 
-      0,   0,  70,   2,  16,   0, 
-      0,   0,   0,   0,  70, 130, 
-     32,   0,   0,   0,   0,   0, 
-      2,   0,   0,   0,  16,   0, 
-      0,   8,  66,   0,  16,   0, 
-      1,   0,   0,   0,  70,   2, 
-     16,   0,   0,   0,   0,   0, 
-     70, 130,  32,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-     54,   0,   0,   5, 130,   0, 
-     16,   0,   1,   0,   0,   0, 
-      1,  64,   0,   0,   0,   0, 
-    128,  63,  56,   0,   0,   7, 
-    242,  32,  16,   0,   0,   0, 
-      0,   0,  70,  14,  16,   0, 
-      1,   0,   0,   0,  70,  30, 
-     16,   0,   2,   0,   0,   0, 
-     62,   0,   0,   1,  83,  84, 
-     65,  84, 116,   0,   0,   0, 
-     12,   0,   0,   0,   2,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,   5,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  82,  68,  69,  70, 
-    200,   1,   0,   0,   1,   0, 
-      0,   0, 248,   0,   0,   0, 
-      5,   0,   0,   0,  28,   0, 
-      0,   0,   0,   4, 255, 255, 
-      0,   1,   0,   0, 157,   1, 
-      0,   0, 188,   0,   0,   0, 
-      3,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-      1,   0,   0,   0, 199,   0, 
-      0,   0,   2,   0,   0,   0, 
-      5,   0,   0,   0,   4,   0, 
-      0,   0, 255, 255, 255, 255, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,  13,   0,   0,   0, 
-    211,   0,   0,   0,   2,   0, 
-      0,   0,   5,   0,   0,   0, 
-      4,   0,   0,   0, 255, 255, 
-    255, 255,   1,   0,   0,   0, 
-      1,   0,   0,   0,  13,   0, 
-      0,   0, 223,   0,   0,   0, 
-      2,   0,   0,   0,   5,   0, 
-      0,   0,   4,   0,   0,   0, 
-    255, 255, 255, 255,   2,   0, 
-      0,   0,   1,   0,   0,   0, 
-     13,   0,   0,   0, 235,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   1,   0,   0,   0, 
-    116, 104, 101,  83,  97, 109, 
-    112, 108, 101, 114,   0, 116, 
-    104, 101,  84, 101, 120, 116, 
-    117, 114, 101,  89,   0, 116, 
-    104, 101,  84, 101, 120, 116, 
-    117, 114, 101,  85,   0, 116, 
-    104, 101,  84, 101, 120, 116, 
-    117, 114, 101,  86,   0,  67, 
-    111, 110, 115, 116,  97, 110, 
-    116, 115,   0, 171, 171, 171, 
-    235,   0,   0,   0,   4,   0, 
-      0,   0,  16,   1,   0,   0, 
-     64,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-    112,   1,   0,   0,   0,   0, 
-      0,   0,  16,   0,   0,   0, 
-      2,   0,   0,   0, 120,   1, 
-      0,   0,   0,   0,   0,   0, 
-    136,   1,   0,   0,  16,   0, 
-      0,   0,  16,   0,   0,   0, 
-      2,   0,   0,   0, 120,   1, 
-      0,   0,   0,   0,   0,   0, 
-    143,   1,   0,   0,  32,   0, 
-      0,   0,  16,   0,   0,   0, 
-      2,   0,   0,   0, 120,   1, 
-      0,   0,   0,   0,   0,   0, 
-    150,   1,   0,   0,  48,   0, 
-      0,   0,  16,   0,   0,   0, 
-      2,   0,   0,   0, 120,   1, 
-      0,   0,   0,   0,   0,   0, 
-     89, 111, 102, 102, 115, 101, 
-    116,   0,   1,   0,   3,   0, 
-      1,   0,   4,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-     82,  99, 111, 101, 102, 102, 
-      0,  71,  99, 111, 101, 102, 
-    102,   0,  66,  99, 111, 101, 
-    102, 102,   0,  77, 105,  99, 
-    114, 111, 115, 111, 102, 116, 
-     32,  40,  82,  41,  32,  72, 
-     76,  83,  76,  32,  83, 104, 
-     97, 100, 101, 114,  32,  67, 
-    111, 109, 112, 105, 108, 101, 
-    114,  32,  49,  48,  46,  49, 
-      0, 171, 171, 171,  73,  83, 
-     71,  78, 108,   0,   0,   0, 
-      3,   0,   0,   0,   8,   0, 
-      0,   0,  80,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   3,   0,   0,   0, 
-      0,   0,   0,   0,  15,   0, 
-      0,   0,  92,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-      1,   0,   0,   0,   3,   3, 
-      0,   0, 101,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-      2,   0,   0,   0,  15,  15, 
-      0,   0,  83,  86,  95,  80, 
-     79,  83,  73,  84,  73,  79, 
-     78,   0,  84,  69,  88,  67, 
-     79,  79,  82,  68,   0,  67, 
-     79,  76,  79,  82,   0, 171, 
-     79,  83,  71,  78,  44,   0, 
-      0,   0,   1,   0,   0,   0, 
-      8,   0,   0,   0,  32,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   3,   0, 
-      0,   0,   0,   0,   0,   0, 
-     15,   0,   0,   0,  83,  86, 
-     95,  84,  65,  82,  71,  69, 
-     84,   0, 171, 171
-};
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Buffer Definitions: 
+//
+// cbuffer Constants
+// {
+//
+//   float scRGB_output;                // Offset:    0 Size:     4
+//   float SDR_whitelevel;              // Offset:    4 Size:     4 [unused]
+//   float HDR_whitelevel;              // Offset:    8 Size:     4 [unused]
+//   float maxCLL;                      // Offset:   12 Size:     4 [unused]
+//   float4 Yoffset;                    // Offset:   16 Size:    16
+//   float4 Rcoeff;                     // Offset:   32 Size:    16
+//   float4 Gcoeff;                     // Offset:   48 Size:    16
+//   float4 Bcoeff;                     // Offset:   64 Size:    16
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim      HLSL Bind  Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// theSampler                        sampler      NA          NA             s0      1 
+// theTextureY                       texture  float4          2d             t0      1 
+// theTextureU                       texture  float4          2d             t1      1 
+// theTextureV                       texture  float4          2d             t2      1 
+// Constants                         cbuffer      NA          NA            cb0      1 
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION              0   xyzw        0      POS   float       
+// TEXCOORD                 0   xy          1     NONE   float   xy  
+// COLOR                    0   xyzw        2     NONE   float   xyzw
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_TARGET                0   xyzw        0   TARGET   float   xyzw
+//
+//
+// Constant buffer to DX9 shader constant mappings:
+//
+// Target Reg Buffer  Start Reg # of Regs        Data Conversion
+// ---------- ------- --------- --------- ----------------------
+// c0         cb0             0         5  ( FLT, FLT, FLT, FLT)
+//
+//
+// Sampler/Resource to DX9 shader sampler mappings:
+//
+// Target Sampler Source Sampler  Source Resource
+// -------------- --------------- ----------------
+// s0             s0              t0               
+// s1             s0              t1               
+// s2             s0              t2               
+//
+//
+// Level9 shader bytecode:
+//
+    ps_2_0
+    def c5, 0.0404499993, 0.0773993805, 0.0549999997, 0.947867334
+    def c6, 2.4000001, 1, 0, 0
+    dcl t0.xy
+    dcl t1
+    dcl_2d s0
+    dcl_2d s1
+    dcl_2d s2
+    texld r0, t0, s0
+    texld r1, t0, s1
+    texld r2, t0, s2
+    mov r0.y, r1.x
+    mov r0.z, r2.x
+    add r0.xyz, r0, c1
+    dp3 r1.x, r0, c2
+    add r0.w, r1.x, c5.z
+    abs r0.w, r0.w
+    mul r0.w, r0.w, c5.w
+    pow r1.w, r0.w, c6.x
+    add r0.w, -r1.x, c5.x
+    mul r2.x, r1.x, c5.y
+    cmp r2.x, r0.w, r2.x, r1.w
+    dp3 r1.y, r0, c3
+    dp3 r1.z, r0, c4
+    add r1.w, r1.y, c5.z
+    abs r1.w, r1.w
+    mul r1.w, r1.w, c5.w
+    pow r2.w, r1.w, c6.x
+    add r1.w, -r1.y, c5.x
+    mul r0.x, r1.y, c5.y
+    cmp r2.y, r1.w, r0.x, r2.w
+    add r1.w, r1.z, c5.z
+    abs r1.w, r1.w
+    mul r1.w, r1.w, c5.w
+    pow r2.w, r1.w, c6.x
+    add r1.w, -r1.z, c5.x
+    mul r0.x, r1.z, c5.y
+    cmp r2.z, r1.w, r0.x, r2.w
+    mul r1.w, c0.x, c0.x
+    cmp r0.xyz, -r1.w, r1, r2
+    mov r0.w, c6.y
+    mul r0, r0, t1
+    mov oC0, r0
+
+// approximately 41 instruction slots used (3 texture, 38 arithmetic)
+ps_4_0
+dcl_constantbuffer CB0[5], immediateIndexed
+dcl_sampler s0, mode_default
+dcl_resource_texture2d (float,float,float,float) t0
+dcl_resource_texture2d (float,float,float,float) t1
+dcl_resource_texture2d (float,float,float,float) t2
+dcl_input_ps linear v1.xy
+dcl_input_ps linear v2.xyzw
+dcl_output o0.xyzw
+dcl_temps 4
+sample r0.xyzw, v1.xyxx, t0.xyzw, s0
+sample r1.xyzw, v1.xyxx, t1.xyzw, s0
+sample r2.xyzw, v1.xyxx, t2.yzxw, s0
+mov r2.x, r0.x
+mov r2.y, r1.x
+add r0.xyz, r2.xyzx, cb0[1].xyzx
+dp3 r1.x, r0.xyzx, cb0[2].xyzx
+dp3 r1.y, r0.xyzx, cb0[3].xyzx
+dp3 r1.z, r0.xyzx, cb0[4].xyzx
+ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x
+if_nz r0.x
+  ge r0.xyz, l(0.040450, 0.040450, 0.040450, 0.000000), r1.xyzx
+  mul r2.xyz, r1.xyzx, l(0.077399, 0.077399, 0.077399, 0.000000)
+  add r3.xyz, r1.xyzx, l(0.055000, 0.055000, 0.055000, 0.000000)
+  mul r3.xyz, |r3.xyzx|, l(0.947867, 0.947867, 0.947867, 0.000000)
+  log r3.xyz, r3.xyzx
+  mul r3.xyz, r3.xyzx, l(2.400000, 2.400000, 2.400000, 0.000000)
+  exp r3.xyz, r3.xyzx
+  movc r1.xyz, r0.xyzx, r2.xyzx, r3.xyzx
+endif 
+mov r1.w, l(1.000000)
+mul o0.xyzw, r1.xyzw, v2.xyzw
+ret 
+// Approximately 23 instruction slots used
+#endif
+
+const BYTE g_main[] =
+{
+     68,  88,  66,  67,   9,  92, 
+    101, 235, 212,  83,  42, 215, 
+    158, 193, 215,  73, 102,  13, 
+    226, 183,   1,   0,   0,   0, 
+    212,   9,   0,   0,   6,   0, 
+      0,   0,  56,   0,   0,   0, 
+     20,   3,   0,   0,  56,   6, 
+      0,   0, 180,   6,   0,   0, 
+     44,   9,   0,   0, 160,   9, 
+      0,   0,  65, 111, 110,  57, 
+    212,   2,   0,   0, 212,   2, 
+      0,   0,   0,   2, 255, 255, 
+    152,   2,   0,   0,  60,   0, 
+      0,   0,   1,   0,  48,   0, 
+      0,   0,  60,   0,   0,   0, 
+     60,   0,   3,   0,  36,   0, 
+      0,   0,  60,   0,   0,   0, 
+      0,   0,   1,   0,   1,   0, 
+      2,   0,   2,   0,   0,   0, 
+      0,   0,   5,   0,   0,   0, 
+      0,   0,   0,   0,   0,   2, 
+    255, 255,  81,   0,   0,   5, 
+      5,   0,  15, 160, 230, 174, 
+     37,  61, 145, 131, 158,  61, 
+    174,  71,  97,  61, 111, 167, 
+    114,  63,  81,   0,   0,   5, 
+      6,   0,  15, 160, 154, 153, 
+     25,  64,   0,   0, 128,  63, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  31,   0,   0,   2, 
+      0,   0,   0, 128,   0,   0, 
+      3, 176,  31,   0,   0,   2, 
+      0,   0,   0, 128,   1,   0, 
+     15, 176,  31,   0,   0,   2, 
+      0,   0,   0, 144,   0,   8, 
+     15, 160,  31,   0,   0,   2, 
+      0,   0,   0, 144,   1,   8, 
+     15, 160,  31,   0,   0,   2, 
+      0,   0,   0, 144,   2,   8, 
+     15, 160,  66,   0,   0,   3, 
+      0,   0,  15, 128,   0,   0, 
+    228, 176,   0,   8, 228, 160, 
+     66,   0,   0,   3,   1,   0, 
+     15, 128,   0,   0, 228, 176, 
+      1,   8, 228, 160,  66,   0, 
+      0,   3,   2,   0,  15, 128, 
+      0,   0, 228, 176,   2,   8, 
+    228, 160,   1,   0,   0,   2, 
+      0,   0,   2, 128,   1,   0, 
+      0, 128,   1,   0,   0,   2, 
+      0,   0,   4, 128,   2,   0, 
+      0, 128,   2,   0,   0,   3, 
+      0,   0,   7, 128,   0,   0, 
+    228, 128,   1,   0, 228, 160, 
+      8,   0,   0,   3,   1,   0, 
+      1, 128,   0,   0, 228, 128, 
+      2,   0, 228, 160,   2,   0, 
+      0,   3,   0,   0,   8, 128, 
+      1,   0,   0, 128,   5,   0, 
+    170, 160,  35,   0,   0,   2, 
+      0,   0,   8, 128,   0,   0, 
+    255, 128,   5,   0,   0,   3, 
+      0,   0,   8, 128,   0,   0, 
+    255, 128,   5,   0, 255, 160, 
+     32,   0,   0,   3,   1,   0, 
+      8, 128,   0,   0, 255, 128, 
+      6,   0,   0, 160,   2,   0, 
+      0,   3,   0,   0,   8, 128, 
+      1,   0,   0, 129,   5,   0, 
+      0, 160,   5,   0,   0,   3, 
+      2,   0,   1, 128,   1,   0, 
+      0, 128,   5,   0,  85, 160, 
+     88,   0,   0,   4,   2,   0, 
+      1, 128,   0,   0, 255, 128, 
+      2,   0,   0, 128,   1,   0, 
+    255, 128,   8,   0,   0,   3, 
+      1,   0,   2, 128,   0,   0, 
+    228, 128,   3,   0, 228, 160, 
+      8,   0,   0,   3,   1,   0, 
+      4, 128,   0,   0, 228, 128, 
+      4,   0, 228, 160,   2,   0, 
+      0,   3,   1,   0,   8, 128, 
+      1,   0,  85, 128,   5,   0, 
+    170, 160,  35,   0,   0,   2, 
+      1,   0,   8, 128,   1,   0, 
+    255, 128,   5,   0,   0,   3, 
+      1,   0,   8, 128,   1,   0, 
+    255, 128,   5,   0, 255, 160, 
+     32,   0,   0,   3,   2,   0, 
+      8, 128,   1,   0, 255, 128, 
+      6,   0,   0, 160,   2,   0, 
+      0,   3,   1,   0,   8, 128, 
+      1,   0,  85, 129,   5,   0, 
+      0, 160,   5,   0,   0,   3, 
+      0,   0,   1, 128,   1,   0, 
+     85, 128,   5,   0,  85, 160, 
+     88,   0,   0,   4,   2,   0, 
+      2, 128,   1,   0, 255, 128, 
+      0,   0,   0, 128,   2,   0, 
+    255, 128,   2,   0,   0,   3, 
+      1,   0,   8, 128,   1,   0, 
+    170, 128,   5,   0, 170, 160, 
+     35,   0,   0,   2,   1,   0, 
+      8, 128,   1,   0, 255, 128, 
+      5,   0,   0,   3,   1,   0, 
+      8, 128,   1,   0, 255, 128, 
+      5,   0, 255, 160,  32,   0, 
+      0,   3,   2,   0,   8, 128, 
+      1,   0, 255, 128,   6,   0, 
+      0, 160,   2,   0,   0,   3, 
+      1,   0,   8, 128,   1,   0, 
+    170, 129,   5,   0,   0, 160, 
+      5,   0,   0,   3,   0,   0, 
+      1, 128,   1,   0, 170, 128, 
+      5,   0,  85, 160,  88,   0, 
+      0,   4,   2,   0,   4, 128, 
+      1,   0, 255, 128,   0,   0, 
+      0, 128,   2,   0, 255, 128, 
+      5,   0,   0,   3,   1,   0, 
+      8, 128,   0,   0,   0, 160, 
+      0,   0,   0, 160,  88,   0, 
+      0,   4,   0,   0,   7, 128, 
+      1,   0, 255, 129,   1,   0, 
+    228, 128,   2,   0, 228, 128, 
+      1,   0,   0,   2,   0,   0, 
+      8, 128,   6,   0,  85, 160, 
+      5,   0,   0,   3,   0,   0, 
+     15, 128,   0,   0, 228, 128, 
+      1,   0, 228, 176,   1,   0, 
+      0,   2,   0,   8,  15, 128, 
+      0,   0, 228, 128, 255, 255, 
+      0,   0,  83,  72,  68,  82, 
+     28,   3,   0,   0,  64,   0, 
+      0,   0, 199,   0,   0,   0, 
+     89,   0,   0,   4,  70, 142, 
+     32,   0,   0,   0,   0,   0, 
+      5,   0,   0,   0,  90,   0, 
+      0,   3,   0,  96,  16,   0, 
+      0,   0,   0,   0,  88,  24, 
+      0,   4,   0, 112,  16,   0, 
+      0,   0,   0,   0,  85,  85, 
+      0,   0,  88,  24,   0,   4, 
+      0, 112,  16,   0,   1,   0, 
+      0,   0,  85,  85,   0,   0, 
+     88,  24,   0,   4,   0, 112, 
+     16,   0,   2,   0,   0,   0, 
+     85,  85,   0,   0,  98,  16, 
+      0,   3,  50,  16,  16,   0, 
+      1,   0,   0,   0,  98,  16, 
+      0,   3, 242,  16,  16,   0, 
+      2,   0,   0,   0, 101,   0, 
+      0,   3, 242,  32,  16,   0, 
+      0,   0,   0,   0, 104,   0, 
+      0,   2,   4,   0,   0,   0, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   0,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0,  70, 126,  16,   0, 
+      0,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0,  70, 126,  16,   0, 
+      1,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+     69,   0,   0,   9, 242,   0, 
+     16,   0,   2,   0,   0,   0, 
+     70,  16,  16,   0,   1,   0, 
+      0,   0, 150, 124,  16,   0, 
+      2,   0,   0,   0,   0,  96, 
+     16,   0,   0,   0,   0,   0, 
+     54,   0,   0,   5,  18,   0, 
+     16,   0,   2,   0,   0,   0, 
+     10,   0,  16,   0,   0,   0, 
+      0,   0,  54,   0,   0,   5, 
+     34,   0,  16,   0,   2,   0, 
+      0,   0,  10,   0,  16,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   8, 114,   0,  16,   0, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   2,   0,   0,   0, 
+     70, 130,  32,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+     16,   0,   0,   8,  18,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,   2,  16,   0,   0,   0, 
+      0,   0,  70, 130,  32,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,  16,   0,   0,   8, 
+     34,   0,  16,   0,   1,   0, 
+      0,   0,  70,   2,  16,   0, 
+      0,   0,   0,   0,  70, 130, 
+     32,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,  16,   0, 
+      0,   8,  66,   0,  16,   0, 
+      1,   0,   0,   0,  70,   2, 
+     16,   0,   0,   0,   0,   0, 
+     70, 130,  32,   0,   0,   0, 
+      0,   0,   4,   0,   0,   0, 
+     57,   0,   0,  11,  18,   0, 
+     16,   0,   0,   0,   0,   0, 
+      2,  64,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  10, 128,  32,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  31,   0,   4,   3, 
+     10,   0,  16,   0,   0,   0, 
+      0,   0,  29,   0,   0,  10, 
+    114,   0,  16,   0,   0,   0, 
+      0,   0,   2,  64,   0,   0, 
+    230, 174,  37,  61, 230, 174, 
+     37,  61, 230, 174,  37,  61, 
+      0,   0,   0,   0,  70,   2, 
+     16,   0,   1,   0,   0,   0, 
+     56,   0,   0,  10, 114,   0, 
+     16,   0,   2,   0,   0,   0, 
+     70,   2,  16,   0,   1,   0, 
+      0,   0,   2,  64,   0,   0, 
+    145, 131, 158,  61, 145, 131, 
+    158,  61, 145, 131, 158,  61, 
+      0,   0,   0,   0,   0,   0, 
+      0,  10, 114,   0,  16,   0, 
+      3,   0,   0,   0,  70,   2, 
+     16,   0,   1,   0,   0,   0, 
+      2,  64,   0,   0, 174,  71, 
+     97,  61, 174,  71,  97,  61, 
+    174,  71,  97,  61,   0,   0, 
+      0,   0,  56,   0,   0,  11, 
+    114,   0,  16,   0,   3,   0, 
+      0,   0,  70,   2,  16, 128, 
+    129,   0,   0,   0,   3,   0, 
+      0,   0,   2,  64,   0,   0, 
+    111, 167, 114,  63, 111, 167, 
+    114,  63, 111, 167, 114,  63, 
+      0,   0,   0,   0,  47,   0, 
+      0,   5, 114,   0,  16,   0, 
+      3,   0,   0,   0,  70,   2, 
+     16,   0,   3,   0,   0,   0, 
+     56,   0,   0,  10, 114,   0, 
+     16,   0,   3,   0,   0,   0, 
+     70,   2,  16,   0,   3,   0, 
+      0,   0,   2,  64,   0,   0, 
+    154, 153,  25,  64, 154, 153, 
+     25,  64, 154, 153,  25,  64, 
+      0,   0,   0,   0,  25,   0, 
+      0,   5, 114,   0,  16,   0, 
+      3,   0,   0,   0,  70,   2, 
+     16,   0,   3,   0,   0,   0, 
+     55,   0,   0,   9, 114,   0, 
+     16,   0,   1,   0,   0,   0, 
+     70,   2,  16,   0,   0,   0, 
+      0,   0,  70,   2,  16,   0, 
+      2,   0,   0,   0,  70,   2, 
+     16,   0,   3,   0,   0,   0, 
+     21,   0,   0,   1,  54,   0, 
+      0,   5, 130,   0,  16,   0, 
+      1,   0,   0,   0,   1,  64, 
+      0,   0,   0,   0, 128,  63, 
+     56,   0,   0,   7, 242,  32, 
+     16,   0,   0,   0,   0,   0, 
+     70,  14,  16,   0,   1,   0, 
+      0,   0,  70,  30,  16,   0, 
+      2,   0,   0,   0,  62,   0, 
+      0,   1,  83,  84,  65,  84, 
+    116,   0,   0,   0,  23,   0, 
+      0,   0,   4,   0,   0,   0, 
+      0,   0,   0,   0,   3,   0, 
+      0,   0,  12,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     82,  68,  69,  70, 112,   2, 
+      0,   0,   1,   0,   0,   0, 
+    248,   0,   0,   0,   5,   0, 
+      0,   0,  28,   0,   0,   0, 
+      0,   4, 255, 255,   0,   1, 
+      0,   0,  69,   2,   0,   0, 
+    188,   0,   0,   0,   3,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0, 199,   0,   0,   0, 
+      2,   0,   0,   0,   5,   0, 
+      0,   0,   4,   0,   0,   0, 
+    255, 255, 255, 255,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+     13,   0,   0,   0, 211,   0, 
+      0,   0,   2,   0,   0,   0, 
+      5,   0,   0,   0,   4,   0, 
+      0,   0, 255, 255, 255, 255, 
+      1,   0,   0,   0,   1,   0, 
+      0,   0,  13,   0,   0,   0, 
+    223,   0,   0,   0,   2,   0, 
+      0,   0,   5,   0,   0,   0, 
+      4,   0,   0,   0, 255, 255, 
+    255, 255,   2,   0,   0,   0, 
+      1,   0,   0,   0,  13,   0, 
+      0,   0, 235,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0, 116, 104, 
+    101,  83,  97, 109, 112, 108, 
+    101, 114,   0, 116, 104, 101, 
+     84, 101, 120, 116, 117, 114, 
+    101,  89,   0, 116, 104, 101, 
+     84, 101, 120, 116, 117, 114, 
+    101,  85,   0, 116, 104, 101, 
+     84, 101, 120, 116, 117, 114, 
+    101,  86,   0,  67, 111, 110, 
+    115, 116,  97, 110, 116, 115, 
+      0, 171, 171, 171, 235,   0, 
+      0,   0,   8,   0,   0,   0, 
+     16,   1,   0,   0,  80,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0, 208,   1, 
+      0,   0,   0,   0,   0,   0, 
+      4,   0,   0,   0,   2,   0, 
+      0,   0, 224,   1,   0,   0, 
+      0,   0,   0,   0, 240,   1, 
+      0,   0,   4,   0,   0,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0, 224,   1,   0,   0, 
+      0,   0,   0,   0, 255,   1, 
+      0,   0,   8,   0,   0,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0, 224,   1,   0,   0, 
+      0,   0,   0,   0,  14,   2, 
+      0,   0,  12,   0,   0,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0, 224,   1,   0,   0, 
+      0,   0,   0,   0,  21,   2, 
+      0,   0,  16,   0,   0,   0, 
+     16,   0,   0,   0,   2,   0, 
+      0,   0,  32,   2,   0,   0, 
+      0,   0,   0,   0,  48,   2, 
+      0,   0,  32,   0,   0,   0, 
+     16,   0,   0,   0,   2,   0, 
+      0,   0,  32,   2,   0,   0, 
+      0,   0,   0,   0,  55,   2, 
+      0,   0,  48,   0,   0,   0, 
+     16,   0,   0,   0,   2,   0, 
+      0,   0,  32,   2,   0,   0, 
+      0,   0,   0,   0,  62,   2, 
+      0,   0,  64,   0,   0,   0, 
+     16,   0,   0,   0,   2,   0, 
+      0,   0,  32,   2,   0,   0, 
+      0,   0,   0,   0, 115,  99, 
+     82,  71,  66,  95, 111, 117, 
+    116, 112, 117, 116,   0, 171, 
+    171, 171,   0,   0,   3,   0, 
+      1,   0,   1,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+     83,  68,  82,  95, 119, 104, 
+    105, 116, 101, 108, 101, 118, 
+    101, 108,   0,  72,  68,  82, 
+     95, 119, 104, 105, 116, 101, 
+    108, 101, 118, 101, 108,   0, 
+    109,  97, 120,  67,  76,  76, 
+      0,  89, 111, 102, 102, 115, 
+    101, 116,   0, 171, 171, 171, 
+      1,   0,   3,   0,   1,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  82,  99, 
+    111, 101, 102, 102,   0,  71, 
+     99, 111, 101, 102, 102,   0, 
+     66,  99, 111, 101, 102, 102, 
+      0,  77, 105,  99, 114, 111, 
+    115, 111, 102, 116,  32,  40, 
+     82,  41,  32,  72,  76,  83, 
+     76,  32,  83, 104,  97, 100, 
+    101, 114,  32,  67, 111, 109, 
+    112, 105, 108, 101, 114,  32, 
+     49,  48,  46,  49,   0, 171, 
+    171, 171,  73,  83,  71,  78, 
+    108,   0,   0,   0,   3,   0, 
+      0,   0,   8,   0,   0,   0, 
+     80,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+     92,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   1,   0, 
+      0,   0,   3,   3,   0,   0, 
+    101,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   2,   0, 
+      0,   0,  15,  15,   0,   0, 
+     83,  86,  95,  80,  79,  83, 
+     73,  84,  73,  79,  78,   0, 
+     84,  69,  88,  67,  79,  79, 
+     82,  68,   0,  67,  79,  76, 
+     79,  82,   0, 171,  79,  83, 
+     71,  78,  44,   0,   0,   0, 
+      1,   0,   0,   0,   8,   0, 
+      0,   0,  32,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,  15,   0, 
+      0,   0,  83,  86,  95,  84, 
+     65,  82,  71,  69,  84,   0, 
+    171, 171
+};

+ 6 - 20
src/render/direct3d11/D3D11_PixelShader_YUV.hlsl

@@ -3,21 +3,7 @@ Texture2D theTextureU : register(t1);
 Texture2D theTextureV : register(t2);
 SamplerState theSampler : register(s0);
 
-struct PixelShaderInput
-{
-    float4 pos : SV_POSITION;
-    float2 tex : TEXCOORD0;
-    float4 color : COLOR0;
-};
-
-cbuffer Constants : register(b0)
-{
-    float4 Yoffset;
-    float4 Rcoeff;
-    float4 Gcoeff;
-    float4 Bcoeff;
-};
-
+#include "D3D11_PixelShader_Common.incl"
 
 float4 main(PixelShaderInput input) : SV_TARGET
 {
@@ -28,11 +14,11 @@ float4 main(PixelShaderInput input) : SV_TARGET
     yuv.y = theTextureU.Sample(theSampler, input.tex).r;
     yuv.z = theTextureV.Sample(theSampler, input.tex).r;
 
+    float3 rgb;
     yuv += Yoffset.xyz;
-    Output.r = dot(yuv, Rcoeff.xyz);
-    Output.g = dot(yuv, Gcoeff.xyz);
-    Output.b = dot(yuv, Bcoeff.xyz);
-    Output.a = 1.0f;
+    rgb.r = dot(yuv, Rcoeff.xyz);
+    rgb.g = dot(yuv, Gcoeff.xyz);
+    rgb.b = dot(yuv, Bcoeff.xyz);
 
-    return Output * input.color;
+    return GetOutputColorFromSRGB(rgb) * input.color;
 }

+ 339 - 339
src/render/direct3d11/D3D11_VertexShader.h

@@ -1,339 +1,339 @@
-#if 0
-//
-// Generated by Microsoft (R) HLSL Shader Compiler 10.1
-//
-//
-// Buffer Definitions: 
-//
-// cbuffer VertexShaderConstants
-// {
-//
-//   row_major float4x4 model;          // Offset:    0 Size:    64
-//   row_major float4x4 projectionAndView;// Offset:   64 Size:    64
-//
-// }
-//
-//
-// Resource Bindings:
-//
-// Name                                 Type  Format         Dim      HLSL Bind  Count
-// ------------------------------ ---------- ------- ----------- -------------- ------
-// VertexShaderConstants             cbuffer      NA          NA            cb0      1 
-//
-//
-//
-// Input signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// POSITION                 0   xyz         0     NONE   float   xyz 
-// TEXCOORD                 0   xy          1     NONE   float   xy  
-// COLOR                    0   xyzw        2     NONE   float   xyzw
-//
-//
-// Output signature:
-//
-// Name                 Index   Mask Register SysValue  Format   Used
-// -------------------- ----- ------ -------- -------- ------- ------
-// SV_POSITION              0   xyzw        0      POS   float   xyzw
-// TEXCOORD                 0   xy          1     NONE   float   xy  
-// COLOR                    0   xyzw        2     NONE   float   xyzw
-//
-//
-// Constant buffer to DX9 shader constant mappings:
-//
-// Target Reg Buffer  Start Reg # of Regs        Data Conversion
-// ---------- ------- --------- --------- ----------------------
-// c1         cb0             0         8  ( FLT, FLT, FLT, FLT)
-//
-//
-// Runtime generated constant mappings:
-//
-// Target Reg                               Constant Description
-// ---------- --------------------------------------------------
-// c0                              Vertex Shader position offset
-//
-//
-// Level9 shader bytecode:
-//
-    vs_2_0
-    dcl_texcoord v0
-    dcl_texcoord1 v1
-    dcl_texcoord2 v2
-    mul r0, v0.y, c2
-    mad r0, v0.x, c1, r0
-    mad r0, v0.z, c3, r0
-    add r0, r0, c4
-    mul r1, r0.y, c6
-    mad r1, r0.x, c5, r1
-    mad r1, r0.z, c7, r1
-    mad r0, r0.w, c8, r1
-    mad oPos.xy, r0.w, c0, r0
-    mov oPos.zw, r0
-    mov oT0.xy, v1
-    mov oT1, v2
-
-// approximately 12 instruction slots used
-vs_4_0
-dcl_constantbuffer CB0[8], immediateIndexed
-dcl_input v0.xyz
-dcl_input v1.xy
-dcl_input v2.xyzw
-dcl_output_siv o0.xyzw, position
-dcl_output o1.xy
-dcl_output o2.xyzw
-dcl_temps 2
-mul r0.xyzw, v0.yyyy, cb0[1].xyzw
-mad r0.xyzw, v0.xxxx, cb0[0].xyzw, r0.xyzw
-mad r0.xyzw, v0.zzzz, cb0[2].xyzw, r0.xyzw
-add r0.xyzw, r0.xyzw, cb0[3].xyzw
-mul r1.xyzw, r0.yyyy, cb0[5].xyzw
-mad r1.xyzw, r0.xxxx, cb0[4].xyzw, r1.xyzw
-mad r1.xyzw, r0.zzzz, cb0[6].xyzw, r1.xyzw
-mad o0.xyzw, r0.wwww, cb0[7].xyzw, r1.xyzw
-mov o1.xy, v1.xyxx
-mov o2.xyzw, v2.xyzw
-ret 
-// Approximately 11 instruction slots used
-#endif
-
-const BYTE g_main[] =
-{
-     68,  88,  66,  67, 152, 172, 
-     81,  45, 198, 200,  12,  38, 
-    143,   4, 178, 228, 158, 175, 
-    169,  64,   1,   0,   0,   0, 
-    140,   5,   0,   0,   6,   0, 
-      0,   0,  56,   0,   0,   0, 
-    108,   1,   0,   0,  52,   3, 
-      0,   0, 176,   3,   0,   0, 
-    168,   4,   0,   0,  24,   5, 
-      0,   0,  65, 111, 110,  57, 
-     44,   1,   0,   0,  44,   1, 
-      0,   0,   0,   2, 254, 255, 
-    248,   0,   0,   0,  52,   0, 
-      0,   0,   1,   0,  36,   0, 
-      0,   0,  48,   0,   0,   0, 
-     48,   0,   0,   0,  36,   0, 
-      1,   0,  48,   0,   0,   0, 
-      0,   0,   8,   0,   1,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   2, 254, 255, 
-     31,   0,   0,   2,   5,   0, 
-      0, 128,   0,   0,  15, 144, 
-     31,   0,   0,   2,   5,   0, 
-      1, 128,   1,   0,  15, 144, 
-     31,   0,   0,   2,   5,   0, 
-      2, 128,   2,   0,  15, 144, 
-      5,   0,   0,   3,   0,   0, 
-     15, 128,   0,   0,  85, 144, 
-      2,   0, 228, 160,   4,   0, 
-      0,   4,   0,   0,  15, 128, 
-      0,   0,   0, 144,   1,   0, 
-    228, 160,   0,   0, 228, 128, 
-      4,   0,   0,   4,   0,   0, 
-     15, 128,   0,   0, 170, 144, 
-      3,   0, 228, 160,   0,   0, 
-    228, 128,   2,   0,   0,   3, 
-      0,   0,  15, 128,   0,   0, 
-    228, 128,   4,   0, 228, 160, 
-      5,   0,   0,   3,   1,   0, 
-     15, 128,   0,   0,  85, 128, 
-      6,   0, 228, 160,   4,   0, 
-      0,   4,   1,   0,  15, 128, 
-      0,   0,   0, 128,   5,   0, 
-    228, 160,   1,   0, 228, 128, 
-      4,   0,   0,   4,   1,   0, 
-     15, 128,   0,   0, 170, 128, 
-      7,   0, 228, 160,   1,   0, 
-    228, 128,   4,   0,   0,   4, 
-      0,   0,  15, 128,   0,   0, 
-    255, 128,   8,   0, 228, 160, 
-      1,   0, 228, 128,   4,   0, 
-      0,   4,   0,   0,   3, 192, 
-      0,   0, 255, 128,   0,   0, 
-    228, 160,   0,   0, 228, 128, 
-      1,   0,   0,   2,   0,   0, 
-     12, 192,   0,   0, 228, 128, 
-      1,   0,   0,   2,   0,   0, 
-      3, 224,   1,   0, 228, 144, 
-      1,   0,   0,   2,   1,   0, 
-     15, 224,   2,   0, 228, 144, 
-    255, 255,   0,   0,  83,  72, 
-     68,  82, 192,   1,   0,   0, 
-     64,   0,   1,   0, 112,   0, 
-      0,   0,  89,   0,   0,   4, 
-     70, 142,  32,   0,   0,   0, 
-      0,   0,   8,   0,   0,   0, 
-     95,   0,   0,   3, 114,  16, 
-     16,   0,   0,   0,   0,   0, 
-     95,   0,   0,   3,  50,  16, 
-     16,   0,   1,   0,   0,   0, 
-     95,   0,   0,   3, 242,  16, 
-     16,   0,   2,   0,   0,   0, 
-    103,   0,   0,   4, 242,  32, 
-     16,   0,   0,   0,   0,   0, 
-      1,   0,   0,   0, 101,   0, 
-      0,   3,  50,  32,  16,   0, 
-      1,   0,   0,   0, 101,   0, 
-      0,   3, 242,  32,  16,   0, 
-      2,   0,   0,   0, 104,   0, 
-      0,   2,   2,   0,   0,   0, 
-     56,   0,   0,   8, 242,   0, 
-     16,   0,   0,   0,   0,   0, 
-     86,  21,  16,   0,   0,   0, 
-      0,   0,  70, 142,  32,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,  50,   0,   0,  10, 
-    242,   0,  16,   0,   0,   0, 
-      0,   0,   6,  16,  16,   0, 
-      0,   0,   0,   0,  70, 142, 
-     32,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,  70,  14, 
-     16,   0,   0,   0,   0,   0, 
-     50,   0,   0,  10, 242,   0, 
-     16,   0,   0,   0,   0,   0, 
-    166,  26,  16,   0,   0,   0, 
-      0,   0,  70, 142,  32,   0, 
-      0,   0,   0,   0,   2,   0, 
-      0,   0,  70,  14,  16,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   8, 242,   0,  16,   0, 
-      0,   0,   0,   0,  70,  14, 
-     16,   0,   0,   0,   0,   0, 
-     70, 142,  32,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-     56,   0,   0,   8, 242,   0, 
-     16,   0,   1,   0,   0,   0, 
-     86,   5,  16,   0,   0,   0, 
-      0,   0,  70, 142,  32,   0, 
-      0,   0,   0,   0,   5,   0, 
-      0,   0,  50,   0,   0,  10, 
-    242,   0,  16,   0,   1,   0, 
-      0,   0,   6,   0,  16,   0, 
-      0,   0,   0,   0,  70, 142, 
-     32,   0,   0,   0,   0,   0, 
-      4,   0,   0,   0,  70,  14, 
-     16,   0,   1,   0,   0,   0, 
-     50,   0,   0,  10, 242,   0, 
-     16,   0,   1,   0,   0,   0, 
-    166,  10,  16,   0,   0,   0, 
-      0,   0,  70, 142,  32,   0, 
-      0,   0,   0,   0,   6,   0, 
-      0,   0,  70,  14,  16,   0, 
-      1,   0,   0,   0,  50,   0, 
-      0,  10, 242,  32,  16,   0, 
-      0,   0,   0,   0, 246,  15, 
-     16,   0,   0,   0,   0,   0, 
-     70, 142,  32,   0,   0,   0, 
-      0,   0,   7,   0,   0,   0, 
-     70,  14,  16,   0,   1,   0, 
-      0,   0,  54,   0,   0,   5, 
-     50,  32,  16,   0,   1,   0, 
-      0,   0,  70,  16,  16,   0, 
-      1,   0,   0,   0,  54,   0, 
-      0,   5, 242,  32,  16,   0, 
-      2,   0,   0,   0,  70,  30, 
-     16,   0,   2,   0,   0,   0, 
-     62,   0,   0,   1,  83,  84, 
-     65,  84, 116,   0,   0,   0, 
-     11,   0,   0,   0,   2,   0, 
-      0,   0,   0,   0,   0,   0, 
-      6,   0,   0,   0,   8,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   1,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   2,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,  82,  68,  69,  70, 
-    240,   0,   0,   0,   1,   0, 
-      0,   0,  84,   0,   0,   0, 
-      1,   0,   0,   0,  28,   0, 
-      0,   0,   0,   4, 254, 255, 
-      0,   1,   0,   0, 198,   0, 
-      0,   0,  60,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-      1,   0,   0,   0,  86, 101, 
-    114, 116, 101, 120,  83, 104, 
-     97, 100, 101, 114,  67, 111, 
-    110, 115, 116,  97, 110, 116, 
-    115,   0, 171, 171,  60,   0, 
-      0,   0,   2,   0,   0,   0, 
-    108,   0,   0,   0, 128,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0, 156,   0, 
-      0,   0,   0,   0,   0,   0, 
-     64,   0,   0,   0,   2,   0, 
-      0,   0, 164,   0,   0,   0, 
-      0,   0,   0,   0, 180,   0, 
-      0,   0,  64,   0,   0,   0, 
-     64,   0,   0,   0,   2,   0, 
-      0,   0, 164,   0,   0,   0, 
-      0,   0,   0,   0, 109, 111, 
-    100, 101, 108,   0, 171, 171, 
-      2,   0,   3,   0,   4,   0, 
-      4,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0, 112, 114, 
-    111, 106, 101,  99, 116, 105, 
-    111, 110,  65, 110, 100,  86, 
-    105, 101, 119,   0,  77, 105, 
-     99, 114, 111, 115, 111, 102, 
-    116,  32,  40,  82,  41,  32, 
-     72,  76,  83,  76,  32,  83, 
-    104,  97, 100, 101, 114,  32, 
-     67, 111, 109, 112, 105, 108, 
-    101, 114,  32,  49,  48,  46, 
-     49,   0, 171, 171,  73,  83, 
-     71,  78, 104,   0,   0,   0, 
-      3,   0,   0,   0,   8,   0, 
-      0,   0,  80,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-      0,   0,   0,   0,   7,   7, 
-      0,   0,  89,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-      1,   0,   0,   0,   3,   3, 
-      0,   0,  98,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      0,   0,   3,   0,   0,   0, 
-      2,   0,   0,   0,  15,  15, 
-      0,   0,  80,  79,  83,  73, 
-     84,  73,  79,  78,   0,  84, 
-     69,  88,  67,  79,  79,  82, 
-     68,   0,  67,  79,  76,  79, 
-     82,   0,  79,  83,  71,  78, 
-    108,   0,   0,   0,   3,   0, 
-      0,   0,   8,   0,   0,   0, 
-     80,   0,   0,   0,   0,   0, 
-      0,   0,   1,   0,   0,   0, 
-      3,   0,   0,   0,   0,   0, 
-      0,   0,  15,   0,   0,   0, 
-     92,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,   1,   0, 
-      0,   0,   3,  12,   0,   0, 
-    101,   0,   0,   0,   0,   0, 
-      0,   0,   0,   0,   0,   0, 
-      3,   0,   0,   0,   2,   0, 
-      0,   0,  15,   0,   0,   0, 
-     83,  86,  95,  80,  79,  83, 
-     73,  84,  73,  79,  78,   0, 
-     84,  69,  88,  67,  79,  79, 
-     82,  68,   0,  67,  79,  76, 
-     79,  82,   0, 171
-};
+#if 0
+//
+// Generated by Microsoft (R) HLSL Shader Compiler 10.1
+//
+//
+// Buffer Definitions: 
+//
+// cbuffer VertexShaderConstants
+// {
+//
+//   row_major float4x4 model;          // Offset:    0 Size:    64
+//   row_major float4x4 projectionAndView;// Offset:   64 Size:    64
+//
+// }
+//
+//
+// Resource Bindings:
+//
+// Name                                 Type  Format         Dim      HLSL Bind  Count
+// ------------------------------ ---------- ------- ----------- -------------- ------
+// VertexShaderConstants             cbuffer      NA          NA            cb0      1 
+//
+//
+//
+// Input signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// POSITION                 0   xyz         0     NONE   float   xyz 
+// TEXCOORD                 0   xy          1     NONE   float   xy  
+// COLOR                    0   xyzw        2     NONE   float   xyzw
+//
+//
+// Output signature:
+//
+// Name                 Index   Mask Register SysValue  Format   Used
+// -------------------- ----- ------ -------- -------- ------- ------
+// SV_POSITION              0   xyzw        0      POS   float   xyzw
+// TEXCOORD                 0   xy          1     NONE   float   xy  
+// COLOR                    0   xyzw        2     NONE   float   xyzw
+//
+//
+// Constant buffer to DX9 shader constant mappings:
+//
+// Target Reg Buffer  Start Reg # of Regs        Data Conversion
+// ---------- ------- --------- --------- ----------------------
+// c1         cb0             0         8  ( FLT, FLT, FLT, FLT)
+//
+//
+// Runtime generated constant mappings:
+//
+// Target Reg                               Constant Description
+// ---------- --------------------------------------------------
+// c0                              Vertex Shader position offset
+//
+//
+// Level9 shader bytecode:
+//
+    vs_2_0
+    dcl_texcoord v0
+    dcl_texcoord1 v1
+    dcl_texcoord2 v2
+    mul r0, v0.y, c2
+    mad r0, v0.x, c1, r0
+    mad r0, v0.z, c3, r0
+    add r0, r0, c4
+    mul r1, r0.y, c6
+    mad r1, r0.x, c5, r1
+    mad r1, r0.z, c7, r1
+    mad r0, r0.w, c8, r1
+    mad oPos.xy, r0.w, c0, r0
+    mov oPos.zw, r0
+    mov oT0.xy, v1
+    mov oT1, v2
+
+// approximately 12 instruction slots used
+vs_4_0
+dcl_constantbuffer CB0[8], immediateIndexed
+dcl_input v0.xyz
+dcl_input v1.xy
+dcl_input v2.xyzw
+dcl_output_siv o0.xyzw, position
+dcl_output o1.xy
+dcl_output o2.xyzw
+dcl_temps 2
+mul r0.xyzw, v0.yyyy, cb0[1].xyzw
+mad r0.xyzw, v0.xxxx, cb0[0].xyzw, r0.xyzw
+mad r0.xyzw, v0.zzzz, cb0[2].xyzw, r0.xyzw
+add r0.xyzw, r0.xyzw, cb0[3].xyzw
+mul r1.xyzw, r0.yyyy, cb0[5].xyzw
+mad r1.xyzw, r0.xxxx, cb0[4].xyzw, r1.xyzw
+mad r1.xyzw, r0.zzzz, cb0[6].xyzw, r1.xyzw
+mad o0.xyzw, r0.wwww, cb0[7].xyzw, r1.xyzw
+mov o1.xy, v1.xyxx
+mov o2.xyzw, v2.xyzw
+ret 
+// Approximately 11 instruction slots used
+#endif
+
+const BYTE g_main[] =
+{
+     68,  88,  66,  67, 152, 172, 
+     81,  45, 198, 200,  12,  38, 
+    143,   4, 178, 228, 158, 175, 
+    169,  64,   1,   0,   0,   0, 
+    140,   5,   0,   0,   6,   0, 
+      0,   0,  56,   0,   0,   0, 
+    108,   1,   0,   0,  52,   3, 
+      0,   0, 176,   3,   0,   0, 
+    168,   4,   0,   0,  24,   5, 
+      0,   0,  65, 111, 110,  57, 
+     44,   1,   0,   0,  44,   1, 
+      0,   0,   0,   2, 254, 255, 
+    248,   0,   0,   0,  52,   0, 
+      0,   0,   1,   0,  36,   0, 
+      0,   0,  48,   0,   0,   0, 
+     48,   0,   0,   0,  36,   0, 
+      1,   0,  48,   0,   0,   0, 
+      0,   0,   8,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   2, 254, 255, 
+     31,   0,   0,   2,   5,   0, 
+      0, 128,   0,   0,  15, 144, 
+     31,   0,   0,   2,   5,   0, 
+      1, 128,   1,   0,  15, 144, 
+     31,   0,   0,   2,   5,   0, 
+      2, 128,   2,   0,  15, 144, 
+      5,   0,   0,   3,   0,   0, 
+     15, 128,   0,   0,  85, 144, 
+      2,   0, 228, 160,   4,   0, 
+      0,   4,   0,   0,  15, 128, 
+      0,   0,   0, 144,   1,   0, 
+    228, 160,   0,   0, 228, 128, 
+      4,   0,   0,   4,   0,   0, 
+     15, 128,   0,   0, 170, 144, 
+      3,   0, 228, 160,   0,   0, 
+    228, 128,   2,   0,   0,   3, 
+      0,   0,  15, 128,   0,   0, 
+    228, 128,   4,   0, 228, 160, 
+      5,   0,   0,   3,   1,   0, 
+     15, 128,   0,   0,  85, 128, 
+      6,   0, 228, 160,   4,   0, 
+      0,   4,   1,   0,  15, 128, 
+      0,   0,   0, 128,   5,   0, 
+    228, 160,   1,   0, 228, 128, 
+      4,   0,   0,   4,   1,   0, 
+     15, 128,   0,   0, 170, 128, 
+      7,   0, 228, 160,   1,   0, 
+    228, 128,   4,   0,   0,   4, 
+      0,   0,  15, 128,   0,   0, 
+    255, 128,   8,   0, 228, 160, 
+      1,   0, 228, 128,   4,   0, 
+      0,   4,   0,   0,   3, 192, 
+      0,   0, 255, 128,   0,   0, 
+    228, 160,   0,   0, 228, 128, 
+      1,   0,   0,   2,   0,   0, 
+     12, 192,   0,   0, 228, 128, 
+      1,   0,   0,   2,   0,   0, 
+      3, 224,   1,   0, 228, 144, 
+      1,   0,   0,   2,   1,   0, 
+     15, 224,   2,   0, 228, 144, 
+    255, 255,   0,   0,  83,  72, 
+     68,  82, 192,   1,   0,   0, 
+     64,   0,   1,   0, 112,   0, 
+      0,   0,  89,   0,   0,   4, 
+     70, 142,  32,   0,   0,   0, 
+      0,   0,   8,   0,   0,   0, 
+     95,   0,   0,   3, 114,  16, 
+     16,   0,   0,   0,   0,   0, 
+     95,   0,   0,   3,  50,  16, 
+     16,   0,   1,   0,   0,   0, 
+     95,   0,   0,   3, 242,  16, 
+     16,   0,   2,   0,   0,   0, 
+    103,   0,   0,   4, 242,  32, 
+     16,   0,   0,   0,   0,   0, 
+      1,   0,   0,   0, 101,   0, 
+      0,   3,  50,  32,  16,   0, 
+      1,   0,   0,   0, 101,   0, 
+      0,   3, 242,  32,  16,   0, 
+      2,   0,   0,   0, 104,   0, 
+      0,   2,   2,   0,   0,   0, 
+     56,   0,   0,   8, 242,   0, 
+     16,   0,   0,   0,   0,   0, 
+     86,  21,  16,   0,   0,   0, 
+      0,   0,  70, 142,  32,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,  50,   0,   0,  10, 
+    242,   0,  16,   0,   0,   0, 
+      0,   0,   6,  16,  16,   0, 
+      0,   0,   0,   0,  70, 142, 
+     32,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,  70,  14, 
+     16,   0,   0,   0,   0,   0, 
+     50,   0,   0,  10, 242,   0, 
+     16,   0,   0,   0,   0,   0, 
+    166,  26,  16,   0,   0,   0, 
+      0,   0,  70, 142,  32,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,  70,  14,  16,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   8, 242,   0,  16,   0, 
+      0,   0,   0,   0,  70,  14, 
+     16,   0,   0,   0,   0,   0, 
+     70, 142,  32,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+     56,   0,   0,   8, 242,   0, 
+     16,   0,   1,   0,   0,   0, 
+     86,   5,  16,   0,   0,   0, 
+      0,   0,  70, 142,  32,   0, 
+      0,   0,   0,   0,   5,   0, 
+      0,   0,  50,   0,   0,  10, 
+    242,   0,  16,   0,   1,   0, 
+      0,   0,   6,   0,  16,   0, 
+      0,   0,   0,   0,  70, 142, 
+     32,   0,   0,   0,   0,   0, 
+      4,   0,   0,   0,  70,  14, 
+     16,   0,   1,   0,   0,   0, 
+     50,   0,   0,  10, 242,   0, 
+     16,   0,   1,   0,   0,   0, 
+    166,  10,  16,   0,   0,   0, 
+      0,   0,  70, 142,  32,   0, 
+      0,   0,   0,   0,   6,   0, 
+      0,   0,  70,  14,  16,   0, 
+      1,   0,   0,   0,  50,   0, 
+      0,  10, 242,  32,  16,   0, 
+      0,   0,   0,   0, 246,  15, 
+     16,   0,   0,   0,   0,   0, 
+     70, 142,  32,   0,   0,   0, 
+      0,   0,   7,   0,   0,   0, 
+     70,  14,  16,   0,   1,   0, 
+      0,   0,  54,   0,   0,   5, 
+     50,  32,  16,   0,   1,   0, 
+      0,   0,  70,  16,  16,   0, 
+      1,   0,   0,   0,  54,   0, 
+      0,   5, 242,  32,  16,   0, 
+      2,   0,   0,   0,  70,  30, 
+     16,   0,   2,   0,   0,   0, 
+     62,   0,   0,   1,  83,  84, 
+     65,  84, 116,   0,   0,   0, 
+     11,   0,   0,   0,   2,   0, 
+      0,   0,   0,   0,   0,   0, 
+      6,   0,   0,   0,   8,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   1,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   2,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,  82,  68,  69,  70, 
+    240,   0,   0,   0,   1,   0, 
+      0,   0,  84,   0,   0,   0, 
+      1,   0,   0,   0,  28,   0, 
+      0,   0,   0,   4, 254, 255, 
+      0,   1,   0,   0, 198,   0, 
+      0,   0,  60,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      1,   0,   0,   0,  86, 101, 
+    114, 116, 101, 120,  83, 104, 
+     97, 100, 101, 114,  67, 111, 
+    110, 115, 116,  97, 110, 116, 
+    115,   0, 171, 171,  60,   0, 
+      0,   0,   2,   0,   0,   0, 
+    108,   0,   0,   0, 128,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0, 156,   0, 
+      0,   0,   0,   0,   0,   0, 
+     64,   0,   0,   0,   2,   0, 
+      0,   0, 164,   0,   0,   0, 
+      0,   0,   0,   0, 180,   0, 
+      0,   0,  64,   0,   0,   0, 
+     64,   0,   0,   0,   2,   0, 
+      0,   0, 164,   0,   0,   0, 
+      0,   0,   0,   0, 109, 111, 
+    100, 101, 108,   0, 171, 171, 
+      2,   0,   3,   0,   4,   0, 
+      4,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0, 112, 114, 
+    111, 106, 101,  99, 116, 105, 
+    111, 110,  65, 110, 100,  86, 
+    105, 101, 119,   0,  77, 105, 
+     99, 114, 111, 115, 111, 102, 
+    116,  32,  40,  82,  41,  32, 
+     72,  76,  83,  76,  32,  83, 
+    104,  97, 100, 101, 114,  32, 
+     67, 111, 109, 112, 105, 108, 
+    101, 114,  32,  49,  48,  46, 
+     49,   0, 171, 171,  73,  83, 
+     71,  78, 104,   0,   0,   0, 
+      3,   0,   0,   0,   8,   0, 
+      0,   0,  80,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      0,   0,   0,   0,   7,   7, 
+      0,   0,  89,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      1,   0,   0,   0,   3,   3, 
+      0,   0,  98,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      0,   0,   3,   0,   0,   0, 
+      2,   0,   0,   0,  15,  15, 
+      0,   0,  80,  79,  83,  73, 
+     84,  73,  79,  78,   0,  84, 
+     69,  88,  67,  79,  79,  82, 
+     68,   0,  67,  79,  76,  79, 
+     82,   0,  79,  83,  71,  78, 
+    108,   0,   0,   0,   3,   0, 
+      0,   0,   8,   0,   0,   0, 
+     80,   0,   0,   0,   0,   0, 
+      0,   0,   1,   0,   0,   0, 
+      3,   0,   0,   0,   0,   0, 
+      0,   0,  15,   0,   0,   0, 
+     92,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   1,   0, 
+      0,   0,   3,  12,   0,   0, 
+    101,   0,   0,   0,   0,   0, 
+      0,   0,   0,   0,   0,   0, 
+      3,   0,   0,   0,   2,   0, 
+      0,   0,  15,   0,   0,   0, 
+     83,  86,  95,  80,  79,  83, 
+     73,  84,  73,  79,  78,   0, 
+     84,  69,  88,  67,  79,  79, 
+     82,  68,   0,  67,  79,  76, 
+     79,  82,   0, 171
+};

+ 58 - 34
src/render/direct3d11/SDL_render_d3d11.c

@@ -76,11 +76,11 @@ typedef struct
 
 typedef struct
 {
-    float YCbCr_matrix[16];
     float scRGB_output;
     float SDR_whitelevel;
     float HDR_whitelevel;
     float maxCLL;
+    float YCbCr_matrix[16];
 } PixelShaderConstants;
 
 /* Per-vertex data */
@@ -155,6 +155,11 @@ typedef struct
     D3D_FEATURE_LEVEL featureLevel;
     SDL_bool pixelSizeChanged;
 
+    /* HDR state */
+    SDL_bool HDR_enabled;
+    int SDR_whitelevel;
+    int HDR_whitelevel;
+
     /* Rasterizers */
     ID3D11RasterizerState *mainRasterizer;
     ID3D11RasterizerState *clippedRasterizer;
@@ -465,6 +470,21 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen
     return blendState;
 }
 
+static void D3D11_UpdateHDRState(SDL_Renderer *renderer)
+{
+    D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
+
+    /* Using some placeholder values here... */
+    data->HDR_enabled = SDL_TRUE;
+    if (renderer->output_colorspace == SDL_COLORSPACE_SCRGB && data->HDR_enabled) {
+        data->SDR_whitelevel = 200.0f;
+        data->HDR_whitelevel = 400.0f;
+    } else {
+        data->SDR_whitelevel = 80.0f;
+        data->HDR_whitelevel = 80.0f;
+    }
+}
+
 /* Create resources that depend on the device. */
 static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
 {
@@ -716,6 +736,8 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
 
     SDL_SetProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_D3D11_DEVICE_POINTER, data->d3dDevice);
 
+    D3D11_UpdateHDRState(renderer);
+
 done:
     SAFE_RELEASE(d3dDevice);
     SAFE_RELEASE(d3dContext);
@@ -2177,46 +2199,42 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
         rendererData->currentBlendState = blendState;
     }
 
-    if (shader_params != rendererData->currentShaderParams[shader]) {
-        if (shader_params) {
-            SAFE_RELEASE(rendererData->pixelShaderConstants[shader]);
+    if (!rendererData->pixelShaderConstants[shader] ||
+        shader_params != rendererData->currentShaderParams[shader]) {
+        SAFE_RELEASE(rendererData->pixelShaderConstants[shader]);
 
-            PixelShaderConstants constants;
-            SDL_memcpy(constants.YCbCr_matrix, shader_params, sizeof(constants.YCbCr_matrix));
-            if (renderer->output_colorspace == SDL_COLORSPACE_SCRGB) {
-                constants.scRGB_output = 1.0f;
-            } else {
-                constants.scRGB_output = 0.0f;
-            }
+        PixelShaderConstants constants;
+        if (renderer->output_colorspace == SDL_COLORSPACE_SCRGB) {
+            constants.scRGB_output = 1.0f;
+        } else {
+            constants.scRGB_output = 0.0f;
+        }
 
-            /* Using some placeholder values here... */
-            const SDL_bool HDR = SDL_TRUE;
-            if (renderer->output_colorspace == SDL_COLORSPACE_SCRGB && HDR) {
-                constants.SDR_whitelevel = 200.0f;
-                constants.HDR_whitelevel = 400.0f;
-            } else {
-                constants.SDR_whitelevel = 80.0f;
-                constants.HDR_whitelevel = 80.0f;
-            }
-            constants.maxCLL = 400.0f;
+        constants.SDR_whitelevel = (float)rendererData->SDR_whitelevel;
+        constants.HDR_whitelevel = (float)rendererData->HDR_whitelevel;
+        constants.maxCLL = 400.0f;
 
-            D3D11_BUFFER_DESC desc;
-            SDL_zero(desc);
-            desc.Usage = D3D11_USAGE_DEFAULT;
-            desc.ByteWidth = sizeof(constants);
-            desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
+        if (shader_params) {
+            SDL_memcpy(constants.YCbCr_matrix, shader_params, sizeof(constants.YCbCr_matrix));
+        }
 
-            D3D11_SUBRESOURCE_DATA data;
-            SDL_zero(data);
-            data.pSysMem = &constants;
+        D3D11_BUFFER_DESC desc;
+        SDL_zero(desc);
+        desc.Usage = D3D11_USAGE_DEFAULT;
+        desc.ByteWidth = sizeof(constants);
+        desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
 
-            HRESULT result = ID3D11Device_CreateBuffer(rendererData->d3dDevice, &desc, &data, &rendererData->pixelShaderConstants[shader]);
-            if (FAILED(result)) {
-                WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device::CreateBuffer [create shader constants]"), result);
-                return -1;
-            }
+        D3D11_SUBRESOURCE_DATA data;
+        SDL_zero(data);
+        data.pSysMem = &constants;
+
+        HRESULT result = ID3D11Device_CreateBuffer(rendererData->d3dDevice, &desc, &data, &rendererData->pixelShaderConstants[shader]);
+        if (FAILED(result)) {
+            WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device::CreateBuffer [create shader constants]"), result);
+            return -1;
         }
         rendererData->currentShaderParams[shader] = shader_params;
+        rendererData->currentShader = SHADER_NONE;
     }
     if (shader != rendererData->currentShader) {
         if (!rendererData->pixelShaders[shader]) {
@@ -2371,7 +2389,13 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
             SDL_bool convert_color = SDL_RenderingLinearSpace(renderer);
             SDL_FColor color = cmd->data.color.color;
             if (convert_color) {
+                float light_scale = (float)rendererData->SDR_whitelevel / 80.0f;
+
                 SDL_ConvertToLinear(&color);
+
+                color.r *= light_scale;
+                color.g *= light_scale;
+                color.b *= light_scale;
             }
             ID3D11DeviceContext_ClearRenderTargetView(rendererData->d3dContext, D3D11_GetCurrentRenderTargetView(renderer), &color.r);
             break;