Skip to content

Commit b3ca0ae

Browse files
committed
Added tests for predefined layout
1 parent 310be40 commit b3ca0ae

File tree

3 files changed

+16
-27
lines changed

3 files changed

+16
-27
lines changed

03_DeviceSelectionAndSharedSources/app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_1.comp.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[[vk::binding(0,0)]] RWStructuredBuffer<SomeType> asdf;
55
[[vk::binding(0,1)]] RWByteAddressBuffer output;
66
[[vk::binding(0,2)]] RWByteAddressBuffer output2[2];
7-
[[vk::binding(1,2)]] RWByteAddressBuffer output3[];
7+
[[vk::binding(1,0)]] RWByteAddressBuffer output3[];
88

99
[numthreads(WorkgroupSize, 1, 1)]
1010
void main(uint32_t3 ID : SV_DispatchThreadID)

03_DeviceSelectionAndSharedSources/app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_2.comp.hlsl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22
#include "common.hlsl"
33

44
[[vk::binding(0,0)]] RWStructuredBuffer<SomeType> asdf;
5-
[[vk::binding(0,1)]] RWByteAddressBuffer output;
6-
[[vk::binding(1,1)]] RWByteAddressBuffer output2[2];
7-
[[vk::binding(0,2)]] RWByteAddressBuffer output3;
5+
[[vk::binding(1,1)]] RWByteAddressBuffer output[2];
6+
[[vk::binding(0,2)]] RWByteAddressBuffer output2;
87

98
[numthreads(WorkgroupSize, 1, 1)]
109
void main(uint32_t3 ID : SV_DispatchThreadID)
1110
{
1211
const uint32_t index = ID.x;
1312
const uint32_t byteOffset = sizeof(uint32_t)*index;
1413

15-
output.Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] + asdf[index].c[3]);
16-
output2[1].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
17-
output3.Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
14+
output[1].Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
15+
output2.Store<uint32_t>(byteOffset, asdf[index].a + asdf[index].b[2] - asdf[index].c[3]);
1816
}

03_DeviceSelectionAndSharedSources/main.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
117117
// testing pre-defined layout compatibility
118118
{
119119
constexpr std::array mergeTestShadersPaths = {
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"
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"
124124
};
125125
constexpr uint32_t MERGE_TEST_SHADERS_CNT = mergeTestShadersPaths.size();
126126

@@ -129,13 +129,13 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
129129

130130
for (uint32_t i = 0u; i < MERGE_TEST_SHADERS_CNT; ++i)
131131
{
132-
m_logger->log("------- %s INTROSPECTION -------", ILogger::E_LOG_LEVEL::ELL_WARNING, mergeTestShadersPaths[i]);
132+
m_logger->log("------- LOADING %s -------", ILogger::E_LOG_LEVEL::ELL_WARNING, mergeTestShadersPaths[i]);
133133
auto sourceIntrospectionPair = this->compileShaderAndTestIntrospection(mergeTestShadersPaths[i], introspector[i]);
134134
// TODO: disctinct functions for shader compilation and introspection
135135
sources[i] = sourceIntrospectionPair.first;
136136
}
137137

138-
constexpr uint32_t BINDINGS_DS_0_CNT = 2u;
138+
constexpr uint32_t BINDINGS_DS_0_CNT = 1u;
139139
const ICPUDescriptorSetLayout::SBinding bindingsDS0[BINDINGS_DS_0_CNT] = {
140140
{
141141
.binding = 0,
@@ -144,14 +144,6 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
144144
.stageFlags = ICPUShader::ESS_COMPUTE,
145145
.count = 1,
146146
.samplers = nullptr
147-
},
148-
{
149-
.binding = 1,
150-
.type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
151-
.createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
152-
.stageFlags = IGPUShader::ESS_COMPUTE,
153-
.count = 3,
154-
.samplers = nullptr
155147
}
156148
};
157149

@@ -170,7 +162,7 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
170162
.type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
171163
.createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
172164
.stageFlags = ICPUShader::ESS_COMPUTE,
173-
.count = 5,
165+
.count = 2,
174166
.samplers = nullptr
175167
}
176168
};
@@ -194,16 +186,15 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
194186
pplnCreationSuccess[i] = static_cast<bool>(introspector[i].createApproximateComputePipelineFromIntrospection(specInfo, core::smart_refctd_ptr<ICPUPipelineLayout>(predefinedPplnLayout)));
195187
}
196188

197-
//assert(MERGE_TEST_SHADERS_CNT <= 4u);
198189
// DESCRIPTOR VALIDATION TESTS
199190
// layout from introspection is a subset of pre-defined layout, hence ppln creation should SUCCEED
200191
confirmExpectedOutput(pplnCreationSuccess[0], true);
201192
// layout from introspection is NOT a subset (too many bindings in descriptor set 0) of pre-defined layout, hence ppln creation should FAIL
202-
//confirmExpectedOutput(pplnCreationSuccess[1], false);
193+
confirmExpectedOutput(pplnCreationSuccess[1], false);
203194
// 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
204-
//confirmExpectedOutput(pplnCreationSuccess[2], false);
195+
confirmExpectedOutput(pplnCreationSuccess[2], false);
205196
// 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
206-
//confirmExpectedOutput(pplnCreationSuccess[3], false);
197+
confirmExpectedOutput(pplnCreationSuccess[3], false);
207198
// PUSH CONSTANTS VALIDATION TESTS
208199
// layout from introspection is a subset of pre-defined layout (Push constant size declared in shader are compatible), hence ppln creation should SUCCEED
209200
// TODO
@@ -216,7 +207,7 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
216207
auto mainShader = this->compileShaderAndTestIntrospection("app_resources/shader.comp.hlsl", introspector);
217208
auto source = mainShader.first;
218209
auto mainShaderIntrospection = mainShader.second;
219-
mainShaderIntrospection->debugPrint(m_logger.get());
210+
//mainShaderIntrospection->debugPrint(m_logger.get());
220211
// auto source2 = this->compileShaderAndTestIntrospection("app_resources/shader.comp.hlsl", introspector); // to make sure caching works
221212

222213

0 commit comments

Comments
 (0)