Updated direct3d12 renderer with HDR10 and SDR whitelevel support

This commit is contained in:
Sam Lantinga
2024-02-05 12:27:42 -08:00
parent c3e4481d56
commit b05ea8e04e
30 changed files with 3207 additions and 1577 deletions
@@ -6,8 +6,6 @@ SamplerState theSampler : register(s0);
float4 main(PixelShaderInput input) : SV_TARGET
{
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg;
@@ -6,8 +6,6 @@ SamplerState theSampler : register(s0);
float4 main(PixelShaderInput input) : SV_TARGET
{
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr;
@@ -7,8 +7,6 @@ SamplerState theSampler : register(s0);
float4 main(PixelShaderInput input) : SV_TARGET
{
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.y = theTextureU.Sample(theSampler, input.tex).r;
+15 -16
View File
@@ -380,6 +380,21 @@ static void D3D11_DestroyRenderer(SDL_Renderer *renderer)
SDL_free(renderer);
}
static void D3D11_UpdateHDRState(SDL_Renderer *renderer)
{
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
/* Using some placeholder values here... */
data->HDR_enabled = SDL_TRUE;
if (renderer->output_colorspace == SDL_COLORSPACE_SCRGB && data->HDR_enabled) {
data->SDR_whitelevel = 200.0f;
data->HDR_whitelevel = 400.0f;
} else {
data->SDR_whitelevel = 80.0f;
data->HDR_whitelevel = 80.0f;
}
}
static D3D11_BLEND GetBlendFunc(SDL_BlendFactor factor)
{
switch (factor) {
@@ -470,21 +485,6 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen
return blendState;
}
static void D3D11_UpdateHDRState(SDL_Renderer *renderer)
{
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
/* Using some placeholder values here... */
data->HDR_enabled = SDL_TRUE;
if (renderer->output_colorspace == SDL_COLORSPACE_SCRGB && data->HDR_enabled) {
data->SDR_whitelevel = 200.0f;
data->HDR_whitelevel = 400.0f;
} else {
data->SDR_whitelevel = 80.0f;
data->HDR_whitelevel = 80.0f;
}
}
/* Create resources that depend on the device. */
static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
{
@@ -2222,7 +2222,6 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
} else {
constants.scRGB_output = 0.0f;
}
constants.SDR_whitelevel = (float)rendererData->SDR_whitelevel;
constants.HDR_whitelevel = (float)rendererData->HDR_whitelevel;
constants.maxCLL = 400.0f;
File diff suppressed because it is too large Load Diff
@@ -1,19 +1,15 @@
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#include "D3D12_PixelShader_Common.incl"
#define ColorRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
"DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
"DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
"DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0)"
"RootConstants(num32BitConstants=20, b1)"
[RootSignature(ColorRS)]
float4 main(PixelShaderInput input) : SV_TARGET0
{
return input.color;
return GetOutputColor(1.0) * input.color;
}
@@ -0,0 +1,75 @@
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
cbuffer Constants : register(b1)
{
float scRGB_output;
float SDR_whitelevel;
float HDR_whitelevel;
float maxCLL;
float4 Yoffset;
float4 Rcoeff;
float4 Gcoeff;
float4 Bcoeff;
};
float3 scRGBtoNits(float3 v)
{
return v * 80.0;
}
float3 scRGBfromNits(float3 v)
{
return v / 80.0;
}
float sRGBtoLinear(float v)
{
if (v <= 0.04045) {
v = (v / 12.92);
} else {
v = pow(abs(v + 0.055) / 1.055, 2.4);
}
return v;
}
float sRGBfromLinear(float v)
{
if (v <= 0.0031308) {
v = (v * 12.92);
} else {
v = (pow(abs(v), 1.0 / 2.4) * 1.055 - 0.055);
}
return v;
}
float4 GetOutputColor(float4 rgba)
{
if (scRGB_output) {
rgba.rgb = scRGBfromNits(rgba.rgb * SDR_whitelevel);
}
return rgba;
}
float4 GetOutputColorFromSRGB(float3 rgb)
{
float4 output;
if (scRGB_output) {
output.r = sRGBtoLinear(rgb.r);
output.g = sRGBtoLinear(rgb.g);
output.b = sRGBtoLinear(rgb.b);
rgb = scRGBfromNits(rgb * SDR_whitelevel);
} else {
output.rgb = rgb.rgb;
}
output.a = 1.0;
return output;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,69 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureUV : register(t1);
SamplerState theSampler : register(s0);
#include "D3D12_PixelShader_Common.incl"
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=20, b1),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
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);
}
[RootSignature(NVRS)]
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
};
float4 Output;
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 = (rgb / maxCLL) * HDR_whitelevel;
rgb = scRGBfromNits(rgb);
if (!scRGB_output) {
rgb.r = sRGBfromLinear(rgb.r);
rgb.g = sRGBfromLinear(rgb.g);
rgb.b = sRGBfromLinear(rgb.b);
rgb.rgb = clamp(rgb.rgb, 0.0, 1.0);
}
Output.rgb = rgb.rgb;
Output.a = 1.0;
return Output * input.color;
}
File diff suppressed because it is too large Load Diff
@@ -2,28 +2,14 @@ Texture2D theTextureY : register(t0);
Texture2D theTextureUV : register(t1);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
cbuffer Constants : register(b1)
{
float4 Yoffset;
float4 Rcoeff;
float4 Gcoeff;
float4 Bcoeff;
};
#include "D3D12_PixelShader_Common.incl"
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=16, b1),"\
"RootConstants(num32BitConstants=20, b1),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
@@ -31,22 +17,15 @@ cbuffer Constants : register(b1)
[RootSignature(NVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {0.0, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg;
float3 rgb;
yuv += Yoffset.xyz;
Output.r = dot(yuv, Rcoeff.xyz);
Output.g = dot(yuv, Gcoeff.xyz);
Output.b = dot(yuv, Bcoeff.xyz);
Output.a = 1.0f;
rgb.r = dot(yuv, Rcoeff.xyz);
rgb.g = dot(yuv, Gcoeff.xyz);
rgb.b = dot(yuv, Bcoeff.xyz);
return Output * input.color;
return GetOutputColorFromSRGB(rgb) * input.color;
}
File diff suppressed because it is too large Load Diff
@@ -2,28 +2,14 @@ Texture2D theTextureY : register(t0);
Texture2D theTextureUV : register(t1);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
cbuffer Constants : register(b1)
{
float4 Yoffset;
float4 Rcoeff;
float4 Gcoeff;
float4 Bcoeff;
};
#include "D3D12_PixelShader_Common.incl"
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=16, b1),"\
"RootConstants(num32BitConstants=20, b1),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
@@ -31,22 +17,15 @@ cbuffer Constants : register(b1)
[RootSignature(NVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {0.0, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr;
float3 rgb;
yuv += Yoffset.xyz;
Output.r = dot(yuv, Rcoeff.xyz);
Output.g = dot(yuv, Gcoeff.xyz);
Output.b = dot(yuv, Bcoeff.xyz);
Output.a = 1.0f;
rgb.r = dot(yuv, Rcoeff.xyz);
rgb.g = dot(yuv, Gcoeff.xyz);
rgb.b = dot(yuv, Bcoeff.xyz);
return Output * input.color;
return GetOutputColorFromSRGB(rgb) * input.color;
}
File diff suppressed because it is too large Load Diff
@@ -1,24 +1,19 @@
Texture2D theTexture : register(t0);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#include "D3D12_PixelShader_Common.incl"
#define TextureRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"RootConstants(num32BitConstants=20, b1),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(TextureRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
return theTexture.Sample(theSampler, input.tex) * input.color;
return GetOutputColor(theTexture.Sample(theSampler, input.tex)) * input.color;
}
File diff suppressed because it is too large Load Diff
@@ -3,28 +3,14 @@ Texture2D theTextureU : register(t1);
Texture2D theTextureV : register(t2);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
cbuffer Constants : register(b1)
{
float4 Yoffset;
float4 Rcoeff;
float4 Gcoeff;
float4 Bcoeff;
};
#include "D3D12_PixelShader_Common.incl"
#define YUVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=16, b1),"\
"RootConstants(num32BitConstants=20, b1),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t2), visibility = SHADER_VISIBILITY_PIXEL ),"\
@@ -33,23 +19,16 @@ cbuffer Constants : register(b1)
[RootSignature(YUVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {0.0, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
float4 Output;
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;
Output.r = dot(yuv, Rcoeff.xyz);
Output.g = dot(yuv, Gcoeff.xyz);
Output.b = dot(yuv, Bcoeff.xyz);
Output.a = 1.0f;
rgb.r = dot(yuv, Rcoeff.xyz);
rgb.g = dot(yuv, Gcoeff.xyz);
rgb.b = dot(yuv, Bcoeff.xyz);
return Output * input.color;
return GetOutputColorFromSRGB(rgb) * input.color;
}
+3 -3
View File
@@ -3,8 +3,8 @@ Disassembly failed
#endif
const unsigned char g_ColorRS[] = {
0x44, 0x58, 0x42, 0x43, 0x31, 0xbf, 0x40, 0x31, 0x79, 0x1f, 0x99, 0xd8,
0xf3, 0x2c, 0x12, 0x07, 0x40, 0x16, 0x5c, 0xf4, 0x01, 0x00, 0x00, 0x00,
0x44, 0x58, 0x42, 0x43, 0x24, 0x3f, 0x6b, 0x5a, 0xb1, 0xd3, 0x78, 0x2f,
0x7f, 0xd4, 0x83, 0xd9, 0x7d, 0x6b, 0xc4, 0x31, 0x01, 0x00, 0x00, 0x00,
0x74, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
0x52, 0x54, 0x53, 0x30, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -12,5 +12,5 @@ const unsigned char g_ColorRS[] = {
0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00
};
+3 -3
View File
@@ -3,8 +3,8 @@ Disassembly failed
#endif
const unsigned char g_NVRS[] = {
0x44, 0x58, 0x42, 0x43, 0x9c, 0x0e, 0x93, 0x02, 0x5b, 0xc1, 0x94, 0xb2,
0xc8, 0xbe, 0xbf, 0x7b, 0xa2, 0xb7, 0xb3, 0x59, 0x01, 0x00, 0x00, 0x00,
0x44, 0x58, 0x42, 0x43, 0xfd, 0x56, 0xee, 0x54, 0x9c, 0x1e, 0xc4, 0x3b,
0xc6, 0x37, 0x26, 0x3f, 0x01, 0x62, 0x06, 0x1c, 0x01, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
0x52, 0x54, 0x53, 0x30, 0xcc, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -15,7 +15,7 @@ const unsigned char g_NVRS[] = {
0x05, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00,
@@ -3,8 +3,8 @@ Disassembly failed
#endif
const unsigned char g_TextureRS[] = {
0x44, 0x58, 0x42, 0x43, 0x73, 0x35, 0xf9, 0xf2, 0x72, 0x02, 0x54, 0xfb,
0x0b, 0xd1, 0xca, 0xbe, 0xab, 0x3d, 0xab, 0x6e, 0x01, 0x00, 0x00, 0x00,
0x44, 0x58, 0x42, 0x43, 0x25, 0x9c, 0x4f, 0xa4, 0x10, 0x16, 0x82, 0x9d,
0x3d, 0x46, 0xb7, 0x5d, 0xf0, 0xc2, 0x90, 0xa7, 0x01, 0x00, 0x00, 0x00,
0xcc, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
0x52, 0x54, 0x53, 0x30, 0xa0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -14,7 +14,7 @@ const unsigned char g_TextureRS[] = {
0x05, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00,
+3 -3
View File
@@ -3,8 +3,8 @@ Disassembly failed
#endif
const unsigned char g_YUVRS[] = {
0x44, 0x58, 0x42, 0x43, 0x7b, 0x5d, 0x13, 0xc6, 0x83, 0xfa, 0x66, 0x6f,
0x93, 0x7e, 0xd6, 0xcd, 0x5a, 0x0a, 0x69, 0xe5, 0x01, 0x00, 0x00, 0x00,
0x44, 0x58, 0x42, 0x43, 0xc2, 0xcd, 0x2f, 0xaf, 0x3b, 0x72, 0x07, 0x2a,
0xa9, 0x73, 0x1b, 0xab, 0x8e, 0x46, 0xf7, 0x46, 0x01, 0x00, 0x00, 0x00,
0x24, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
0x52, 0x54, 0x53, 0x30, 0xf8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -16,7 +16,7 @@ const unsigned char g_YUVRS[] = {
0x05, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00,
@@ -26,7 +26,7 @@ struct VertexShaderOutput
"DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
"DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0)," \
"RootConstants(num32BitConstants=0, b1)"\
"RootConstants(num32BitConstants=20, b1)"\
#define TextureRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
@@ -34,7 +34,7 @@ struct VertexShaderOutput
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"RootConstants(num32BitConstants=0, b1),"\
"RootConstants(num32BitConstants=20, b1),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
@@ -44,7 +44,7 @@ struct VertexShaderOutput
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"RootConstants(num32BitConstants=16, b1),"\
"RootConstants(num32BitConstants=20, b1),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t2), visibility = SHADER_VISIBILITY_PIXEL ),"\
@@ -56,7 +56,7 @@ struct VertexShaderOutput
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"RootConstants(num32BitConstants=16, b1),"\
"RootConstants(num32BitConstants=20, b1),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
@@ -236,8 +236,8 @@ attributes #2 = { nounwind readonly }
#endif
const unsigned char g_mainColor[] = {
0x44, 0x58, 0x42, 0x43, 0x27, 0x9e, 0x5a, 0x32, 0x1b, 0x5e, 0x27, 0x10,
0x34, 0x7d, 0xf5, 0x7f, 0x06, 0xdd, 0x03, 0xd9, 0x01, 0x00, 0x00, 0x00,
0x44, 0x58, 0x42, 0x43, 0xd2, 0x9c, 0xbb, 0x08, 0x88, 0xc9, 0x51, 0x6d,
0x10, 0xea, 0x39, 0xeb, 0x7b, 0xab, 0xdf, 0x50, 0x01, 0x00, 0x00, 0x00,
0xa3, 0x12, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x50, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x63, 0x01, 0x00, 0x00,
0x87, 0x02, 0x00, 0x00, 0xd7, 0x02, 0x00, 0x00, 0x87, 0x09, 0x00, 0x00,
@@ -296,7 +296,7 @@ const unsigned char g_mainColor[] = {
0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x54, 0x41, 0x54, 0xa8,
0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x53, 0x54, 0x41, 0x54, 0xa8,
0x06, 0x00, 0x00, 0x60, 0x00, 0x01, 0x00, 0xaa, 0x01, 0x00, 0x00, 0x44,
0x58, 0x49, 0x4c, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x90,
0x06, 0x00, 0x00, 0x42, 0x43, 0xc0, 0xde, 0x21, 0x0c, 0x00, 0x00, 0xa1,
@@ -236,8 +236,8 @@ attributes #2 = { nounwind readonly }
#endif
const unsigned char g_mainNV[] = {
0x44, 0x58, 0x42, 0x43, 0xbc, 0x48, 0xc9, 0x9e, 0xc7, 0xab, 0xe1, 0xca,
0x8e, 0x06, 0x6b, 0xe6, 0x96, 0x2b, 0x14, 0x91, 0x01, 0x00, 0x00, 0x00,
0x44, 0x58, 0x42, 0x43, 0x19, 0x1b, 0x50, 0x7a, 0xe4, 0x25, 0xcb, 0x64,
0x07, 0x40, 0xcd, 0x31, 0x3a, 0x23, 0xa6, 0x35, 0x01, 0x00, 0x00, 0x00,
0x17, 0x13, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x50, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x63, 0x01, 0x00, 0x00,
0x87, 0x02, 0x00, 0x00, 0x5b, 0x03, 0x00, 0x00, 0x03, 0x0a, 0x00, 0x00,
@@ -299,7 +299,7 @@ const unsigned char g_mainNV[] = {
0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x74,
0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x74,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x00,
@@ -236,8 +236,8 @@ attributes #2 = { nounwind readonly }
#endif
const unsigned char g_mainTexture[] = {
0x44, 0x58, 0x42, 0x43, 0x43, 0x2f, 0x19, 0x6f, 0xcb, 0x72, 0x40, 0xd1,
0xc9, 0x74, 0xd2, 0x78, 0xfc, 0xf2, 0x03, 0x7c, 0x01, 0x00, 0x00, 0x00,
0x44, 0x58, 0x42, 0x43, 0x74, 0x5e, 0x15, 0x62, 0x5c, 0xf4, 0x2a, 0x49,
0x52, 0xac, 0x1f, 0x81, 0x9a, 0xff, 0xaa, 0xbf, 0x01, 0x00, 0x00, 0x00,
0xff, 0x12, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x50, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x63, 0x01, 0x00, 0x00,
0x87, 0x02, 0x00, 0x00, 0x2f, 0x03, 0x00, 0x00, 0xdf, 0x09, 0x00, 0x00,
@@ -298,7 +298,7 @@ const unsigned char g_mainTexture[] = {
0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x68,
0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x68,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x03,
@@ -236,8 +236,8 @@ attributes #2 = { nounwind readonly }
#endif
const unsigned char g_mainYUV[] = {
0x44, 0x58, 0x42, 0x43, 0xa4, 0x7a, 0x63, 0xbc, 0x6b, 0x62, 0xe8, 0x12,
0x9f, 0x7b, 0x63, 0x07, 0x5a, 0x41, 0x5f, 0x3a, 0x01, 0x00, 0x00, 0x00,
0x44, 0x58, 0x42, 0x43, 0xbb, 0xef, 0x2b, 0x63, 0x10, 0x5a, 0xb4, 0x09,
0xc0, 0x20, 0xa8, 0xff, 0x4d, 0xb1, 0xab, 0xe7, 0x01, 0x00, 0x00, 0x00,
0x4f, 0x13, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x50, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x63, 0x01, 0x00, 0x00,
0x87, 0x02, 0x00, 0x00, 0x87, 0x03, 0x00, 0x00, 0x33, 0x0a, 0x00, 0x00,
@@ -300,7 +300,7 @@ const unsigned char g_mainYUV[] = {
0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x00,
+114 -14
View File
@@ -88,6 +88,15 @@ typedef struct
Float4X4 projectionAndView;
} VertexShaderConstants;
typedef struct
{
float scRGB_output;
float SDR_whitelevel;
float HDR_whitelevel;
float maxCLL;
float YCbCr_matrix[16];
} PixelShaderConstants;
/* Per-vertex data */
typedef struct
{
@@ -182,6 +191,11 @@ typedef struct
DXGI_FORMAT renderTargetFormat;
SDL_bool pixelSizeChanged;
/* HDR state */
SDL_bool HDR_enabled;
int SDR_whitelevel;
int HDR_whitelevel;
/* Descriptor heaps */
ID3D12DescriptorHeap *rtvDescriptorHeap;
UINT rtvDescriptorSize;
@@ -314,6 +328,10 @@ static DXGI_FORMAT SDLPixelFormatToDXGITextureFormat(Uint32 format, Uint32 color
case SDL_PIXELFORMAT_NV12:
case SDL_PIXELFORMAT_NV21:
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;
}
@@ -339,6 +357,9 @@ static DXGI_FORMAT SDLPixelFormatToDXGIMainResourceViewFormat(Uint32 format, Uin
case SDL_PIXELFORMAT_NV12: /* For the Y texture */
case SDL_PIXELFORMAT_NV21: /* For the Y texture */
return DXGI_FORMAT_R8_UNORM;
case SDL_PIXELFORMAT_P010: /* For the Y texture */
case SDL_PIXELFORMAT_P016: /* For the Y texture */
return DXGI_FORMAT_R16_UNORM;
default:
return DXGI_FORMAT_UNKNOWN;
}
@@ -549,6 +570,21 @@ static void D3D12_DestroyRenderer(SDL_Renderer *renderer)
SDL_free(renderer);
}
static void D3D12_UpdateHDRState(SDL_Renderer *renderer)
{
D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata;
/* Using some placeholder values here... */
data->HDR_enabled = SDL_FALSE;
if (renderer->output_colorspace == SDL_COLORSPACE_SCRGB && data->HDR_enabled) {
data->SDR_whitelevel = 200.0f;
data->HDR_whitelevel = 400.0f;
} else {
data->SDR_whitelevel = 80.0f;
data->HDR_whitelevel = 80.0f;
}
}
static D3D12_BLEND GetBlendFunc(SDL_BlendFactor factor)
{
switch (factor) {
@@ -1112,6 +1148,8 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
SDL_SetProperty(props, SDL_PROP_RENDERER_D3D12_DEVICE_POINTER, data->d3dDevice);
SDL_SetProperty(props, SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER, data->commandQueue);
D3D12_UpdateHDRState(renderer);
done:
SAFE_RELEASE(d3dDevice);
return result;
@@ -1556,7 +1594,9 @@ static int D3D12_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_NV21 ||
texture->format == SDL_PIXELFORMAT_P010 ||
texture->format == SDL_PIXELFORMAT_P016) {
textureDesc.Width = (textureDesc.Width + 1) & ~1;
textureDesc.Height = (textureDesc.Height + 1) & ~1;
}
@@ -1586,7 +1626,6 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
D3D_GUID(SDL_IID_ID3D12Resource),
(void **)&textureData->mainTexture);
if (FAILED(result)) {
D3D12_DestroyTexture(renderer, texture);
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [texture]"), result);
}
}
@@ -1613,7 +1652,6 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
D3D_GUID(SDL_IID_ID3D12Resource),
(void **)&textureData->mainTextureU);
if (FAILED(result)) {
D3D12_DestroyTexture(renderer, texture);
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [texture]"), result);
}
}
@@ -1633,7 +1671,6 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
D3D_GUID(SDL_IID_ID3D12Resource),
(void **)&textureData->mainTextureV);
if (FAILED(result)) {
D3D12_DestroyTexture(renderer, texture);
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Device::CreateCommittedResource [texture]"), result);
}
}
@@ -1648,11 +1685,45 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
}
if (texture->format == SDL_PIXELFORMAT_NV12 ||
texture->format == SDL_PIXELFORMAT_NV21) {
texture->format == SDL_PIXELFORMAT_NV21 ||
texture->format == SDL_PIXELFORMAT_P010 ||
texture->format == SDL_PIXELFORMAT_P016) {
int bits_per_pixel;
textureData->nv12 = SDL_TRUE;
textureData->shader = (texture->format == SDL_PIXELFORMAT_NV12 ? SHADER_NV12 : SHADER_NV21);
textureData->shader_params = SDL_GetYCbCRtoRGBConversionMatrix(texture->colorspace, texture->w, texture->h, 8);
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) {
return SDL_SetError("Unsupported YUV colorspace");
}
@@ -1694,7 +1765,11 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
if (textureData->nv12) {
D3D12_SHADER_RESOURCE_VIEW_DESC nvResourceViewDesc = resourceViewDesc;
nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM;
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) {
nvResourceViewDesc.Format = DXGI_FORMAT_R16G16_UNORM;
}
nvResourceViewDesc.Texture2D.PlaneSlice = 1;
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewNV);
@@ -1781,7 +1856,9 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res
D3D_CALL_RET(texture, GetDesc, &textureDesc);
textureDesc.Width = w;
textureDesc.Height = h;
if (textureDesc.Format == DXGI_FORMAT_NV12) {
if (textureDesc.Format == DXGI_FORMAT_NV12 ||
textureDesc.Format == DXGI_FORMAT_P010 ||
textureDesc.Format == DXGI_FORMAT_P016) {
textureDesc.Width = (textureDesc.Width + 1) & ~1;
textureDesc.Height = (textureDesc.Height + 1) & ~1;
}
@@ -2572,6 +2649,7 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
break;
case SHADER_NV12:
case SHADER_NV21:
case SHADER_HDR10:
tableIndex = 4;
break;
#endif
@@ -2593,11 +2671,25 @@ static int D3D12_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
0);
}
if (shader_params && (updateSubresource == SDL_TRUE || shader_params != rendererData->currentPipelineState->shader_params)) {
if (updateSubresource == SDL_TRUE || (shader_params && shader_params != rendererData->currentPipelineState->shader_params)) {
PixelShaderConstants constants;
if (renderer->output_colorspace == SDL_COLORSPACE_SCRGB) {
constants.scRGB_output = 1.0f;
} else {
constants.scRGB_output = 0.0f;
}
constants.SDR_whitelevel = (float)rendererData->SDR_whitelevel;
constants.HDR_whitelevel = (float)rendererData->HDR_whitelevel;
constants.maxCLL = 400.0f;
if (shader_params) {
SDL_memcpy(constants.YCbCr_matrix, shader_params, sizeof(constants.YCbCr_matrix));
}
D3D_CALL(rendererData->commandList, SetGraphicsRoot32BitConstants,
1,
16,
shader_params,
20,
&constants,
0);
rendererData->currentPipelineState->shader_params = shader_params;
}
@@ -2740,7 +2832,13 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
SDL_bool convert_color = SDL_RenderingLinearSpace(renderer);
SDL_FColor color = cmd->data.color.color;
if (convert_color) {
float light_scale = (float)rendererData->SDR_whitelevel / 80.0f;
SDL_ConvertToLinear(&color);
color.r *= light_scale;
color.g *= light_scale;
color.b *= light_scale;
}
D3D_CALL(rendererData->commandList, ClearRenderTargetView, rtvDescriptor, &color.r, 0, NULL);
break;
@@ -3135,7 +3233,7 @@ SDL_RenderDriver D3D12_RenderDriver = {
"direct3d12",
(SDL_RENDERER_ACCELERATED |
SDL_RENDERER_PRESENTVSYNC), /* flags. see SDL_RendererFlags */
7, /* num_texture_formats */
9, /* num_texture_formats */
{ /* texture_formats */
SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_XRGB8888,
@@ -3143,7 +3241,9 @@ SDL_RenderDriver D3D12_RenderDriver = {
SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_IYUV,
SDL_PIXELFORMAT_NV12,
SDL_PIXELFORMAT_NV21 },
SDL_PIXELFORMAT_NV21,
SDL_PIXELFORMAT_P010,
SDL_PIXELFORMAT_P016 },
16384, /* max_texture_width */
16384 /* max_texture_height */
}
@@ -51,6 +51,10 @@
#include "D3D12_PixelShader_NV21.h"
#undef g_main
#define g_main D3D12_PixelShader_HDR10
#include "D3D12_PixelShader_HDR10.h"
#undef g_main
#define g_mainColor D3D12_VertexShader_Colors
#include "D3D12_VertexShader_Color.h"
@@ -110,6 +114,9 @@ static struct
{ D3D12_PixelShader_NV21, sizeof(D3D12_PixelShader_NV21),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_HDR10, sizeof(D3D12_PixelShader_HDR10),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
#endif
};
@@ -35,6 +35,7 @@ typedef enum
SHADER_YUV,
SHADER_NV12,
SHADER_NV21,
SHADER_HDR10,
#endif
NUM_SHADERS
} D3D12_Shader;
@@ -3,6 +3,7 @@ dxc -E main -T ps_6_0 -Fh D3D12_PixelShader_Textures.h D3D12_PixelShader_Textur
dxc -E main -T ps_6_0 -Fh D3D12_PixelShader_YUV.h D3D12_PixelShader_YUV.hlsl
dxc -E main -T ps_6_0 -Fh D3D12_PixelShader_NV12.h D3D12_PixelShader_NV12.hlsl
dxc -E main -T ps_6_0 -Fh D3D12_PixelShader_NV21.h D3D12_PixelShader_NV21.hlsl
dxc -E main -T ps_6_0 -Fh D3D12_PixelShader_HDR10.h D3D12_PixelShader_HDR10.hlsl
dxc -E mainColor -T vs_6_0 -Fh D3D12_VertexShader_Color.h D3D12_VertexShader.hlsl
dxc -E mainTexture -T vs_6_0 -Fh D3D12_VertexShader_Texture.h D3D12_VertexShader.hlsl