Merge pull request #2274 from degasus/disable_bbox

Disable bbox
This commit is contained in:
Ryan Houdek 2015-05-25 08:46:12 -04:00
commit 69963dc4b0
28 changed files with 47 additions and 175 deletions

View File

@ -19,4 +19,5 @@ EmulationIssues = Needs Efb to Ram for BBox (proper graphics).
[Video_Hacks]
EFBToTextureEnable = False
BBoxEnable = True

View File

@ -17,3 +17,5 @@ EmulationIssues =
[ActionReplay]
# Add action replay cheats here.
[Video_Hacks]
BBoxEnable = True

View File

@ -17,3 +17,5 @@ EmulationIssues =
[ActionReplay]
# Add action replay cheats here.
[Video_Hacks]
BBoxEnable = True

View File

@ -25,3 +25,6 @@ PH_SZFar = 0
PH_ExtraParam = 0
PH_ZNear =
PH_ZFar =
[Video_Hacks]
BBoxEnable = True

View File

@ -23,3 +23,5 @@ ProjectionHack = 0
[Video_Hacks]
EFBToTextureEnable = False
[Video_Hacks]
BBoxEnable = True

View File

@ -12,7 +12,6 @@
#include "Common/FileUtil.h"
#include "Common/JitRegister.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
#ifdef _WIN32
#include <process.h>
@ -38,13 +37,12 @@ static File::IOFile s_perf_map_file;
namespace JitRegister
{
void Init()
void Init(const std::string& perf_dir)
{
#if defined USE_OPROFILE && USE_OPROFILE
s_agent = op_open_agent();
#endif
const std::string& perf_dir = SConfig::GetInstance().m_LocalCoreStartupParameter.m_perfDir;
if (!perf_dir.empty())
{
std::string filename = StringFromFormat("%s/perf-%d.map", perf_dir.data(), getpid());

View File

@ -9,7 +9,7 @@
namespace JitRegister
{
void Init();
void Init(const std::string& perf_dir);
void Shutdown();
void RegisterV(const void* base_address, u32 code_size,
const char* format, va_list args);

View File

@ -36,7 +36,7 @@ using namespace Gen;
return;
}
JitRegister::Init();
JitRegister::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_perfDir);
iCache.fill(JIT_ICACHE_INVALID_BYTE);
iCacheEx.fill(JIT_ICACHE_INVALID_BYTE);

View File

@ -110,6 +110,7 @@ static wxString aa_desc = _("Reduces the amount of aliasing caused by rasterizin
static wxString scaled_efb_copy_desc = _("Greatly increases quality of textures generated using render-to-texture effects.\nRaising the internal resolution will improve the effect of this setting.\nSlightly increases GPU load and causes relatively few graphical issues.\n\nIf unsure, leave this checked.");
static wxString pixel_lighting_desc = _("Calculates lighting of 3D objects per-pixel rather than per-vertex, smoothing out the appearance of lit polygons and making individual triangles less noticeable.\nRarely causes slowdowns or graphical issues.\n\nIf unsure, leave this unchecked.");
static wxString fast_depth_calc_desc = _("Use a less accurate algorithm to calculate depth values.\nCauses issues in a few games, but can give a decent speedup depending on the game and/or your GPU.\n\nIf unsure, leave this checked.");
static wxString disable_bbox_desc = _("Disable the bounding box emulation.\nThis may improve the GPU performance a lot, but some games will break.\n\nIf unsure, leave this checked.");
static wxString force_filtering_desc = _("Filter all textures, including any that the game explicitly set as unfiltered.\nMay improve quality of certain textures in some games, but will cause issues in others.\nOn Direct3D, setting Anisotropic Filtering above 1x will also have the same effect as enabling this option.\n\nIf unsure, leave this unchecked.");
static wxString borderless_fullscreen_desc = _("Implement fullscreen mode with a borderless window spanning the whole screen instead of using exclusive mode.\nAllows for faster transitions between fullscreen and windowed mode, but slightly increases input latency, makes movement less smooth and slightly decreases performance.\nExclusive mode is required for Nvidia 3D Vision to work in the Direct3D backend.\n\nIf unsure, leave this unchecked.");
static wxString internal_res_desc = _("Specifies the resolution used to render at. A high resolution greatly improves visual quality, but also greatly increases GPU load and can cause issues in certain games.\n\"Multiple of 640x528\" will result in a size slightly larger than \"Window Size\" but yield fewer issues. Generally speaking, the lower the internal resolution is, the better your performance will be.\n\nIf unsure, select 640x528.");
@ -517,6 +518,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
wxGridSizer* const szr_other = new wxGridSizer(2, 5, 5);
szr_other->Add(CreateCheckBox(page_hacks, _("Disable Destination Alpha"), disable_dstalpha_desc, vconfig.bDstAlphaPass));
szr_other->Add(CreateCheckBox(page_hacks, _("Fast Depth Calculation"), fast_depth_calc_desc, vconfig.bFastDepthCalc));
szr_other->Add(CreateCheckBox(page_hacks, _("Disable Bounding Box"), disable_bbox_desc, vconfig.bBBoxEnable, true));
wxStaticBoxSizer* const group_other = new wxStaticBoxSizer(wxVERTICAL, page_hacks, _("Other"));
group_other->Add(szr_other, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);

View File

@ -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;

View File

@ -36,7 +36,6 @@ class SWVertexLoader
VertexLoaderBase* m_CurrentLoader;
u8 m_attributeIndex;
u8 m_primitiveType;
public:
SWVertexLoader();

View File

@ -379,16 +379,11 @@ static void BPWritten(const BPCmd& bp)
u8 offset = bp.address & 2;
BoundingBox::active = true;
if (g_ActiveConfig.backend_info.bSupportsBBox)
if (g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable)
{
g_renderer->BBoxWrite(offset, bp.newvalue & 0x3ff);
g_renderer->BBoxWrite(offset + 1, bp.newvalue >> 10);
}
else
{
BoundingBox::coords[offset] = bp.newvalue & 0x3ff;
BoundingBox::coords[offset + 1] = bp.newvalue >> 10;
}
}
return;
case BPMEM_TEXINVALIDATE:

View File

@ -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)

View File

@ -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);

