1 Specialization Constants tests 2 3Tests: 4 + dEQP-VK.pipeline.spec_constant.* 5 6Includes: 7 + Uses extended GLSL (KHR_vulkan_glsl) to specify shaders 8 (dependency on glslang) 9 + Basic specialization constants (OpSpecConstant, OpSpecConstantTrue, 10 OpSpecConstantFalse instructions) 11 - No specialization info (default values) 12 - Partial and full specialization 13 - 32 bit boolean, integer and float types 14 - (optional) 16 and 64 bit types, where supported 15 + Specialization constants in composites (OpSpecConstantComposite instruction) 16 - struct members 17 - array elements 18 - vector components 19 - matrix columns 20 + Specialization constants in expressions (OpSpecConstantOp instruction) 21 - Array size 22 - (optional) Various instructions as listed in the spec 23 + Compute shader work group size specialization 24 + Built-in constant specialization (override the default value) 25 + All of the above should be exercised with all applicable shader stages in 26 both pipeline types (compute and graphics). 27 28Excludes: 29 + SPIR-V assembly code 30 + OpSpecConstantOp instructions are covered by assembly tests in 31 external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp 32 33Notes: 34 + SPIR-V generated from GLSL should be inspected for instruction coverage 35 and overall correctness before accepting the tests. 36 37Description: 38 39The tests will run various shader stages with some specialization constants. 40Constant values are read in the shader, written to a SSBO, and read back from 41a host-visible buffer. Depending on the test, none, some, or all specialization 42constants are defined through VkSpecializationInfo. The test passes if the value 43written by the shader matches the expected reference value (either the default 44or a set specialized value). 45 46For expression tests result of an operation is written to the output SSBO and 47then compared to a reference operation result. 48 49A test with no specialization info verifies that the default values defined in 50the shader are used correctly. Specialization with one or more specialization 51constants check if Vulkan structure is consumed correctly by the API. 52 53Different types and type widths are tested to see if provided value is passed 54correctly to the shader. The tests will use types and expressions similar to the 55following (examples are not exhaustive): 56 57 // Basic specialization constants and const expressions 58 59 layout(constant_id = 7) const int foo = 3; 60 layout(constant_id = 9) const float bar = 6.5; 61 62 int data[foo]; 63 int data2[foo + 2]; 64 65 // Specialization constant expressions 66 67 const float expr_fadd = bar + 3.5; // OpFAdd 68 69 // Specialization constant composites 70 71 const vec3 sc_vec = vec3(1.0, bar, 3.0); 72 const int sc_array[4] = int[](foo, 2, 3, 4); 73 74 // Override work group size 75 76 layout(local_size_y_id = 19) in; // y=? (id=19) 77 layout(local_size_x_id = 20, local_size_z_id = 21) in; // x=? z=? 78 79 // Override Built-in constant 80 81 layout(constant_id = 13) gl_MaxImageUnits; 82