@@ -42,8 +42,8 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
42
42
// if (!introspection->canSpecializationlesslyCreateDescSetFrom())
43
43
// return logFail("Someone changed the shader and some descriptor binding depends on a specialization constant!");
44
44
45
- #if 0
46
45
// flexible test
46
+ #if 0
47
47
{
48
48
m_logger->log("------- test.hlsl INTROSPECTION -------", ILogger::E_LOG_LEVEL::ELL_WARNING);
49
49
CSPIRVIntrospector introspector;
@@ -66,8 +66,9 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
66
66
}
67
67
};
68
68
69
- // TODO: if these are to stay, then i should avoid code multiplication
70
69
// testing creation of compute pipeline layouts compatible for multiple shaders
70
+ #if 0
71
+ // TODO: if these are to stay, then i should avoid code multiplication
71
72
{
72
73
constexpr std::array mergeTestShadersPaths = {
73
74
"app_resources/pplnLayoutMergeTest/shader_0.comp.hlsl",
@@ -112,14 +113,14 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
112
113
// TODO: idk what should happen when last binding in introspection is fixed-length sized array and last binding in introspection to merge is run-time sized array
113
114
confirmExpectedOutput(pplnIntroData->merge(introspections[5].get()), false);
114
115
}
115
-
116
+ # endif
116
117
// testing pre-defined layout compatibility
117
118
{
118
119
constexpr std::array mergeTestShadersPaths = {
119
- " app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_0.comp.hlsl" ,
120
- " app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_1.comp.hlsl" ,
121
- " app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_2.comp.hlsl" ,
122
- " app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_3.comp.hlsl"
120
+ " app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_0.comp.hlsl"
121
+ // "app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_1.comp.hlsl",
122
+ // "app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_2.comp.hlsl",
123
+ // "app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_3.comp.hlsl"
123
124
};
124
125
constexpr uint32_t MERGE_TEST_SHADERS_CNT = mergeTestShadersPaths.size ();
125
126
@@ -139,31 +140,39 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
139
140
{
140
141
.binding = 0 ,
141
142
.type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
142
- .createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE, // not is not the time for descriptor indexing
143
+ .createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
143
144
.stageFlags = ICPUShader::ESS_COMPUTE,
144
145
.count = 1 ,
145
- .samplers = nullptr // irrelevant for a buffer
146
+ .samplers = nullptr
146
147
},
147
148
{
148
149
.binding = 1 ,
149
150
.type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
150
- .createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE, // not is not the time for descriptor indexing
151
+ .createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
151
152
.stageFlags = IGPUShader::ESS_COMPUTE,
152
- .count = 2 ,
153
- .samplers = nullptr // irrelevant for a buffer
153
+ .count = 3 ,
154
+ .samplers = nullptr
154
155
}
155
156
};
156
157
157
- constexpr uint32_t BINDINGS_DS_1_CNT = 1u ;
158
+ constexpr uint32_t BINDINGS_DS_1_CNT = 2u ;
158
159
const ICPUDescriptorSetLayout::SBinding bindingsDS1[BINDINGS_DS_1_CNT] = {
159
160
{
160
- .binding = 6 ,
161
+ .binding = 0 ,
161
162
.type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
162
163
.createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
163
164
.stageFlags = ICPUShader::ESS_COMPUTE,
164
165
.count = 1 ,
165
- .samplers = nullptr // irrelevant for a buffer
166
+ .samplers = nullptr
166
167
},
168
+ {
169
+ .binding = 1 ,
170
+ .type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
171
+ .createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
172
+ .stageFlags = ICPUShader::ESS_COMPUTE,
173
+ .count = 5 ,
174
+ .samplers = nullptr
175
+ }
167
176
};
168
177
169
178
core::smart_refctd_ptr<ICPUDescriptorSetLayout> dsLayout0 = core::make_smart_refctd_ptr<ICPUDescriptorSetLayout>(bindingsDS0, bindingsDS0 + BINDINGS_DS_0_CNT);
@@ -185,76 +194,32 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
185
194
pplnCreationSuccess[i] = static_cast <bool >(introspector[i].createApproximateComputePipelineFromIntrospection (specInfo, core::smart_refctd_ptr<ICPUPipelineLayout>(predefinedPplnLayout)));
186
195
}
187
196
188
- assert (MERGE_TEST_SHADERS_CNT <= 4u );
197
+ // assert(MERGE_TEST_SHADERS_CNT <= 4u);
189
198
// DESCRIPTOR VALIDATION TESTS
190
199
// layout from introspection is a subset of pre-defined layout, hence ppln creation should SUCCEED
191
200
confirmExpectedOutput (pplnCreationSuccess[0 ], true );
192
201
// layout from introspection is NOT a subset (too many bindings in descriptor set 0) of pre-defined layout, hence ppln creation should FAIL
193
- confirmExpectedOutput (pplnCreationSuccess[1 ], false );
202
+ // confirmExpectedOutput(pplnCreationSuccess[1], false);
194
203
// layout from introspection is NOT a subset (pre-defined layout doesn't have descriptor set 2) of pre-defined layout, hence ppln creation should FAIL
195
- confirmExpectedOutput (pplnCreationSuccess[2 ], false );
204
+ // confirmExpectedOutput(pplnCreationSuccess[2], false);
196
205
// layout from introspection is NOT a subset (same bindings, different type of one of the bindings) of pre-defined layout, hence ppln creation should FAIL
197
- confirmExpectedOutput (pplnCreationSuccess[3 ], false );
206
+ // confirmExpectedOutput(pplnCreationSuccess[3], false);
198
207
// PUSH CONSTANTS VALIDATION TESTS
199
208
// layout from introspection is a subset of pre-defined layout (Push constant size declared in shader are compatible), hence ppln creation should SUCCEED
200
209
// TODO
201
210
// layout from introspection is NOT a subset of pre-defined layout (Push constant size declared in shader are NOT compatible), hence ppln creation should FAIL
202
211
// TODO
203
212
}
204
213
205
- // testing what will happen when last binding in introspection is fixed-length sized array and last binding in introspection to merge is run-time sized array
206
- {
207
- CSPIRVIntrospector introspector;
208
- auto source = this ->compileShaderAndTestIntrospection (" app_resources/lastBindingCompatibilityTest.comp.hlsl" , introspector).first ;
209
-
210
- ICPUShader::SSpecInfo specInfo;
211
- specInfo.entryPoint = " main" ;
212
- specInfo.shader = source.get ();
213
-
214
- m_logger->log (" ------- shader.comp.hlsl PIPELINE CREATION -------" , ILogger::E_LOG_LEVEL::ELL_WARNING);
215
- smart_refctd_ptr<nbl::asset::ICPUComputePipeline> cpuPipeline = introspector.createApproximateComputePipelineFromIntrospection (specInfo);
216
-
217
- smart_refctd_ptr<IGPUShader> shader = m_device->createShader (source.get ());
218
-
219
- nbl::video::IGPUDescriptorSetLayout::SBinding bindingsDS0[1 ] = {
220
- {
221
- .binding = 0 ,
222
- .type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
223
- .createFlags = IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_UPDATE_AFTER_BIND_BIT,
224
- .stageFlags = IGPUShader::ESS_COMPUTE,
225
- .count = 0 ,
226
- .samplers = nullptr
227
- },
228
- };
229
-
230
- smart_refctd_ptr<IGPUDescriptorSetLayout> dsLayout0 = m_device->createDescriptorSetLayout (bindingsDS0);
231
- if (!dsLayout0)
232
- return logFail (" Failed to create a Descriptor Layout!\n " );
233
-
234
- // Nabla actually has facilities for SPIR-V Reflection and "guessing" pipeline layouts for a given SPIR-V which we'll cover in a different example
235
- smart_refctd_ptr<nbl::video::IGPUPipelineLayout> pplnLayout = m_device->createPipelineLayout ({}, smart_refctd_ptr (dsLayout0), nullptr , nullptr , nullptr );
236
- if (!pplnLayout)
237
- return logFail (" Failed to create a Pipeline Layout!\n " );
238
-
239
- // We use strong typing on the pipelines (Compute, Graphics, Mesh, RT), since there's no reason to polymorphically switch between different pipelines
240
- smart_refctd_ptr<nbl::video::IGPUComputePipeline> pipeline;
241
- {
242
- IGPUComputePipeline::SCreationParams params = {};
243
- params.layout = pplnLayout.get ();
244
- // Theoretically a blob of SPIR-V can contain multiple named entry points and one has to be chosen, in practice most compilers only support outputting one (and glslang used to require it be called "main")
245
- params.shader .entryPoint = " main" ;
246
- params.shader .shader = shader.get ();
247
- // we'll cover the specialization constant API in another example
248
- if (!m_device->createComputePipelines (nullptr , { ¶ms,1 }, &pipeline))
249
- return logFail (" Failed to create pipelines (compile & link shaders)!\n " );
250
- }
251
- }
252
-
253
214
m_logger->log (" ------- shader.comp.hlsl INTROSPECTION -------" , ILogger::E_LOG_LEVEL::ELL_WARNING);
254
215
CSPIRVIntrospector introspector;
255
- auto source = this ->compileShaderAndTestIntrospection (" app_resources/shader.comp.hlsl" , introspector).first ;
216
+ auto mainShader = this ->compileShaderAndTestIntrospection (" app_resources/shader.comp.hlsl" , introspector);
217
+ auto source = mainShader.first ;
218
+ auto mainShaderIntrospection = mainShader.second ;
219
+ mainShaderIntrospection->debugPrint (m_logger.get ());
256
220
// auto source2 = this->compileShaderAndTestIntrospection("app_resources/shader.comp.hlsl", introspector); // to make sure caching works
257
221
222
+
258
223
m_logger->log (" ------- vtx_test1.hlsl INTROSPECTION -------" , ILogger::E_LOG_LEVEL::ELL_WARNING);
259
224
CSPIRVIntrospector introspector_test1;
260
225
auto vtx_test1 = this ->compileShaderAndTestIntrospection (" app_resources/vtx_test1.hlsl" , introspector_test1);
0 commit comments