Skip to content

Commit

Permalink
vk: Additional VK_EXT_provoking_vertex pipeline fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wunkolo committed Oct 10, 2024
1 parent 6b2bc05 commit 0c23685
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/rend/vulkan/oit/oit_drawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,15 @@ bool OITDrawer::Draw(const Texture *fogTexture, const Texture *paletteTexture)
bool firstFrameAfterInit = oitBuffers->isFirstFrameAfterInit();
oitBuffers->OnNewFrame(cmdBuffer);

setFirstProvokingVertex(pvrrc);
if (VulkanContext::Instance()->hasProvokingVertex())
{
// Pipelines are using VK_EXT_provoking_vertex, no need to
// re-order vertices
}
else
{
setFirstProvokingVertex(pvrrc);
}

// Upload vertex and index buffers
UploadMainBuffer(vtxUniforms, fragUniforms);
Expand Down
22 changes: 22 additions & 0 deletions core/rend/vulkan/oit/oit_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,17 @@ void OITPipelineManager::CreateClearPipeline()
0.0f, // depthBiasSlopeFactor
1.0f // lineWidth
);

// Dreamcast uses the last vertex as the provoking vertex, but Vulkan uses the first.
// Utilize VK_EXT_provoking_vertex when available to set the provoking vertex to be the
// last vertex
vk::PipelineRasterizationProvokingVertexStateCreateInfoEXT provokingVertexInfo{};
if (GetContext()->hasProvokingVertex())
{
provokingVertexInfo.provokingVertexMode = vk::ProvokingVertexModeEXT::eLastVertex;
pipelineRasterizationStateCreateInfo.pNext = &provokingVertexInfo;
}

vk::PipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo;

// Depth and stencil
Expand Down Expand Up @@ -522,6 +533,17 @@ void OITPipelineManager::CreateTrModVolPipeline(ModVolMode mode, int cullMode, b
0.0f, // depthBiasSlopeFactor
1.0f // lineWidth
);

// Dreamcast uses the last vertex as the provoking vertex, but Vulkan uses the first.
// Utilize VK_EXT_provoking_vertex when available to set the provoking vertex to be the
// last vertex
vk::PipelineRasterizationProvokingVertexStateCreateInfoEXT provokingVertexInfo{};
if (GetContext()->hasProvokingVertex())
{
provokingVertexInfo.provokingVertexMode = vk::ProvokingVertexModeEXT::eLastVertex;
pipelineRasterizationStateCreateInfo.pNext = &provokingVertexInfo;
}

vk::PipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo;

// Depth and stencil
Expand Down
11 changes: 11 additions & 0 deletions core/rend/vulkan/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ void PipelineManager::CreateDepthPassPipeline(int cullMode, bool naomi2)
0.0f, // depthBiasSlopeFactor
1.0f // lineWidth
);

// Dreamcast uses the last vertex as the provoking vertex, but Vulkan uses the first.
// Utilize VK_EXT_provoking_vertex when available to set the provoking vertex to be the
// last vertex
vk::PipelineRasterizationProvokingVertexStateCreateInfoEXT provokingVertexInfo{};
if (GetContext()->hasProvokingVertex())
{
provokingVertexInfo.provokingVertexMode = vk::ProvokingVertexModeEXT::eLastVertex;
pipelineRasterizationStateCreateInfo.pNext = &provokingVertexInfo;
}

vk::PipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo;

// Depth and stencil
Expand Down

0 comments on commit 0c23685

Please sign in to comment.