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