mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 06:21:26 +12:00
vk: Validate pipeline state before compiling in case of shader cache moved between GPUs/drivers
This commit is contained in:
parent
9199b1b1d8
commit
4a32b70aec
1 changed files with 33 additions and 8 deletions
|
@ -93,10 +93,20 @@ namespace vk
|
||||||
dynamic_state_descriptors.push_back(VK_DYNAMIC_STATE_STENCIL_REFERENCE);
|
dynamic_state_descriptors.push_back(VK_DYNAMIC_STATE_STENCIL_REFERENCE);
|
||||||
dynamic_state_descriptors.push_back(VK_DYNAMIC_STATE_DEPTH_BIAS);
|
dynamic_state_descriptors.push_back(VK_DYNAMIC_STATE_DEPTH_BIAS);
|
||||||
|
|
||||||
if (g_render_device->get_depth_bounds_support())
|
auto pdss = &create_info.state.ds;
|
||||||
|
VkPipelineDepthStencilStateCreateInfo ds2;
|
||||||
|
if (g_render_device->get_depth_bounds_support()) [[likely]]
|
||||||
{
|
{
|
||||||
dynamic_state_descriptors.push_back(VK_DYNAMIC_STATE_DEPTH_BOUNDS);
|
dynamic_state_descriptors.push_back(VK_DYNAMIC_STATE_DEPTH_BOUNDS);
|
||||||
}
|
}
|
||||||
|
else if (pdss->depthBoundsTestEnable)
|
||||||
|
{
|
||||||
|
rsx_log.warning("Depth bounds test is enabled in the pipeline object but not supported by the current driver.");
|
||||||
|
|
||||||
|
ds2 = *pdss;
|
||||||
|
pdss = &ds2;
|
||||||
|
ds2.depthBoundsTestEnable = VK_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
VkPipelineDynamicStateCreateInfo dynamic_state_info = {};
|
VkPipelineDynamicStateCreateInfo dynamic_state_info = {};
|
||||||
dynamic_state_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
dynamic_state_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
||||||
|
@ -110,12 +120,27 @@ namespace vk
|
||||||
vp.viewportCount = 1;
|
vp.viewportCount = 1;
|
||||||
vp.scissorCount = 1;
|
vp.scissorCount = 1;
|
||||||
|
|
||||||
VkPipelineMultisampleStateCreateInfo ms = create_info.state.ms;
|
auto pmss = &create_info.state.ms;
|
||||||
ensure(ms.rasterizationSamples == VkSampleCountFlagBits((create_info.renderpass_key >> 16) & 0xF)); // "Multisample state mismatch!"
|
VkPipelineMultisampleStateCreateInfo ms2;
|
||||||
if (ms.rasterizationSamples != VK_SAMPLE_COUNT_1_BIT)
|
ensure(pmss->rasterizationSamples == VkSampleCountFlagBits((create_info.renderpass_key >> 16) & 0xF)); // "Multisample state mismatch!"
|
||||||
|
|
||||||
|
if (pmss->rasterizationSamples != VK_SAMPLE_COUNT_1_BIT || pmss->sampleShadingEnable) [[unlikely]]
|
||||||
{
|
{
|
||||||
// Update the sample mask pointer
|
ms2 = *pmss;
|
||||||
ms.pSampleMask = &create_info.state.temp_storage.msaa_sample_mask;
|
pmss = &ms2;
|
||||||
|
|
||||||
|
if (ms2.rasterizationSamples != VK_SAMPLE_COUNT_1_BIT)
|
||||||
|
{
|
||||||
|
// Update the sample mask pointer
|
||||||
|
ms2.pSampleMask = &create_info.state.temp_storage.msaa_sample_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_cfg.video.antialiasing_level == msaa_level::none && ms2.sampleShadingEnable)
|
||||||
|
{
|
||||||
|
// Do not compile with MSAA enabled if multisampling is disabled
|
||||||
|
rsx_log.warning("MSAA is disabled globally but a shader with multi-sampling enabled was submitted for compilation.");
|
||||||
|
ms2.sampleShadingEnable = VK_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rebase pointers from pipeline structure in case it is moved/copied
|
// Rebase pointers from pipeline structure in case it is moved/copied
|
||||||
|
@ -128,9 +153,9 @@ namespace vk
|
||||||
info.pInputAssemblyState = &create_info.state.ia;
|
info.pInputAssemblyState = &create_info.state.ia;
|
||||||
info.pRasterizationState = &create_info.state.rs;
|
info.pRasterizationState = &create_info.state.rs;
|
||||||
info.pColorBlendState = &cs;
|
info.pColorBlendState = &cs;
|
||||||
info.pMultisampleState = &ms;
|
info.pMultisampleState = pmss;
|
||||||
info.pViewportState = &vp;
|
info.pViewportState = &vp;
|
||||||
info.pDepthStencilState = &create_info.state.ds;
|
info.pDepthStencilState = pdss;
|
||||||
info.stageCount = 2;
|
info.stageCount = 2;
|
||||||
info.pStages = shader_stages;
|
info.pStages = shader_stages;
|
||||||
info.pDynamicState = &dynamic_state_info;
|
info.pDynamicState = &dynamic_state_info;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue