mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 16:49:58 -06:00
THIS BREAKS THE D3D PLUGIN FOR THE NEAR TERM. Resurrect an old patch that moves D3D over to the common shader generator framework. Needs a lot more work.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2484 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -15,42 +15,142 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "VideoCommon.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "VertexManager.h"
|
||||
#include <map>
|
||||
|
||||
DecodedVArray tempvarray;
|
||||
#include "Statistics.h"
|
||||
|
||||
#include "VertexShaderManager.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "VertexLoaderManager.h"
|
||||
|
||||
static int s_attr_dirty; // bitfield
|
||||
|
||||
static VertexLoader *g_VertexLoaders[8];
|
||||
|
||||
namespace VertexLoaderManager
|
||||
{
|
||||
|
||||
typedef std::map<VertexLoaderUID, VertexLoader *> VertexLoaderMap;
|
||||
static VertexLoaderMap g_VertexLoaderMap;
|
||||
// TODO - change into array of pointers. Keep a map of all seen so far.
|
||||
|
||||
void Init()
|
||||
{
|
||||
tempvarray.Create(65536*3, 1, 8, 3, 2, 8);
|
||||
MarkAllDirty();
|
||||
for (int i = 0; i < 8; i++)
|
||||
g_VertexLoaders[i] = NULL;
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
tempvarray.Destroy();
|
||||
for (VertexLoaderMap::iterator iter = g_VertexLoaderMap.begin(); iter != g_VertexLoaderMap.end(); ++iter)
|
||||
{
|
||||
delete iter->second;
|
||||
}
|
||||
g_VertexLoaderMap.clear();
|
||||
}
|
||||
|
||||
int GetVertexSize(int vat)
|
||||
void AppendListToString(std::string *dest)
|
||||
{
|
||||
VertexLoader& vtxLoader = g_VertexLoaders[vat];
|
||||
vtxLoader.Setup();
|
||||
return vtxLoader.GetVertexSize();
|
||||
for (VertexLoaderMap::iterator iter = g_VertexLoaderMap.begin(); iter != g_VertexLoaderMap.end(); ++iter)
|
||||
{
|
||||
iter->second->AppendToString(dest);
|
||||
}
|
||||
}
|
||||
|
||||
void RunVertices(int vat, int primitive, int num_vertices)
|
||||
void MarkAllDirty()
|
||||
{
|
||||
tempvarray.Reset();
|
||||
VertexLoader::SetVArray(&tempvarray);
|
||||
VertexLoader& vtxLoader = g_VertexLoaders[vat];
|
||||
vtxLoader.Setup();
|
||||
vtxLoader.PrepareRun();
|
||||
int vsize = vtxLoader.GetVertexSize();
|
||||
vtxLoader.RunVertices(num_vertices);
|
||||
VertexManager::AddVertices(primitive, num_vertices, &tempvarray);
|
||||
s_attr_dirty = 0xff;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void RefreshLoader(int vtx_attr_group)
|
||||
{
|
||||
if ((s_attr_dirty >> vtx_attr_group) & 1)
|
||||
{
|
||||
VertexLoaderUID uid;
|
||||
uid.InitFromCurrentState(vtx_attr_group);
|
||||
VertexLoaderMap::iterator iter = g_VertexLoaderMap.find(uid);
|
||||
if (iter != g_VertexLoaderMap.end())
|
||||
{
|
||||
g_VertexLoaders[vtx_attr_group] = iter->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
VertexLoader *loader = new VertexLoader(g_VtxDesc, g_VtxAttr[vtx_attr_group]);
|
||||
g_VertexLoaderMap[uid] = loader;
|
||||
g_VertexLoaders[vtx_attr_group] = loader;
|
||||
INCSTAT(stats.numVertexLoaders);
|
||||
}
|
||||
}
|
||||
s_attr_dirty &= ~(1 << vtx_attr_group);
|
||||
}
|
||||
|
||||
void RunVertices(int vtx_attr_group, int primitive, int count)
|
||||
{
|
||||
if (!count)
|
||||
return;
|
||||
RefreshLoader(vtx_attr_group);
|
||||
g_VertexLoaders[vtx_attr_group]->RunVertices(vtx_attr_group, primitive, count);
|
||||
}
|
||||
|
||||
int GetVertexSize(int vtx_attr_group)
|
||||
{
|
||||
RefreshLoader(vtx_attr_group);
|
||||
return g_VertexLoaders[vtx_attr_group]->GetVertexSize();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void LoadCPReg(u32 sub_cmd, u32 value)
|
||||
{
|
||||
switch (sub_cmd & 0xF0)
|
||||
{
|
||||
case 0x30:
|
||||
VertexShaderManager::SetTexMatrixChangedA(value);
|
||||
break;
|
||||
|
||||
case 0x40:
|
||||
VertexShaderManager::SetTexMatrixChangedB(value);
|
||||
break;
|
||||
|
||||
case 0x50:
|
||||
g_VtxDesc.Hex &= ~0x1FFFF; // keep the Upper bits
|
||||
g_VtxDesc.Hex |= value;
|
||||
s_attr_dirty = 0xFF;
|
||||
break;
|
||||
|
||||
case 0x60:
|
||||
g_VtxDesc.Hex &= 0x1FFFF; // keep the lower 17Bits
|
||||
g_VtxDesc.Hex |= (u64)value << 17;
|
||||
s_attr_dirty = 0xFF;
|
||||
break;
|
||||
|
||||
case 0x70:
|
||||
_assert_((sub_cmd & 0x0F) < 8);
|
||||
g_VtxAttr[sub_cmd & 7].g0.Hex = value;
|
||||
s_attr_dirty |= 1 << (sub_cmd & 7);
|
||||
break;
|
||||
|
||||
case 0x80:
|
||||
_assert_((sub_cmd & 0x0F) < 8);
|
||||
g_VtxAttr[sub_cmd & 7].g1.Hex = value;
|
||||
s_attr_dirty |= 1 << (sub_cmd & 7);
|
||||
break;
|
||||
|
||||
case 0x90:
|
||||
_assert_((sub_cmd & 0x0F) < 8);
|
||||
g_VtxAttr[sub_cmd & 7].g2.Hex = value;
|
||||
s_attr_dirty |= 1 << (sub_cmd & 7);
|
||||
break;
|
||||
|
||||
// Pointers to vertex arrays in GC RAM
|
||||
case 0xA0:
|
||||
arraybases[sub_cmd & 0xF] = value & 0xFFFFFFFF; // huh, why the mask?
|
||||
break;
|
||||
|
||||
case 0xB0:
|
||||
arraystrides[sub_cmd & 0xF] = value & 0xFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user