summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/VertexManagerBase.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2022-10-23 01:49:26 -0400
committerGitHub <noreply@github.com>2022-10-23 01:49:26 -0400
commitcdcbe51b2a0c4dd78ab8d1d3ad38d8ab2947405b (patch)
tree5d29d92713f591f003b7d83da63b427b3c847ea1 /Source/Core/VideoCommon/VertexManagerBase.cpp
parent06bd0a908692f61702a483c51c93fadb2ed7eefc (diff)
parent1e9b6f88e4c13722a2a47aeb0d54df95c3a07c69 (diff)
Merge pull request #10890 from tellowkrinkle/VertexLineExpand
VideoCommon: Add vertex shader point/line expansion
Diffstat (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp')
-rw-r--r--Source/Core/VideoCommon/VertexManagerBase.cpp93
1 files changed, 70 insertions, 23 deletions
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp
index 41b3968b2b..273f67c746 100644
--- a/Source/Core/VideoCommon/VertexManagerBase.cpp
+++ b/Source/Core/VideoCommon/VertexManagerBase.cpp
@@ -140,12 +140,12 @@ DataReader VertexManagerBase::PrepareForAdditionalData(OpcodeDecoder::Primitive
// Check for size in buffer, if the buffer gets full, call Flush()
if (!m_is_flushed &&
- (count > m_index_generator.GetRemainingIndices() || count > GetRemainingIndices(primitive) ||
- needed_vertex_bytes > GetRemainingSize()))
+ (count > m_index_generator.GetRemainingIndices(primitive) ||
+ count > GetRemainingIndices(primitive) || needed_vertex_bytes > GetRemainingSize()))
{
Flush();
- if (count > m_index_generator.GetRemainingIndices())
+ if (count > m_index_generator.GetRemainingIndices(primitive))
{
ERROR_LOG_FMT(VIDEO, "Too little remaining index values. Use 32-bit or reset them on flush.");
}
@@ -193,7 +193,55 @@ u32 VertexManagerBase::GetRemainingIndices(OpcodeDecoder::Primitive primitive) c
{
const u32 index_len = MAXIBUFFERSIZE - m_index_generator.GetIndexLen();
- if (g_Config.backend_info.bSupportsPrimitiveRestart)
+ if (primitive >= Primitive::GX_DRAW_LINES)
+ {
+ if (g_Config.UseVSForLinePointExpand())
+ {
+ if (g_Config.backend_info.bSupportsPrimitiveRestart)
+ {
+ switch (primitive)
+ {
+ case Primitive::GX_DRAW_LINES:
+ return index_len / 5 * 2;
+ case Primitive::GX_DRAW_LINE_STRIP:
+ return index_len / 5 + 1;
+ case Primitive::GX_DRAW_POINTS:
+ return index_len / 5;
+ default:
+ return 0;
+ }
+ }
+ else
+ {
+ switch (primitive)
+ {
+ case Primitive::GX_DRAW_LINES:
+ return index_len / 6 * 2;
+ case Primitive::GX_DRAW_LINE_STRIP:
+ return index_len / 6 + 1;
+ case Primitive::GX_DRAW_POINTS:
+ return index_len / 6;
+ default:
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ switch (primitive)
+ {
+ case Primitive::GX_DRAW_LINES:
+ return index_len;
+ case Primitive::GX_DRAW_LINE_STRIP:
+ return index_len / 2 + 1;
+ case Primitive::GX_DRAW_POINTS:
+ return index_len;
+ default:
+ return 0;
+ }
+ }
+ }
+ else if (g_Config.backend_info.bSupportsPrimitiveRestart)
{
switch (primitive)
{
@@ -206,15 +254,6 @@ u32 VertexManagerBase::GetRemainingIndices(OpcodeDecoder::Primitive primitive) c
return index_len / 1 - 1;
case Primitive::GX_DRAW_TRIANGLE_FAN:
return index_len / 6 * 4 + 1;
-
- case Primitive::GX_DRAW_LINES:
- return index_len;
- case Primitive::GX_DRAW_LINE_STRIP:
- return index_len / 2 + 1;
-
- case Primitive::GX_DRAW_POINTS:
- return index_len;
-
default:
return 0;
}
@@ -232,15 +271,6 @@ u32 VertexManagerBase::GetRemainingIndices(OpcodeDecoder::Primitive primitive) c
return index_len / 3 + 2;
case Primitive::GX_DRAW_TRIANGLE_FAN:
return index_len / 3 + 2;
-
- case Primitive::GX_DRAW_LINES:
- return index_len;
- case Primitive::GX_DRAW_LINE_STRIP:
- return index_len / 2 + 1;
-
- case Primitive::GX_DRAW_POINTS:
- return index_len;
-
default:
return 0;
}
@@ -511,13 +541,24 @@ void VertexManagerBase::Flush()
VertexLoaderManager::GetCurrentVertexFormat()->GetVertexStride(), num_indices,
&base_vertex, &base_index);
+ if (g_ActiveConfig.backend_info.api_type != APIType::D3D &&
+ g_ActiveConfig.UseVSForLinePointExpand() &&
+ (m_current_primitive_type == PrimitiveType::Points ||
+ m_current_primitive_type == PrimitiveType::Lines))
+ {
+ // VS point/line expansion puts the vertex id at gl_VertexID << 2
+ // That means the base vertex has to be adjusted to match
+ // (The shader adds this after shifting right on D3D, so no need to do this)
+ base_vertex <<= 2;
+ }
+
// Texture loading can cause palettes to be applied (-> uniforms -> draws).
// Palette application does not use vertices, only a full-screen quad, so this is okay.
// Same with GPU texture decoding, which uses compute shaders.
g_texture_cache->BindTextures(used_textures);
// Now we can upload uniforms, as nothing else will override them.
- GeometryShaderManager::SetConstants();
+ GeometryShaderManager::SetConstants(m_current_primitive_type);
PixelShaderManager::SetConstants();
UploadUniforms();
@@ -785,6 +826,12 @@ void VertexManagerBase::UpdatePipelineObject()
}
}
+void VertexManagerBase::OnConfigChange()
+{
+ // Reload index generator function tables in case VS expand config changed
+ m_index_generator.Init();
+}
+
void VertexManagerBase::OnDraw()
{
m_draw_counter++;