diff options
| author | JMC47 <JMC4789@gmail.com> | 2022-10-23 01:49:26 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-23 01:49:26 -0400 |
| commit | cdcbe51b2a0c4dd78ab8d1d3ad38d8ab2947405b (patch) | |
| tree | 5d29d92713f591f003b7d83da63b427b3c847ea1 /Source/Core/VideoCommon/ShaderCache.cpp | |
| parent | 06bd0a908692f61702a483c51c93fadb2ed7eefc (diff) | |
| parent | 1e9b6f88e4c13722a2a47aeb0d54df95c3a07c69 (diff) | |
Merge pull request #10890 from tellowkrinkle/VertexLineExpand
VideoCommon: Add vertex shader point/line expansion
Diffstat (limited to 'Source/Core/VideoCommon/ShaderCache.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/ShaderCache.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index f281024f22..59ae917686 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -10,6 +10,7 @@ #include "Common/MsgHandler.h" #include "Core/ConfigManager.h" +#include "VideoCommon/ConstantManager.h" #include "VideoCommon/DriverDetails.h" #include "VideoCommon/FramebufferManager.h" #include "VideoCommon/FramebufferShaderGen.h" @@ -695,6 +696,35 @@ static GXPipelineUid ApplyDriverBugs(const GXPipelineUid& in) ps->ztest = EmulatedZ::EarlyWithZComplocHack; } + if (g_ActiveConfig.UseVSForLinePointExpand() && + (out.rasterization_state.primitive == PrimitiveType::Points || + out.rasterization_state.primitive == PrimitiveType::Lines)) + { + // All primitives are expanded to triangles in the vertex shader + vertex_shader_uid_data* vs = out.vs_uid.GetUidData(); + const PortableVertexDeclaration& decl = out.vertex_format->GetVertexDeclaration(); + vs->position_has_3_elems = decl.position.components >= 3; + vs->texcoord_elem_count = 0; + for (int i = 0; i < 8; i++) + { + if (decl.texcoords[i].enable) + { + ASSERT(decl.texcoords[i].components <= 3); + vs->texcoord_elem_count |= decl.texcoords[i].components << (i * 2); + } + } + out.vertex_format = nullptr; + if (out.rasterization_state.primitive == PrimitiveType::Points) + vs->vs_expand = VSExpand::Point; + else + vs->vs_expand = VSExpand::Line; + PrimitiveType prim = g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? + PrimitiveType::TriangleStrip : + PrimitiveType::Triangles; + out.rasterization_state.primitive = prim; + out.gs_uid.GetUidData()->primitive_type = static_cast<u32>(prim); + } + return out; } @@ -760,6 +790,17 @@ static GXUberPipelineUid ApplyDriverBugs(const GXUberPipelineUid& in) out.blending_state.usedualsrc = false; out.ps_uid.GetUidData()->no_dual_src = true; } + + if (g_ActiveConfig.UseVSForLinePointExpand()) + { + // All primitives are expanded to triangles in the vertex shader + PrimitiveType prim = g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? + PrimitiveType::TriangleStrip : + PrimitiveType::Triangles; + out.rasterization_state.primitive = prim; + out.gs_uid.GetUidData()->primitive_type = static_cast<u32>(prim); + } + return out; } |
