Skip to content

Commit

Permalink
Backends: DX9: vs_3_0/ps_3_0 -> vs_2_0/ps_2_0, support more hardware
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuanlan authored and Kuanlan committed Feb 28, 2021
1 parent e4fb921 commit 7d600fd
Showing 1 changed file with 81 additions and 83 deletions.
164 changes: 81 additions & 83 deletions backends/imgui_impl_d3d9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ bool ImGui_ImplDX9_CreateDeviceObjects()
if (D3D_OK != g.d3d9Device->CreateVertexDeclaration(layout, &g.d3d9InputLayout))
return false;

// Create vertex shader (vs_3_0)
// Create vertex shader
/*
float4x4 mvp : register(c0);
Expand Down Expand Up @@ -352,60 +352,55 @@ bool ImGui_ImplDX9_CreateDeviceObjects()
return output;
};
*/
// Precompile with Visual Studio 2019 HLSL compiler, vs_2_0
const BYTE vertex_shader_blob[] = {
0, 3, 254, 255, 254, 255,
30, 0, 67, 84, 65, 66,
28, 0, 0, 0, 75, 0,
0, 0, 0, 3, 254, 255,
1, 0, 0, 0, 28, 0,
0, 0, 0, 1, 0, 0,
68, 0, 0, 0, 48, 0,
0, 0, 2, 0, 0, 0,
4, 0, 2, 0, 52, 0,
0, 0, 0, 0, 0, 0,
109, 118, 112, 0, 3, 0,
3, 0, 4, 0, 4, 0,
1, 0, 0, 0, 0, 0,
0, 0, 118, 115, 95, 51,
95, 48, 0, 77, 105, 99,
114, 111, 115, 111, 102, 116,
32, 40, 82, 41, 32, 72,
76, 83, 76, 32, 83, 104,
97, 100, 101, 114, 32, 67,
111, 109, 112, 105, 108, 101,
114, 32, 49, 48, 46, 49,
0, 171, 31, 0, 0, 2,
0, 0, 0, 128, 0, 0,
15, 144, 31, 0, 0, 2,
5, 0, 0, 128, 1, 0,
15, 144, 31, 0, 0, 2,
10, 0, 0, 128, 2, 0,
15, 144, 31, 0, 0, 2,
0, 0, 0, 128, 0, 0,
15, 224, 31, 0, 0, 2,
5, 0, 0, 128, 1, 0,
3, 224, 31, 0, 0, 2,
10, 0, 0, 128, 2, 0,
15, 224, 5, 0, 0, 3,
0, 0, 15, 128, 1, 0,
228, 160, 0, 0, 85, 144,
4, 0, 0, 4, 0, 0,
15, 128, 0, 0, 228, 160,
0, 0, 0, 144, 0, 0,
228, 128, 2, 0, 0, 3,
0, 0, 15, 224, 0, 0,
228, 128, 3, 0, 228, 160,
1, 0, 0, 2, 1, 0,
3, 224, 1, 0, 228, 144,
1, 0, 0, 2, 2, 0,
15, 224, 2, 0, 228, 144,
255, 255, 0, 0
0, 2, 254, 255, 254, 255,
30, 0, 67, 84, 65, 66,
28, 0, 0, 0, 75, 0,
0, 0, 0, 2, 254, 255,
1, 0, 0, 0, 28, 0,
0, 0, 0, 1, 0, 0,
68, 0, 0, 0, 48, 0,
0, 0, 2, 0, 0, 0,
4, 0, 2, 0, 52, 0,
0, 0, 0, 0, 0, 0,
109, 118, 112, 0, 3, 0,
3, 0, 4, 0, 4, 0,
1, 0, 0, 0, 0, 0,
0, 0, 118, 115, 95, 50,
95, 48, 0, 77, 105, 99,
114, 111, 115, 111, 102, 116,
32, 40, 82, 41, 32, 72,
76, 83, 76, 32, 83, 104,
97, 100, 101, 114, 32, 67,
111, 109, 112, 105, 108, 101,
114, 32, 49, 48, 46, 49,
0, 171, 31, 0, 0, 2,
0, 0, 0, 128, 0, 0,
15, 144, 31, 0, 0, 2,
5, 0, 0, 128, 1, 0,
15, 144, 31, 0, 0, 2,
10, 0, 0, 128, 2, 0,
15, 144, 5, 0, 0, 3,
0, 0, 15, 128, 0, 0,
85, 144, 1, 0, 228, 160,
4, 0, 0, 4, 0, 0,
15, 128, 0, 0, 228, 160,
0, 0, 0, 144, 0, 0,
228, 128, 2, 0, 0, 3,
0, 0, 15, 192, 0, 0,
228, 128, 3, 0, 228, 160,
1, 0, 0, 2, 0, 0,
3, 224, 1, 0, 228, 144,
1, 0, 0, 2, 0, 0,
15, 208, 2, 0, 228, 144,
255, 255, 0, 0
};
SafeRelease(g.d3d9VertexShader);
if (D3D_OK != g.d3d9Device->CreateVertexShader((DWORD*)vertex_shader_blob, &g.d3d9VertexShader))
return false;

