From 6b2a1e57e2482efb46a91401fa22aaf5ef779974 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 6 Apr 2015 11:44:13 +0200 Subject: [PATCH] BBox: remove now unreachable SW bbox implementation --- .../VideoBackends/Software/SWVertexLoader.cpp | 3 +- .../VideoBackends/Software/SWVertexLoader.h | 1 - Source/Core/VideoCommon/BoundingBox.cpp | 121 ------------------ Source/Core/VideoCommon/BoundingBox.h | 10 -- Source/Core/VideoCommon/VertexLoader.cpp | 19 +-- Source/Core/VideoCommon/VertexLoader.h | 2 +- Source/Core/VideoCommon/VertexLoaderARM64.cpp | 2 +- Source/Core/VideoCommon/VertexLoaderARM64.h | 2 +- Source/Core/VideoCommon/VertexLoaderBase.cpp | 6 +- Source/Core/VideoCommon/VertexLoaderBase.h | 2 +- .../Core/VideoCommon/VertexLoaderManager.cpp | 2 +- Source/Core/VideoCommon/VertexLoaderX64.cpp | 2 +- Source/Core/VideoCommon/VertexLoaderX64.h | 2 +- .../VideoCommon/VertexLoaderTest.cpp | 2 +- 14 files changed, 15 insertions(+), 161 deletions(-) diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp index 859cf593b4..31c6eebb17 100644 --- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp +++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp @@ -33,7 +33,6 @@ SWVertexLoader::~SWVertexLoader() void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType) { m_attributeIndex = attributeIndex; - m_primitiveType = primitiveType; VertexLoaderUID uid(g_main_cp_state.vtx_desc, g_main_cp_state.vtx_attr[m_attributeIndex]); m_CurrentLoader = m_VertexLoaderMap[uid].get(); @@ -182,7 +181,7 @@ void SWVertexLoader::LoadVertex() int converted_vertices = m_CurrentLoader->RunVertices( DataReader(g_video_buffer_read_ptr, nullptr), // src DataReader(m_LoadedVertices.data(), m_LoadedVertices.data() + m_LoadedVertices.size()), // dst - 1, m_primitiveType + 1 // vertices ); g_video_buffer_read_ptr = old + m_CurrentLoader->m_VertexSize; diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.h b/Source/Core/VideoBackends/Software/SWVertexLoader.h index cfdbd9efd5..ff6c4cc18c 100644 --- a/Source/Core/VideoBackends/Software/SWVertexLoader.h +++ b/Source/Core/VideoBackends/Software/SWVertexLoader.h @@ -36,7 +36,6 @@ class SWVertexLoader VertexLoaderBase* m_CurrentLoader; u8 m_attributeIndex; - u8 m_primitiveType; public: SWVertexLoader(); diff --git a/Source/Core/VideoCommon/BoundingBox.cpp b/Source/Core/VideoCommon/BoundingBox.cpp index 9ea0fa5689..795302978b 100644 --- a/Source/Core/VideoCommon/BoundingBox.cpp +++ b/Source/Core/VideoCommon/BoundingBox.cpp @@ -18,127 +18,6 @@ namespace BoundingBox // External vars bool active = false; u16 coords[4] = { 0x80, 0xA0, 0x80, 0xA0 }; -u8 posMtxIdx; -u8 texMtxIdx[8]; - - -// Internal vars -static SetupUnit vtxUnit; -static VAT myVat; -static u8 * bufferPos; -static TVtxDesc vertexDesc; -static PortableVertexDeclaration vertexDecl; - -// Gets the pointer to the current buffer position -void LOADERDECL SetVertexBufferPosition(VertexLoader* loader) -{ - bufferPos = g_vertex_manager_write_ptr; -} - -// Prepares the bounding box for new primitive data -void Prepare(const VAT & vat, int primitive, const TVtxDesc & vtxDesc, const PortableVertexDeclaration & vtxDecl) -{ - if (!active) - return; - - myVat = vat; - vertexDesc = vtxDesc; - vertexDecl = vtxDecl; - - vtxUnit.Init(primitive); - - // Initialize the SW renderer - static bool SWinit = false; - - if (!SWinit) - { - Clipper::Init(); - Rasterizer::Init(); - SWinit = true; - } - - // Update SW renderer values - Clipper::SetViewOffset(); - Rasterizer::SetScissor(); - - for (u8 i = 0; i < 4; ++i) - { - Rasterizer::SetTevReg(i, 0, true, (s16)PixelShaderManager::constants.kcolors[i][0]); - Rasterizer::SetTevReg(i, 1, true, (s16)PixelShaderManager::constants.kcolors[i][1]); - Rasterizer::SetTevReg(i, 2, true, (s16)PixelShaderManager::constants.kcolors[i][2]); - Rasterizer::SetTevReg(i, 3, true, (s16)PixelShaderManager::constants.kcolors[i][3]); - - Rasterizer::SetTevReg(i, 0, false, (s16)PixelShaderManager::constants.colors[i][0]); - Rasterizer::SetTevReg(i, 1, false, (s16)PixelShaderManager::constants.colors[i][1]); - Rasterizer::SetTevReg(i, 2, false, (s16)PixelShaderManager::constants.colors[i][2]); - Rasterizer::SetTevReg(i, 3, false, (s16)PixelShaderManager::constants.colors[i][3]); - } -} - -// Updates the bounding box -void LOADERDECL Update(VertexLoader* loader) -{ - if (!active) - return; - - // Grab vertex input data and transform to output vertex - InputVertexData myVertex; - OutputVertexData * outVertex = vtxUnit.GetVertex(); - - // Feed vertex position and matrix - myVertex.position = Vec3((const float *)bufferPos); - myVertex.posMtx = vertexDesc.PosMatIdx ? posMtxIdx : g_main_cp_state.matrix_index_a.PosNormalMtxIdx; - - // Transform position - TransformUnit::TransformPosition(&myVertex, outVertex); - - if (g_main_cp_state.vtx_desc.Normal != NOT_PRESENT) - { - // Feed normal input data and transform - memcpy((u8 *)myVertex.normal, bufferPos + vertexDecl.normals[0].offset, sizeof(float) * 3 * ((myVat.g0.NormalElements) ? 3 : 1)); - - TransformUnit::TransformNormal(&myVertex, myVat.g0.NormalElements, outVertex); - } - - // Feed color input data - for (int i = 0; i < 2; ++i) - { - if (vertexDecl.colors[i].enable) - { - u32 color; - memcpy((u8 *)&color, bufferPos + vertexDecl.colors[i].offset, sizeof(u32)); - *(u32*)myVertex.color[i] = Common::swap32(color); - } - } - - // Transform color - TransformUnit::TransformColor(&myVertex, outVertex); - - // Feed texture matrices - int idx = 0; - - myVertex.texMtx[0] = (vertexDesc.Tex0MatIdx) ? texMtxIdx[idx++] : g_main_cp_state.matrix_index_a.Tex0MtxIdx; - myVertex.texMtx[1] = (vertexDesc.Tex1MatIdx) ? texMtxIdx[idx++] : g_main_cp_state.matrix_index_a.Tex1MtxIdx; - myVertex.texMtx[2] = (vertexDesc.Tex2MatIdx) ? texMtxIdx[idx++] : g_main_cp_state.matrix_index_a.Tex2MtxIdx; - myVertex.texMtx[3] = (vertexDesc.Tex3MatIdx) ? texMtxIdx[idx++] : g_main_cp_state.matrix_index_a.Tex3MtxIdx; - myVertex.texMtx[4] = (vertexDesc.Tex4MatIdx) ? texMtxIdx[idx++] : g_main_cp_state.matrix_index_b.Tex4MtxIdx; - myVertex.texMtx[5] = (vertexDesc.Tex5MatIdx) ? texMtxIdx[idx++] : g_main_cp_state.matrix_index_b.Tex5MtxIdx; - myVertex.texMtx[6] = (vertexDesc.Tex6MatIdx) ? texMtxIdx[idx++] : g_main_cp_state.matrix_index_b.Tex6MtxIdx; - myVertex.texMtx[7] = (vertexDesc.Tex7MatIdx) ? texMtxIdx[idx++] : g_main_cp_state.matrix_index_b.Tex7MtxIdx; - - // Feed texture coordinate data - for (int i = 0; i < 8; ++i) - { - if (vertexDecl.texcoords[i].enable) - memcpy((u8 *)&myVertex.texCoords[i], bufferPos + vertexDecl.texcoords[i].offset, sizeof(float) * 2); - } - - // Transform texture coordinate - TransformUnit::TransformTexCoord(&myVertex, outVertex, false); - - // Render the vertex in SW to calculate bbox - vtxUnit.SetupVertex(); -} // Save state void DoState(PointerWrap &p) diff --git a/Source/Core/VideoCommon/BoundingBox.h b/Source/Core/VideoCommon/BoundingBox.h index afff0e3e72..fd1faee30c 100644 --- a/Source/Core/VideoCommon/BoundingBox.h +++ b/Source/Core/VideoCommon/BoundingBox.h @@ -25,16 +25,6 @@ enum BOTTOM = 3 }; -// Current position matrix index -extern u8 posMtxIdx; - -// Texture matrix indexes -extern u8 texMtxIdx[8]; - -void LOADERDECL SetVertexBufferPosition(VertexLoader* loader); -void LOADERDECL Update(VertexLoader* loader); -void Prepare(const VAT & vat, int primitive, const TVtxDesc & vtxDesc, const PortableVertexDeclaration & vtxDecl); - // Save state void DoState(PointerWrap &p); diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index 8e5c73b6a0..d7dad1c95a 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -7,7 +7,6 @@ #include "Core/Host.h" -#include "VideoCommon/BoundingBox.h" #include "VideoCommon/DataReader.h" #include "VideoCommon/PixelEngine.h" #include "VideoCommon/VertexLoader.h" @@ -24,14 +23,14 @@ u8* g_vertex_manager_write_ptr; static void LOADERDECL PosMtx_ReadDirect_UByte(VertexLoader* loader) { - u8 posmtx = BoundingBox::posMtxIdx = DataReadU8() & 0x3f; + u32 posmtx = DataReadU8() & 0x3f; DataWrite(posmtx); PRIM_LOG("posmtx: %d, ", posmtx); } static void LOADERDECL TexMtx_ReadDirect_UByte(VertexLoader* loader) { - BoundingBox::texMtxIdx[loader->m_texmtxread] = loader->m_curtexmtx[loader->m_texmtxread] = DataReadU8() & 0x3f; + loader->m_curtexmtx[loader->m_texmtxread] = DataReadU8() & 0x3f; PRIM_LOG("texmtx%d: %d, ", loader->m_texmtxread, loader->m_curtexmtx[loader->m_texmtxread]); loader->m_texmtxread++; @@ -87,10 +86,6 @@ void VertexLoader::CompileVertexTranslator() // Reset pipeline m_numPipelineStages = 0; - // Get the pointer to this vertex's buffer data for the bounding box - if (!g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable) - WriteCall(BoundingBox::SetVertexBufferPosition); - // Colors const u64 col[2] = { m_VtxDesc.Color0, m_VtxDesc.Color1 }; // TextureCoord @@ -298,10 +293,6 @@ void VertexLoader::CompileVertexTranslator() } } - // Update the bounding box - if (!g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable) - WriteCall(BoundingBox::Update); - // indexed position formats may skip a the vertex if (m_VtxDesc.Position & 2) { @@ -317,7 +308,7 @@ void VertexLoader::WriteCall(TPipelineFunction func) m_PipelineStages[m_numPipelineStages++] = func; } -int VertexLoader::RunVertices(DataReader src, DataReader dst, int count, int primitive) +int VertexLoader::RunVertices(DataReader src, DataReader dst, int count) { g_vertex_manager_write_ptr = dst.GetPointer(); g_video_buffer_read_ptr = src.GetPointer(); @@ -325,10 +316,6 @@ int VertexLoader::RunVertices(DataReader src, DataReader dst, int count, int pri m_numLoadedVertices += count; m_skippedVertices = 0; - // Prepare bounding box - if (!g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable) - BoundingBox::Prepare(m_vat, primitive, m_VtxDesc, m_native_vtx_decl); - for (int s = 0; s < count; s++) { m_tcIndex = 0; diff --git a/Source/Core/VideoCommon/VertexLoader.h b/Source/Core/VideoCommon/VertexLoader.h index 3bae14a2d0..4e6e19f727 100644 --- a/Source/Core/VideoCommon/VertexLoader.h +++ b/Source/Core/VideoCommon/VertexLoader.h @@ -32,7 +32,7 @@ class VertexLoader : public VertexLoaderBase public: VertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr); - int RunVertices(DataReader src, DataReader dst, int count, int primitive) override; + int RunVertices(DataReader src, DataReader dst, int count) override; std::string GetName() const override { return "OldLoader"; } bool IsInitialized() override { return true; } // This vertex loader supports all formats diff --git a/Source/Core/VideoCommon/VertexLoaderARM64.cpp b/Source/Core/VideoCommon/VertexLoaderARM64.cpp index 397a179e9e..11bfd4b495 100644 --- a/Source/Core/VideoCommon/VertexLoaderARM64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderARM64.cpp @@ -535,7 +535,7 @@ void VertexLoaderARM64::GenerateVertexLoader() m_native_vtx_decl.stride = m_dst_ofs; } -int VertexLoaderARM64::RunVertices(DataReader src, DataReader dst, int count, int primitive) +int VertexLoaderARM64::RunVertices(DataReader src, DataReader dst, int count) { m_numLoadedVertices += count; return ((int (*)(u8* src, u8* dst, int count))region)(src.GetPointer(), dst.GetPointer(), count); diff --git a/Source/Core/VideoCommon/VertexLoaderARM64.h b/Source/Core/VideoCommon/VertexLoaderARM64.h index 4a6a389201..b67ac78cf2 100644 --- a/Source/Core/VideoCommon/VertexLoaderARM64.h +++ b/Source/Core/VideoCommon/VertexLoaderARM64.h @@ -14,7 +14,7 @@ public: protected: std::string GetName() const override { return "VertexLoaderARM64"; } bool IsInitialized() override { return true; } - int RunVertices(DataReader src, DataReader dst, int count, int primitive) override; + int RunVertices(DataReader src, DataReader dst, int count) override; private: u32 m_src_ofs = 0; diff --git a/Source/Core/VideoCommon/VertexLoaderBase.cpp b/Source/Core/VideoCommon/VertexLoaderBase.cpp index 9089ee67af..94ba4f2728 100644 --- a/Source/Core/VideoCommon/VertexLoaderBase.cpp +++ b/Source/Core/VideoCommon/VertexLoaderBase.cpp @@ -161,13 +161,13 @@ public: delete b; } - int RunVertices(DataReader src, DataReader dst, int count, int primitive) override + int RunVertices(DataReader src, DataReader dst, int count) override { buffer_a.resize(count * a->m_native_vtx_decl.stride + 4); buffer_b.resize(count * b->m_native_vtx_decl.stride + 4); - int count_a = a->RunVertices(src, DataReader(buffer_a.data(), buffer_a.data()+buffer_a.size()), count, primitive); - int count_b = b->RunVertices(src, DataReader(buffer_b.data(), buffer_b.data()+buffer_b.size()), count, primitive); + int count_a = a->RunVertices(src, DataReader(buffer_a.data(), buffer_a.data()+buffer_a.size()), count); + int count_b = b->RunVertices(src, DataReader(buffer_b.data(), buffer_b.data()+buffer_b.size()), count); if (count_a != count_b) ERROR_LOG(VIDEO, "The two vertex loaders have loaded a different amount of vertices (a: %d, b: %d).", count_a, count_b); diff --git a/Source/Core/VideoCommon/VertexLoaderBase.h b/Source/Core/VideoCommon/VertexLoaderBase.h index fc3737ae69..9b8391a52f 100644 --- a/Source/Core/VideoCommon/VertexLoaderBase.h +++ b/Source/Core/VideoCommon/VertexLoaderBase.h @@ -74,7 +74,7 @@ public: static VertexLoaderBase* CreateVertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr); virtual ~VertexLoaderBase() {} - virtual int RunVertices(DataReader src, DataReader dst, int count, int primitive) = 0; + virtual int RunVertices(DataReader src, DataReader dst, int count) = 0; virtual bool IsInitialized() = 0; diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index 74dad016cb..199197646a 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -165,7 +165,7 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo DataReader dst = VertexManager::PrepareForAdditionalData(primitive, count, loader->m_native_vtx_decl.stride, cullall); - count = loader->RunVertices(src, dst, count, primitive); + count = loader->RunVertices(src, dst, count); IndexGenerator::AddIndices(primitive, count); diff --git a/Source/Core/VideoCommon/VertexLoaderX64.cpp b/Source/Core/VideoCommon/VertexLoaderX64.cpp index 1754a32fb4..6aa85be2fa 100644 --- a/Source/Core/VideoCommon/VertexLoaderX64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderX64.cpp @@ -508,7 +508,7 @@ void VertexLoaderX64::GenerateVertexLoader() m_native_vtx_decl.stride = m_dst_ofs; } -int VertexLoaderX64::RunVertices(DataReader src, DataReader dst, int count, int primitive) +int VertexLoaderX64::RunVertices(DataReader src, DataReader dst, int count) { m_numLoadedVertices += count; return ((int (*)(u8* src, u8* dst, int count))region)(src.GetPointer(), dst.GetPointer(), count); diff --git a/Source/Core/VideoCommon/VertexLoaderX64.h b/Source/Core/VideoCommon/VertexLoaderX64.h index 53b7b58d9e..9f04f7e094 100644 --- a/Source/Core/VideoCommon/VertexLoaderX64.h +++ b/Source/Core/VideoCommon/VertexLoaderX64.h @@ -9,7 +9,7 @@ public: protected: std::string GetName() const override { return "VertexLoaderX64"; } bool IsInitialized() override { return true; } - int RunVertices(DataReader src, DataReader dst, int count, int primitive) override; + int RunVertices(DataReader src, DataReader dst, int count) override; private: u32 m_src_ofs = 0; diff --git a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp index 1c6579b795..0fe5db1b55 100644 --- a/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp +++ b/Source/UnitTests/VideoCommon/VertexLoaderTest.cpp @@ -83,7 +83,7 @@ protected: if (expected_count == -1) expected_count = count; ResetPointers(); - int actual_count = m_loader->RunVertices(m_src, m_dst, count, GX_DRAW_POINTS); + int actual_count = m_loader->RunVertices(m_src, m_dst, count); EXPECT_EQ(actual_count, expected_count); }