Skip to content

Commit 22eb2e6

Browse files
committed
Added push constant compatibility tests
1 parent b3ca0ae commit 22eb2e6

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma wave shader_stage(compute)
2+
#include "common.hlsl"
3+
4+
[[vk::binding(0,1)]] RWByteAddressBuffer output;
5+
6+
struct SubsetPushConstants
7+
{
8+
uint32_t a[4];
9+
};
10+
11+
[[vk::push_constant]]
12+
SubsetPushConstants pc;
13+
14+
[numthreads(WorkgroupSize, 1, 1)]
15+
void main(uint32_t3 ID : SV_DispatchThreadID)
16+
{
17+
const uint32_t index = ID.x;
18+
const uint32_t byteOffset = sizeof(uint32_t)*index;
19+
20+
output.Store<uint32_t>(byteOffset, pc.a[index % 4]);
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma wave shader_stage(compute)
2+
#include "common.hlsl"
3+
4+
[[vk::binding(0,1)]] RWByteAddressBuffer output;
5+
6+
struct SubsetPushConstants
7+
{
8+
uint32_t a[50];
9+
};
10+
11+
[[vk::push_constant]]
12+
SubsetPushConstants pc;
13+
14+
[numthreads(WorkgroupSize, 1, 1)]
15+
void main(uint32_t3 ID : SV_DispatchThreadID)
16+
{
17+
const uint32_t index = ID.x;
18+
const uint32_t byteOffset = sizeof(uint32_t)*index;
19+
20+
output.Store<uint32_t>(byteOffset, pc.a[index % 50]);
21+
}

03_DeviceSelectionAndSharedSources/main.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
6767
};
6868

6969
// testing creation of compute pipeline layouts compatible for multiple shaders
70-
#if 0
70+
#if 1
7171
// TODO: if these are to stay, then i should avoid code multiplication
7272
{
7373
constexpr std::array mergeTestShadersPaths = {
@@ -120,7 +120,9 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
120120
"app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_0.comp.hlsl",
121121
"app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_1.comp.hlsl",
122122
"app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_2.comp.hlsl",
123-
"app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_3.comp.hlsl"
123+
"app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_3.comp.hlsl",
124+
"app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_4.comp.hlsl",
125+
"app_resources/pplnLayoutCreationWithPredefinedLayoutTest/shader_5.comp.hlsl"
124126
};
125127
constexpr uint32_t MERGE_TEST_SHADERS_CNT = mergeTestShadersPaths.size();
126128

@@ -173,7 +175,12 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
173175
if (!dsLayout0 || !dsLayout1)
174176
return logFail("Failed to create a Descriptor Layout!\n");
175177

176-
smart_refctd_ptr<ICPUPipelineLayout> predefinedPplnLayout = core::make_smart_refctd_ptr<ICPUPipelineLayout>(std::span<const asset::SPushConstantRange>(), std::move(dsLayout0), std::move(dsLayout1), nullptr, nullptr);
178+
SPushConstantRange pc;
179+
pc.offset = 0u;
180+
pc.size = 5 * sizeof(uint32_t);
181+
pc.stageFlags = IShader::E_SHADER_STAGE::ESS_COMPUTE;
182+
183+
smart_refctd_ptr<ICPUPipelineLayout> predefinedPplnLayout = core::make_smart_refctd_ptr<ICPUPipelineLayout>(std::span<const asset::SPushConstantRange>({ pc }), std::move(dsLayout0), std::move(dsLayout1), nullptr, nullptr);
177184
if (!predefinedPplnLayout)
178185
return logFail("Failed to create a Pipeline Layout!\n");
179186

@@ -195,11 +202,12 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
195202
confirmExpectedOutput(pplnCreationSuccess[2], false);
196203
// 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
197204
confirmExpectedOutput(pplnCreationSuccess[3], false);
205+
198206
// PUSH CONSTANTS VALIDATION TESTS
199207
// layout from introspection is a subset of pre-defined layout (Push constant size declared in shader are compatible), hence ppln creation should SUCCEED
200-
// TODO
208+
confirmExpectedOutput(pplnCreationSuccess[4], true);
201209
// 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-
// TODO
210+
confirmExpectedOutput(pplnCreationSuccess[5], false);
203211
}
204212

205213
m_logger->log("------- shader.comp.hlsl INTROSPECTION -------", ILogger::E_LOG_LEVEL::ELL_WARNING);

0 commit comments

Comments
 (0)