diff options
| author | TellowKrinkle <tellowkrinkle@gmail.com> | 2022-07-23 00:47:04 -0500 |
|---|---|---|
| committer | TellowKrinkle <tellowkrinkle@gmail.com> | 2022-10-22 20:13:24 -0500 |
| commit | 68f49df0f8a845eecd1e65c4d75dfbee3bdc989e (patch) | |
| tree | 95fd1e84279cba083fa8e776ba439b59ad7503a7 /Source/Core/VideoCommon/VertexManagerBase.cpp | |
| parent | 804e42150e03532e63ecc5a7f6f6eed751a132af (diff) | |
VideoCommon: Add vertex shader point and line expansion
Diffstat (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexManagerBase.cpp | 87 |
1 files changed, 64 insertions, 23 deletions
diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 41b3968b2b..f8e4970a51 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(); |
