From 54c2ba6afd776d0d0c8f2bc438ad34d49a9cd87c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 21 Feb 2024 09:03:03 -0800 Subject: [PATCH] Added the Chrome HDR tonemap operator Also added support for the SDL_PIXELFORMAT_XBGR2101010 pixel format to the D3D12, D3D11, and Metal renderers. --- include/SDL3/SDL_surface.h | 4 +- .../direct3d11/D3D11_PixelShader_Advanced.h | 1060 ++++ .../D3D11_PixelShader_Advanced.hlsl | 7 + .../direct3d11/D3D11_PixelShader_Colors.h | 124 +- .../direct3d11/D3D11_PixelShader_Common.incl | 175 +- .../direct3d11/D3D11_PixelShader_HDR10.h | 507 -- .../direct3d11/D3D11_PixelShader_HDR10.hlsl | 45 - .../direct3d11/D3D11_PixelShader_NV12.h | 545 -- .../direct3d11/D3D11_PixelShader_NV12.hlsl | 20 - .../direct3d11/D3D11_PixelShader_NV21.h | 548 -- .../direct3d11/D3D11_PixelShader_NV21.hlsl | 20 - .../direct3d11/D3D11_PixelShader_Textures.h | 130 +- src/render/direct3d11/D3D11_PixelShader_YUV.h | 580 -- .../direct3d11/D3D11_PixelShader_YUV.hlsl | 22 - src/render/direct3d11/SDL_render_d3d11.c | 202 +- src/render/direct3d11/SDL_shaders_d3d11.c | 23 +- src/render/direct3d11/SDL_shaders_d3d11.h | 7 +- src/render/direct3d11/compile_shaders.bat | 5 +- .../direct3d12/D3D12_PixelShader_Advanced.h | 1387 +++++ ...1.hlsl => D3D12_PixelShader_Advanced.hlsl} | 22 +- .../direct3d12/D3D12_PixelShader_Colors.h | 442 +- .../direct3d12/D3D12_PixelShader_Colors.hlsl | 2 +- .../direct3d12/D3D12_PixelShader_Common.incl | 175 +- .../direct3d12/D3D12_PixelShader_HDR10.h | 856 --- .../direct3d12/D3D12_PixelShader_HDR10.hlsl | 56 - .../direct3d12/D3D12_PixelShader_NV12.h | 729 --- .../direct3d12/D3D12_PixelShader_NV12.hlsl | 31 - .../direct3d12/D3D12_PixelShader_NV21.h | 729 --- .../direct3d12/D3D12_PixelShader_Textures.h | 495 +- .../D3D12_PixelShader_Textures.hlsl | 6 +- src/render/direct3d12/D3D12_PixelShader_YUV.h | 745 --- .../direct3d12/D3D12_PixelShader_YUV.hlsl | 34 - ...RootSig_YUV.h => D3D12_RootSig_Advanced.h} | 2 +- src/render/direct3d12/D3D12_RootSig_NV.h | 27 - src/render/direct3d12/D3D12_VertexShader.hlsl | 23 +- ...er_YUV.h => D3D12_VertexShader_Advanced.h} | 434 +- src/render/direct3d12/D3D12_VertexShader_NV.h | 647 -- src/render/direct3d12/SDL_render_d3d12.c | 230 +- src/render/direct3d12/SDL_shaders_d3d12.c | 58 +- src/render/direct3d12/SDL_shaders_d3d12.h | 12 +- src/render/direct3d12/compile_shaders.bat | 11 +- src/render/metal/SDL_render_metal.m | 203 +- src/render/metal/SDL_shaders_metal.metal | 244 +- src/render/metal/SDL_shaders_metal_ios.h | 4609 +++++++------- .../metal/SDL_shaders_metal_iphonesimulator.h | 5401 ++++++++--------- src/render/metal/SDL_shaders_metal_macos.h | 4487 ++++++-------- src/render/metal/SDL_shaders_metal_tvos.h | 4609 +++++++------- .../metal/SDL_shaders_metal_tvsimulator.h | 5370 ++++++++-------- src/video/SDL_blit_slow.c | 128 +- src/video/SDL_surface.c | 6 +- 50 files changed, 15111 insertions(+), 21123 deletions(-) create mode 100644 src/render/direct3d11/D3D11_PixelShader_Advanced.h create mode 100644 src/render/direct3d11/D3D11_PixelShader_Advanced.hlsl delete mode 100644 src/render/direct3d11/D3D11_PixelShader_HDR10.h delete mode 100644 src/render/direct3d11/D3D11_PixelShader_HDR10.hlsl delete mode 100644 src/render/direct3d11/D3D11_PixelShader_NV12.h delete mode 100644 src/render/direct3d11/D3D11_PixelShader_NV12.hlsl delete mode 100644 src/render/direct3d11/D3D11_PixelShader_NV21.h delete mode 100644 src/render/direct3d11/D3D11_PixelShader_NV21.hlsl delete mode 100644 src/render/direct3d11/D3D11_PixelShader_YUV.h delete mode 100644 src/render/direct3d11/D3D11_PixelShader_YUV.hlsl create mode 100644 src/render/direct3d12/D3D12_PixelShader_Advanced.h rename src/render/direct3d12/{D3D12_PixelShader_NV21.hlsl => D3D12_PixelShader_Advanced.hlsl} (50%) delete mode 100644 src/render/direct3d12/D3D12_PixelShader_HDR10.h delete mode 100644 src/render/direct3d12/D3D12_PixelShader_HDR10.hlsl delete mode 100644 src/render/direct3d12/D3D12_PixelShader_NV12.h delete mode 100644 src/render/direct3d12/D3D12_PixelShader_NV12.hlsl delete mode 100644 src/render/direct3d12/D3D12_PixelShader_NV21.h delete mode 100644 src/render/direct3d12/D3D12_PixelShader_YUV.h delete mode 100644 src/render/direct3d12/D3D12_PixelShader_YUV.hlsl rename src/render/direct3d12/{D3D12_RootSig_YUV.h => D3D12_RootSig_Advanced.h} (97%) delete mode 100644 src/render/direct3d12/D3D12_RootSig_NV.h rename src/render/direct3d12/{D3D12_VertexShader_YUV.h => D3D12_VertexShader_Advanced.h} (74%) delete mode 100644 src/render/direct3d12/D3D12_VertexShader_NV.h diff --git a/include/SDL3/SDL_surface.h b/include/SDL3/SDL_surface.h index 0bfcafde0..f58b39b7a 100644 --- a/include/SDL3/SDL_surface.h +++ b/include/SDL3/SDL_surface.h @@ -212,9 +212,9 @@ extern DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface); * for YUV surfaces. * - `SDL_PROP_SURFACE_MAXCLL_NUMBER`: MaxCLL (Maximum Content Light Level) indicates the maximum light level of any single pixel (in cd/m2 or nits) of the content. MaxCLL is usually measured off the final delivered content after mastering. If one uses the full light level of the HDR mastering display and adds a hard clip at its maximum value, MaxCLL would be equal to the peak luminance of the mastering monitor. This defaults to 400 for HDR10 surfaces. * - `SDL_PROP_SURFACE_MAXFALL_NUMBER`: MaxFALL (Maximum Frame Average Light Level) indicates the maximum value of the frame average light level (in cd/m2 or nits) of the content. MaxFALL is calculated by averaging the decoded luminance values of all the pixels within a frame. MaxFALL is usually much lower than MaxCLL. - * - `SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point surfaces, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. This defaults to 100 for surfaces using the PQ colorspace and 1.0 for other surfaces. + * - `SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point surfaces, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. This defaults to 100 for HDR10 surfaces and 1.0 for other surfaces. * - `SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point surfaces, this defines the maximum dynamic range used by the content, in terms of the SDR white point. This defaults to SDL_PROP_SURFACE_MAXCLL_NUMBER / SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT, or 4.0, for HDR10 surfaces. - * - `SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING`: the tone mapping operator used when converting between different SDR/HDR ranges. Currently this supports the form "*=N", where N is a floating point scale factor applied in linear space. + * - `SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING`: the tone mapping operator used when compressing from a surface with high dynamic range to another with lower dynamic range. Currently this supports "chrome", which uses the same tone mapping that Chrome uses for HDR content, the form "*=N", where N is a floating point scale factor applied in linear space, and "none", which disables tone mapping. This defaults to "chrome". * * \param surface the SDL_Surface structure to query * \returns a valid property ID on success or 0 on failure; call diff --git a/src/render/direct3d11/D3D11_PixelShader_Advanced.h b/src/render/direct3d11/D3D11_PixelShader_Advanced.h new file mode 100644 index 000000000..a1297c981 --- /dev/null +++ b/src/render/direct3d11/D3D11_PixelShader_Advanced.h @@ -0,0 +1,1060 @@ +#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/src/render/direct3d11/D3D11_PixelShader_Advanced.hlsl b/src/render/direct3d11/D3D11_PixelShader_Advanced.hlsl new file mode 100644 index 000000000..39dda47bc --- /dev/null +++ b/src/render/direct3d11/D3D11_PixelShader_Advanced.hlsl @@ -0,0 +1,7 @@ + +#include "D3D11_PixelShader_Common.incl" + +float4 main(PixelShaderInput input) : SV_TARGET +{ + return AdvancedPixelShader(input); +} diff --git a/src/render/direct3d11/D3D11_PixelShader_Colors.h b/src/render/direct3d11/D3D11_PixelShader_Colors.h index ad68f93bb..6658e4d11 100644 --- a/src/render/direct3d11/D3D11_PixelShader_Colors.h +++ b/src/render/direct3d11/D3D11_PixelShader_Colors.h @@ -9,13 +9,17 @@ // { // // float scRGB_output; // Offset: 0 Size: 4 [unused] -// float color_scale; // Offset: 4 Size: 4 -// float unused1; // Offset: 8 Size: 4 [unused] -// float unused2; // Offset: 12 Size: 4 [unused] -// float4 Yoffset; // Offset: 16 Size: 16 [unused] -// float4 Rcoeff; // Offset: 32 Size: 16 [unused] -// float4 Gcoeff; // Offset: 48 Size: 16 [unused] -// float4 Bcoeff; // Offset: 64 Size: 16 [unused] +// 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] // // } // @@ -55,7 +59,7 @@ // ps_2_0 dcl t1 - mul r0.xyz, t1, c0.y + mul r0.xyz, t1, c0.w mov r0.w, t1.w mov oC0, r0 @@ -65,7 +69,7 @@ dcl_constantbuffer CB0[1], immediateIndexed dcl_input_ps linear v2.xyzw dcl_output o0.xyzw dcl_temps 1 -mov r0.x, cb0[0].y +mov r0.x, cb0[0].w mov r0.w, l(1.000000) mul o0.xyzw, r0.xxxw, v2.xyzw ret @@ -74,15 +78,15 @@ ret const BYTE g_main[] = { - 68, 88, 66, 67, 76, 154, - 233, 103, 201, 50, 167, 173, - 112, 159, 134, 20, 133, 254, - 166, 35, 1, 0, 0, 0, - 24, 4, 0, 0, 6, 0, + 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, - 112, 3, 0, 0, 228, 3, + 24, 4, 0, 0, 140, 4, 0, 0, 65, 111, 110, 57, 108, 0, 0, 0, 108, 0, 0, 0, 0, 2, 255, 255, @@ -97,7 +101,7 @@ const BYTE g_main[] = 0, 0, 0, 128, 1, 0, 15, 176, 5, 0, 0, 3, 0, 0, 7, 128, 1, 0, - 228, 176, 0, 0, 85, 160, + 228, 176, 0, 0, 255, 160, 1, 0, 0, 2, 0, 0, 8, 128, 1, 0, 255, 176, 1, 0, 0, 2, 0, 8, @@ -115,7 +119,7 @@ const BYTE g_main[] = 104, 0, 0, 2, 1, 0, 0, 0, 54, 0, 0, 6, 18, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 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, @@ -147,12 +151,12 @@ const BYTE g_main[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 68, - 69, 70, 180, 1, 0, 0, + 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, - 137, 1, 0, 0, 60, 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, @@ -160,54 +164,82 @@ const BYTE g_main[] = 0, 0, 1, 0, 0, 0, 67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 171, 171, - 60, 0, 0, 0, 8, 0, + 60, 0, 0, 0, 12, 0, 0, 0, 96, 0, 0, 0, - 80, 0, 0, 0, 0, 0, + 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 32, 1, 0, 0, 0, 0, + 128, 1, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 48, 1, + 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, - 64, 1, 0, 0, 4, 0, + 160, 1, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, - 2, 0, 0, 0, 48, 1, + 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, - 76, 1, 0, 0, 8, 0, + 173, 1, 0, 0, 8, 0, 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 48, 1, + 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, - 84, 1, 0, 0, 12, 0, + 184, 1, 0, 0, 12, 0, 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 48, 1, + 2, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, - 92, 1, 0, 0, 16, 0, - 0, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 100, 1, + 196, 1, 0, 0, 16, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, - 116, 1, 0, 0, 32, 0, - 0, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 100, 1, + 211, 1, 0, 0, 20, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, - 123, 1, 0, 0, 48, 0, - 0, 0, 16, 0, 0, 0, - 0, 0, 0, 0, 100, 1, + 227, 1, 0, 0, 24, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 144, 1, 0, 0, 0, 0, 0, 0, - 130, 1, 0, 0, 64, 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, 100, 1, + 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, 99, 111, 108, 111, + 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, 117, 110, 117, 115, - 101, 100, 49, 0, 117, 110, - 117, 115, 101, 100, 50, 0, - 89, 111, 102, 102, 115, 101, - 116, 0, 1, 0, 3, 0, + 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, diff --git a/src/render/direct3d11/D3D11_PixelShader_Common.incl b/src/render/direct3d11/D3D11_PixelShader_Common.incl index 35623b762..61053d8c4 100644 --- a/src/render/direct3d11/D3D11_PixelShader_Common.incl +++ b/src/render/direct3d11/D3D11_PixelShader_Common.incl @@ -1,3 +1,9 @@ + +Texture2D texture0 : register(t0); +Texture2D texture1 : register(t1); +Texture2D texture2 : register(t2); +SamplerState sampler0 : register(s0); + struct PixelShaderInput { float4 pos : SV_POSITION; @@ -5,12 +11,33 @@ struct PixelShaderInput float4 color : COLOR0; }; +// These should mirror the definitions in SDL_render_d3d12.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 unused1; - float unused2; + + float tonemap_method; + float tonemap_factor1; + float tonemap_factor2; + float sdr_white_point; float4 Yoffset; float4 Rcoeff; @@ -18,15 +45,17 @@ cbuffer Constants : register(b0) float4 Bcoeff; }; -float3 scRGBtoNits(float3 v) -{ - return v * 80.0; -} +static const float3x3 mat709to2020 = { + { 0.627404, 0.329283, 0.043313 }, + { 0.069097, 0.919541, 0.011362 }, + { 0.016391, 0.088013, 0.895595 } +}; -float3 scRGBfromNits(float3 v) -{ - return v / 80.0; -} +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) { @@ -48,6 +77,92 @@ float sRGBfromLinear(float v) 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; @@ -58,9 +173,9 @@ float4 GetOutputColor(float4 rgba) return output; } -float4 GetOutputColorFromSRGB(float3 rgb) +float3 GetOutputColorFromSRGB(float3 rgb) { - float4 output; + float3 output; if (scRGB_output) { rgb.r = sRGBtoLinear(rgb.r); @@ -69,17 +184,15 @@ float4 GetOutputColorFromSRGB(float3 rgb) } output.rgb = rgb * color_scale; - output.a = 1.0; return output; } -float4 GetOutputColorFromSCRGB(float3 rgb) +float3 GetOutputColorFromLinear(float3 rgb) { - float4 output; + float3 output; output.rgb = rgb * color_scale; - output.a = 1.0; if (!scRGB_output) { output.r = sRGBfromLinear(output.r); @@ -90,3 +203,33 @@ float4 GetOutputColorFromSCRGB(float3 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/src/render/direct3d11/D3D11_PixelShader_HDR10.h b/src/render/direct3d11/D3D11_PixelShader_HDR10.h deleted file mode 100644 index d8e17c33f..000000000 --- a/src/render/direct3d11/D3D11_PixelShader_HDR10.h +++ /dev/null @@ -1,507 +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 color_scale; // Offset: 4 Size: 4 -// float unused1; // Offset: 8 Size: 4 [unused] -// float unused2; // Offset: 12 Size: 4 [unused] -// float4 Yoffset; // Offset: 16 Size: 16 -// float4 Rcoeff; // Offset: 32 Size: 16 -// float4 Gcoeff; // Offset: 48 Size: 16 -// float4 Bcoeff; // Offset: 64 Size: 16 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim HLSL Bind Count -// ------------------------------ ---------- ------- ----------- -------------- ------ -// theSampler sampler NA NA s0 1 -// theTextureY texture float4 2d t0 1 -// theTextureUV texture float4 2d t1 1 -// Constants cbuffer NA NA cb0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// TEXCOORD 0 xy 1 NONE float xy -// COLOR 0 xyzw 2 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer CB0[5], immediateIndexed -dcl_sampler s0, mode_default -dcl_resource_texture2d (float,float,float,float) t0 -dcl_resource_texture2d (float,float,float,float) t1 -dcl_input_ps linear v1.xy -dcl_input_ps linear v2.xyzw -dcl_output o0.xyzw -dcl_temps 4 -sample_indexable(texture2d)(float,float,float,float) r0.x, v1.xyxx, t0.xyzw, s0 -sample_indexable(texture2d)(float,float,float,float) r0.yz, v1.xyxx, t1.zxyw, s0 -add r0.xyz, r0.xyzx, cb0[1].xyzx -dp3 r1.x, r0.xyzx, cb0[2].xyzx -dp3 r1.y, r0.xyzx, cb0[3].xyzx -dp3 r1.z, r0.xyzx, cb0[4].xyzx -log r0.xyz, |r1.xyzx| -mul r0.xyz, r0.xyzx, l(0.012683, 0.012683, 0.012683, 0.000000) -exp r0.xyz, r0.xyzx -add r1.xyz, r0.xyzx, l(-0.835938, -0.835938, -0.835938, 0.000000) -max r1.xyz, r1.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000) -mad r0.xyz, -r0.xyzx, l(18.687500, 18.687500, 18.687500, 0.000000), l(18.851562, 18.851562, 18.851562, 0.000000) -div r0.xyz, r1.xyzx, r0.xyzx -log r0.xyz, |r0.xyzx| -mul r0.xyz, r0.xyzx, l(6.277395, 6.277395, 6.277395, 0.000000) -exp r0.xyz, r0.xyzx -mul r0.xyz, r0.xyzx, l(10000.000000, 10000.000000, 10000.000000, 0.000000) -dp3 r1.x, l(1.660496, -0.587656, -0.072840, 0.000000), r0.xyzx -dp3 r1.y, l(-0.124547, 1.132895, -0.008348, 0.000000), r0.xyzx -dp3 r1.z, l(-0.018154, -0.100597, 1.118751, 0.000000), r0.xyzx -mul r0.xyz, r1.xyzx, cb0[0].yyyy -mul r1.xyz, r0.xyzx, l(0.012500, 0.012500, 0.012500, 0.000000) -ne r0.w, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x -if_z r0.w - ge r2.xyz, l(0.250464, 0.250464, 0.250464, 0.000000), r0.xyzx - mul r0.xyz, r0.xyzx, l(0.161500, 0.161500, 0.161500, 0.000000) - log r3.xyz, |r1.xyzx| - mul r3.xyz, r3.xyzx, l(0.416667, 0.416667, 0.416667, 0.000000) - exp r3.xyz, r3.xyzx - mad r3.xyz, r3.xyzx, l(1.055000, 1.055000, 1.055000, 0.000000), l(-0.055000, -0.055000, -0.055000, 0.000000) - movc_sat r1.xyz, r2.xyzx, r0.xyzx, r3.xyzx -endif -mov r1.w, l(1.000000) -mul o0.xyzw, r1.xyzw, v2.xyzw -ret -// Approximately 35 instruction slots used -#endif - -const BYTE g_main[] = -{ - 68, 88, 66, 67, 95, 217, - 108, 181, 38, 184, 86, 20, - 51, 33, 123, 248, 135, 60, - 0, 250, 1, 0, 0, 0, - 144, 9, 0, 0, 5, 0, - 0, 0, 52, 0, 0, 0, - 72, 3, 0, 0, 188, 3, - 0, 0, 240, 3, 0, 0, - 244, 8, 0, 0, 82, 68, - 69, 70, 12, 3, 0, 0, - 1, 0, 0, 0, 236, 0, - 0, 0, 4, 0, 0, 0, - 60, 0, 0, 0, 0, 5, - 255, 255, 0, 1, 0, 0, - 225, 2, 0, 0, 82, 68, - 49, 49, 60, 0, 0, 0, - 24, 0, 0, 0, 32, 0, - 0, 0, 40, 0, 0, 0, - 36, 0, 0, 0, 12, 0, - 0, 0, 0, 0, 0, 0, - 188, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 199, 0, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 1, 0, 0, 0, - 13, 0, 0, 0, 211, 0, - 0, 0, 2, 0, 0, 0, - 5, 0, 0, 0, 4, 0, - 0, 0, 255, 255, 255, 255, - 1, 0, 0, 0, 1, 0, - 0, 0, 13, 0, 0, 0, - 224, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 116, 104, 101, 83, - 97, 109, 112, 108, 101, 114, - 0, 116, 104, 101, 84, 101, - 120, 116, 117, 114, 101, 89, - 0, 116, 104, 101, 84, 101, - 120, 116, 117, 114, 101, 85, - 86, 0, 67, 111, 110, 115, - 116, 97, 110, 116, 115, 0, - 171, 171, 224, 0, 0, 0, - 8, 0, 0, 0, 4, 1, - 0, 0, 80, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 68, 2, 0, 0, - 0, 0, 0, 0, 4, 0, - 0, 0, 2, 0, 0, 0, - 88, 2, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 124, 2, 0, 0, 4, 0, - 0, 0, 4, 0, 0, 0, - 2, 0, 0, 0, 88, 2, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 136, 2, - 0, 0, 8, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 88, 2, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 144, 2, 0, 0, - 12, 0, 0, 0, 4, 0, - 0, 0, 0, 0, 0, 0, - 88, 2, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 152, 2, 0, 0, 16, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 168, 2, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 204, 2, - 0, 0, 32, 0, 0, 0, - 16, 0, 0, 0, 2, 0, - 0, 0, 168, 2, 0, 0, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 211, 2, 0, 0, - 48, 0, 0, 0, 16, 0, - 0, 0, 2, 0, 0, 0, - 168, 2, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 218, 2, 0, 0, 64, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 168, 2, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 255, 255, 255, 255, - 0, 0, 0, 0, 115, 99, - 82, 71, 66, 95, 111, 117, - 116, 112, 117, 116, 0, 102, - 108, 111, 97, 116, 0, 171, - 0, 0, 3, 0, 1, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 81, 2, 0, 0, - 99, 111, 108, 111, 114, 95, - 115, 99, 97, 108, 101, 0, - 117, 110, 117, 115, 101, 100, - 49, 0, 117, 110, 117, 115, - 101, 100, 50, 0, 89, 111, - 102, 102, 115, 101, 116, 0, - 102, 108, 111, 97, 116, 52, - 0, 171, 1, 0, 3, 0, - 1, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 160, 2, - 0, 0, 82, 99, 111, 101, - 102, 102, 0, 71, 99, 111, - 101, 102, 102, 0, 66, 99, - 111, 101, 102, 102, 0, 77, - 105, 99, 114, 111, 115, 111, - 102, 116, 32, 40, 82, 41, - 32, 72, 76, 83, 76, 32, - 83, 104, 97, 100, 101, 114, - 32, 67, 111, 109, 112, 105, - 108, 101, 114, 32, 49, 48, - 46, 49, 0, 171, 171, 171, - 73, 83, 71, 78, 108, 0, - 0, 0, 3, 0, 0, 0, - 8, 0, 0, 0, 80, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 92, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 3, 3, 0, 0, 101, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 2, 0, 0, 0, - 15, 15, 0, 0, 83, 86, - 95, 80, 79, 83, 73, 84, - 73, 79, 78, 0, 84, 69, - 88, 67, 79, 79, 82, 68, - 0, 67, 79, 76, 79, 82, - 0, 171, 79, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 84, 65, 82, - 71, 69, 84, 0, 171, 171, - 83, 72, 69, 88, 252, 4, - 0, 0, 80, 0, 0, 0, - 63, 1, 0, 0, 106, 8, - 0, 1, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 90, 0, 0, 3, 0, 96, - 16, 0, 0, 0, 0, 0, - 88, 24, 0, 4, 0, 112, - 16, 0, 0, 0, 0, 0, - 85, 85, 0, 0, 88, 24, - 0, 4, 0, 112, 16, 0, - 1, 0, 0, 0, 85, 85, - 0, 0, 98, 16, 0, 3, - 50, 16, 16, 0, 1, 0, - 0, 0, 98, 16, 0, 3, - 242, 16, 16, 0, 2, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 104, 0, 0, 2, - 4, 0, 0, 0, 69, 0, - 0, 139, 194, 0, 0, 128, - 67, 85, 21, 0, 18, 0, - 16, 0, 0, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 70, 126, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 98, 0, 16, 0, 0, 0, - 0, 0, 70, 16, 16, 0, - 1, 0, 0, 0, 38, 125, - 16, 0, 1, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 16, 0, - 0, 8, 18, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 16, 0, 0, 8, 34, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 16, 0, 0, 8, - 66, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 47, 0, - 0, 6, 114, 0, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 128, 129, 0, 0, 0, - 1, 0, 0, 0, 56, 0, - 0, 10, 114, 0, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 172, 205, - 79, 60, 172, 205, 79, 60, - 172, 205, 79, 60, 0, 0, - 0, 0, 25, 0, 0, 5, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 0, 0, - 0, 10, 114, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 86, 191, 0, 0, 86, 191, - 0, 0, 86, 191, 0, 0, - 0, 0, 52, 0, 0, 10, - 114, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 50, 0, 0, 16, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 128, - 149, 65, 0, 128, 149, 65, - 0, 128, 149, 65, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 208, 150, 65, 0, 208, - 150, 65, 0, 208, 150, 65, - 0, 0, 0, 0, 14, 0, - 0, 7, 114, 0, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 47, 0, 0, 6, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 128, - 129, 0, 0, 0, 0, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 107, 224, 200, 64, - 107, 224, 200, 64, 107, 224, - 200, 64, 0, 0, 0, 0, - 25, 0, 0, 5, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 64, 28, 70, - 0, 64, 28, 70, 0, 64, - 28, 70, 0, 0, 0, 0, - 16, 0, 0, 10, 18, 0, - 16, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 34, 139, - 212, 63, 160, 112, 22, 191, - 35, 45, 149, 189, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 16, 0, - 0, 10, 34, 0, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 127, 18, 255, 189, - 180, 2, 145, 63, 13, 198, - 8, 188, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 16, 0, 0, 10, - 66, 0, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 179, 183, 148, 188, 205, 5, - 206, 189, 60, 51, 143, 63, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 8, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 86, 133, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 205, 204, 76, 60, - 205, 204, 76, 60, 205, 204, - 76, 60, 0, 0, 0, 0, - 57, 0, 0, 11, 130, 0, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 10, 128, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 31, 0, 0, 3, - 58, 0, 16, 0, 0, 0, - 0, 0, 29, 0, 0, 10, - 114, 0, 16, 0, 2, 0, - 0, 0, 2, 64, 0, 0, - 209, 60, 128, 62, 209, 60, - 128, 62, 209, 60, 128, 62, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 10, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 66, 96, 37, 62, 66, 96, - 37, 62, 66, 96, 37, 62, - 0, 0, 0, 0, 47, 0, - 0, 6, 114, 0, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 128, 129, 0, 0, 0, - 1, 0, 0, 0, 56, 0, - 0, 10, 114, 0, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 0, 3, 0, 0, 0, - 2, 64, 0, 0, 85, 85, - 213, 62, 85, 85, 213, 62, - 85, 85, 213, 62, 0, 0, - 0, 0, 25, 0, 0, 5, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 50, 0, - 0, 15, 114, 0, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 0, 3, 0, 0, 0, - 2, 64, 0, 0, 61, 10, - 135, 63, 61, 10, 135, 63, - 61, 10, 135, 63, 0, 0, - 0, 0, 2, 64, 0, 0, - 174, 71, 97, 189, 174, 71, - 97, 189, 174, 71, 97, 189, - 0, 0, 0, 0, 55, 32, - 0, 9, 114, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 21, 0, - 0, 1, 54, 0, 0, 5, - 130, 0, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 56, 0, - 0, 7, 242, 32, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 1, 0, 0, 0, - 70, 30, 16, 0, 2, 0, - 0, 0, 62, 0, 0, 1, - 83, 84, 65, 84, 148, 0, - 0, 0, 35, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 27, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 -}; diff --git a/src/render/direct3d11/D3D11_PixelShader_HDR10.hlsl b/src/render/direct3d11/D3D11_PixelShader_HDR10.hlsl deleted file mode 100644 index d7878e91c..000000000 --- a/src/render/direct3d11/D3D11_PixelShader_HDR10.hlsl +++ /dev/null @@ -1,45 +0,0 @@ -Texture2D theTextureY : register(t0); -Texture2D theTextureUV : register(t1); -SamplerState theSampler : register(s0); - -#include "D3D11_PixelShader_Common.incl" - -float3 PQtoNits(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); -} - -float4 main(PixelShaderInput input) : SV_TARGET -{ - const float3x3 mat2020to709 = { - 1.660496, -0.587656, -0.072840, - -0.124547, 1.132895, -0.008348, - -0.018154, -0.100597, 1.118751 - }; - - float3 yuv; - yuv.x = theTextureY.Sample(theSampler, input.tex).r; - yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg; - - float3 rgb; - yuv += Yoffset.xyz; - rgb.r = dot(yuv, Rcoeff.xyz); - rgb.g = dot(yuv, Gcoeff.xyz); - rgb.b = dot(yuv, Bcoeff.xyz); - - rgb = PQtoNits(rgb); - - rgb = mul(mat2020to709, rgb); - - rgb = scRGBfromNits(rgb); - - return GetOutputColorFromSCRGB(rgb) * input.color; -} diff --git a/src/render/direct3d11/D3D11_PixelShader_NV12.h b/src/render/direct3d11/D3D11_PixelShader_NV12.h deleted file mode 100644 index 2a76fbaed..000000000 --- a/src/render/direct3d11/D3D11_PixelShader_NV12.h +++ /dev/null @@ -1,545 +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 color_scale; // Offset: 4 Size: 4 -// float unused1; // Offset: 8 Size: 4 [unused] -// float unused2; // Offset: 12 Size: 4 [unused] -// float4 Yoffset; // Offset: 16 Size: 16 -// float4 Rcoeff; // Offset: 32 Size: 16 -// float4 Gcoeff; // Offset: 48 Size: 16 -// float4 Bcoeff; // Offset: 64 Size: 16 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim HLSL Bind Count -// ------------------------------ ---------- ------- ----------- -------------- ------ -// theSampler sampler NA NA s0 1 -// theTextureY texture float4 2d t0 1 -// theTextureUV texture float4 2d t1 1 -// Constants cbuffer NA NA cb0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// TEXCOORD 0 xy 1 NONE float xy -// COLOR 0 xyzw 2 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -// -// Constant buffer to DX9 shader constant mappings: -// -// Target Reg Buffer Start Reg # of Regs Data Conversion -// ---------- ------- --------- --------- ---------------------- -// c0 cb0 0 5 ( FLT, FLT, FLT, FLT) -// -// -// Sampler/Resource to DX9 shader sampler mappings: -// -// Target Sampler Source Sampler Source Resource -// -------------- --------------- ---------------- -// s0 s0 t0 -// s1 s0 t1 -// -// -// Level9 shader bytecode: -// - ps_2_0 - def c5, 0.0404499993, 0.0773993805, 0.0549999997, 0.947867334 - def c6, 2.4000001, 1, 0, 0 - dcl t0.xy - dcl t1 - dcl_2d s0 - dcl_2d s1 - texld r0, t0, s0 - texld r1, t0, s1 - mov r0.yz, r1.zxyw - add r0.xyz, r0, c1 - dp3 r1.x, r0, c2 - add r0.w, r1.x, c5.z - abs r0.w, r0.w - mul r0.w, r0.w, c5.w - pow r1.w, r0.w, c6.x - add r0.w, -r1.x, c5.x - mul r2.w, r1.x, c5.y - cmp r2.x, r0.w, r2.w, r1.w - dp3 r1.y, r0, c3 - dp3 r1.z, r0, c4 - add r1.w, r1.y, c5.z - abs r1.w, r1.w - mul r1.w, r1.w, c5.w - pow r2.w, r1.w, c6.x - add r1.w, -r1.y, c5.x - mul r0.x, r1.y, c5.y - cmp r2.y, r1.w, r0.x, r2.w - add r1.w, r1.z, c5.z - abs r1.w, r1.w - mul r1.w, r1.w, c5.w - pow r2.w, r1.w, c6.x - add r1.w, -r1.z, c5.x - mul r0.x, r1.z, c5.y - cmp r2.z, r1.w, r0.x, r2.w - mul r1.w, c0.x, c0.x - cmp r0.xyz, -r1.w, r1, r2 - mul r0.xyz, r0, c0.y - mov r0.w, c6.y - mul r0, r0, t1 - mov oC0, r0 - -// approximately 40 instruction slots used (2 texture, 38 arithmetic) -ps_4_0 -dcl_constantbuffer CB0[5], immediateIndexed -dcl_sampler s0, mode_default -dcl_resource_texture2d (float,float,float,float) t0 -dcl_resource_texture2d (float,float,float,float) t1 -dcl_input_ps linear v1.xy -dcl_input_ps linear v2.xyzw -dcl_output o0.xyzw -dcl_temps 4 -sample r0.xyzw, v1.xyxx, t0.xyzw, s0 -sample r1.xyzw, v1.xyxx, t1.zxyw, s0 -mov r1.x, r0.x -add r0.xyz, r1.xyzx, cb0[1].xyzx -dp3 r1.x, r0.xyzx, cb0[2].xyzx -dp3 r1.y, r0.xyzx, cb0[3].xyzx -dp3 r1.z, r0.xyzx, cb0[4].xyzx -ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x -if_nz r0.x - ge r0.xyz, l(0.040450, 0.040450, 0.040450, 0.000000), r1.xyzx - mul r2.xyz, r1.xyzx, l(0.077399, 0.077399, 0.077399, 0.000000) - add r3.xyz, r1.xyzx, l(0.055000, 0.055000, 0.055000, 0.000000) - mul r3.xyz, |r3.xyzx|, l(0.947867, 0.947867, 0.947867, 0.000000) - log r3.xyz, r3.xyzx - mul r3.xyz, r3.xyzx, l(2.400000, 2.400000, 2.400000, 0.000000) - exp r3.xyz, r3.xyzx - movc r1.xyz, r0.xyzx, r2.xyzx, r3.xyzx -endif -mul r0.xyz, r1.xyzx, cb0[0].yyyy -mov r0.w, l(1.000000) -mul o0.xyzw, r0.xyzw, v2.xyzw -ret -// Approximately 22 instruction slots used -#endif - -const BYTE g_main[] = -{ - 68, 88, 66, 67, 58, 20, - 110, 34, 151, 86, 32, 17, - 118, 15, 98, 32, 139, 247, - 137, 113, 1, 0, 0, 0, - 88, 9, 0, 0, 6, 0, - 0, 0, 56, 0, 0, 0, - 248, 2, 0, 0, 244, 5, - 0, 0, 112, 6, 0, 0, - 176, 8, 0, 0, 36, 9, - 0, 0, 65, 111, 110, 57, - 184, 2, 0, 0, 184, 2, - 0, 0, 0, 2, 255, 255, - 128, 2, 0, 0, 56, 0, - 0, 0, 1, 0, 44, 0, - 0, 0, 56, 0, 0, 0, - 56, 0, 2, 0, 36, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 0, 0, 0, 0, - 0, 2, 255, 255, 81, 0, - 0, 5, 5, 0, 15, 160, - 230, 174, 37, 61, 145, 131, - 158, 61, 174, 71, 97, 61, - 111, 167, 114, 63, 81, 0, - 0, 5, 6, 0, 15, 160, - 154, 153, 25, 64, 0, 0, - 128, 63, 0, 0, 0, 0, - 0, 0, 0, 0, 31, 0, - 0, 2, 0, 0, 0, 128, - 0, 0, 3, 176, 31, 0, - 0, 2, 0, 0, 0, 128, - 1, 0, 15, 176, 31, 0, - 0, 2, 0, 0, 0, 144, - 0, 8, 15, 160, 31, 0, - 0, 2, 0, 0, 0, 144, - 1, 8, 15, 160, 66, 0, - 0, 3, 0, 0, 15, 128, - 0, 0, 228, 176, 0, 8, - 228, 160, 66, 0, 0, 3, - 1, 0, 15, 128, 0, 0, - 228, 176, 1, 8, 228, 160, - 1, 0, 0, 2, 0, 0, - 6, 128, 1, 0, 210, 128, - 2, 0, 0, 3, 0, 0, - 7, 128, 0, 0, 228, 128, - 1, 0, 228, 160, 8, 0, - 0, 3, 1, 0, 1, 128, - 0, 0, 228, 128, 2, 0, - 228, 160, 2, 0, 0, 3, - 0, 0, 8, 128, 1, 0, - 0, 128, 5, 0, 170, 160, - 35, 0, 0, 2, 0, 0, - 8, 128, 0, 0, 255, 128, - 5, 0, 0, 3, 0, 0, - 8, 128, 0, 0, 255, 128, - 5, 0, 255, 160, 32, 0, - 0, 3, 1, 0, 8, 128, - 0, 0, 255, 128, 6, 0, - 0, 160, 2, 0, 0, 3, - 0, 0, 8, 128, 1, 0, - 0, 129, 5, 0, 0, 160, - 5, 0, 0, 3, 2, 0, - 8, 128, 1, 0, 0, 128, - 5, 0, 85, 160, 88, 0, - 0, 4, 2, 0, 1, 128, - 0, 0, 255, 128, 2, 0, - 255, 128, 1, 0, 255, 128, - 8, 0, 0, 3, 1, 0, - 2, 128, 0, 0, 228, 128, - 3, 0, 228, 160, 8, 0, - 0, 3, 1, 0, 4, 128, - 0, 0, 228, 128, 4, 0, - 228, 160, 2, 0, 0, 3, - 1, 0, 8, 128, 1, 0, - 85, 128, 5, 0, 170, 160, - 35, 0, 0, 2, 1, 0, - 8, 128, 1, 0, 255, 128, - 5, 0, 0, 3, 1, 0, - 8, 128, 1, 0, 255, 128, - 5, 0, 255, 160, 32, 0, - 0, 3, 2, 0, 8, 128, - 1, 0, 255, 128, 6, 0, - 0, 160, 2, 0, 0, 3, - 1, 0, 8, 128, 1, 0, - 85, 129, 5, 0, 0, 160, - 5, 0, 0, 3, 0, 0, - 1, 128, 1, 0, 85, 128, - 5, 0, 85, 160, 88, 0, - 0, 4, 2, 0, 2, 128, - 1, 0, 255, 128, 0, 0, - 0, 128, 2, 0, 255, 128, - 2, 0, 0, 3, 1, 0, - 8, 128, 1, 0, 170, 128, - 5, 0, 170, 160, 35, 0, - 0, 2, 1, 0, 8, 128, - 1, 0, 255, 128, 5, 0, - 0, 3, 1, 0, 8, 128, - 1, 0, 255, 128, 5, 0, - 255, 160, 32, 0, 0, 3, - 2, 0, 8, 128, 1, 0, - 255, 128, 6, 0, 0, 160, - 2, 0, 0, 3, 1, 0, - 8, 128, 1, 0, 170, 129, - 5, 0, 0, 160, 5, 0, - 0, 3, 0, 0, 1, 128, - 1, 0, 170, 128, 5, 0, - 85, 160, 88, 0, 0, 4, - 2, 0, 4, 128, 1, 0, - 255, 128, 0, 0, 0, 128, - 2, 0, 255, 128, 5, 0, - 0, 3, 1, 0, 8, 128, - 0, 0, 0, 160, 0, 0, - 0, 160, 88, 0, 0, 4, - 0, 0, 7, 128, 1, 0, - 255, 129, 1, 0, 228, 128, - 2, 0, 228, 128, 5, 0, - 0, 3, 0, 0, 7, 128, - 0, 0, 228, 128, 0, 0, - 85, 160, 1, 0, 0, 2, - 0, 0, 8, 128, 6, 0, - 85, 160, 5, 0, 0, 3, - 0, 0, 15, 128, 0, 0, - 228, 128, 1, 0, 228, 176, - 1, 0, 0, 2, 0, 8, - 15, 128, 0, 0, 228, 128, - 255, 255, 0, 0, 83, 72, - 68, 82, 244, 2, 0, 0, - 64, 0, 0, 0, 189, 0, - 0, 0, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 90, 0, 0, 3, 0, 96, - 16, 0, 0, 0, 0, 0, - 88, 24, 0, 4, 0, 112, - 16, 0, 0, 0, 0, 0, - 85, 85, 0, 0, 88, 24, - 0, 4, 0, 112, 16, 0, - 1, 0, 0, 0, 85, 85, - 0, 0, 98, 16, 0, 3, - 50, 16, 16, 0, 1, 0, - 0, 0, 98, 16, 0, 3, - 242, 16, 16, 0, 2, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 104, 0, 0, 2, - 4, 0, 0, 0, 69, 0, - 0, 9, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 16, - 16, 0, 1, 0, 0, 0, - 70, 126, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 69, 0, - 0, 9, 242, 0, 16, 0, - 1, 0, 0, 0, 70, 16, - 16, 0, 1, 0, 0, 0, - 38, 125, 16, 0, 1, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 5, 18, 0, 16, 0, - 1, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 16, 0, 0, 8, - 18, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 16, 0, - 0, 8, 34, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 16, 0, 0, 8, 66, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 4, 0, - 0, 0, 57, 0, 0, 11, - 18, 0, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 31, 0, - 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 29, 0, - 0, 10, 114, 0, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 230, 174, 37, 61, - 230, 174, 37, 61, 230, 174, - 37, 61, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 145, 131, 158, 61, - 145, 131, 158, 61, 145, 131, - 158, 61, 0, 0, 0, 0, - 0, 0, 0, 10, 114, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 174, 71, 97, 61, 174, 71, - 97, 61, 174, 71, 97, 61, - 0, 0, 0, 0, 56, 0, - 0, 11, 114, 0, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 128, 129, 0, 0, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 111, 167, 114, 63, - 111, 167, 114, 63, 111, 167, - 114, 63, 0, 0, 0, 0, - 47, 0, 0, 5, 114, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 154, 153, 25, 64, - 154, 153, 25, 64, 154, 153, - 25, 64, 0, 0, 0, 0, - 25, 0, 0, 5, 114, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 55, 0, 0, 9, - 114, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 21, 0, 0, 1, - 56, 0, 0, 8, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 86, 133, 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, 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, 22, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 13, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 82, 68, - 69, 70, 56, 2, 0, 0, - 1, 0, 0, 0, 204, 0, - 0, 0, 4, 0, 0, 0, - 28, 0, 0, 0, 0, 4, - 255, 255, 0, 1, 0, 0, - 13, 2, 0, 0, 156, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 167, 0, 0, 0, 2, 0, - 0, 0, 5, 0, 0, 0, - 4, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 1, 0, 0, 0, 13, 0, - 0, 0, 179, 0, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 1, 0, - 0, 0, 1, 0, 0, 0, - 13, 0, 0, 0, 192, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 116, 104, 101, 83, 97, 109, - 112, 108, 101, 114, 0, 116, - 104, 101, 84, 101, 120, 116, - 117, 114, 101, 89, 0, 116, - 104, 101, 84, 101, 120, 116, - 117, 114, 101, 85, 86, 0, - 67, 111, 110, 115, 116, 97, - 110, 116, 115, 0, 171, 171, - 192, 0, 0, 0, 8, 0, - 0, 0, 228, 0, 0, 0, - 80, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 164, 1, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 2, 0, 0, 0, 180, 1, - 0, 0, 0, 0, 0, 0, - 196, 1, 0, 0, 4, 0, - 0, 0, 4, 0, 0, 0, - 2, 0, 0, 0, 180, 1, - 0, 0, 0, 0, 0, 0, - 208, 1, 0, 0, 8, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 180, 1, - 0, 0, 0, 0, 0, 0, - 216, 1, 0, 0, 12, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 180, 1, - 0, 0, 0, 0, 0, 0, - 224, 1, 0, 0, 16, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 232, 1, - 0, 0, 0, 0, 0, 0, - 248, 1, 0, 0, 32, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 232, 1, - 0, 0, 0, 0, 0, 0, - 255, 1, 0, 0, 48, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 232, 1, - 0, 0, 0, 0, 0, 0, - 6, 2, 0, 0, 64, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 232, 1, - 0, 0, 0, 0, 0, 0, - 115, 99, 82, 71, 66, 95, - 111, 117, 116, 112, 117, 116, - 0, 171, 171, 171, 0, 0, - 3, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 99, 111, 108, 111, - 114, 95, 115, 99, 97, 108, - 101, 0, 117, 110, 117, 115, - 101, 100, 49, 0, 117, 110, - 117, 115, 101, 100, 50, 0, - 89, 111, 102, 102, 115, 101, - 116, 0, 1, 0, 3, 0, - 1, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 82, 99, 111, 101, 102, 102, - 0, 71, 99, 111, 101, 102, - 102, 0, 66, 99, 111, 101, - 102, 102, 0, 77, 105, 99, - 114, 111, 115, 111, 102, 116, - 32, 40, 82, 41, 32, 72, - 76, 83, 76, 32, 83, 104, - 97, 100, 101, 114, 32, 67, - 111, 109, 112, 105, 108, 101, - 114, 32, 49, 48, 46, 49, - 0, 171, 171, 171, 73, 83, - 71, 78, 108, 0, 0, 0, - 3, 0, 0, 0, 8, 0, - 0, 0, 80, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 92, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 3, 3, - 0, 0, 101, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 15, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 67, - 79, 76, 79, 82, 0, 171, - 79, 83, 71, 78, 44, 0, - 0, 0, 1, 0, 0, 0, - 8, 0, 0, 0, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 83, 86, - 95, 84, 65, 82, 71, 69, - 84, 0, 171, 171 -}; diff --git a/src/render/direct3d11/D3D11_PixelShader_NV12.hlsl b/src/render/direct3d11/D3D11_PixelShader_NV12.hlsl deleted file mode 100644 index f20317385..000000000 --- a/src/render/direct3d11/D3D11_PixelShader_NV12.hlsl +++ /dev/null @@ -1,20 +0,0 @@ -Texture2D theTextureY : register(t0); -Texture2D theTextureUV : register(t1); -SamplerState theSampler : register(s0); - -#include "D3D11_PixelShader_Common.incl" - -float4 main(PixelShaderInput input) : SV_TARGET -{ - float3 yuv; - yuv.x = theTextureY.Sample(theSampler, input.tex).r; - yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg; - - float3 rgb; - yuv += Yoffset.xyz; - rgb.r = dot(yuv, Rcoeff.xyz); - rgb.g = dot(yuv, Gcoeff.xyz); - rgb.b = dot(yuv, Bcoeff.xyz); - - return GetOutputColorFromSRGB(rgb) * input.color; -} diff --git a/src/render/direct3d11/D3D11_PixelShader_NV21.h b/src/render/direct3d11/D3D11_PixelShader_NV21.h deleted file mode 100644 index 3db1d52c2..000000000 --- a/src/render/direct3d11/D3D11_PixelShader_NV21.h +++ /dev/null @@ -1,548 +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 color_scale; // Offset: 4 Size: 4 -// float unused1; // Offset: 8 Size: 4 [unused] -// float unused2; // Offset: 12 Size: 4 [unused] -// float4 Yoffset; // Offset: 16 Size: 16 -// float4 Rcoeff; // Offset: 32 Size: 16 -// float4 Gcoeff; // Offset: 48 Size: 16 -// float4 Bcoeff; // Offset: 64 Size: 16 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim HLSL Bind Count -// ------------------------------ ---------- ------- ----------- -------------- ------ -// theSampler sampler NA NA s0 1 -// theTextureY texture float4 2d t0 1 -// theTextureUV texture float4 2d t1 1 -// Constants cbuffer NA NA cb0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// TEXCOORD 0 xy 1 NONE float xy -// COLOR 0 xyzw 2 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -// -// Constant buffer to DX9 shader constant mappings: -// -// Target Reg Buffer Start Reg # of Regs Data Conversion -// ---------- ------- --------- --------- ---------------------- -// c0 cb0 0 5 ( FLT, FLT, FLT, FLT) -// -// -// Sampler/Resource to DX9 shader sampler mappings: -// -// Target Sampler Source Sampler Source Resource -// -------------- --------------- ---------------- -// s0 s0 t0 -// s1 s0 t1 -// -// -// Level9 shader bytecode: -// - ps_2_0 - def c5, 0.0404499993, 0.0773993805, 0.0549999997, 0.947867334 - def c6, 2.4000001, 1, 0, 0 - dcl t0.xy - dcl t1 - dcl_2d s0 - dcl_2d s1 - texld r0, t0, s0 - texld r1, t0, s1 - mov r0.y, r1.y - mov r0.z, r1.x - add r0.xyz, r0, c1 - dp3 r1.x, r0, c2 - add r0.w, r1.x, c5.z - abs r0.w, r0.w - mul r0.w, r0.w, c5.w - pow r1.w, r0.w, c6.x - add r0.w, -r1.x, c5.x - mul r2.w, r1.x, c5.y - cmp r2.x, r0.w, r2.w, r1.w - dp3 r1.y, r0, c3 - dp3 r1.z, r0, c4 - add r1.w, r1.y, c5.z - abs r1.w, r1.w - mul r1.w, r1.w, c5.w - pow r2.w, r1.w, c6.x - add r1.w, -r1.y, c5.x - mul r0.x, r1.y, c5.y - cmp r2.y, r1.w, r0.x, r2.w - add r1.w, r1.z, c5.z - abs r1.w, r1.w - mul r1.w, r1.w, c5.w - pow r2.w, r1.w, c6.x - add r1.w, -r1.z, c5.x - mul r0.x, r1.z, c5.y - cmp r2.z, r1.w, r0.x, r2.w - mul r1.w, c0.x, c0.x - cmp r0.xyz, -r1.w, r1, r2 - mul r0.xyz, r0, c0.y - mov r0.w, c6.y - mul r0, r0, t1 - mov oC0, r0 - -// approximately 41 instruction slots used (2 texture, 39 arithmetic) -ps_4_0 -dcl_constantbuffer CB0[5], immediateIndexed -dcl_sampler s0, mode_default -dcl_resource_texture2d (float,float,float,float) t0 -dcl_resource_texture2d (float,float,float,float) t1 -dcl_input_ps linear v1.xy -dcl_input_ps linear v2.xyzw -dcl_output o0.xyzw -dcl_temps 4 -sample r0.xyzw, v1.xyxx, t0.xyzw, s0 -sample r1.xyzw, v1.xyxx, t1.zyxw, s0 -mov r1.x, r0.x -add r0.xyz, r1.xyzx, cb0[1].xyzx -dp3 r1.x, r0.xyzx, cb0[2].xyzx -dp3 r1.y, r0.xyzx, cb0[3].xyzx -dp3 r1.z, r0.xyzx, cb0[4].xyzx -ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x -if_nz r0.x - ge r0.xyz, l(0.040450, 0.040450, 0.040450, 0.000000), r1.xyzx - mul r2.xyz, r1.xyzx, l(0.077399, 0.077399, 0.077399, 0.000000) - add r3.xyz, r1.xyzx, l(0.055000, 0.055000, 0.055000, 0.000000) - mul r3.xyz, |r3.xyzx|, l(0.947867, 0.947867, 0.947867, 0.000000) - log r3.xyz, r3.xyzx - mul r3.xyz, r3.xyzx, l(2.400000, 2.400000, 2.400000, 0.000000) - exp r3.xyz, r3.xyzx - movc r1.xyz, r0.xyzx, r2.xyzx, r3.xyzx -endif -mul r0.xyz, r1.xyzx, cb0[0].yyyy -mov r0.w, l(1.000000) -mul o0.xyzw, r0.xyzw, v2.xyzw -ret -// Approximately 22 instruction slots used -#endif - -const BYTE g_main[] = -{ - 68, 88, 66, 67, 150, 187, - 194, 202, 50, 132, 111, 243, - 88, 169, 196, 166, 186, 146, - 56, 89, 1, 0, 0, 0, - 100, 9, 0, 0, 6, 0, - 0, 0, 56, 0, 0, 0, - 4, 3, 0, 0, 0, 6, - 0, 0, 124, 6, 0, 0, - 188, 8, 0, 0, 48, 9, - 0, 0, 65, 111, 110, 57, - 196, 2, 0, 0, 196, 2, - 0, 0, 0, 2, 255, 255, - 140, 2, 0, 0, 56, 0, - 0, 0, 1, 0, 44, 0, - 0, 0, 56, 0, 0, 0, - 56, 0, 2, 0, 36, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 0, 0, 0, 0, - 0, 2, 255, 255, 81, 0, - 0, 5, 5, 0, 15, 160, - 230, 174, 37, 61, 145, 131, - 158, 61, 174, 71, 97, 61, - 111, 167, 114, 63, 81, 0, - 0, 5, 6, 0, 15, 160, - 154, 153, 25, 64, 0, 0, - 128, 63, 0, 0, 0, 0, - 0, 0, 0, 0, 31, 0, - 0, 2, 0, 0, 0, 128, - 0, 0, 3, 176, 31, 0, - 0, 2, 0, 0, 0, 128, - 1, 0, 15, 176, 31, 0, - 0, 2, 0, 0, 0, 144, - 0, 8, 15, 160, 31, 0, - 0, 2, 0, 0, 0, 144, - 1, 8, 15, 160, 66, 0, - 0, 3, 0, 0, 15, 128, - 0, 0, 228, 176, 0, 8, - 228, 160, 66, 0, 0, 3, - 1, 0, 15, 128, 0, 0, - 228, 176, 1, 8, 228, 160, - 1, 0, 0, 2, 0, 0, - 2, 128, 1, 0, 85, 128, - 1, 0, 0, 2, 0, 0, - 4, 128, 1, 0, 0, 128, - 2, 0, 0, 3, 0, 0, - 7, 128, 0, 0, 228, 128, - 1, 0, 228, 160, 8, 0, - 0, 3, 1, 0, 1, 128, - 0, 0, 228, 128, 2, 0, - 228, 160, 2, 0, 0, 3, - 0, 0, 8, 128, 1, 0, - 0, 128, 5, 0, 170, 160, - 35, 0, 0, 2, 0, 0, - 8, 128, 0, 0, 255, 128, - 5, 0, 0, 3, 0, 0, - 8, 128, 0, 0, 255, 128, - 5, 0, 255, 160, 32, 0, - 0, 3, 1, 0, 8, 128, - 0, 0, 255, 128, 6, 0, - 0, 160, 2, 0, 0, 3, - 0, 0, 8, 128, 1, 0, - 0, 129, 5, 0, 0, 160, - 5, 0, 0, 3, 2, 0, - 8, 128, 1, 0, 0, 128, - 5, 0, 85, 160, 88, 0, - 0, 4, 2, 0, 1, 128, - 0, 0, 255, 128, 2, 0, - 255, 128, 1, 0, 255, 128, - 8, 0, 0, 3, 1, 0, - 2, 128, 0, 0, 228, 128, - 3, 0, 228, 160, 8, 0, - 0, 3, 1, 0, 4, 128, - 0, 0, 228, 128, 4, 0, - 228, 160, 2, 0, 0, 3, - 1, 0, 8, 128, 1, 0, - 85, 128, 5, 0, 170, 160, - 35, 0, 0, 2, 1, 0, - 8, 128, 1, 0, 255, 128, - 5, 0, 0, 3, 1, 0, - 8, 128, 1, 0, 255, 128, - 5, 0, 255, 160, 32, 0, - 0, 3, 2, 0, 8, 128, - 1, 0, 255, 128, 6, 0, - 0, 160, 2, 0, 0, 3, - 1, 0, 8, 128, 1, 0, - 85, 129, 5, 0, 0, 160, - 5, 0, 0, 3, 0, 0, - 1, 128, 1, 0, 85, 128, - 5, 0, 85, 160, 88, 0, - 0, 4, 2, 0, 2, 128, - 1, 0, 255, 128, 0, 0, - 0, 128, 2, 0, 255, 128, - 2, 0, 0, 3, 1, 0, - 8, 128, 1, 0, 170, 128, - 5, 0, 170, 160, 35, 0, - 0, 2, 1, 0, 8, 128, - 1, 0, 255, 128, 5, 0, - 0, 3, 1, 0, 8, 128, - 1, 0, 255, 128, 5, 0, - 255, 160, 32, 0, 0, 3, - 2, 0, 8, 128, 1, 0, - 255, 128, 6, 0, 0, 160, - 2, 0, 0, 3, 1, 0, - 8, 128, 1, 0, 170, 129, - 5, 0, 0, 160, 5, 0, - 0, 3, 0, 0, 1, 128, - 1, 0, 170, 128, 5, 0, - 85, 160, 88, 0, 0, 4, - 2, 0, 4, 128, 1, 0, - 255, 128, 0, 0, 0, 128, - 2, 0, 255, 128, 5, 0, - 0, 3, 1, 0, 8, 128, - 0, 0, 0, 160, 0, 0, - 0, 160, 88, 0, 0, 4, - 0, 0, 7, 128, 1, 0, - 255, 129, 1, 0, 228, 128, - 2, 0, 228, 128, 5, 0, - 0, 3, 0, 0, 7, 128, - 0, 0, 228, 128, 0, 0, - 85, 160, 1, 0, 0, 2, - 0, 0, 8, 128, 6, 0, - 85, 160, 5, 0, 0, 3, - 0, 0, 15, 128, 0, 0, - 228, 128, 1, 0, 228, 176, - 1, 0, 0, 2, 0, 8, - 15, 128, 0, 0, 228, 128, - 255, 255, 0, 0, 83, 72, - 68, 82, 244, 2, 0, 0, - 64, 0, 0, 0, 189, 0, - 0, 0, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 90, 0, 0, 3, 0, 96, - 16, 0, 0, 0, 0, 0, - 88, 24, 0, 4, 0, 112, - 16, 0, 0, 0, 0, 0, - 85, 85, 0, 0, 88, 24, - 0, 4, 0, 112, 16, 0, - 1, 0, 0, 0, 85, 85, - 0, 0, 98, 16, 0, 3, - 50, 16, 16, 0, 1, 0, - 0, 0, 98, 16, 0, 3, - 242, 16, 16, 0, 2, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 104, 0, 0, 2, - 4, 0, 0, 0, 69, 0, - 0, 9, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 16, - 16, 0, 1, 0, 0, 0, - 70, 126, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 69, 0, - 0, 9, 242, 0, 16, 0, - 1, 0, 0, 0, 70, 16, - 16, 0, 1, 0, 0, 0, - 102, 124, 16, 0, 1, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 5, 18, 0, 16, 0, - 1, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 8, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 16, 0, 0, 8, - 18, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 16, 0, - 0, 8, 34, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 16, 0, 0, 8, 66, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 4, 0, - 0, 0, 57, 0, 0, 11, - 18, 0, 16, 0, 0, 0, - 0, 0, 2, 64, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 10, 128, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 31, 0, - 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 29, 0, - 0, 10, 114, 0, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 230, 174, 37, 61, - 230, 174, 37, 61, 230, 174, - 37, 61, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 145, 131, 158, 61, - 145, 131, 158, 61, 145, 131, - 158, 61, 0, 0, 0, 0, - 0, 0, 0, 10, 114, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 2, 64, 0, 0, - 174, 71, 97, 61, 174, 71, - 97, 61, 174, 71, 97, 61, - 0, 0, 0, 0, 56, 0, - 0, 11, 114, 0, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 128, 129, 0, 0, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 111, 167, 114, 63, - 111, 167, 114, 63, 111, 167, - 114, 63, 0, 0, 0, 0, - 47, 0, 0, 5, 114, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 56, 0, 0, 10, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 2, 64, - 0, 0, 154, 153, 25, 64, - 154, 153, 25, 64, 154, 153, - 25, 64, 0, 0, 0, 0, - 25, 0, 0, 5, 114, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 55, 0, 0, 9, - 114, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 70, 2, 16, 0, 3, 0, - 0, 0, 21, 0, 0, 1, - 56, 0, 0, 8, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 86, 133, 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, 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, 22, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 13, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 82, 68, - 69, 70, 56, 2, 0, 0, - 1, 0, 0, 0, 204, 0, - 0, 0, 4, 0, 0, 0, - 28, 0, 0, 0, 0, 4, - 255, 255, 0, 1, 0, 0, - 13, 2, 0, 0, 156, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 167, 0, 0, 0, 2, 0, - 0, 0, 5, 0, 0, 0, - 4, 0, 0, 0, 255, 255, - 255, 255, 0, 0, 0, 0, - 1, 0, 0, 0, 13, 0, - 0, 0, 179, 0, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 1, 0, - 0, 0, 1, 0, 0, 0, - 13, 0, 0, 0, 192, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, - 116, 104, 101, 83, 97, 109, - 112, 108, 101, 114, 0, 116, - 104, 101, 84, 101, 120, 116, - 117, 114, 101, 89, 0, 116, - 104, 101, 84, 101, 120, 116, - 117, 114, 101, 85, 86, 0, - 67, 111, 110, 115, 116, 97, - 110, 116, 115, 0, 171, 171, - 192, 0, 0, 0, 8, 0, - 0, 0, 228, 0, 0, 0, - 80, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 164, 1, 0, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 2, 0, 0, 0, 180, 1, - 0, 0, 0, 0, 0, 0, - 196, 1, 0, 0, 4, 0, - 0, 0, 4, 0, 0, 0, - 2, 0, 0, 0, 180, 1, - 0, 0, 0, 0, 0, 0, - 208, 1, 0, 0, 8, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 180, 1, - 0, 0, 0, 0, 0, 0, - 216, 1, 0, 0, 12, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 180, 1, - 0, 0, 0, 0, 0, 0, - 224, 1, 0, 0, 16, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 232, 1, - 0, 0, 0, 0, 0, 0, - 248, 1, 0, 0, 32, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 232, 1, - 0, 0, 0, 0, 0, 0, - 255, 1, 0, 0, 48, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 232, 1, - 0, 0, 0, 0, 0, 0, - 6, 2, 0, 0, 64, 0, - 0, 0, 16, 0, 0, 0, - 2, 0, 0, 0, 232, 1, - 0, 0, 0, 0, 0, 0, - 115, 99, 82, 71, 66, 95, - 111, 117, 116, 112, 117, 116, - 0, 171, 171, 171, 0, 0, - 3, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 99, 111, 108, 111, - 114, 95, 115, 99, 97, 108, - 101, 0, 117, 110, 117, 115, - 101, 100, 49, 0, 117, 110, - 117, 115, 101, 100, 50, 0, - 89, 111, 102, 102, 115, 101, - 116, 0, 1, 0, 3, 0, - 1, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 82, 99, 111, 101, 102, 102, - 0, 71, 99, 111, 101, 102, - 102, 0, 66, 99, 111, 101, - 102, 102, 0, 77, 105, 99, - 114, 111, 115, 111, 102, 116, - 32, 40, 82, 41, 32, 72, - 76, 83, 76, 32, 83, 104, - 97, 100, 101, 114, 32, 67, - 111, 109, 112, 105, 108, 101, - 114, 32, 49, 48, 46, 49, - 0, 171, 171, 171, 73, 83, - 71, 78, 108, 0, 0, 0, - 3, 0, 0, 0, 8, 0, - 0, 0, 80, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 92, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 3, 3, - 0, 0, 101, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 15, 15, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 67, - 79, 76, 79, 82, 0, 171, - 79, 83, 71, 78, 44, 0, - 0, 0, 1, 0, 0, 0, - 8, 0, 0, 0, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 83, 86, - 95, 84, 65, 82, 71, 69, - 84, 0, 171, 171 -}; diff --git a/src/render/direct3d11/D3D11_PixelShader_NV21.hlsl b/src/render/direct3d11/D3D11_PixelShader_NV21.hlsl deleted file mode 100644 index bea988b73..000000000 --- a/src/render/direct3d11/D3D11_PixelShader_NV21.hlsl +++ /dev/null @@ -1,20 +0,0 @@ -Texture2D theTextureY : register(t0); -Texture2D theTextureUV : register(t1); -SamplerState theSampler : register(s0); - -#include "D3D11_PixelShader_Common.incl" - -float4 main(PixelShaderInput input) : SV_TARGET -{ - float3 yuv; - yuv.x = theTextureY.Sample(theSampler, input.tex).r; - yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr; - - float3 rgb; - yuv += Yoffset.xyz; - rgb.r = dot(yuv, Rcoeff.xyz); - rgb.g = dot(yuv, Gcoeff.xyz); - rgb.b = dot(yuv, Bcoeff.xyz); - - return GetOutputColorFromSRGB(rgb) * input.color; -} diff --git a/src/render/direct3d11/D3D11_PixelShader_Textures.h b/src/render/direct3d11/D3D11_PixelShader_Textures.h index 8103dbdb8..996cac622 100644 --- a/src/render/direct3d11/D3D11_PixelShader_Textures.h +++ b/src/render/direct3d11/D3D11_PixelShader_Textures.h @@ -9,13 +9,17 @@ // { // // float scRGB_output; // Offset: 0 Size: 4 [unused] -// float color_scale; // Offset: 4 Size: 4 -// float unused1; // Offset: 8 Size: 4 [unused] -// float unused2; // Offset: 12 Size: 4 [unused] -// float4 Yoffset; // Offset: 16 Size: 16 [unused] -// float4 Rcoeff; // Offset: 32 Size: 16 [unused] -// float4 Gcoeff; // Offset: 48 Size: 16 [unused] -// float4 Bcoeff; // Offset: 64 Size: 16 [unused] +// 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] // // } // @@ -67,7 +71,7 @@ dcl t1 dcl_2d s0 texld r0, t0, s0 - mul r0.xyz, r0, c0.y + mul r0.xyz, r0, c0.w mul r0, r0, t1 mov oC0, r0 @@ -81,7 +85,7 @@ 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].yyyy +mul r0.xyz, r0.xyzx, cb0[0].wwww mul o0.xyzw, r0.xyzw, v2.xyzw ret // Approximately 4 instruction slots used @@ -89,15 +93,15 @@ ret const BYTE g_main[] = { - 68, 88, 66, 67, 159, 171, - 49, 134, 139, 171, 105, 34, - 166, 1, 101, 132, 110, 4, - 121, 76, 1, 0, 0, 0, - 220, 4, 0, 0, 6, 0, + 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, - 52, 4, 0, 0, 168, 4, + 220, 4, 0, 0, 80, 5, 0, 0, 65, 111, 110, 57, 156, 0, 0, 0, 156, 0, 0, 0, 0, 2, 255, 255, @@ -120,7 +124,7 @@ const BYTE g_main[] = 0, 8, 228, 160, 5, 0, 0, 3, 0, 0, 7, 128, 0, 0, 228, 128, 0, 0, - 85, 160, 5, 0, 0, 3, + 255, 160, 5, 0, 0, 3, 0, 0, 15, 128, 0, 0, 228, 128, 1, 0, 228, 176, 1, 0, 0, 2, 0, 8, @@ -152,7 +156,7 @@ const BYTE g_main[] = 56, 0, 0, 8, 114, 0, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 0, 0, - 0, 0, 86, 133, 32, 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, @@ -181,11 +185,11 @@ const BYTE g_main[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 68, 69, 70, - 8, 2, 0, 0, 1, 0, + 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, 221, 1, + 0, 1, 0, 0, 133, 2, 0, 0, 124, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -208,53 +212,81 @@ const BYTE g_main[] = 120, 116, 117, 114, 101, 0, 67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 146, 0, - 0, 0, 8, 0, 0, 0, - 180, 0, 0, 0, 80, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 116, 1, - 0, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 132, 1, 0, 0, - 0, 0, 0, 0, 148, 1, - 0, 0, 4, 0, 0, 0, - 4, 0, 0, 0, 2, 0, - 0, 0, 132, 1, 0, 0, - 0, 0, 0, 0, 160, 1, - 0, 0, 8, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 132, 1, 0, 0, - 0, 0, 0, 0, 168, 1, 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, 132, 1, 0, 0, - 0, 0, 0, 0, 176, 1, + 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, - 16, 0, 0, 0, 0, 0, - 0, 0, 184, 1, 0, 0, - 0, 0, 0, 0, 200, 1, + 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, 184, 1, 0, 0, - 0, 0, 0, 0, 207, 1, + 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, 184, 1, 0, 0, - 0, 0, 0, 0, 214, 1, + 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, 184, 1, 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, - 117, 110, 117, 115, 101, 100, - 49, 0, 117, 110, 117, 115, - 101, 100, 50, 0, 89, 111, - 102, 102, 115, 101, 116, 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, diff --git a/src/render/direct3d11/D3D11_PixelShader_YUV.h b/src/render/direct3d11/D3D11_PixelShader_YUV.h deleted file mode 100644 index 158763bf7..000000000 --- a/src/render/direct3d11/D3D11_PixelShader_YUV.h +++ /dev/null @@ -1,580 +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 color_scale; // Offset: 4 Size: 4 -// float unused1; // Offset: 8 Size: 4 [unused] -// float unused2; // Offset: 12 Size: 4 [unused] -// float4 Yoffset; // Offset: 16 Size: 16 -// float4 Rcoeff; // Offset: 32 Size: 16 -// float4 Gcoeff; // Offset: 48 Size: 16 -// float4 Bcoeff; // Offset: 64 Size: 16 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim HLSL Bind Count -// ------------------------------ ---------- ------- ----------- -------------- ------ -// theSampler sampler NA NA s0 1 -// theTextureY texture float4 2d t0 1 -// theTextureU texture float4 2d t1 1 -// theTextureV texture float4 2d t2 1 -// Constants cbuffer NA NA cb0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// TEXCOORD 0 xy 1 NONE float xy -// COLOR 0 xyzw 2 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -// -// Constant buffer to DX9 shader constant mappings: -// -// Target Reg Buffer Start Reg # of Regs Data Conversion -// ---------- ------- --------- --------- ---------------------- -// c0 cb0 0 5 ( FLT, FLT, FLT, FLT) -// -// -// Sampler/Resource to DX9 shader sampler mappings: -// -// Target Sampler Source Sampler Source Resource -// -------------- --------------- ---------------- -// s0 s0 t0 -// s1 s0 t1 -// s2 s0 t2 -// -// -// Level9 shader bytecode: -// - ps_2_0 - def c5, 0.0404499993, 0.0773993805, 0.0549999997, 0.947867334 - def c6, 2.4000001, 1, 0, 0 - dcl t0.xy - dcl t1 - dcl_2d s0 - dcl_2d s1 - dcl_2d s2 - texld r0, t0, s0 - texld r1, t0, s1 - texld r2, t0, s2 - mov r0.y, r1.x - mov r0.z, r2.x - add r0.xyz, r0, c1 - dp3 r1.x, r0, c2 - add r0.w, r1.x, c5.z - abs r0.w, r0.w - mul r0.w, r0.w, c5.w - pow r1.w, r0.w, c6.x - add r0.w, -r1.x, c5.x - mul r2.x, r1.x, c5.y - cmp r2.x, r0.w, r2.x, r1.w - dp3 r1.y, r0, c3 - dp3 r1.z, r0, c4 - add r1.w, r1.y, c5.z - abs r1.w, r1.w - mul r1.w, r1.w, c5.w - pow r2.w, r1.w, c6.x - add r1.w, -r1.y, c5.x - mul r0.x, r1.y, c5.y - cmp r2.y, r1.w, r0.x, r2.w - add r1.w, r1.z, c5.z - abs r1.w, r1.w - mul r1.w, r1.w, c5.w - pow r2.w, r1.w, c6.x - add r1.w, -r1.z, c5.x - mul r0.x, r1.z, c5.y - cmp r2.z, r1.w, r0.x, r2.w - mul r1.w, c0.x, c0.x - cmp r0.xyz, -r1.w, r1, r2 - mul r0.xyz, r0, c0.y - mov r0.w, c6.y - mul r0, r0, t1 - mov oC0, r0 - -// approximately 42 instruction slots used (3 texture, 39 arithmetic) -ps_4_0 -dcl_constantbuffer CB0[5], immediateIndexed -dcl_sampler s0, mode_default -dcl_resource_texture2d (float,float,float,float) t0 -dcl_resource_texture2d (float,float,float,float) t1 -dcl_resource_texture2d (float,float,float,float) t2 -dcl_input_ps linear v1.xy -dcl_input_ps linear v2.xyzw -dcl_output o0.xyzw -dcl_temps 4 -sample r0.xyzw, v1.xyxx, t0.xyzw, s0 -sample r1.xyzw, v1.xyxx, t1.xyzw, s0 -sample r2.xyzw, v1.xyxx, t2.yzxw, s0 -mov r2.x, r0.x -mov r2.y, r1.x -add r0.xyz, r2.xyzx, cb0[1].xyzx -dp3 r1.x, r0.xyzx, cb0[2].xyzx -dp3 r1.y, r0.xyzx, cb0[3].xyzx -dp3 r1.z, r0.xyzx, cb0[4].xyzx -ne r0.x, l(0.000000, 0.000000, 0.000000, 0.000000), cb0[0].x -if_nz r0.x - ge r0.xyz, l(0.040450, 0.040450, 0.040450, 0.000000), r1.xyzx - mul r2.xyz, r1.xyzx, l(0.077399, 0.077399, 0.077399, 0.000000) - add r3.xyz, r1.xyzx, l(0.055000, 0.055000, 0.055000, 0.000000) - mul r3.xyz, |r3.xyzx|, l(0.947867, 0.947867, 0.947867, 0.000000) - log r3.xyz, r3.xyzx - mul r3.xyz, r3.xyzx, l(2.400000, 2.400000, 2.400000, 0.000000) - exp r3.xyz, r3.xyzx - movc r1.xyz, r0.xyzx, r2.xyzx, r3.xyzx -endif -mul r0.xyz, r1.xyzx, cb0[0].yyyy -mov r0.w, l(1.000000) -mul o0.xyzw, r0.xyzw, v2.xyzw -ret -// Approximately 24 instruction slots used -#endif - -const BYTE g_main[] = -{ - 68, 88, 66, 67, 84, 14, - 232, 134, 42, 204, 66, 203, - 56, 83, 173, 74, 161, 2, - 47, 168, 1, 0, 0, 0, - 248, 9, 0, 0, 6, 0, - 0, 0, 56, 0, 0, 0, - 36, 3, 0, 0, 104, 6, - 0, 0, 228, 6, 0, 0, - 80, 9, 0, 0, 196, 9, - 0, 0, 65, 111, 110, 57, - 228, 2, 0, 0, 228, 2, - 0, 0, 0, 2, 255, 255, - 168, 2, 0, 0, 60, 0, - 0, 0, 1, 0, 48, 0, - 0, 0, 60, 0, 0, 0, - 60, 0, 3, 0, 36, 0, - 0, 0, 60, 0, 0, 0, - 0, 0, 1, 0, 1, 0, - 2, 0, 2, 0, 0, 0, - 0, 0, 5, 0, 0, 0, - 0, 0, 0, 0, 0, 2, - 255, 255, 81, 0, 0, 5, - 5, 0, 15, 160, 230, 174, - 37, 61, 145, 131, 158, 61, - 174, 71, 97, 61, 111, 167, - 114, 63, 81, 0, 0, 5, - 6, 0, 15, 160, 154, 153, - 25, 64, 0, 0, 128, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 31, 0, 0, 2, - 0, 0, 0, 128, 0, 0, - 3, 176, 31, 0, 0, 2, - 0, 0, 0, 128, 1, 0, - 15, 176, 31, 0, 0, 2, - 0, 0, 0, 144, 0, 8, - 15, 160, 31, 0, 0, 2, - 0, 0, 0, 144, 1, 8, - 15, 160, 31, 0, 0, 2, - 0, 0, 0, 144, 2, 8, - 15, 160, 66, 0, 0, 3, - 0, 0, 15, 128, 0, 0, - 228, 176, 0, 8, 228, 160, - 66, 0, 0, 3, 1, 0, - 15, 128, 0, 0, 228, 176, - 1, 8, 228, 160, 66, 0, - 0, 3, 2, 0, 15, 128, - 0, 0, 228, 176, 2, 8, - 228, 160, 1, 0, 0, 2, - 0, 0, 2, 128, 1, 0, - 0, 128, 1, 0, 0, 2, - 0, 0, 4, 128, 2, 0, - 0, 128, 2, 0, 0, 3, - 0, 0, 7, 128, 0, 0, - 228, 128, 1, 0, 228, 160, - 8, 0, 0, 3, 1, 0, - 1, 128, 0, 0, 228, 128, - 2, 0, 228, 160, 2, 0, - 0, 3, 0, 0, 8, 128, - 1, 0, 0, 128, 5, 0, - 170, 160, 35, 0, 0, 2, - 0, 0, 8, 128, 0, 0, - 255, 128, 5, 0, 0, 3, - 0, 0, 8, 128, 0, 0, - 255, 128, 5, 0, 255, 160, - 32, 0, 0, 3, 1, 0, - 8, 128, 0, 0, 255, 128, - 6, 0, 0, 160, 2, 0, - 0, 3, 0, 0, 8, 128, - 1, 0, 0, 129, 5, 0, - 0, 160, 5, 0, 0, 3, - 2, 0, 1, 128, 1, 0, - 0, 128, 5, 0, 85, 160, - 88, 0, 0, 4, 2, 0, - 1, 128, 0, 0, 255, 128, - 2, 0, 0, 128, 1, 0, - 255, 128, 8, 0, 0, 3, - 1, 0, 2, 128, 0, 0, - 228, 128, 3, 0, 228, 160, - 8, 0, 0, 3, 1, 0, - 4, 128, 0, 0, 228, 128, - 4, 0, 228, 160, 2, 0, - 0, 3, 1, 0, 8, 128, - 1, 0, 85, 128, 5, 0, - 170, 160, 35, 0, 0, 2, - 1, 0, 8, 128, 1, 0, - 255, 128, 5, 0, 0, 3, - 1, 0, 8, 128, 1, 0, - 255, 128, 5, 0, 255, 160, - 32, 0, 0, 3, 2, 0, - 8, 128, 1, 0, 255, 128, - 6, 0, 0, 160, 2, 0, - 0, 3, 1, 0, 8, 128, - 1, 0, 85, 129, 5, 0, - 0, 160, 5, 0, 0, 3, - 0, 0, 1, 128, 1, 0, - 85, 128, 5, 0, 85, 160, - 88, 0, 0, 4, 2, 0, - 2, 128, 1, 0, 255, 128, - 0, 0, 0, 128, 2, 0, - 255, 128, 2, 0, 0, 3, - 1, 0, 8, 128, 1, 0, - 170, 128, 5, 0, 170, 160, - 35, 0, 0, 2, 1, 0, - 8, 128, 1, 0, 255, 128, - 5, 0, 0, 3, 1, 0, - 8, 128, 1, 0, 255, 128, - 5, 0, 255, 160, 32, 0, - 0, 3, 2, 0, 8, 128, - 1, 0, 255, 128, 6, 0, - 0, 160, 2, 0, 0, 3, - 1, 0, 8, 128, 1, 0, - 170, 129, 5, 0, 0, 160, - 5, 0, 0, 3, 0, 0, - 1, 128, 1, 0, 170, 128, - 5, 0, 85, 160, 88, 0, - 0, 4, 2, 0, 4, 128, - 1, 0, 255, 128, 0, 0, - 0, 128, 2, 0, 255, 128, - 5, 0, 0, 3, 1, 0, - 8, 128, 0, 0, 0, 160, - 0, 0, 0, 160, 88, 0, - 0, 4, 0, 0, 7, 128, - 1, 0, 255, 129, 1, 0, - 228, 128, 2, 0, 228, 128, - 5, 0, 0, 3, 0, 0, - 7, 128, 0, 0, 228, 128, - 0, 0, 85, 160, 1, 0, - 0, 2, 0, 0, 8, 128, - 6, 0, 85, 160, 5, 0, - 0, 3, 0, 0, 15, 128, - 0, 0, 228, 128, 1, 0, - 228, 176, 1, 0, 0, 2, - 0, 8, 15, 128, 0, 0, - 228, 128, 255, 255, 0, 0, - 83, 72, 68, 82, 60, 3, - 0, 0, 64, 0, 0, 0, - 207, 0, 0, 0, 89, 0, - 0, 4, 70, 142, 32, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 90, 0, 0, 3, - 0, 96, 16, 0, 0, 0, - 0, 0, 88, 24, 0, 4, - 0, 112, 16, 0, 0, 0, - 0, 0, 85, 85, 0, 0, - 88, 24, 0, 4, 0, 112, - 16, 0, 1, 0, 0, 0, - 85, 85, 0, 0, 88, 24, - 0, 4, 0, 112, 16, 0, - 2, 0, 0, 0, 85, 85, - 0, 0, 98, 16, 0, 3, - 50, 16, 16, 0, 1, 0, - 0, 0, 98, 16, 0, 3, - 242, 16, 16, 0, 2, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 104, 0, 0, 2, - 4, 0, 0, 0, 69, 0, - 0, 9, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 16, - 16, 0, 1, 0, 0, 0, - 70, 126, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 69, 0, - 0, 9, 242, 0, 16, 0, - 1, 0, 0, 0, 70, 16, - 16, 0, 1, 0, 0, 0, - 70, 126, 16, 0, 1, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 69, 0, - 0, 9, 242, 0, 16, 0, - 2, 0, 0, 0, 70, 16, - 16, 0, 1, 0, 0, 0, - 150, 124, 16, 0, 2, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 54, 0, - 0, 5, 18, 0, 16, 0, - 2, 0, 0, 0, 10, 0, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 5, 34, 0, - 16, 0, 2, 0, 0, 0, - 10, 0, 16, 0, 1, 0, - 0, 0, 0, 0, 0, 8, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 16, 0, - 0, 8, 18, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 16, 0, 0, 8, 34, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 16, 0, 0, 8, - 66, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 57, 0, - 0, 11, 18, 0, 16, 0, - 0, 0, 0, 0, 2, 64, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 10, 128, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 31, 0, 4, 3, 10, 0, - 16, 0, 0, 0, 0, 0, - 29, 0, 0, 10, 114, 0, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 230, 174, - 37, 61, 230, 174, 37, 61, - 230, 174, 37, 61, 0, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 56, 0, - 0, 10, 114, 0, 16, 0, - 2, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 2, 64, 0, 0, 145, 131, - 158, 61, 145, 131, 158, 61, - 145, 131, 158, 61, 0, 0, - 0, 0, 0, 0, 0, 10, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 2, 64, - 0, 0, 174, 71, 97, 61, - 174, 71, 97, 61, 174, 71, - 97, 61, 0, 0, 0, 0, - 56, 0, 0, 11, 114, 0, - 16, 0, 3, 0, 0, 0, - 70, 2, 16, 128, 129, 0, - 0, 0, 3, 0, 0, 0, - 2, 64, 0, 0, 111, 167, - 114, 63, 111, 167, 114, 63, - 111, 167, 114, 63, 0, 0, - 0, 0, 47, 0, 0, 5, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 56, 0, - 0, 10, 114, 0, 16, 0, - 3, 0, 0, 0, 70, 2, - 16, 0, 3, 0, 0, 0, - 2, 64, 0, 0, 154, 153, - 25, 64, 154, 153, 25, 64, - 154, 153, 25, 64, 0, 0, - 0, 0, 25, 0, 0, 5, - 114, 0, 16, 0, 3, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 55, 0, - 0, 9, 114, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 3, 0, 0, 0, 21, 0, - 0, 1, 56, 0, 0, 8, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 86, 133, - 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, - 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, 24, 0, - 0, 0, 4, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 13, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 82, 68, 69, 70, 100, 2, - 0, 0, 1, 0, 0, 0, - 248, 0, 0, 0, 5, 0, - 0, 0, 28, 0, 0, 0, - 0, 4, 255, 255, 0, 1, - 0, 0, 57, 2, 0, 0, - 188, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 1, 0, - 0, 0, 199, 0, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 1, 0, 0, 0, - 13, 0, 0, 0, 211, 0, - 0, 0, 2, 0, 0, 0, - 5, 0, 0, 0, 4, 0, - 0, 0, 255, 255, 255, 255, - 1, 0, 0, 0, 1, 0, - 0, 0, 13, 0, 0, 0, - 223, 0, 0, 0, 2, 0, - 0, 0, 5, 0, 0, 0, - 4, 0, 0, 0, 255, 255, - 255, 255, 2, 0, 0, 0, - 1, 0, 0, 0, 13, 0, - 0, 0, 235, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 116, 104, - 101, 83, 97, 109, 112, 108, - 101, 114, 0, 116, 104, 101, - 84, 101, 120, 116, 117, 114, - 101, 89, 0, 116, 104, 101, - 84, 101, 120, 116, 117, 114, - 101, 85, 0, 116, 104, 101, - 84, 101, 120, 116, 117, 114, - 101, 86, 0, 67, 111, 110, - 115, 116, 97, 110, 116, 115, - 0, 171, 171, 171, 235, 0, - 0, 0, 8, 0, 0, 0, - 16, 1, 0, 0, 80, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 208, 1, - 0, 0, 0, 0, 0, 0, - 4, 0, 0, 0, 2, 0, - 0, 0, 224, 1, 0, 0, - 0, 0, 0, 0, 240, 1, - 0, 0, 4, 0, 0, 0, - 4, 0, 0, 0, 2, 0, - 0, 0, 224, 1, 0, 0, - 0, 0, 0, 0, 252, 1, - 0, 0, 8, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 224, 1, 0, 0, - 0, 0, 0, 0, 4, 2, - 0, 0, 12, 0, 0, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 224, 1, 0, 0, - 0, 0, 0, 0, 12, 2, - 0, 0, 16, 0, 0, 0, - 16, 0, 0, 0, 2, 0, - 0, 0, 20, 2, 0, 0, - 0, 0, 0, 0, 36, 2, - 0, 0, 32, 0, 0, 0, - 16, 0, 0, 0, 2, 0, - 0, 0, 20, 2, 0, 0, - 0, 0, 0, 0, 43, 2, - 0, 0, 48, 0, 0, 0, - 16, 0, 0, 0, 2, 0, - 0, 0, 20, 2, 0, 0, - 0, 0, 0, 0, 50, 2, - 0, 0, 64, 0, 0, 0, - 16, 0, 0, 0, 2, 0, - 0, 0, 20, 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, - 99, 111, 108, 111, 114, 95, - 115, 99, 97, 108, 101, 0, - 117, 110, 117, 115, 101, 100, - 49, 0, 117, 110, 117, 115, - 101, 100, 50, 0, 89, 111, - 102, 102, 115, 101, 116, 0, - 1, 0, 3, 0, 1, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 82, 99, - 111, 101, 102, 102, 0, 71, - 99, 111, 101, 102, 102, 0, - 66, 99, 111, 101, 102, 102, - 0, 77, 105, 99, 114, 111, - 115, 111, 102, 116, 32, 40, - 82, 41, 32, 72, 76, 83, - 76, 32, 83, 104, 97, 100, - 101, 114, 32, 67, 111, 109, - 112, 105, 108, 101, 114, 32, - 49, 48, 46, 49, 0, 171, - 171, 171, 73, 83, 71, 78, - 108, 0, 0, 0, 3, 0, - 0, 0, 8, 0, 0, 0, - 80, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 92, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 3, 3, 0, 0, - 101, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 2, 0, - 0, 0, 15, 15, 0, 0, - 83, 86, 95, 80, 79, 83, - 73, 84, 73, 79, 78, 0, - 84, 69, 88, 67, 79, 79, - 82, 68, 0, 67, 79, 76, - 79, 82, 0, 171, 79, 83, - 71, 78, 44, 0, 0, 0, - 1, 0, 0, 0, 8, 0, - 0, 0, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 84, - 65, 82, 71, 69, 84, 0, - 171, 171 -}; diff --git a/src/render/direct3d11/D3D11_PixelShader_YUV.hlsl b/src/render/direct3d11/D3D11_PixelShader_YUV.hlsl deleted file mode 100644 index 7af854289..000000000 --- a/src/render/direct3d11/D3D11_PixelShader_YUV.hlsl +++ /dev/null @@ -1,22 +0,0 @@ -Texture2D theTextureY : register(t0); -Texture2D theTextureU : register(t1); -Texture2D theTextureV : register(t2); -SamplerState theSampler : register(s0); - -#include "D3D11_PixelShader_Common.incl" - -float4 main(PixelShaderInput input) : SV_TARGET -{ - float3 yuv; - yuv.x = theTextureY.Sample(theSampler, input.tex).r; - yuv.y = theTextureU.Sample(theSampler, input.tex).r; - yuv.z = theTextureV.Sample(theSampler, input.tex).r; - - float3 rgb; - yuv += Yoffset.xyz; - rgb.r = dot(yuv, Rcoeff.xyz); - rgb.g = dot(yuv, Gcoeff.xyz); - rgb.b = dot(yuv, Bcoeff.xyz); - - return GetOutputColorFromSRGB(rgb) * input.color; -} diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 358e1318e..c875285aa 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -75,21 +75,41 @@ typedef struct Float4X4 projectionAndView; } VertexShaderConstants; +/* These should mirror the definitions in D3D11_PixelShader_Common.incl */ +//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 unused1; - float unused2; + + float tonemap_method; + float tonemap_factor1; + float tonemap_factor2; + float sdr_white_point; + float YCbCr_matrix[16]; } PixelShaderConstants; typedef struct { ID3D11Buffer *constants; - SDL_bool scRGB_output; - float color_scale; - const float *shader_params; + PixelShaderConstants shader_constants; } PixelShaderState; /* Per-vertex data */ @@ -112,7 +132,7 @@ typedef struct int lockedTexturePositionY; D3D11_FILTER scaleMode; D3D11_Shader shader; - const float *shader_params; + const float *YCbCr_matrix; #if SDL_HAVE_YUV /* YV12 texture support */ SDL_bool yuv; @@ -245,6 +265,8 @@ static DXGI_FORMAT SDLPixelFormatToDXGITextureFormat(Uint32 format, Uint32 color switch (format) { case SDL_PIXELFORMAT_RGBA64_FLOAT: return DXGI_FORMAT_R16G16B16A16_FLOAT; + case SDL_PIXELFORMAT_XBGR2101010: + return DXGI_FORMAT_R10G10B10A2_UNORM; case SDL_PIXELFORMAT_ARGB8888: if (colorspace == SDL_COLORSPACE_SRGB_LINEAR) { return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; @@ -263,8 +285,6 @@ static DXGI_FORMAT SDLPixelFormatToDXGITextureFormat(Uint32 format, Uint32 color return DXGI_FORMAT_NV12; case SDL_PIXELFORMAT_P010: return DXGI_FORMAT_P010; - case SDL_PIXELFORMAT_P016: - return DXGI_FORMAT_P016; default: return DXGI_FORMAT_UNKNOWN; } @@ -275,6 +295,8 @@ static DXGI_FORMAT SDLPixelFormatToDXGIMainResourceViewFormat(Uint32 format, Uin switch (format) { case SDL_PIXELFORMAT_RGBA64_FLOAT: return DXGI_FORMAT_R16G16B16A16_FLOAT; + case SDL_PIXELFORMAT_XBGR2101010: + return DXGI_FORMAT_R10G10B10A2_UNORM; case SDL_PIXELFORMAT_ARGB8888: if (colorspace == SDL_COLORSPACE_SRGB_LINEAR) { return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; @@ -291,7 +313,6 @@ static DXGI_FORMAT SDLPixelFormatToDXGIMainResourceViewFormat(Uint32 format, Uin case SDL_PIXELFORMAT_NV21: /* For the Y texture */ return DXGI_FORMAT_R8_UNORM; case SDL_PIXELFORMAT_P010: /* For the Y texture */ - case SDL_PIXELFORMAT_P016: /* For the Y texture */ return DXGI_FORMAT_R16_UNORM; default: return DXGI_FORMAT_UNKNOWN; @@ -1267,14 +1288,17 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL /* NV12 textures must have even width and height */ if (texture->format == SDL_PIXELFORMAT_NV12 || texture->format == SDL_PIXELFORMAT_NV21 || - texture->format == SDL_PIXELFORMAT_P010 || - texture->format == SDL_PIXELFORMAT_P016) { + 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; - textureData->shader = SHADER_RGB; + 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; @@ -1339,53 +1363,28 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL } SDL_SetProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER, textureData->mainTextureV); - textureData->shader = SHADER_YUV; - textureData->shader_params = SDL_GetYCbCRtoRGBConversionMatrix(texture->colorspace, texture->w, texture->h, 8); - if (!textureData->shader_params) { + 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 || - texture->format == SDL_PIXELFORMAT_P016) { + texture->format == SDL_PIXELFORMAT_P010) { int bits_per_pixel; textureData->nv12 = SDL_TRUE; - switch (texture->format) { - case SDL_PIXELFORMAT_NV12: - textureData->shader = SHADER_NV12; - break; - case SDL_PIXELFORMAT_NV21: - textureData->shader = SHADER_NV21; - break; - case SDL_PIXELFORMAT_P010: - case SDL_PIXELFORMAT_P016: - if(SDL_COLORSPACEPRIMARIES(texture->colorspace) == SDL_COLOR_PRIMARIES_BT2020 && - SDL_COLORSPACETRANSFER(texture->colorspace) == SDL_TRANSFER_CHARACTERISTICS_PQ) { - textureData->shader = SHADER_HDR10; - } else { - return SDL_SetError("Unsupported YUV colorspace"); - } - break; - default: - /* This should never happen because of the check above */ - return SDL_SetError("Unsupported YUV colorspace"); - } switch (texture->format) { case SDL_PIXELFORMAT_P010: bits_per_pixel = 10; break; - case SDL_PIXELFORMAT_P016: - bits_per_pixel = 16; - break; default: bits_per_pixel = 8; break; } - textureData->shader_params = SDL_GetYCbCRtoRGBConversionMatrix(texture->colorspace, texture->w, texture->h, bits_per_pixel); - if (!textureData->shader_params) { + textureData->YCbCr_matrix = SDL_GetYCbCRtoRGBConversionMatrix(texture->colorspace, texture->w, texture->h, bits_per_pixel); + if (!textureData->YCbCr_matrix) { return SDL_SetError("Unsupported YUV colorspace"); } } @@ -1425,7 +1424,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL if (texture->format == SDL_PIXELFORMAT_NV12 || texture->format == SDL_PIXELFORMAT_NV21) { nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM; - } else if (texture->format == SDL_PIXELFORMAT_P010 || texture->format == SDL_PIXELFORMAT_P016) { + } else if (texture->format == SDL_PIXELFORMAT_P010) { nvResourceViewDesc.Format = DXGI_FORMAT_R16G16_UNORM; } @@ -1503,8 +1502,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; stagingTextureDesc.Usage = D3D11_USAGE_STAGING; if (stagingTextureDesc.Format == DXGI_FORMAT_NV12 || - stagingTextureDesc.Format == DXGI_FORMAT_P010 || - stagingTextureDesc.Format == DXGI_FORMAT_P016) { + stagingTextureDesc.Format == DXGI_FORMAT_P010) { stagingTextureDesc.Width = (stagingTextureDesc.Width + 1) & ~1; stagingTextureDesc.Height = (stagingTextureDesc.Height + 1) & ~1; } @@ -1548,8 +1546,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex } if (stagingTextureDesc.Format == DXGI_FORMAT_NV12 || - stagingTextureDesc.Format == DXGI_FORMAT_P010 || - stagingTextureDesc.Format == DXGI_FORMAT_P016) { + stagingTextureDesc.Format == DXGI_FORMAT_P010) { /* Copy the UV plane as well */ h = (h + 1) / 2; length = (length + 1) & ~1; @@ -2170,8 +2167,71 @@ static ID3D11RenderTargetView *D3D11_GetCurrentRenderTargetView(SDL_Renderer *re } } +static void D3D11_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, const SDL_Texture *texture, 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->driverdata; + + 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 (SDL_COLORSPACEPRIMARIES(texture->colorspace) == SDL_COLOR_PRIMARIES_BT2020 && + SDL_COLORSPACETRANSFER(texture->colorspace) == SDL_TRANSFER_CHARACTERISTICS_PQ) { + constants->input_type = INPUTTYPE_HDR10; + } else { + 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 int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, - D3D11_Shader shader, const float *shader_params, + D3D11_Shader shader, const PixelShaderConstants *shader_constants, const int numShaderResources, ID3D11ShaderResourceView **shaderResources, ID3D11SamplerState *sampler, const Float4X4 *matrix) @@ -2184,9 +2244,8 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c const SDL_BlendMode blendMode = cmd->data.draw.blend; ID3D11BlendState *blendState = NULL; SDL_bool updateSubresource = SDL_FALSE; - SDL_bool scRGB_output = SDL_RenderingLinearSpace(renderer); - float color_scale = cmd->data.draw.color_scale; PixelShaderState *shader_state = &rendererData->currentShaderState[shader]; + PixelShaderConstants solid_constants; if (numShaderResources > 0) { shaderResource = shaderResources[0]; @@ -2260,37 +2319,31 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c rendererData->currentBlendState = blendState; } - if (!shader_state->constants || - scRGB_output != shader_state->scRGB_output || - color_scale != shader_state->color_scale || - shader_params != shader_state->shader_params) { - SAFE_RELEASE(shader_state->constants); + if (!shader_constants) { + D3D11_SetupShaderConstants(renderer, cmd, NULL, &solid_constants); + shader_constants = &solid_constants; + } - PixelShaderConstants constants; - constants.scRGB_output = (float)scRGB_output; - constants.color_scale = color_scale; - if (shader_params) { - SDL_memcpy(constants.YCbCr_matrix, shader_params, sizeof(constants.YCbCr_matrix)); - } + 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(constants); + desc.ByteWidth = sizeof(*shader_constants); desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; D3D11_SUBRESOURCE_DATA data; SDL_zero(data); - data.pSysMem = &constants; + 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 -1; } - shader_state->scRGB_output = scRGB_output; - shader_state->color_scale = color_scale; - shader_state->shader_params = shader_params; + SDL_memcpy(&shader_state->shader_constants, shader_constants, sizeof(*shader_constants)); /* Force the shader parameters to be re-set */ rendererData->currentShader = SHADER_NONE; @@ -2302,8 +2355,8 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c } } ID3D11DeviceContext_PSSetShader(rendererData->d3dContext, rendererData->pixelShaders[shader], NULL, 0); - if (rendererData->currentShaderState[shader].constants) { - ID3D11DeviceContext_PSSetConstantBuffers(rendererData->d3dContext, 0, 1, &rendererData->currentShaderState[shader].constants); + if (shader_state->constants) { + ID3D11DeviceContext_PSSetConstantBuffers(rendererData->d3dContext, 0, 1, &shader_state->constants); } rendererData->currentShader = shader; } @@ -2336,6 +2389,9 @@ static int D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; ID3D11SamplerState *textureSampler; + PixelShaderConstants constants; + + D3D11_SetupShaderConstants(renderer, cmd, texture, &constants); switch (textureData->scaleMode) { case D3D11_FILTER_MIN_MAG_MIP_POINT: @@ -2355,7 +2411,7 @@ static int D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c shaderResources[1] = textureData->mainTextureResourceViewU; shaderResources[2] = textureData->mainTextureResourceViewV; - return D3D11_SetDrawState(renderer, cmd, textureData->shader, textureData->shader_params, + return D3D11_SetDrawState(renderer, cmd, textureData->shader, &constants, SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix); } else if (textureData->nv12) { @@ -2364,11 +2420,11 @@ static int D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c shaderResources[0] = textureData->mainTextureResourceView; shaderResources[1] = textureData->mainTextureResourceViewNV; - return D3D11_SetDrawState(renderer, cmd, textureData->shader, textureData->shader_params, + 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, textureData->shader_params, + return D3D11_SetDrawState(renderer, cmd, textureData->shader, &constants, 1, &textureData->mainTextureResourceView, textureSampler, matrix); } @@ -2791,13 +2847,13 @@ SDL_RenderDriver D3D11_RenderDriver = { { /* texture_formats */ SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, + SDL_PIXELFORMAT_XBGR2101010, SDL_PIXELFORMAT_RGBA64_FLOAT, SDL_PIXELFORMAT_YV12, SDL_PIXELFORMAT_IYUV, SDL_PIXELFORMAT_NV12, SDL_PIXELFORMAT_NV21, - SDL_PIXELFORMAT_P010, - SDL_PIXELFORMAT_P016 }, + SDL_PIXELFORMAT_P010 }, 0, /* max_texture_width: will be filled in later */ 0 /* max_texture_height: will be filled in later */ } diff --git a/src/render/direct3d11/SDL_shaders_d3d11.c b/src/render/direct3d11/SDL_shaders_d3d11.c index 557297fb6..7a88999fd 100644 --- a/src/render/direct3d11/SDL_shaders_d3d11.c +++ b/src/render/direct3d11/SDL_shaders_d3d11.c @@ -44,20 +44,8 @@ #include "D3D11_PixelShader_Textures.h" #undef g_main -#define g_main D3D11_PixelShader_YUV -#include "D3D11_PixelShader_YUV.h" -#undef g_main - -#define g_main D3D11_PixelShader_NV12 -#include "D3D11_PixelShader_NV12.h" -#undef g_main - -#define g_main D3D11_PixelShader_NV21 -#include "D3D11_PixelShader_NV21.h" -#undef g_main - -#define g_main D3D11_PixelShader_HDR10 -#include "D3D11_PixelShader_HDR10.h" +#define g_main D3D11_PixelShader_Advanced +#include "D3D11_PixelShader_Advanced.h" #undef g_main #define g_main D3D11_VertexShader @@ -73,12 +61,7 @@ static struct { NULL, 0 }, { D3D11_PixelShader_Colors, sizeof(D3D11_PixelShader_Colors) }, { D3D11_PixelShader_Textures, sizeof(D3D11_PixelShader_Textures) }, -#if SDL_HAVE_YUV - { D3D11_PixelShader_YUV, sizeof(D3D11_PixelShader_YUV) }, - { D3D11_PixelShader_NV12, sizeof(D3D11_PixelShader_NV12) }, - { D3D11_PixelShader_NV21, sizeof(D3D11_PixelShader_NV21) }, - { D3D11_PixelShader_HDR10, sizeof(D3D11_PixelShader_HDR10) }, -#endif + { D3D11_PixelShader_Advanced, sizeof(D3D11_PixelShader_Advanced) }, }; SDL_COMPILE_TIME_ASSERT(D3D11_shaders, SDL_arraysize(D3D11_shaders) == NUM_SHADERS); diff --git a/src/render/direct3d11/SDL_shaders_d3d11.h b/src/render/direct3d11/SDL_shaders_d3d11.h index 9567cf6f9..53ce2625a 100644 --- a/src/render/direct3d11/SDL_shaders_d3d11.h +++ b/src/render/direct3d11/SDL_shaders_d3d11.h @@ -27,12 +27,7 @@ typedef enum SHADER_NONE, SHADER_SOLID, SHADER_RGB, -#if SDL_HAVE_YUV - SHADER_YUV, - SHADER_NV12, - SHADER_NV21, - SHADER_HDR10, -#endif + SHADER_ADVANCED, NUM_SHADERS } D3D11_Shader; diff --git a/src/render/direct3d11/compile_shaders.bat b/src/render/direct3d11/compile_shaders.bat index 8f33d582d..51d2a34ce 100644 --- a/src/render/direct3d11/compile_shaders.bat +++ b/src/render/direct3d11/compile_shaders.bat @@ -1,7 +1,4 @@ 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_4_0_level_9_1 /Fh D3D11_PixelShader_YUV.h D3D11_PixelShader_YUV.hlsl -fxc /T ps_4_0_level_9_1 /Fh D3D11_PixelShader_NV12.h D3D11_PixelShader_NV12.hlsl -fxc /T ps_4_0_level_9_1 /Fh D3D11_PixelShader_NV21.h D3D11_PixelShader_NV21.hlsl -fxc /T ps_5_0 /Fh D3D11_PixelShader_HDR10.h D3D11_PixelShader_HDR10.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 diff --git a/src/render/direct3d12/D3D12_PixelShader_Advanced.h b/src/render/direct3d12/D3D12_PixelShader_Advanced.h new file mode 100644 index 000000000..e795a0c59 --- /dev/null +++ b/src/render/direct3d12/D3D12_PixelShader_Advanced.h @@ -0,0 +1,1387 @@ +#if 0 +; +; 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 +; +; shader hash: f6874446eaee41c102142c02d5bb3ab7 +; +; Pipeline Runtime Information: +; +; Pixel Shader +; DepthOutput=0 +; SampleFrequency=0 +; +; +; Input signature: +; +; Name Index InterpMode DynIdx +; -------------------- ----- ---------------------- ------ +; SV_Position 0 noperspective +; TEXCOORD 0 linear +; COLOR 0 linear +; +; Output signature: +; +; Name Index InterpMode DynIdx +; -------------------- ----- ---------------------- ------ +; SV_Target 0 +; +; Buffer Definitions: +; +; cbuffer Constants +; { +; +; struct Constants +; { +; +; float scRGB_output; ; Offset: 0 +; float texture_type; ; Offset: 4 +; float input_type; ; Offset: 8 +; float color_scale; ; Offset: 12 +; float tonemap_method; ; Offset: 16 +; float tonemap_factor1; ; Offset: 20 +; float tonemap_factor2; ; Offset: 24 +; float sdr_white_point; ; Offset: 28 +; float4 Yoffset; ; Offset: 32 +; float4 Rcoeff; ; Offset: 48 +; float4 Gcoeff; ; Offset: 64 +; float4 Bcoeff; ; Offset: 80 +; +; } Constants; ; Offset: 0 Size: 96 +; +; } +; +; +; Resource Bindings: +; +; Name Type Format Dim ID HLSL Bind Count +; ------------------------------ ---------- ------- ----------- ------- -------------- ------ +; Constants cbuffer NA NA CB0 cb1 1 +; sampler0 sampler NA NA S0 s0 1 +; texture0 texture f32 2d T0 t0 1 +; texture1 texture f32 2d T1 t1 1 +; texture2 texture f32 2d T2 t2 1 +; +; +; ViewId state: +; +; Number of inputs: 12, outputs: 4 +; Outputs dependent on ViewId: { } +; Inputs contributing to computation of Outputs: +; output 0 depends on inputs: { 4, 5, 8 } +; output 1 depends on inputs: { 4, 5, 9 } +; output 2 depends on inputs: { 4, 5, 10 } +; output 3 depends on inputs: { 4, 5, 11 } +; +target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64" +target triple = "dxil-ms-dx" + +%dx.types.Handle = type { i8* } +%dx.types.CBufRet.f32 = type { float, float, float, float } +%dx.types.ResRet.f32 = type { float, float, float, float, i32 } +%"class.Texture2D >" = type { <4 x float>, %"class.Texture2D >::mips_type" } +%"class.Texture2D >::mips_type" = type { i32 } +%Constants = type { float, float, float, float, float, float, float, float, <4 x float>, <4 x float>, <4 x float>, <4 x float> } +%struct.SamplerState = type { i32 } + +define void @main() { + %1 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 2, i32 2, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex) + %2 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 1, i32 1, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex) + %3 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 0, i32 0, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex) + %4 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 3, i32 0, i32 0, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex) + %5 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 2, i32 0, i32 1, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex) + %6 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 0, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) + %7 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 1, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) + %8 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 2, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) + %9 = call float @dx.op.loadInput.f32(i32 4, i32 2, i32 0, i8 3, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) + %10 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 0, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) + %11 = call float @dx.op.loadInput.f32(i32 4, i32 1, i32 0, i8 1, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) + %12 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %5, i32 0) ; CBufferLoadLegacy(handle,regIndex) + %13 = extractvalue %dx.types.CBufRet.f32 %12, 1 + %14 = fcmp fast oeq float %13, 0.000000e+00 + br i1 %14, label %114, label %15 + +;