BBox: remove now unreachable SW bbox implementation
This commit is contained in:
parent
acd074e291
commit
6b2a1e57e2
|
@ -33,7 +33,6 @@ SWVertexLoader::~SWVertexLoader()
|
||||||
void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
|
void SWVertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType)
|
||||||
{
|
{
|
||||||
m_attributeIndex = attributeIndex;
|
m_attributeIndex = attributeIndex;
|
||||||
m_primitiveType = primitiveType;
|
|
||||||
|
|
||||||
VertexLoaderUID uid(g_main_cp_state.vtx_desc, g_main_cp_state.vtx_attr[m_attributeIndex]);
|
VertexLoaderUID uid(g_main_cp_state.vtx_desc, g_main_cp_state.vtx_attr[m_attributeIndex]);
|
||||||
m_CurrentLoader = m_VertexLoaderMap[uid].get();
|
m_CurrentLoader = m_VertexLoaderMap[uid].get();
|
||||||
|
@ -182,7 +181,7 @@ void SWVertexLoader::LoadVertex()
|
||||||
int converted_vertices = m_CurrentLoader->RunVertices(
|
int converted_vertices = m_CurrentLoader->RunVertices(
|
||||||
DataReader(g_video_buffer_read_ptr, nullptr), // src
|
DataReader(g_video_buffer_read_ptr, nullptr), // src
|
||||||
DataReader(m_LoadedVertices.data(), m_LoadedVertices.data() + m_LoadedVertices.size()), // dst
|
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;
|
g_video_buffer_read_ptr = old + m_CurrentLoader->m_VertexSize;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ class SWVertexLoader
|
||||||
VertexLoaderBase* m_CurrentLoader;
|
VertexLoaderBase* m_CurrentLoader;
|
||||||
|
|
||||||
u8 m_attributeIndex;
|
u8 m_attributeIndex;
|
||||||
u8 m_primitiveType;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SWVertexLoader();
|
SWVertexLoader();
|
||||||
|
|
|
@ -18,127 +18,6 @@ namespace BoundingBox
|
||||||
// External vars
|
// External vars
|
||||||
bool active = false;
|
bool active = false;
|
||||||
u16 coords[4] = { 0x80, 0xA0, 0x80, 0xA0 };
|
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
|
// Save state
|
||||||
void DoState(PointerWrap &p)
|
void DoState(PointerWrap &p)
|
||||||
|
|
|
@ -25,16 +25,6 @@ enum
|
||||||
BOTTOM = 3
|
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
|
// Save state
|
||||||
void DoState(PointerWrap &p);
|
void DoState(PointerWrap &p);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
|
|
||||||
#include "VideoCommon/BoundingBox.h"
|
|
||||||
#include "VideoCommon/DataReader.h"
|
#include "VideoCommon/DataReader.h"
|
||||||
#include "VideoCommon/PixelEngine.h"
|
#include "VideoCommon/PixelEngine.h"
|
||||||
#include "VideoCommon/VertexLoader.h"
|
#include "VideoCommon/VertexLoader.h"
|
||||||
|
@ -24,14 +23,14 @@ u8* g_vertex_manager_write_ptr;
|
||||||
|
|
||||||
static void LOADERDECL PosMtx_ReadDirect_UByte(VertexLoader* loader)
|
static void LOADERDECL PosMtx_ReadDirect_UByte(VertexLoader* loader)
|
||||||
{
|
{
|
||||||
u8 posmtx = BoundingBox::posMtxIdx = DataReadU8() & 0x3f;
|
u32 posmtx = DataReadU8() & 0x3f;
|
||||||
DataWrite<u32>(posmtx);
|
DataWrite<u32>(posmtx);
|
||||||
PRIM_LOG("posmtx: %d, ", posmtx);
|
PRIM_LOG("posmtx: %d, ", posmtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LOADERDECL TexMtx_ReadDirect_UByte(VertexLoader* loader)
|
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]);
|
PRIM_LOG("texmtx%d: %d, ", loader->m_texmtxread, loader->m_curtexmtx[loader->m_texmtxread]);
|
||||||
loader->m_texmtxread++;
|
loader->m_texmtxread++;
|
||||||
|
@ -87,10 +86,6 @@ void VertexLoader::CompileVertexTranslator()
|
||||||
// Reset pipeline
|
// Reset pipeline
|
||||||
m_numPipelineStages = 0;
|
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
|
// Colors
|
||||||
const u64 col[2] = { m_VtxDesc.Color0, m_VtxDesc.Color1 };
|
const u64 col[2] = { m_VtxDesc.Color0, m_VtxDesc.Color1 };
|
||||||
// TextureCoord
|
// 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
|
// indexed position formats may skip a the vertex
|
||||||
if (m_VtxDesc.Position & 2)
|
if (m_VtxDesc.Position & 2)
|
||||||
{
|
{
|
||||||
|
@ -317,7 +308,7 @@ void VertexLoader::WriteCall(TPipelineFunction func)
|
||||||
m_PipelineStages[m_numPipelineStages++] = 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_vertex_manager_write_ptr = dst.GetPointer();
|
||||||
g_video_buffer_read_ptr = src.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_numLoadedVertices += count;
|
||||||
m_skippedVertices = 0;
|
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++)
|
for (int s = 0; s < count; s++)
|
||||||
{
|
{
|
||||||
m_tcIndex = 0;
|
m_tcIndex = 0;
|
||||||
|
|
|
@ -32,7 +32,7 @@ class VertexLoader : public VertexLoaderBase
|
||||||
public:
|
public:
|
||||||
VertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr);
|
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"; }
|
std::string GetName() const override { return "OldLoader"; }
|
||||||
bool IsInitialized() override { return true; } // This vertex loader supports all formats
|
bool IsInitialized() override { return true; } // This vertex loader supports all formats
|
||||||
|
|
||||||
|
|
|
@ -535,7 +535,7 @@ void VertexLoaderARM64::GenerateVertexLoader()
|
||||||
m_native_vtx_decl.stride = m_dst_ofs;
|
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;
|
m_numLoadedVertices += count;
|
||||||
return ((int (*)(u8* src, u8* dst, int count))region)(src.GetPointer(), dst.GetPointer(), count);
|
return ((int (*)(u8* src, u8* dst, int count))region)(src.GetPointer(), dst.GetPointer(), count);
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
std::string GetName() const override { return "VertexLoaderARM64"; }
|
std::string GetName() const override { return "VertexLoaderARM64"; }
|
||||||
bool IsInitialized() override { return true; }
|
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:
|
private:
|
||||||
u32 m_src_ofs = 0;
|
u32 m_src_ofs = 0;
|
||||||
|
|
|
@ -161,13 +161,13 @@ public:
|
||||||
delete b;
|
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_a.resize(count * a->m_native_vtx_decl.stride + 4);
|
||||||
buffer_b.resize(count * b->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_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, primitive);
|
int count_b = b->RunVertices(src, DataReader(buffer_b.data(), buffer_b.data()+buffer_b.size()), count);
|
||||||
|
|
||||||
if (count_a != count_b)
|
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);
|
ERROR_LOG(VIDEO, "The two vertex loaders have loaded a different amount of vertices (a: %d, b: %d).", count_a, count_b);
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
static VertexLoaderBase* CreateVertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr);
|
static VertexLoaderBase* CreateVertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr);
|
||||||
virtual ~VertexLoaderBase() {}
|
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;
|
virtual bool IsInitialized() = 0;
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ int RunVertices(int vtx_attr_group, int primitive, int count, DataReader src, bo
|
||||||
DataReader dst = VertexManager::PrepareForAdditionalData(primitive, count,
|
DataReader dst = VertexManager::PrepareForAdditionalData(primitive, count,
|
||||||
loader->m_native_vtx_decl.stride, cullall);
|
loader->m_native_vtx_decl.stride, cullall);
|
||||||
|
|
||||||
count = loader->RunVertices(src, dst, count, primitive);
|
count = loader->RunVertices(src, dst, count);
|
||||||
|
|
||||||
IndexGenerator::AddIndices(primitive, count);
|
IndexGenerator::AddIndices(primitive, count);
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,7 @@ void VertexLoaderX64::GenerateVertexLoader()
|
||||||
m_native_vtx_decl.stride = m_dst_ofs;
|
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;
|
m_numLoadedVertices += count;
|
||||||
return ((int (*)(u8* src, u8* dst, int count))region)(src.GetPointer(), dst.GetPointer(), count);
|
return ((int (*)(u8* src, u8* dst, int count))region)(src.GetPointer(), dst.GetPointer(), count);
|
||||||
|
|
|
@ -9,7 +9,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
std::string GetName() const override { return "VertexLoaderX64"; }
|
std::string GetName() const override { return "VertexLoaderX64"; }
|
||||||
bool IsInitialized() override { return true; }
|
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:
|
private:
|
||||||
u32 m_src_ofs = 0;
|
u32 m_src_ofs = 0;
|
||||||
|
|
|
@ -83,7 +83,7 @@ protected:
|
||||||
if (expected_count == -1)
|
if (expected_count == -1)
|
||||||
expected_count = count;
|
expected_count = count;
|
||||||
ResetPointers();
|
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);
|
EXPECT_EQ(actual_count, expected_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue