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