1Conformance Test 2 3 GL_ARB_gl_spirv 4 5Contributors 6 7 Adam Czupryna, Mobica 8 9Contacts 10 11 Adam Czupryna, Mobica (adam.czupryna 'at' mobica.com) 12 13Status 14 15 In review 16 17Version 18 19 July 5, 2017 (version 1) 20 21Dependencies 22 23 OpenGL 4.5 is required. 24 25 ARB_gl_spirv extension is required. 26 27 This specification is written against: 28 - OpenGL 4.5 Core Profile Specification, 29 - version 4.50 (revision 5) Shading Language Specification, 30 - ARB_gl_spirv extension Specification. 31 32Overview 33 34 This test verifies two things: 35 36 1. Verifies if OpenGL API allows a SPIR-V module to be specified as containing a 37 programmable shader stage, rather than using GLSL, whatever the source language 38 was used to create the SPIR-V module. 39 40 2. Verifies if GLSL is modified to be a source language for creating SPIR-V 41 modules for OpenGL consumption. 42 43Tests 44 45 SPIR-V Modules Tests 46 47 * Positive Tests 48 49 - Create GLSL shader for each shading stage. Each stage should receive color 50 vector from previous stage and multiply it by constant value greater than 1. 51 First stage should set color components to non zero values. Last stage should 52 draw color to the framebuffer. 53 54 Perform drawing and verify the result. Expect that color read from the 55 framebuffer will be correctly multiplied. 56 57 - Use glslang to compile GLSL shaders to SPIR-V binary modules. Create shader 58 objects using ShaderBinary function with binary format set to 59 SHADER_BINARY_FORMAT_SPIR_V_ARB and specialize it using SpecializeShader 60 function. 61 62 Perform drawing and verify the result. Expect the same result as for 63 previous case. 64 65 * Shader Binary Multiple Shader Objects 66 67 - Create GLSL shader for at least two shading stages. Use glslang to compile 68 GLSL shaders to single SPIR-V module. Create shader object for each stage and 69 perform ShaderBinary function passing shader set as an argument, use 70 SHADER_BINARY_FORMAT_SPIR_V_ARB binary format. Specialize shader objects 71 using SpecializeShader function with proper entry point argument for each 72 shader. 73 74 Perform drawing and verify if the result is as expected. 75 76 * State Queries 77 78 - Verify if GetShaderiv with <pname> set to SPIR_V_BINARY_ARB used on valid 79 shader created using SHADER_BINARY_FORMAT_SPIR_V_ARB binary format will 80 result in TRUE. 81 82 - Verify if ShaderSource function used on shader with SPIR_V_BINARY_ARB state 83 set to TRUE will result in changing SPIR_V_BINARY_ARB state to FALSE. 84 85 - Verify if ShaderSource function used on shader with SPIR_V_BINARY_ARB state 86 set to TRUE will result in changing SPIR_V_BINARY_ARB state to FALSE. 87 88 - Verify if shader compile status is set to TRUE if shader is specialized. 89 90 - Verify if GetShaderInfoLog function return information about the last 91 specialization attempt if SpecializeShader is use in a wrong way. 92 93 - Verify if GetProgramiv function return one for ACTIVE_ATTRIBUTE_MAX_LENGTH 94 <pname> when no name reflection information is available. 95 96 - Verify if GetProgramiv function return one for ACTIVE_UNIFORM_MAX_LENGTH 97 <pname> when no name reflection information is available. 98 99 - Verify if GetProgramiv function return one for TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 100 <pname> when no name reflection information is available. 101 102 - Verify if GetProgramiv function return one for ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 103 <pname> when no name reflection information is available. 104 105 * Error Verification 106 107 - Verify if CompileShader function used on shader with SPIR_V_BINARY_ARB state 108 will result in generating INVALID_OPERATION error. 109 110 - Verify if SpecializeShader function generate INVALID_VALUE error when 111 <shader> is not the name of either a program or shader object. 112 113 - Verify if SpecializeShader function generate INVALID_OPERATION error when 114 <shader> is the name of a program object. 115 116 - Verify if SpecializeShader function generate INVALID_OPERATION error when 117 SPIR_V_BINARY_ARB state for <shader> is not TRUE, or if the shader has 118 already been specialized. 119 120 - Verify if SpecializeShader function generate INVALID_VALUE when <pEntryPoint> 121 does not name a valid entry point for <shader>. 122 123 - Verify if SpecializeShader function generate INVALID_VALUE when any element 124 of <pConstantIndex> refers to a specialization constant that does not exist 125 in the shader module contained in <shader>. 126 127 - Verify if LinkProgram fail when one or more of the shader objects attached to 128 <program> are not specialized. 129 130 - Verify if LinkProgram fail when not all of shaders attached to <program> have 131 the same value for the SPIR_V_BINARY_ARB state. 132 133 GLSL to SPIR-V Features Tests 134 135 * Enable SPIR-V Features 136 137 - Create vertex shader that checks if GL_SPIRV is defined and returns error 138 message if not. 139 140 * Built-in Functions 141 142 - Create set of shaders that uses built-in functions listed in section 8 of 143 The OpenGL Shading Language 4.50 specification. Compile shader to SPIR-V 144 binary module using glslang and disassembly module. 145 146 - Verify if no error occured during compilation. 147 148 - Verify if built-in functions are converted from GLSL to SPIR-V as expected. 149 150 NOTE: noise* built-in functions are excluded from testing as they are deprecated. 151 152 * Specialization Constants 153 154 - Create fragment shader with specialized constant floats - one for each color 155 component and forward it to default fragment output as vec4. Compile shader 156 to SPIR-V binary module using glslang. Create shader object and specialize it 157 with different values. 158 159 - Render a fullscreen polygon and read back pixels from framebuffer. 160 161 - Expect that color components of read pixels follows values used in shader 162 specialization. 163 164 SPIR-V Validation 165 166 * SPIR-V Built-In Variable Decorations 167 168 Create SPIR-V modules set that uses built-in variable decorations listed below: 169 170 Built-in Variable Decoration Minimum GL version (Extension) 171 ---------------------------- ----------------------------- 172 NumWorkgroups GL 4.3 (ARB_compute_shader) 173 WorkgroupSize GL 4.3 (ARB_compute_shader) 174 WorkgroupId GL 4.3 (ARB_compute_shader) 175 LocalInvocationId GL 4.3 (ARB_compute_shader) 176 GlobalInvocationId GL 4.3 (ARB_compute_shader) 177 LocalInvocationIndex GL 4.3 (ARB_compute_shader) 178 VertexId 179 InstanceId 180 Position 181 PointSize 182 ClipDistance 183 CullDistance GL 4.5 (ARB_cull_distance) 184 PrimitiveId 185 InvocationId GL 4.0 (ARB_tessellation_shader) 186 Layer 187 ViewportIndex GL 4.1 (ARB_viewport_array) 188 PatchVertices GL 4.0 (ARB_tessellation_shader) 189 TessLevelOuter GL 4.0 (ARB_tessellation_shader) 190 TessLevelInner GL 4.0 (ARB_tessellation_shader) 191 TessCoord GL 4.0 (ARB_tessellation_shader) 192 FragCoord 193 FrontFacing 194 PointCoord 195 SampleId GL 4.0 (ARB_sample_shading) 196 SamplePosition GL 4.0 (ARB_sample_shading) 197 SampleMask GL 4.0 (ARB_sample_shading) 198 HelperInvocation GL 4.5 (ARB_ES3_1_compatibility) 199 200 Use SPIR-V modules in apropriate shader stage (adequate to variable it tests). 201 Create program objects and execute them. Make sure that no error occured and 202 the result of program execution is as expected. 203 204 * SPIR-V Capabilities 205 206 Create SPIR-V modules set that capabilities listed below: 207 208 OpCapability Minimum GL version (Extension) 209 ------------------------------ ----------------------------- 210 Matrix 211 Shader 212 Geometry 213 Tessellation GL 4.0 (ARB_tessellation_shader) 214 Float64 GL 4.0 (ARB_gpu_shader_fp64) 215 AtomicStorage GL 4.2 (ARB_shader_atomic_counters) 216 TessellationPointSize GL 4.0 (ARB_tessellation_shader) 217 GeometryPointSize 218 ImageGatherExtended GL 4.0 (ARB_gpu_shader5) 219 StorageImageMultisample GL 4.2 (ARB_shader_image_load_store) 220 UniformBufferArrayDynamicIndexing GL 4.0 (ARB_gpu_shader5) 221 SampledImageArrayDynamicIndexing GL 4.0 (ARB_gpu_shader5) 222 StorageBufferArrayDynamicIndexing GL 4.3 (ARB_shader_storage_buffer_object) 223 StorageImageArrayDynamicIndexing GL 4.2 (ARB_shader_image_load_store) 224 ClipDistance 225 CullDistance GL 4.5 (ARB_cull_distance) 226 ImageCubeArray GL 4.0 (ARB_texture_cube_map_array) 227 SampleRateShading GL 4.0 (ARB_sample_shading) 228 ImageRect 229 SampledRect 230 Sampled1D 231 Image1D 232 SampledCubeArray GL 4.0 (ARB_texture_cube_map_array) 233 SampledBuffer 234 ImageBuffer 235 ImageMSArray 236 StorageImageExtendedFormats GL 4.2 (ARB_shader_image_load_store) 237 ImageQuery 238 DerivativeControl GL 4.5 (ARB_derivative_control) 239 InterpolationFunction GL 4.0 (ARB_gpu_shader5) 240 TransformFeedback 241 GeometryStreams GL 4.0 (ARB_gpu_shader5) 242 StorageImageWriteWithoutFormat GL 4.2 (ARB_shader_image_load_store) 243 MultiViewport GL 4.1 (ARB_viewport_array) 244 Int64 (ARB_gpu_shader_int64) 245 SparseResidency (ARB_sparse_texture2) 246 MinLod (ARB_sparse_texture_clamp) 247 StorageImageReadWithoutFormat (EXT_shader_image_load_formatted) 248 Int64Atomics (NV_shader_atomic_int64) 249 250 Use SPIR-V modules in apropriate shader stage (adequate to capability it tests). 251 Create program objects and execute them. Make sure that no error occured and 252 the result of program execution is as expected. 253 254Revision History 255 256 Revision 1, 5 July, 2017 (Adam Czupryna) 257 - Initial version. 258 259