git.s-ol.nu ~forks/DiligentTools / 9f521ed
ImGui renderer: updated shaders for Vulkan and OpenGL assiduous 11 months ago
1 changed file(s) with 115 addition(s) and 82 deletion(s). Raw diff Collapse all Expand all
3333 namespace Diligent
3434 {
3535
36 static const char* VertexShaderSource = R"(
36 static const char* VertexShaderHLSL = R"(
3737 cbuffer Constants
3838 {
3939 float4x4 ProjectionMatrix;
6161 }
6262 )";
6363
64 static const char* PixelShaderSource = R"(
64 static const char* PixelShaderHLSL = R"(
6565 struct PSInput
6666 {
6767 float4 pos : SV_POSITION;
7878 }
7979 )";
8080
81
82
83 static const char* VertexShaderGLSL = R"(
84 layout(binding=0) uniform Constants
85 {
86 mat4 ProjectionMatrix;
87 };
88
89 layout(location = 0) in vec2 in_pos;
90 layout(location = 1) in vec2 in_uv;
91 layout(location = 2) in vec4 in_col;
92
93 layout(location = 0) out vec4 vsout_col;
94 layout(location = 1) out vec2 vsout_uv;
95
96 #ifndef GL_ES
97 out gl_PerVertex
98 {
99 vec4 gl_Position;
100 };
101 #endif
102
103 void main()
104 {
105 gl_Position = ProjectionMatrix * vec4(in_pos.xy, 0.0, 1.0);
106 vsout_col = in_col;
107 vsout_uv = in_uv;
108 }
109 )";
110
111 static const char* PixelShaderGLSL = R"(
112 layout(binding = 0) uniform sampler2D Texture;
113
114 layout(location = 0) in vec4 vsout_col;
115 layout(location = 1) in vec2 vsout_uv;
116
117 layout(location = 0) out vec4 psout_col;
118
119 void main()
120 {
121 psout_col = vsout_col * texture(Texture, vsout_uv);
122 }
123 )";
124
125
81126 // clang-format off
82127
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
128 // glslangValidator.exe -V -e main --vn VertexShader_SPIRV ImGUI.vert
129
130 static constexpr uint32_t VertexShader_SPIRV[] =
131 {
132 0x07230203,0x00010000,0x0008000a,0x00000028,0x00000000,0x00020011,0x00000001,0x0006000b,
133 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
134 0x000b000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000a,0x00000016,0x00000020,
135 0x00000022,0x00000025,0x00000026,0x00030003,0x00000002,0x000001a4,0x00040005,0x00000004,
136 0x6e69616d,0x00000000,0x00060005,0x00000008,0x505f6c67,0x65567265,0x78657472,0x00000000,
137 0x00060006,0x00000008,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000000a,
138 0x00000000,0x00050005,0x0000000e,0x736e6f43,0x746e6174,0x00000073,0x00080006,0x0000000e,
139 0x00000000,0x6a6f7250,0x69746365,0x614d6e6f,0x78697274,0x00000000,0x00030005,0x00000010,
140 0x00000000,0x00040005,0x00000016,0x705f6e69,0x0000736f,0x00050005,0x00000020,0x756f7376,
141 0x6f635f74,0x0000006c,0x00040005,0x00000022,0x635f6e69,0x00006c6f,0x00050005,0x00000025,
142 0x756f7376,0x76755f74,0x00000000,0x00040005,0x00000026,0x755f6e69,0x00000076,0x00050048,
143 0x00000008,0x00000000,0x0000000b,0x00000000,0x00030047,0x00000008,0x00000002,0x00040048,
144 0x0000000e,0x00000000,0x00000005,0x00050048,0x0000000e,0x00000000,0x00000023,0x00000000,
145 0x00050048,0x0000000e,0x00000000,0x00000007,0x00000010,0x00030047,0x0000000e,0x00000002,
146 0x00040047,0x00000010,0x00000022,0x00000000,0x00040047,0x00000010,0x00000021,0x00000000,
147 0x00040047,0x00000016,0x0000001e,0x00000000,0x00040047,0x00000020,0x0000001e,0x00000000,
148 0x00040047,0x00000022,0x0000001e,0x00000002,0x00040047,0x00000025,0x0000001e,0x00000001,
149 0x00040047,0x00000026,0x0000001e,0x00000001,0x00020013,0x00000002,0x00030021,0x00000003,
150 0x00000002,0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,
151 0x0003001e,0x00000008,0x00000007,0x00040020,0x00000009,0x00000003,0x00000008,0x0004003b,
152 0x00000009,0x0000000a,0x00000003,0x00040015,0x0000000b,0x00000020,0x00000001,0x0004002b,
153 0x0000000b,0x0000000c,0x00000000,0x00040018,0x0000000d,0x00000007,0x00000004,0x0003001e,
154 0x0000000e,0x0000000d,0x00040020,0x0000000f,0x00000002,0x0000000e,0x0004003b,0x0000000f,
155 0x00000010,0x00000002,0x00040020,0x00000011,0x00000002,0x0000000d,0x00040017,0x00000014,
156 0x00000006,0x00000002,0x00040020,0x00000015,0x00000001,0x00000014,0x0004003b,0x00000015,
157 0x00000016,0x00000001,0x0004002b,0x00000006,0x00000018,0x00000000,0x0004002b,0x00000006,
158 0x00000019,0x3f800000,0x00040020,0x0000001e,0x00000003,0x00000007,0x0004003b,0x0000001e,
159 0x00000020,0x00000003,0x00040020,0x00000021,0x00000001,0x00000007,0x0004003b,0x00000021,
160 0x00000022,0x00000001,0x00040020,0x00000024,0x00000003,0x00000014,0x0004003b,0x00000024,
161 0x00000025,0x00000003,0x0004003b,0x00000015,0x00000026,0x00000001,0x00050036,0x00000002,
162 0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000011,0x00000012,
163 0x00000010,0x0000000c,0x0004003d,0x0000000d,0x00000013,0x00000012,0x0004003d,0x00000014,
164 0x00000017,0x00000016,0x00050051,0x00000006,0x0000001a,0x00000017,0x00000000,0x00050051,
165 0x00000006,0x0000001b,0x00000017,0x00000001,0x00070050,0x00000007,0x0000001c,0x0000001a,
166 0x0000001b,0x00000018,0x00000019,0x00050091,0x00000007,0x0000001d,0x00000013,0x0000001c,
167 0x00050041,0x0000001e,0x0000001f,0x0000000a,0x0000000c,0x0003003e,0x0000001f,0x0000001d,
168 0x0004003d,0x00000007,0x00000023,0x00000022,0x0003003e,0x00000020,0x00000023,0x0004003d,
169 0x00000014,0x00000027,0x00000026,0x0003003e,0x00000025,0x00000027,0x000100fd,0x00010038
127170 };
128171
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
172 static constexpr uint32_t FragmentShader_SPIRV[] =
173 {
174 0x07230203,0x00010000,0x0008000a,0x00000018,0x00000000,0x00020011,0x00000001,0x0006000b,
175 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
176 0x0008000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000b,0x00000014,
177 0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001a4,0x00040005,0x00000004,
178 0x6e69616d,0x00000000,0x00050005,0x00000009,0x756f7370,0x6f635f74,0x0000006c,0x00050005,
179 0x0000000b,0x756f7376,0x6f635f74,0x0000006c,0x00040005,0x00000010,0x74786554,0x00657275,
180 0x00050005,0x00000014,0x756f7376,0x76755f74,0x00000000,0x00040047,0x00000009,0x0000001e,
181 0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000000,0x00040047,0x00000010,0x00000022,
182 0x00000000,0x00040047,0x00000010,0x00000021,0x00000000,0x00040047,0x00000014,0x0000001e,
183 0x00000001,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
184 0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,
185 0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040020,0x0000000a,0x00000001,
186 0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,0x00090019,0x0000000d,0x00000006,
187 0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000000e,
188 0x0000000d,0x00040020,0x0000000f,0x00000000,0x0000000e,0x0004003b,0x0000000f,0x00000010,
189 0x00000000,0x00040017,0x00000012,0x00000006,0x00000002,0x00040020,0x00000013,0x00000001,
190 0x00000012,0x0004003b,0x00000013,0x00000014,0x00000001,0x00050036,0x00000002,0x00000004,
191 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d,0x00000007,0x0000000c,0x0000000b,
192 0x0004003d,0x0000000e,0x00000011,0x00000010,0x0004003d,0x00000012,0x00000015,0x00000014,
193 0x00050057,0x00000007,0x00000016,0x00000011,0x00000015,0x00050085,0x00000007,0x00000017,
194 0x0000000c,0x00000016,0x0003003e,0x00000009,0x00000017,0x000100fd,0x00010038
162195 };
163196 // clang-format on
164197
219252
220253 ShaderCreateInfo ShaderCI;
221254 ShaderCI.UseCombinedTextureSamplers = true;
222 ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL;
255 ShaderCI.SourceLanguage = SHADER_SOURCE_LANGUAGE_DEFAULT;
223256
224257 RefCntAutoPtr<IShader> pVS;
225258 {
232265 }
233266 else
234267 {
235 ShaderCI.Source = VertexShaderSource;
268 ShaderCI.Source = m_pDevice->GetDeviceCaps().IsD3DDevice() ? VertexShaderHLSL : VertexShaderGLSL;
236269 }
237270 m_pDevice->CreateShader(ShaderCI, &pVS);
238271 }
248281 }
249282 else
250283 {
251 ShaderCI.Source = PixelShaderSource;
284 ShaderCI.Source = m_pDevice->GetDeviceCaps().IsD3DDevice() ? PixelShaderHLSL : PixelShaderGLSL;
252285 }
253286 m_pDevice->CreateShader(ShaderCI, &pPS);
254287 }