WinRT: compiled the d3d11 renderer's shaders into SDL itself

Previously, the shaders would get compiled separately, the output of which would need to be packaged into the app.  This change should make SDL's dll be the only binary needed to include SDL in a WinRT app.
main
David Ludwig 2013-12-25 21:39:48 -05:00
parent ca867fc92d
commit ce8057221a
8 changed files with 413 additions and 236 deletions

View File

@ -397,26 +397,6 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT> <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
</FxCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" /> <Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -7,9 +7,6 @@
<Filter Include="Source Files"> <Filter Include="Source Files">
<UniqueIdentifier>{abc3a7e6-f955-4cb5-8340-fae0f653e9c1}</UniqueIdentifier> <UniqueIdentifier>{abc3a7e6-f955-4cb5-8340-fae0f653e9c1}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="GPU Shaders">
<UniqueIdentifier>{fd67993e-5155-488b-9313-d1eb06a1b67e}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\include\begin_code.h"> <ClInclude Include="..\..\include\begin_code.h">
@ -612,15 +609,4 @@
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
<Filter>GPU Shaders</Filter>
</FxCompile>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
<Filter>GPU Shaders</Filter>
</FxCompile>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
<Filter>GPU Shaders</Filter>
</FxCompile>
</ItemGroup>
</Project> </Project>

View File

@ -324,48 +324,6 @@
<ClInclude Include="..\..\src\video\winrt\SDL_winrtopengles.h" /> <ClInclude Include="..\..\src\video\winrt\SDL_winrtopengles.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h" /> <ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0_level_9_1</ShaderModel>
</FxCompile>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0_level_9_1</ShaderModel>
</FxCompile>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">4.0_level_9_1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0_level_9_1</ShaderModel>
</FxCompile>
</ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</ProjectGuid> <ProjectGuid>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>

View File

@ -1,16 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
<Filter>GPU Shaders</Filter>
</FxCompile>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
<Filter>GPU Shaders</Filter>
</FxCompile>
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
<Filter>GPU Shaders</Filter>
</FxCompile>
</ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\SDL.c"> <ClCompile Include="..\..\src\SDL.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
@ -652,8 +641,5 @@
<Filter Include="Source Files"> <Filter Include="Source Files">
<UniqueIdentifier>{ddf04d85-6a87-4c5a-bc52-869b38f45a61}</UniqueIdentifier> <UniqueIdentifier>{ddf04d85-6a87-4c5a-bc52-869b38f45a61}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="GPU Shaders">
<UniqueIdentifier>{83ed1283-8234-4c77-99a8-ffcfd8ce7381}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,12 +0,0 @@
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
float4 main(PixelShaderInput input) : SV_TARGET
{
return input.color;
}

View File

@ -1,14 +0,0 @@
Texture2D theTexture : register(t0);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
float4 main(PixelShaderInput input) : SV_TARGET
{
return theTexture.Sample(theSampler, input.tex) * input.color;
}

View File

