From 97d0ff58c8dbe374a1b87e1a72f1f245ed27ed96 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 13 Apr 2022 16:12:53 -0700 Subject: Convert vertex loader position cache to std::array --- Source/Core/VideoCommon/VertexManagerBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp') diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 5fa85b2761..4ffebaadf3 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -558,7 +558,7 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format) { // If this vertex format has per-vertex position matrix IDs, look it up. if (vert_decl.posmtx.enable) - mtxIdx = VertexLoaderManager::position_matrix_index[3 - i]; + mtxIdx = VertexLoaderManager::position_matrix_index_cache[3 - i]; if (vert_decl.position.components == 2) VertexLoaderManager::position_cache[2 - i][2] = 0; -- cgit v1.2.3 From 39b2854b981aadec1576254ad5e4d91dc21c9709 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Thu, 14 Apr 2022 12:01:57 -0700 Subject: VertexLoader: Convert count register to remaining register This more accurately represents what's going on, and also ends at 0 instead of 1, making some indexing operations easier. This also changes it so that position_matrix_index_cache actually starts from index 0 instead of index 1. --- Source/Core/VideoCommon/VertexManagerBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp') diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index 4ffebaadf3..a93a9b34f1 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -558,7 +558,7 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format) { // If this vertex format has per-vertex position matrix IDs, look it up. if (vert_decl.posmtx.enable) - mtxIdx = VertexLoaderManager::position_matrix_index_cache[3 - i]; + mtxIdx = VertexLoaderManager::position_matrix_index_cache[2 - i]; if (vert_decl.position.components == 2) VertexLoaderManager::position_cache[2 - i][2] = 0; -- cgit v1.2.3 From 2a5c77f43ff1d69e78f12f13435a38c5eb2ed854 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Wed, 13 Apr 2022 22:03:34 -0700 Subject: VideoCommon: Handle emboss texgen with only a single normal Fixes a large number of effects in Rogue Squadron 2 and 3. --- Source/Core/VideoCommon/VertexManagerBase.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Source/Core/VideoCommon/VertexManagerBase.cpp') diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index a93a9b34f1..bb23a468ea 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -453,6 +453,7 @@ void VertexManagerBase::Flush() } } + CalculateBinormals(VertexLoaderManager::GetCurrentVertexFormat()); // Calculate ZSlope for zfreeze VertexShaderManager::SetConstants(); if (!bpmem.genMode.zfreeze) @@ -595,6 +596,31 @@ void VertexManagerBase::CalculateZSlope(NativeVertexFormat* format) m_zslope.dirty = true; } +void VertexManagerBase::CalculateBinormals(NativeVertexFormat* format) +{ + const PortableVertexDeclaration vert_decl = format->GetVertexDeclaration(); + + // Only update the binormal/tangent vertex shader constants if the vertex format lacks binormals + // (VertexLoaderManager::binormal_cache gets updated by the vertex loader when binormals are + // present, though) + if (vert_decl.normals[1].enable) + return; + + VertexLoaderManager::tangent_cache[3] = 0; + VertexLoaderManager::binormal_cache[3] = 0; + + if (VertexShaderManager::constants.cached_tangent != VertexLoaderManager::tangent_cache) + { + VertexShaderManager::constants.cached_tangent = VertexLoaderManager::tangent_cache; + VertexShaderManager::dirty = true; + } + if (VertexShaderManager::constants.cached_binormal != VertexLoaderManager::binormal_cache) + { + VertexShaderManager::constants.cached_binormal = VertexLoaderManager::binormal_cache; + VertexShaderManager::dirty = true; + } +} + void VertexManagerBase::UpdatePipelineConfig() { NativeVertexFormat* vertex_format = VertexLoaderManager::GetCurrentVertexFormat(); -- cgit v1.2.3