big changes here:

- Eliminate the useless check for cpu modifications option from efb to ram as it must be enabled always
- use constant names in dx11 for buffer length calculation instead to simplify code reading
- implemented scaled efb copy in opengl, still bugy in some games, the option is not in the gui but will add it when it works perfect
- Change the depth calculation behavior:
if the game use z textures is exactly the same as before.
if the game do not use z texture calculate z values in the vertex shader. the advantage id this approach is that early z culling is applied,
improving fill rate. this mus speed up things, even with ssaa and msaa enabled.
please test for regression and enjoy.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5896 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Rodolfo Osvaldo Bogado 2010-07-18 00:18:31 +00:00
parent 4b1a3152b6
commit f78133f261
23 changed files with 128 additions and 149 deletions

View File

@ -22,7 +22,7 @@ static const char ID[4] = {'D', 'C', 'A', 'C'};
// Update this to the current SVN revision every time you change shader generation code. // Update this to the current SVN revision every time you change shader generation code.
// We don't automatically get this from SVN_REV because that would mean regenerating the // We don't automatically get this from SVN_REV because that would mean regenerating the
// shader cache for every revision, graphics-related or not, which is simply annoying. // shader cache for every revision, graphics-related or not, which is simply annoying.
const int version = 5820; const int version = 5896;
LinearDiskCache::LinearDiskCache() LinearDiskCache::LinearDiskCache()
: file_(NULL), num_entries_(0) { : file_(NULL), num_entries_(0) {

View File

@ -342,6 +342,7 @@ static const char *swapColors = "rgba";
static char swapModeTable[4][5]; static char swapModeTable[4][5];
static char text[16384]; static char text[16384];
static bool DepthTextureEnable;
struct RegisterState struct RegisterState
{ {
@ -388,7 +389,7 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_T
nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt; nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt;
} }
} }
DepthTextureEnable = bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable && bpmem.zmode.updateenable;
// Declare samplers // Declare samplers
if (texture_mask && ApiType == API_OPENGL) if (texture_mask && ApiType == API_OPENGL)
{ {
@ -454,9 +455,9 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_T
WRITE(p, "void main(\n"); WRITE(p, "void main(\n");
if(ApiType != API_D3D11) if(ApiType != API_D3D11)
WRITE(p, " out float4 ocol0 : COLOR0,\n out float depth : DEPTH,\n in float4 rawpos : POSITION,\n"); WRITE(p, " out float4 ocol0 : COLOR0,%s\n in float4 rawpos : POSITION,\n",DepthTextureEnable ? "\n out float depth : DEPTH," : "");
else else
WRITE(p, " out float4 ocol0 : SV_Target,\n out float depth : SV_Depth,\n in float4 rawpos : SV_Position,\n"); WRITE(p, " out float4 ocol0 : SV_Target,%s\n in float4 rawpos : SV_Position,\n",DepthTextureEnable ? "\n out float depth : SV_Depth," : "");
WRITE(p, " in float4 colors_0 : COLOR0,\n"); WRITE(p, " in float4 colors_0 : COLOR0,\n");
WRITE(p, " in float4 colors_1 : COLOR1"); WRITE(p, " in float4 colors_1 : COLOR1");
@ -479,6 +480,7 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_T
char* pmainstart = p; char* pmainstart = p;
WRITE(p, " float4 c0 = "I_COLORS"[1], c1 = "I_COLORS"[2], c2 = "I_COLORS"[3], prev = float4(0.0f, 0.0f, 0.0f, 0.0f), textemp = float4(0.0f, 0.0f, 0.0f, 0.0f), rastemp = float4(0.0f, 0.0f, 0.0f, 0.0f), konsttemp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n" WRITE(p, " float4 c0 = "I_COLORS"[1], c1 = "I_COLORS"[2], c2 = "I_COLORS"[3], prev = float4(0.0f, 0.0f, 0.0f, 0.0f), textemp = float4(0.0f, 0.0f, 0.0f, 0.0f), rastemp = float4(0.0f, 0.0f, 0.0f, 0.0f), konsttemp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n"
" float3 comp16 = float3(1.0f, 255.0f, 0.0f), comp24 = float3(1.0f, 255.0f, 255.0f*255.0f);\n" " float3 comp16 = float3(1.0f, 255.0f, 0.0f), comp24 = float3(1.0f, 255.0f, 255.0f*255.0f);\n"
" float4 alphabump=0;\n" " float4 alphabump=0;\n"
@ -561,20 +563,23 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_T
// alpha test will always fail, so restart the shader and just make it an empty function // alpha test will always fail, so restart the shader and just make it an empty function
p = pmainstart; p = pmainstart;
WRITE(p, "ocol0 = 0;\n"); WRITE(p, "ocol0 = 0;\n");
WRITE(p, "depth = 1.f;\n"); if(DepthTextureEnable)
WRITE(p, "depth = 1.f;\n");
WRITE(p, "discard;\n"); WRITE(p, "discard;\n");
if(ApiType != API_D3D11) if(ApiType != API_D3D11)
WRITE(p, "return;\n"); WRITE(p, "return;\n");
} }
else else
{ {
if (numTexgen >= 7) if((bpmem.fog.c_proj_fsel.fsel != 0) || DepthTextureEnable)
WRITE(p, "float4 clipPos = float4(uv0.w, uv1.w, uv2.w, uv3.w);\n"); {
if (numTexgen >= 7)
WRITE(p, "float4 clipPos = float4(uv0.w, uv1.w, uv2.w, uv3.w);\n");
// the screen space depth value = far z + (clip z / clip w) * z range
WRITE(p, "float zCoord = "I_ZBIAS"[1].x + (clipPos.z / clipPos.w) * "I_ZBIAS"[1].y;\n");
}
// the screen space depth value = far z + (clip z / clip w) * z range if (DepthTextureEnable)
WRITE(p, "float zCoord = "I_ZBIAS"[1].x + (clipPos.z / clipPos.w) * "I_ZBIAS"[1].y;\n");
if (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable && bpmem.zmode.updateenable)
{ {
// use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format... // use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format...
if (bpmem.ztex2.op == ZTEXTURE_ADD) if (bpmem.ztex2.op == ZTEXTURE_ADD)
@ -586,8 +591,8 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_T
WRITE(p, "zCoord = zCoord * (16777215.0f/16777216.0f);\n"); WRITE(p, "zCoord = zCoord * (16777215.0f/16777216.0f);\n");
WRITE(p, "zCoord = frac(zCoord);\n"); WRITE(p, "zCoord = frac(zCoord);\n");
WRITE(p, "zCoord = zCoord * (16777216.0f/16777215.0f);\n"); WRITE(p, "zCoord = zCoord * (16777216.0f/16777215.0f);\n");
WRITE(p, "depth = zCoord;\n");
} }
WRITE(p, "depth = zCoord;\n");
if (dstAlphaEnable) if (dstAlphaEnable)
WRITE(p, " ocol0 = float4(prev.rgb, "I_ALPHA"[0].a);\n"); WRITE(p, " ocol0 = float4(prev.rgb, "I_ALPHA"[0].a);\n");
@ -954,7 +959,7 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType)
void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, u32 texture_mask, API_TYPE ApiType) void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, u32 texture_mask, API_TYPE ApiType)
{ {
if (texture_mask & (1<<texmap)) { if (texture_mask & (1<<texmap)) {// opengl only
// non pow 2 // non pow 2
bool bwraps = (texture_mask & (0x100<<texmap)) ? true : false; bool bwraps = (texture_mask & (0x100<<texmap)) ? true : false;
bool bwrapt = (texture_mask & (0x10000<<texmap)) ? true : false; bool bwrapt = (texture_mask & (0x10000<<texmap)) ? true : false;
@ -973,21 +978,11 @@ void SampleTexture(char *&p, const char *destination, const char *texcoords, con
else { else {
WRITE(p, "tempcoord.y = %s.y;\n", texcoords); WRITE(p, "tempcoord.y = %s.y;\n", texcoords);
} }
if (ApiType == API_D3D11) WRITE(p, "%s=texRECT(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap);
WRITE(p, "%s= Tex%d.Sample(samp%d,tempcoord.xy).%s;\n", destination, texmap,texmap, texswap);
else if (ApiType == API_D3D9)
WRITE(p, "%s=tex2D(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap);
else
WRITE(p, "%s=texRECT(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap);
} }
else else
{ {
if (ApiType == API_D3D11) WRITE(p, "%s=texRECT(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap);
WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy).%s;\n", destination,texmap,texmap, texcoords, texswap);
else if (ApiType == API_D3D9)
WRITE(p, "%s=tex2D(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap);
else
WRITE(p, "%s=texRECT(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap);
} }
} }
else else
@ -1061,9 +1056,7 @@ static bool WriteAlphaTest(char *&p, API_TYPE ApiType)
compindex = bpmem.alphaFunc.comp1 % 8; compindex = bpmem.alphaFunc.comp1 % 8;
WRITE(p, tevAlphaFuncsTable[compindex],alphaRef[1]);//lookup the second component from the alpha function table WRITE(p, tevAlphaFuncsTable[compindex],alphaRef[1]);//lookup the second component from the alpha function table
WRITE(p, ")){ocol0 = 0;%sdiscard;%s}\n",DepthTextureEnable ? "depth = 1.f;" : "",(ApiType != API_D3D11)? "return;" : "");
WRITE(p, ")){ocol0 = 0;depth = 1.f;discard;%s}\n",(ApiType != API_D3D11)? "return;" : "");
return true; return true;
} }
@ -1087,13 +1080,13 @@ static void WriteFog(char *&p)
{ {
// perspective // perspective
// ze = A/(B - Zs) // ze = A/(B - Zs)
WRITE (p, " float ze = "I_FOG"[1].x / ("I_FOG"[1].y - depth);\n"); WRITE (p, " float ze = "I_FOG"[1].x / ("I_FOG"[1].y - zCoord);\n");
} }
else else
{ {
// orthographic // orthographic
// ze = a*Zs // ze = a*Zs
WRITE (p, " float ze = "I_FOG"[1].x * depth;\n"); WRITE (p, " float ze = "I_FOG"[1].x * zCoord;\n");
} }
WRITE (p, " float fog = saturate(ze - "I_FOG"[1].z);\n"); WRITE (p, " float fog = saturate(ze - "I_FOG"[1].z);\n");

View File

@ -37,9 +37,8 @@
#define C_INDTEXSCALE (C_ZBIAS + 2) #define C_INDTEXSCALE (C_ZBIAS + 2)
#define C_INDTEXMTX (C_INDTEXSCALE + 2) #define C_INDTEXMTX (C_INDTEXSCALE + 2)
#define C_FOG (C_INDTEXMTX + 6) #define C_FOG (C_INDTEXMTX + 6)
#define C_ENVCONST_END (C_FOG + 2)
#define C_COLORMATRIX (C_FOG + 2) #define C_COLORMATRIX (C_FOG + 2)
#define C_PENVCONST_END (C_COLORMATRIX + 16)
#define PIXELSHADERUID_MAX_VALUES (5 + 32 + 6 + 11) #define PIXELSHADERUID_MAX_VALUES (5 + 32 + 6 + 11)
// DO NOT make anything in this class virtual. // DO NOT make anything in this class virtual.

View File

@ -135,6 +135,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "uniform s_"I_LIGHTS" "I_LIGHTS" : register(c%d);\n", C_LIGHTS); WRITE(p, "uniform s_"I_LIGHTS" "I_LIGHTS" : register(c%d);\n", C_LIGHTS);
WRITE(p, "uniform s_"I_MATERIALS" "I_MATERIALS" : register(c%d);\n", C_MATERIALS); WRITE(p, "uniform s_"I_MATERIALS" "I_MATERIALS" : register(c%d);\n", C_MATERIALS);
WRITE(p, "uniform s_"I_PROJECTION" "I_PROJECTION" : register(c%d);\n", C_PROJECTION); WRITE(p, "uniform s_"I_PROJECTION" "I_PROJECTION" : register(c%d);\n", C_PROJECTION);
WRITE(p, "uniform float4 "I_DEPTHPARAMS" : register(c%d);\n", C_DEPTHPARAMS);
WRITE(p, "VS_OUTPUT main(\n"); WRITE(p, "VS_OUTPUT main(\n");
@ -462,14 +463,11 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "o.tex3.w = o.pos.w;\n"); WRITE(p, "o.tex3.w = o.pos.w;\n");
} }
//write the true depth value, if the game uses depth textures pixel shaders will override with the correct values
//if not early z culling will improve speed
if (is_d3d) if (is_d3d)
{ {
WRITE(p, "o.pos.z = o.pos.z + o.pos.w;\n"); WRITE(p, "o.pos.z = "I_DEPTHPARAMS".x * o.pos.w + o.pos.z * "I_DEPTHPARAMS".y;\n");
}
else
{
// scale to gl clip space - which is -o.pos.w to o.pos.w, hence the addition.
WRITE(p, "o.pos.z = (o.pos.z * 2.0f) + o.pos.w;\n");
} }
WRITE(p, "return o;\n}\n"); WRITE(p, "return o;\n}\n");

View File

@ -35,7 +35,7 @@
#define I_TRANSFORMMATRICES "ctrmtx" #define I_TRANSFORMMATRICES "ctrmtx"
#define I_NORMALMATRICES "cnmtx" #define I_NORMALMATRICES "cnmtx"
#define I_POSTTRANSFORMMATRICES "cpostmtx" #define I_POSTTRANSFORMMATRICES "cpostmtx"
#define I_FOGPARAMS "cfog" #define I_DEPTHPARAMS "cDepth"
#define C_POSNORMALMATRIX 0 #define C_POSNORMALMATRIX 0
#define C_PROJECTION (C_POSNORMALMATRIX + 6) #define C_PROJECTION (C_POSNORMALMATRIX + 6)
@ -45,8 +45,8 @@
#define C_TRANSFORMMATRICES (C_TEXMATRICES + 24) #define C_TRANSFORMMATRICES (C_TEXMATRICES + 24)
#define C_NORMALMATRICES (C_TRANSFORMMATRICES + 64) #define C_NORMALMATRICES (C_TRANSFORMMATRICES + 64)
#define C_POSTTRANSFORMMATRICES (C_NORMALMATRICES + 32) #define C_POSTTRANSFORMMATRICES (C_NORMALMATRICES + 32)
#define C_FOGPARAMS (C_POSTTRANSFORMMATRICES + 64) #define C_DEPTHPARAMS (C_POSTTRANSFORMMATRICES + 64)
#define C_VENVCONST_END (C_DEPTHPARAMS + 4)
class VERTEXSHADERUID class VERTEXSHADERUID
{ {

View File

@ -276,7 +276,7 @@ void VertexShaderManager::SetConstants()
if (bViewportChanged) if (bViewportChanged)
{ {
bViewportChanged = false; bViewportChanged = false;
SetVSConstant4f(C_DEPTHPARAMS,xfregs.rawViewport[5]/ 16777216.0f,xfregs.rawViewport[2]/ 16777216.0f,0.0f,0.0f);
// This is so implementation-dependent that we can't have it here. // This is so implementation-dependent that we can't have it here.
UpdateViewport(); UpdateViewport();
} }
@ -521,14 +521,6 @@ void VertexShaderManager::SetViewport(float* _Viewport, int constantIndex)
{ {
xfregs.rawViewport[constantIndex] = _Viewport[0]; xfregs.rawViewport[constantIndex] = _Viewport[0];
} }
/*//Tino: i think this is not needed so leave this commented till confirmed
// Workaround for paper mario, yep this is bizarre.
for (size_t i = 0; i < ARRAYSIZE(xfregs.rawViewport); ++i)
{
if (*(u32*)(_Viewport + i) == 0x7f800000) // invalid fp number
return;
}
memcpy(xfregs.rawViewport, _Viewport, sizeof(xfregs.rawViewport));*/
bViewportChanged = true; bViewportChanged = true;
} }

View File

@ -93,7 +93,6 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Hacks", "EFBCopyDisable", &bEFBCopyDisable, false); iniFile.Get("Hacks", "EFBCopyDisable", &bEFBCopyDisable, false);
iniFile.Get("Hacks", "EFBCopyDisableHotKey", &bOSDHotKey, 0); iniFile.Get("Hacks", "EFBCopyDisableHotKey", &bOSDHotKey, 0);
iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToTexture, false); iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToTexture, false);
iniFile.Get("Hacks", "EFBVerifyTextureModificationsByCPU",&bVerifyTextureModificationsByCPU,false);
iniFile.Get("Hacks", "EFBScaledCopy", &bCopyEFBScaled, true); iniFile.Get("Hacks", "EFBScaledCopy", &bCopyEFBScaled, true);
iniFile.Get("Hacks", "FIFOBPHack", &bFIFOBPhack, false); iniFile.Get("Hacks", "FIFOBPHack", &bFIFOBPhack, false);
iniFile.Get("Hacks", "ProjectionHack", &iPhackvalue, 0); iniFile.Get("Hacks", "ProjectionHack", &iPhackvalue, 0);
@ -126,8 +125,6 @@ void VideoConfig::GameIniLoad(const char *ini_file)
iniFile.Get("Video", "EFBCopyDisableHotKey", &bOSDHotKey); iniFile.Get("Video", "EFBCopyDisableHotKey", &bOSDHotKey);
if (iniFile.Exists("Video", "EFBToTextureEnable")) if (iniFile.Exists("Video", "EFBToTextureEnable"))
iniFile.Get("Video", "EFBToTextureEnable", &bCopyEFBToTexture); iniFile.Get("Video", "EFBToTextureEnable", &bCopyEFBToTexture);
if (iniFile.Exists("Video", "EFBVerifyTextureModificationsByCPU"))
iniFile.Get("Video", "EFBVerifyTextureModificationsByCPU", &bVerifyTextureModificationsByCPU);
if (iniFile.Exists("Video", "EFBScaledCopy")) if (iniFile.Exists("Video", "EFBScaledCopy"))
iniFile.Get("Video", "EFBScaledCopy", &bCopyEFBScaled); iniFile.Get("Video", "EFBScaledCopy", &bCopyEFBScaled);
if (iniFile.Exists("Video", "SafeTextureCache")) if (iniFile.Exists("Video", "SafeTextureCache"))
@ -203,7 +200,6 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Hacks", "EFBCopyDisable", bEFBCopyDisable); iniFile.Set("Hacks", "EFBCopyDisable", bEFBCopyDisable);
iniFile.Set("Hacks", "EFBCopyDisableHotKey", bOSDHotKey); iniFile.Set("Hacks", "EFBCopyDisableHotKey", bOSDHotKey);
iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToTexture); iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToTexture);
iniFile.Set("Hacks", "EFBVerifyTextureModificationsByCPU", bVerifyTextureModificationsByCPU);
iniFile.Set("Hacks", "EFBScaledCopy", bCopyEFBScaled); iniFile.Set("Hacks", "EFBScaledCopy", bCopyEFBScaled);
iniFile.Set("Hacks", "FIFOBPHack", bFIFOBPhack); iniFile.Set("Hacks", "FIFOBPHack", bFIFOBPhack);
iniFile.Set("Hacks", "ProjectionHack", iPhackvalue); iniFile.Set("Hacks", "ProjectionHack", iPhackvalue);

