mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Readability, comments, tiny typo bugfix in gl gfx plugin (fix is on line 322 in pixelshadermanager)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@930 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -161,7 +161,7 @@ void BPWritten(int addr, int changes, int newval)
|
||||
|
||||
case BPMEM_LINEPTWIDTH:
|
||||
{
|
||||
float fratio = VertexShaderMngr::rawViewport[0] != 0 ? (float)Renderer::GetTargetWidth() / 640.0f : 1.0f;
|
||||
float fratio = VertexShaderMngr::GetPixelAspectRatio();
|
||||
if (bpmem.lineptwidth.linesize > 0)
|
||||
glLineWidth((float)bpmem.lineptwidth.linesize * fratio / 6.0f); // scale by ratio of widths
|
||||
if (bpmem.lineptwidth.pointsize > 0)
|
||||
|
@ -133,7 +133,6 @@ FRAGMENTSHADER* PixelShaderMngr::GetShader()
|
||||
}
|
||||
|
||||
PSCacheEntry& newentry = pshaders[uid];
|
||||
|
||||
char *code = GeneratePixelShader(s_texturemask,
|
||||
Renderer::GetZBufferTarget() != 0,
|
||||
Renderer::GetRenderMode() != Renderer::RM_Normal);
|
||||
@ -184,9 +183,6 @@ void PixelShaderMngr::Cleanup()
|
||||
|
||||
bool PixelShaderMngr::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
||||
{
|
||||
// todo: Should error be checked?
|
||||
// CGerror cgerr = cgGetError();
|
||||
|
||||
char stropt[64];
|
||||
sprintf(stropt, "MaxLocalParams=32,NumInstructionSlots=%d", s_nMaxPixelInstructions);
|
||||
const char* opts[] = {"-profileopts", stropt, "-O2", "-q", NULL};
|
||||
@ -207,6 +203,7 @@ bool PixelShaderMngr::CompilePixelShader(FRAGMENTSHADER& ps, const char* pstrpro
|
||||
|
||||
if (Renderer::IsUsingATIDrawBuffers()) {
|
||||
// sometimes compilation can use ARB_draw_buffers, which would fail for ATI cards
|
||||
// replace the three characters ARB with ATI. TODO - check whether this is fixed in modern ATI drivers.
|
||||
char* poptions = strstr(pcompiledprog, "ARB_draw_buffers");
|
||||
if (poptions != NULL) {
|
||||
poptions[0] = 'A';
|
||||
@ -313,6 +310,7 @@ void PixelShaderMngr::SetConstants(FRAGMENTSHADER& ps)
|
||||
|
||||
// indirect incoming texture scales, update all!
|
||||
if (s_bIndTexScaleChanged) {
|
||||
// set as two sets of vec4s, each containing S and T of two ind stages.
|
||||
float f[8];
|
||||
|
||||
for (u32 i = 0; i < bpmem.genMode.numindstages; ++i) {
|
||||
@ -321,7 +319,7 @@ void PixelShaderMngr::SetConstants(FRAGMENTSHADER& ps)
|
||||
TCoordInfo& tc = bpmem.texcoords[texcoord];
|
||||
|
||||
f[2*i] = bpmem.texscale[i/2].getScaleS(i&1) * (float)(tc.s.scale_minus_1+1) / (float)(lastTexDims[srctexmap] & 0xffff);
|
||||
f[2*i+1] = bpmem.texscale[i/2].getScaleT(i&1) * (float)(tc.t.scale_minus_1+1) / (float)((lastTexDims[srctexmap]>>16)&0xfff);
|
||||
f[2*i+1] = bpmem.texscale[i/2].getScaleT(i&1) * (float)(tc.t.scale_minus_1+1) / (float)((lastTexDims[srctexmap] >> 16) & 0xffff);
|
||||
|
||||
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2*i], f[2*i+1]);
|
||||
}
|
||||
@ -361,7 +359,6 @@ void PixelShaderMngr::SetConstants(FRAGMENTSHADER& ps)
|
||||
void PixelShaderMngr::SetPSTextureDims(int texid)
|
||||
{
|
||||
float fdims[4];
|
||||
|
||||
if (s_texturemask & (1<<texid)) {
|
||||
if (maptocoord[texid] >= 0) {
|
||||
TCoordInfo& tc = bpmem.texcoords[maptocoord[texid]];
|
||||
@ -392,7 +389,6 @@ void PixelShaderMngr::SetPSTextureDims(int texid)
|
||||
fdims[3] = 1.0f/(float)((lastTexDims[texid]>>16)&0xfff);
|
||||
}
|
||||
}
|
||||
|
||||
PRIM_LOG("texdims%d: %f %f %f %f\n", texid, fdims[0], fdims[1], fdims[2], fdims[3]);
|
||||
SetPSConstant4fv(C_TEXDIMS + texid, fdims);
|
||||
}
|
||||
@ -517,6 +513,8 @@ GLuint PixelShaderMngr::GetColorMatrixProgram()
|
||||
return s_ColorMatrixProgram;
|
||||
}
|
||||
|
||||
// Mash together all the inputs that contribute to the code of a generated pixel shader into
|
||||
// a unique identifier, basically containing all the bits. Yup, it's a lot ....
|
||||
void PixelShaderMngr::GetPixelShaderId(PixelShaderMngr::PIXELSHADERUID& uid)
|
||||
{
|
||||
u32 projtexcoords = 0;
|
||||
@ -527,22 +525,25 @@ void PixelShaderMngr::GetPixelShaderId(PixelShaderMngr::PIXELSHADERUID& uid)
|
||||
projtexcoords |= 1 << texcoord;
|
||||
}
|
||||
}
|
||||
|
||||
u32 zbufrender = (Renderer::GetZBufferTarget() && bpmem.zmode.updateenable) ? 1 : 0;
|
||||
u32 zBufRenderToCol0 = Renderer::GetRenderMode() != Renderer::RM_Normal;
|
||||
uid.values[0] = (u32)bpmem.genMode.numtevstages|((u32)bpmem.genMode.numindstages<<4)|((u32)bpmem.genMode.numtexgens<<7)
|
||||
|((u32)bpmem.dstalpha.enable<<11)|((u32)((bpmem.alphaFunc.hex>>16)&0xff)<<12)|(projtexcoords<<20)|((u32)bpmem.ztex2.op<<28)
|
||||
|(zbufrender<<30)|(zBufRenderToCol0<<31);
|
||||
uid.values[0] = (u32)bpmem.genMode.numtevstages |
|
||||
((u32)bpmem.genMode.numindstages << 4) |
|
||||
((u32)bpmem.genMode.numtexgens << 7) |
|
||||
((u32)bpmem.dstalpha.enable << 11) |
|
||||
((u32)((bpmem.alphaFunc.hex >> 16) & 0xff) << 12) |
|
||||
(projtexcoords << 20) |
|
||||
((u32)bpmem.ztex2.op << 28) |
|
||||
(zbufrender << 30) |
|
||||
(zBufRenderToCol0 << 31);
|
||||
|
||||
s_curuid.values[0] = (s_curuid.values[0] & ~0x0ff00000) | (projtexcoords << 20);
|
||||
|
||||
// swap table
|
||||
for (int i = 0; i < 8; i += 2)
|
||||
((u8*)&uid.values[1])[i/2] = (bpmem.tevksel[i].hex & 0xf) | ((bpmem.tevksel[i + 1].hex & 0xf)<<4);
|
||||
|
||||
uid.values[2] = s_texturemask;
|
||||
int hdr = 3;
|
||||
|
||||
u32* pcurvalue = &uid.values[hdr];
|
||||
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages+1; ++i) {
|
||||
TevStageCombiner::ColorCombiner &cc = bpmem.combiners[i].colorC;
|
||||
@ -552,7 +553,6 @@ void PixelShaderMngr::GetPixelShaderId(PixelShaderMngr::PIXELSHADERUID& uid)
|
||||
u32 val1 = ac.hex&0xffffff;
|
||||
val0 |= bpmem.tevksel[i/2].getKC(i&1)<<24;
|
||||
val1 |= bpmem.tevksel[i/2].getKA(i&1)<<24;
|
||||
|
||||
pcurvalue[0] = val0;
|
||||
pcurvalue[1] = val1;
|
||||
pcurvalue += 2;
|
||||
@ -560,10 +560,14 @@ void PixelShaderMngr::GetPixelShaderId(PixelShaderMngr::PIXELSHADERUID& uid)
|
||||
|
||||
for (u32 i = 0; i < ((u32)bpmem.genMode.numtevstages+1)/2; ++i) {
|
||||
u32 val0, val1;
|
||||
if (bpmem.tevorders[i].hex&0x40 ) val0 = bpmem.tevorders[i].hex&0x3ff;
|
||||
else val0 = bpmem.tevorders[i].hex&0x380;
|
||||
if (bpmem.tevorders[i].hex&0x40000 ) val1 = (bpmem.tevorders[i].hex&0x3ff000)>>12;
|
||||
else val1 = (bpmem.tevorders[i].hex&0x380000)>>12;
|
||||
if (bpmem.tevorders[i].hex & 0x40)
|
||||
val0 = bpmem.tevorders[i].hex & 0x3ff;
|
||||
else
|
||||
val0 = bpmem.tevorders[i].hex & 0x380;
|
||||
if (bpmem.tevorders[i].hex & 0x40000)
|
||||
val1 = (bpmem.tevorders[i].hex & 0x3ff000) >> 12;
|
||||
else
|
||||
val1 = (bpmem.tevorders[i].hex & 0x380000) >> 12;
|
||||
|
||||
switch (i % 3) {
|
||||
case 0: pcurvalue[0] = val0|(val1<<10); break;
|
||||
@ -574,13 +578,15 @@ void PixelShaderMngr::GetPixelShaderId(PixelShaderMngr::PIXELSHADERUID& uid)
|
||||
|
||||
if ((bpmem.genMode.numtevstages + 1) & 1) { // odd
|
||||
u32 val0;
|
||||
if (bpmem.tevorders[bpmem.genMode.numtevstages/2].hex&0x40 ) val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex&0x3ff;
|
||||
else val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex&0x380;
|
||||
if (bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x40)
|
||||
val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex&0x3ff;
|
||||
else
|
||||
val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x380;
|
||||
|
||||
switch (bpmem.genMode.numtevstages % 3) {
|
||||
case 0: pcurvalue[0] = val0; break;
|
||||
case 1: pcurvalue[0] |= val0 << 20; break;
|
||||
case 2: pcurvalue[1] |= (val0<<10); pcurvalue++; break;
|
||||
case 2: pcurvalue[1] |= val0 << 10; pcurvalue++; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -598,5 +604,6 @@ void PixelShaderMngr::GetPixelShaderId(PixelShaderMngr::PIXELSHADERUID& uid)
|
||||
}
|
||||
}
|
||||
|
||||
// yeah, well ....
|
||||
uid.indstages = (u32)(pcurvalue - &uid.values[0] - 2 - uid.tevstages);
|
||||
}
|
||||
|
@ -137,13 +137,15 @@ VertexLoader::~VertexLoader()
|
||||
int VertexLoader::ComputeVertexSize()
|
||||
{
|
||||
if (!m_AttrDirty) {
|
||||
if (m_VtxDesc.Hex0 == VertexManager::GetVtxDesc().Hex0 && (m_VtxDesc.Hex1&1)==(VertexManager::GetVtxDesc().Hex1&1))
|
||||
// Compare the 33 desc bits.
|
||||
if (m_VtxDesc.Hex0 == VertexManager::GetVtxDesc().Hex0 &&
|
||||
(m_VtxDesc.Hex1 & 1) == (VertexManager::GetVtxDesc().Hex1 & 1))
|
||||
return m_VertexSize;
|
||||
|
||||
m_VtxDesc.Hex = VertexManager::GetVtxDesc().Hex;
|
||||
}
|
||||
else {
|
||||
// set anyway
|
||||
// Attributes are dirty so we have to recompute everything anyway.
|
||||
m_VtxDesc.Hex = VertexManager::GetVtxDesc().Hex;
|
||||
}
|
||||
|
||||
@ -157,14 +159,14 @@ int VertexLoader::ComputeVertexSize()
|
||||
m_VertexSize += 1;
|
||||
|
||||
// Texture matrix indices
|
||||
if (m_VtxDesc.Tex0MatIdx) {m_VertexSize+=1; }
|
||||
if (m_VtxDesc.Tex1MatIdx) {m_VertexSize+=1; }
|
||||
if (m_VtxDesc.Tex2MatIdx) {m_VertexSize+=1; }
|
||||
if (m_VtxDesc.Tex3MatIdx) {m_VertexSize+=1; }
|
||||
if (m_VtxDesc.Tex4MatIdx) {m_VertexSize+=1; }
|
||||
if (m_VtxDesc.Tex5MatIdx) {m_VertexSize+=1; }
|
||||
if (m_VtxDesc.Tex6MatIdx) {m_VertexSize+=1; }
|
||||
if (m_VtxDesc.Tex7MatIdx) {m_VertexSize+=1; }
|
||||
if (m_VtxDesc.Tex0MatIdx) m_VertexSize += 1;
|
||||
if (m_VtxDesc.Tex1MatIdx) m_VertexSize += 1;
|
||||
if (m_VtxDesc.Tex2MatIdx) m_VertexSize += 1;
|
||||
if (m_VtxDesc.Tex3MatIdx) m_VertexSize += 1;
|
||||
if (m_VtxDesc.Tex4MatIdx) m_VertexSize += 1;
|
||||
if (m_VtxDesc.Tex5MatIdx) m_VertexSize += 1;
|
||||
if (m_VtxDesc.Tex6MatIdx) m_VertexSize += 1;
|
||||
if (m_VtxDesc.Tex7MatIdx) m_VertexSize += 1;
|
||||
|
||||
switch (m_VtxDesc.Position) {
|
||||
case NOT_PRESENT: {_assert_("Vertex descriptor without position!");} break;
|
||||
@ -396,7 +398,6 @@ void VertexLoader::ProcessFormat()
|
||||
// Texture matrix indices (remove if corresponding texture coordinate isn't enabled)
|
||||
for (int i = 0; i < 8; i++) {
|
||||
SetupTexCoord(i, tc[i], m_VtxAttr.texCoord[i].Format, m_VtxAttr.texCoord[i].Elements, m_VtxAttr.texCoord[i].Frac);
|
||||
|
||||
if (m_components & (VB_HAS_TEXMTXIDX0 << i)) {
|
||||
if (tc[i] != NOT_PRESENT) {
|
||||
// if texmtx is included, texcoord will always be 3 floats, z will be the texmtx index
|
||||
@ -719,6 +720,7 @@ void VertexLoader::RunVertices(int primitive, int count)
|
||||
if ((v % granularity) == 0)
|
||||
{
|
||||
if (VertexManager::GetRemainingSize() < granularity*m_VBVertexStride) {
|
||||
// This buffer full - break current primitive and flush, to switch to the next buffer.
|
||||
u8* plastptr = VertexManager::s_pCurBufferPointer;
|
||||
if (v - startv > 0)
|
||||
VertexManager::AddVertices(primitive, v - startv + extraverts);
|
||||
|
@ -24,7 +24,7 @@ static u32 s_prevcomponents; // previous state set
|
||||
|
||||
u8* VertexManager::s_pCurBufferPointer = NULL;
|
||||
|
||||
const GLenum c_primitiveType[8] =
|
||||
static const GLenum c_primitiveType[8] =
|
||||
{
|
||||
GL_QUADS,
|
||||
0, //nothing
|
||||
@ -57,6 +57,7 @@ bool VertexManager::Init()
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
fnSetupVertexPointers = NULL;
|
||||
s_vStoredPrimitives.reserve(1000);
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
return true;
|
||||
@ -245,6 +246,9 @@ void VertexManager::Flush()
|
||||
PixelShaderMngr::SetConstants(*ps);
|
||||
|
||||
// finally bind
|
||||
|
||||
// TODO - cache progid, check if same as before. Maybe GL does this internally, though.
|
||||
// This is the really annoying problem with GL - you never know whether it's worth caching stuff yourself.
|
||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vs->glprogid);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ps->glprogid);
|
||||
|
||||
@ -253,7 +257,8 @@ void VertexManager::Flush()
|
||||
#endif
|
||||
|
||||
int offset = 0;
|
||||
for (vector< pair<int, int> >::const_iterator it = s_vStoredPrimitives.begin(); it != s_vStoredPrimitives.end(); ++it) {
|
||||
for (vector< pair<int, int> >::const_iterator it = s_vStoredPrimitives.begin(); it != s_vStoredPrimitives.end(); ++it)
|
||||
{
|
||||
glDrawArrays(it->first, offset, it->second);
|
||||
offset += it->second;
|
||||
}
|
||||
|
@ -36,24 +36,23 @@
|
||||
|
||||
VertexShaderMngr::VSCache VertexShaderMngr::vshaders;
|
||||
VERTEXSHADER* VertexShaderMngr::pShaderLast = NULL;
|
||||
float VertexShaderMngr::rawViewport[6] = {0};
|
||||
float VertexShaderMngr::rawProjection[7] = {0};
|
||||
|
||||
float GC_ALIGNED16(g_fProjectionMatrix[16]);
|
||||
|
||||
static int s_nMaxVertexInstructions;
|
||||
extern int A, B;
|
||||
extern float AR;
|
||||
extern int nBackbufferWidth, nBackbufferHeight;
|
||||
|
||||
////////////////////////
|
||||
// Internal Variables //
|
||||
////////////////////////
|
||||
static float s_fMaterials[16];
|
||||
// Internal Variables
|
||||
static int s_nMaxVertexInstructions;
|
||||
|
||||
static float s_fMaterials[16];
|
||||
static float rawViewport[6] = {0};
|
||||
static float rawProjection[7] = {0};
|
||||
|
||||
// track changes
|
||||
static bool bTexMatricesChanged[2], bPosNormalMatrixChanged, bProjectionChanged, bViewportChanged;
|
||||
int nMaterialsChanged;
|
||||
static int nMaterialsChanged;
|
||||
static int nTransformMatricesChanged[2]; // min,max
|
||||
static int nNormalMatricesChanged[2]; // min,max
|
||||
static int nPostTransformMatricesChanged[2]; // min,max
|
||||
@ -85,12 +84,15 @@ void VertexShaderMngr::Init()
|
||||
|
||||
void VertexShaderMngr::Shutdown()
|
||||
{
|
||||
VSCache::iterator iter = vshaders.begin();
|
||||
for (;iter!=vshaders.end();iter++)
|
||||
for (VSCache::iterator iter = vshaders.begin(); iter != vshaders.end(); iter++)
|
||||
iter->second.Destroy();
|
||||
vshaders.clear();
|
||||
}
|
||||
|
||||
float VertexShaderMngr::GetPixelAspectRatio() {
|
||||
return rawViewport[0] != 0 ? (float)Renderer::GetTargetWidth() / 640.0f : 1.0f;
|
||||
}
|
||||
|
||||
VERTEXSHADER* VertexShaderMngr::GetShader(u32 components)
|
||||
{
|
||||
DVSTARTPROFILE();
|
||||
@ -268,11 +270,17 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
|
||||
for (int i = istart; i < iend; ++i) {
|
||||
u32 color = *(const u32*)(xfmemptr + 3);
|
||||
SetVSConstant4f(C_LIGHTS + 5*i,
|
||||
((color>>24)&0xFF)/255.0f, ((color>>16)&0xFF)/255.0f, ((color>>8)&0xFF)/255.0f, ((color)&0xFF)/255.0f);
|
||||
((color >> 24) & 0xFF)/255.0f,
|
||||
((color >> 16) & 0xFF)/255.0f,
|
||||
((color >> 8) & 0xFF)/255.0f,
|
||||
((color) & 0xFF)/255.0f);
|
||||
xfmemptr += 4;
|
||||
for (int j = 0; j < 4; ++j, xfmemptr += 3) {
|
||||
if( j == 1 && fabs(xfmemptr[0]) < 0.00001f && fabs(xfmemptr[1]) < 0.00001f && fabs(xfmemptr[2]) < 0.00001f) {
|
||||
// dist atten, make sure not equal to 0!!!
|
||||
if (j == 1 &&
|
||||
fabs(xfmemptr[0]) < 0.00001f &&
|
||||
fabs(xfmemptr[1]) < 0.00001f &&
|
||||
fabs(xfmemptr[2]) < 0.00001f) {
|
||||
// dist attenuation, make sure not equal to 0!!!
|
||||
SetVSConstant4f(C_LIGHTS+5*i+j+1, 0.00001f, xfmemptr[1], xfmemptr[2], 0);
|
||||
}
|
||||
else
|
||||
@ -307,9 +315,10 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
|
||||
|
||||
if (bTexMatricesChanged[0]) {
|
||||
bTexMatricesChanged[0] = false;
|
||||
|
||||
float* fptrs[] = {(float*)xfmem + MatrixIndexA.Tex0MtxIdx * 4, (float*)xfmem + MatrixIndexA.Tex1MtxIdx * 4,
|
||||
(float*)xfmem + MatrixIndexA.Tex2MtxIdx * 4, (float*)xfmem + MatrixIndexA.Tex3MtxIdx * 4 };
|
||||
float* fptrs[] = {
|
||||
(float*)xfmem + MatrixIndexA.Tex0MtxIdx * 4, (float*)xfmem + MatrixIndexA.Tex1MtxIdx * 4,
|
||||
(float*)xfmem + MatrixIndexA.Tex2MtxIdx * 4, (float*)xfmem + MatrixIndexA.Tex3MtxIdx * 4
|
||||
};
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
SetVSConstant4fv(C_TEXMATRICES+3*i, fptrs[i]);
|
||||
@ -352,8 +361,10 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
|
||||
int scissorYOff = bpmem.scissorOffset.y * 2 - 342;
|
||||
float fourThree = 4.0f / 3.0f;
|
||||
float ratio = AR / fourThree;
|
||||
float hAdj; float wAdj; float actualRatiow; float actualRatioh;
|
||||
int overfl; int xoffs = 0; int yoffs = 0;
|
||||
float wAdj, hAdj;
|
||||
float actualRatiow, actualRatioh;
|
||||
int overfl;
|
||||
int xoffs = 0, yoffs = 0;
|
||||
int wid, hei, actualWid, actualHei;
|
||||
int winw = nBackbufferWidth; int winh = nBackbufferHeight;
|
||||
if (g_Config.bKeepAR)
|
||||
@ -420,17 +431,17 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
|
||||
g_fProjectionMatrix[0] = rawProjection[0];
|
||||
g_fProjectionMatrix[1] = 0.0f;
|
||||
g_fProjectionMatrix[2] = rawProjection[1];
|
||||
g_fProjectionMatrix[3] = 0;//-0.5f/Renderer::GetTargetWidth();
|
||||
g_fProjectionMatrix[3] = 0;
|
||||
|
||||
g_fProjectionMatrix[4] = 0.0f;
|
||||
g_fProjectionMatrix[5] = rawProjection[2];
|
||||
g_fProjectionMatrix[6] = rawProjection[3];
|
||||
g_fProjectionMatrix[7] = 0;//+0.5f/Renderer::GetTargetHeight();
|
||||
g_fProjectionMatrix[7] = 0;
|
||||
|
||||
g_fProjectionMatrix[8] = 0.0f;
|
||||
g_fProjectionMatrix[9] = 0.0f;
|
||||
g_fProjectionMatrix[10] = rawProjection[4];
|
||||
g_fProjectionMatrix[11] = -(0.0f - rawProjection[5]);
|
||||
g_fProjectionMatrix[11] = -(0.0f - rawProjection[5]); // Yes, it's important that it's done this way.
|
||||
|
||||
g_fProjectionMatrix[12] = 0.0f;
|
||||
g_fProjectionMatrix[13] = 0.0f;
|
||||
@ -451,7 +462,7 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
|
||||
g_fProjectionMatrix[8] = 0.0f;
|
||||
g_fProjectionMatrix[9] = 0.0f;
|
||||
g_fProjectionMatrix[10] = rawProjection[4];
|
||||
g_fProjectionMatrix[11] = -(0.0f - rawProjection[5]);
|
||||
g_fProjectionMatrix[11] = -(0.0f - rawProjection[5]); // Yes, it's important that it's done this way.
|
||||
|
||||
g_fProjectionMatrix[12] = 0;
|
||||
g_fProjectionMatrix[13] = 0;
|
||||
@ -564,10 +575,10 @@ void VertexShaderMngr::SetTexMatrixChangedB(u32 Value)
|
||||
|
||||
void VertexShaderMngr::SetViewport(float* _Viewport)
|
||||
{
|
||||
// check for paper mario
|
||||
// Workaround for paper mario, yep this is bizarre.
|
||||
for (size_t i = 0; i < ARRAYSIZE(rawViewport); ++i) {
|
||||
if( *(u32*)(_Viewport + i) == 0x7f800000 )
|
||||
return; // invalid number
|
||||
if (*(u32*)(_Viewport + i) == 0x7f800000) // invalid fp number
|
||||
return;
|
||||
}
|
||||
memcpy(rawViewport, _Viewport, sizeof(rawViewport));
|
||||
bViewportChanged = true;
|
||||
@ -723,16 +734,16 @@ void VertexShaderMngr::LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
|
||||
break;
|
||||
case 0x1018:
|
||||
//_assert_msg_(GX_XF, 0, "XF matrixindex0");
|
||||
VertexShaderMngr::SetTexMatrixChangedA(data); //?
|
||||
SetTexMatrixChangedA(data); //?
|
||||
break;
|
||||
case 0x1019:
|
||||
//_assert_msg_(GX_XF, 0, "XF matrixindex1");
|
||||
VertexShaderMngr::SetTexMatrixChangedB(data); //?
|
||||
SetTexMatrixChangedB(data); //?
|
||||
break;
|
||||
|
||||
case 0x101a:
|
||||
VertexManager::Flush();
|
||||
VertexShaderMngr::SetViewport((float*)&pData[i]);
|
||||
SetViewport((float*)&pData[i]);
|
||||
i += 6;
|
||||
break;
|
||||
|
||||
@ -795,7 +806,7 @@ void VertexShaderMngr::LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData)
|
||||
}
|
||||
}
|
||||
|
||||
// Check docs for this sucker...
|
||||
// TODO - verify that it is correct. Seems to work, though.
|
||||
void VertexShaderMngr::LoadIndexedXF(u32 val, int array)
|
||||
{
|
||||
int index = val >> 16;
|
||||
@ -816,21 +827,31 @@ float* VertexShaderMngr::GetPosNormalMat()
|
||||
return (float*)xfmem + MatrixIndexA.PosNormalMtxIdx * 4;
|
||||
}
|
||||
|
||||
// Mash together all the inputs that contribute to the code of a generated vertex shader into
|
||||
// a unique identifier, basically containing all the bits. Yup, it's a lot ....
|
||||
void VertexShaderMngr::GetVertexShaderId(VERTEXSHADERUID& id, u32 components)
|
||||
{
|
||||
u32 zbufrender = (bpmem.ztex2.op == ZTEXTURE_ADD) || Renderer::GetZBufferTarget() != 0;
|
||||
id.values[0] = components|(xfregs.numTexGens<<23)|(xfregs.nNumChans<<27)|((u32)xfregs.bEnableDualTexTransform<<29)|(zbufrender<<30);
|
||||
id.values[0] = components |
|
||||
(xfregs.numTexGens << 23) |
|
||||
(xfregs.nNumChans << 27) |
|
||||
((u32)xfregs.bEnableDualTexTransform << 29) |
|
||||
(zbufrender << 30);
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
id.values[1+i] = xfregs.colChans[i].color.enablelighting?(u32)xfregs.colChans[i].color.hex:(u32)xfregs.colChans[i].color.matsource;
|
||||
id.values[1+i] |= (xfregs.colChans[i].alpha.enablelighting?(u32)xfregs.colChans[i].alpha.hex:(u32)xfregs.colChans[i].alpha.matsource)<<15;
|
||||
id.values[1+i] = xfregs.colChans[i].color.enablelighting ?
|
||||
(u32)xfregs.colChans[i].color.hex :
|
||||
(u32)xfregs.colChans[i].color.matsource;
|
||||
id.values[1+i] |= (xfregs.colChans[i].alpha.enablelighting ?
|
||||
(u32)xfregs.colChans[i].alpha.hex :
|
||||
(u32)xfregs.colChans[i].alpha.matsource) << 15;
|
||||
}
|
||||
|
||||
// fog
|
||||
id.values[1] |= (((u32)bpmem.fog.c_proj_fsel.fsel & 3) << 30);
|
||||
id.values[2] |= (((u32)bpmem.fog.c_proj_fsel.fsel >> 2) << 30);
|
||||
|
||||
u32* pcurvalue = &id.values[3];
|
||||
|
||||
for (int i = 0; i < xfregs.numTexGens; ++i) {
|
||||
TexMtxInfo tinfo = xfregs.texcoords[i].texmtxinfo;
|
||||
if (tinfo.texgentype != XF_TEXGEN_EMBOSS_MAP)
|
||||
|
@ -123,9 +123,7 @@ public:
|
||||
static void LoadIndexedXF(u32 val, int array);
|
||||
|
||||
static float* GetPosNormalMat();
|
||||
|
||||
static float rawViewport[6];
|
||||
static float rawProjection[7];
|
||||
static float GetPixelAspectRatio();
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user