// Create pixel shader (ps_3_0)
// Create pixel shader
/*
sampler tex0 : register(s0);
Expand All @@ -430,41 +425,44 @@ bool ImGui_ImplDX9_CreateDeviceObjects()
return output;
};
*/
// Precompile with Visual Studio 2019 HLSL compiler, ps_2_0
const BYTE pixel_shader_blob[] = {
0, 3, 255, 255, 254, 255,
31, 0, 67, 84, 65, 66,
28, 0, 0, 0, 79, 0,
0, 0, 0, 3, 255, 255,
1, 0, 0, 0, 28, 0,
0, 0, 0, 1, 0, 0,
72, 0, 0, 0, 48, 0,
0, 0, 3, 0, 0, 0,
1, 0, 2, 0, 56, 0,
0, 0, 0, 0, 0, 0,
116, 101, 120, 48, 0, 171,
171, 171, 4, 0, 12, 0,
1, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0,
112, 115, 95, 51, 95, 48,
0, 77, 105, 99, 114, 111,
115, 111, 102, 116, 32, 40,
82, 41, 32, 72, 76, 83,
76, 32, 83, 104, 97, 100,
101, 114, 32, 67, 111, 109,
112, 105, 108, 101, 114, 32,
49, 48, 46, 49, 0, 171,
31, 0, 0, 2, 5, 0,
0, 128, 0, 0, 3, 144,
31, 0, 0, 2, 10, 0,
0, 128, 1, 0, 15, 144,
31, 0, 0, 2, 0, 0,
0, 144, 0, 8, 15, 160,
66, 0, 0, 3, 0, 0,
15, 128, 0, 0, 228, 144,
0, 8, 228, 160, 5, 0,
0, 3, 0, 8, 15, 128,
0, 0, 228, 128, 1, 0,
228, 144, 255, 255, 0, 0
0, 2, 255, 255, 254, 255,
31, 0, 67, 84, 65, 66,
28, 0, 0, 0, 79, 0,
0, 0, 0, 2, 255, 255,
1, 0, 0, 0, 28, 0,
0, 0, 0, 1, 0, 0,
72, 0, 0, 0, 48, 0,
0, 0, 3, 0, 0, 0,
1, 0, 2, 0, 56, 0,
0, 0, 0, 0, 0, 0,
116, 101, 120, 48, 0, 171,
171, 171, 4, 0, 12, 0,
1, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0,
112, 115, 95, 50, 95, 48,
0, 77, 105, 99, 114, 111,
115, 111, 102, 116, 32, 40,
82, 41, 32, 72, 76, 83,
76, 32, 83, 104, 97, 100,
101, 114, 32, 67, 111, 109,
112, 105, 108, 101, 114, 32,
49, 48, 46, 49, 0, 171,
31, 0, 0, 2, 0, 0,
0, 128, 0, 0, 3, 176,
31, 0, 0, 2, 0, 0,
0, 128, 0, 0, 15, 144,
31, 0, 0, 2, 0, 0,
0, 144, 0, 8, 15, 160,
66, 0, 0, 3, 0, 0,
15, 128, 0, 0, 228, 176,
0, 8, 228, 160, 5, 0,
0, 3, 0, 0, 15, 128,
0, 0, 228, 128, 0, 0,
228, 144, 1, 0, 0, 2,
0, 8, 15, 128, 0, 0,
228, 128, 255, 255, 0, 0
};
SafeRelease(g.d3d9PixelShader);
if (D3D_OK != g.d3d9Device->CreatePixelShader((DWORD*)pixel_shader_blob, &g.d3d9PixelShader))
Expand Down

0 comments on commit 7d600fd

Please sign in to comment.