View File

@ -116,7 +116,6 @@ struct VideoConfig
bool bOSDHotKey; bool bOSDHotKey;
bool bHack; bool bHack;
bool bCopyEFBToTexture; bool bCopyEFBToTexture;
bool bVerifyTextureModificationsByCPU;
bool bCopyEFBScaled; bool bCopyEFBScaled;
bool bSafeTextureCache; bool bSafeTextureCache;
int iSafeTextureCache_ColorSamples; int iSafeTextureCache_ColorSamples;

View File

@ -18,6 +18,8 @@
#pragma once #pragma once
#include "D3DBase.h" #include "D3DBase.h"
#include "VertexShaderGen.h"
#include "PixelShaderGen.h"
#include <stack> #include <stack>
using std::stack; using std::stack;
@ -57,8 +59,8 @@ public:
D3D11_RASTERIZER_DESC rastdesc; D3D11_RASTERIZER_DESC rastdesc;
D3D11_DEPTH_STENCIL_DESC depthdesc; D3D11_DEPTH_STENCIL_DESC depthdesc;
float psconstants[116]; float psconstants[C_PENVCONST_END*4];
float vsconstants[952]; float vsconstants[C_VENVCONST_END*4];
bool vscbufchanged; bool vscbufchanged;
bool pscbufchanged; bool pscbufchanged;

