From 30f41c02aec763d32e62351452da9ef582bc3472 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Fri, 6 Mar 2026 13:30:59 -0800 Subject: Move contrib libraries to contrib repo --- .../render/direct3d11/D3D11_PixelShader_Advanced.h | 1060 -------- .../direct3d11/D3D11_PixelShader_Advanced.hlsl | 7 - .../render/direct3d11/D3D11_PixelShader_Colors.h | 284 -- .../direct3d11/D3D11_PixelShader_Colors.hlsl | 7 - .../direct3d11/D3D11_PixelShader_Common.hlsli | 235 -- .../render/direct3d11/D3D11_PixelShader_Textures.h | 332 --- .../direct3d11/D3D11_PixelShader_Textures.hlsl | 9 - .../src/render/direct3d11/D3D11_VertexShader.h | 339 --- .../src/render/direct3d11/D3D11_VertexShader.hlsl | 38 - .../src/render/direct3d11/SDL_render_d3d11.c | 2767 -------------------- .../src/render/direct3d11/SDL_shaders_d3d11.c | 116 - .../src/render/direct3d11/SDL_shaders_d3d11.h | 35 - .../src/render/direct3d11/compile_shaders.bat | 4 - 13 files changed, 5233 deletions(-) delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Advanced.h delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Advanced.hlsl delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Colors.h delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Colors.hlsl delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Common.hlsli delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Textures.h delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Textures.hlsl delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/D3D11_VertexShader.h delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/D3D11_VertexShader.hlsl delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/SDL_render_d3d11.c delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/SDL_shaders_d3d11.c delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/SDL_shaders_d3d11.h delete mode 100644 contrib/SDL-3.2.8/src/render/direct3d11/compile_shaders.bat (limited to 'contrib/SDL-3.2.8/src/render/direct3d11') diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Advanced.h b/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Advanced.h deleted file mode 100644 index a1297c9..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Advanced.h +++ /dev/null @@ -1,1060 +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 texture_type; // Offset: 4 Size: 4 -// float input_type; // Offset: 8 Size: 4 -// float color_scale; // Offset: 12 Size: 4 -// float tonemap_method; // Offset: 16 Size: 4 -// float tonemap_factor1; // Offset: 20 Size: 4 -// float tonemap_factor2; // Offset: 24 Size: 4 -// float sdr_white_point; // Offset: 28 Size: 4 -// float4 Yoffset; // Offset: 32 Size: 16 -// float4 Rcoeff; // Offset: 48 Size: 16 -// float4 Gcoeff; // Offset: 64 Size: 16 -// float4 Bcoeff; // Offset: 80 Size: 16 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim HLSL Bind Count -// ------------------------------ ---------- ------- ----------- -------------- ------ -// sampler0 sampler NA NA s0 1 -// texture0 texture float4 2d t0 1 -// texture1 texture float4 2d t1 1 -// texture2 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 -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer CB0[6], 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 7 -eq r0.xyzw, cb0[0].yzzz, l(0.000000, 3.000000, 2.000000, 1.000000) -if_nz r0.x - mov r1.xyzw, l(1.000000,1.000000,1.000000,1.000000) -else - eq r0.x, cb0[0].y, l(1.000000) - if_nz r0.x - sample_indexable(texture2d)(float,float,float,float) r1.xyzw, v1.xyxx, t0.xyzw, s0 - else - eq r0.x, cb0[0].y, l(2.000000) - if_nz r0.x - sample_indexable(texture2d)(float,float,float,float) r2.x, v1.xyxx, t0.xyzw, s0 - sample_indexable(texture2d)(float,float,float,float) r2.yz, v1.xyxx, t1.zxyw, s0 - add r2.xyz, r2.xyzx, cb0[2].xyzx - dp3 r1.x, r2.xyzx, cb0[3].xyzx - dp3 r1.y, r2.xyzx, cb0[4].xyzx - dp3 r1.z, r2.xyzx, cb0[5].xyzx - else - eq r0.x, cb0[0].y, l(3.000000) - if_nz r0.x - sample_indexable(texture2d)(float,float,float,float) r2.x, v1.xyxx, t0.xyzw, s0 - sample_indexable(texture2d)(float,float,float,float) r2.yz, v1.xyxx, t1.zyxw, s0 - add r2.xyz, r2.xyzx, cb0[2].xyzx - dp3 r1.x, r2.xyzx, cb0[3].xyzx - dp3 r1.y, r2.xyzx, cb0[4].xyzx - dp3 r1.z, r2.xyzx, cb0[5].xyzx - else - eq r0.x, cb0[0].y, l(4.000000) - if_nz r0.x - sample_indexable(texture2d)(float,float,float,float) r2.x, v1.xyxx, t0.xyzw, s0 - sample_indexable(texture2d)(float,float,float,float) r2.y, v1.xyxx, t1.yxzw, s0 - sample_indexable(texture2d)(float,float,float,float) r2.z, v1.xyxx, t2.yzxw, s0 - add r2.xyz, r2.xyzx, cb0[2].xyzx - dp3 r1.x, r2.xyzx, cb0[3].xyzx - dp3 r1.y, r2.xyzx, cb0[4].xyzx - dp3 r1.z, r2.xyzx, cb0[5].xyzx - else - mov r1.xyz, l(1.000000,0,0,0) - endif - endif - endif - mov r1.w, l(1.000000) - endif -endif -log r2.xyz, |r1.xyzx| -mul r2.xyz, r2.xyzx, l(0.012683, 0.012683, 0.012683, 0.000000) -exp r2.xyz, r2.xyzx -add r3.xyz, r2.xyzx, l(-0.835938, -0.835938, -0.835938, 0.000000) -max r3.xyz, r3.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) -mad r2.xyz, -r2.xyzx, l(18.687500, 18.687500, 18.687500, 0.000000), l(18.851562, 18.851562, 18.851562, 0.000000) -div r2.xyz, r3.xyzx, r2.xyzx -log r2.xyz, |r2.xyzx| -mul r2.xyz, r2.xyzx, l(6.277395, 6.277395, 6.277395, 0.000000) -exp r2.xyz, r2.xyzx -mul r2.xyz, r2.xyzx, l(10000.000000, 10000.000000, 10000.000000, 0.000000) -div r2.xyz, r2.xyzx, cb0[1].wwww -movc r2.xyz, r0.yyyy, r2.xyzx, r1.xyzx -ne r0.x, cb0[1].x, l(0.000000) -mul r3.xyz, r2.xyzx, cb0[1].yyyy -eq r4.xy, cb0[1].xxxx, l(1.000000, 2.000000, 0.000000, 0.000000) -dp3 r5.x, l(0.627404, 0.329283, 0.043313, 0.000000), r2.xyzx -dp3 r5.y, l(0.069097, 0.919541, 0.011362, 0.000000), r2.xyzx -dp3 r5.z, l(0.016391, 0.088013, 0.895595, 0.000000), r2.xyzx -movc r5.xyz, r0.zzzz, r5.xyzx, r2.xyzx -max r2.w, r5.z, r5.y -max r2.w, r2.w, r5.x -lt r3.w, l(0.000000), r2.w -mad r4.zw, cb0[1].yyyz, r2.wwww, l(0.000000, 0.000000, 1.000000, 1.000000) -div r2.w, r4.z, r4.w -mul r6.xyz, r2.wwww, r5.xyzx -movc r5.xyz, r3.wwww, r6.xyzx, r5.xyzx -dp3 r6.x, l(1.660496, -0.587656, -0.072840, 0.000000), r5.xyzx -dp3 r6.y, l(-0.124547, 1.132895, -0.008348, 0.000000), r5.xyzx -dp3 r6.z, l(-0.018154, -0.100597, 1.118751, 0.000000), r5.xyzx -movc r5.xyz, r0.zzzz, r6.xyzx, r5.xyzx -movc r4.yzw, r4.yyyy, r5.xxyz, r2.xxyz -movc r3.xyz, r4.xxxx, r3.xyzx, r4.yzwy -movc r2.xyz, r0.xxxx, r3.xyzx, r2.xyzx -if_nz r0.w - ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x - if_nz r0.x - ge r3.xyz, l(0.040450, 0.040450, 0.040450, 0.000000), r2.xyzx - mul r4.xyz, r2.xyzx, l(0.077399, 0.077399, 0.077399, 0.000000) - add r5.xyz, r2.xyzx, l(0.055000, 0.055000, 0.055000, 0.000000) - mul r5.xyz, |r5.xyzx|, l(0.947867, 0.947867, 0.947867, 0.000000) - log r5.xyz, r5.xyzx - mul r5.xyz, r5.xyzx, l(2.400000, 2.400000, 2.400000, 0.000000) - exp r5.xyz, r5.xyzx - movc r2.xyz, r3.xyzx, r4.xyzx, r5.xyzx - endif - mul r1.xyz, r2.xyzx, cb0[0].wwww -else - if_nz r0.z - mul r1.xyz, r2.xyzx, cb0[0].wwww - ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x - if_z r0.x - ge r0.xzw, l(0.003131, 0.000000, 0.003131, 0.003131), r1.xxyz - mul r3.xyz, r1.xyzx, l(12.920000, 12.920000, 12.920000, 0.000000) - log r4.xyz, |r1.xyzx| - mul r4.xyz, r4.xyzx, l(0.416667, 0.416667, 0.416667, 0.000000) - exp r4.xyz, r4.xyzx - mad r4.xyz, r4.xyzx, l(1.055000, 1.055000, 1.055000, 0.000000), l(-0.055000, -0.055000, -0.055000, 0.000000) - movc_sat r1.xyz, r0.xzwx, r3.xyzx, r4.xyzx - endif - else - if_nz r0.y - dp3 r0.x, l(1.660496, -0.587656, -0.072840, 0.000000), r2.xyzx - dp3 r0.y, l(-0.124547, 1.132895, -0.008348, 0.000000), r2.xyzx - dp3 r0.z, l(-0.018154, -0.100597, 1.118751, 0.000000), r2.xyzx - mul r1.xyz, r0.xyzx, cb0[0].wwww - ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x - if_z r0.x - ge r0.xyz, l(0.003131, 0.003131, 0.003131, 0.000000), r1.xyzx - mul r3.xyz, r1.xyzx, l(12.920000, 12.920000, 12.920000, 0.000000) - log r4.xyz, |r1.xyzx| - mul r4.xyz, r4.xyzx, l(0.416667, 0.416667, 0.416667, 0.000000) - exp r4.xyz, r4.xyzx - mad r4.xyz, r4.xyzx, l(1.055000, 1.055000, 1.055000, 0.000000), l(-0.055000, -0.055000, -0.055000, 0.000000) - movc_sat r1.xyz, r0.xyzx, r3.xyzx, r4.xyzx - endif - else - mul r1.xyz, r2.xyzx, cb0[0].wwww - endif - endif -endif -mul o0.xyzw, r1.xyzw, v2.xyzw -ret -// Approximately 126 instruction slots used -#endif - -const BYTE g_main[] = -{ - 68, 88, 66, 67, 154, 200, - 28, 25, 30, 140, 0, 183, - 251, 32, 6, 185, 210, 29, - 251, 110, 1, 0, 0, 0, - 64, 20, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 80, 4, 0, 0, 196, 4, - 0, 0, 248, 4, 0, 0, - 164, 19, 0, 0, 82, 68, - 69, 70, 20, 4, 0, 0, - 1, 0, 0, 0, 12, 1, - 0, 0, 5, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 233, 3, 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, - 220, 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, 229, 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, 238, 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, - 247, 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, 0, 1, 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, 115, 97, - 109, 112, 108, 101, 114, 48, - 0, 116, 101, 120, 116, 117, - 114, 101, 48, 0, 116, 101, - 120, 116, 117, 114, 101, 49, - 0, 116, 101, 120, 116, 117, - 114, 101, 50, 0, 67, 111, - 110, 115, 116, 97, 110, 116, - 115, 0, 171, 171, 0, 1, - 0, 0, 12, 0, 0, 0, - 36, 1, 0, 0, 96, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 4, 3, - 0, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 2, 0, - 0, 0, 24, 3, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 60, 3, 0, 0, - 4, 0, 0, 0, 4, 0, - 0, 0, 2, 0, 0, 0, - 24, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 73, 3, 0, 0, 8, 0, - 0, 0, 4, 0, 0, 0, - 2, 0, 0, 0, 24, 3, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 84, 3, - 0, 0, 12, 0, 0, 0, - 4, 0, 0, 0, 2, 0, - 0, 0, 24, 3, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 96, 3, 0, 0, - 16, 0, 0, 0, 4, 0, - 0, 0, 2, 0, 0, 0, - 24, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 111, 3, 0, 0, 20, 0, - 0, 0, 4, 0, 0, 0, - 2, 0, 0, 0, 24, 3, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 127, 3, - 0, 0, 24, 0, 0, 0, - 4, 0, 0, 0, 2, 0, - 0, 0, 24, 3, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 143, 3, 0, 0, - 28, 0, 0, 0, 4, 0, - 0, 0, 2, 0, 0, 0, - 24, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 159, 3, 0, 0, 32, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 176, 3, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 212, 3, - 0, 0, 48, 0, 0, 0, - 16, 0, 0, 0, 2, 0, - 0, 0, 176, 3, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 219, 3, 0, 0, - 64, 0, 0, 0, 16, 0, - 0, 0, 2, 0, 0, 0, - 176, 3, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 226, 3, 0, 0, 80, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 176, 3, - 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, 17, 3, 0, 0, - 116, 101, 120, 116, 117, 114, - 101, 95, 116, 121, 112, 101, - 0, 105, 110, 112, 117, 116, - 95, 116, 121, 112, 101, 0, - 99, 111, 108, 111, 114, 95, - 115, 99, 97, 108, 101, 0, - 116, 111, 110, 101, 109, 97, - 112, 95, 109, 101, 116, 104, - 111, 100, 0, 116, 111, 110, - 101, 109, 97, 112, 95, 102, - 97, 99, 116, 111, 114, 49, - 0, 116, 111, 110, 101, 109, - 97, 112, 95, 102, 97, 99, - 116, 111, 114, 50, 0, 115, - 100, 114, 95, 119, 104, 105, - 116, 101, 95, 112, 111, 105, - 110, 116, 0, 89, 111, 102, - 102, 115, 101, 116, 0, 102, - 108, 111, 97, 116, 52, 0, - 171, 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, 167, 3, - 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, 164, 14, - 0, 0, 80, 0, 0, 0, - 169, 3, 0, 0, 106, 8, - 0, 1, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 6, 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, 7, 0, - 0, 0, 24, 0, 0, 11, - 242, 0, 16, 0, 0, 0, - 0, 0, 150, 138, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 64, 64, 0, 0, 0, 64, - 0, 0, 128, 63, 31, 0, - 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 8, 242, 0, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 63, - 0, 0, 128, 63, 0, 0, - 128, 63, 0, 0, 128, 63, - 18, 0, 0, 1, 24, 0, - 0, 8, 18, 0, 16, 0, - 0, 0, 0, 0, 26, 128, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 31, 0, 4, 3, 10, 0, - 16, 0, 0, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 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, 18, 0, 0, 1, - 24, 0, 0, 8, 18, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 64, 31, 0, 4, 3, - 10, 0, 16, 0, 0, 0, - 0, 0, 69, 0, 0, 139, - 194, 0, 0, 128, 67, 85, - 21, 0, 18, 0, 16, 0, - 2, 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, 2, 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, 2, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 16, 0, 0, 8, - 18, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 16, 0, - 0, 8, 34, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 16, 0, 0, 8, 66, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 18, 0, 0, 1, - 24, 0, 0, 8, 18, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 64, 64, 31, 0, 4, 3, - 10, 0, 16, 0, 0, 0, - 0, 0, 69, 0, 0, 139, - 194, 0, 0, 128, 67, 85, - 21, 0, 18, 0, 16, 0, - 2, 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, 2, 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, - 0, 0, 0, 8, 114, 0, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 16, 0, 0, 8, - 18, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 16, 0, - 0, 8, 34, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 16, 0, 0, 8, 66, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 18, 0, 0, 1, - 24, 0, 0, 8, 18, 0, - 16, 0, 0, 0, 0, 0, - 26, 128, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 64, 31, 0, 4, 3, - 10, 0, 16, 0, 0, 0, - 0, 0, 69, 0, 0, 139, - 194, 0, 0, 128, 67, 85, - 21, 0, 18, 0, 16, 0, - 2, 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, 34, 0, - 16, 0, 2, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 22, 126, 16, 0, - 1, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 66, 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, 0, 0, 0, 8, - 114, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 16, 0, - 0, 8, 18, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 16, 0, 0, 8, 34, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 4, 0, - 0, 0, 16, 0, 0, 8, - 66, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 5, 0, 0, 0, 18, 0, - 0, 1, 54, 0, 0, 8, - 114, 0, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 128, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 21, 0, - 0, 1, 21, 0, 0, 1, - 21, 0, 0, 1, 54, 0, - 0, 5, 130, 0, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 21, 0, 0, 1, 21, 0, - 0, 1, 47, 0, 0, 6, - 114, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 128, - 129, 0, 0, 0, 1, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 2, 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, 2, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 0, 0, 0, 10, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 2, 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, 3, 0, 0, 0, - 70, 2, 16, 0, 3, 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, - 2, 0, 0, 0, 70, 2, - 16, 128, 65, 0, 0, 0, - 2, 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, 2, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 47, 0, 0, 6, 114, 0, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 128, 129, 0, - 0, 0, 2, 0, 0, 0, - 56, 0, 0, 10, 114, 0, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 0, 2, 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, - 2, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 56, 0, 0, 10, 114, 0, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 2, 64, 0, 0, - 0, 64, 28, 70, 0, 64, - 28, 70, 0, 64, 28, 70, - 0, 0, 0, 0, 14, 0, - 0, 8, 114, 0, 16, 0, - 2, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 246, 143, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 2, 0, 0, 0, - 86, 5, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 57, 0, 0, 8, 18, 0, - 16, 0, 0, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 0, 0, 56, 0, 0, 8, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 86, 133, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 24, 0, - 0, 11, 50, 0, 16, 0, - 4, 0, 0, 0, 6, 128, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 128, 63, - 0, 0, 0, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 16, 0, 0, 10, 18, 0, - 16, 0, 5, 0, 0, 0, - 2, 64, 0, 0, 140, 157, - 32, 63, 200, 151, 168, 62, - 249, 104, 49, 61, 0, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 16, 0, - 0, 10, 34, 0, 16, 0, - 5, 0, 0, 0, 2, 64, - 0, 0, 186, 130, 141, 61, - 10, 103, 107, 63, 175, 39, - 58, 60, 0, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 16, 0, 0, 10, - 66, 0, 16, 0, 5, 0, - 0, 0, 2, 64, 0, 0, - 107, 70, 134, 60, 41, 64, - 180, 61, 183, 69, 101, 63, - 0, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 5, 0, 0, 0, - 166, 10, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 5, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 52, 0, 0, 7, 130, 0, - 16, 0, 2, 0, 0, 0, - 42, 0, 16, 0, 5, 0, - 0, 0, 26, 0, 16, 0, - 5, 0, 0, 0, 52, 0, - 0, 7, 130, 0, 16, 0, - 2, 0, 0, 0, 58, 0, - 16, 0, 2, 0, 0, 0, - 10, 0, 16, 0, 5, 0, - 0, 0, 49, 0, 0, 7, - 130, 0, 16, 0, 3, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 0, 0, 58, 0, - 16, 0, 2, 0, 0, 0, - 50, 0, 0, 13, 194, 0, - 16, 0, 4, 0, 0, 0, - 86, 137, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 246, 15, 16, 0, 2, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 63, - 0, 0, 128, 63, 14, 0, - 0, 7, 130, 0, 16, 0, - 2, 0, 0, 0, 42, 0, - 16, 0, 4, 0, 0, 0, - 58, 0, 16, 0, 4, 0, - 0, 0, 56, 0, 0, 7, - 114, 0, 16, 0, 6, 0, - 0, 0, 246, 15, 16, 0, - 2, 0, 0, 0, 70, 2, - 16, 0, 5, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 5, 0, 0, 0, - 246, 15, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 6, 0, 0, 0, 70, 2, - 16, 0, 5, 0, 0, 0, - 16, 0, 0, 10, 18, 0, - 16, 0, 6, 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, - 5, 0, 0, 0, 16, 0, - 0, 10, 34, 0, 16, 0, - 6, 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, 5, 0, - 0, 0, 16, 0, 0, 10, - 66, 0, 16, 0, 6, 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, 5, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 5, 0, 0, 0, - 166, 10, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 6, 0, 0, 0, 70, 2, - 16, 0, 5, 0, 0, 0, - 55, 0, 0, 9, 226, 0, - 16, 0, 4, 0, 0, 0, - 86, 5, 16, 0, 4, 0, - 0, 0, 6, 9, 16, 0, - 5, 0, 0, 0, 6, 9, - 16, 0, 2, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 3, 0, 0, 0, - 6, 0, 16, 0, 4, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 150, 7, - 16, 0, 4, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 2, 0, 0, 0, - 6, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 31, 0, 4, 3, 58, 0, - 16, 0, 0, 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, 3, 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, 2, 0, 0, 0, - 56, 0, 0, 10, 114, 0, - 16, 0, 4, 0, 0, 0, - 70, 2, 16, 0, 2, 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, - 5, 0, 0, 0, 70, 2, - 16, 0, 2, 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, 5, 0, - 0, 0, 70, 2, 16, 128, - 129, 0, 0, 0, 5, 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, - 5, 0, 0, 0, 70, 2, - 16, 0, 5, 0, 0, 0, - 56, 0, 0, 10, 114, 0, - 16, 0, 5, 0, 0, 0, - 70, 2, 16, 0, 5, 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, - 5, 0, 0, 0, 70, 2, - 16, 0, 5, 0, 0, 0, - 55, 0, 0, 9, 114, 0, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 4, 0, 0, 0, 70, 2, - 16, 0, 5, 0, 0, 0, - 21, 0, 0, 1, 56, 0, - 0, 8, 114, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 246, 143, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 18, 0, 0, 1, 31, 0, - 4, 3, 42, 0, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 8, 114, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 246, 143, 32, 0, 0, 0, - 0, 0, 0, 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, 0, 3, - 10, 0, 16, 0, 0, 0, - 0, 0, 29, 0, 0, 10, - 210, 0, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 28, 46, 77, 59, 0, 0, - 0, 0, 28, 46, 77, 59, - 28, 46, 77, 59, 6, 9, - 16, 0, 1, 0, 0, 0, - 56, 0, 0, 10, 114, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 82, 184, 78, 65, 82, 184, - 78, 65, 82, 184, 78, 65, - 0, 0, 0, 0, 47, 0, - 0, 6, 114, 0, 16, 0, - 4, 0, 0, 0, 70, 2, - 16, 128, 129, 0, 0, 0, - 1, 0, 0, 0, 56, 0, - 0, 10, 114, 0, 16, 0, - 4, 0, 0, 0, 70, 2, - 16, 0, 4, 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, 4, 0, - 0, 0, 70, 2, 16, 0, - 4, 0, 0, 0, 50, 0, - 0, 15, 114, 0, 16, 0, - 4, 0, 0, 0, 70, 2, - 16, 0, 4, 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, 134, 3, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 4, 0, 0, 0, 21, 0, - 0, 1, 18, 0, 0, 1, - 31, 0, 4, 3, 26, 0, - 16, 0, 0, 0, 0, 0, - 16, 0, 0, 10, 18, 0, - 16, 0, 0, 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, - 2, 0, 0, 0, 16, 0, - 0, 10, 34, 0, 16, 0, - 0, 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, 2, 0, - 0, 0, 16, 0, 0, 10, - 66, 0, 16, 0, 0, 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, 2, 0, 0, 0, - 56, 0, 0, 8, 114, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 246, 143, 32, 0, - 0, 0, 0, 0, 0, 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, - 0, 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, 28, 46, 77, 59, - 28, 46, 77, 59, 28, 46, - 77, 59, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 82, 184, 78, 65, - 82, 184, 78, 65, 82, 184, - 78, 65, 0, 0, 0, 0, - 47, 0, 0, 6, 114, 0, - 16, 0, 4, 0, 0, 0, - 70, 2, 16, 128, 129, 0, - 0, 0, 1, 0, 0, 0, - 56, 0, 0, 10, 114, 0, - 16, 0, 4, 0, 0, 0, - 70, 2, 16, 0, 4, 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, - 4, 0, 0, 0, 70, 2, - 16, 0, 4, 0, 0, 0, - 50, 0, 0, 15, 114, 0, - 16, 0, 4, 0, 0, 0, - 70, 2, 16, 0, 4, 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, 0, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 0, 4, 0, 0, 0, - 21, 0, 0, 1, 18, 0, - 0, 1, 56, 0, 0, 8, - 114, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 246, 143, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 21, 0, - 0, 1, 21, 0, 0, 1, - 21, 0, 0, 1, 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, 126, 0, 0, 0, - 7, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 71, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 9, 0, 0, 0, 11, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 8, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 10, 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, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Advanced.hlsl b/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Advanced.hlsl deleted file mode 100644 index aad7b77..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Advanced.hlsl +++ /dev/null @@ -1,7 +0,0 @@ - -#include "D3D11_PixelShader_Common.hlsli" - -float4 main(PixelShaderInput input) : SV_TARGET -{ - return AdvancedPixelShader(input); -} diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Colors.h b/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Colors.h deleted file mode 100644 index 6658e4d..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Colors.h +++ /dev/null @@ -1,284 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 10.1 -// -// -// Buffer Definitions: -// -// cbuffer Constants -// { -// -// float scRGB_output; // Offset: 0 Size: 4 [unused] -// float texture_type; // Offset: 4 Size: 4 [unused] -// float input_type; // Offset: 8 Size: 4 [unused] -// float color_scale; // Offset: 12 Size: 4 -// float tonemap_method; // Offset: 16 Size: 4 [unused] -// float tonemap_factor1; // Offset: 20 Size: 4 [unused] -// float tonemap_factor2; // Offset: 24 Size: 4 [unused] -// float sdr_white_point; // Offset: 28 Size: 4 [unused] -// float4 Yoffset; // Offset: 32 Size: 16 [unused] -// float4 Rcoeff; // Offset: 48 Size: 16 [unused] -// float4 Gcoeff; // Offset: 64 Size: 16 [unused] -// float4 Bcoeff; // Offset: 80 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 - dcl t1 - mul r0.xyz, t1, c0.w - mov r0.w, t1.w - mov oC0, r0 - -// approximately 3 instruction slots used -ps_4_0 -dcl_constantbuffer CB0[1], immediateIndexed -dcl_input_ps linear v2.xyzw -dcl_output o0.xyzw -dcl_temps 1 -mov r0.x, cb0[0].w -mov r0.w, l(1.000000) -mul o0.xyzw, r0.xxxw, v2.xyzw -ret -// Approximately 4 instruction slots used -#endif - -const BYTE g_main[] = -{ - 68, 88, 66, 67, 78, 223, - 23, 23, 93, 184, 255, 26, - 153, 0, 220, 179, 25, 194, - 30, 249, 1, 0, 0, 0, - 192, 4, 0, 0, 6, 0, - 0, 0, 56, 0, 0, 0, - 172, 0, 0, 0, 56, 1, - 0, 0, 180, 1, 0, 0, - 24, 4, 0, 0, 140, 4, - 0, 0, 65, 111, 110, 57, - 108, 0, 0, 0, 108, 0, - 0, 0, 0, 2, 255, 255, - 60, 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, 31, 0, 0, 2, - 0, 0, 0, 128, 1, 0, - 15, 176, 5, 0, 0, 3, - 0, 0, 7, 128, 1, 0, - 228, 176, 0, 0, 255, 160, - 1, 0, 0, 2, 0, 0, - 8, 128, 1, 0, 255, 176, - 1, 0, 0, 2, 0, 8, - 15, 128, 0, 0, 228, 128, - 255, 255, 0, 0, 83, 72, - 68, 82, 132, 0, 0, 0, - 64, 0, 0, 0, 33, 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, 54, 0, 0, 6, - 18, 0, 16, 0, 0, 0, - 0, 0, 58, 128, 32, 0, - 0, 0, 0, 0, 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, 6, 12, - 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, 4, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 2, 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, 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, 92, 2, 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, - 49, 2, 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, 12, 0, - 0, 0, 96, 0, 0, 0, - 96, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 128, 1, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 144, 1, - 0, 0, 0, 0, 0, 0, - 160, 1, 0, 0, 4, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 144, 1, - 0, 0, 0, 0, 0, 0, - 173, 1, 0, 0, 8, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 144, 1, - 0, 0, 0, 0, 0, 0, - 184, 1, 0, 0, 12, 0, - 0, 0, 4, 0, 0, 0, - 2, 0, 0, 0, 144, 1, - 0, 0, 0, 0, 0, 0, - 196, 1, 0, 0, 16, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 144, 1, - 0, 0, 0, 0, 0, 0, - 211, 1, 0, 0, 20, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 144, 1, - 0, 0, 0, 0, 0, 0, - 227, 1, 0, 0, 24, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 144, 1, - 0, 0, 0, 0, 0, 0, - 243, 1, 0, 0, 28, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 144, 1, - 0, 0, 0, 0, 0, 0, - 3, 2, 0, 0, 32, 0, - 0, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 12, 2, - 0, 0, 0, 0, 0, 0, - 28, 2, 0, 0, 48, 0, - 0, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 12, 2, - 0, 0, 0, 0, 0, 0, - 35, 2, 0, 0, 64, 0, - 0, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 12, 2, - 0, 0, 0, 0, 0, 0, - 42, 2, 0, 0, 80, 0, - 0, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 12, 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, 116, 101, 120, 116, - 117, 114, 101, 95, 116, 121, - 112, 101, 0, 105, 110, 112, - 117, 116, 95, 116, 121, 112, - 101, 0, 99, 111, 108, 111, - 114, 95, 115, 99, 97, 108, - 101, 0, 116, 111, 110, 101, - 109, 97, 112, 95, 109, 101, - 116, 104, 111, 100, 0, 116, - 111, 110, 101, 109, 97, 112, - 95, 102, 97, 99, 116, 111, - 114, 49, 0, 116, 111, 110, - 101, 109, 97, 112, 95, 102, - 97, 99, 116, 111, 114, 50, - 0, 115, 100, 114, 95, 119, - 104, 105, 116, 101, 95, 112, - 111, 105, 110, 116, 0, 89, - 111, 102, 102, 115, 101, 116, - 0, 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 -}; diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Colors.hlsl b/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Colors.hlsl deleted file mode 100644 index 5757491..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Colors.hlsl +++ /dev/null @@ -1,7 +0,0 @@ - -#include "D3D11_PixelShader_Common.hlsli" - -float4 main(PixelShaderInput input) : SV_TARGET -{ - return GetOutputColor(1.0) * input.color; -} diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Common.hlsli b/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Common.hlsli deleted file mode 100644 index b940c0c..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Common.hlsli +++ /dev/null @@ -1,235 +0,0 @@ - -Texture2D texture0 : register(t0); -Texture2D texture1 : register(t1); -Texture2D texture2 : register(t2); -SamplerState sampler0 : register(s0); - -struct PixelShaderInput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; - float4 color : COLOR0; -}; - -// These should mirror the definitions in SDL_render_d3d11.c -static const float TONEMAP_NONE = 0; -static const float TONEMAP_LINEAR = 1; -static const float TONEMAP_CHROME = 2; - -static const float TEXTURETYPE_NONE = 0; -static const float TEXTURETYPE_RGB = 1; -static const float TEXTURETYPE_NV12 = 2; -static const float TEXTURETYPE_NV21 = 3; -static const float TEXTURETYPE_YUV = 4; - -static const float INPUTTYPE_UNSPECIFIED = 0; -static const float INPUTTYPE_SRGB = 1; -static const float INPUTTYPE_SCRGB = 2; -static const float INPUTTYPE_HDR10 = 3; - -cbuffer Constants : register(b0) -{ - float scRGB_output; - float texture_type; - float input_type; - float color_scale; - - float tonemap_method; - float tonemap_factor1; - float tonemap_factor2; - float sdr_white_point; - - float4 Yoffset; - float4 Rcoeff; - float4 Gcoeff; - float4 Bcoeff; -}; - -static const float3x3 mat709to2020 = { - { 0.627404, 0.329283, 0.043313 }, - { 0.069097, 0.919541, 0.011362 }, - { 0.016391, 0.088013, 0.895595 } -}; - -static const float3x3 mat2020to709 = { - { 1.660496, -0.587656, -0.072840 }, - { -0.124547, 1.132895, -0.008348 }, - { -0.018154, -0.100597, 1.118751 } -}; - -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; -} - -float3 PQtoLinear(float3 v) -{ - const float c1 = 0.8359375; - const float c2 = 18.8515625; - const float c3 = 18.6875; - const float oo_m1 = 1.0 / 0.1593017578125; - const float oo_m2 = 1.0 / 78.84375; - - float3 num = max(pow(abs(v), oo_m2) - c1, 0.0); - float3 den = c2 - c3 * pow(abs(v), oo_m2); - return (10000.0 * pow(abs(num / den), oo_m1) / sdr_white_point); -} - -float3 ApplyTonemap(float3 v) -{ - if (tonemap_method == TONEMAP_LINEAR) { - v *= tonemap_factor1; - } else if (tonemap_method == TONEMAP_CHROME) { - if (input_type == INPUTTYPE_SCRGB) { - // Convert to BT.2020 colorspace for tone mapping - v = mul(mat709to2020, v); - } - - float vmax = max(v.r, max(v.g, v.b)); - if (vmax > 0.0) { - float scale = (1.0 + tonemap_factor1 * vmax) / (1.0 + tonemap_factor2 * vmax); - v *= scale; - } - - if (input_type == INPUTTYPE_SCRGB) { - // Convert to BT.709 colorspace after tone mapping - v = mul(mat2020to709, v); - } - } - return v; -} - -float4 GetInputColor(PixelShaderInput input) -{ - float4 rgba; - - if (texture_type == TEXTURETYPE_NONE) { - rgba = 1.0; - } else if (texture_type == TEXTURETYPE_RGB) { - rgba = texture0.Sample(sampler0, input.tex); - } else if (texture_type == TEXTURETYPE_NV12) { - float3 yuv; - yuv.x = texture0.Sample(sampler0, input.tex).r; - yuv.yz = texture1.Sample(sampler0, input.tex).rg; - - yuv += Yoffset.xyz; - rgba.r = dot(yuv, Rcoeff.xyz); - rgba.g = dot(yuv, Gcoeff.xyz); - rgba.b = dot(yuv, Bcoeff.xyz); - rgba.a = 1.0; - } else if (texture_type == TEXTURETYPE_NV21) { - float3 yuv; - yuv.x = texture0.Sample(sampler0, input.tex).r; - yuv.yz = texture1.Sample(sampler0, input.tex).gr; - - yuv += Yoffset.xyz; - rgba.r = dot(yuv, Rcoeff.xyz); - rgba.g = dot(yuv, Gcoeff.xyz); - rgba.b = dot(yuv, Bcoeff.xyz); - rgba.a = 1.0; - } else if (texture_type == TEXTURETYPE_YUV) { - float3 yuv; - yuv.x = texture0.Sample(sampler0, input.tex).r; - yuv.y = texture1.Sample(sampler0, input.tex).r; - yuv.z = texture2.Sample(sampler0, input.tex).r; - - yuv += Yoffset.xyz; - rgba.r = dot(yuv, Rcoeff.xyz); - rgba.g = dot(yuv, Gcoeff.xyz); - rgba.b = dot(yuv, Bcoeff.xyz); - rgba.a = 1.0; - } else { - // Error! - rgba.r = 1.0; - rgba.g = 0.0; - rgba.b = 0.0; - rgba.a = 1.0; - } - return rgba; -} - -float4 GetOutputColor(float4 rgba) -{ - float4 output; - - output.rgb = rgba.rgb * color_scale; - output.a = rgba.a; - - return output; -} - -float3 GetOutputColorFromSRGB(float3 rgb) -{ - float3 output; - - if (scRGB_output) { - rgb.r = sRGBtoLinear(rgb.r); - rgb.g = sRGBtoLinear(rgb.g); - rgb.b = sRGBtoLinear(rgb.b); - } - - output.rgb = rgb * color_scale; - - return output; -} - -float3 GetOutputColorFromLinear(float3 rgb) -{ - float3 output; - - output.rgb = rgb * color_scale; - - if (!scRGB_output) { - output.r = sRGBfromLinear(output.r); - output.g = sRGBfromLinear(output.g); - output.b = sRGBfromLinear(output.b); - output.rgb = saturate(output.rgb); - } - - return output; -} - -float4 AdvancedPixelShader(PixelShaderInput input) -{ - float4 rgba = GetInputColor(input); - float4 output; - - if (input_type == INPUTTYPE_HDR10) { - rgba.rgb = PQtoLinear(rgba.rgb); - } - - if (tonemap_method != TONEMAP_NONE) { - rgba.rgb = ApplyTonemap(rgba.rgb); - } - - if (input_type == INPUTTYPE_SRGB) { - output.rgb = GetOutputColorFromSRGB(rgba.rgb); - output.a = rgba.a; - } else if (input_type == INPUTTYPE_SCRGB) { - output.rgb = GetOutputColorFromLinear(rgba.rgb); - output.a = rgba.a; - } else if (input_type == INPUTTYPE_HDR10) { - rgba.rgb = mul(mat2020to709, rgba.rgb); - output.rgb = GetOutputColorFromLinear(rgba.rgb); - output.a = rgba.a; - } else { - output = GetOutputColor(rgba); - } - - return output * input.color; -} diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Textures.h b/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Textures.h deleted file mode 100644 index 996cac6..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Textures.h +++ /dev/null @@ -1,332 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 10.1 -// -// -// Buffer Definitions: -// -// cbuffer Constants -// { -// -// float scRGB_output; // Offset: 0 Size: 4 [unused] -// float texture_type; // Offset: 4 Size: 4 [unused] -// float input_type; // Offset: 8 Size: 4 [unused] -// float color_scale; // Offset: 12 Size: 4 -// float tonemap_method; // Offset: 16 Size: 4 [unused] -// float tonemap_factor1; // Offset: 20 Size: 4 [unused] -// float tonemap_factor2; // Offset: 24 Size: 4 [unused] -// float sdr_white_point; // Offset: 28 Size: 4 [unused] -// float4 Yoffset; // Offset: 32 Size: 16 [unused] -// float4 Rcoeff; // Offset: 48 Size: 16 [unused] -// float4 Gcoeff; // Offset: 64 Size: 16 [unused] -// float4 Bcoeff; // Offset: 80 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 - dcl t0.xy - dcl t1 - dcl_2d s0 - texld r0, t0, s0 - mul r0.xyz, r0, c0.w - mul r0, r0, t1 - mov oC0, r0 - -// approximately 4 instruction slots used (1 texture, 3 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 1 -sample r0.xyzw, v1.xyxx, t0.xyzw, s0 -mul r0.xyz, r0.xyzx, cb0[0].wwww -mul o0.xyzw, r0.xyzw, v2.xyzw -ret -// Approximately 4 instruction slots used -#endif - -const BYTE g_main[] = -{ - 68, 88, 66, 67, 8, 152, - 224, 210, 182, 254, 37, 89, - 68, 213, 13, 174, 95, 42, - 2, 11, 1, 0, 0, 0, - 132, 5, 0, 0, 6, 0, - 0, 0, 56, 0, 0, 0, - 220, 0, 0, 0, 168, 1, - 0, 0, 36, 2, 0, 0, - 220, 4, 0, 0, 80, 5, - 0, 0, 65, 111, 110, 57, - 156, 0, 0, 0, 156, 0, - 0, 0, 0, 2, 255, 255, - 104, 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, - 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, 7, 128, - 0, 0, 228, 128, 0, 0, - 255, 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, 196, 0, 0, 0, - 64, 0, 0, 0, 49, 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, 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, 8, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 246, 143, 32, 0, - 0, 0, 0, 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, - 4, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 3, 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, 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, - 176, 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, 133, 2, - 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, 12, 0, 0, 0, - 180, 0, 0, 0, 96, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 212, 1, - 0, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 228, 1, 0, 0, - 0, 0, 0, 0, 244, 1, - 0, 0, 4, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 228, 1, 0, 0, - 0, 0, 0, 0, 1, 2, - 0, 0, 8, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 228, 1, 0, 0, - 0, 0, 0, 0, 12, 2, - 0, 0, 12, 0, 0, 0, - 4, 0, 0, 0, 2, 0, - 0, 0, 228, 1, 0, 0, - 0, 0, 0, 0, 24, 2, - 0, 0, 16, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 228, 1, 0, 0, - 0, 0, 0, 0, 39, 2, - 0, 0, 20, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 228, 1, 0, 0, - 0, 0, 0, 0, 55, 2, - 0, 0, 24, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 228, 1, 0, 0, - 0, 0, 0, 0, 71, 2, - 0, 0, 28, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 228, 1, 0, 0, - 0, 0, 0, 0, 87, 2, - 0, 0, 32, 0, 0, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 96, 2, 0, 0, - 0, 0, 0, 0, 112, 2, - 0, 0, 48, 0, 0, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 96, 2, 0, 0, - 0, 0, 0, 0, 119, 2, - 0, 0, 64, 0, 0, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 96, 2, 0, 0, - 0, 0, 0, 0, 126, 2, - 0, 0, 80, 0, 0, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 96, 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, - 116, 101, 120, 116, 117, 114, - 101, 95, 116, 121, 112, 101, - 0, 105, 110, 112, 117, 116, - 95, 116, 121, 112, 101, 0, - 99, 111, 108, 111, 114, 95, - 115, 99, 97, 108, 101, 0, - 116, 111, 110, 101, 109, 97, - 112, 95, 109, 101, 116, 104, - 111, 100, 0, 116, 111, 110, - 101, 109, 97, 112, 95, 102, - 97, 99, 116, 111, 114, 49, - 0, 116, 111, 110, 101, 109, - 97, 112, 95, 102, 97, 99, - 116, 111, 114, 50, 0, 115, - 100, 114, 95, 119, 104, 105, - 116, 101, 95, 112, 111, 105, - 110, 116, 0, 89, 111, 102, - 102, 115, 101, 116, 0, 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 -}; diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Textures.hlsl b/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Textures.hlsl deleted file mode 100644 index f2ecf18..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_PixelShader_Textures.hlsl +++ /dev/null @@ -1,9 +0,0 @@ -Texture2D theTexture : register(t0); -SamplerState theSampler : register(s0); - -#include "D3D11_PixelShader_Common.hlsli" - -float4 main(PixelShaderInput input) : SV_TARGET -{ - return GetOutputColor(theTexture.Sample(theSampler, input.tex)) * input.color; -} diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_VertexShader.h b/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_VertexShader.h deleted file mode 100644 index 97beaa3..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_VertexShader.h +++ /dev/null @@ -1,339 +0,0 @@ -#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 -}; diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_VertexShader.hlsl b/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_VertexShader.hlsl deleted file mode 100644 index 63e5172..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/D3D11_VertexShader.hlsl +++ /dev/null @@ -1,38 +0,0 @@ -#pragma pack_matrix( row_major ) - -cbuffer VertexShaderConstants : register(b0) -{ - matrix model; - matrix projectionAndView; -}; - -struct VertexShaderInput -{ - float3 pos : POSITION; - float2 tex : TEXCOORD0; - float4 color : COLOR0; -}; - -struct VertexShaderOutput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; - float4 color : COLOR0; -}; - -VertexShaderOutput main(VertexShaderInput input) -{ - VertexShaderOutput output; - float4 pos = float4(input.pos, 1.0f); - - // Transform the vertex position into projected space. - pos = mul(pos, model); - pos = mul(pos, projectionAndView); - output.pos = pos; - - // Pass through texture coordinates and color values without transformation - output.tex = input.tex; - output.color = input.color; - - return output; -} diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/SDL_render_d3d11.c b/contrib/SDL-3.2.8/src/render/direct3d11/SDL_render_d3d11.c deleted file mode 100644 index dc1a722..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/SDL_render_d3d11.c +++ /dev/null @@ -1,2767 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2025 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#ifdef SDL_VIDEO_RENDER_D3D11 - -#define COBJMACROS -#include "../../core/windows/SDL_windows.h" -#include "../../video/windows/SDL_windowswindow.h" -#include "../SDL_sysrender.h" -#include "../SDL_d3dmath.h" -#include "../../video/SDL_pixels_c.h" - -#include -#include -#include - -#include "SDL_shaders_d3d11.h" - -#if defined(_MSC_VER) && !defined(__clang__) -#define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str -#else -#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str -#endif - -#define SAFE_RELEASE(X) \ - if ((X)) { \ - IUnknown_Release(SDL_static_cast(IUnknown *, X)); \ - X = NULL; \ - } - -/* !!! FIXME: vertex buffer bandwidth could be lower; only use UV coords when - !!! FIXME: textures are needed. */ - -// Sampler types -typedef enum -{ - D3D11_SAMPLER_NEAREST_CLAMP, - D3D11_SAMPLER_NEAREST_WRAP, - D3D11_SAMPLER_LINEAR_CLAMP, - D3D11_SAMPLER_LINEAR_WRAP, - D3D11_SAMPLER_COUNT -} D3D11_Sampler; - -// Vertex shader, common values -typedef struct -{ - Float4X4 model; - Float4X4 projectionAndView; -} D3D11_VertexShaderConstants; - -// These should mirror the definitions in D3D11_PixelShader_Common.hlsli -//static const float TONEMAP_NONE = 0; -//static const float TONEMAP_LINEAR = 1; -static const float TONEMAP_CHROME = 2; - -//static const float TEXTURETYPE_NONE = 0; -static const float TEXTURETYPE_RGB = 1; -static const float TEXTURETYPE_NV12 = 2; -static const float TEXTURETYPE_NV21 = 3; -static const float TEXTURETYPE_YUV = 4; - -static const float INPUTTYPE_UNSPECIFIED = 0; -static const float INPUTTYPE_SRGB = 1; -static const float INPUTTYPE_SCRGB = 2; -static const float INPUTTYPE_HDR10 = 3; - -typedef struct -{ - float scRGB_output; - float texture_type; - float input_type; - float color_scale; - - float tonemap_method; - float tonemap_factor1; - float tonemap_factor2; - float sdr_white_point; - - float YCbCr_matrix[16]; -} D3D11_PixelShaderConstants; - -typedef struct -{ - ID3D11Buffer *constants; - D3D11_PixelShaderConstants shader_constants; -} D3D11_PixelShaderState; - -// Per-vertex data -typedef struct -{ - Float2 pos; - Float2 tex; - SDL_FColor color; -} D3D11_VertexPositionColor; - -// Per-texture data -typedef struct -{ - int w, h; - ID3D11Texture2D *mainTexture; - ID3D11ShaderResourceView *mainTextureResourceView; - ID3D11RenderTargetView *mainTextureRenderTargetView; - ID3D11Texture2D *stagingTexture; - int lockedTexturePositionX; - int lockedTexturePositionY; - D3D11_FILTER scaleMode; - D3D11_Shader shader; - const float *YCbCr_matrix; -#ifdef SDL_HAVE_YUV - // YV12 texture support - bool yuv; - ID3D11Texture2D *mainTextureU; - ID3D11ShaderResourceView *mainTextureResourceViewU; - ID3D11Texture2D *mainTextureV; - ID3D11ShaderResourceView *mainTextureResourceViewV; - - // NV12 texture support - bool nv12; - ID3D11ShaderResourceView *mainTextureResourceViewNV; - - Uint8 *pixels; - int pitch; - SDL_Rect locked_rect; -#endif -} D3D11_TextureData; - -// Blend mode data -typedef struct -{ - SDL_BlendMode blendMode; - ID3D11BlendState *blendState; -} D3D11_BlendMode; - -// Private renderer data -typedef struct -{ - SDL_SharedObject *hDXGIMod; - SDL_SharedObject *hD3D11Mod; - IDXGIFactory2 *dxgiFactory; - IDXGIAdapter *dxgiAdapter; - IDXGIDebug *dxgiDebug; - ID3D11Device1 *d3dDevice; - ID3D11DeviceContext1 *d3dContext; - IDXGISwapChain1 *swapChain; - DXGI_SWAP_EFFECT swapEffect; - UINT syncInterval; - UINT presentFlags; - ID3D11RenderTargetView *mainRenderTargetView; - ID3D11RenderTargetView *currentOffscreenRenderTargetView; - ID3D11InputLayout *inputLayout; - ID3D11Buffer *vertexBuffers[8]; - size_t vertexBufferSizes[8]; - ID3D11VertexShader *vertexShader; - ID3D11PixelShader *pixelShaders[NUM_SHADERS]; - int blendModesCount; - D3D11_BlendMode *blendModes; - ID3D11SamplerState *samplers[D3D11_SAMPLER_COUNT]; - D3D_FEATURE_LEVEL featureLevel; - bool pixelSizeChanged; - - // Rasterizers - ID3D11RasterizerState *mainRasterizer; - ID3D11RasterizerState *clippedRasterizer; - - // Vertex buffer constants - D3D11_VertexShaderConstants vertexShaderConstantsData; - ID3D11Buffer *vertexShaderConstants; - - // Cached renderer properties - DXGI_MODE_ROTATION rotation; - ID3D11RenderTargetView *currentRenderTargetView; - ID3D11RasterizerState *currentRasterizerState; - ID3D11BlendState *currentBlendState; - D3D11_Shader currentShader; - D3D11_PixelShaderState currentShaderState[NUM_SHADERS]; - ID3D11ShaderResourceView *currentShaderResource; - ID3D11SamplerState *currentSampler; - bool cliprectDirty; - bool currentCliprectEnabled; - SDL_Rect currentCliprect; - SDL_Rect currentViewport; - int currentViewportRotation; - bool viewportDirty; - Float4X4 identity; - int currentVertexBuffer; -} D3D11_RenderData; - -// Define D3D GUIDs here so we don't have to include uuid.lib. - -#ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-const-variable" -#endif - -static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; -static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; -static const GUID SDL_IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } }; -static const GUID SDL_IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } }; -static const GUID SDL_IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } }; -static const GUID SDL_IID_IDXGISwapChain2 = { 0x94d99bdb, 0xf1f8, 0x4ab0, { 0xb2, 0x36, 0x7d, 0xa0, 0x17, 0x0e, 0xda, 0xb1 } }; -static const GUID SDL_IID_IDXGIDebug1 = { 0xc5a05f0c, 0x16f2, 0x4adf, { 0x9f, 0x4d, 0xa8, 0xc4, 0xd5, 0x8a, 0xc5, 0x50 } }; -static const GUID SDL_IID_IDXGIInfoQueue = { 0xD67441C7, 0x672A, 0x476f, { 0x9E, 0x82, 0xCD, 0x55, 0xB4, 0x49, 0x49, 0xCE } }; -static const GUID SDL_DXGI_DEBUG_ALL = { 0xe48ae283, 0xda80, 0x490b, { 0x87, 0xe6, 0x43, 0xe9, 0xa9, 0xcf, 0xda, 0x8 } }; - -#ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA -#pragma GCC diagnostic pop -#endif - -SDL_PixelFormat D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) -{ - switch (dxgiFormat) { - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - return SDL_PIXELFORMAT_ARGB8888; - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - return SDL_PIXELFORMAT_ABGR8888; - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - return SDL_PIXELFORMAT_XRGB8888; - case DXGI_FORMAT_R10G10B10A2_UNORM: - return SDL_PIXELFORMAT_ABGR2101010; - case DXGI_FORMAT_R16G16B16A16_FLOAT: - return SDL_PIXELFORMAT_RGBA64_FLOAT; - default: - return SDL_PIXELFORMAT_UNKNOWN; - } -} - -static DXGI_FORMAT SDLPixelFormatToDXGITextureFormat(Uint32 format, Uint32 output_colorspace) -{ - switch (format) { - case SDL_PIXELFORMAT_RGBA64_FLOAT: - return DXGI_FORMAT_R16G16B16A16_FLOAT; - case SDL_PIXELFORMAT_ABGR2101010: - return DXGI_FORMAT_R10G10B10A2_UNORM; - case SDL_PIXELFORMAT_ARGB8888: - if (output_colorspace == SDL_COLORSPACE_SRGB_LINEAR) { - return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; - } - return DXGI_FORMAT_B8G8R8A8_UNORM; - case SDL_PIXELFORMAT_ABGR8888: - if (output_colorspace == SDL_COLORSPACE_SRGB_LINEAR) { - return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - } - return DXGI_FORMAT_R8G8B8A8_UNORM; - case SDL_PIXELFORMAT_XRGB8888: - if (output_colorspace == SDL_COLORSPACE_SRGB_LINEAR) { - return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; - } - return DXGI_FORMAT_B8G8R8X8_UNORM; - case SDL_PIXELFORMAT_YV12: - case SDL_PIXELFORMAT_IYUV: - return DXGI_FORMAT_R8_UNORM; - case SDL_PIXELFORMAT_NV12: - case SDL_PIXELFORMAT_NV21: - return DXGI_FORMAT_NV12; - case SDL_PIXELFORMAT_P010: - return DXGI_FORMAT_P010; - default: - return DXGI_FORMAT_UNKNOWN; - } -} - -static DXGI_FORMAT SDLPixelFormatToDXGIMainResourceViewFormat(Uint32 format, Uint32 colorspace) -{ - switch (format) { - case SDL_PIXELFORMAT_RGBA64_FLOAT: - return DXGI_FORMAT_R16G16B16A16_FLOAT; - case SDL_PIXELFORMAT_ABGR2101010: - return DXGI_FORMAT_R10G10B10A2_UNORM; - case SDL_PIXELFORMAT_ARGB8888: - if (colorspace == SDL_COLORSPACE_SRGB_LINEAR) { - return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; - } - return DXGI_FORMAT_B8G8R8A8_UNORM; - case SDL_PIXELFORMAT_ABGR8888: - if (colorspace == SDL_COLORSPACE_SRGB_LINEAR) { - return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - } - return DXGI_FORMAT_R8G8B8A8_UNORM; - case SDL_PIXELFORMAT_XRGB8888: - if (colorspace == SDL_COLORSPACE_SRGB_LINEAR) { - return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; - } - return DXGI_FORMAT_B8G8R8X8_UNORM; - case SDL_PIXELFORMAT_YV12: - case SDL_PIXELFORMAT_IYUV: - case SDL_PIXELFORMAT_NV12: // For the Y texture - case SDL_PIXELFORMAT_NV21: // For the Y texture - return DXGI_FORMAT_R8_UNORM; - case SDL_PIXELFORMAT_P010: // For the Y texture - return DXGI_FORMAT_R16_UNORM; - default: - return DXGI_FORMAT_UNKNOWN; - } -} - -static void D3D11_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); - -static void D3D11_ReleaseAll(SDL_Renderer *renderer) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - - // Release all textures - for (SDL_Texture *texture = renderer->textures; texture; texture = texture->next) { - D3D11_DestroyTexture(renderer, texture); - } - - // Release/reset everything else - if (data) { - int i; - - // Make sure the swap chain is fully released - if (data->d3dContext) { - ID3D11DeviceContext_ClearState(data->d3dContext); - ID3D11DeviceContext_Flush(data->d3dContext); - } - - SAFE_RELEASE(data->vertexShaderConstants); - SAFE_RELEASE(data->clippedRasterizer); - SAFE_RELEASE(data->mainRasterizer); - for (i = 0; i < SDL_arraysize(data->samplers); ++i) { - SAFE_RELEASE(data->samplers[i]); - } - - if (data->blendModesCount > 0) { - for (i = 0; i < data->blendModesCount; ++i) { - SAFE_RELEASE(data->blendModes[i].blendState); - } - SDL_free(data->blendModes); - data->blendModes = NULL; - data->blendModesCount = 0; - } - for (i = 0; i < SDL_arraysize(data->pixelShaders); ++i) { - SAFE_RELEASE(data->pixelShaders[i]); - } - for (i = 0; i < SDL_arraysize(data->currentShaderState); ++i) { - SAFE_RELEASE(data->currentShaderState[i].constants); - } - SAFE_RELEASE(data->vertexShader); - for (i = 0; i < SDL_arraysize(data->vertexBuffers); ++i) { - SAFE_RELEASE(data->vertexBuffers[i]); - } - SAFE_RELEASE(data->inputLayout); - SAFE_RELEASE(data->mainRenderTargetView); - SAFE_RELEASE(data->swapChain); - - SAFE_RELEASE(data->d3dContext); - SAFE_RELEASE(data->d3dDevice); - SAFE_RELEASE(data->dxgiAdapter); - SAFE_RELEASE(data->dxgiFactory); - - data->swapEffect = (DXGI_SWAP_EFFECT)0; - data->rotation = DXGI_MODE_ROTATION_UNSPECIFIED; - data->currentOffscreenRenderTargetView = NULL; - data->currentRenderTargetView = NULL; - data->currentRasterizerState = NULL; - data->currentBlendState = NULL; - data->currentShader = SHADER_NONE; - SDL_zero(data->currentShaderState); - data->currentShaderResource = NULL; - data->currentSampler = NULL; - - // Check for any leaks if in debug mode - if (data->dxgiDebug) { - DXGI_DEBUG_RLO_FLAGS rloFlags = (DXGI_DEBUG_RLO_FLAGS)(DXGI_DEBUG_RLO_DETAIL | DXGI_DEBUG_RLO_IGNORE_INTERNAL); - IDXGIDebug_ReportLiveObjects(data->dxgiDebug, SDL_DXGI_DEBUG_ALL, rloFlags); - SAFE_RELEASE(data->dxgiDebug); - } - - /* Unload the D3D libraries. This should be done last, in order - * to prevent IUnknown::Release() calls from crashing. - */ - if (data->hD3D11Mod) { - SDL_UnloadObject(data->hD3D11Mod); - data->hD3D11Mod = NULL; - } - if (data->hDXGIMod) { - SDL_UnloadObject(data->hDXGIMod); - data->hDXGIMod = NULL; - } - } -} - -static void D3D11_DestroyRenderer(SDL_Renderer *renderer) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - if (data) { - D3D11_ReleaseAll(renderer); - SDL_free(data); - } -} - -static D3D11_BLEND GetBlendFunc(SDL_BlendFactor factor) -{ - switch (factor) { - case SDL_BLENDFACTOR_ZERO: - return D3D11_BLEND_ZERO; - case SDL_BLENDFACTOR_ONE: - return D3D11_BLEND_ONE; - case SDL_BLENDFACTOR_SRC_COLOR: - return D3D11_BLEND_SRC_COLOR; - case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: - return D3D11_BLEND_INV_SRC_COLOR; - case SDL_BLENDFACTOR_SRC_ALPHA: - return D3D11_BLEND_SRC_ALPHA; - case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: - return D3D11_BLEND_INV_SRC_ALPHA; - case SDL_BLENDFACTOR_DST_COLOR: - return D3D11_BLEND_DEST_COLOR; - case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: - return D3D11_BLEND_INV_DEST_COLOR; - case SDL_BLENDFACTOR_DST_ALPHA: - return D3D11_BLEND_DEST_ALPHA; - case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: - return D3D11_BLEND_INV_DEST_ALPHA; - default: - return (D3D11_BLEND)0; - } -} - -static D3D11_BLEND_OP GetBlendEquation(SDL_BlendOperation operation) -{ - switch (operation) { - case SDL_BLENDOPERATION_ADD: - return D3D11_BLEND_OP_ADD; - case SDL_BLENDOPERATION_SUBTRACT: - return D3D11_BLEND_OP_SUBTRACT; - case SDL_BLENDOPERATION_REV_SUBTRACT: - return D3D11_BLEND_OP_REV_SUBTRACT; - case SDL_BLENDOPERATION_MINIMUM: - return D3D11_BLEND_OP_MIN; - case SDL_BLENDOPERATION_MAXIMUM: - return D3D11_BLEND_OP_MAX; - default: - return (D3D11_BLEND_OP)0; - } -} - -static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_BlendMode blendMode) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); - SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); - SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); - SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode); - SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode); - SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode); - ID3D11BlendState *blendState = NULL; - D3D11_BlendMode *blendModes; - HRESULT result = S_OK; - - D3D11_BLEND_DESC blendDesc; - SDL_zero(blendDesc); - blendDesc.AlphaToCoverageEnable = FALSE; - blendDesc.IndependentBlendEnable = FALSE; - blendDesc.RenderTarget[0].BlendEnable = TRUE; - blendDesc.RenderTarget[0].SrcBlend = GetBlendFunc(srcColorFactor); - blendDesc.RenderTarget[0].DestBlend = GetBlendFunc(dstColorFactor); - blendDesc.RenderTarget[0].BlendOp = GetBlendEquation(colorOperation); - blendDesc.RenderTarget[0].SrcBlendAlpha = GetBlendFunc(srcAlphaFactor); - blendDesc.RenderTarget[0].DestBlendAlpha = GetBlendFunc(dstAlphaFactor); - blendDesc.RenderTarget[0].BlendOpAlpha = GetBlendEquation(alphaOperation); - blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - result = ID3D11Device_CreateBlendState(data->d3dDevice, &blendDesc, &blendState); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBlendState"), result); - return NULL; - } - - blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes)); - if (!blendModes) { - SAFE_RELEASE(blendState); - return NULL; - } - blendModes[data->blendModesCount].blendMode = blendMode; - blendModes[data->blendModesCount].blendState = blendState; - data->blendModes = blendModes; - ++data->blendModesCount; - - return blendState; -} - -// Create resources that depend on the device. -static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) -{ - typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); - typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY2)(UINT flags, REFIID riid, void **ppFactory); - PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc = NULL; - PFN_CREATE_DXGI_FACTORY2 CreateDXGIFactory2Func = NULL; - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc; - ID3D11Device *d3dDevice = NULL; - ID3D11DeviceContext *d3dContext = NULL; - IDXGIDevice1 *dxgiDevice = NULL; - HRESULT result = S_OK; - UINT creationFlags = 0; - bool createDebug; - - /* This array defines the set of DirectX hardware feature levels this app will support. - * Note the ordering should be preserved. - * Don't forget to declare your application's minimum required feature level in its - * description. All applications are assumed to support 9.1 unless otherwise stated. - */ - D3D_FEATURE_LEVEL featureLevels[] = { - D3D_FEATURE_LEVEL_11_1, - D3D_FEATURE_LEVEL_11_0, - D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_10_0, - D3D_FEATURE_LEVEL_9_3, - D3D_FEATURE_LEVEL_9_2, - D3D_FEATURE_LEVEL_9_1 - }; - - D3D11_BUFFER_DESC constantBufferDesc; - D3D11_SAMPLER_DESC samplerDesc; - D3D11_RASTERIZER_DESC rasterDesc; - - // See if we need debug interfaces - createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, false); - - data->hDXGIMod = SDL_LoadObject("dxgi.dll"); - if (!data->hDXGIMod) { - result = E_FAIL; - goto done; - } - - CreateDXGIFactory2Func = (PFN_CREATE_DXGI_FACTORY2)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2"); - if (!CreateDXGIFactory2Func) { - CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory"); - if (!CreateDXGIFactoryFunc) { - result = E_FAIL; - goto done; - } - } - - data->hD3D11Mod = SDL_LoadObject("d3d11.dll"); - if (!data->hD3D11Mod) { - result = E_FAIL; - goto done; - } - - D3D11CreateDeviceFunc = (PFN_D3D11_CREATE_DEVICE)SDL_LoadFunction(data->hD3D11Mod, "D3D11CreateDevice"); - if (!D3D11CreateDeviceFunc) { - result = E_FAIL; - goto done; - } - - if (createDebug) { -#ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__ - IDXGIInfoQueue *dxgiInfoQueue = NULL; - PFN_CREATE_DXGI_FACTORY2 DXGIGetDebugInterfaceFunc; - - // If the debug hint is set, also create the DXGI factory in debug mode - DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY2)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1"); - if (!DXGIGetDebugInterfaceFunc) { - result = E_FAIL; - goto done; - } - - result = DXGIGetDebugInterfaceFunc(0, &SDL_IID_IDXGIDebug1, (void **)&data->dxgiDebug); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("DXGIGetDebugInterface1"), result); - goto done; - } - - result = DXGIGetDebugInterfaceFunc(0, &SDL_IID_IDXGIInfoQueue, (void **)&dxgiInfoQueue); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("DXGIGetDebugInterface1"), result); - goto done; - } - - IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, TRUE); - IDXGIInfoQueue_SetBreakOnSeverity(dxgiInfoQueue, SDL_DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, TRUE); - SAFE_RELEASE(dxgiInfoQueue); -#endif // __IDXGIInfoQueue_INTERFACE_DEFINED__ - creationFlags = DXGI_CREATE_FACTORY_DEBUG; - } - - if (CreateDXGIFactory2Func) { - result = CreateDXGIFactory2Func(creationFlags, &SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory); - } else { - result = CreateDXGIFactoryFunc(&SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory); - } - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("CreateDXGIFactory"), result); - goto done; - } - - // FIXME: Should we use the default adapter? - result = IDXGIFactory2_EnumAdapters(data->dxgiFactory, 0, &data->dxgiAdapter); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result); - goto done; - } - - /* This flag adds support for surfaces with a different color channel ordering - * than the API default. It is required for compatibility with Direct2D. - */ - creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; - - // Make sure Direct3D's debugging feature gets used, if the app requests it. - if (createDebug) { - creationFlags |= D3D11_CREATE_DEVICE_DEBUG; - } - - // Create a single-threaded device unless the app requests otherwise. - if (!SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, false)) { - creationFlags |= D3D11_CREATE_DEVICE_SINGLETHREADED; - } - - // Create the Direct3D 11 API device object and a corresponding context. - result = D3D11CreateDeviceFunc( - data->dxgiAdapter, - D3D_DRIVER_TYPE_UNKNOWN, - NULL, - creationFlags, // Set set debug and Direct2D compatibility flags. - featureLevels, // List of feature levels this app can support. - SDL_arraysize(featureLevels), - D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Store apps. - &d3dDevice, // Returns the Direct3D device created. - &data->featureLevel, // Returns feature level of device created. - &d3dContext // Returns the device immediate context. - ); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("D3D11CreateDevice"), result); - goto done; - } - - result = ID3D11Device_QueryInterface(d3dDevice, &SDL_IID_ID3D11Device1, (void **)&data->d3dDevice); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device to ID3D11Device1"), result); - goto done; - } - - result = ID3D11DeviceContext_QueryInterface(d3dContext, &SDL_IID_ID3D11DeviceContext1, (void **)&data->d3dContext); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext to ID3D11DeviceContext1"), result); - goto done; - } - - result = ID3D11Device_QueryInterface(d3dDevice, &SDL_IID_IDXGIDevice1, (void **)&dxgiDevice); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device to IDXGIDevice1"), result); - goto done; - } - - /* Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and - * ensures that the application will only render after each VSync, minimizing power consumption. - */ - result = IDXGIDevice1_SetMaximumFrameLatency(dxgiDevice, 1); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIDevice1::SetMaximumFrameLatency"), result); - goto done; - } - - /* Make note of the maximum texture size - * Max texture sizes are documented on MSDN, at: - * http://msdn.microsoft.com/en-us/library/windows/apps/ff476876.aspx - */ - switch (data->featureLevel) { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, 16384); - break; - - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, 8192); - break; - - case D3D_FEATURE_LEVEL_9_3: - SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, 4096); - break; - - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - SDL_SetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER, 2048); - break; - - default: - SDL_SetError("%s, Unexpected feature level: %d", __FUNCTION__, data->featureLevel); - result = E_FAIL; - goto done; - } - - if (!D3D11_CreateVertexShader(data->d3dDevice, &data->vertexShader, &data->inputLayout)) { - goto done; - } - - // Setup space to hold vertex shader constants: - SDL_zero(constantBufferDesc); - constantBufferDesc.ByteWidth = sizeof(D3D11_VertexShaderConstants); - constantBufferDesc.Usage = D3D11_USAGE_DEFAULT; - constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - result = ID3D11Device_CreateBuffer(data->d3dDevice, - &constantBufferDesc, - NULL, - &data->vertexShaderConstants); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex shader constants]"), result); - goto done; - } - - // Create samplers to use when drawing textures: - static struct - { - D3D11_FILTER filter; - D3D11_TEXTURE_ADDRESS_MODE address; - } samplerParams[] = { - { D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_CLAMP }, - { D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_WRAP }, - { D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_CLAMP }, - { D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_WRAP }, - }; - SDL_COMPILE_TIME_ASSERT(samplerParams_SIZE, SDL_arraysize(samplerParams) == D3D11_SAMPLER_COUNT); - SDL_zero(samplerDesc); - samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; - samplerDesc.MipLODBias = 0.0f; - samplerDesc.MaxAnisotropy = 1; - samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; - samplerDesc.MinLOD = 0.0f; - samplerDesc.MaxLOD = D3D11_FLOAT32_MAX; - for (int i = 0; i < SDL_arraysize(samplerParams); ++i) { - samplerDesc.Filter = samplerParams[i].filter; - samplerDesc.AddressU = samplerParams[i].address; - samplerDesc.AddressV = samplerParams[i].address; - result = ID3D11Device_CreateSamplerState(data->d3dDevice, - &samplerDesc, - &data->samplers[i]); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateSamplerState [nearest-pixel filter]"), result); - goto done; - } - } - - // Setup Direct3D rasterizer states - SDL_zero(rasterDesc); - rasterDesc.AntialiasedLineEnable = FALSE; - rasterDesc.CullMode = D3D11_CULL_NONE; - rasterDesc.DepthBias = 0; - rasterDesc.DepthBiasClamp = 0.0f; - rasterDesc.DepthClipEnable = TRUE; - rasterDesc.FillMode = D3D11_FILL_SOLID; - rasterDesc.FrontCounterClockwise = FALSE; - rasterDesc.MultisampleEnable = FALSE; - rasterDesc.ScissorEnable = FALSE; - rasterDesc.SlopeScaledDepthBias = 0.0f; - result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->mainRasterizer); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRasterizerState [main rasterizer]"), result); - goto done; - } - - rasterDesc.ScissorEnable = TRUE; - result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->clippedRasterizer); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRasterizerState [clipped rasterizer]"), result); - goto done; - } - - // Create blending states: - if (!D3D11_CreateBlendState(renderer, SDL_BLENDMODE_BLEND)) { - // D3D11_CreateBlendState will set the SDL error, if it fails - goto done; - } - - // Setup render state that doesn't change - ID3D11DeviceContext_IASetInputLayout(data->d3dContext, data->inputLayout); - ID3D11DeviceContext_VSSetShader(data->d3dContext, data->vertexShader, NULL, 0); - ID3D11DeviceContext_VSSetConstantBuffers(data->d3dContext, 0, 1, &data->vertexShaderConstants); - - SDL_SetPointerProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_D3D11_DEVICE_POINTER, data->d3dDevice); - -done: - SAFE_RELEASE(d3dDevice); - SAFE_RELEASE(d3dContext); - SAFE_RELEASE(dxgiDevice); - return result; -} - -static DXGI_MODE_ROTATION D3D11_GetCurrentRotation(void) -{ - // FIXME - return DXGI_MODE_ROTATION_IDENTITY; -} - -static BOOL D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) -{ - switch (rotation) { - case DXGI_MODE_ROTATION_ROTATE90: - case DXGI_MODE_ROTATION_ROTATE270: - return TRUE; - default: - return FALSE; - } -} - -static int D3D11_GetRotationForCurrentRenderTarget(SDL_Renderer *renderer) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - if (data->currentOffscreenRenderTargetView) { - return DXGI_MODE_ROTATION_IDENTITY; - } else { - return data->rotation; - } -} - -static bool D3D11_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rect *sdlRect, D3D11_RECT *outRect, BOOL includeViewportOffset) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer); - const SDL_Rect *viewport = &data->currentViewport; - - switch (rotation) { - case DXGI_MODE_ROTATION_IDENTITY: - outRect->left = sdlRect->x; - outRect->right = (LONG)sdlRect->x + sdlRect->w; - outRect->top = sdlRect->y; - outRect->bottom = (LONG)sdlRect->y + sdlRect->h; - if (includeViewportOffset) { - outRect->left += viewport->x; - outRect->right += viewport->x; - outRect->top += viewport->y; - outRect->bottom += viewport->y; - } - break; - case DXGI_MODE_ROTATION_ROTATE270: - outRect->left = sdlRect->y; - outRect->right = (LONG)sdlRect->y + sdlRect->h; - outRect->top = viewport->w - sdlRect->x - sdlRect->w; - outRect->bottom = viewport->w - sdlRect->x; - break; - case DXGI_MODE_ROTATION_ROTATE180: - outRect->left = viewport->w - sdlRect->x - sdlRect->w; - outRect->right = viewport->w - sdlRect->x; - outRect->top = viewport->h - sdlRect->y - sdlRect->h; - outRect->bottom = viewport->h - sdlRect->y; - break; - case DXGI_MODE_ROTATION_ROTATE90: - outRect->left = viewport->h - sdlRect->y - sdlRect->h; - outRect->right = viewport->h - sdlRect->y; - outRect->top = sdlRect->x; - outRect->bottom = (LONG)sdlRect->x + sdlRect->h; - break; - default: - return SDL_SetError("The physical display is in an unknown or unsupported rotation"); - } - return true; -} - -static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - IUnknown *coreWindow = NULL; - IDXGISwapChain3 *swapChain3 = NULL; - HRESULT result = S_OK; - - // Create a swap chain using the same adapter as the existing Direct3D device. - DXGI_SWAP_CHAIN_DESC1 swapChainDesc; - SDL_zero(swapChainDesc); - swapChainDesc.Width = w; - swapChainDesc.Height = h; - switch (renderer->output_colorspace) { - case SDL_COLORSPACE_SRGB_LINEAR: - swapChainDesc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; - break; - case SDL_COLORSPACE_HDR10: - swapChainDesc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; - break; - default: - swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; // This is the most common swap chain format. - break; - } - swapChainDesc.Stereo = FALSE; - swapChainDesc.SampleDesc.Count = 1; // Don't use multi-sampling. - swapChainDesc.SampleDesc.Quality = 0; - swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swapChainDesc.BufferCount = 2; // Use double-buffering to minimize latency. - if (WIN_IsWindows8OrGreater()) { - swapChainDesc.Scaling = DXGI_SCALING_NONE; - } else { - swapChainDesc.Scaling = DXGI_SCALING_STRETCH; - } - if (SDL_GetWindowFlags(renderer->window) & SDL_WINDOW_TRANSPARENT) { - swapChainDesc.Scaling = DXGI_SCALING_STRETCH; - swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - } else { - swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // All Windows Store apps must use this SwapEffect. - } - swapChainDesc.Flags = 0; - - if (coreWindow) { - result = IDXGIFactory2_CreateSwapChainForCoreWindow(data->dxgiFactory, - (IUnknown *)data->d3dDevice, - coreWindow, - &swapChainDesc, - NULL, // Allow on all displays. - &data->swapChain); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForCoreWindow"), result); - goto done; - } - } else { -#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) - HWND hwnd = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(renderer->window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); - if (!hwnd) { - SDL_SetError("Couldn't get window handle"); - result = E_FAIL; - goto done; - } - - result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory, - (IUnknown *)data->d3dDevice, - hwnd, - &swapChainDesc, - NULL, - NULL, // Allow on all displays. - &data->swapChain); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGIFactory2::CreateSwapChainForHwnd"), result); - goto done; - } - - IDXGIFactory_MakeWindowAssociation(data->dxgiFactory, hwnd, DXGI_MWA_NO_WINDOW_CHANGES); -#else - SDL_SetError(__FUNCTION__ ", Unable to find something to attach a swap chain to"); - goto done; -#endif // defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) / else - } - data->swapEffect = swapChainDesc.SwapEffect; - - if (SUCCEEDED(IDXGISwapChain1_QueryInterface(data->swapChain, &SDL_IID_IDXGISwapChain2, (void **)&swapChain3))) { - UINT colorspace_support = 0; - DXGI_COLOR_SPACE_TYPE colorspace; - switch (renderer->output_colorspace) { - case SDL_COLORSPACE_SRGB_LINEAR: - colorspace = DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709; - break; - case SDL_COLORSPACE_HDR10: - colorspace = DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020; - break; - default: - // sRGB - colorspace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; - break; - } - if (SUCCEEDED(IDXGISwapChain3_CheckColorSpaceSupport(swapChain3, colorspace, &colorspace_support)) && - (colorspace_support & DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT)) { - result = IDXGISwapChain3_SetColorSpace1(swapChain3, colorspace); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain3::SetColorSpace1"), result); - goto done; - } - } else if (colorspace != DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709) { - // Not the default, we're not going to be able to present in this colorspace - SDL_SetError("Unsupported output colorspace"); - result = DXGI_ERROR_UNSUPPORTED; - } - } - - SDL_SetPointerProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER, data->swapChain); - -done: - SAFE_RELEASE(swapChain3); - SAFE_RELEASE(coreWindow); - return result; -} - -static void D3D11_ReleaseMainRenderTargetView(SDL_Renderer *renderer) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - ID3D11DeviceContext_OMSetRenderTargets(data->d3dContext, 0, NULL, NULL); - SAFE_RELEASE(data->mainRenderTargetView); -} - -// Initialize all resources that change when the window's size changes. -static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - ID3D11Texture2D *backBuffer = NULL; - HRESULT result = S_OK; - int w, h; - - // Release the previous render target view - D3D11_ReleaseMainRenderTargetView(renderer); - - /* The width and height of the swap chain must be based on the display's - * non-rotated size. - */ - SDL_GetWindowSizeInPixels(renderer->window, &w, &h); - data->rotation = D3D11_GetCurrentRotation(); - // SDL_Log("%s: windowSize={%d,%d}, orientation=%d", __FUNCTION__, w, h, (int)data->rotation); - if (D3D11_IsDisplayRotated90Degrees(data->rotation)) { - int tmp = w; - w = h; - h = tmp; - } - - if (data->swapChain) { - // If the swap chain already exists, resize it. - result = IDXGISwapChain_ResizeBuffers(data->swapChain, - 0, - w, h, - DXGI_FORMAT_UNKNOWN, - 0); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::ResizeBuffers"), result); - goto done; - } - } else { - result = D3D11_CreateSwapChain(renderer, w, h); - if (FAILED(result) || !data->swapChain) { - goto done; - } - } - - // Set the proper rotation for the swap chain. - if (WIN_IsWindows8OrGreater()) { - if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) { - result = IDXGISwapChain1_SetRotation(data->swapChain, data->rotation); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain1::SetRotation"), result); - goto done; - } - } - } - - result = IDXGISwapChain_GetBuffer(data->swapChain, - 0, - &SDL_IID_ID3D11Texture2D, - (void **)&backBuffer); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::GetBuffer [back-buffer]"), result); - goto done; - } - - // Create a render target view of the swap chain back buffer. - result = ID3D11Device_CreateRenderTargetView(data->d3dDevice, - (ID3D11Resource *)backBuffer, - NULL, - &data->mainRenderTargetView); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device::CreateRenderTargetView"), result); - goto done; - } - - /* Set the swap chain target immediately, so that a target is always set - * even before we get to SetDrawState. Without this it's possible to hit - * null references in places like ReadPixels! - */ - ID3D11DeviceContext_OMSetRenderTargets(data->d3dContext, - 1, - &data->mainRenderTargetView, - NULL); - - data->viewportDirty = true; - -done: - SAFE_RELEASE(backBuffer); - return result; -} - -static bool D3D11_HandleDeviceLost(SDL_Renderer *renderer) -{ - bool recovered = false; - - D3D11_ReleaseAll(renderer); - - if (SUCCEEDED(D3D11_CreateDeviceResources(renderer)) && - SUCCEEDED(D3D11_CreateWindowSizeDependentResources(renderer))) { - recovered = true; - } else { - SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Renderer couldn't recover from device lost: %s", SDL_GetError()); - D3D11_ReleaseAll(renderer); - } - - // Let the application know that the device has been reset or lost - SDL_Event event; - SDL_zero(event); - event.type = recovered ? SDL_EVENT_RENDER_DEVICE_RESET : SDL_EVENT_RENDER_DEVICE_LOST; - event.render.windowID = SDL_GetWindowID(SDL_GetRenderWindow(renderer)); - SDL_PushEvent(&event); - - return recovered; -} - -// This method is called when the window's size changes. -static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer *renderer) -{ - return D3D11_CreateWindowSizeDependentResources(renderer); -} - -static void D3D11_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - - if (event->type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) { - data->pixelSizeChanged = true; - } -} - -static bool D3D11_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode) -{ - SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode); - SDL_BlendFactor srcAlphaFactor = SDL_GetBlendModeSrcAlphaFactor(blendMode); - SDL_BlendOperation colorOperation = SDL_GetBlendModeColorOperation(blendMode); - SDL_BlendFactor dstColorFactor = SDL_GetBlendModeDstColorFactor(blendMode); - SDL_BlendFactor dstAlphaFactor = SDL_GetBlendModeDstAlphaFactor(blendMode); - SDL_BlendOperation alphaOperation = SDL_GetBlendModeAlphaOperation(blendMode); - - if (!GetBlendFunc(srcColorFactor) || !GetBlendFunc(srcAlphaFactor) || - !GetBlendEquation(colorOperation) || - !GetBlendFunc(dstColorFactor) || !GetBlendFunc(dstAlphaFactor) || - !GetBlendEquation(alphaOperation)) { - return false; - } - return true; -} - -static bool GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D11Texture2D **texture) -{ - IUnknown *unknown = SDL_GetPointerProperty(props, name, NULL); - if (unknown) { - HRESULT result = IUnknown_QueryInterface(unknown, &SDL_IID_ID3D11Texture2D, (void **)texture); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(name, result); - } - } - return true; -} - -static bool D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - D3D11_TextureData *textureData; - HRESULT result; - DXGI_FORMAT textureFormat = SDLPixelFormatToDXGITextureFormat(texture->format, renderer->output_colorspace); - D3D11_TEXTURE2D_DESC textureDesc; - D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc; - - if (!rendererData->d3dDevice) { - return SDL_SetError("Device lost and couldn't be recovered"); - } - - if (textureFormat == DXGI_FORMAT_UNKNOWN) { - return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified", - __FUNCTION__, texture->format); - } - - textureData = (D3D11_TextureData *)SDL_calloc(1, sizeof(*textureData)); - if (!textureData) { - return false; - } - textureData->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR; - - texture->internal = textureData; - - SDL_zero(textureDesc); - textureDesc.Width = texture->w; - textureDesc.Height = texture->h; - textureDesc.MipLevels = 1; - textureDesc.ArraySize = 1; - textureDesc.Format = textureFormat; - textureDesc.SampleDesc.Count = 1; - textureDesc.SampleDesc.Quality = 0; - textureDesc.MiscFlags = 0; - - // NV12 textures must have even width and height - if (texture->format == SDL_PIXELFORMAT_NV12 || - texture->format == SDL_PIXELFORMAT_NV21 || - texture->format == SDL_PIXELFORMAT_P010) { - textureDesc.Width = (textureDesc.Width + 1) & ~1; - textureDesc.Height = (textureDesc.Height + 1) & ~1; - } - textureData->w = (int)textureDesc.Width; - textureData->h = (int)textureDesc.Height; - if (SDL_COLORSPACETRANSFER(texture->colorspace) == SDL_TRANSFER_CHARACTERISTICS_SRGB) { - textureData->shader = SHADER_RGB; - } else { - textureData->shader = SHADER_ADVANCED; - } - - if (texture->access == SDL_TEXTUREACCESS_STREAMING) { - textureDesc.Usage = D3D11_USAGE_DYNAMIC; - textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - } else { - textureDesc.Usage = D3D11_USAGE_DEFAULT; - textureDesc.CPUAccessFlags = 0; - } - - if (texture->access == SDL_TEXTUREACCESS_TARGET) { - textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; - } else { - textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - } - - if (!GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER, &textureData->mainTexture)) { - return false; - } - if (!textureData->mainTexture) { - result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &textureDesc, - NULL, - &textureData->mainTexture); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); - } - } - SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER, textureData->mainTexture); -#ifdef SDL_HAVE_YUV - if (texture->format == SDL_PIXELFORMAT_YV12 || - texture->format == SDL_PIXELFORMAT_IYUV) { - textureData->yuv = true; - - textureDesc.Width = (textureDesc.Width + 1) / 2; - textureDesc.Height = (textureDesc.Height + 1) / 2; - - if (!GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER, &textureData->mainTextureU)) { - return false; - } - if (!textureData->mainTextureU) { - result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &textureDesc, - NULL, - &textureData->mainTextureU); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); - } - } - SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER, textureData->mainTextureU); - - if (!GetTextureProperty(create_props, SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER, &textureData->mainTextureV)) { - return false; - } - if (!textureData->mainTextureV) { - result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &textureDesc, - NULL, - &textureData->mainTextureV); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result); - } - } - SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER, textureData->mainTextureV); - - textureData->YCbCr_matrix = SDL_GetYCbCRtoRGBConversionMatrix(texture->colorspace, texture->w, texture->h, 8); - if (!textureData->YCbCr_matrix) { - return SDL_SetError("Unsupported YUV colorspace"); - } - } - if (texture->format == SDL_PIXELFORMAT_NV12 || - texture->format == SDL_PIXELFORMAT_NV21 || - texture->format == SDL_PIXELFORMAT_P010) { - int bits_per_pixel; - - textureData->nv12 = true; - - switch (texture->format) { - case SDL_PIXELFORMAT_P010: - bits_per_pixel = 10; - break; - default: - bits_per_pixel = 8; - break; - } - textureData->YCbCr_matrix = SDL_GetYCbCRtoRGBConversionMatrix(texture->colorspace, texture->w, texture->h, bits_per_pixel); - if (!textureData->YCbCr_matrix) { - return SDL_SetError("Unsupported YUV colorspace"); - } - } -#endif // SDL_HAVE_YUV - SDL_zero(resourceViewDesc); - resourceViewDesc.Format = SDLPixelFormatToDXGIMainResourceViewFormat(texture->format, renderer->output_colorspace); - resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - resourceViewDesc.Texture2D.MostDetailedMip = 0; - resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels; - result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTexture, - &resourceViewDesc, - &textureData->mainTextureResourceView); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); - } -#ifdef SDL_HAVE_YUV - if (textureData->yuv) { - result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTextureU, - &resourceViewDesc, - &textureData->mainTextureResourceViewU); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); - } - result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTextureV, - &resourceViewDesc, - &textureData->mainTextureResourceViewV); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); - } - } - - if (textureData->nv12) { - D3D11_SHADER_RESOURCE_VIEW_DESC nvResourceViewDesc = resourceViewDesc; - - if (texture->format == SDL_PIXELFORMAT_NV12 || texture->format == SDL_PIXELFORMAT_NV21) { - nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM; - } else if (texture->format == SDL_PIXELFORMAT_P010) { - nvResourceViewDesc.Format = DXGI_FORMAT_R16G16_UNORM; - } - - result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTexture, - &nvResourceViewDesc, - &textureData->mainTextureResourceViewNV); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result); - } - } -#endif // SDL_HAVE_YUV - - if (texture->access & SDL_TEXTUREACCESS_TARGET) { - D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc; - SDL_zero(renderTargetViewDesc); - renderTargetViewDesc.Format = textureDesc.Format; - renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; - renderTargetViewDesc.Texture2D.MipSlice = 0; - - result = ID3D11Device_CreateRenderTargetView(rendererData->d3dDevice, - (ID3D11Resource *)textureData->mainTexture, - &renderTargetViewDesc, - &textureData->mainTextureRenderTargetView); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateRenderTargetView"), result); - } - } - - return true; -} - -static void D3D11_DestroyTexture(SDL_Renderer *renderer, - SDL_Texture *texture) -{ - D3D11_TextureData *data = (D3D11_TextureData *)texture->internal; - - if (!data) { - return; - } - - SAFE_RELEASE(data->mainTexture); - SAFE_RELEASE(data->mainTextureResourceView); - SAFE_RELEASE(data->mainTextureRenderTargetView); - SAFE_RELEASE(data->stagingTexture); -#ifdef SDL_HAVE_YUV - SAFE_RELEASE(data->mainTextureU); - SAFE_RELEASE(data->mainTextureResourceViewU); - SAFE_RELEASE(data->mainTextureV); - SAFE_RELEASE(data->mainTextureResourceViewV); - SAFE_RELEASE(data->mainTextureResourceViewNV); - SDL_free(data->pixels); -#endif - SDL_free(data); - texture->internal = NULL; -} - -static bool D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch) -{ - ID3D11Texture2D *stagingTexture; - const Uint8 *src; - Uint8 *dst; - int row; - UINT length; - HRESULT result; - D3D11_TEXTURE2D_DESC stagingTextureDesc; - D3D11_MAPPED_SUBRESOURCE textureMemory; - - // Create a 'staging' texture, which will be used to write to a portion of the main texture. - ID3D11Texture2D_GetDesc(texture, &stagingTextureDesc); - stagingTextureDesc.Width = w; - stagingTextureDesc.Height = h; - stagingTextureDesc.BindFlags = 0; - stagingTextureDesc.MiscFlags = 0; - stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - stagingTextureDesc.Usage = D3D11_USAGE_STAGING; - if (stagingTextureDesc.Format == DXGI_FORMAT_NV12 || - stagingTextureDesc.Format == DXGI_FORMAT_P010) { - stagingTextureDesc.Width = (stagingTextureDesc.Width + 1) & ~1; - stagingTextureDesc.Height = (stagingTextureDesc.Height + 1) & ~1; - } - result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &stagingTextureDesc, - NULL, - &stagingTexture); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); - } - - // Get a write-only pointer to data in the staging texture: - result = ID3D11DeviceContext_Map(rendererData->d3dContext, - (ID3D11Resource *)stagingTexture, - 0, - D3D11_MAP_WRITE, - 0, - &textureMemory); - if (FAILED(result)) { - SAFE_RELEASE(stagingTexture); - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); - } - - src = (const Uint8 *)pixels; - dst = (Uint8 *)textureMemory.pData; - length = w * bpp; - if (length == (UINT)pitch && length == textureMemory.RowPitch) { - SDL_memcpy(dst, src, (size_t)length * h); - } else { - if (length > (UINT)pitch) { - length = pitch; - } - if (length > textureMemory.RowPitch) { - length = textureMemory.RowPitch; - } - for (row = 0; row < h; ++row) { - SDL_memcpy(dst, src, length); - src += pitch; - dst += textureMemory.RowPitch; - } - } - - if (stagingTextureDesc.Format == DXGI_FORMAT_NV12 || - stagingTextureDesc.Format == DXGI_FORMAT_P010) { - // Copy the UV plane as well - h = (h + 1) / 2; - if (stagingTextureDesc.Format == DXGI_FORMAT_P010) { - length = (length + 3) & ~3; - pitch = (pitch + 3) & ~3; - } else { - length = (length + 1) & ~1; - pitch = (pitch + 1) & ~1; - } - dst = (Uint8 *)textureMemory.pData + stagingTextureDesc.Height * textureMemory.RowPitch; - for (row = 0; row < h; ++row) { - SDL_memcpy(dst, src, length); - src += pitch; - dst += textureMemory.RowPitch; - } - } - - // Commit the pixel buffer's changes back to the staging texture: - ID3D11DeviceContext_Unmap(rendererData->d3dContext, - (ID3D11Resource *)stagingTexture, - 0); - - // Copy the staging texture's contents back to the texture: - ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, - (ID3D11Resource *)texture, - 0, - x, - y, - 0, - (ID3D11Resource *)stagingTexture, - 0, - NULL); - - SAFE_RELEASE(stagingTexture); - - return true; -} - -#ifdef SDL_HAVE_YUV -static bool D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch); - -static bool D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch); -#endif - -static bool D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, const void *srcPixels, - int srcPitch) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - D3D11_TextureData *textureData = (D3D11_TextureData *)texture->internal; - - if (!textureData) { - return SDL_SetError("Texture is not currently available"); - } - -#ifdef SDL_HAVE_YUV - if (textureData->nv12) { - const Uint8 *Yplane = (const Uint8 *)srcPixels; - const Uint8 *UVplane = Yplane + rect->h * srcPitch; - - return D3D11_UpdateTextureNV(renderer, texture, rect, Yplane, srcPitch, UVplane, srcPitch); - - } else if (textureData->yuv) { - int Ypitch = srcPitch; - int UVpitch = ((Ypitch + 1) / 2); - const Uint8 *Yplane = (const Uint8 *)srcPixels; - const Uint8 *Uplane = Yplane + rect->h * Ypitch; - const Uint8 *Vplane = Uplane + ((rect->h + 1) / 2) * UVpitch; - - if (texture->format == SDL_PIXELFORMAT_YV12) { - return D3D11_UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Vplane, UVpitch, Uplane, UVpitch); - } else { - return D3D11_UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, UVpitch, Vplane, UVpitch); - } - } -#endif - - if (!D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch)) { - return false; - } - return true; -} - -#ifdef SDL_HAVE_YUV -static bool D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *Uplane, int Upitch, - const Uint8 *Vplane, int Vpitch) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - D3D11_TextureData *textureData = (D3D11_TextureData *)texture->internal; - - if (!textureData) { - return SDL_SetError("Texture is not currently available"); - } - - if (!D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch)) { - return false; - } - if (!D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Uplane, Upitch)) { - return false; - } - if (!D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Vplane, Vpitch)) { - return false; - } - return true; -} - -static bool D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, - const Uint8 *Yplane, int Ypitch, - const Uint8 *UVplane, int UVpitch) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - D3D11_TextureData *textureData = (D3D11_TextureData *)texture->internal; - ID3D11Texture2D *stagingTexture; - const Uint8 *src; - Uint8 *dst; - int w, h, row; - UINT length; - HRESULT result; - D3D11_TEXTURE2D_DESC stagingTextureDesc; - D3D11_MAPPED_SUBRESOURCE textureMemory; - - if (!textureData) { - return SDL_SetError("Texture is not currently available"); - } - - w = rect->w; - h = rect->h; - - // Create a 'staging' texture, which will be used to write to a portion of the main texture. - ID3D11Texture2D_GetDesc(textureData->mainTexture, &stagingTextureDesc); - stagingTextureDesc.Width = w; - stagingTextureDesc.Height = h; - stagingTextureDesc.BindFlags = 0; - stagingTextureDesc.MiscFlags = 0; - stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - stagingTextureDesc.Usage = D3D11_USAGE_STAGING; - if (stagingTextureDesc.Format == DXGI_FORMAT_NV12 || - stagingTextureDesc.Format == DXGI_FORMAT_P010) { - stagingTextureDesc.Width = (stagingTextureDesc.Width + 1) & ~1; - stagingTextureDesc.Height = (stagingTextureDesc.Height + 1) & ~1; - } - result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &stagingTextureDesc, - NULL, - &stagingTexture); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); - } - - // Get a write-only pointer to data in the staging texture: - result = ID3D11DeviceContext_Map(rendererData->d3dContext, - (ID3D11Resource *)stagingTexture, - 0, - D3D11_MAP_WRITE, - 0, - &textureMemory); - if (FAILED(result)) { - SAFE_RELEASE(stagingTexture); - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); - } - - src = Yplane; - dst = (Uint8 *)textureMemory.pData; - length = w; - if (length == (UINT)Ypitch && length == textureMemory.RowPitch) { - SDL_memcpy(dst, src, (size_t)length * h); - } else { - if (length > (UINT)Ypitch) { - length = Ypitch; - } - if (length > textureMemory.RowPitch) { - length = textureMemory.RowPitch; - } - for (row = 0; row < h; ++row) { - SDL_memcpy(dst, src, length); - src += Ypitch; - dst += textureMemory.RowPitch; - } - } - - src = UVplane; - length = w; - h = (h + 1) / 2; - if (stagingTextureDesc.Format == DXGI_FORMAT_P010) { - length = (length + 3) & ~3; - UVpitch = (UVpitch + 3) & ~3; - } else { - length = (length + 1) & ~1; - UVpitch = (UVpitch + 1) & ~1; - } - dst = (Uint8 *)textureMemory.pData + stagingTextureDesc.Height * textureMemory.RowPitch; - for (row = 0; row < h; ++row) { - SDL_memcpy(dst, src, length); - src += UVpitch; - dst += textureMemory.RowPitch; - } - - // Commit the pixel buffer's changes back to the staging texture: - ID3D11DeviceContext_Unmap(rendererData->d3dContext, - (ID3D11Resource *)stagingTexture, - 0); - - // Copy the staging texture's contents back to the texture: - ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, - (ID3D11Resource *)textureData->mainTexture, - 0, - rect->x, - rect->y, - 0, - (ID3D11Resource *)stagingTexture, - 0, - NULL); - - SAFE_RELEASE(stagingTexture); - - return true; -} -#endif - -static bool D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, - const SDL_Rect *rect, void **pixels, int *pitch) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - D3D11_TextureData *textureData = (D3D11_TextureData *)texture->internal; - HRESULT result = S_OK; - D3D11_TEXTURE2D_DESC stagingTextureDesc; - D3D11_MAPPED_SUBRESOURCE textureMemory; - - if (!textureData) { - return SDL_SetError("Texture is not currently available"); - } -#ifdef SDL_HAVE_YUV - if (textureData->yuv || textureData->nv12) { - // It's more efficient to upload directly... - if (!textureData->pixels) { - textureData->pitch = texture->w; - textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2); - if (!textureData->pixels) { - return false; - } - } - textureData->locked_rect = *rect; - *pixels = - (void *)(textureData->pixels + rect->y * textureData->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); - *pitch = textureData->pitch; - return true; - } -#endif - if (textureData->stagingTexture) { - return SDL_SetError("texture is already locked"); - } - - /* Create a 'staging' texture, which will be used to write to a portion - * of the main texture. This is necessary, as Direct3D 11.1 does not - * have the ability to write a CPU-bound pixel buffer to a rectangular - * subrect of a texture. Direct3D 11.1 can, however, write a pixel - * buffer to an entire texture, hence the use of a staging texture. - */ - ID3D11Texture2D_GetDesc(textureData->mainTexture, &stagingTextureDesc); - stagingTextureDesc.Width = rect->w; - stagingTextureDesc.Height = rect->h; - stagingTextureDesc.BindFlags = 0; - stagingTextureDesc.MiscFlags = 0; - stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - stagingTextureDesc.Usage = D3D11_USAGE_STAGING; - result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, - &stagingTextureDesc, - NULL, - &textureData->stagingTexture); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); - } - - // Get a write-only pointer to data in the staging texture: - result = ID3D11DeviceContext_Map(rendererData->d3dContext, - (ID3D11Resource *)textureData->stagingTexture, - 0, - D3D11_MAP_WRITE, - 0, - &textureMemory); - if (FAILED(result)) { - SAFE_RELEASE(textureData->stagingTexture); - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); - } - - /* Make note of where the staging texture will be written to - * (on a call to SDL_UnlockTexture): - */ - textureData->lockedTexturePositionX = rect->x; - textureData->lockedTexturePositionY = rect->y; - - /* Make sure the caller has information on the texture's pixel buffer, - * then return: - */ - *pixels = textureMemory.pData; - *pitch = textureMemory.RowPitch; - return true; -} - -static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - D3D11_TextureData *textureData = (D3D11_TextureData *)texture->internal; - - if (!textureData) { - return; - } -#ifdef SDL_HAVE_YUV - if (textureData->yuv || textureData->nv12) { - const SDL_Rect *rect = &textureData->locked_rect; - void *pixels = - (void *)(textureData->pixels + rect->y * textureData->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); - D3D11_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch); - return; - } -#endif - // Commit the pixel buffer's changes back to the staging texture: - ID3D11DeviceContext_Unmap(rendererData->d3dContext, - (ID3D11Resource *)textureData->stagingTexture, - 0); - - // Copy the staging texture's contents back to the main texture: - ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, - (ID3D11Resource *)textureData->mainTexture, - 0, - textureData->lockedTexturePositionX, - textureData->lockedTexturePositionY, - 0, - (ID3D11Resource *)textureData->stagingTexture, - 0, - NULL); - - SAFE_RELEASE(textureData->stagingTexture); -} - -static void D3D11_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) -{ - D3D11_TextureData *textureData = (D3D11_TextureData *)texture->internal; - - if (!textureData) { - return; - } - - textureData->scaleMode = (scaleMode == SDL_SCALEMODE_NEAREST) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR; -} - -static bool D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - D3D11_TextureData *textureData = NULL; - - if (!texture) { - rendererData->currentOffscreenRenderTargetView = NULL; - return true; - } - - textureData = (D3D11_TextureData *)texture->internal; - - if (!textureData->mainTextureRenderTargetView) { - return SDL_SetError("specified texture is not a render target"); - } - - rendererData->currentOffscreenRenderTargetView = textureData->mainTextureRenderTargetView; - - return true; -} - -static bool D3D11_QueueNoOp(SDL_Renderer *renderer, SDL_RenderCommand *cmd) -{ - return true; // nothing to do in this backend. -} - -static bool D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) -{ - D3D11_VertexPositionColor *verts = (D3D11_VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(D3D11_VertexPositionColor), 0, &cmd->data.draw.first); - int i; - SDL_FColor color = cmd->data.draw.color; - bool convert_color = SDL_RenderingLinearSpace(renderer); - - if (!verts) { - return false; - } - - cmd->data.draw.count = count; - - if (convert_color) { - SDL_ConvertToLinear(&color); - } - - for (i = 0; i < count; i++) { - verts->pos.x = points[i].x + 0.5f; - verts->pos.y = points[i].y + 0.5f; - verts->tex.x = 0.0f; - verts->tex.y = 0.0f; - verts->color = color; - verts++; - } - - return true; -} - -static bool D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, - const float *xy, int xy_stride, const SDL_FColor *color, int color_stride, const float *uv, int uv_stride, - int num_vertices, const void *indices, int num_indices, int size_indices, - float scale_x, float scale_y) -{ - int i; - int count = indices ? num_indices : num_vertices; - D3D11_VertexPositionColor *verts = (D3D11_VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(D3D11_VertexPositionColor), 0, &cmd->data.draw.first); - bool convert_color = SDL_RenderingLinearSpace(renderer); - D3D11_TextureData *textureData = texture ? (D3D11_TextureData *)texture->internal : NULL; - float u_scale = textureData ? (float)texture->w / textureData->w : 0.0f; - float v_scale = textureData ? (float)texture->h / textureData->h : 0.0f; - - if (!verts) { - return false; - } - - cmd->data.draw.count = count; - size_indices = indices ? size_indices : 0; - - for (i = 0; i < count; i++) { - int j; - float *xy_; - if (size_indices == 4) { - j = ((const Uint32 *)indices)[i]; - } else if (size_indices == 2) { - j = ((const Uint16 *)indices)[i]; - } else if (size_indices == 1) { - j = ((const Uint8 *)indices)[i]; - } else { - j = i; - } - - xy_ = (float *)((char *)xy + j * xy_stride); - - verts->pos.x = xy_[0] * scale_x; - verts->pos.y = xy_[1] * scale_y; - verts->color = *(SDL_FColor *)((char *)color + j * color_stride); - if (convert_color) { - SDL_ConvertToLinear(&verts->color); - } - - if (texture) { - float *uv_ = (float *)((char *)uv + j * uv_stride); - verts->tex.x = uv_[0] * u_scale; - verts->tex.y = uv_[1] * v_scale; - } else { - verts->tex.x = 0.0f; - verts->tex.y = 0.0f; - } - - verts += 1; - } - return true; -} - -static bool D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, - const void *vertexData, size_t dataSizeInBytes) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - HRESULT result = S_OK; - const int vbidx = rendererData->currentVertexBuffer; - const UINT stride = sizeof(D3D11_VertexPositionColor); - const UINT offset = 0; - - if (dataSizeInBytes == 0) { - return true; // nothing to do. - } - - if (rendererData->vertexBuffers[vbidx] && rendererData->vertexBufferSizes[vbidx] >= dataSizeInBytes) { - D3D11_MAPPED_SUBRESOURCE mappedResource; - result = ID3D11DeviceContext_Map(rendererData->d3dContext, - (ID3D11Resource *)rendererData->vertexBuffers[vbidx], - 0, - D3D11_MAP_WRITE_DISCARD, - 0, - &mappedResource); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [vertex buffer]"), result); - } - SDL_memcpy(mappedResource.pData, vertexData, dataSizeInBytes); - ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)rendererData->vertexBuffers[vbidx], 0); - } else { - D3D11_BUFFER_DESC vertexBufferDesc; - D3D11_SUBRESOURCE_DATA vertexBufferData; - - SAFE_RELEASE(rendererData->vertexBuffers[vbidx]); - - SDL_zero(vertexBufferDesc); - vertexBufferDesc.ByteWidth = (UINT)dataSizeInBytes; - vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; - vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - - SDL_zero(vertexBufferData); - vertexBufferData.pSysMem = vertexData; - vertexBufferData.SysMemPitch = 0; - vertexBufferData.SysMemSlicePitch = 0; - - result = ID3D11Device_CreateBuffer(rendererData->d3dDevice, - &vertexBufferDesc, - &vertexBufferData, - &rendererData->vertexBuffers[vbidx]); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateBuffer [vertex buffer]"), result); - } - - rendererData->vertexBufferSizes[vbidx] = dataSizeInBytes; - } - - ID3D11DeviceContext_IASetVertexBuffers(rendererData->d3dContext, - 0, - 1, - &rendererData->vertexBuffers[vbidx], - &stride, - &offset); - - rendererData->currentVertexBuffer++; - if (rendererData->currentVertexBuffer >= SDL_arraysize(rendererData->vertexBuffers)) { - rendererData->currentVertexBuffer = 0; - } - - return true; -} - -static bool D3D11_UpdateViewport(SDL_Renderer *renderer) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - const SDL_Rect *viewport = &data->currentViewport; - Float4X4 projection; - Float4X4 view; - SDL_FRect orientationAlignedViewport; - BOOL swapDimensions; - D3D11_VIEWPORT d3dviewport; - const int rotation = D3D11_GetRotationForCurrentRenderTarget(renderer); - - if (viewport->w == 0 || viewport->h == 0) { - /* If the viewport is empty, assume that it is because - * SDL_CreateRenderer is calling it, and will call it again later - * with a non-empty viewport. - */ - // SDL_Log("%s, no viewport was set!", __FUNCTION__); - return false; - } - - /* Make sure the SDL viewport gets rotated to that of the physical display's rotation. - * Keep in mind here that the Y-axis will be been inverted (from Direct3D's - * default coordinate system) so rotations will be done in the opposite - * direction of the DXGI_MODE_ROTATION enumeration. - */ - switch (rotation) { - case DXGI_MODE_ROTATION_IDENTITY: - projection = MatrixIdentity(); - break; - case DXGI_MODE_ROTATION_ROTATE270: - projection = MatrixRotationZ(SDL_PI_F * 0.5f); - break; - case DXGI_MODE_ROTATION_ROTATE180: - projection = MatrixRotationZ(SDL_PI_F); - break; - case DXGI_MODE_ROTATION_ROTATE90: - projection = MatrixRotationZ(-SDL_PI_F * 0.5f); - break; - default: - return SDL_SetError("An unknown DisplayOrientation is being used"); - } - - // Update the view matrix - SDL_zero(view); - view.m[0][0] = 2.0f / viewport->w; - view.m[1][1] = -2.0f / viewport->h; - view.m[2][2] = 1.0f; - view.m[3][0] = -1.0f; - view.m[3][1] = 1.0f; - view.m[3][3] = 1.0f; - - /* Combine the projection + view matrix together now, as both only get - * set here (as of this writing, on Dec 26, 2013). When done, store it - * for eventual transfer to the GPU. - */ - data->vertexShaderConstantsData.projectionAndView = MatrixMultiply( - view, - projection); - - /* Update the Direct3D viewport, which seems to be aligned to the - * swap buffer's coordinate space, which is always in either - * a landscape mode, for all Windows 8/RT devices, or a portrait mode, - * for Windows Phone devices. - */ - swapDimensions = D3D11_IsDisplayRotated90Degrees(rotation); - if (swapDimensions) { - orientationAlignedViewport.x = (float)viewport->y; - orientationAlignedViewport.y = (float)viewport->x; - orientationAlignedViewport.w = (float)viewport->h; - orientationAlignedViewport.h = (float)viewport->w; - } else { - orientationAlignedViewport.x = (float)viewport->x; - orientationAlignedViewport.y = (float)viewport->y; - orientationAlignedViewport.w = (float)viewport->w; - orientationAlignedViewport.h = (float)viewport->h; - } - - d3dviewport.TopLeftX = orientationAlignedViewport.x; - d3dviewport.TopLeftY = orientationAlignedViewport.y; - d3dviewport.Width = orientationAlignedViewport.w; - d3dviewport.Height = orientationAlignedViewport.h; - d3dviewport.MinDepth = 0.0f; - d3dviewport.MaxDepth = 1.0f; - // SDL_Log("%s: D3D viewport = {%f,%f,%f,%f}", __FUNCTION__, d3dviewport.TopLeftX, d3dviewport.TopLeftY, d3dviewport.Width, d3dviewport.Height); - ID3D11DeviceContext_RSSetViewports(data->d3dContext, 1, &d3dviewport); - - data->viewportDirty = false; - - return true; -} - -static ID3D11RenderTargetView *D3D11_GetCurrentRenderTargetView(SDL_Renderer *renderer) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - if (data->currentOffscreenRenderTargetView) { - return data->currentOffscreenRenderTargetView; - } else { - return data->mainRenderTargetView; - } -} - -static void D3D11_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_Texture *texture, D3D11_PixelShaderConstants *constants) -{ - float output_headroom; - - SDL_zerop(constants); - - constants->scRGB_output = (float)SDL_RenderingLinearSpace(renderer); - constants->color_scale = cmd->data.draw.color_scale; - - if (texture) { - D3D11_TextureData *textureData = (D3D11_TextureData *)texture->internal; - - switch (texture->format) { - case SDL_PIXELFORMAT_YV12: - case SDL_PIXELFORMAT_IYUV: - constants->texture_type = TEXTURETYPE_YUV; - constants->input_type = INPUTTYPE_SRGB; - break; - case SDL_PIXELFORMAT_NV12: - constants->texture_type = TEXTURETYPE_NV12; - constants->input_type = INPUTTYPE_SRGB; - break; - case SDL_PIXELFORMAT_NV21: - constants->texture_type = TEXTURETYPE_NV21; - constants->input_type = INPUTTYPE_SRGB; - break; - case SDL_PIXELFORMAT_P010: - constants->texture_type = TEXTURETYPE_NV12; - constants->input_type = INPUTTYPE_HDR10; - break; - default: - constants->texture_type = TEXTURETYPE_RGB; - if (texture->colorspace == SDL_COLORSPACE_SRGB_LINEAR) { - constants->input_type = INPUTTYPE_SCRGB; - } else if (texture->colorspace == SDL_COLORSPACE_HDR10) { - constants->input_type = INPUTTYPE_HDR10; - } else { - // The sampler will convert from sRGB to linear on load if working in linear colorspace - constants->input_type = INPUTTYPE_UNSPECIFIED; - } - break; - } - - constants->sdr_white_point = texture->SDR_white_point; - - if (renderer->target) { - output_headroom = renderer->target->HDR_headroom; - } else { - output_headroom = renderer->HDR_headroom; - } - - if (texture->HDR_headroom > output_headroom) { - constants->tonemap_method = TONEMAP_CHROME; - constants->tonemap_factor1 = (output_headroom / (texture->HDR_headroom * texture->HDR_headroom)); - constants->tonemap_factor2 = (1.0f / output_headroom); - } - - if (textureData->YCbCr_matrix) { - SDL_memcpy(constants->YCbCr_matrix, textureData->YCbCr_matrix, sizeof(constants->YCbCr_matrix)); - } - } -} - -static bool D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, - D3D11_Shader shader, const D3D11_PixelShaderConstants *shader_constants, - const int numShaderResources, ID3D11ShaderResourceView **shaderResources, - ID3D11SamplerState *sampler, const Float4X4 *matrix) - -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - const Float4X4 *newmatrix = matrix ? matrix : &rendererData->identity; - ID3D11RasterizerState *rasterizerState; - ID3D11RenderTargetView *renderTargetView = D3D11_GetCurrentRenderTargetView(renderer); - ID3D11ShaderResourceView *shaderResource; - const SDL_BlendMode blendMode = cmd->data.draw.blend; - ID3D11BlendState *blendState = NULL; - bool updateSubresource = false; - D3D11_PixelShaderState *shader_state = &rendererData->currentShaderState[shader]; - D3D11_PixelShaderConstants solid_constants; - - if (numShaderResources > 0) { - shaderResource = shaderResources[0]; - } else { - shaderResource = NULL; - } - - // Make sure the render target isn't bound to a shader - if (shaderResource != rendererData->currentShaderResource) { - ID3D11ShaderResourceView *pNullResource = NULL; - ID3D11DeviceContext_PSSetShaderResources(rendererData->d3dContext, 0, 1, &pNullResource); - rendererData->currentShaderResource = NULL; - } - - if (renderTargetView != rendererData->currentRenderTargetView) { - ID3D11DeviceContext_OMSetRenderTargets(rendererData->d3dContext, - 1, - &renderTargetView, - NULL); - rendererData->currentRenderTargetView = renderTargetView; - } - - if (rendererData->viewportDirty) { - if (D3D11_UpdateViewport(renderer)) { - // vertexShaderConstantsData.projectionAndView has changed - updateSubresource = true; - } - } - - if (rendererData->cliprectDirty) { - if (!rendererData->currentCliprectEnabled) { - ID3D11DeviceContext_RSSetScissorRects(rendererData->d3dContext, 0, NULL); - } else { - D3D11_RECT scissorRect; - if (!D3D11_GetViewportAlignedD3DRect(renderer, &rendererData->currentCliprect, &scissorRect, TRUE)) { - // D3D11_GetViewportAlignedD3DRect will have set the SDL error - return false; - } - ID3D11DeviceContext_RSSetScissorRects(rendererData->d3dContext, 1, &scissorRect); - } - rendererData->cliprectDirty = false; - } - - if (!rendererData->currentCliprectEnabled) { - rasterizerState = rendererData->mainRasterizer; - } else { - rasterizerState = rendererData->clippedRasterizer; - } - if (rasterizerState != rendererData->currentRasterizerState) { - ID3D11DeviceContext_RSSetState(rendererData->d3dContext, rasterizerState); - rendererData->currentRasterizerState = rasterizerState; - } - - if (blendMode != SDL_BLENDMODE_NONE) { - int i; - for (i = 0; i < rendererData->blendModesCount; ++i) { - if (blendMode == rendererData->blendModes[i].blendMode) { - blendState = rendererData->blendModes[i].blendState; - break; - } - } - if (!blendState) { - blendState = D3D11_CreateBlendState(renderer, blendMode); - if (!blendState) { - return false; - } - } - } - if (blendState != rendererData->currentBlendState) { - ID3D11DeviceContext_OMSetBlendState(rendererData->d3dContext, blendState, 0, 0xFFFFFFFF); - rendererData->currentBlendState = blendState; - } - - if (!shader_constants) { - D3D11_SetupShaderConstants(renderer, cmd, NULL, &solid_constants); - shader_constants = &solid_constants; - } - - if (!shader_state->constants || - SDL_memcmp(shader_constants, &shader_state->shader_constants, sizeof(*shader_constants)) != 0) { - SAFE_RELEASE(shader_state->constants); - - D3D11_BUFFER_DESC desc; - SDL_zero(desc); - desc.Usage = D3D11_USAGE_DEFAULT; - desc.ByteWidth = sizeof(*shader_constants); - desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - - D3D11_SUBRESOURCE_DATA data; - SDL_zero(data); - data.pSysMem = shader_constants; - - HRESULT result = ID3D11Device_CreateBuffer(rendererData->d3dDevice, &desc, &data, &shader_state->constants); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device::CreateBuffer [create shader constants]"), result); - return false; - } - SDL_memcpy(&shader_state->shader_constants, shader_constants, sizeof(*shader_constants)); - - // Force the shader parameters to be re-set - rendererData->currentShader = SHADER_NONE; - } - if (shader != rendererData->currentShader) { - if (!rendererData->pixelShaders[shader]) { - if (!D3D11_CreatePixelShader(rendererData->d3dDevice, shader, &rendererData->pixelShaders[shader])) { - return false; - } - } - ID3D11DeviceContext_PSSetShader(rendererData->d3dContext, rendererData->pixelShaders[shader], NULL, 0); - if (shader_state->constants) { - ID3D11DeviceContext_PSSetConstantBuffers(rendererData->d3dContext, 0, 1, &shader_state->constants); - } - rendererData->currentShader = shader; - } - if (shaderResource != rendererData->currentShaderResource) { - ID3D11DeviceContext_PSSetShaderResources(rendererData->d3dContext, 0, numShaderResources, shaderResources); - rendererData->currentShaderResource = shaderResource; - } - if (sampler != rendererData->currentSampler) { - ID3D11DeviceContext_PSSetSamplers(rendererData->d3dContext, 0, 1, &sampler); - rendererData->currentSampler = sampler; - } - - if (updateSubresource == true || SDL_memcmp(&rendererData->vertexShaderConstantsData.model, newmatrix, sizeof(*newmatrix)) != 0) { - SDL_copyp(&rendererData->vertexShaderConstantsData.model, newmatrix); - ID3D11DeviceContext_UpdateSubresource(rendererData->d3dContext, - (ID3D11Resource *)rendererData->vertexShaderConstants, - 0, - NULL, - &rendererData->vertexShaderConstantsData, - 0, - 0); - } - - return true; -} - -static bool D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const Float4X4 *matrix) -{ - SDL_Texture *texture = cmd->data.draw.texture; - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - D3D11_TextureData *textureData = (D3D11_TextureData *)texture->internal; - ID3D11SamplerState *textureSampler; - D3D11_PixelShaderConstants constants; - - if (!textureData) { - return SDL_SetError("Texture is not currently available"); - } - - D3D11_SetupShaderConstants(renderer, cmd, texture, &constants); - - switch (textureData->scaleMode) { - case D3D11_FILTER_MIN_MAG_MIP_POINT: - switch (cmd->data.draw.texture_address_mode) { - case SDL_TEXTURE_ADDRESS_CLAMP: - textureSampler = rendererData->samplers[D3D11_SAMPLER_NEAREST_CLAMP]; - break; - case SDL_TEXTURE_ADDRESS_WRAP: - textureSampler = rendererData->samplers[D3D11_SAMPLER_NEAREST_WRAP]; - break; - default: - return SDL_SetError("Unknown texture address mode: %d", cmd->data.draw.texture_address_mode); - } - break; - case D3D11_FILTER_MIN_MAG_MIP_LINEAR: - switch (cmd->data.draw.texture_address_mode) { - case SDL_TEXTURE_ADDRESS_CLAMP: - textureSampler = rendererData->samplers[D3D11_SAMPLER_LINEAR_CLAMP]; - break; - case SDL_TEXTURE_ADDRESS_WRAP: - textureSampler = rendererData->samplers[D3D11_SAMPLER_LINEAR_WRAP]; - break; - default: - return SDL_SetError("Unknown texture address mode: %d", cmd->data.draw.texture_address_mode); - } - break; - default: - return SDL_SetError("Unknown scale mode: %d", textureData->scaleMode); - } -#ifdef SDL_HAVE_YUV - if (textureData->yuv) { - ID3D11ShaderResourceView *shaderResources[3]; - - shaderResources[0] = textureData->mainTextureResourceView; - shaderResources[1] = textureData->mainTextureResourceViewU; - shaderResources[2] = textureData->mainTextureResourceViewV; - - return D3D11_SetDrawState(renderer, cmd, textureData->shader, &constants, - SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix); - - } else if (textureData->nv12) { - ID3D11ShaderResourceView *shaderResources[2]; - - shaderResources[0] = textureData->mainTextureResourceView; - shaderResources[1] = textureData->mainTextureResourceViewNV; - - return D3D11_SetDrawState(renderer, cmd, textureData->shader, &constants, - SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix); - } -#endif // SDL_HAVE_YUV - return D3D11_SetDrawState(renderer, cmd, textureData->shader, &constants, - 1, &textureData->mainTextureResourceView, textureSampler, matrix); -} - -static void D3D11_DrawPrimitives(SDL_Renderer *renderer, D3D11_PRIMITIVE_TOPOLOGY primitiveTopology, const size_t vertexStart, const size_t vertexCount) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - ID3D11DeviceContext_IASetPrimitiveTopology(rendererData->d3dContext, primitiveTopology); - ID3D11DeviceContext_Draw(rendererData->d3dContext, (UINT)vertexCount, (UINT)vertexStart); -} - -static void D3D11_InvalidateCachedState(SDL_Renderer *renderer) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - data->currentRenderTargetView = NULL; - data->currentRasterizerState = NULL; - data->currentBlendState = NULL; - data->currentShader = SHADER_NONE; - data->currentShaderResource = NULL; - data->currentSampler = NULL; - data->cliprectDirty = true; - data->viewportDirty = true; -} - -static bool D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) -{ - D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->internal; - const int viewportRotation = D3D11_GetRotationForCurrentRenderTarget(renderer); - - if (!rendererData->d3dDevice) { - return SDL_SetError("Device lost and couldn't be recovered"); - } - - if (rendererData->pixelSizeChanged) { - D3D11_UpdateForWindowSizeChange(renderer); - rendererData->pixelSizeChanged = false; - } - - if (rendererData->currentViewportRotation != viewportRotation) { - rendererData->currentViewportRotation = viewportRotation; - rendererData->viewportDirty = true; - } - - if (!D3D11_UpdateVertexBuffer(renderer, vertices, vertsize)) { - return false; - } - - while (cmd) { - switch (cmd->command) { - case SDL_RENDERCMD_SETDRAWCOLOR: - { - break; // this isn't currently used in this render backend. - } - - case SDL_RENDERCMD_SETVIEWPORT: - { - SDL_Rect *viewport = &rendererData->currentViewport; - if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { - SDL_copyp(viewport, &cmd->data.viewport.rect); - rendererData->viewportDirty = true; - rendererData->cliprectDirty = true; - } - break; - } - - case SDL_RENDERCMD_SETCLIPRECT: - { - const SDL_Rect *rect = &cmd->data.cliprect.rect; - if (rendererData->currentCliprectEnabled != cmd->data.cliprect.enabled) { - rendererData->currentCliprectEnabled = cmd->data.cliprect.enabled; - rendererData->cliprectDirty = true; - } - if (SDL_memcmp(&rendererData->currentCliprect, rect, sizeof(*rect)) != 0) { - SDL_copyp(&rendererData->currentCliprect, rect); - rendererData->cliprectDirty = true; - } - break; - } - - case SDL_RENDERCMD_CLEAR: - { - bool convert_color = SDL_RenderingLinearSpace(renderer); - SDL_FColor color = cmd->data.color.color; - if (convert_color) { - SDL_ConvertToLinear(&color); - } - color.r *= cmd->data.color.color_scale; - color.g *= cmd->data.color.color_scale; - color.b *= cmd->data.color.color_scale; - ID3D11DeviceContext_ClearRenderTargetView(rendererData->d3dContext, D3D11_GetCurrentRenderTargetView(renderer), &color.r); - break; - } - - case SDL_RENDERCMD_DRAW_POINTS: - { - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const size_t start = first / sizeof(D3D11_VertexPositionColor); - D3D11_SetDrawState(renderer, cmd, SHADER_SOLID, NULL, 0, NULL, NULL, NULL); - D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, start, count); - break; - } - - case SDL_RENDERCMD_DRAW_LINES: - { - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const size_t start = first / sizeof(D3D11_VertexPositionColor); - const D3D11_VertexPositionColor *verts = (D3D11_VertexPositionColor *)(((Uint8 *)vertices) + first); - D3D11_SetDrawState(renderer, cmd, SHADER_SOLID, NULL, 0, NULL, NULL, NULL); - D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, start, count); - if (verts[0].pos.x != verts[count - 1].pos.x || verts[0].pos.y != verts[count - 1].pos.y) { - D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, start + (count - 1), 1); - } - break; - } - - case SDL_RENDERCMD_FILL_RECTS: // unused - break; - - case SDL_RENDERCMD_COPY: // unused - break; - - case SDL_RENDERCMD_COPY_EX: // unused - break; - - case SDL_RENDERCMD_GEOMETRY: - { - SDL_Texture *texture = cmd->data.draw.texture; - const size_t count = cmd->data.draw.count; - const size_t first = cmd->data.draw.first; - const size_t start = first / sizeof(D3D11_VertexPositionColor); - - if (texture) { - D3D11_SetCopyState(renderer, cmd, NULL); - } else { - D3D11_SetDrawState(renderer, cmd, SHADER_SOLID, NULL, 0, NULL, NULL, NULL); - } - - D3D11_DrawPrimitives(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, start, count); - break; - } - - case SDL_RENDERCMD_NO_OP: - break; - } - - cmd = cmd->next; - } - - return true; -} - -static SDL_Surface *D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - ID3D11RenderTargetView *renderTargetView = NULL; - ID3D11Texture2D *backBuffer = NULL; - ID3D11Texture2D *stagingTexture = NULL; - HRESULT result; - D3D11_TEXTURE2D_DESC stagingTextureDesc; - D3D11_RECT srcRect = { 0, 0, 0, 0 }; - D3D11_BOX srcBox; - D3D11_MAPPED_SUBRESOURCE textureMemory; - SDL_Surface *output = NULL; - - renderTargetView = D3D11_GetCurrentRenderTargetView(renderer); - if (!renderTargetView) { - SDL_SetError("%s, ID3D11DeviceContext::OMGetRenderTargets failed", __FUNCTION__); - goto done; - } - - ID3D11View_GetResource(renderTargetView, (ID3D11Resource **)&backBuffer); - if (!backBuffer) { - SDL_SetError("%s, ID3D11View::GetResource failed", __FUNCTION__); - goto done; - } - - // Create a staging texture to copy the screen's data to: - ID3D11Texture2D_GetDesc(backBuffer, &stagingTextureDesc); - stagingTextureDesc.Width = rect->w; - stagingTextureDesc.Height = rect->h; - stagingTextureDesc.BindFlags = 0; - stagingTextureDesc.MiscFlags = 0; - stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - stagingTextureDesc.Usage = D3D11_USAGE_STAGING; - result = ID3D11Device_CreateTexture2D(data->d3dDevice, - &stagingTextureDesc, - NULL, - &stagingTexture); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D [create staging texture]"), result); - goto done; - } - - // Copy the desired portion of the back buffer to the staging texture: - if (!D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect, FALSE)) { - // D3D11_GetViewportAlignedD3DRect will have set the SDL error - goto done; - } - - srcBox.left = srcRect.left; - srcBox.right = srcRect.right; - srcBox.top = srcRect.top; - srcBox.bottom = srcRect.bottom; - srcBox.front = 0; - srcBox.back = 1; - ID3D11DeviceContext_CopySubresourceRegion(data->d3dContext, - (ID3D11Resource *)stagingTexture, - 0, - 0, 0, 0, - (ID3D11Resource *)backBuffer, - 0, - &srcBox); - - // Map the staging texture's data to CPU-accessible memory: - result = ID3D11DeviceContext_Map(data->d3dContext, - (ID3D11Resource *)stagingTexture, - 0, - D3D11_MAP_READ, - 0, - &textureMemory); - if (FAILED(result)) { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11DeviceContext1::Map [map staging texture]"), result); - goto done; - } - - output = SDL_DuplicatePixels( - rect->w, rect->h, - D3D11_DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format), - renderer->target ? renderer->target->colorspace : renderer->output_colorspace, - textureMemory.pData, - textureMemory.RowPitch); - - // Unmap the texture: - ID3D11DeviceContext_Unmap(data->d3dContext, - (ID3D11Resource *)stagingTexture, - 0); - -done: - SAFE_RELEASE(backBuffer); - SAFE_RELEASE(stagingTexture); - return output; -} - -static bool D3D11_RenderPresent(SDL_Renderer *renderer) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - HRESULT result; - DXGI_PRESENT_PARAMETERS parameters; - - if (!data->d3dDevice) { - return SDL_SetError("Device lost and couldn't be recovered"); - } - - SDL_zero(parameters); - - /* The application may optionally specify "dirty" or "scroll" - * rects to improve efficiency in certain scenarios. - */ - result = IDXGISwapChain1_Present1(data->swapChain, data->syncInterval, data->presentFlags, ¶meters); - - /* Discard the contents of the render target. - * This is a valid operation only when the existing contents will be entirely - * overwritten. If dirty or scroll rects are used, this call should be removed. - */ - ID3D11DeviceContext1_DiscardView(data->d3dContext, (ID3D11View *)data->mainRenderTargetView); - - // When the present flips, it unbinds the current view, so bind it again on the next draw call - data->currentRenderTargetView = NULL; - - if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) { - /* If the device was removed either by a disconnect or a driver upgrade, we - * must recreate all device resources. - */ - if (result == DXGI_ERROR_DEVICE_REMOVED) { - if (D3D11_HandleDeviceLost(renderer)) { - SDL_SetError("Present failed, device lost"); - } else { - // Recovering from device lost failed, error is already set - } - } else if (result == DXGI_ERROR_INVALID_CALL) { - // We probably went through a fullscreen <-> windowed transition - D3D11_CreateWindowSizeDependentResources(renderer); - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result); - } else { - WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("IDXGISwapChain::Present"), result); - } - return false; - } - return true; -} - -static bool D3D11_SetVSync(SDL_Renderer *renderer, const int vsync) -{ - D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal; - - if (vsync < 0) { - return SDL_Unsupported(); - } - - if (vsync > 0) { - data->syncInterval = vsync; - data->presentFlags = 0; - } else { - data->syncInterval = 0; - data->presentFlags = DXGI_PRESENT_DO_NOT_WAIT; - } - return true; -} - -static bool D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_PropertiesID create_props) -{ - D3D11_RenderData *data; - - HWND hwnd = (HWND)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL); - if (!hwnd) { - return SDL_SetError("Couldn't get window handle"); - } - - SDL_SetupRendererColorspace(renderer, create_props); - - if (renderer->output_colorspace != SDL_COLORSPACE_SRGB && - renderer->output_colorspace != SDL_COLORSPACE_SRGB_LINEAR - /*&& renderer->output_colorspace != SDL_COLORSPACE_HDR10*/) { - return SDL_SetError("Unsupported output colorspace"); - } - - data = (D3D11_RenderData *)SDL_calloc(1, sizeof(*data)); - if (!data) { - return false; - } - - data->identity = MatrixIdentity(); - - renderer->WindowEvent = D3D11_WindowEvent; - renderer->SupportsBlendMode = D3D11_SupportsBlendMode; - renderer->CreateTexture = D3D11_CreateTexture; - renderer->UpdateTexture = D3D11_UpdateTexture; -#ifdef SDL_HAVE_YUV - renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV; - renderer->UpdateTextureNV = D3D11_UpdateTextureNV; -#endif - renderer->LockTexture = D3D11_LockTexture; - renderer->UnlockTexture = D3D11_UnlockTexture; - renderer->SetTextureScaleMode = D3D11_SetTextureScaleMode; - renderer->SetRenderTarget = D3D11_SetRenderTarget; - renderer->QueueSetViewport = D3D11_QueueNoOp; - renderer->QueueSetDrawColor = D3D11_QueueNoOp; - renderer->QueueDrawPoints = D3D11_QueueDrawPoints; - renderer->QueueDrawLines = D3D11_QueueDrawPoints; // lines and points queue vertices the same way. - renderer->QueueGeometry = D3D11_QueueGeometry; - renderer->InvalidateCachedState = D3D11_InvalidateCachedState; - renderer->RunCommandQueue = D3D11_RunCommandQueue; - renderer->RenderReadPixels = D3D11_RenderReadPixels; - renderer->RenderPresent = D3D11_RenderPresent; - renderer->DestroyTexture = D3D11_DestroyTexture; - renderer->DestroyRenderer = D3D11_DestroyRenderer; - renderer->SetVSync = D3D11_SetVSync; - renderer->internal = data; - D3D11_InvalidateCachedState(renderer); - - renderer->name = D3D11_RenderDriver.name; - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_ARGB8888); - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_ABGR8888); - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_XRGB8888); - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_ABGR2101010); - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_RGBA64_FLOAT); - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_YV12); - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_IYUV); - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV12); - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_NV21); - SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_P010); - - data->syncInterval = 0; - data->presentFlags = DXGI_PRESENT_DO_NOT_WAIT; - - /* HACK: make sure the SDL_Renderer references the SDL_Window data now, in - * order to give init functions access to the underlying window handle: - */ - renderer->window = window; - - // Initialize Direct3D resources - if (FAILED(D3D11_CreateDeviceResources(renderer))) { - return false; - } - if (FAILED(D3D11_CreateWindowSizeDependentResources(renderer))) { - return false; - } - - return true; -} - -SDL_RenderDriver D3D11_RenderDriver = { - D3D11_CreateRenderer, "direct3d11" -}; - -#endif // SDL_VIDEO_RENDER_D3D11 diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/SDL_shaders_d3d11.c b/contrib/SDL-3.2.8/src/render/direct3d11/SDL_shaders_d3d11.c deleted file mode 100644 index 18965e2..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/SDL_shaders_d3d11.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2025 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#ifdef SDL_VIDEO_RENDER_D3D11 - -#define COBJMACROS -#include "../../core/windows/SDL_windows.h" -#include - -#include "SDL_shaders_d3d11.h" - -#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str - -#if SDL_WINAPI_FAMILY_PHONE -#error Need to build shaders with level_9_3 -#endif - -// The shaders here were compiled with compile_shaders.bat - -#define g_main D3D11_PixelShader_Colors -#include "D3D11_PixelShader_Colors.h" -#undef g_main - -#define g_main D3D11_PixelShader_Textures -#include "D3D11_PixelShader_Textures.h" -#undef g_main - -#define g_main D3D11_PixelShader_Advanced -#include "D3D11_PixelShader_Advanced.h" -#undef g_main - -#define g_main D3D11_VertexShader -#include "D3D11_VertexShader.h" -#undef g_main - - -static struct -{ - const void *shader_data; - SIZE_T shader_size; -} D3D11_shaders[] = { - { NULL, 0 }, - { D3D11_PixelShader_Colors, sizeof(D3D11_PixelShader_Colors) }, - { D3D11_PixelShader_Textures, sizeof(D3D11_PixelShader_Textures) }, - { D3D11_PixelShader_Advanced, sizeof(D3D11_PixelShader_Advanced) }, -}; -SDL_COMPILE_TIME_ASSERT(D3D11_shaders, SDL_arraysize(D3D11_shaders) == NUM_SHADERS); - -bool D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout) -{ - // Declare how the input layout for SDL's vertex shader will be setup: - const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = { - { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - HRESULT result; - - // Load in SDL's one and only vertex shader: - result = ID3D11Device_CreateVertexShader(d3dDevice, - D3D11_VertexShader, - sizeof(D3D11_VertexShader), - NULL, - vertexShader); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result); - } - - // Create an input layout for SDL's vertex shader: - result = ID3D11Device_CreateInputLayout(d3dDevice, - vertexDesc, - ARRAYSIZE(vertexDesc), - D3D11_VertexShader, - sizeof(D3D11_VertexShader), - inputLayout); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result); - } - return true; -} - -bool D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader) -{ - HRESULT result; - - result = ID3D11Device_CreatePixelShader(d3dDevice, - D3D11_shaders[shader].shader_data, - D3D11_shaders[shader].shader_size, - NULL, - pixelShader); - if (FAILED(result)) { - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader"), result); - } - return true; -} - -#endif // SDL_VIDEO_RENDER_D3D11 diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/SDL_shaders_d3d11.h b/contrib/SDL-3.2.8/src/render/direct3d11/SDL_shaders_d3d11.h deleted file mode 100644 index 2279fb0..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/SDL_shaders_d3d11.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2025 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -// D3D11 shader implementation - -typedef enum -{ - SHADER_NONE, - SHADER_SOLID, - SHADER_RGB, - SHADER_ADVANCED, - NUM_SHADERS -} D3D11_Shader; - -extern bool D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout); -extern bool D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader); diff --git a/contrib/SDL-3.2.8/src/render/direct3d11/compile_shaders.bat b/contrib/SDL-3.2.8/src/render/direct3d11/compile_shaders.bat deleted file mode 100644 index 51d2a34..0000000 --- a/contrib/SDL-3.2.8/src/render/direct3d11/compile_shaders.bat +++ /dev/null @@ -1,4 +0,0 @@ -fxc /T ps_4_0_level_9_1 /Fh D3D11_PixelShader_Colors.h D3D11_PixelShader_Colors.hlsl -fxc /T ps_4_0_level_9_1 /Fh D3D11_PixelShader_Textures.h D3D11_PixelShader_Textures.hlsl -fxc /T ps_5_0 /Fh D3D11_PixelShader_Advanced.h D3D11_PixelShader_Advanced.hlsl -fxc /T vs_4_0_level_9_1 /Fh D3D11_VertexShader.h D3D11_VertexShader.hlsl -- cgit v1.2.3