mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-22 03:08:22 +00:00
GPU: Clean up D3D12 blit shader compilation
This commit is contained in:
@@ -1,21 +1,15 @@
|
|||||||
#if D3D12
|
|
||||||
#define BlitRS \
|
#define BlitRS \
|
||||||
"DescriptorTable ( Sampler(s0, space=2), visibility = SHADER_VISIBILITY_PIXEL ),"\
|
"DescriptorTable ( Sampler(s0, space=2), visibility = SHADER_VISIBILITY_PIXEL ),"\
|
||||||
"DescriptorTable ( SRV(t0, space=2), visibility = SHADER_VISIBILITY_PIXEL ),"\
|
"DescriptorTable ( SRV(t0, space=2), visibility = SHADER_VISIBILITY_PIXEL ),"\
|
||||||
"CBV(b0, space=3, visibility = SHADER_VISIBILITY_PIXEL),"\
|
"CBV(b0, space=3, visibility = SHADER_VISIBILITY_PIXEL),"\
|
||||||
|
|
||||||
#define REG(reg, space) register(reg, space)
|
|
||||||
#else
|
|
||||||
#define REG(reg, space) register(reg)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct VertexToPixel
|
struct VertexToPixel
|
||||||
{
|
{
|
||||||
float2 tex : TEXCOORD0;
|
float2 tex : TEXCOORD0;
|
||||||
float4 pos : SV_POSITION;
|
float4 pos : SV_POSITION;
|
||||||
};
|
};
|
||||||
|
|
||||||
cbuffer SourceRegionBuffer : REG(b0, space3)
|
cbuffer SourceRegionBuffer : register(b0, space3)
|
||||||
{
|
{
|
||||||
float2 UVLeftTop;
|
float2 UVLeftTop;
|
||||||
float2 UVDimensions;
|
float2 UVDimensions;
|
||||||
@@ -23,16 +17,14 @@ cbuffer SourceRegionBuffer : REG(b0, space3)
|
|||||||
float LayerOrDepth;
|
float LayerOrDepth;
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture2D SourceTexture2D : REG(t0, space2);
|
Texture2D SourceTexture2D : register(t0, space2);
|
||||||
Texture2DArray SourceTexture2DArray : REG(t0, space2);
|
Texture2DArray SourceTexture2DArray : register(t0, space2);
|
||||||
Texture3D SourceTexture3D : REG(t0, space2);
|
Texture3D SourceTexture3D : register(t0, space2);
|
||||||
TextureCube SourceTextureCube : REG(t0, space2);
|
TextureCube SourceTextureCube : register(t0, space2);
|
||||||
TextureCubeArray SourceTextureCubeArray : REG(t0, space2);
|
TextureCubeArray SourceTextureCubeArray : register(t0, space2);
|
||||||
sampler SourceSampler : REG(s0, space2);
|
sampler SourceSampler : register(s0, space2);
|
||||||
|
|
||||||
#if D3D12
|
|
||||||
[RootSignature(BlitRS)]
|
[RootSignature(BlitRS)]
|
||||||
#endif
|
|
||||||
VertexToPixel FullscreenVert(uint vI : SV_VERTEXID)
|
VertexToPixel FullscreenVert(uint vI : SV_VERTEXID)
|
||||||
{
|
{
|
||||||
float2 inTex = float2((vI << 1) & 2, vI & 2);
|
float2 inTex = float2((vI << 1) & 2, vI & 2);
|
||||||
@@ -42,36 +34,28 @@ VertexToPixel FullscreenVert(uint vI : SV_VERTEXID)
|
|||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if D3D12
|
|
||||||
[RootSignature(BlitRS)]
|
[RootSignature(BlitRS)]
|
||||||
#endif
|
|
||||||
float4 BlitFrom2D(VertexToPixel input) : SV_Target0
|
float4 BlitFrom2D(VertexToPixel input) : SV_Target0
|
||||||
{
|
{
|
||||||
float2 newCoord = UVLeftTop + UVDimensions * input.tex;
|
float2 newCoord = UVLeftTop + UVDimensions * input.tex;
|
||||||
return SourceTexture2D.SampleLevel(SourceSampler, newCoord, MipLevel);
|
return SourceTexture2D.SampleLevel(SourceSampler, newCoord, MipLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if D3D12
|
|
||||||
[RootSignature(BlitRS)]
|
[RootSignature(BlitRS)]
|
||||||
#endif
|
|
||||||
float4 BlitFrom2DArray(VertexToPixel input) : SV_Target0
|
float4 BlitFrom2DArray(VertexToPixel input) : SV_Target0
|
||||||
{
|
{
|
||||||
float3 newCoord = float3(UVLeftTop + UVDimensions * input.tex, (uint)LayerOrDepth);
|
float3 newCoord = float3(UVLeftTop + UVDimensions * input.tex, (uint)LayerOrDepth);
|
||||||
return SourceTexture2DArray.SampleLevel(SourceSampler, newCoord, MipLevel);
|
return SourceTexture2DArray.SampleLevel(SourceSampler, newCoord, MipLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if D3D12
|
|
||||||
[RootSignature(BlitRS)]
|
[RootSignature(BlitRS)]
|
||||||
#endif
|
|
||||||
float4 BlitFrom3D(VertexToPixel input) : SV_Target0
|
float4 BlitFrom3D(VertexToPixel input) : SV_Target0
|
||||||
{
|
{
|
||||||
float3 newCoord = float3(UVLeftTop + UVDimensions * input.tex, LayerOrDepth);
|
float3 newCoord = float3(UVLeftTop + UVDimensions * input.tex, LayerOrDepth);
|
||||||
return SourceTexture3D.SampleLevel(SourceSampler, newCoord, MipLevel);
|
return SourceTexture3D.SampleLevel(SourceSampler, newCoord, MipLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if D3D12
|
|
||||||
[RootSignature(BlitRS)]
|
[RootSignature(BlitRS)]
|
||||||
#endif
|
|
||||||
float4 BlitFromCube(VertexToPixel input) : SV_Target0
|
float4 BlitFromCube(VertexToPixel input) : SV_Target0
|
||||||
{
|
{
|
||||||
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
|
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
|
||||||
@@ -91,9 +75,7 @@ float4 BlitFromCube(VertexToPixel input) : SV_Target0
|
|||||||
return SourceTextureCube.SampleLevel(SourceSampler, newCoord, MipLevel);
|
return SourceTextureCube.SampleLevel(SourceSampler, newCoord, MipLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if D3D12
|
|
||||||
[RootSignature(BlitRS)]
|
[RootSignature(BlitRS)]
|
||||||
#endif
|
|
||||||
float4 BlitFromCubeArray(VertexToPixel input) : SV_Target0
|
float4 BlitFromCubeArray(VertexToPixel input) : SV_Target0
|
||||||
{
|
{
|
||||||
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
|
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
|
@@ -8,11 +8,11 @@ echo Suffix %SUFFIX%
|
|||||||
|
|
||||||
cd "%~dp0"
|
cd "%~dp0"
|
||||||
|
|
||||||
%DXC% -E FullscreenVert -T vs_6_0 -Fh D3D12_FullscreenVert.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
|
%DXC% -E FullscreenVert -T vs_6_0 -Fh D3D12_FullscreenVert.h D3D_Blit.hlsl
|
||||||
%DXC% -E BlitFrom2D -T ps_6_0 -Fh D3D12_BlitFrom2D.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
|
%DXC% -E BlitFrom2D -T ps_6_0 -Fh D3D12_BlitFrom2D.h D3D_Blit.hlsl
|
||||||
%DXC% -E BlitFrom2DArray -T ps_6_0 -Fh D3D12_BlitFrom2DArray.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
|
%DXC% -E BlitFrom2DArray -T ps_6_0 -Fh D3D12_BlitFrom2DArray.h D3D_Blit.hlsl
|
||||||
%DXC% -E BlitFrom3D -T ps_6_0 -Fh D3D12_BlitFrom3D.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
|
%DXC% -E BlitFrom3D -T ps_6_0 -Fh D3D12_BlitFrom3D.h D3D_Blit.hlsl
|
||||||
%DXC% -E BlitFromCube -T ps_6_0 -Fh D3D12_BlitFromCube.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
|
%DXC% -E BlitFromCube -T ps_6_0 -Fh D3D12_BlitFromCube.h D3D_Blit.hlsl
|
||||||
%DXC% -E BlitFromCubeArray -T ps_6_0 -Fh D3D12_BlitFromCubeArray.h ..\d3dcommon\D3D_Blit.hlsl /D D3D12=1
|
%DXC% -E BlitFromCubeArray -T ps_6_0 -Fh D3D12_BlitFromCubeArray.h D3D_Blit.hlsl
|
||||||
copy /b D3D12_FullscreenVert.h+D3D12_BlitFrom2D.h+D3D12_BlitFrom2DArray.h+D3D12_BlitFrom3D.h+D3D12_BlitFromCube.h+D3D12_BlitFromCubeArray.h D3D12_Blit%SUFFIX%
|
copy /b D3D12_FullscreenVert.h+D3D12_BlitFrom2D.h+D3D12_BlitFrom2DArray.h+D3D12_BlitFrom3D.h+D3D12_BlitFromCube.h+D3D12_BlitFromCubeArray.h D3D12_Blit%SUFFIX%
|
||||||
del D3D12_FullscreenVert.h D3D12_BlitFrom2D.h D3D12_BlitFrom2DArray.h D3D12_BlitFrom3D.h D3D12_BlitFromCube.h D3D12_BlitFromCubeArray.h
|
del D3D12_FullscreenVert.h D3D12_BlitFrom2D.h D3D12_BlitFrom2DArray.h D3D12_BlitFrom3D.h D3D12_BlitFromCube.h D3D12_BlitFromCubeArray.h
|
||||||
|
Reference in New Issue
Block a user