View File

@ -48,7 +48,7 @@ ID3D11InputLayout* VertexShaderCache::GetSimpleInputLayout() { return SimpleLayo
ID3D11InputLayout* VertexShaderCache::GetClearInputLayout() { return ClearLayout; } ID3D11InputLayout* VertexShaderCache::GetClearInputLayout() { return ClearLayout; }
// maps the constant numbers to float indices in the constant buffer // maps the constant numbers to float indices in the constant buffer
unsigned int vs_constant_offset_table[238]; unsigned int vs_constant_offset_table[C_VENVCONST_END];
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{ {
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number] ] = f1; D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number] ] = f1;
@ -164,14 +164,16 @@ void VertexShaderCache::Init()
// these values are hardcoded, they depend on internal D3DCompile behavior // these values are hardcoded, they depend on internal D3DCompile behavior
// TODO: Do this with D3DReflect or something instead // TODO: Do this with D3DReflect or something instead
unsigned int k; unsigned int k;
for (k = 0;k < 64;k++) vs_constant_offset_table[C_TRANSFORMMATRICES+k] = 312+4*k;
for (k = 0;k < 24;k++) vs_constant_offset_table[C_TEXMATRICES+k] = 216+4*k;
for (k = 0;k < 32;k++) vs_constant_offset_table[C_NORMALMATRICES+k] = 568+4*k;
for (k = 0;k < 6;k++) vs_constant_offset_table[C_POSNORMALMATRIX+k] = 0+4*k; for (k = 0;k < 6;k++) vs_constant_offset_table[C_POSNORMALMATRIX+k] = 0+4*k;
for (k = 0;k < 64;k++) vs_constant_offset_table[C_POSTTRANSFORMMATRICES+k] = 696+4*k;
for (k = 0;k < 40;k++) vs_constant_offset_table[C_LIGHTS+k] = 56+4*k;
for (k = 0;k < 4;k++) vs_constant_offset_table[C_MATERIALS+k] = 40+4*k;
for (k = 0;k < 4;k++) vs_constant_offset_table[C_PROJECTION+k] = 24+4*k; for (k = 0;k < 4;k++) vs_constant_offset_table[C_PROJECTION+k] = 24+4*k;
for (k = 0;k < 4;k++) vs_constant_offset_table[C_MATERIALS+k] = 40+4*k;
for (k = 0;k < 40;k++) vs_constant_offset_table[C_LIGHTS+k] = 56+4*k;
for (k = 0;k < 24;k++) vs_constant_offset_table[C_TEXMATRICES+k] = 216+4*k;
for (k = 0;k < 64;k++) vs_constant_offset_table[C_TRANSFORMMATRICES+k] = 312+4*k;
for (k = 0;k < 32;k++) vs_constant_offset_table[C_NORMALMATRICES+k] = 568+4*k;
for (k = 0;k < 64;k++) vs_constant_offset_table[C_POSTTRANSFORMMATRICES+k] = 696+4*k;
for (k = 0;k < 4;k++) vs_constant_offset_table[C_DEPTHPARAMS+k] = 952+4*k;
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX))) if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX)); File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));

