Light | Dark

glSpecializeShader

Name

glSpecializeShader — specialize a shader object from a SPIR-V module

C Specification

void glSpecializeShader( GLuint shader,
  const GLchar* pEntryPoint,
  GLuint numSpecializationConstants,
  const GLuint* pConstantIndex,
  const GLuint* pConstantValue);
 

Parameters

shader

Specifies the name of a shader object containing unspecialized SPIR-V as created from a successful call to glShaderBinary to which a SPIR-V module was passed.

pEntryPoint

Specifies a pointer to a null-terminated UTF-8 string specifying the name of the entry point in the SPIR-V module to use for this shader.

numSpecializationConstants

Specifies the number of specialization constants whose values to set in this call.

pConstantIndex

Specifies a pointer to an array of numSpecializationConstants unsigned integers, each holding the index of a specialization constant in the SPIR-V module whose value to set.

pConstantValue

Specifies a pointer to an array of numSpecializationConstants unsigned integers, each holding the value to set for the corresponding specialization constant indexed by pConstantIndex.

Description

glSpecializeShader specializes a shader created from a SPIR-V module. Shaders associated with SPIR-V modules must be specialized before they can be linked into a program object. It is not necessary to specialize the shader before it is attached to a program object. Once specialized, a shader may not be specialized again without first re-associating the original SPIR-V module with it, through glShaderBinary.

Specialization does two things:

• Selects the name of the entry point, for that shader's stage, from the SPIR-V module.

• Sets the values of all, or a subset of, the specialization constants in the SPIR-V module.

The entry point specified by pEntryPoint must match the name of an OpEntryPoint declaration in the SPIR-V module associated with shader. The execution mode of the selected entry point must match the type of the shader object.

Each entry in pConstantIndex specifies the index of a specialization constant in the SPIR-V module whose value should be set. The corresponding entry in pConstantValue is used to set the value of the specialization constant indexed by the entry in pConstantIndex. Although this array is of unsigned integer, each entry is bitcast to the appropriate type for the module, and therefore, floating-point constants may be set by including their IEEE-754 bit representation in the pConstantValue array.

Specialization constants not referenced by pConstantIndex retain their default values as specified in the SPIR-V module.

On successful shader specialization, the compile status for shader is set to GL_TRUE. On failure, the compile status for shader is set to GL_FALSE and additional information about the cause of the failure may be available in the shader compilation log.

Errors

GL_INVALID_VALUE is generated if shader is not the name of either a program or shader object.

GL_INVALID_OPERATION is generated if shader is the name of a program object.

GL_INVALID_OPERATION is generated if the value of GL_SPIR_V_BINARY for shader is not GL_TRUE, or if the shader has already been specialized.

GL_INVALID_VALUE is generated if pEntryPoint does not match the name of any OpEntryPoint declaration in the SPIR-V module associated with shader.

GL_INVALID_OPERATION is generated if the execution mode of the OpEntryPoint indicated by pEntryPoint does not match the type of shader.

GL_INVALID_VALUE is generated if any element of pConstantIndex refers to a specialization constant that does not exist in the shader module contained in shader.

An GL_INVALID_OPERATION error is generated if the SPIR-V module fails to meet the requirements listed in the OpenGL specification.

Associated Gets

glGetShaderiv with argument GL_COMPILE_STATUS

glGetShaderiv with argument GL_SPIR_V_BINARY

glGetShaderInfoLog

Version Support

OpenGL Version
Function / Feature Name 2.0 2.1 3.0 3.1 3.2 3.3 4.0 4.1 4.2 4.3 4.4 4.5 4.6
glSpecializeShader - - - - - - - - - - - -
Think you can improve this page? Edit this page on GitHub.