@ -1,41 +0,0 @@
#pragma pack_matrix( row_major )
cbuffer VertexShaderConstants : register(b0)
{
matrix model;
matrix view;
matrix projection;
};
struct VertexShaderInput
{
float3 pos : POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
struct VertexShaderOutput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
VertexShaderOutput main(VertexShaderInput input)
{
VertexShaderOutput output;
float4 pos = float4(input.pos, 1.0f);
// Transform the vertex position into projected space.
pos = mul(pos, model);
pos = mul(pos, view);
pos = mul(pos, projection);
output.pos = pos;
// Pass through texture coordinates and color values without transformation
output.tex = input.tex;
output.color = input.color;
return output;
}

View File

@ -130,6 +130,395 @@ typedef struct
} D3D11_RenderData; } D3D11_RenderData;
/* Direct3D 11.x shaders
SDL's shaders are compiled into SDL itself, to simplify distribution.
All Direct3D 11.x shaders were compiled with the following:
fxc /E"main" /T "<TYPE>" /Fo"<OUTPUT FILE>" "<INPUT FILE>"
Variables:
- <TYPE>: the type of shader. A table of utilized shader types is
listed below.
- <OUTPUT FILE>: where to store compiled output
- <INPUT FILE>: where to read shader source code from
Shader types:
- ps_4_0_level_9_1: Pixel shader for Windows 8+, including Windows RT
- vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT
- ps_4_0_level_9_3: Pixel shader for Windows Phone 8
- vs_4_0_level_9_3: Vertex shader for Windows Phone 8
*/
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
#define D3D11_USE_SHADER_MODEL_4_0_level_9_3
#else
#define D3D11_USE_SHADER_MODEL_4_0_level_9_1
#endif
/* The texture-rendering pixel shader:
--- D3D11_PixelShader_Textures.hlsl ---
Texture2D theTexture : register(t0);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
float4 main(PixelShaderInput input) : SV_TARGET
{
return theTexture.Sample(theSampler, input.tex) * input.color;
}
*/
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_PixelShader_Textures[] = {
0x43425844, 0x6299b59f, 0x155258f2, 0x873ab86a, 0xfcbb6dcd, 0x00000001,
0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
0x00280000, 0x00000000, 0xffff0200, 0x0200001f, 0x80000000, 0xb0030000,
0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
};
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_PixelShader_Textures[] = {
0x43425844, 0x5876569a, 0x01b6c87e, 0x8447454f, 0xc7f3ef10, 0x00000001,
0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
0x00280000, 0x00000000, 0xffff0201, 0x0200001f, 0x80000000, 0xb0030000,
0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
};
#else
#error "An appropriate 'textures' pixel shader is not defined"
#endif
/* The color-only-rendering pixel shader:
--- D3D11_PixelShader_Colors.hlsl ---
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
float4 main(PixelShaderInput input) : SV_TARGET
{
return input.color;
}
*/
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_PixelShader_Colors[] = {
0x43425844, 0xd74c28fe, 0xa1eb8804, 0x269d512a, 0x7699723d, 0x00000001,
0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
};
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_PixelShader_Colors[] = {
0x43425844, 0x93f6ccfc, 0x5f919270, 0x7a11aa4f, 0x9148e931, 0x00000001,
0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054,
};
#else
#error "An appropriate 'colors' pixel shader is not defined."
#endif
/* The sole vertex shader:
--- D3D11_VertexShader.hlsl ---
#pragma pack_matrix( row_major )
cbuffer VertexShaderConstants : register(b0)
{
matrix model;
matrix view;
matrix projection;
};
struct VertexShaderInput
{
float3 pos : POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
struct VertexShaderOutput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
VertexShaderOutput main(VertexShaderInput input)
{
VertexShaderOutput output;
float4 pos = float4(input.pos, 1.0f);
// Transform the vertex position into projected space.
pos = mul(pos, model);
pos = mul(pos, view);
pos = mul(pos, projection);
output.pos = pos;
// Pass through texture coordinates and color values without transformation
output.tex = input.tex;
output.color = input.color;
return output;
}
*/
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_VertexShader[] = {
0x43425844, 0x3f31b022, 0x2ffad8b8, 0xd6c45cbd, 0xa7894c28, 0x00000001,
0x00000690, 0x00000006, 0x00000038, 0x000001b8, 0x00000418, 0x00000494,
0x000005ac, 0x0000061c, 0x396e6f41, 0x00000178, 0x00000178, 0xfffe0200,
0x00000144, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
0x00300001, 0x00000000, 0x0001000c, 0x00000000, 0x00000000, 0xfffe0200,
0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x03000005, 0x800f0001,
0x80550000, 0xa0e4000a, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40009,
0x80e40001, 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e4000b, 0x80e40001,
0x04000004, 0x800f0000, 0x80ff0000, 0xa0e4000c, 0x80e40001, 0x04000004,
0xc0030000, 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000,
0x80e40000, 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001,
0x90e40002, 0x0000ffff, 0x52444853, 0x00000258, 0x00010040, 0x00000096,
0x04000059, 0x00208e46, 0x00000000, 0x0000000c, 0x0300005f, 0x00101072,
0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2,
0x00000002, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065,
0x00102032, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068,
0x00000002, 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000,
0x00208e46, 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000,
0x00101006, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46,
0x00000000, 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000,
0x00208e46, 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000,
0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000,
0x00000003, 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000,
0x00208e46, 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001,
0x00100006, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46,
0x00000001, 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000,
0x00208e46, 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032,
0x001000f2, 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000,
0x00000007, 0x00100e46, 0x00000001, 0x08000038, 0x001000f2, 0x00000001,
0x00100556, 0x00000000, 0x00208e46, 0x00000000, 0x00000009, 0x0a000032,
0x001000f2, 0x00000001, 0x00100006, 0x00000000, 0x00208e46, 0x00000000,
0x00000008, 0x00100e46, 0x00000001, 0x0a000032, 0x001000f2, 0x00000001,
0x00100aa6, 0x00000000, 0x00208e46, 0x00000000, 0x0000000a, 0x00100e46,
0x00000001, 0x0a000032, 0x001020f2, 0x00000000, 0x00100ff6, 0x00000000,
0x00208e46, 0x00000000, 0x0000000b, 0x00100e46, 0x00000001, 0x05000036,
0x00102032, 0x00000001, 0x00101046, 0x00000001, 0x05000036, 0x001020f2,
0x00000002, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074,
0x0000000f, 0x00000002, 0x00000000, 0x00000006, 0x00000004, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452,
0x00000110, 0x00000001, 0x00000054, 0x00000001, 0x0000001c, 0xfffe0400,
0x00000100, 0x000000dc, 0x0000003c, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x74726556, 0x68537865,
0x72656461, 0x736e6f43, 0x746e6174, 0xabab0073, 0x0000003c, 0x00000003,
0x0000006c, 0x000000c0, 0x00000000, 0x00000000, 0x000000b4, 0x00000000,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x000000cc, 0x00000040,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x000000d1, 0x00000080,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x65646f6d, 0xabab006c,
0x00030002, 0x00040004, 0x00000000, 0x00000000, 0x77656976, 0x6f727000,
0x7463656a, 0x006e6f69, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029,
0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e30332e,
0x30303239, 0x3336312e, 0xab003438, 0x4e475349, 0x00000068, 0x00000003,
0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
0x00000707, 0x00000059, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
0x00000303, 0x00000062, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
0x00000f0f, 0x49534f50, 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044,
0x00524f4c, 0x4e47534f, 0x0000006c, 0x00000003, 0x00000008, 0x00000050,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c,
0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03, 0x00000065,
0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653,
0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f,
};
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_VertexShader[] = {
0x43425844, 0xacfd840a, 0x6a6ae1e1, 0xc3649c43, 0x8bfc0816, 0x00000001,
0x00000690, 0x00000006, 0x00000038, 0x000001b8, 0x00000418, 0x00000494,
0x000005ac, 0x0000061c, 0x396e6f41, 0x00000178, 0x00000178, 0xfffe0200,
0x00000144, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
0x00300001, 0x00000000, 0x0001000c, 0x00000000, 0x00000000, 0xfffe0201,
0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x03000005, 0x800f0001,
0x80550000, 0xa0e4000a, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40009,
0x80e40001, 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e4000b, 0x80e40001,
0x04000004, 0x800f0000, 0x80ff0000, 0xa0e4000c, 0x80e40001, 0x04000004,
0xc0030000, 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000,
0x80e40000, 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001,
0x90e40002, 0x0000ffff, 0x52444853, 0x00000258, 0x00010040, 0x00000096,
0x04000059, 0x00208e46, 0x00000000, 0x0000000c, 0x0300005f, 0x00101072,
0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2,
0x00000002, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065,
0x00102032, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068,
0x00000002, 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000,
0x00208e46, 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000,
0x00101006, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46,
0x00000000, 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000,
0x00208e46, 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000,
0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000,
0x00000003, 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000,
0x00208e46, 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001,
0x00100006, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46,
0x00000001, 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000,
0x00208e46, 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032,
0x001000f2, 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000,
0x00000007, 0x00100e46, 0x00000001, 0x08000038, 0x001000f2, 0x00000001,
0x00100556, 0x00000000, 0x00208e46, 0x00000000, 0x00000009, 0x0a000032,
0x001000f2, 0x00000001, 0x00100006, 0x00000000, 0x00208e46, 0x00000000,
0x00000008, 0x00100e46, 0x00000001, 0x0a000032, 0x001000f2, 0x00000001,
0x00100aa6, 0x00000000, 0x00208e46, 0x00000000, 0x0000000a, 0x00100e46,
0x00000001, 0x0a000032, 0x001020f2, 0x00000000, 0x00100ff6, 0x00000000,
0x00208e46, 0x00000000, 0x0000000b, 0x00100e46, 0x00000001, 0x05000036,
0x00102032, 0x00000001, 0x00101046, 0x00000001, 0x05000036, 0x001020f2,
0x00000002, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074,
0x0000000f, 0x00000002, 0x00000000, 0x00000006, 0x00000004, 0x00000000,
0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452,
0x00000110, 0x00000001, 0x00000054, 0x00000001, 0x0000001c, 0xfffe0400,
0x00000100, 0x000000dc, 0x0000003c, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x74726556, 0x68537865,
0x72656461, 0x736e6f43, 0x746e6174, 0xabab0073, 0x0000003c, 0x00000003,
0x0000006c, 0x000000c0, 0x00000000, 0x00000000, 0x000000b4, 0x00000000,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x000000cc, 0x00000040,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x000000d1, 0x00000080,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x65646f6d, 0xabab006c,
0x00030002, 0x00040004, 0x00000000, 0x00000000, 0x77656976, 0x6f727000,
0x7463656a, 0x006e6f69, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029,
0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e30332e,
0x30303239, 0x3336312e, 0xab003438, 0x4e475349, 0x00000068, 0x00000003,
0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
0x00000707, 0x00000059, 0x00000000, 0x00000000, 0x00000003, 0x00000001,
0x00000303, 0x00000062, 0x00000000, 0x00000000, 0x00000003, 0x00000002,
0x00000f0f, 0x49534f50, 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044,
0x00524f4c, 0x4e47534f, 0x0000006c, 0x00000003, 0x00000008, 0x00000050,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c,
0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03, 0x00000065,
0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653,
0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
};
#else
#error "An appropriate vertex shader is not defined."
#endif
/* Direct3D 11.1 renderer implementation */ /* Direct3D 11.1 renderer implementation */
static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags); static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags);
static void D3D11_WindowEvent(SDL_Renderer * renderer, static void D3D11_WindowEvent(SDL_Renderer * renderer,
@ -294,66 +683,6 @@ D3D11_DestroyRenderer(SDL_Renderer * renderer)
} }
} }
static bool
D3D11_ReadFileContents(const wstring & fileName, vector<char> & out)
{
ifstream in(fileName, ios::in | ios::binary);
if (!in) {
return false;
}
in.seekg(0, ios::end);
out.resize((size_t) in.tellg());
in.seekg(0, ios::beg);
in.read(&out[0], out.size());
return in.good();
}
static bool
D3D11_ReadShaderContents(const wstring & shaderName, vector<char> & out)
{
wstring fileName;
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
fileName = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_INSTALLED_LOCATION);
fileName += L"\\SDL_VS2012_WinRT\\";
#elif WINAPI_FAMILY == WINAPI_PHONE_APP
fileName = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_INSTALLED_LOCATION);
fileName += L"\\";
#endif
// TODO, WinRT: test Direct3D 11.1 shader loading on Win32
fileName += shaderName;
return D3D11_ReadFileContents(fileName, out);
}
static HRESULT
D3D11_LoadPixelShader(SDL_Renderer * renderer,
const wstring & shaderName,
ID3D11PixelShader ** shaderOutput)
{
D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata;
HRESULT result = S_OK;
vector<char> fileData;
if (!D3D11_ReadShaderContents(shaderName, fileData)) {
SDL_SetError("Unable to open SDL's pixel shader file.");
return E_FAIL;
}
result = data->d3dDevice->CreatePixelShader(
&fileData[0],
fileData.size(),
nullptr,
shaderOutput
);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader", result);
return result;
}
return S_OK;
}
static HRESULT static HRESULT
D3D11_CreateBlendMode(SDL_Renderer * renderer, D3D11_CreateBlendMode(SDL_Renderer * renderer,
BOOL enableBlending, BOOL enableBlending,
@ -396,12 +725,12 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
// Make sure Direct3D's debugging feature gets used, if the app requests it. // Make sure Direct3D's debugging feature gets used, if the app requests it.
const char *hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D11_DEBUG); //const char *hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D11_DEBUG);
if (hint) { //if (hint) {
if (*hint == '1') { // if (*hint == '1') {
creationFlags |= D3D11_CREATE_DEVICE_DEBUG; creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
} // }
} //}
// This array defines the set of DirectX hardware feature levels this app will support. // This array defines the set of DirectX hardware feature levels this app will support.
// Note the ordering should be preserved. // Note the ordering should be preserved.
@ -481,15 +810,9 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
// //
// Load in SDL's one and only vertex shader: // Load in SDL's one and only vertex shader:
// //
vector<char> fileData;
if (!D3D11_ReadShaderContents(L"SDL_D3D11_VertexShader_Default.cso", fileData)) {
SDL_SetError("Unable to open SDL's vertex shader file.");
return E_FAIL;
}
result = data->d3dDevice->CreateVertexShader( result = data->d3dDevice->CreateVertexShader(
&fileData[0], D3D11_VertexShader,
fileData.size(), sizeof(D3D11_VertexShader),
nullptr, nullptr,
&data->vertexShader &data->vertexShader
); );
@ -511,8 +834,8 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
result = data->d3dDevice->CreateInputLayout( result = data->d3dDevice->CreateInputLayout(
vertexDesc, vertexDesc,
ARRAYSIZE(vertexDesc), ARRAYSIZE(vertexDesc),
&fileData[0], D3D11_VertexShader,
fileData.size(), sizeof(D3D11_VertexShader),
&data->inputLayout &data->inputLayout
); );
if (FAILED(result)) { if (FAILED(result)) {
@ -523,15 +846,26 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
// //
// Load in SDL's pixel shaders // Load in SDL's pixel shaders
// //
result = D3D11_LoadPixelShader(renderer, L"SDL_D3D11_PixelShader_TextureColored.cso", &data->texturePixelShader);
result = data->d3dDevice->CreatePixelShader(
D3D11_PixelShader_Textures,
sizeof(D3D11_PixelShader_Textures),
nullptr,
&data->texturePixelShader
);
if (FAILED(result)) { if (FAILED(result)) {
// D3D11_LoadPixelShader will have aleady set the SDL error WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['textures' shader]", result);
return result; return result;
} }
result = D3D11_LoadPixelShader(renderer, L"SDL_D3D11_PixelShader_FixedColor.cso", &data->colorPixelShader); result = data->d3dDevice->CreatePixelShader(
D3D11_PixelShader_Colors,
sizeof(D3D11_PixelShader_Colors),
nullptr,
&data->colorPixelShader
);
if (FAILED(result)) { if (FAILED(result)) {
// D3D11_LoadPixelShader will have aleady set the SDL error WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['color' shader]", result);
return result; return result;
} }