View File

@ -60,7 +60,6 @@ BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog)
EVT_CHECKBOX(ID_OVERLAYFPS, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_CHECKBOX(ID_OVERLAYFPS, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_ENABLEEFBCOPY, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_CHECKBOX(ID_ENABLEEFBCOPY, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_RADIOBUTTON(ID_EFBTORAM, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_RADIOBUTTON(ID_EFBTORAM, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_VERIFYTEXTUREMODIFICATIONS, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_RADIOBUTTON(ID_EFBTOTEX, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_RADIOBUTTON(ID_EFBTOTEX, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_ENABLEHOTKEY, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_CHECKBOX(ID_ENABLEHOTKEY, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_WIREFRAME, GFXConfigDialogDX::AdvancedSettingsChanged) EVT_CHECKBOX(ID_WIREFRAME, GFXConfigDialogDX::AdvancedSettingsChanged)
@ -139,7 +138,6 @@ void GFXConfigDialogDX::InitializeGUIValues()
m_CopyEFB->SetValue(!g_Config.bEFBCopyDisable); m_CopyEFB->SetValue(!g_Config.bEFBCopyDisable);
g_Config.bCopyEFBToTexture ? m_Radio_CopyEFBToGL->SetValue(true) : m_Radio_CopyEFBToRAM->SetValue(true); g_Config.bCopyEFBToTexture ? m_Radio_CopyEFBToGL->SetValue(true) : m_Radio_CopyEFBToRAM->SetValue(true);
m_VerifyTextureModification->SetValue(g_Config.bVerifyTextureModificationsByCPU);
m_EnableHotkeys->SetValue(g_Config.bOSDHotKey); m_EnableHotkeys->SetValue(g_Config.bOSDHotKey);
m_WireFrame->SetValue(g_Config.bWireFrame); m_WireFrame->SetValue(g_Config.bWireFrame);
m_EnableXFB->SetValue(g_Config.bUseXFB); m_EnableXFB->SetValue(g_Config.bUseXFB);
@ -301,7 +299,6 @@ void GFXConfigDialogDX::CreateGUIControls()
m_CopyEFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEEFBCOPY, wxT("Enable EFB Copy"), wxDefaultPosition, wxDefaultSize, 0 ); m_CopyEFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEEFBCOPY, wxT("Enable EFB Copy"), wxDefaultPosition, wxDefaultSize, 0 );
m_EnableHotkeys = new wxCheckBox( m_PageAdvanced, ID_ENABLEHOTKEY, wxT("Enable Hotkey"), wxDefaultPosition, wxDefaultSize, 0 ); m_EnableHotkeys = new wxCheckBox( m_PageAdvanced, ID_ENABLEHOTKEY, wxT("Enable Hotkey"), wxDefaultPosition, wxDefaultSize, 0 );
m_Radio_CopyEFBToRAM = new wxRadioButton( m_PageAdvanced, ID_EFBTORAM, wxT("To RAM (accuracy)"), wxDefaultPosition, wxDefaultSize, 0 ); m_Radio_CopyEFBToRAM = new wxRadioButton( m_PageAdvanced, ID_EFBTORAM, wxT("To RAM (accuracy)"), wxDefaultPosition, wxDefaultSize, 0 );
m_VerifyTextureModification = new wxCheckBox( m_PageAdvanced, ID_VERIFYTEXTUREMODIFICATIONS, wxT("Check for textures modified by the cpu"), wxDefaultPosition, wxDefaultSize, 0 );
m_Radio_CopyEFBToGL = new wxRadioButton( m_PageAdvanced, ID_EFBTOTEX, wxT("To Texture (performance, resolution)"), wxDefaultPosition, wxDefaultSize, 0 ); m_Radio_CopyEFBToGL = new wxRadioButton( m_PageAdvanced, ID_EFBTOTEX, wxT("To Texture (performance, resolution)"), wxDefaultPosition, wxDefaultSize, 0 );
m_WireFrame = new wxCheckBox( m_PageAdvanced, ID_WIREFRAME, wxT("Enable Wireframe"), wxDefaultPosition, wxDefaultSize, 0 ); m_WireFrame = new wxCheckBox( m_PageAdvanced, ID_WIREFRAME, wxT("Enable Wireframe"), wxDefaultPosition, wxDefaultSize, 0 );
m_EnableRealXFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEREALXFB, wxT("Enable Real XFB"), wxDefaultPosition, wxDefaultSize, 0 ); m_EnableRealXFB = new wxCheckBox( m_PageAdvanced, ID_ENABLEREALXFB, wxT("Enable Real XFB"), wxDefaultPosition, wxDefaultSize, 0 );
@ -334,12 +331,11 @@ void GFXConfigDialogDX::CreateGUIControls()
sSettings->Add( m_CopyEFB, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); sSettings->Add( m_CopyEFB, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sSettings->Add( m_EnableHotkeys, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxLEFT, 20 ); sSettings->Add( m_EnableHotkeys, wxGBPosition( 1, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxLEFT, 20 );
sSettings->Add( m_Radio_CopyEFBToRAM, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 10 ); sSettings->Add( m_Radio_CopyEFBToRAM, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 10 );
sSettings->Add( m_VerifyTextureModification, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 10 ); sSettings->Add( m_Radio_CopyEFBToGL, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 10 );
sSettings->Add( m_Radio_CopyEFBToGL, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP, 10 );
sSettings->Add( m_WireFrame, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxLEFT, 20 ); sSettings->Add( m_WireFrame, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxLEFT, 20 );
sSettings->Add( m_EnableRealXFB, wxGBPosition( 5, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxLEFT, 20 ); sSettings->Add( m_EnableRealXFB, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxLEFT, 20 );
sSettings->Add( m_EnableXFB, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); sSettings->Add( m_EnableXFB, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sSettings->Add( m_UseNativeMips, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 ); sSettings->Add( m_UseNativeMips, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sbSettings->Add( sSettings, 0, wxEXPAND, 5 ); sbSettings->Add( sSettings, 0, wxEXPAND, 5 );
sAdvanced->Add( sbSettings, 0, wxEXPAND|wxALL, 5 ); sAdvanced->Add( sbSettings, 0, wxEXPAND|wxALL, 5 );
@ -466,9 +462,6 @@ void GFXConfigDialogDX::AdvancedSettingsChanged(wxCommandEvent& event)
break; break;
case ID_EFBTORAM: case ID_EFBTORAM:
g_Config.bCopyEFBToTexture = false; g_Config.bCopyEFBToTexture = false;
case ID_VERIFYTEXTUREMODIFICATIONS:
g_Config.bVerifyTextureModificationsByCPU = m_VerifyTextureModification->IsChecked();
break;
case ID_EFBTOTEX: case ID_EFBTOTEX:
g_Config.bCopyEFBToTexture = true; g_Config.bCopyEFBToTexture = true;
break; break;
@ -532,7 +525,6 @@ void GFXConfigDialogDX::UpdateGUI()
// Disable the Copy to options when EFBCopy is disabled // Disable the Copy to options when EFBCopy is disabled
m_Radio_CopyEFBToRAM->Enable(!g_Config.bEFBCopyDisable); m_Radio_CopyEFBToRAM->Enable(!g_Config.bEFBCopyDisable);
m_VerifyTextureModification->Enable(!g_Config.bEFBCopyDisable && !g_Config.bCopyEFBToTexture);
m_Radio_CopyEFBToGL->Enable(!g_Config.bEFBCopyDisable); m_Radio_CopyEFBToGL->Enable(!g_Config.bEFBCopyDisable);
// Disable/Enable Safe Texture Cache options // Disable/Enable Safe Texture Cache options

View File

@ -112,7 +112,6 @@ class GFXConfigDialogDX : public wxDialog
wxCheckBox *m_OverlayFPS; wxCheckBox *m_OverlayFPS;
wxCheckBox *m_CopyEFB; wxCheckBox *m_CopyEFB;
wxRadioButton *m_Radio_CopyEFBToRAM; wxRadioButton *m_Radio_CopyEFBToRAM;
wxCheckBox *m_VerifyTextureModification;
wxRadioButton *m_Radio_CopyEFBToGL; wxRadioButton *m_Radio_CopyEFBToGL;
wxCheckBox *m_EnableHotkeys; wxCheckBox *m_EnableHotkeys;
wxCheckBox *m_WireFrame; wxCheckBox *m_WireFrame;
@ -150,7 +149,6 @@ class GFXConfigDialogDX : public wxDialog
ID_OVERLAYFPS, ID_OVERLAYFPS,
ID_ENABLEEFBCOPY, ID_ENABLEEFBCOPY,
ID_EFBTORAM, ID_EFBTORAM,
ID_VERIFYTEXTUREMODIFICATIONS,
ID_EFBTOTEX, ID_EFBTOTEX,
ID_ENABLEHOTKEY, ID_ENABLEHOTKEY,
ID_WIREFRAME, ID_WIREFRAME,

View File

@ -266,7 +266,7 @@ void PixelShaderCache::Clear()
iter->second.Destroy(); iter->second.Destroy();
PixelShaders.clear(); PixelShaders.clear();
for (int i = 0; i < (C_COLORMATRIX + 16) * 4; i++) for (int i = 0; i < C_PENVCONST_END * 4; i++)
lastPSconstants[i / 4][i % 4] = -100000000.0f; lastPSconstants[i / 4][i % 4] = -100000000.0f;
memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid)); memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid));
} }

View File

@ -135,7 +135,7 @@ void TextureCache::Cleanup()
if (frameCount > TEXTURE_KILL_THRESHOLD + iter->second.frameCount) if (frameCount > TEXTURE_KILL_THRESHOLD + iter->second.frameCount)
{ {
iter->second.Destroy(false); iter->second.Destroy(false);
iter = textures.erase(iter); textures.erase(iter++);
} }
else else
{ {
@ -160,7 +160,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
u32 texID = address; u32 texID = address;
u64 texHash; u64 texHash;
u32 FullFormat = tex_format; u32 FullFormat = tex_format;
bool TextureIsDinamic = false; bool TextureisDynamic = false;
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
u32 FullFormat = (tex_format | (tlutfmt << 16)); u32 FullFormat = (tex_format | (tlutfmt << 16));
@ -196,9 +196,9 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
if (!g_ActiveConfig.bSafeTextureCache) if (!g_ActiveConfig.bSafeTextureCache)
{ {
if(entry.isRenderTarget || entry.isDinamic) if(entry.isRenderTarget || entry.isDynamic)
{ {
if(!g_ActiveConfig.bCopyEFBToTexture && g_ActiveConfig.bVerifyTextureModificationsByCPU) if(!g_ActiveConfig.bCopyEFBToTexture)
{ {
hash_value = TexDecoder_GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples); hash_value = TexDecoder_GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples);
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
@ -218,19 +218,19 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
} }
else else
{ {
if(entry.isRenderTarget || entry.isDinamic) if(entry.isRenderTarget || entry.isDynamic)
{ {
if(g_ActiveConfig.bCopyEFBToTexture || !g_ActiveConfig.bVerifyTextureModificationsByCPU) if(g_ActiveConfig.bCopyEFBToTexture)
{ {
hash_value = 0; hash_value = 0;
} }
} }
} }
if (((entry.isRenderTarget || entry.isDinamic) && hash_value == entry.hash && address == entry.addr) if (((entry.isRenderTarget || entry.isDynamic) && hash_value == entry.hash && address == entry.addr)
|| ((address == entry.addr) && (hash_value == entry.hash) && FullFormat == entry.fmt/* && entry.MipLevels == maxlevel*/)) || ((address == entry.addr) && (hash_value == entry.hash) && FullFormat == entry.fmt/* && entry.MipLevels == maxlevel*/))
{ {
entry.frameCount = frameCount; entry.frameCount = frameCount;
entry.isDinamic = false; entry.isDynamic = false;
D3D::SetTexture(stage, entry.texture); D3D::SetTexture(stage, entry.texture);
return &entry; return &entry;
} }
@ -239,11 +239,11 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
// Let's reload the new texture data into the same texture, // Let's reload the new texture data into the same texture,
// instead of destroying it and having to create a new one. // instead of destroying it and having to create a new one.
// Might speed up movie playback very, very slightly. // Might speed up movie playback very, very slightly.
TextureIsDinamic = (entry.isRenderTarget || entry.isDinamic) && !g_ActiveConfig.bCopyEFBToTexture; TextureisDynamic = (entry.isRenderTarget || entry.isDynamic) && !g_ActiveConfig.bCopyEFBToTexture;
if (!entry.isRenderTarget && if (!entry.isRenderTarget &&
((!entry.isDinamic && width == entry.w && height==entry.h && FullFormat == entry.fmt /* && entry.MipLevels < maxlevel*/) ((!entry.isDynamic && width == entry.w && height==entry.h && FullFormat == entry.fmt /* && entry.MipLevels < maxlevel*/)
|| (entry.isDinamic && entry.w == width && entry.h == height))) || (entry.isDynamic && entry.w == width && entry.h == height)))
{ {
skip_texture_create = true; skip_texture_create = true;
} }
@ -257,7 +257,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
// Make an entry in the table // Make an entry in the table
TCacheEntry& entry = textures[texID]; TCacheEntry& entry = textures[texID];
entry.isDinamic = TextureIsDinamic; entry.isDynamic = TextureisDynamic;
PC_TexFormat pcfmt = PC_TEX_FMT_NONE; PC_TexFormat pcfmt = PC_TEX_FMT_NONE;
if (g_ActiveConfig.bHiresTextures) if (g_ActiveConfig.bHiresTextures)
@ -313,7 +313,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
} }
entry.oldpixel = ((u32 *)ptr)[0]; entry.oldpixel = ((u32 *)ptr)[0];
if (g_ActiveConfig.bSafeTextureCache || entry.isDinamic) if (g_ActiveConfig.bSafeTextureCache || entry.isDynamic)
entry.hash = hash_value; entry.hash = hash_value;
else else
{ {
@ -403,9 +403,6 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source_rect) void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source_rect)
{ {
int efb_w = source_rect.GetWidth();
int efb_h = source_rect.GetHeight();
int tex_w = (abs(source_rect.GetWidth()) >> bScaleByHalf); int tex_w = (abs(source_rect.GetWidth()) >> bScaleByHalf);
int tex_h = (abs(source_rect.GetHeight()) >> bScaleByHalf); int tex_h = (abs(source_rect.GetHeight()) >> bScaleByHalf);
//compensate the texture grow if supersampling is enabled to conserve memory usage //compensate the texture grow if supersampling is enabled to conserve memory usage
@ -420,14 +417,14 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
TexCache::iterator iter; TexCache::iterator iter;
LPDIRECT3DTEXTURE9 tex = NULL; LPDIRECT3DTEXTURE9 tex = NULL;
iter = textures.find(address); iter = textures.find(address);
bool TextureIsDinamic = false; bool TextureisDynamic = false;
if (iter != textures.end()) if (iter != textures.end())
{ {
if ((iter->second.isRenderTarget && iter->second.Scaledw == Scaledtex_w && iter->second.Scaledh == Scaledtex_h) if ((iter->second.isRenderTarget && iter->second.Scaledw == Scaledtex_w && iter->second.Scaledh == Scaledtex_h)
|| (iter->second.isDinamic && iter->second.w == tex_w && iter->second.h == tex_h)) || (iter->second.isDynamic && iter->second.w == tex_w && iter->second.h == tex_h))
{ {
tex = iter->second.texture; tex = iter->second.texture;
TextureIsDinamic = iter->second.isDinamic; TextureisDynamic = iter->second.isDynamic;
iter->second.frameCount = frameCount; iter->second.frameCount = frameCount;
} }
else else
@ -439,7 +436,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
textures.erase(iter); textures.erase(iter);
} }
} }
if(TextureIsDinamic) if(TextureisDynamic)
{ {
Scaledtex_w = tex_w; Scaledtex_w = tex_w;
Scaledtex_h = tex_h; Scaledtex_h = tex_h;
@ -457,7 +454,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
entry.Scaledh = Scaledtex_h; entry.Scaledh = Scaledtex_h;
entry.fmt = copyfmt; entry.fmt = copyfmt;
entry.isNonPow2 = true; entry.isNonPow2 = true;
entry.isDinamic = false; entry.isDynamic = false;
D3D::dev->CreateTexture(Scaledtex_w, Scaledtex_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &entry.texture, 0); D3D::dev->CreateTexture(Scaledtex_w, Scaledtex_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &entry.texture, 0);
textures[address] = entry; textures[address] = entry;
tex = entry.texture; tex = entry.texture;
@ -468,7 +465,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
// We have to run a pixel shader, for color conversion. // We have to run a pixel shader, for color conversion.
Renderer::ResetAPIState(); // reset any game specific settings Renderer::ResetAPIState(); // reset any game specific settings
if(!TextureIsDinamic || g_ActiveConfig.bCopyEFBToTexture) if(!TextureisDynamic || g_ActiveConfig.bCopyEFBToTexture)
{ {
float colmat[16]= {0.0f}; float colmat[16]= {0.0f};

View File

@ -45,7 +45,7 @@ public:
float scaleX, scaleY; // Hires texutres need this float scaleX, scaleY; // Hires texutres need this
bool isRenderTarget; bool isRenderTarget;
bool isDinamic;// mofified from cpu bool isDynamic;// mofified from cpu
bool isNonPow2; bool isNonPow2;
TCacheEntry() TCacheEntry()

View File

@ -450,10 +450,7 @@ u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture,u32 Sou
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight,readStride, true, bScaleByHalf > 0); EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight,readStride, true, bScaleByHalf > 0);
TextureCache::MakeRangeDynamic(address,size_in_bytes); TextureCache::MakeRangeDynamic(address,size_in_bytes);
u64 Hashvalue = 0; u64 Hashvalue = 0;
if(g_ActiveConfig.bVerifyTextureModificationsByCPU) Hashvalue = TexDecoder_GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
{
Hashvalue = TexDecoder_GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
}
return Hashvalue; return Hashvalue;
} }

View File

@ -243,7 +243,6 @@ void Flush()
} }
} }
u32 nonpow2tex = 0;
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
if (usedtextures & (1 << i)) { if (usedtextures & (1 << i)) {

View File

@ -37,7 +37,7 @@
VertexShaderCache::VSCache VertexShaderCache::vshaders; VertexShaderCache::VSCache VertexShaderCache::vshaders;
const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry; const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry;
static float GC_ALIGNED16(lastVSconstants[C_FOGPARAMS + 8][4]); static float GC_ALIGNED16(lastVSconstants[C_VENVCONST_END][4]);
#define MAX_SSAA_SHADERS 3 #define MAX_SSAA_SHADERS 3
static LPDIRECT3DVERTEXSHADER9 SimpleVertexShader[MAX_SSAA_SHADERS]; static LPDIRECT3DVERTEXSHADER9 SimpleVertexShader[MAX_SSAA_SHADERS];
@ -218,7 +218,7 @@ void VertexShaderCache::Clear()
iter->second.Destroy(); iter->second.Destroy();
vshaders.clear(); vshaders.clear();
for (int i = 0; i < (C_FOGPARAMS + 8) * 4; i++) for (int i = 0; i < (C_VENVCONST_END * 4); i++)
lastVSconstants[i / 4][i % 4] = -100000000.0f; lastVSconstants[i / 4][i % 4] = -100000000.0f;
memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid)); memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid));
} }

