MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-ValidationLayers / TEST_F

Function TEST_F

tests/unit/shader_spirv.cpp:28–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26class NegativeShaderSpirv : public VkLayerTest {};
27
28TEST_F(NegativeShaderSpirv, CodeSize) {
29 TEST_DESCRIPTION("Test that errors are produced for a spirv modules with invalid code sizes");
30
31 RETURN_IF_SKIP(Init());
32 InitRenderTarget();
33
34 {
35 VkShaderModule module;
36 VkShaderModuleCreateInfo module_create_info = vku::InitStructHelper();
37
38 module_create_info.pCode = nullptr;
39 module_create_info.codeSize = 0;
40
41 m_errorMonitor->SetDesiredError("VUID-VkShaderModuleCreateInfo-codeSize-01085");
42 vk::CreateShaderModule(device(), &module_create_info, nullptr, &module);
43 m_errorMonitor->VerifyFound();
44 }
45
46 {
47 VkShaderModule module;
48 VkShaderModuleCreateInfo module_create_info = vku::InitStructHelper();
49
50 constexpr icd_spv_header spv = {};
51 module_create_info.pCode = reinterpret_cast<const uint32_t*>(&spv);
52 module_create_info.codeSize = 4;
53
54 m_errorMonitor->SetDesiredError("Invalid SPIR-V header");
55 vk::CreateShaderModule(device(), &module_create_info, nullptr, &module);
56 m_errorMonitor->VerifyFound();
57 }
58
59 {
60 VkShaderModuleCreateInfo module_create_info = vku::InitStructHelper();
61 VkShaderModule module;
62 std::vector<uint32_t> shader = GLSLToSPV(VK_SHADER_STAGE_VERTEX_BIT, kVertexMinimalGlsl);
63 module_create_info.pCode = shader.data();
64 // Introduce failure by making codeSize a non-multiple of 4
65 module_create_info.codeSize = shader.size() * sizeof(uint32_t) - 1;
66
67 m_errorMonitor->SetDesiredError("VUID-VkShaderModuleCreateInfo-codeSize-08735");
68 vk::CreateShaderModule(*m_device, &module_create_info, nullptr, &module);
69 m_errorMonitor->VerifyFound();
70 }
71}
72
73TEST_F(NegativeShaderSpirv, CodeSizeMaintenance5) {
74 TEST_DESCRIPTION("Test SPIRV is still checked if using new pNext in VkPipelineShaderStageCreateInfo");

Callers

nothing calls this directly

Calls 14

size32Function · 0.85
VkShaderObjClass · 0.85
SetDesiredErrorMethod · 0.80
CreateComputePipelineMethod · 0.80
SetUnexpectedErrorMethod · 0.80
c_strMethod · 0.80
CreateShaderModuleFunction · 0.50
VerifyFoundMethod · 0.45

Tested by

no test coverage detected