WinRT: simplified the d3d11 vertex shader a bit

The projection and view matrices are now computed ahead of time, as they both get computed in the same spot, and typically not often.  If this does, however, become a performance problem later on, this change can always be reverted.
main
David Ludwig 2013-12-26 11:03:43 -05:00
parent 7ef05d266f
commit 94233675c7
1 changed files with 133 additions and 143 deletions

View File

@ -71,8 +71,7 @@ static const D3D11_FILTER SDL_D3D11_LINEAR_FILTER = D3D11_FILTER_MIN_MAG_MIP_LIN
struct VertexShaderConstants struct VertexShaderConstants
{ {
DirectX::XMFLOAT4X4 model; DirectX::XMFLOAT4X4 model;
DirectX::XMFLOAT4X4 view; DirectX::XMFLOAT4X4 projectionAndView;
DirectX::XMFLOAT4X4 projection;
}; };
/* Per-vertex data */ /* Per-vertex data */
@ -153,6 +152,12 @@ typedef struct
- vs_4_0_level_9_1: Vertex 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 - ps_4_0_level_9_3: Pixel shader for Windows Phone 8
- vs_4_0_level_9_3: Vertex shader for Windows Phone 8 - vs_4_0_level_9_3: Vertex shader for Windows Phone 8
Shader object code was converted to a list of DWORDs via the following
*nix style command (available separately from Windows + MSVC):
hexdump -v -e '6/4 "0x%08.8x, " "\n"' <FILE>
*/ */
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
#define D3D11_USE_SHADER_MODEL_4_0_level_9_3 #define D3D11_USE_SHADER_MODEL_4_0_level_9_3
@ -337,8 +342,7 @@ static const DWORD D3D11_PixelShader_Colors[] = {
cbuffer VertexShaderConstants : register(b0) cbuffer VertexShaderConstants : register(b0)
{ {
matrix model; matrix model;
matrix view; matrix projectionAndView;
matrix projection;
}; };
struct VertexShaderInput struct VertexShaderInput
@ -362,8 +366,7 @@ static const DWORD D3D11_PixelShader_Colors[] = {
// Transform the vertex position into projected space. // Transform the vertex position into projected space.
pos = mul(pos, model); pos = mul(pos, model);
pos = mul(pos, view); pos = mul(pos, projectionAndView);
pos = mul(pos, projection);
output.pos = pos; output.pos = pos;
// Pass through texture coordinates and color values without transformation // Pass through texture coordinates and color values without transformation
@ -375,11 +378,11 @@ static const DWORD D3D11_PixelShader_Colors[] = {
*/ */
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) #if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_VertexShader[] = { static const DWORD D3D11_VertexShader[] = {
0x43425844, 0x3f31b022, 0x2ffad8b8, 0xd6c45cbd, 0xa7894c28, 0x00000001, 0x43425844, 0x62dfae5f, 0x3e8bd8df, 0x9ec97127, 0x5044eefb, 0x00000001,
0x00000690, 0x00000006, 0x00000038, 0x000001b8, 0x00000418, 0x00000494, 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
0x000005ac, 0x0000061c, 0x396e6f41, 0x00000178, 0x00000178, 0xfffe0200, 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
0x00000144, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000, 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
0x00300001, 0x00000000, 0x0001000c, 0x00000000, 0x00000000, 0xfffe0200, 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0200,
0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001, 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000, 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000, 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
@ -387,72 +390,62 @@ static const DWORD D3D11_VertexShader[] = {
0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000, 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001, 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004, 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x03000005, 0x800f0001, 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
0x80550000, 0xa0e4000a, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40009, 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
0x80e40001, 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e4000b, 0x80e40001, 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
0x04000004, 0x800f0000, 0x80ff0000, 0xa0e4000c, 0x80e40001, 0x04000004, 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
0xc0030000, 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
0x80e40000, 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
0x90e40002, 0x0000ffff, 0x52444853, 0x00000258, 0x00010040, 0x00000096, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
0x04000059, 0x00208e46, 0x00000000, 0x0000000c, 0x0300005f, 0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
0x00000002, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
0x00102032, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
0x00000002, 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
0x00208e46, 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
0x00101006, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
0x00000000, 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
0x00208e46, 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
0x00000003, 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
0x00208e46, 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
0x00100006, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
0x00000001, 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
0x00208e46, 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
0x001000f2, 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
0x00000007, 0x00100e46, 0x00000001, 0x08000038, 0x001000f2, 0x00000001, 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
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, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000110, 0x00000001, 0x00000054, 0x00000001, 0x0000001c, 0xfffe0400, 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
0x00000100, 0x000000dc, 0x0000003c, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x74726556, 0x68537865, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
0x72656461, 0x736e6f43, 0x746e6174, 0xabab0073, 0x0000003c, 0x00000003, 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
0x0000006c, 0x000000c0, 0x00000000, 0x00000000, 0x000000b4, 0x00000000, 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x000000cc, 0x00000040, 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x000000d1, 0x00000080, 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x65646f6d, 0xabab006c, 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
0x00030002, 0x00040004, 0x00000000, 0x00000000, 0x77656976, 0x6f727000, 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
0x7463656a, 0x006e6f69, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e30332e, 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
0x30303239, 0x3336312e, 0xab003438, 0x4e475349, 0x00000068, 0x00000003, 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
0x00000707, 0x00000059, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
0x00000303, 0x00000062, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
0x00000f0f, 0x49534f50, 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
0x00524f4c, 0x4e47534f, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
}; };
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) #elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_VertexShader[] = { static const DWORD D3D11_VertexShader[] = {
0x43425844, 0xacfd840a, 0x6a6ae1e1, 0xc3649c43, 0x8bfc0816, 0x00000001, 0x43425844, 0x01a24e41, 0x696af551, 0x4b2a87d1, 0x82ea03f6, 0x00000001,
0x00000690, 0x00000006, 0x00000038, 0x000001b8, 0x00000418, 0x00000494, 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
0x000005ac, 0x0000061c, 0x396e6f41, 0x00000178, 0x00000178, 0xfffe0200, 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
0x00000144, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000, 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
0x00300001, 0x00000000, 0x0001000c, 0x00000000, 0x00000000, 0xfffe0201, 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0201,
0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001, 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000, 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000, 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
@ -460,64 +453,54 @@ static const DWORD D3D11_VertexShader[] = {
0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000, 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001, 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004, 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x03000005, 0x800f0001, 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
0x80550000, 0xa0e4000a, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40009, 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
0x80e40001, 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e4000b, 0x80e40001, 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
0x04000004, 0x800f0000, 0x80ff0000, 0xa0e4000c, 0x80e40001, 0x04000004, 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
0xc0030000, 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
0x80e40000, 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
0x90e40002, 0x0000ffff, 0x52444853, 0x00000258, 0x00010040, 0x00000096, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
0x04000059, 0x00208e46, 0x00000000, 0x0000000c, 0x0300005f, 0x00101072, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
0x00000002, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
0x00102032, 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
0x00000002, 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
0x00208e46, 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
0x00101006, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
0x00000000, 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
0x00208e46, 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
0x00000003, 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
0x00208e46, 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
0x00100006, 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
0x00000001, 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
0x00208e46, 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
0x001000f2, 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
0x00000007, 0x00100e46, 0x00000001, 0x08000038, 0x001000f2, 0x00000001, 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
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, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000110, 0x00000001, 0x00000054, 0x00000001, 0x0000001c, 0xfffe0400, 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
0x00000100, 0x000000dc, 0x0000003c, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x74726556, 0x68537865, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
0x72656461, 0x736e6f43, 0x746e6174, 0xabab0073, 0x0000003c, 0x00000003, 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
0x0000006c, 0x000000c0, 0x00000000, 0x00000000, 0x000000b4, 0x00000000, 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x000000cc, 0x00000040, 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x000000d1, 0x00000080, 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
0x00000040, 0x00000002, 0x000000bc, 0x00000000, 0x65646f6d, 0xabab006c, 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
0x00030002, 0x00040004, 0x00000000, 0x00000000, 0x77656976, 0x6f727000, 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
0x7463656a, 0x006e6f69, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e30332e, 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
0x30303239, 0x3336312e, 0xab003438, 0x4e475349, 0x00000068, 0x00000003, 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
0x00000707, 0x00000059, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
0x00000303, 0x00000062, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
0x00000f0f, 0x49534f50, 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
0x00524f4c, 0x4e47534f, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
}; };
#else #else
#error "An appropriate vertex shader is not defined." #error "An appropriate vertex shader is not defined."
@ -1698,19 +1681,20 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
// Keep in mind here that the Y-axis will be been inverted (from Direct3D's // Keep in mind here that the Y-axis will be been inverted (from Direct3D's
// default coordinate system) so rotations will be done in the opposite // default coordinate system) so rotations will be done in the opposite
// direction of the DXGI_MODE_ROTATION enumeration. // direction of the DXGI_MODE_ROTATION enumeration.
DirectX::XMMATRIX projection;
switch (D3D11_GetRotationForOrientation(data->orientation)) switch (D3D11_GetRotationForOrientation(data->orientation))
{ {
case DXGI_MODE_ROTATION_IDENTITY: case DXGI_MODE_ROTATION_IDENTITY:
XMStoreFloat4x4(&data->vertexShaderConstantsData.projection, XMMatrixIdentity()); projection = XMMatrixIdentity();
break; break;
case DXGI_MODE_ROTATION_ROTATE270: case DXGI_MODE_ROTATION_ROTATE270:
XMStoreFloat4x4(&data->vertexShaderConstantsData.projection, XMMatrixRotationZ(XM_PIDIV2)); projection = XMMatrixRotationZ(XM_PIDIV2);
break; break;
case DXGI_MODE_ROTATION_ROTATE180: case DXGI_MODE_ROTATION_ROTATE180:
XMStoreFloat4x4(&data->vertexShaderConstantsData.projection, XMMatrixRotationZ(XM_PI)); projection = XMMatrixRotationZ(XM_PI);
break; break;
case DXGI_MODE_ROTATION_ROTATE90: case DXGI_MODE_ROTATION_ROTATE90:
XMStoreFloat4x4(&data->vertexShaderConstantsData.projection, XMMatrixRotationZ(-XM_PIDIV2)); projection = XMMatrixRotationZ(-XM_PIDIV2);
break; break;
default: default:
return SDL_SetError("An unknown DisplayOrientation is being used"); return SDL_SetError("An unknown DisplayOrientation is being used");
@ -1721,16 +1705,22 @@ D3D11_UpdateViewport(SDL_Renderer * renderer)
// //
float viewportWidth = (float) renderer->viewport.w; float viewportWidth = (float) renderer->viewport.w;
float viewportHeight = (float) renderer->viewport.h; float viewportHeight = (float) renderer->viewport.h;
XMStoreFloat4x4(&data->vertexShaderConstantsData.view, DirectX::XMMATRIX view = XMMatrixMultiply(
XMMatrixMultiply(
XMMatrixScaling(2.0f / viewportWidth, 2.0f / viewportHeight, 1.0f), XMMatrixScaling(2.0f / viewportWidth, 2.0f / viewportHeight, 1.0f),
XMMatrixMultiply( XMMatrixMultiply(
XMMatrixTranslation(-1, -1, 0), XMMatrixTranslation(-1, -1, 0),
XMMatrixRotationX(XM_PI) XMMatrixRotationX(XM_PI)
))); ));
#if 0
data->vertexShaderConstantsData.view = XMMatrixIdentity(); //
#endif // Combine the projection + view matrix together now, as both only get
// set here (as of this writing, on Dec 26, 2013). When done, store it
// for eventual transfer to the GPU.
//
XMStoreFloat4x4(&data->vertexShaderConstantsData.projectionAndView,
XMMatrixMultiply(
view,
projection));
// //
// Reset the model matrix // Reset the model matrix