git.s-ol.nu ~forks/DiligentTools / a246e44
Imgui renderer: using pre-compiled SPIRV shaders in Vulkan mode assiduous 11 months ago
1 changed file(s) with 102 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
7878 }
7979 )";
8080
81 // clang-format off
82
83 // glslangValidator.exe -fhlsl_functionality1 -V -e main --vn VertexShader_SPIRV ImGUI.vert.hlsl
84
85 static const uint32_t VertexShader_SPIRV[] =
86 {
87 0x07230203,0x00010000,0x0008000a,0x00000054,0x00000000,0x00020011,0x00000001,0x0009000a,
88 0x5f565053,0x474f4f47,0x685f454c,0x5f6c736c,0x636e7566,0x6e6f6974,0x74696c61,0x00003179,
89 0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,
90 0x00000001,0x000b000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x00000030,0x00000033,
91 0x00000037,0x00000041,0x00000044,0x00000048,0x00030003,0x00000005,0x000001f4,0x00040005,
92 0x00000004,0x6e69616d,0x00000000,0x00050005,0x0000001d,0x736e6f43,0x746e6174,0x00000073,
93 0x00080006,0x0000001d,0x00000000,0x6a6f7250,0x69746365,0x614d6e6f,0x78697274,0x00000000,
94 0x00030005,0x0000001f,0x00000000,0x00050005,0x00000030,0x6e495356,0x736f702e,0x00000000,
95 0x00040005,0x00000033,0x6e495356,0x0076752e,0x00050005,0x00000037,0x6e495356,0x6c6f632e,
96 0x00000000,0x00050005,0x00000041,0x6e495350,0x736f702e,0x00000000,0x00050005,0x00000044,
97 0x6e495350,0x6c6f632e,0x00000000,0x00040005,0x00000048,0x6e495350,0x0076752e,0x00040048,
98 0x0000001d,0x00000000,0x00000004,0x00050048,0x0000001d,0x00000000,0x00000023,0x00000000,
99 0x00050048,0x0000001d,0x00000000,0x00000007,0x00000010,0x00030047,0x0000001d,0x00000002,
100 0x00040047,0x0000001f,0x00000022,0x00000000,0x00040047,0x0000001f,0x00000021,0x00000000,
101 0x00040047,0x00000030,0x0000001e,0x00000000,0x00051600,0x00000030,0x00001603,0x52545441,
102 0x00304249,0x00040047,0x00000033,0x0000001e,0x00000001,0x00051600,0x00000033,0x00001603,
103 0x52545441,0x00314249,0x00040047,0x00000037,0x0000001e,0x00000002,0x00051600,0x00000037,
104 0x00001603,0x52545441,0x00324249,0x00040047,0x00000041,0x0000000b,0x00000000,0x00061600,
105 0x00000041,0x00001603,0x505f5653,0x5449534f,0x004e4f49,0x00040047,0x00000044,0x0000001e,
106 0x00000000,0x00051600,0x00000044,0x00001603,0x4f4c4f43,0x00000052,0x00040047,0x00000048,
107 0x0000001e,0x00000001,0x00061600,0x00000048,0x00001603,0x43584554,0x44524f4f,0x00000000,
108 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,
109 0x00040017,0x00000007,0x00000006,0x00000002,0x00040017,0x00000008,0x00000006,0x00000004,
110 0x00040015,0x00000012,0x00000020,0x00000001,0x0004002b,0x00000012,0x00000013,0x00000000,
111 0x0004002b,0x00000006,0x00000017,0x00000000,0x0004002b,0x00000006,0x00000018,0x3f800000,
112 0x00040018,0x0000001c,0x00000008,0x00000004,0x0003001e,0x0000001d,0x0000001c,0x00040020,
113 0x0000001e,0x00000002,0x0000001d,0x0004003b,0x0000001e,0x0000001f,0x00000002,0x00040020,
114 0x00000020,0x00000002,0x0000001c,0x00040020,0x0000002f,0x00000001,0x00000007,0x0004003b,
115 0x0000002f,0x00000030,0x00000001,0x0004003b,0x0000002f,0x00000033,0x00000001,0x00040020,
116 0x00000036,0x00000001,0x00000008,0x0004003b,0x00000036,0x00000037,0x00000001,0x00040020,
117 0x00000040,0x00000003,0x00000008,0x0004003b,0x00000040,0x00000041,0x00000003,0x0004003b,
118 0x00000040,0x00000044,0x00000003,0x00040020,0x00000047,0x00000003,0x00000007,0x0004003b,
119 0x00000047,0x00000048,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,
120 0x000200f8,0x00000005,0x0004003d,0x00000007,0x00000031,0x00000030,0x0004003d,0x00000007,
121 0x00000034,0x00000033,0x0004003d,0x00000008,0x00000038,0x00000037,0x00050051,0x00000006,
122 0x0000004e,0x00000031,0x00000000,0x00050051,0x00000006,0x0000004f,0x00000031,0x00000001,
123 0x00070050,0x00000008,0x00000050,0x0000004e,0x0000004f,0x00000017,0x00000018,0x00050041,
124 0x00000020,0x00000051,0x0000001f,0x00000013,0x0004003d,0x0000001c,0x00000052,0x00000051,
125 0x00050090,0x00000008,0x00000053,0x00000050,0x00000052,0x0003003e,0x00000041,0x00000053,
126 0x0003003e,0x00000044,0x00000038,0x0003003e,0x00000048,0x00000034,0x000100fd,0x00010038
127 };
128
129 static const uint32_t FragmentShader_SPIRV[] =
130 {
131 0x07230203, 0x00010000, 0x0008000a, 0x00000043, 0x00000000, 0x00020011, 0x00000001, 0x0009000a,
132 0x5f565053, 0x474f4f47, 0x685f454c, 0x5f6c736c, 0x636e7566, 0x6e6f6974, 0x74696c61, 0x00003179,
133 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000,
134 0x00000001, 0x0009000f, 0x00000004, 0x00000004, 0x6e69616d, 0x00000000, 0x00000029, 0x0000002c,
135 0x00000030, 0x00000034, 0x00030010, 0x00000004, 0x00000007, 0x00030003, 0x00000005, 0x000001f4,
136 0x00040005, 0x00000004, 0x6e69616d, 0x00000000, 0x00040005, 0x00000016, 0x74786554, 0x00657275,
137 0x00060005, 0x0000001a, 0x74786554, 0x5f657275, 0x706d6173, 0x0072656c, 0x00050005, 0x00000029,
138 0x6e495350, 0x736f702e, 0x00000000, 0x00050005, 0x0000002c, 0x6e495350, 0x6c6f632e, 0x00000000,
139 0x00040005, 0x00000030, 0x6e495350, 0x0076752e, 0x00070005, 0x00000034, 0x746e6540, 0x6f507972,
140 0x4f746e69, 0x75707475, 0x00000074, 0x00040047, 0x00000016, 0x00000022, 0x00000000, 0x00040047,
141 0x00000016, 0x00000021, 0x00000000, 0x00040047, 0x0000001a, 0x00000022, 0x00000000, 0x00040047,
142 0x0000001a, 0x00000021, 0x00000000, 0x00040047, 0x00000029, 0x0000000b, 0x0000000f, 0x00061600,
143 0x00000029, 0x00001603, 0x505f5653, 0x5449534f, 0x004e4f49, 0x00040047, 0x0000002c, 0x0000001e,
144 0x00000000, 0x00051600, 0x0000002c, 0x00001603, 0x4f4c4f43, 0x00000052, 0x00040047, 0x00000030,
145 0x0000001e, 0x00000001, 0x00061600, 0x00000030, 0x00001603, 0x43584554, 0x44524f4f, 0x00000000,
146 0x00040047, 0x00000034, 0x0000001e, 0x00000000, 0x00061600, 0x00000034, 0x00001603, 0x545f5653,
147 0x45475241, 0x00000054, 0x00020013, 0x00000002, 0x00030021, 0x00000003, 0x00000002, 0x00030016,
148 0x00000006, 0x00000020, 0x00040017, 0x00000007, 0x00000006, 0x00000004, 0x00040017, 0x00000008,
149 0x00000006, 0x00000002, 0x00090019, 0x00000014, 0x00000006, 0x00000001, 0x00000000, 0x00000000,
150 0x00000000, 0x00000001, 0x00000000, 0x00040020, 0x00000015, 0x00000000, 0x00000014, 0x0004003b,
151 0x00000015, 0x00000016, 0x00000000, 0x0002001a, 0x00000018, 0x00040020, 0x00000019, 0x00000000,
152 0x00000018, 0x0004003b, 0x00000019, 0x0000001a, 0x00000000, 0x0003001b, 0x0000001c, 0x00000014,
153 0x00040020, 0x00000028, 0x00000001, 0x00000007, 0x0004003b, 0x00000028, 0x00000029, 0x00000001,
154 0x0004003b, 0x00000028, 0x0000002c, 0x00000001, 0x00040020, 0x0000002f, 0x00000001, 0x00000008,
155 0x0004003b, 0x0000002f, 0x00000030, 0x00000001, 0x00040020, 0x00000033, 0x00000003, 0x00000007,
156 0x0004003b, 0x00000033, 0x00000034, 0x00000003, 0x00050036, 0x00000002, 0x00000004, 0x00000000,
157 0x00000003, 0x000200f8, 0x00000005, 0x0004003d, 0x00000007, 0x0000002d, 0x0000002c, 0x0004003d,
158 0x00000008, 0x00000031, 0x00000030, 0x0004003d, 0x00000014, 0x0000003c, 0x00000016, 0x0004003d,
159 0x00000018, 0x0000003d, 0x0000001a, 0x00050056, 0x0000001c, 0x0000003e, 0x0000003c, 0x0000003d,
160 0x00050057, 0x00000007, 0x00000041, 0x0000003e, 0x00000031, 0x00050085, 0x00000007, 0x00000042,
161 0x0000002d, 0x00000041, 0x0003003e, 0x00000034, 0x00000042, 0x000100fd, 0x00010038
162 };
163 // clang-format on
164
81165 ImGuiDiligentRenderer::ImGuiDiligentRenderer(IRenderDevice* pDevice,
82166 TEXTURE_FORMAT BackBufferFmt,
83167 TEXTURE_FORMAT DepthBufferFmt,
141225 {
142226 ShaderCI.Desc.ShaderType = SHADER_TYPE_VERTEX;
143227 ShaderCI.Desc.Name = "Imgui VS";
144 ShaderCI.Source = VertexShaderSource;
228 if (m_pDevice->GetDeviceCaps().IsVulkanDevice())
229 {
230 ShaderCI.ByteCode = VertexShader_SPIRV;
231 ShaderCI.ByteCodeSize = sizeof(VertexShader_SPIRV);
232 }
233 else
234 {
235 ShaderCI.Source = VertexShaderSource;
236 }
145237 m_pDevice->CreateShader(ShaderCI, &pVS);
146238 }
147239
149241 {
150242 ShaderCI.Desc.ShaderType = SHADER_TYPE_PIXEL;
151243 ShaderCI.Desc.Name = "Imgui PS";
152 ShaderCI.Source = PixelShaderSource;
244 if (m_pDevice->GetDeviceCaps().IsVulkanDevice())
245 {
246 ShaderCI.ByteCode = FragmentShader_SPIRV;
247 ShaderCI.ByteCodeSize = sizeof(FragmentShader_SPIRV);
248 }
249 else
250 {
251 ShaderCI.Source = PixelShaderSource;
252 }
153253 m_pDevice->CreateShader(ShaderCI, &pPS);
154254 }
155255