1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-14 00:48:44 +01:00

[dxvk] Use new shader stage info objects in DxvkShaderPipelineLibrary

Avoids crashing on drivers which do not support NULL modules for compute
pipelines and just reduces the amount of code by a small amount.
This commit is contained in:
Philip Rebohle 2022-07-06 00:49:21 +02:00
parent e6470b6d10
commit 6265b5b809
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -486,16 +486,9 @@ namespace dxvk {
const DxvkShaderPipelineLibraryCompileArgs& args) { const DxvkShaderPipelineLibraryCompileArgs& args) {
auto vk = m_device->vkd(); auto vk = m_device->vkd();
// Set up shader stage. Do not create a shader module. DxvkShaderStageInfo stageInfo(m_device);
SpirvCodeBuffer spirv = m_shader->getCode(m_layout, DxvkShaderModuleCreateInfo()); stageInfo.addStage(VK_SHADER_STAGE_VERTEX_BIT,
m_shader->getCode(m_layout, DxvkShaderModuleCreateInfo()), nullptr);
VkShaderModuleCreateInfo codeInfo = { VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO };
codeInfo.codeSize = spirv.size();
codeInfo.pCode = spirv.data();
VkPipelineShaderStageCreateInfo stageInfo = { VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, &codeInfo };
stageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
stageInfo.pName = "main";
// Set up dynamic state. We do not know any pipeline state // Set up dynamic state. We do not know any pipeline state
// at this time, so make as much state dynamic as we can. // at this time, so make as much state dynamic as we can.
@ -542,8 +535,8 @@ namespace dxvk {
VkGraphicsPipelineCreateInfo info = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, &libInfo }; VkGraphicsPipelineCreateInfo info = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, &libInfo };
info.flags = VK_PIPELINE_CREATE_LIBRARY_BIT_KHR; info.flags = VK_PIPELINE_CREATE_LIBRARY_BIT_KHR;
info.stageCount = 1; info.stageCount = stageInfo.getStageCount();
info.pStages = &stageInfo; info.pStages = stageInfo.getStageInfos();
info.pViewportState = &vpInfo; info.pViewportState = &vpInfo;
info.pRasterizationState = &rsInfo; info.pRasterizationState = &rsInfo;
info.pDynamicState = &dyInfo; info.pDynamicState = &dyInfo;
@ -562,16 +555,9 @@ namespace dxvk {
VkPipeline DxvkShaderPipelineLibrary::compileFragmentShaderPipeline(VkPipelineCache cache) { VkPipeline DxvkShaderPipelineLibrary::compileFragmentShaderPipeline(VkPipelineCache cache) {
auto vk = m_device->vkd(); auto vk = m_device->vkd();
// Set up shader stage. Do not create a shader module. DxvkShaderStageInfo stageInfo(m_device);
SpirvCodeBuffer spirv = m_shader->getCode(m_layout, DxvkShaderModuleCreateInfo()); stageInfo.addStage(VK_SHADER_STAGE_FRAGMENT_BIT,
m_shader->getCode(m_layout, DxvkShaderModuleCreateInfo()), nullptr);
VkShaderModuleCreateInfo codeInfo = { VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO };
codeInfo.codeSize = spirv.size();
codeInfo.pCode = spirv.data();
VkPipelineShaderStageCreateInfo stageInfo = { VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, &codeInfo };
stageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
stageInfo.pName = "main";
// Set up dynamic state. We do not know any pipeline state // Set up dynamic state. We do not know any pipeline state
// at this time, so make as much state dynamic as we can. // at this time, so make as much state dynamic as we can.
@ -619,8 +605,8 @@ namespace dxvk {
VkGraphicsPipelineCreateInfo info = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, &libInfo }; VkGraphicsPipelineCreateInfo info = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, &libInfo };
info.flags = VK_PIPELINE_CREATE_LIBRARY_BIT_KHR; info.flags = VK_PIPELINE_CREATE_LIBRARY_BIT_KHR;
info.stageCount = 1; info.stageCount = stageInfo.getStageCount();
info.pStages = &stageInfo; info.pStages = stageInfo.getStageInfos();
info.pDepthStencilState = &dsInfo; info.pDepthStencilState = &dsInfo;
info.pDynamicState = &dyInfo; info.pDynamicState = &dyInfo;
info.layout = m_layout->getPipelineLayout(); info.layout = m_layout->getPipelineLayout();
@ -641,21 +627,13 @@ namespace dxvk {
VkPipeline DxvkShaderPipelineLibrary::compileComputeShaderPipeline(VkPipelineCache cache) { VkPipeline DxvkShaderPipelineLibrary::compileComputeShaderPipeline(VkPipelineCache cache) {
auto vk = m_device->vkd(); auto vk = m_device->vkd();
// Set up shader stage. Do not create a shader module since we only DxvkShaderStageInfo stageInfo(m_device);
// ever call this if graphics pipeline libraries are supported. stageInfo.addStage(VK_SHADER_STAGE_COMPUTE_BIT,
SpirvCodeBuffer spirv = m_shader->getCode(m_layout, DxvkShaderModuleCreateInfo()); m_shader->getCode(m_layout, DxvkShaderModuleCreateInfo()), nullptr);
VkShaderModuleCreateInfo codeInfo = { VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO };
codeInfo.codeSize = spirv.size();
codeInfo.pCode = spirv.data();
VkPipelineShaderStageCreateInfo stageInfo = { VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, &codeInfo };
stageInfo.stage = VK_SHADER_STAGE_COMPUTE_BIT;
stageInfo.pName = "main";
// Compile the compute pipeline as normal // Compile the compute pipeline as normal
VkComputePipelineCreateInfo info = { VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO }; VkComputePipelineCreateInfo info = { VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO };
info.stage = stageInfo; info.stage = *stageInfo.getStageInfos();
info.layout = m_layout->getPipelineLayout(); info.layout = m_layout->getPipelineLayout();
info.basePipelineIndex = -1; info.basePipelineIndex = -1;