mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Add specialization constants to tests to ensure they are preserved
* These canary values must be propagated correctly to derived pipelines (made with patched shaders etc) or else the shaders disable themselves/misbehave, which invalidates the test. That way if the test passes we know the specialization constants were properly propagated.
This commit is contained in:
@@ -107,8 +107,12 @@ layout(binding = 0, std430) buffer outbuftype {
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
layout(constant_id = 1) const int spec_canary = 0;
|
||||
|
||||
void main()
|
||||
{
|
||||
if(spec_canary != 1337) return;
|
||||
|
||||
outbuf[push.bufidx].outrefs[0].binding = 0;
|
||||
outbuf[push.bufidx].outrefs[0].idx = push.idx1;
|
||||
outbuf[push.bufidx].outrefs[1].binding = 2;
|
||||
@@ -189,8 +193,12 @@ void add_parameterless()
|
||||
Color += 0.1f * texture(tex1[)EOSHADER" STRINGIZE(INDEX3) R"EOSHADER(], vertIn.uv.xy);
|
||||
}
|
||||
|
||||
layout(constant_id = 2) const int spec_canary = 0;
|
||||
|
||||
void main()
|
||||
{
|
||||
if(spec_canary != 1338) { Color = vec4(1.0, 0.0, 0.0, 1.0); return; }
|
||||
|
||||
if(vertIn.uv.y < 0.2f)
|
||||
{
|
||||
// nonuniform dynamic index
|
||||
@@ -334,10 +342,27 @@ void main()
|
||||
CompileShaderModule(common + pixel, ShaderLang::glsl, ShaderStage::frag, "main"),
|
||||
};
|
||||
|
||||
VkPipelineShaderStageCreateInfo compshad =
|
||||
CompileShaderModule(comp, ShaderLang::glsl, ShaderStage::comp, "main");
|
||||
|
||||
VkSpecializationMapEntry specmap[2] = {
|
||||
{1, 0 * sizeof(uint32_t), sizeof(uint32_t)}, {2, 1 * sizeof(uint32_t), sizeof(uint32_t)},
|
||||
};
|
||||
|
||||
uint32_t specvals[2] = {1337, 1338};
|
||||
|
||||
VkSpecializationInfo spec = {};
|
||||
spec.mapEntryCount = ARRAY_COUNT(specmap);
|
||||
spec.pMapEntries = specmap;
|
||||
spec.dataSize = sizeof(specvals);
|
||||
spec.pData = specvals;
|
||||
|
||||
pipeCreateInfo.stages[1].pSpecializationInfo = &spec;
|
||||
compshad.pSpecializationInfo = &spec;
|
||||
|
||||
VkPipeline pipe = createGraphicsPipeline(pipeCreateInfo);
|
||||
|
||||
VkPipeline comppipe = createComputePipeline(vkh::ComputePipelineCreateInfo(
|
||||
layout, CompileShaderModule(comp, ShaderLang::glsl, ShaderStage::comp, "main")));
|
||||
VkPipeline comppipe = createComputePipeline(vkh::ComputePipelineCreateInfo(layout, compshad));
|
||||
|
||||
float left = float(NONUNIFORMIDX - 1.0f);
|
||||
float middle = float(NONUNIFORMIDX);
|
||||
|
||||
@@ -43,8 +43,21 @@ layout(push_constant, std140) uniform pushbuf
|
||||
layout(location = 0) out vec2 vertOutCol2;
|
||||
layout(location = 1) out vec4 vertOutcol;
|
||||
|
||||
layout(constant_id = 1) const int spec_canary = 0;
|
||||
|
||||
void main()
|
||||
{
|
||||
if(spec_canary != 1337)
|
||||
{
|
||||
gl_Position = vec4(-1, -1, -1, 1);
|
||||
vertOutcol = vec4(0, 0, 0, 0);
|
||||
vertOutCol2 = vec2(0, 0);
|
||||
#if defined(USE_POINTS)
|
||||
gl_PointSize = 0.0f;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
vec4 pos = vec4(Position.xy * scale.xy + offset.xy, Position.z, 1.0f);
|
||||
vertOutcol = Color;
|
||||
|
||||
@@ -179,10 +192,25 @@ void main()
|
||||
pipeCreateInfo.depthStencilState.stencilTestEnable = VK_FALSE;
|
||||
pipeCreateInfo.depthStencilState.back = pipeCreateInfo.depthStencilState.front;
|
||||
|
||||
VkSpecializationMapEntry specmap[1] = {
|
||||
{1, 0 * sizeof(uint32_t), sizeof(uint32_t)},
|
||||
};
|
||||
|
||||
uint32_t specvals[1] = {1337};
|
||||
|
||||
VkSpecializationInfo spec = {};
|
||||
spec.mapEntryCount = ARRAY_COUNT(specmap);
|
||||
spec.pMapEntries = specmap;
|
||||
spec.dataSize = sizeof(specvals);
|
||||
spec.pData = specvals;
|
||||
|
||||
pipeCreateInfo.stages[0].pSpecializationInfo = &spec;
|
||||
|
||||
VkPipeline pipe = createGraphicsPipeline(pipeCreateInfo);
|
||||
|
||||
pipeCreateInfo.stages[0] = CompileShaderModule(vertex, ShaderLang::glsl, ShaderStage::vert,
|
||||
"main", {std::make_pair("USE_POINTS", "1")}),
|
||||
pipeCreateInfo.stages[0].pSpecializationInfo = &spec;
|
||||
pipeCreateInfo.inputAssemblyState.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
|
||||
|
||||
VkPipeline pointspipe = createGraphicsPipeline(pipeCreateInfo);
|
||||
|
||||
@@ -50,8 +50,18 @@ layout(location = 2) in vec2 UV;
|
||||
|
||||
layout(location = 0) out v2f vertOut;
|
||||
|
||||
layout(constant_id = 1) const int spec_canary = 0;
|
||||
|
||||
void main()
|
||||
{
|
||||
if(spec_canary != 1337)
|
||||
{
|
||||
gl_Position = vertOut.pos = vec4(-1, -1, -1, 1);
|
||||
vertOut.col = vec4(0, 0, 0, 0);
|
||||
vertOut.uv = vec4(0, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
vertOut.pos = vec4(Position.xyz, 1);
|
||||
gl_Position = vertOut.pos;
|
||||
vertOut.col = Color;
|
||||
@@ -66,8 +76,12 @@ layout(location = 0) in v2f vertIn;
|
||||
|
||||
layout(location = 0, index = 0) out vec4 Color;
|
||||
|
||||
layout(constant_id = 2) const int spec_canary = 0;
|
||||
|
||||
void main()
|
||||
{
|
||||
if(spec_canary != 1338) { Color = vec4(1.0, 0.0, 0.0, 1.0); return; }
|
||||
|
||||
Color = vertIn.col;
|
||||
}
|
||||
|
||||
@@ -78,8 +92,12 @@ void main()
|
||||
|
||||
layout(location = 0, index = 0) out vec4 Color;
|
||||
|
||||
layout(constant_id = 2) const int spec_canary = 0;
|
||||
|
||||
void main()
|
||||
{
|
||||
if(spec_canary != 1338) { Color = vec4(1.0, 0.0, 0.0, 1.0); return; }
|
||||
|
||||
Color = vec4(1,1,1,1);
|
||||
}
|
||||
|
||||
@@ -240,6 +258,21 @@ void main()
|
||||
CompileShaderModule(common + pixel, ShaderLang::glsl, ShaderStage::frag, "main"),
|
||||
};
|
||||
|
||||
VkSpecializationMapEntry specmap[2] = {
|
||||
{1, 0 * sizeof(uint32_t), sizeof(uint32_t)}, {2, 1 * sizeof(uint32_t), sizeof(uint32_t)},
|
||||
};
|
||||
|
||||
uint32_t specvals[2] = {1337, 1338};
|
||||
|
||||
VkSpecializationInfo spec = {};
|
||||
spec.mapEntryCount = ARRAY_COUNT(specmap);
|
||||
spec.pMapEntries = specmap;
|
||||
spec.dataSize = sizeof(specvals);
|
||||
spec.pData = specvals;
|
||||
|
||||
pipeCreateInfo.stages[0].pSpecializationInfo = &spec;
|
||||
pipeCreateInfo.stages[1].pSpecializationInfo = &spec;
|
||||
|
||||
pipeCreateInfo.rasterizationState.depthClampEnable = VK_FALSE;
|
||||
pipeCreateInfo.rasterizationState.cullMode = VK_CULL_MODE_BACK_BIT;
|
||||
|
||||
@@ -293,6 +326,7 @@ void main()
|
||||
|
||||
pipeCreateInfo.stages[1] =
|
||||
CompileShaderModule(whitepixel, ShaderLang::glsl, ShaderStage::frag, "main");
|
||||
pipeCreateInfo.stages[1].pSpecializationInfo = &spec;
|
||||
pipeCreateInfo.multisampleState.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
|
||||
pipeCreateInfo.renderPass = subrp;
|
||||
pipeCreateInfo.depthStencilState.stencilTestEnable = VK_FALSE;
|
||||
|
||||
@@ -46,8 +46,12 @@ void main()
|
||||
|
||||
layout(location = 0, index = 0) out vec4 Color;
|
||||
|
||||
layout(constant_id = 1) const int spec_canary = 0;
|
||||
|
||||
void main()
|
||||
{
|
||||
if(spec_canary != 1337) { Color = vec4(0.2, 0.0, 0.2, 1.0); return; }
|
||||
|
||||
#if 1
|
||||
Color = vec4(0.0, 1.0, 0.0, 1.0);
|
||||
#else
|
||||
@@ -104,11 +108,26 @@ void main()
|
||||
CompileShaderModule(pixel, ShaderLang::glsl, ShaderStage::frag, "main"),
|
||||
};
|
||||
|
||||
VkSpecializationMapEntry specmap[1] = {
|
||||
{1, 0 * sizeof(uint32_t), sizeof(uint32_t)},
|
||||
};
|
||||
|
||||
uint32_t specvals[1] = {1337};
|
||||
|
||||
VkSpecializationInfo spec = {};
|
||||
spec.mapEntryCount = ARRAY_COUNT(specmap);
|
||||
spec.pMapEntries = specmap;
|
||||
spec.dataSize = sizeof(specvals);
|
||||
spec.pData = specvals;
|
||||
|
||||
pipeCreateInfo.stages[1].pSpecializationInfo = &spec;
|
||||
|
||||
VkPipeline pipe = createGraphicsPipeline(pipeCreateInfo);
|
||||
|
||||
// use the same source but make a distinct shader module so we can edit it separately
|
||||
pipeCreateInfo.stages[1] =
|
||||
CompileShaderModule(pixel, ShaderLang::glsl, ShaderStage::frag, "main");
|
||||
pipeCreateInfo.stages[1].pSpecializationInfo = &spec;
|
||||
|
||||
VkPipeline pipe2 = createGraphicsPipeline(pipeCreateInfo);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user