GDK: Remove old shader sources, unify shader compilation .bats

This commit is contained in:
Jade Macho
2024-03-01 15:50:57 +01:00
committed by Sam Lantinga
parent bcbede31ce
commit 23ace600fc
19 changed files with 127 additions and 693 deletions

View File

@@ -31,28 +31,46 @@
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
/* Shader blob headers are generated with a pre-build step using buildshaders.bat */
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Colors_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT601_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT709_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_JPEG_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT601_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT709_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_JPEG_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Textures_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT601_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT709_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_JPEG_One.h"
/* Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat */
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Color_One.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_NV_One.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Texture_One.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_YUV_One.h"
#define g_main D3D12_PixelShader_Colors
#include "D3D12_PixelShader_Colors_One.h"
#undef g_main
#define g_main D3D12_PixelShader_Textures
#include "D3D12_PixelShader_Textures_One.h"
#undef g_main
#define g_main D3D12_PixelShader_Advanced
#include "D3D12_PixelShader_Advanced_One.h"
#undef g_main
#define g_mainColor D3D12_VertexShader_Colors
#include "D3D12_VertexShader_Color_One.h"
#undef g_mainColor
#define g_mainTexture D3D12_VertexShader_Textures
#include "D3D12_VertexShader_Texture_One.h"
#undef g_mainTexture
#define g_mainAdvanced D3D12_VertexShader_Advanced
#include "D3D12_VertexShader_Advanced_One.h"
#undef g_mainAdvanced
#define g_ColorRS D3D12_RootSig_Color
#include "D3D12_RootSig_Color_One.h"
#undef g_ColorRS
#define g_TextureRS D3D12_RootSig_Texture
#include "D3D12_RootSig_Texture_One.h"
#undef g_TextureRS
#define g_AdvancedRS D3D12_RootSig_Advanced
#include "D3D12_RootSig_Advanced_One.h"
#undef g_AdvancedRS
#include "../VisualC-GDK/shaders/D3D12_RootSig_Color_One.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_NV_One.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_Texture_One.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_YUV_One.h"
static struct
{
@@ -63,40 +81,14 @@ static struct
D3D12_RootSignature root_sig;
} D3D12_shaders[NUM_SHADERS] = {
{ D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
D3D12_VertexShader_Color, sizeof(D3D12_VertexShader_Color),
D3D12_VertexShader_Colors, sizeof(D3D12_VertexShader_Colors),
ROOTSIG_COLOR },
{ D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
D3D12_VertexShader_Texture, sizeof(D3D12_VertexShader_Texture),
D3D12_VertexShader_Textures, sizeof(D3D12_VertexShader_Textures),
ROOTSIG_TEXTURE },
#if SDL_HAVE_YUV
{ D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
#endif
{ D3D12_PixelShader_Advanced, sizeof(D3D12_PixelShader_Advanced),
D3D12_VertexShader_Advanced, sizeof(D3D12_VertexShader_Advanced),
ROOTSIG_ADVANCED },
};
static struct
@@ -106,10 +98,7 @@ static struct
} D3D12_rootsigs[NUM_ROOTSIGS] = {
{ D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) },
{ D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) },
#if SDL_HAVE_YUV
{ D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) },
{ D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) },
#endif
{ D3D12_RootSig_Advanced, sizeof(D3D12_RootSig_Advanced) },
};
extern "C" void

View File

