mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Update svn:eol-style=native ( r1442 ) for Source/*.cpp
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2384 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,145 +1,145 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "D3DBase.h"
|
||||
|
||||
#include "Profiler.h"
|
||||
#include "x64Emitter.h"
|
||||
#include "ABI.h"
|
||||
#include "MemoryUtil.h"
|
||||
#include "VertexShader.h"
|
||||
|
||||
#include "CPMemory.h"
|
||||
#include "NativeVertexFormat.h"
|
||||
|
||||
|
||||
class D3DVertexFormat : public NativeVertexFormat
|
||||
{
|
||||
PortableVertexDeclaration vtx_decl;
|
||||
LPDIRECT3DVERTEXDECLARATION9 d3d_decl;
|
||||
|
||||
public:
|
||||
D3DVertexFormat();
|
||||
~D3DVertexFormat();
|
||||
virtual void Initialize(const PortableVertexDeclaration &_vtx_decl);
|
||||
virtual void SetupVertexPointers() const;
|
||||
};
|
||||
|
||||
|
||||
NativeVertexFormat *NativeVertexFormat::Create()
|
||||
{
|
||||
return new D3DVertexFormat();
|
||||
}
|
||||
|
||||
D3DVertexFormat::D3DVertexFormat() : d3d_decl(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
D3DVertexFormat::~D3DVertexFormat()
|
||||
{
|
||||
if (d3d_decl)
|
||||
{
|
||||
d3d_decl->Release();
|
||||
d3d_decl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
D3DDECLTYPE VarToD3D(VarType t)
|
||||
{
|
||||
static const D3DDECLTYPE lookup[5] =
|
||||
{
|
||||
D3DDECLTYPE_UBYTE4, D3DDECLTYPE_UBYTE4, D3DDECLTYPE_SHORT4N, D3DDECLTYPE_USHORT4N, D3DDECLTYPE_FLOAT3,
|
||||
};
|
||||
return lookup[t];
|
||||
}
|
||||
|
||||
// TODO: Ban signed bytes as normals - not likely that ATI supports them natively.
|
||||
// We probably won't see much of a speed loss, and any speed loss will be regained anyway
|
||||
// when we finally compile display lists.
|
||||
|
||||
void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
|
||||
{
|
||||
D3DVERTEXELEMENT9 *elems = new D3DVERTEXELEMENT9[32];
|
||||
memset(elems, 0, sizeof(D3DVERTEXELEMENT9) * 32);
|
||||
|
||||
// There's only one stream and it's 0, so the above memset takes care of that - no need to set Stream.
|
||||
// Same for method.
|
||||
|
||||
// So, here we go. First position:
|
||||
int elem_idx = 0;
|
||||
elems[elem_idx].Offset = 0; // Positions are always first, at position 0.
|
||||
elems[elem_idx].Type = D3DDECLTYPE_FLOAT3;
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_POSITION;
|
||||
++elem_idx;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (_vtx_decl.normal_offset[i] >= 0)
|
||||
{
|
||||
elems[elem_idx].Offset = _vtx_decl.normal_offset[i];
|
||||
elems[elem_idx].Type = VarToD3D(_vtx_decl.normal_gl_type);
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_NORMAL;
|
||||
elems[elem_idx].UsageIndex = i;
|
||||
++elem_idx;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (_vtx_decl.color_offset[i] >= 0)
|
||||
{
|
||||
elems[elem_idx].Offset = _vtx_decl.color_offset[i];
|
||||
elems[elem_idx].Type = VarToD3D(_vtx_decl.color_gl_type);
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_COLOR;
|
||||
elems[elem_idx].UsageIndex = i;
|
||||
++elem_idx;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (_vtx_decl.texcoord_offset[i] >= 0)
|
||||
{
|
||||
elems[elem_idx].Offset = _vtx_decl.texcoord_offset[i];
|
||||
elems[elem_idx].Type = VarToD3D(_vtx_decl.texcoord_gl_type[i]);
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_TEXCOORD;
|
||||
elems[elem_idx].UsageIndex = i;
|
||||
++elem_idx;
|
||||
}
|
||||
}
|
||||
|
||||
if (vtx_decl.posmtx_offset != -1)
|
||||
{
|
||||
// glVertexAttribPointer(SHADER_POSMTX_ATTRIB, 4, GL_UNSIGNED_BYTE, GL_FALSE, vtx_decl.stride, (void *)vtx_decl.posmtx_offset);
|
||||
elems[elem_idx].Offset = _vtx_decl.posmtx_offset;
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_BLENDINDICES;
|
||||
elems[elem_idx].UsageIndex = 0;
|
||||
++elem_idx;
|
||||
}
|
||||
|
||||
if (FAILED(D3D::dev->CreateVertexDeclaration(elems, &d3d_decl)))
|
||||
{
|
||||
PanicAlert("Failed to create D3D vertex declaration!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void D3DVertexFormat::SetupVertexPointers() const
|
||||
{
|
||||
D3D::dev->SetVertexDeclaration(d3d_decl);
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "D3DBase.h"
|
||||
|
||||
#include "Profiler.h"
|
||||
#include "x64Emitter.h"
|
||||
#include "ABI.h"
|
||||
#include "MemoryUtil.h"
|
||||
#include "VertexShader.h"
|
||||
|
||||
#include "CPMemory.h"
|
||||
#include "NativeVertexFormat.h"
|
||||
|
||||
|
||||
class D3DVertexFormat : public NativeVertexFormat
|
||||
{
|
||||
PortableVertexDeclaration vtx_decl;
|
||||
LPDIRECT3DVERTEXDECLARATION9 d3d_decl;
|
||||
|
||||
public:
|
||||
D3DVertexFormat();
|
||||
~D3DVertexFormat();
|
||||
virtual void Initialize(const PortableVertexDeclaration &_vtx_decl);
|
||||
virtual void SetupVertexPointers() const;
|
||||
};
|
||||
|
||||
|
||||
NativeVertexFormat *NativeVertexFormat::Create()
|
||||
{
|
||||
return new D3DVertexFormat();
|
||||
}
|
||||
|
||||
D3DVertexFormat::D3DVertexFormat() : d3d_decl(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
D3DVertexFormat::~D3DVertexFormat()
|
||||
{
|
||||
if (d3d_decl)
|
||||
{
|
||||
d3d_decl->Release();
|
||||
d3d_decl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
D3DDECLTYPE VarToD3D(VarType t)
|
||||
{
|
||||
static const D3DDECLTYPE lookup[5] =
|
||||
{
|
||||
D3DDECLTYPE_UBYTE4, D3DDECLTYPE_UBYTE4, D3DDECLTYPE_SHORT4N, D3DDECLTYPE_USHORT4N, D3DDECLTYPE_FLOAT3,
|
||||
};
|
||||
return lookup[t];
|
||||
}
|
||||
|
||||
// TODO: Ban signed bytes as normals - not likely that ATI supports them natively.
|
||||
// We probably won't see much of a speed loss, and any speed loss will be regained anyway
|
||||
// when we finally compile display lists.
|
||||
|
||||
void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
|
||||
{
|
||||
D3DVERTEXELEMENT9 *elems = new D3DVERTEXELEMENT9[32];
|
||||
memset(elems, 0, sizeof(D3DVERTEXELEMENT9) * 32);
|
||||
|
||||
// There's only one stream and it's 0, so the above memset takes care of that - no need to set Stream.
|
||||
// Same for method.
|
||||
|
||||
// So, here we go. First position:
|
||||
int elem_idx = 0;
|
||||
elems[elem_idx].Offset = 0; // Positions are always first, at position 0.
|
||||
elems[elem_idx].Type = D3DDECLTYPE_FLOAT3;
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_POSITION;
|
||||
++elem_idx;
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (_vtx_decl.normal_offset[i] >= 0)
|
||||
{
|
||||
elems[elem_idx].Offset = _vtx_decl.normal_offset[i];
|
||||
elems[elem_idx].Type = VarToD3D(_vtx_decl.normal_gl_type);
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_NORMAL;
|
||||
elems[elem_idx].UsageIndex = i;
|
||||
++elem_idx;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (_vtx_decl.color_offset[i] >= 0)
|
||||
{
|
||||
elems[elem_idx].Offset = _vtx_decl.color_offset[i];
|
||||
elems[elem_idx].Type = VarToD3D(_vtx_decl.color_gl_type);
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_COLOR;
|
||||
elems[elem_idx].UsageIndex = i;
|
||||
++elem_idx;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (_vtx_decl.texcoord_offset[i] >= 0)
|
||||
{
|
||||
elems[elem_idx].Offset = _vtx_decl.texcoord_offset[i];
|
||||
elems[elem_idx].Type = VarToD3D(_vtx_decl.texcoord_gl_type[i]);
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_TEXCOORD;
|
||||
elems[elem_idx].UsageIndex = i;
|
||||
++elem_idx;
|
||||
}
|
||||
}
|
||||
|
||||
if (vtx_decl.posmtx_offset != -1)
|
||||
{
|
||||
// glVertexAttribPointer(SHADER_POSMTX_ATTRIB, 4, GL_UNSIGNED_BYTE, GL_FALSE, vtx_decl.stride, (void *)vtx_decl.posmtx_offset);
|
||||
elems[elem_idx].Offset = _vtx_decl.posmtx_offset;
|
||||
elems[elem_idx].Usage = D3DDECLUSAGE_BLENDINDICES;
|
||||
elems[elem_idx].UsageIndex = 0;
|
||||
++elem_idx;
|
||||
}
|
||||
|
||||
if (FAILED(D3D::dev->CreateVertexDeclaration(elems, &d3d_decl)))
|
||||
{
|
||||
PanicAlert("Failed to create D3D vertex declaration!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void D3DVertexFormat::SetupVertexPointers() const
|
||||
{
|
||||
D3D::dev->SetVertexDeclaration(d3d_decl);
|
||||
}
|
@ -1,133 +1,133 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "Statistics.h"
|
||||
#include "Utils.h"
|
||||
#include "Profiler.h"
|
||||
#include "PixelShaderCache.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "BPMemory.h"
|
||||
#include "XFMemory.h"
|
||||
|
||||
PShaderCache::PSCache PShaderCache::pshaders;
|
||||
|
||||
//I hope we don't get too many hash collisions :p
|
||||
//all these magic numbers are primes, it should help a bit
|
||||
tevhash GetCurrentTEV()
|
||||
{
|
||||
u32 hash = bpmem.genMode.numindstages + bpmem.genMode.numtevstages*11 + bpmem.genMode.numtexgens*8*17;
|
||||
for (int i = 0; i < (int)bpmem.genMode.numtevstages+1; i++)
|
||||
{
|
||||
hash = _rotl(hash,3) ^ (bpmem.combiners[i].colorC.hex*13);
|
||||
hash = _rotl(hash,7) ^ ((bpmem.combiners[i].alphaC.hex&0xFFFFFFFC)*3);
|
||||
hash = _rotl(hash,9) ^ xfregs.texcoords[i].texmtxinfo.projection*451;
|
||||
}
|
||||
for (int i = 0; i < (int)bpmem.genMode.numtevstages/2+1; i++)
|
||||
{
|
||||
hash = _rotl(hash,13) ^ (bpmem.tevorders[i].hex*7);
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
hash = _rotl(hash,3) ^ bpmem.tevksel[i].swap1;
|
||||
hash = _rotl(hash,3) ^ bpmem.tevksel[i].swap2;
|
||||
}
|
||||
hash ^= bpmem.dstalpha.enable ^ 0xc0debabe;
|
||||
hash = _rotl(hash,4) ^ bpmem.alphaFunc.comp0*7;
|
||||
hash = _rotl(hash,4) ^ bpmem.alphaFunc.comp1*13;
|
||||
hash = _rotl(hash,4) ^ bpmem.alphaFunc.logic*11;
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
void PShaderCache::Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PShaderCache::Shutdown()
|
||||
{
|
||||
PSCache::iterator iter = pshaders.begin();
|
||||
for (;iter!=pshaders.end();iter++)
|
||||
iter->second.Destroy();
|
||||
pshaders.clear();
|
||||
}
|
||||
|
||||
|
||||
void PShaderCache::SetShader()
|
||||
{
|
||||
if (D3D::GetShaderVersion() < 2)
|
||||
return; // we are screwed
|
||||
|
||||
static LPDIRECT3DPIXELSHADER9 lastShader = 0;
|
||||
DVSTARTPROFILE();
|
||||
|
||||
tevhash currentHash = GetCurrentTEV();
|
||||
|
||||
PSCache::iterator iter;
|
||||
iter = pshaders.find(currentHash);
|
||||
|
||||
if (iter != pshaders.end())
|
||||
{
|
||||
iter->second.frameCount = frameCount;
|
||||
PSCacheEntry &entry = iter->second;
|
||||
if (!lastShader || entry.shader != lastShader)
|
||||
{
|
||||
D3D::dev->SetPixelShader(entry.shader);
|
||||
lastShader = entry.shader;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const char *code = GeneratePixelShader();
|
||||
LPDIRECT3DPIXELSHADER9 shader = D3D::CompilePShader(code, int(strlen(code)));
|
||||
if (shader)
|
||||
{
|
||||
//Make an entry in the table
|
||||
PSCacheEntry newentry;
|
||||
newentry.shader = shader;
|
||||
newentry.frameCount = frameCount;
|
||||
pshaders[currentHash] = newentry;
|
||||
}
|
||||
|
||||
D3D::dev->SetPixelShader(shader);
|
||||
|
||||
INCSTAT(stats.numPixelShadersCreated);
|
||||
SETSTAT(stats.numPixelShadersAlive, (int)pshaders.size());
|
||||
}
|
||||
|
||||
void PShaderCache::Cleanup()
|
||||
{
|
||||
PSCache::iterator iter;
|
||||
iter = pshaders.begin();
|
||||
|
||||
while (iter != pshaders.end())
|
||||
{
|
||||
PSCacheEntry &entry = iter->second;
|
||||
if (entry.frameCount < frameCount-30)
|
||||
{
|
||||
entry.Destroy();
|
||||
iter = pshaders.erase(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
SETSTAT(stats.numPixelShadersAlive, (int)pshaders.size());
|
||||
}
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "Statistics.h"
|
||||
#include "Utils.h"
|
||||
#include "Profiler.h"
|
||||
#include "PixelShaderCache.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "BPMemory.h"
|
||||
#include "XFMemory.h"
|
||||
|
||||
PShaderCache::PSCache PShaderCache::pshaders;
|
||||
|
||||
//I hope we don't get too many hash collisions :p
|
||||
//all these magic numbers are primes, it should help a bit
|
||||
tevhash GetCurrentTEV()
|
||||
{
|
||||
u32 hash = bpmem.genMode.numindstages + bpmem.genMode.numtevstages*11 + bpmem.genMode.numtexgens*8*17;
|
||||
for (int i = 0; i < (int)bpmem.genMode.numtevstages+1; i++)
|
||||
{
|
||||
hash = _rotl(hash,3) ^ (bpmem.combiners[i].colorC.hex*13);
|
||||
hash = _rotl(hash,7) ^ ((bpmem.combiners[i].alphaC.hex&0xFFFFFFFC)*3);
|
||||
hash = _rotl(hash,9) ^ xfregs.texcoords[i].texmtxinfo.projection*451;
|
||||
}
|
||||
for (int i = 0; i < (int)bpmem.genMode.numtevstages/2+1; i++)
|
||||
{
|
||||
hash = _rotl(hash,13) ^ (bpmem.tevorders[i].hex*7);
|
||||
}
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
hash = _rotl(hash,3) ^ bpmem.tevksel[i].swap1;
|
||||
hash = _rotl(hash,3) ^ bpmem.tevksel[i].swap2;
|
||||
}
|
||||
hash ^= bpmem.dstalpha.enable ^ 0xc0debabe;
|
||||
hash = _rotl(hash,4) ^ bpmem.alphaFunc.comp0*7;
|
||||
hash = _rotl(hash,4) ^ bpmem.alphaFunc.comp1*13;
|
||||
hash = _rotl(hash,4) ^ bpmem.alphaFunc.logic*11;
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
void PShaderCache::Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void PShaderCache::Shutdown()
|
||||
{
|
||||
PSCache::iterator iter = pshaders.begin();
|
||||
for (;iter!=pshaders.end();iter++)
|
||||
iter->second.Destroy();
|
||||
pshaders.clear();
|
||||
}
|
||||
|
||||
|
||||
void PShaderCache::SetShader()
|
||||
{
|
||||
if (D3D::GetShaderVersion() < 2)
|
||||
return; // we are screwed
|
||||
|
||||
static LPDIRECT3DPIXELSHADER9 lastShader = 0;
|
||||
DVSTARTPROFILE();
|
||||
|
||||
tevhash currentHash = GetCurrentTEV();
|
||||
|
||||
PSCache::iterator iter;
|
||||
iter = pshaders.find(currentHash);
|
||||
|
||||
if (iter != pshaders.end())
|
||||
{
|
||||
iter->second.frameCount = frameCount;
|
||||
PSCacheEntry &entry = iter->second;
|
||||
if (!lastShader || entry.shader != lastShader)
|
||||
{
|
||||
D3D::dev->SetPixelShader(entry.shader);
|
||||
lastShader = entry.shader;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const char *code = GeneratePixelShader();
|
||||
LPDIRECT3DPIXELSHADER9 shader = D3D::CompilePShader(code, int(strlen(code)));
|
||||
if (shader)
|
||||
{
|
||||
//Make an entry in the table
|
||||
PSCacheEntry newentry;
|
||||
newentry.shader = shader;
|
||||
newentry.frameCount = frameCount;
|
||||
pshaders[currentHash] = newentry;
|
||||
}
|
||||
|
||||
D3D::dev->SetPixelShader(shader);
|
||||
|
||||
INCSTAT(stats.numPixelShadersCreated);
|
||||
SETSTAT(stats.numPixelShadersAlive, (int)pshaders.size());
|
||||
}
|
||||
|
||||
void PShaderCache::Cleanup()
|
||||
{
|
||||
PSCache::iterator iter;
|
||||
iter = pshaders.begin();
|
||||
|
||||
while (iter != pshaders.end())
|
||||
{
|
||||
PSCacheEntry &entry = iter->second;
|
||||
if (entry.frameCount < frameCount-30)
|
||||
{
|
||||
entry.Destroy();
|
||||
iter = pshaders.erase(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
SETSTAT(stats.numPixelShadersAlive, (int)pshaders.size());
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// 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"
|
||||
|
||||
DecodedVArray tempvarray;
|
||||
|
||||
namespace VertexLoaderManager
|
||||
{
|
||||
|
||||
void Init()
|
||||
{
|
||||
tempvarray.Create(65536*3, 1, 8, 3, 2, 8);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
tempvarray.Destroy();
|
||||
}
|
||||
|
||||
int GetVertexSize(int vat)
|
||||
{
|
||||
VertexLoader& vtxLoader = g_VertexLoaders[vat];
|
||||
vtxLoader.Setup();
|
||||
return vtxLoader.GetVertexSize();
|
||||
}
|
||||
|
||||
void RunVertices(int vat, int primitive, int num_vertices)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// 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"
|
||||
|
||||
DecodedVArray tempvarray;
|
||||
|
||||
namespace VertexLoaderManager
|
||||
{
|
||||
|
||||
void Init()
|
||||
{
|
||||
tempvarray.Create(65536*3, 1, 8, 3, 2, 8);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
tempvarray.Destroy();
|
||||
}
|
||||
|
||||
int GetVertexSize(int vat)
|
||||
{
|
||||
VertexLoader& vtxLoader = g_VertexLoaders[vat];
|
||||
vtxLoader.Setup();
|
||||
return vtxLoader.GetVertexSize();
|
||||
}
|
||||
|
||||
void RunVertices(int vat, int primitive, int num_vertices)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -1,110 +1,110 @@
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "Statistics.h"
|
||||
#include "Utils.h"
|
||||
#include "Profiler.h"
|
||||
#include "VertexShaderCache.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "BPMemory.h"
|
||||
#include "XFMemory.h"
|
||||
|
||||
VShaderCache::VSCache VShaderCache::vshaders;
|
||||
|
||||
void VShaderCache::Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void VShaderCache::Shutdown()
|
||||
{
|
||||
VSCache::iterator iter = vshaders.begin();
|
||||
for (; iter != vshaders.end(); iter++)
|
||||
iter->second.Destroy();
|
||||
vshaders.clear();
|
||||
}
|
||||
|
||||
|
||||
void VShaderCache::SetShader()
|
||||
{
|
||||
static LPDIRECT3DVERTEXSHADER9 shader = NULL;
|
||||
if (D3D::GetShaderVersion() < 2)
|
||||
return; // we are screwed
|
||||
|
||||
if (shader) {
|
||||
//D3D::dev->SetVertexShader(shader);
|
||||
return;
|
||||
}
|
||||
|
||||
static LPDIRECT3DVERTEXSHADER9 lastShader = 0;
|
||||
DVSTARTPROFILE();
|
||||
|
||||
u32 currentHash = 0x1337; // GetCurrentTEV();
|
||||
|
||||
VSCache::iterator iter;
|
||||
iter = vshaders.find(currentHash);
|
||||
|
||||
if (iter != vshaders.end())
|
||||
{
|
||||
iter->second.frameCount=frameCount;
|
||||
VSCacheEntry &entry = iter->second;
|
||||
if (!lastShader || entry.shader != lastShader)
|
||||
{
|
||||
D3D::dev->SetVertexShader(entry.shader);
|
||||
lastShader = entry.shader;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const char *code = GenerateVertexShader();
|
||||
shader = D3D::CompileVShader(code, int(strlen(code)));
|
||||
if (shader)
|
||||
{
|
||||
//Make an entry in the table
|
||||
VSCacheEntry entry;
|
||||
entry.shader = shader;
|
||||
entry.frameCount=frameCount;
|
||||
vshaders[currentHash] = entry;
|
||||
}
|
||||
|
||||
D3D::dev->SetVertexShader(shader);
|
||||
|
||||
INCSTAT(stats.numVertexShadersCreated);
|
||||
SETSTAT(stats.numVertexShadersAlive, (int)vshaders.size());
|
||||
}
|
||||
|
||||
void VShaderCache::Cleanup()
|
||||
{
|
||||
for (VSCache::iterator iter = vshaders.begin(); iter != vshaders.end();)
|
||||
{
|
||||
VSCacheEntry &entry = iter->second;
|
||||
if (entry.frameCount < frameCount - 30)
|
||||
{
|
||||
entry.Destroy();
|
||||
iter = vshaders.erase(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
SETSTAT(stats.numVertexShadersAlive, (int)vshaders.size());
|
||||
}
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "Statistics.h"
|
||||
#include "Utils.h"
|
||||
#include "Profiler.h"
|
||||
#include "VertexShaderCache.h"
|
||||
#include "VertexLoader.h"
|
||||
#include "BPMemory.h"
|
||||
#include "XFMemory.h"
|
||||
|
||||
VShaderCache::VSCache VShaderCache::vshaders;
|
||||
|
||||
void VShaderCache::Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void VShaderCache::Shutdown()
|
||||
{
|
||||
VSCache::iterator iter = vshaders.begin();
|
||||
for (; iter != vshaders.end(); iter++)
|
||||
iter->second.Destroy();
|
||||
vshaders.clear();
|
||||
}
|
||||
|
||||
|
||||
void VShaderCache::SetShader()
|
||||
{
|
||||
static LPDIRECT3DVERTEXSHADER9 shader = NULL;
|
||||
if (D3D::GetShaderVersion() < 2)
|
||||
return; // we are screwed
|
||||
|
||||
if (shader) {
|
||||
//D3D::dev->SetVertexShader(shader);
|
||||
return;
|
||||
}
|
||||
|
||||
static LPDIRECT3DVERTEXSHADER9 lastShader = 0;
|
||||
DVSTARTPROFILE();
|
||||
|
||||
u32 currentHash = 0x1337; // GetCurrentTEV();
|
||||
|
||||
VSCache::iterator iter;
|
||||
iter = vshaders.find(currentHash);
|
||||
|
||||
if (iter != vshaders.end())
|
||||
{
|
||||
iter->second.frameCount=frameCount;
|
||||
VSCacheEntry &entry = iter->second;
|
||||
if (!lastShader || entry.shader != lastShader)
|
||||
{
|
||||
D3D::dev->SetVertexShader(entry.shader);
|
||||
lastShader = entry.shader;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const char *code = GenerateVertexShader();
|
||||
shader = D3D::CompileVShader(code, int(strlen(code)));
|
||||
if (shader)
|
||||
{
|
||||
//Make an entry in the table
|
||||
VSCacheEntry entry;
|
||||
entry.shader = shader;
|
||||
entry.frameCount=frameCount;
|
||||
vshaders[currentHash] = entry;
|
||||
}
|
||||
|
||||
D3D::dev->SetVertexShader(shader);
|
||||
|
||||
INCSTAT(stats.numVertexShadersCreated);
|
||||
SETSTAT(stats.numVertexShadersAlive, (int)vshaders.size());
|
||||
}
|
||||
|
||||
void VShaderCache::Cleanup()
|
||||
{
|
||||
for (VSCache::iterator iter = vshaders.begin(); iter != vshaders.end();)
|
||||
{
|
||||
VSCacheEntry &entry = iter->second;
|
||||
if (entry.frameCount < frameCount - 30)
|
||||
{
|
||||
entry.Destroy();
|
||||
iter = vshaders.erase(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
SETSTAT(stats.numVertexShadersAlive, (int)vshaders.size());
|
||||
}
|
||||
|
Reference in New Issue
Block a user