View File

@ -45,7 +45,7 @@ GLuint PixelShaderCache::CurrentShader;
bool PixelShaderCache::ShaderEnabled; bool PixelShaderCache::ShaderEnabled;
static FRAGMENTSHADER* pShaderLast = NULL; static FRAGMENTSHADER* pShaderLast = NULL;
static float lastPSconstants[C_COLORMATRIX+16][4]; static float lastPSconstants[C_PENVCONST_END][4];
void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
@ -89,7 +89,7 @@ void PixelShaderCache::Init()
CurrentShader = 0; CurrentShader = 0;
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
for (unsigned int i = 0; i < (C_COLORMATRIX+16) * 4; i++) for (unsigned int i = 0; i < (C_PENVCONST_END) * 4; i++)
lastPSconstants[i/4][i%4] = -100000000.0f; lastPSconstants[i/4][i%4] = -100000000.0f;
memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid)); memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid));

View File

@ -383,10 +383,7 @@ u64 EncodeToRamFromTexture(u32 address,GLuint source_texture,float MValueX,float
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0); EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight, readStride, true, bScaleByHalf > 0);
TextureMngr::MakeRangeDynamic(address,size_in_bytes); TextureMngr::MakeRangeDynamic(address,size_in_bytes);
u64 Hashvalue = 0; u64 Hashvalue = 0;
if(g_ActiveConfig.bVerifyTextureModificationsByCPU) Hashvalue = TexDecoder_GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
{
Hashvalue = TexDecoder_GetHash64(dest_ptr,size_in_bytes,g_ActiveConfig.iSafeTextureCache_ColorSamples);
}
return Hashvalue; return Hashvalue;
} }