@@ -31,28 +31,47 @@
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
/* Shader blob headers are generated with a pre-build step using buildshaders.bat */
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Colors_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Textures_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT601_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT709_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_JPEG_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT601_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT709_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_JPEG_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT601_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT709_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_JPEG_Series.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Color_Series.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Texture_Series.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_NV_Series.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_YUV_Series.h"
/* Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat */
#define g_main D3D12_PixelShader_Colors
#include "D3D12_PixelShader_Colors_Series.h"
#undef g_main
#define g_main D3D12_PixelShader_Textures
#include "D3D12_PixelShader_Textures_Series.h"
#undef g_main
#define g_main D3D12_PixelShader_Advanced
#include "D3D12_PixelShader_Advanced_Series.h"
#undef g_main
#define g_mainColor D3D12_VertexShader_Colors
#include "D3D12_VertexShader_Color_Series.h"
#undef g_mainColor
#define g_mainTexture D3D12_VertexShader_Textures
#include "D3D12_VertexShader_Texture_Series.h"
#undef g_mainTexture
#define g_mainAdvanced D3D12_VertexShader_Advanced
#include "D3D12_VertexShader_Advanced_Series.h"
#undef g_mainAdvanced
#define g_ColorRS D3D12_RootSig_Color
#include "D3D12_RootSig_Color_Series.h"
#undef g_ColorRS
#define g_TextureRS D3D12_RootSig_Texture
#include "D3D12_RootSig_Texture_Series.h"
#undef g_TextureRS
#define g_AdvancedRS D3D12_RootSig_Advanced
#include "D3D12_RootSig_Advanced_Series.h"
#undef g_AdvancedRS
#include "../VisualC-GDK/shaders/D3D12_RootSig_Color_Series.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_Texture_Series.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_YUV_Series.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_NV_Series.h"
static struct
{
@@ -63,40 +82,14 @@ static struct
D3D12_RootSignature root_sig;
} D3D12_shaders[NUM_SHADERS] = {
{ D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
D3D12_VertexShader_Color, sizeof(D3D12_VertexShader_Color),
D3D12_VertexShader_Colors, sizeof(D3D12_VertexShader_Colors),
ROOTSIG_COLOR },
{ D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
D3D12_VertexShader_Texture, sizeof(D3D12_VertexShader_Texture),
D3D12_VertexShader_Textures, sizeof(D3D12_VertexShader_Textures),
ROOTSIG_TEXTURE },
#if SDL_HAVE_YUV
{ D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
#endif
{ D3D12_PixelShader_Advanced, sizeof(D3D12_PixelShader_Advanced),
D3D12_VertexShader_Advanced, sizeof(D3D12_VertexShader_Advanced),
ROOTSIG_ADVANCED },
};
static struct
@@ -106,10 +99,7 @@ static struct
} D3D12_rootsigs[NUM_ROOTSIGS] = {
{ D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) },
{ D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) },
#if SDL_HAVE_YUV
{ D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) },
{ D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) },
#endif
{ D3D12_RootSig_Advanced, sizeof(D3D12_RootSig_Advanced) },
};
extern "C" void

View File

@@ -1,11 +1,21 @@
dxc -E main -T ps_6_0 -Fh D3D12_PixelShader_Colors.h D3D12_PixelShader_Colors.hlsl
dxc -E main -T ps_6_0 -Fh D3D12_PixelShader_Textures.h D3D12_PixelShader_Textures.hlsl
dxc -E main -T ps_6_0 -Fh D3D12_PixelShader_Advanced.h D3D12_PixelShader_Advanced.hlsl
rem This script runs for the Windows build, but also via the _xbox variant with these vars set.
rem Make sure to default to building for Windows if they're not set.
if %DXC%.==. set DXC=dxc
if %SUFFIX%.==. set SUFFIX=.h
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
dxc -E mainAdvanced -T vs_6_0 -Fh D3D12_VertexShader_Advanced.h D3D12_VertexShader.hlsl
echo Building with %DXC%
echo Suffix %SUFFIX%
dxc -E ColorRS -T rootsig_1_1 -rootsig-define ColorRS -Fh D3D12_RootSig_Color.h D3D12_VertexShader.hlsl
dxc -E TextureRS -T rootsig_1_1 -rootsig-define TextureRS -Fh D3D12_RootSig_Texture.h D3D12_VertexShader.hlsl
dxc -E AdvancedRS -T rootsig_1_1 -rootsig-define AdvancedRS -Fh D3D12_RootSig_Advanced.h D3D12_VertexShader.hlsl
cd "%~dp0"
%DXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_Colors%SUFFIX% D3D12_PixelShader_Colors.hlsl
%DXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_Textures%SUFFIX% D3D12_PixelShader_Textures.hlsl
%DXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_Advanced%SUFFIX% D3D12_PixelShader_Advanced.hlsl
%DXC% -E mainColor -T vs_6_0 -Fh D3D12_VertexShader_Color%SUFFIX% D3D12_VertexShader.hlsl
%DXC% -E mainTexture -T vs_6_0 -Fh D3D12_VertexShader_Texture%SUFFIX% D3D12_VertexShader.hlsl
%DXC% -E mainAdvanced -T vs_6_0 -Fh D3D12_VertexShader_Advanced%SUFFIX% D3D12_VertexShader.hlsl
%DXC% -E ColorRS -T rootsig_1_1 -rootsig-define ColorRS -Fh D3D12_RootSig_Color%SUFFIX% D3D12_VertexShader.hlsl
%DXC% -E TextureRS -T rootsig_1_1 -rootsig-define TextureRS -Fh D3D12_RootSig_Texture%SUFFIX% D3D12_VertexShader.hlsl
%DXC% -E AdvancedRS -T rootsig_1_1 -rootsig-define AdvancedRS -Fh D3D12_RootSig_Advanced%SUFFIX% D3D12_VertexShader.hlsl

View File

@@ -0,0 +1,13 @@
if %2.==one. goto setxboxone
rem Xbox Series compile
set DXC="%GameDKLatest%\GXDK\bin\Scarlett\DXC.exe"
set SUFFIX=_Series.h
goto startbuild
:setxboxone
set DXC="%GameDKLatest%\GXDK\bin\XboxOne\DXC.exe"
set SUFFIX=_One.h
:startbuild
call "%~dp0\compile_shaders.bat"