Name VK_NV_glsl_shader Name Strings VK_NV_glsl_shader Extension Type Device extension Contributors Piers Daniell, NVIDIA Contacts Piers Daniell (pdaniell at nvidia.com) Status Proposal Version Last Modified Date: 2/15/2016 Revision: 2 Registered Extension Number 13 IP Status No known IP claims. Dependencies This extension is written against version 1.0 of the {apiname} API. This extension interacts with VK_EXT_debug_report if available. Overview Implementations that expose this function allow GLSL shaders to be referenced by VkShaderModuleCreateInfo.pCode as an alternative to SPIR-V shaders. The implementation will automatically detect whether SPIR-V or GLSL is passed in. In order to support Vulkan features the GLSL shaders must be authored to the GL_KHR_vulkan_glsl extension specification. New Object Types None New Enum Constants The following enum has been added to VkResult: VK_ERROR_INVALID_SHADER_NV = -1000012000 New Enums None New Procedures and Functions None Description Modify Section 2.5.2 (Return Codes) to add one more error: * VK_ERROR_INVALID_SHADER_NV One or more shaders failed to compile or link. More details are reported back to the application via VK_EXT_debug_report if enabled. Modify Section 9.1 (Compute Pipelines) and add the following at the bottom of the vkCreateComputePipelines() command description: If any shader stage fails to compile VK_ERROR_INVALID_SHADER_NV will be generated and the compile log will be reported back to the application by VK_EXT_debug_report if enabled. Modify Section 9.2 (Graphics Pipelines) and add the following at the bottom of the vkCreateGraphicsPipelines() command description: If any shader stage fails to compile VK_ERROR_INVALID_SHADER_NV will be generated and the compile log will be reported back to the application by VK_EXT_debug_report if enabled. Modify Section 8.1 (Shader Modules) validity section for VkShaderModuleCreateInfo: * codeSize must: be a multiple of 4. If the VK_NV_glsl_shader extension is enabled and pname:pCode references GLSL code codeSize can be a multiple of 1 * pCode must: point to valid SPIR-V code, formatted and packed as described by https://www.khronos.org/registry/spir-v/specs/1.0/SPIRV.html [the SPIR-V Specification v1.0]. If the VK_NV_glsl_shader extension is enabled pCode can instead reference valid GLSL code and must be written to the GL_KHR_vulkan_glsl extension specification. * pCode must adhere to the validation rules described by the "Validation Rules within a Module" section of the "SPIR-V Environment" appendix. If the VK_NV_glsl_shader extension is enabled pCode can be valid GLSL code with respect to the GL_KHR_vulkan_glsl GLSL extension specification Issues None Example code char const vss[] = "#version 450 core\n" "layout(location = 0) in vec2 aVertex;\n" "layout(location = 1) in vec4 aColor;\n" "out vec4 vColor;\n" "void main()\n" "{\n" " vColor = aColor;\n" " gl_Position = vec4(aVertex, 0, 1);\n" "}\n" ; VkShaderModuleCreateInfo vertexShaderInfo = { VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO }; vertexShaderInfo.codeSize = sizeof vss; vertexShaderInfo.pCode = vss; VkShaderModule vertexShader; vkCreateShaderModule(device, &vertexShaderInfo, 0, &vertexShader);