Skip to content

Commit

Permalink
Minor fix for VK_EXT_graphics_pipeline_library proposal vertex shader…
Browse files Browse the repository at this point in the history
… sample code (KhronosGroup#1819)

* Minor fix for vertex shader sample code

* Added missing sType

* Added missing sTypes

* Added missing sTypes

* Zero-initialize structs

* Added missing sTypes

* Added pName for shader
  • Loading branch information
SaschaWillems authored Apr 5, 2022
1 parent 45af5eb commit ebc0afd
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions proposals/VK_EXT_graphics_pipeline_library.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -438,33 +438,39 @@ VkPipeline createVertexShader(
VkPipelineCache vertexShaderCache,
VkPipelineLayout layout)
{
VkShaderModuleCreateInfo shaderModuleCreateInfo;
VkShaderModuleCreateInfo shaderModuleCreateInfo{};
shaderModuleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
shaderModuleCreateInfo.codeSize = shaderSize;
shaderModuleCreateInfo.pCode = pShader;
VkGraphicsPipelineLibraryCreateInfoEXT libraryInfo;
VkGraphicsPipelineLibraryCreateInfoEXT libraryInfo{};
libraryInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_LIBRARY_CREATE_INFO_EXT;
libraryInfo.flags = VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT;
VkPipelineShaderStageCreateInfo stageCreateInfo;
stageCreateInfo.pNext = shaderModuleCreateInfo;
VkPipelineShaderStageCreateInfo stageCreateInfo{};
stageCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
stageCreateInfo.pNext = &shaderModuleCreateInfo;
stageCreateInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
stageCreateInfo.pName = "main";
VkDynamicState vertexDynamicStates[2] = {
VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT,
VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT };
VkPipelineDynamicStateCreateInfo dynamicInfo;
VkPipelineDynamicStateCreateInfo dynamicInfo{};
dynamicInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
dynamicInfo.dynamicStateCount = 2;
dynamicInfo.pDynamicStates = vertexDynamicStates;
VkGraphicsPipelineCreateInfo vertexShaderCreateInfo;
VkGraphicsPipelineCreateInfo vertexShaderCreateInfo{};
vertexShaderCreateInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
vertexShaderCreateInfo.pNext = &libraryInfo;
vertexShaderCreateInfo.flags = VK_PIPELINE_CREATE_LIBRARY_BIT_KHR |
VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT;
vertexShaderCreateInfo.stageCount = 1;
vertexShaderCreateInfo.pStages = &stageCreateInfo;
vertexShaderCreateInfo.layout = layout;
vertexShaderCreateInfo.pDynamicStates = &dynamicInfo;
vertexShaderCreateInfo.pDynamicState = &dynamicInfo;
VkPipeline vertexShader;
vkCreateGraphicsPipelines(
Expand Down Expand Up @@ -498,11 +504,13 @@ VkPipeline linkExecutable(
VkPipelineCache executableCache,
bool optimized)
{
VkPipelineLibraryCreateInfoKHR linkingInfo;
VkPipelineLibraryCreateInfoKHR linkingInfo{};
linkingInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR;
linkingInfo.libraryCount = libraryCount;
linkingInfo.pLibraries = pLibraries;
VkGraphicsPipelineCreateInfo executablePipelineCreateInfo;
VkGraphicsPipelineCreateInfo executablePipelineCreateInfo{};
executablePipelineCreateInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
executablePipelineCreateInfo.pNext = &linkingInfo;
executablePipelineCreateInfo.flags |= optimized ?
VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT : 0;
Expand Down

0 comments on commit ebc0afd

Please sign in to comment.