View File

@ -157,7 +157,16 @@ u32 VideoBackendHardware::Video_GetQueryResult(PerfQueryType type)
u16 VideoBackendHardware::Video_GetBoundingBox(int index)
{
if (!g_ActiveConfig.backend_info.bSupportsBBox)
return BoundingBox::coords[index];
return 0;
if (!g_ActiveConfig.bBBoxEnable)
{
static bool warn_once = true;
if (warn_once)
ERROR_LOG(VIDEO, "BBox shall be used but it is disabled. Please use a gameini to enable it for this game.");
warn_once = false;
return 0;
}
SyncGPU(SYNC_GPU_BBOX);

View File

@ -277,7 +277,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
out.Write("};\n");
}
if (g_ActiveConfig.backend_info.bSupportsBBox)
if (g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable)
{
if (ApiType == API_OPENGL)
{
@ -641,7 +641,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T
out.Write("\tocol0.a = float(" I_ALPHA".a) / 255.0;\n");
}
if (g_ActiveConfig.backend_info.bSupportsBBox && BoundingBox::active)
if (g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable && BoundingBox::active)
{
uid_data->bounding_box = true;
const char* atomic_op = ApiType == API_OPENGL ? "atomic" : "Interlocked";

View File

@ -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<u32>(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)
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)
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)
BoundingBox::Prepare(m_vat, primitive, m_VtxDesc, m_native_vtx_decl);
for (int s = 0; s < count; s++)
{
m_tcIndex = 0;

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -512,7 +512,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);

View File

@ -13,7 +13,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;

View File

@ -97,6 +97,7 @@ void VideoConfig::Load(const std::string& ini_file)
IniFile::Section* hacks = iniFile.GetOrCreateSection("Hacks");
hacks->Get("EFBAccessEnable", &bEFBAccessEnable, true);
hacks->Get("BBoxEnable", &bBBoxEnable, false);
hacks->Get("EFBToTextureEnable", &bSkipEFBCopyToRam, true);
hacks->Get("EFBScaledCopy", &bCopyEFBScaled, true);
hacks->Get("EFBEmulateFormatChanges", &bEFBEmulateFormatChanges, false);
@ -196,6 +197,7 @@ void VideoConfig::GameIniLoad()
CHECK_SETTING("Video_Stereoscopy", "StereoConvergenceMinimum", iStereoConvergenceMinimum);
CHECK_SETTING("Video_Hacks", "EFBAccessEnable", bEFBAccessEnable);
CHECK_SETTING("Video_Hacks", "BBoxEnable", bBBoxEnable);
CHECK_SETTING("Video_Hacks", "EFBToTextureEnable", bSkipEFBCopyToRam);
CHECK_SETTING("Video_Hacks", "EFBScaledCopy", bCopyEFBScaled);
CHECK_SETTING("Video_Hacks", "EFBEmulateFormatChanges", bEFBEmulateFormatChanges);
@ -283,6 +285,7 @@ void VideoConfig::Save(const std::string& ini_file)
IniFile::Section* hacks = iniFile.GetOrCreateSection("Hacks");
hacks->Set("EFBAccessEnable", bEFBAccessEnable);
hacks->Set("BBoxEnable", bBBoxEnable);
hacks->Set("EFBToTextureEnable", bSkipEFBCopyToRam);
hacks->Set("EFBScaledCopy", bCopyEFBScaled);
hacks->Set("EFBEmulateFormatChanges", bEFBEmulateFormatChanges);

View File

@ -112,6 +112,7 @@ struct VideoConfig final
// Hacks
bool bEFBAccessEnable;
bool bPerfQueriesEnable;
bool bBBoxEnable;
bool bEFBEmulateFormatChanges;
bool bSkipEFBCopyToRam;

View File

@ -87,7 +87,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);
}