mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-31 01:59:52 -06:00
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:
@ -18,6 +18,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "VertexShaderGen.h"
|
||||
#include "PixelShaderGen.h"
|
||||
#include <stack>
|
||||
|
||||
using std::stack;
|
||||
@ -57,8 +59,8 @@ public:
|
||||
D3D11_RASTERIZER_DESC rastdesc;
|
||||
D3D11_DEPTH_STENCIL_DESC depthdesc;
|
||||
|
||||
float psconstants[116];
|
||||
float vsconstants[952];
|
||||
float psconstants[C_PENVCONST_END*4];
|
||||
float vsconstants[C_VENVCONST_END*4];
|
||||
bool vscbufchanged;
|
||||
bool pscbufchanged;
|
||||
|
||||
|
@ -48,7 +48,7 @@ ID3D11InputLayout* VertexShaderCache::GetSimpleInputLayout() { return SimpleLayo
|
||||
ID3D11InputLayout* VertexShaderCache::GetClearInputLayout() { return ClearLayout; }
|
||||
|
||||
// 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)
|
||||
{
|
||||
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
|
||||
// TODO: Do this with D3DReflect or something instead
|
||||
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 < 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_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)))
|
||||
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
|
||||
|
@ -59,8 +59,7 @@ BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog)
|
||||
EVT_CHECKBOX(ID_DISABLEFOG, GFXConfigDialogDX::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_OVERLAYFPS, GFXConfigDialogDX::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_ENABLEEFBCOPY, GFXConfigDialogDX::AdvancedSettingsChanged)
|
||||
EVT_RADIOBUTTON(ID_EFBTORAM, GFXConfigDialogDX::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_VERIFYTEXTUREMODIFICATIONS, GFXConfigDialogDX::AdvancedSettingsChanged)
|
||||
EVT_RADIOBUTTON(ID_EFBTORAM, GFXConfigDialogDX::AdvancedSettingsChanged)
|
||||
EVT_RADIOBUTTON(ID_EFBTOTEX, GFXConfigDialogDX::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_ENABLEHOTKEY, GFXConfigDialogDX::AdvancedSettingsChanged)
|
||||
EVT_CHECKBOX(ID_WIREFRAME, GFXConfigDialogDX::AdvancedSettingsChanged)
|
||||
@ -138,8 +137,7 @@ void GFXConfigDialogDX::InitializeGUIValues()
|
||||
m_OverlayFPS->SetValue(g_Config.bShowFPS);
|
||||
|
||||
m_CopyEFB->SetValue(!g_Config.bEFBCopyDisable);
|
||||
g_Config.bCopyEFBToTexture ? m_Radio_CopyEFBToGL->SetValue(true) : m_Radio_CopyEFBToRAM->SetValue(true);
|
||||
m_VerifyTextureModification->SetValue(g_Config.bVerifyTextureModificationsByCPU);
|
||||
g_Config.bCopyEFBToTexture ? m_Radio_CopyEFBToGL->SetValue(true) : m_Radio_CopyEFBToRAM->SetValue(true);
|
||||
m_EnableHotkeys->SetValue(g_Config.bOSDHotKey);
|
||||
m_WireFrame->SetValue(g_Config.bWireFrame);
|
||||
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_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_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_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 );
|
||||
@ -334,12 +331,11 @@ void GFXConfigDialogDX::CreateGUIControls()
|
||||
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_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( 4, 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_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_EnableXFB, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
|
||||
sSettings->Add( m_UseNativeMips, wxGBPosition( 6, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
|
||||
sSettings->Add( m_EnableRealXFB, wxGBPosition( 4, 1 ), wxGBSpan( 1, 1 ), wxEXPAND|wxLEFT, 20 );
|
||||
sSettings->Add( m_EnableXFB, wxGBPosition( 4, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
|
||||
sSettings->Add( m_UseNativeMips, wxGBPosition( 5, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
|
||||
sbSettings->Add( sSettings, 0, wxEXPAND, 5 );
|
||||
sAdvanced->Add( sbSettings, 0, wxEXPAND|wxALL, 5 );
|
||||
|
||||
@ -466,9 +462,6 @@ void GFXConfigDialogDX::AdvancedSettingsChanged(wxCommandEvent& event)
|
||||
break;
|
||||
case ID_EFBTORAM:
|
||||
g_Config.bCopyEFBToTexture = false;
|
||||
case ID_VERIFYTEXTUREMODIFICATIONS:
|
||||
g_Config.bVerifyTextureModificationsByCPU = m_VerifyTextureModification->IsChecked();
|
||||
break;
|
||||
case ID_EFBTOTEX:
|
||||
g_Config.bCopyEFBToTexture = true;
|
||||
break;
|
||||
@ -532,7 +525,6 @@ void GFXConfigDialogDX::UpdateGUI()
|
||||
|
||||
// Disable the Copy to options when EFBCopy is disabled
|
||||
m_Radio_CopyEFBToRAM->Enable(!g_Config.bEFBCopyDisable);
|
||||
m_VerifyTextureModification->Enable(!g_Config.bEFBCopyDisable && !g_Config.bCopyEFBToTexture);
|
||||
m_Radio_CopyEFBToGL->Enable(!g_Config.bEFBCopyDisable);
|
||||
|
||||
// Disable/Enable Safe Texture Cache options
|
||||
|
@ -112,7 +112,6 @@ class GFXConfigDialogDX : public wxDialog
|
||||
wxCheckBox *m_OverlayFPS;
|
||||
wxCheckBox *m_CopyEFB;
|
||||
wxRadioButton *m_Radio_CopyEFBToRAM;
|
||||
wxCheckBox *m_VerifyTextureModification;
|
||||
wxRadioButton *m_Radio_CopyEFBToGL;
|
||||
wxCheckBox *m_EnableHotkeys;
|
||||
wxCheckBox *m_WireFrame;
|
||||
@ -150,7 +149,6 @@ class GFXConfigDialogDX : public wxDialog
|
||||
ID_OVERLAYFPS,
|
||||
ID_ENABLEEFBCOPY,
|
||||
ID_EFBTORAM,
|
||||
ID_VERIFYTEXTUREMODIFICATIONS,
|
||||
ID_EFBTOTEX,
|
||||
ID_ENABLEHOTKEY,
|
||||
ID_WIREFRAME,
|
||||
|
@ -266,7 +266,7 @@ void PixelShaderCache::Clear()
|
||||
iter->second.Destroy();
|
||||
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;
|
||||
memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid));
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ void TextureCache::Cleanup()
|
||||
if (frameCount > TEXTURE_KILL_THRESHOLD + iter->second.frameCount)
|
||||
{
|
||||
iter->second.Destroy(false);
|
||||
iter = textures.erase(iter);
|
||||
textures.erase(iter++);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -160,7 +160,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||
u32 texID = address;
|
||||
u64 texHash;
|
||||
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))
|
||||
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(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);
|
||||
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
|
||||
{
|
||||
if(entry.isRenderTarget || entry.isDinamic)
|
||||
if(entry.isRenderTarget || entry.isDynamic)
|
||||
{
|
||||
if(g_ActiveConfig.bCopyEFBToTexture || !g_ActiveConfig.bVerifyTextureModificationsByCPU)
|
||||
if(g_ActiveConfig.bCopyEFBToTexture)
|
||||
{
|
||||
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*/))
|
||||
{
|
||||
entry.frameCount = frameCount;
|
||||
entry.isDinamic = false;
|
||||
entry.isDynamic = false;
|
||||
D3D::SetTexture(stage, entry.texture);
|
||||
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,
|
||||
// instead of destroying it and having to create a new one.
|
||||
// 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 && width == entry.w && height==entry.h && FullFormat == entry.fmt /* && entry.MipLevels < maxlevel*/)
|
||||
|| (entry.isDinamic && entry.w == width && entry.h == height)))
|
||||
((!entry.isDynamic && width == entry.w && height==entry.h && FullFormat == entry.fmt /* && entry.MipLevels < maxlevel*/)
|
||||
|| (entry.isDynamic && entry.w == width && entry.h == height)))
|
||||
{
|
||||
skip_texture_create = true;
|
||||
}
|
||||
@ -257,7 +257,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||
|
||||
// Make an entry in the table
|
||||
TCacheEntry& entry = textures[texID];
|
||||
entry.isDinamic = TextureIsDinamic;
|
||||
entry.isDynamic = TextureisDynamic;
|
||||
PC_TexFormat pcfmt = PC_TEX_FMT_NONE;
|
||||
|
||||
if (g_ActiveConfig.bHiresTextures)
|
||||
@ -313,7 +313,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||
}
|
||||
|
||||
entry.oldpixel = ((u32 *)ptr)[0];
|
||||
if (g_ActiveConfig.bSafeTextureCache || entry.isDinamic)
|
||||
if (g_ActiveConfig.bSafeTextureCache || entry.isDynamic)
|
||||
entry.hash = hash_value;
|
||||
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)
|
||||
{
|
||||
int efb_w = source_rect.GetWidth();
|
||||
int efb_h = source_rect.GetHeight();
|
||||
|
||||
int tex_w = (abs(source_rect.GetWidth()) >> bScaleByHalf);
|
||||
int tex_h = (abs(source_rect.GetHeight()) >> bScaleByHalf);
|
||||
//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;
|
||||
LPDIRECT3DTEXTURE9 tex = NULL;
|
||||
iter = textures.find(address);
|
||||
bool TextureIsDinamic = false;
|
||||
bool TextureisDynamic = false;
|
||||
if (iter != textures.end())
|
||||
{
|
||||
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;
|
||||
TextureIsDinamic = iter->second.isDinamic;
|
||||
TextureisDynamic = iter->second.isDynamic;
|
||||
iter->second.frameCount = frameCount;
|
||||
}
|
||||
else
|
||||
@ -439,7 +436,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
|
||||
textures.erase(iter);
|
||||
}
|
||||
}
|
||||
if(TextureIsDinamic)
|
||||
if(TextureisDynamic)
|
||||
{
|
||||
Scaledtex_w = tex_w;
|
||||
Scaledtex_h = tex_h;
|
||||
@ -457,7 +454,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
|
||||
entry.Scaledh = Scaledtex_h;
|
||||
entry.fmt = copyfmt;
|
||||
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);
|
||||
textures[address] = entry;
|
||||
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.
|
||||
Renderer::ResetAPIState(); // reset any game specific settings
|
||||
if(!TextureIsDinamic || g_ActiveConfig.bCopyEFBToTexture)
|
||||
if(!TextureisDynamic || g_ActiveConfig.bCopyEFBToTexture)
|
||||
{
|
||||
|
||||
float colmat[16]= {0.0f};
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
float scaleX, scaleY; // Hires texutres need this
|
||||
|
||||
bool isRenderTarget;
|
||||
bool isDinamic;// mofified from cpu
|
||||
bool isDynamic;// mofified from cpu
|
||||
bool isNonPow2;
|
||||
|
||||
TCacheEntry()
|
||||
|
@ -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);
|
||||
TextureCache::MakeRangeDynamic(address,size_in_bytes);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,6 @@ void Flush()
|
||||
}
|
||||
}
|
||||
|
||||
u32 nonpow2tex = 0;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (usedtextures & (1 << i)) {
|
||||
|
@ -37,7 +37,7 @@
|
||||
VertexShaderCache::VSCache VertexShaderCache::vshaders;
|
||||
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
|
||||
|
||||
static LPDIRECT3DVERTEXSHADER9 SimpleVertexShader[MAX_SSAA_SHADERS];
|
||||
@ -218,7 +218,7 @@ void VertexShaderCache::Clear()
|
||||
iter->second.Destroy();
|
||||
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;
|
||||
memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid));
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ GLuint PixelShaderCache::CurrentShader;
|
||||
bool PixelShaderCache::ShaderEnabled;
|
||||
|
||||
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)
|
||||
@ -89,7 +89,7 @@ void PixelShaderCache::Init()
|
||||
CurrentShader = 0;
|
||||
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;
|
||||
memset(&last_pixel_shader_uid, 0xFF, sizeof(last_pixel_shader_uid));
|
||||
|
||||
|
@ -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);
|
||||
TextureMngr::MakeRangeDynamic(address,size_in_bytes);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||
u32 texID = address;
|
||||
u64 texHash = 0;
|
||||
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))
|
||||
FullFormat = (tex_format | (tlutfmt << 16));
|
||||
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(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);
|
||||
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
|
||||
{
|
||||
if(entry.isRenderTarget || entry.isDinamic)
|
||||
if(entry.isRenderTarget || entry.isDynamic)
|
||||
{
|
||||
if(g_ActiveConfig.bCopyEFBToTexture || !g_ActiveConfig.bVerifyTextureModificationsByCPU)
|
||||
if(g_ActiveConfig.bCopyEFBToTexture)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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);
|
||||
GL_REPORT_ERRORD();
|
||||
entry.SetTextureParameters(tm0,tm1);
|
||||
entry.isDinamic = false;
|
||||
entry.isDynamic = false;
|
||||
return &entry;
|
||||
}
|
||||
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,
|
||||
// instead of destroying it and having to create a new one.
|
||||
// Might speed up movie playback very, very slightly.
|
||||
TextureIsDinamic = (entry.isRenderTarget || entry.isDinamic) && !g_ActiveConfig.bCopyEFBToTexture;
|
||||
if (!entry.isRenderTarget && ((!entry.isDinamic &&
|
||||
TextureisDynamic = (entry.isRenderTarget || entry.isDynamic) && !g_ActiveConfig.bCopyEFBToTexture;
|
||||
if (!entry.isRenderTarget && ((!entry.isDynamic &&
|
||||
width == entry.w && height == entry.h &&
|
||||
(int)FullFormat == entry.fmt) ||
|
||||
(entry.isDinamic &&
|
||||
(entry.isDynamic &&
|
||||
entry.w == width && entry.h == height)))
|
||||
{
|
||||
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
|
||||
TCacheEntry& entry = textures[texID];
|
||||
entry.isDinamic = TextureIsDinamic;
|
||||
entry.isDynamic = TextureisDynamic;
|
||||
PC_TexFormat dfmt = PC_TEX_FMT_NONE;
|
||||
|
||||
if (g_ActiveConfig.bHiresTextures)
|
||||
@ -416,7 +416,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||
|
||||
entry.oldpixel = ((u32 *)ptr)[0];
|
||||
|
||||
if (g_ActiveConfig.bSafeTextureCache || entry.isDinamic)
|
||||
if (g_ActiveConfig.bSafeTextureCache || entry.isDynamic)
|
||||
entry.hash = hash_value;
|
||||
else
|
||||
{
|
||||
@ -574,6 +574,8 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||
entry.frameCount = frameCount;
|
||||
entry.w = width;
|
||||
entry.h = height;
|
||||
entry.Scaledw = width;
|
||||
entry.Scaledh = height;
|
||||
entry.fmt = FullFormat;
|
||||
entry.SetTextureParameters(tm0,tm1);
|
||||
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 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_iformat = 4;
|
||||
GLenum gl_type = GL_UNSIGNED_BYTE;
|
||||
@ -743,16 +751,17 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||
glGenTextures(1, (GLuint *)&entry.texture);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, entry.texture);
|
||||
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();
|
||||
entry.isRenderTarget = true;
|
||||
entry.isDinamic = false;
|
||||
entry.isDynamic = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_assert_(entry.texture);
|
||||
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);
|
||||
// for some reason mario sunshine errors here...
|
||||
@ -760,13 +769,18 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||
GL_REPORT_ERRORD();
|
||||
} else {
|
||||
// Delete existing texture.
|
||||
if(entry.isDynamic)
|
||||
{
|
||||
Scaledtex_h = h;
|
||||
Scaledtex_w = w;
|
||||
}
|
||||
|
||||
glDeleteTextures(1,(GLuint *)&entry.texture);
|
||||
glGenTextures(1, (GLuint *)&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();
|
||||
entry.isRenderTarget = true;
|
||||
entry.isDinamic = false;
|
||||
entry.isRenderTarget = !entry.isDynamic;
|
||||
}
|
||||
}
|
||||
|
||||
@ -786,7 +800,11 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||
|
||||
entry.w = w;
|
||||
entry.h = h;
|
||||
entry.Scaledw = Scaledtex_w;
|
||||
entry.Scaledh = Scaledtex_h;
|
||||
entry.isRectangle = true;
|
||||
entry.scaleX = g_ActiveConfig.bCopyEFBScaled ? xScale : 1.0f;
|
||||
entry.scaleY = g_ActiveConfig.bCopyEFBScaled ? yScale : 1.0f;
|
||||
entry.fmt = copyfmt;
|
||||
|
||||
// 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.
|
||||
Renderer::ResetAPIState(); // reset any game specific settings
|
||||
if(!entry.isDinamic || g_ActiveConfig.bCopyEFBToTexture)
|
||||
if(!entry.isDynamic || g_ActiveConfig.bCopyEFBToTexture)
|
||||
{
|
||||
if (s_TempFramebuffer == 0)
|
||||
glGenFramebuffersEXT(1, (GLuint *)&s_TempFramebuffer);
|
||||
@ -812,7 +830,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
|
||||
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||
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());
|
||||
PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation
|
||||
|
@ -30,8 +30,8 @@ public:
|
||||
struct TCacheEntry
|
||||
{
|
||||
TCacheEntry() : texture(0), addr(0), size_in_bytes(0), hash(0),
|
||||
w(0), h(0), MipLevels(0), scaleX(1.0f), scaleY(1.0f),
|
||||
isRenderTarget(false), isDinamic(false), isRectangle(true),
|
||||
w(0), h(0), MipLevels(0),Scaledw(0), Scaledh(0), scaleX(1.0f), scaleY(1.0f),
|
||||
isRenderTarget(false), isDynamic(false), isRectangle(true),
|
||||
bHaveMipMaps(false) { mode.hex = 0xFCFCFCFC; }
|
||||
|
||||
GLuint texture;
|
||||
@ -42,15 +42,15 @@ public:
|
||||
u32 oldpixel; // used for simple cleanup
|
||||
TexMode0 mode; // current filter and clamp modes that texture is set to
|
||||
TexMode1 mode1; // current filter and clamp modes that texture is set to
|
||||
|
||||
|
||||
int frameCount;
|
||||
int w, h, fmt,MipLevels;
|
||||
|
||||
int Scaledw, Scaledh;
|
||||
float scaleX, scaleY; // Hires texutres need this
|
||||
|
||||
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
|
||||
bool isDinamic; // modified from cpu
|
||||
bool isDynamic; // modified from cpu
|
||||
bool isRectangle; // if nonpow2, use GL_TEXTURE_2D, else GL_TEXTURE_RECTANGLE_NV
|
||||
bool bHaveMipMaps;
|
||||
|
||||
|
@ -44,7 +44,7 @@ bool VertexShaderCache::ShaderEnabled;
|
||||
|
||||
static VERTEXSHADER *pShaderLast = NULL;
|
||||
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)
|
||||
{
|
||||
@ -105,7 +105,7 @@ void VertexShaderCache::Init()
|
||||
glEnable(GL_VERTEX_PROGRAM_ARB);
|
||||
ShaderEnabled = true;
|
||||
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;
|
||||
memset(&last_vertex_shader_uid, 0xFF, sizeof(last_vertex_shader_uid));
|
||||
|
||||
|
Reference in New Issue
Block a user