Skip to content

Commit

Permalink
Add test case for component type mismatch
Browse files Browse the repository at this point in the history
V2: Add comment clarifying why this test works
  • Loading branch information
chrisforbes committed Aug 28, 2018
1 parent 5c71643 commit 3c5b959
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/layer_validation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19483,6 +19483,65 @@ TEST_F(VkLayerTest, DrawTimeImageMultisampleMismatchWithPipeline) {
m_commandBuffer->end();
}

TEST_F(VkLayerTest, DrawTimeImageComponentTypeMismatchWithPipeline) {
TEST_DESCRIPTION(
"Test that an error is produced when the component type of an imageview disagrees with the type in the shader.");

m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "SINT component type, but bound descriptor");

ASSERT_NO_FATAL_FAILURE(Init());
ASSERT_NO_FATAL_FAILURE(InitRenderTarget());

char const *vsSource =
"#version 450\n"
"\n"
"void main() { gl_Position = vec4(0); }\n";
char const *fsSource =
"#version 450\n"
"\n"
"layout(set=0, binding=0) uniform isampler2D s;\n"
"layout(location=0) out vec4 color;\n"
"void main() {\n"
" color = texelFetch(s, ivec2(0), 0);\n"
"}\n";
VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this);
VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this);

VkPipelineObj pipe(m_device);
pipe.AddShader(&vs);
pipe.AddShader(&fs);
pipe.AddDefaultColorAttachment();

VkTextureObj texture(m_device, nullptr); // UNORM texture by default, incompatible with isampler2D
VkSamplerObj sampler(m_device);

VkDescriptorSetObj descriptorSet(m_device);
descriptorSet.AppendSamplerTexture(&sampler, &texture);
descriptorSet.CreateVKDescriptorSet(m_commandBuffer);

VkResult err = pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass());
ASSERT_VK_SUCCESS(err);

m_commandBuffer->begin();
m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);

vkCmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
m_commandBuffer->BindDescriptorSet(descriptorSet);

VkViewport viewport = {0, 0, 16, 16, 0, 1};
vkCmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport);
VkRect2D scissor = {{0, 0}, {16, 16}};
vkCmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor);

// error produced here.
vkCmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0);

m_errorMonitor->VerifyFound();

m_commandBuffer->EndRenderPass();
m_commandBuffer->end();
}

TEST_F(VkLayerTest, AttachmentDescriptionUndefinedFormat) {
TEST_DESCRIPTION("Create a render pass with an attachment description format set to VK_FORMAT_UNDEFINED");

Expand Down

0 comments on commit 3c5b959

Please sign in to comment.