Skip to content
This repository was archived by the owner on Jul 19, 2018. It is now read-only.

Commit c64f688

Browse files
committed
tests: Add test for a specialization-induced array size mismatch
These shaders are fine without the specialization -- but with it applied, we should get a type mismatch on the array sizes.
1 parent 1870a5d commit c64f688

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

tests/layer_validation_tests.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14717,6 +14717,59 @@ TEST_F(VkLayerTest, CreatePipelineVsFsArraySizeDefaultSpecialization) {
1471714717
m_errorMonitor->VerifyFound();
1471814718
}
1471914719

14720+
TEST_F(VkLayerTest, CreatePipelineVsFsArraySizeSpecialization) {
14721+
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Type mismatch");
14722+
14723+
// Trigger a type mismatch when the VS output array size is specialized. If
14724+
// specializations are not applied, then these interfaces match fine.
14725+
14726+
ASSERT_NO_FATAL_FAILURE(Init());
14727+
ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
14728+
14729+
char const *vsSource =
14730+
"#version 450\n"
14731+
"out gl_PerVertex {\n"
14732+
" vec4 gl_Position;\n"
14733+
"};\n"
14734+
"layout(constant_id=0) const uint size = 1;\n"
14735+
"layout(location=0) out float xs[size];\n"
14736+
"void main(){\n"
14737+
" gl_Position = vec4(0);\n"
14738+
" for (int i = 0; i < size; i++) { xs[i] = 42.0; }\n"
14739+
"}\n";
14740+
char const *fsSource =
14741+
"#version 450\n"
14742+
"\n"
14743+
"layout(location=0) in float xs[1];\n"
14744+
"layout(location=0) out vec4 color;\n"
14745+
"void main(){\n"
14746+
" color = vec4(xs[0]);\n"
14747+
"}\n";
14748+
14749+
VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this);
14750+
VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this);
14751+
14752+
// Specialize the VS
14753+
uint32_t actual_size = 2;
14754+
VkSpecializationMapEntry spec_entry = { 0, 0, sizeof(actual_size) };
14755+
VkSpecializationInfo spec = { 1, &spec_entry, sizeof(actual_size), &actual_size };
14756+
auto vs_stage = vs.GetStageCreateInfo();
14757+
vs_stage.pSpecializationInfo = &spec;
14758+
14759+
VkPipelineObj pipe(m_device);
14760+
pipe.AddColorAttachment();
14761+
pipe.AddShader(vs_stage);
14762+
pipe.AddShader(&fs);
14763+
14764+
VkDescriptorSetObj descriptorSet(m_device);
14765+
descriptorSet.AppendDummy();
14766+
descriptorSet.CreateVKDescriptorSet(m_commandBuffer);
14767+
14768+
pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass());
14769+
14770+
m_errorMonitor->VerifyFound();
14771+
}
14772+
1472014773
TEST_F(VkLayerTest, CreatePipelineDepthStencilRequired) {
1472114774
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
1472214775
"pDepthStencilState is NULL when rasterization is enabled and subpass "

0 commit comments

Comments
 (0)