View File

@ -285,7 +285,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
u32 texID = address; u32 texID = address;
u64 texHash = 0; u64 texHash = 0;
u32 FullFormat = tex_format; u32 FullFormat = tex_format;
bool TextureIsDinamic = false; bool TextureisDynamic = false;
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
FullFormat = (tex_format | (tlutfmt << 16)); FullFormat = (tex_format | (tlutfmt << 16));
if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures) if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures)
@ -320,9 +320,9 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
if (!g_ActiveConfig.bSafeTextureCache) if (!g_ActiveConfig.bSafeTextureCache)
{ {
if(entry.isRenderTarget || entry.isDinamic) if(entry.isRenderTarget || entry.isDynamic)
{ {
if(!g_ActiveConfig.bCopyEFBToTexture && g_ActiveConfig.bVerifyTextureModificationsByCPU) if(!g_ActiveConfig.bCopyEFBToTexture)
{ {
hash_value = TexDecoder_GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples); hash_value = TexDecoder_GetHash64(ptr,TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, tex_format),g_ActiveConfig.iSafeTextureCache_ColorSamples);
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2)) if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
@ -342,16 +342,16 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
} }
else else
{ {
if(entry.isRenderTarget || entry.isDinamic) if(entry.isRenderTarget || entry.isDynamic)
{ {
if(g_ActiveConfig.bCopyEFBToTexture || !g_ActiveConfig.bVerifyTextureModificationsByCPU) if(g_ActiveConfig.bCopyEFBToTexture)
{ {
hash_value = 0; hash_value = 0;
} }
} }
} }
if (((entry.isRenderTarget || entry.isDinamic) && hash_value == entry.hash && address == entry.addr) if (((entry.isRenderTarget || entry.isDynamic) && hash_value == entry.hash && address == entry.addr)
|| ((address == entry.addr) && (hash_value == entry.hash) && ((int) FullFormat == entry.fmt) && entry.MipLevels >= maxlevel)) || ((address == entry.addr) && (hash_value == entry.hash) && ((int) FullFormat == entry.fmt) && entry.MipLevels >= maxlevel))
{ {
entry.frameCount = frameCount; entry.frameCount = frameCount;
@ -359,7 +359,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
glBindTexture(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture); glBindTexture(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
entry.SetTextureParameters(tm0,tm1); entry.SetTextureParameters(tm0,tm1);
entry.isDinamic = false; entry.isDynamic = false;
return &entry; return &entry;
} }
else else
@ -367,11 +367,11 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
// Let's reload the new texture data into the same texture, // Let's reload the new texture data into the same texture,
// instead of destroying it and having to create a new one. // instead of destroying it and having to create a new one.
// Might speed up movie playback very, very slightly. // Might speed up movie playback very, very slightly.
TextureIsDinamic = (entry.isRenderTarget || entry.isDinamic) && !g_ActiveConfig.bCopyEFBToTexture; TextureisDynamic = (entry.isRenderTarget || entry.isDynamic) && !g_ActiveConfig.bCopyEFBToTexture;
if (!entry.isRenderTarget && ((!entry.isDinamic && if (!entry.isRenderTarget && ((!entry.isDynamic &&
width == entry.w && height == entry.h && width == entry.w && height == entry.h &&
(int)FullFormat == entry.fmt) || (int)FullFormat == entry.fmt) ||
(entry.isDinamic && (entry.isDynamic &&
entry.w == width && entry.h == height))) entry.w == width && entry.h == height)))
{ {
glBindTexture(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture); glBindTexture(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture);
@ -389,7 +389,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
//Make an entry in the table //Make an entry in the table
TCacheEntry& entry = textures[texID]; TCacheEntry& entry = textures[texID];
entry.isDinamic = TextureIsDinamic; entry.isDynamic = TextureisDynamic;
PC_TexFormat dfmt = PC_TEX_FMT_NONE; PC_TexFormat dfmt = PC_TEX_FMT_NONE;
if (g_ActiveConfig.bHiresTextures) if (g_ActiveConfig.bHiresTextures)
@ -416,7 +416,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
entry.oldpixel = ((u32 *)ptr)[0]; entry.oldpixel = ((u32 *)ptr)[0];
if (g_ActiveConfig.bSafeTextureCache || entry.isDinamic) if (g_ActiveConfig.bSafeTextureCache || entry.isDynamic)
entry.hash = hash_value; entry.hash = hash_value;
else else
{ {
@ -574,6 +574,8 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
entry.frameCount = frameCount; entry.frameCount = frameCount;
entry.w = width; entry.w = width;
entry.h = height; entry.h = height;
entry.Scaledw = width;
entry.Scaledh = height;
entry.fmt = FullFormat; entry.fmt = FullFormat;
entry.SetTextureParameters(tm0,tm1); entry.SetTextureParameters(tm0,tm1);
if (g_ActiveConfig.bDumpTextures) // dump texture to file if (g_ActiveConfig.bDumpTextures) // dump texture to file
@ -731,6 +733,12 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
int w = (abs(source_rect.GetWidth()) >> bScaleByHalf); int w = (abs(source_rect.GetWidth()) >> bScaleByHalf);
int h = (abs(source_rect.GetHeight()) >> bScaleByHalf); int h = (abs(source_rect.GetHeight()) >> bScaleByHalf);
float xScale = Renderer::GetTargetScaleX();
float yScale = Renderer::GetTargetScaleY();
int Scaledtex_w = (g_ActiveConfig.bCopyEFBScaled)?((int)(xScale * w)) : w;
int Scaledtex_h = (g_ActiveConfig.bCopyEFBScaled)?((int)(yScale * h)) : h;
GLenum gl_format = GL_RGBA; GLenum gl_format = GL_RGBA;
GLenum gl_iformat = 4; GLenum gl_iformat = 4;
GLenum gl_type = GL_UNSIGNED_BYTE; GLenum gl_type = GL_UNSIGNED_BYTE;
@ -743,16 +751,17 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
glGenTextures(1, (GLuint *)&entry.texture); glGenTextures(1, (GLuint *)&entry.texture);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, gl_iformat, w, h, 0, gl_format, gl_type, NULL); glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, gl_iformat, Scaledtex_w, Scaledtex_h, 0, gl_format, gl_type, NULL);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
entry.isRenderTarget = true; entry.isRenderTarget = true;
entry.isDinamic = false; entry.isDynamic = false;
} }
else else
{ {
_assert_(entry.texture); _assert_(entry.texture);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
if (entry.w == w && entry.h == h && entry.isRectangle) if (((!entry.isDynamic && entry.Scaledw == Scaledtex_w && entry.Scaledh == Scaledtex_h)
|| (entry.isDynamic && entry.w == w && entry.h == h)) && entry.isRectangle)
{ {
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture);
// for some reason mario sunshine errors here... // for some reason mario sunshine errors here...
@ -760,13 +769,18 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
} else { } else {
// Delete existing texture. // Delete existing texture.
if(entry.isDynamic)
{
Scaledtex_h = h;
Scaledtex_w = w;
}
glDeleteTextures(1,(GLuint *)&entry.texture); glDeleteTextures(1,(GLuint *)&entry.texture);
glGenTextures(1, (GLuint *)&entry.texture); glGenTextures(1, (GLuint *)&entry.texture);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, gl_iformat, w, h, 0, gl_format, gl_type, NULL); glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, gl_iformat, Scaledtex_w, Scaledtex_h, 0, gl_format, gl_type, NULL);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
entry.isRenderTarget = true; entry.isRenderTarget = !entry.isDynamic;
entry.isDinamic = false;
} }
} }
@ -786,7 +800,11 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
entry.w = w; entry.w = w;
entry.h = h; entry.h = h;
entry.Scaledw = Scaledtex_w;
entry.Scaledh = Scaledtex_h;
entry.isRectangle = true; entry.isRectangle = true;
entry.scaleX = g_ActiveConfig.bCopyEFBScaled ? xScale : 1.0f;
entry.scaleY = g_ActiveConfig.bCopyEFBScaled ? yScale : 1.0f;
entry.fmt = copyfmt; entry.fmt = copyfmt;
// Make sure to resolve anything we need to read from. // Make sure to resolve anything we need to read from.
@ -796,7 +814,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
// We have to run a pixel shader, for color conversion. // We have to run a pixel shader, for color conversion.
Renderer::ResetAPIState(); // reset any game specific settings Renderer::ResetAPIState(); // reset any game specific settings
if(!entry.isDinamic || g_ActiveConfig.bCopyEFBToTexture) if(!entry.isDynamic || g_ActiveConfig.bCopyEFBToTexture)
{ {
if (s_TempFramebuffer == 0) if (s_TempFramebuffer == 0)
glGenFramebuffersEXT(1, (GLuint *)&s_TempFramebuffer); glGenFramebuffersEXT(1, (GLuint *)&s_TempFramebuffer);
@ -812,7 +830,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
glEnable(GL_TEXTURE_RECTANGLE_ARB); glEnable(GL_TEXTURE_RECTANGLE_ARB);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture); glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
glViewport(0, 0, w, h); glViewport(0, 0, Scaledtex_w, Scaledtex_h);
PixelShaderCache::SetCurrentShader(bFromZBuffer ? PixelShaderCache::GetDepthMatrixProgram() : PixelShaderCache::GetColorMatrixProgram()); PixelShaderCache::SetCurrentShader(bFromZBuffer ? PixelShaderCache::GetDepthMatrixProgram() : PixelShaderCache::GetColorMatrixProgram());
PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation

View File

@ -30,8 +30,8 @@ public:
struct TCacheEntry struct TCacheEntry
{ {
TCacheEntry() : texture(0), addr(0), size_in_bytes(0), hash(0), TCacheEntry() : texture(0), addr(0), size_in_bytes(0), hash(0),
w(0), h(0), MipLevels(0), scaleX(1.0f), scaleY(1.0f), w(0), h(0), MipLevels(0),Scaledw(0), Scaledh(0), scaleX(1.0f), scaleY(1.0f),
isRenderTarget(false), isDinamic(false), isRectangle(true), isRenderTarget(false), isDynamic(false), isRectangle(true),
bHaveMipMaps(false) { mode.hex = 0xFCFCFCFC; } bHaveMipMaps(false) { mode.hex = 0xFCFCFCFC; }
GLuint texture; GLuint texture;
@ -45,12 +45,12 @@ public:
int frameCount; int frameCount;
int w, h, fmt,MipLevels; int w, h, fmt,MipLevels;
int Scaledw, Scaledh;
float scaleX, scaleY; // Hires texutres need this float scaleX, scaleY; // Hires texutres need this
bool isRenderTarget; // if render texture, then rendertex is filled with the direct copy of the render target bool isRenderTarget; // if render texture, then rendertex is filled with the direct copy of the render target
// later conversions would have to convert properly from rendertexfmt to texfmt // later conversions would have to convert properly from rendertexfmt to texfmt
bool isDinamic; // modified from cpu bool isDynamic; // modified from cpu
bool isRectangle; // if nonpow2, use GL_TEXTURE_2D, else GL_TEXTURE_RECTANGLE_NV bool isRectangle; // if nonpow2, use GL_TEXTURE_2D, else GL_TEXTURE_RECTANGLE_NV
bool bHaveMipMaps; bool bHaveMipMaps;

View File

@ -44,7 +44,7 @@ bool VertexShaderCache::ShaderEnabled;
static VERTEXSHADER *pShaderLast = NULL; static VERTEXSHADER *pShaderLast = NULL;
static int s_nMaxVertexInstructions; static int s_nMaxVertexInstructions;
static float GC_ALIGNED16(lastVSconstants[C_FOGPARAMS+8][4]); static float GC_ALIGNED16(lastVSconstants[C_VENVCONST_END][4]);
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{ {
@ -105,7 +105,7 @@ void VertexShaderCache::Init()
glEnable(GL_VERTEX_PROGRAM_ARB); glEnable(GL_VERTEX_PROGRAM_ARB);
ShaderEnabled = true; ShaderEnabled = true;
CurrentShader = 0; CurrentShader = 0;
for (int i = 0; i < (C_FOGPARAMS + 8) * 4; i++) for (int i = 0; i < (C_VENVCONST_END * 4); i++)
lastVSconstants[i / 4][i % 4] = -100000000.0f; lastVSconstants[i / 4][i % 4] = -100000000.0f;
memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid)); memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid));