git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5629 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
0af55bd85b
commit
b20c04aa45
|
@ -1332,7 +1332,7 @@ void Renderer::SetSamplerState(int stage, int texindex)
|
||||||
min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
||||||
mag = tm0.mag_filter ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
mag = tm0.mag_filter ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
||||||
mip = (tm0.min_filter == 8)?D3DTEXF_NONE:d3dMipFilters[tm0.min_filter & 3];
|
mip = (tm0.min_filter == 8)?D3DTEXF_NONE:d3dMipFilters[tm0.min_filter & 3];
|
||||||
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 5) == 0)) mip = D3DTEXF_NONE;
|
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0)) mip = D3DTEXF_NONE;
|
||||||
}
|
}
|
||||||
if (texindex)
|
if (texindex)
|
||||||
stage += 4;
|
stage += 4;
|
||||||
|
@ -1350,7 +1350,7 @@ void Renderer::SetSamplerState(int stage, int texindex)
|
||||||
D3D::SetSamplerState(stage, D3DSAMP_ADDRESSV, d3dClamps[tm0.wrap_t]);
|
D3D::SetSamplerState(stage, D3DSAMP_ADDRESSV, d3dClamps[tm0.wrap_t]);
|
||||||
float lodbias = tm0.lod_bias / 32.0f;
|
float lodbias = tm0.lod_bias / 32.0f;
|
||||||
D3D::SetSamplerState(stage,D3DSAMP_MIPMAPLODBIAS,*(DWORD*)&lodbias);
|
D3D::SetSamplerState(stage,D3DSAMP_MIPMAPLODBIAS,*(DWORD*)&lodbias);
|
||||||
D3D::SetSamplerState(stage,D3DSAMP_MAXMIPLEVEL,tm1.min_lod>>5);
|
D3D::SetSamplerState(stage,D3DSAMP_MAXMIPLEVEL,tm1.min_lod>>4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetInterlacingMode()
|
void Renderer::SetInterlacingMode()
|
||||||
|
|
|
@ -188,7 +188,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||||
if (!g_ActiveConfig.bSafeTextureCache)
|
if (!g_ActiveConfig.bSafeTextureCache)
|
||||||
hash_value = ((u32 *)ptr)[0];
|
hash_value = ((u32 *)ptr)[0];
|
||||||
|
|
||||||
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash) && FullFormat == entry.fmt && entry.MipLevels <= maxlevel))
|
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash) && FullFormat == entry.fmt/* && entry.MipLevels == maxlevel*/))
|
||||||
{
|
{
|
||||||
entry.frameCount = frameCount;
|
entry.frameCount = frameCount;
|
||||||
D3D::SetTexture(stage, entry.texture);
|
D3D::SetTexture(stage, entry.texture);
|
||||||
|
@ -200,7 +200,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||||
// 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.
|
||||||
|
|
||||||
if (width == entry.w && height==entry.h && FullFormat == entry.fmt && entry.MipLevels == maxlevel)
|
if (width == entry.w && height==entry.h && FullFormat == entry.fmt/* && entry.MipLevels < maxlevel*/)
|
||||||
{
|
{
|
||||||
skip_texture_create = true;
|
skip_texture_create = true;
|
||||||
}
|
}
|
||||||
|
@ -284,8 +284,8 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||||
entry.isNonPow2 = false;
|
entry.isNonPow2 = false;
|
||||||
int TexLevels = (width > height)?width:height;
|
int TexLevels = (width > height)?width:height;
|
||||||
TexLevels = (isPow2 && UseNativeMips && (maxlevel > 0)) ? (int)(log((double)TexLevels)/log((double)2)) + 1 : ((isPow2)? 0 : 1);
|
TexLevels = (isPow2 && UseNativeMips && (maxlevel > 0)) ? (int)(log((double)TexLevels)/log((double)2)) + 1 : ((isPow2)? 0 : 1);
|
||||||
if(TexLevels > maxlevel && maxlevel > 0)
|
if(TexLevels > (maxlevel + 1) && maxlevel > 0)
|
||||||
TexLevels = maxlevel;
|
TexLevels = (maxlevel + 1);
|
||||||
entry.MipLevels = maxlevel;
|
entry.MipLevels = maxlevel;
|
||||||
if (!skip_texture_create)
|
if (!skip_texture_create)
|
||||||
{
|
{
|
||||||
|
|
|
@ -256,7 +256,7 @@ void Flush()
|
||||||
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
|
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
|
||||||
tex.texTlut[i&3].tlut_format,
|
tex.texTlut[i&3].tlut_format,
|
||||||
(tex.texMode0[i&3].min_filter & 3) && (tex.texMode0[i&3].min_filter != 8) && g_ActiveConfig.bUseNativeMips,
|
(tex.texMode0[i&3].min_filter & 3) && (tex.texMode0[i&3].min_filter != 8) && g_ActiveConfig.bUseNativeMips,
|
||||||
(tex.texMode1[i&3].max_lod >> 5));
|
(tex.texMode1[i&3].max_lod >> 4));
|
||||||
|
|
||||||
if (tentry) {
|
if (tentry) {
|
||||||
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0);
|
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0);
|
||||||
|
|
|
@ -84,6 +84,9 @@ void SetMultiPSConstant4fv(int const_number, int count, const float *f)
|
||||||
|
|
||||||
void PixelShaderCache::Init()
|
void PixelShaderCache::Init()
|
||||||
{
|
{
|
||||||
|
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||||
|
ShaderEnabled = true;
|
||||||
|
CurrentShader = 0;
|
||||||
GL_REPORT_ERRORD();
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
for (int i = 0; i < (C_COLORMATRIX+16) * 4; i++)
|
for (int i = 0; i < (C_COLORMATRIX+16) * 4; i++)
|
||||||
|
|
|
@ -557,9 +557,10 @@ void Renderer::ResetAPIState()
|
||||||
{
|
{
|
||||||
// Gets us to a reasonably sane state where it's possible to do things like
|
// Gets us to a reasonably sane state where it's possible to do things like
|
||||||
// image copies with textured quads, etc.
|
// image copies with textured quads, etc.
|
||||||
|
glDisable(GL_VERTEX_PROGRAM_ARB);// needed by nvidia cards to avoid texture problems
|
||||||
|
glDisable(GL_FRAGMENT_PROGRAM_ARB);// needed by nvidia cards to avoid texture problems
|
||||||
VertexShaderCache::DisableShader();
|
VertexShaderCache::DisableShader();
|
||||||
PixelShaderCache::DisableShader();
|
PixelShaderCache::DisableShader();
|
||||||
|
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
|
@ -590,8 +591,9 @@ void Renderer::RestoreAPIState()
|
||||||
SetColorMask();
|
SetColorMask();
|
||||||
SetBlendMode(true);
|
SetBlendMode(true);
|
||||||
|
|
||||||
VertexShaderCache::SetCurrentShader(0);
|
|
||||||
glEnable(GL_VERTEX_PROGRAM_ARB);// needed by nvidia cards o avoid texture problems
|
glEnable(GL_VERTEX_PROGRAM_ARB);// needed by nvidia cards o avoid texture problems
|
||||||
|
glEnable(GL_FRAGMENT_PROGRAM_ARB);// needed by nvidia cards o avoid texture problems
|
||||||
|
VertexShaderCache::SetCurrentShader(0);
|
||||||
PixelShaderCache::SetCurrentShader(0);
|
PixelShaderCache::SetCurrentShader(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,9 +132,9 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode,TexMode1 &
|
||||||
if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4)
|
if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4)
|
||||||
mode.min_filter += 4; // take equivalent forced linear
|
mode.min_filter += 4; // take equivalent forced linear
|
||||||
int filt = newmode.min_filter;
|
int filt = newmode.min_filter;
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt & (((newmode1.max_lod >> 5) > 0)?7:4)]);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt & 7]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, newmode1.min_lod >> 5);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, newmode1.min_lod >> 4);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, newmode1.max_lod >> 5);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, newmode1.max_lod >> 4);
|
||||||
glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, (newmode.lod_bias/32.0f));
|
glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, (newmode.lod_bias/32.0f));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -259,9 +259,8 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
|
|
||||||
TexMode0 &tm0 = bpmem.tex[texstage >> 2].texMode0[texstage & 3];
|
TexMode0 &tm0 = bpmem.tex[texstage >> 2].texMode0[texstage & 3];
|
||||||
TexMode1 &tm1 = bpmem.tex[texstage >> 2].texMode1[texstage & 3];
|
TexMode1 &tm1 = bpmem.tex[texstage >> 2].texMode1[texstage & 3];
|
||||||
|
int maxlevel = (tm1.max_lod >> 4);
|
||||||
bool UseNativeMips = (tm0.min_filter & 3) && (tm0.min_filter != 8) && g_ActiveConfig.bUseNativeMips;
|
bool UseNativeMips = (tm0.min_filter & 3) && (tm0.min_filter != 8) && g_ActiveConfig.bUseNativeMips;
|
||||||
int maxlevel = tm1.max_lod >> 4;//this ir realy strange should be 5 but that breaks some textures
|
|
||||||
|
|
||||||
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
||||||
int bsw = TexDecoder_GetBlockWidthInTexels(tex_format) - 1;
|
int bsw = TexDecoder_GetBlockWidthInTexels(tex_format) - 1;
|
||||||
|
@ -309,14 +308,14 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
if (!g_ActiveConfig.bSafeTextureCache)
|
if (!g_ActiveConfig.bSafeTextureCache)
|
||||||
hash_value = ((u32 *)ptr)[0];
|
hash_value = ((u32 *)ptr)[0];
|
||||||
|
|
||||||
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash) && ((int) FullFormat == entry.fmt) && maxlevel <= entry.MipLevels ))
|
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash) && ((int) FullFormat == entry.fmt && entry.MipLevels >= maxlevel)))
|
||||||
{
|
{
|
||||||
entry.frameCount = frameCount;
|
entry.frameCount = frameCount;
|
||||||
glEnable(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D);
|
glEnable(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D);
|
||||||
// entry.isRectangle ? TextureMngr::EnableTex2D(texstage) : TextureMngr::EnableTexRECT(texstage);
|
// entry.isRectangle ? TextureMngr::EnableTex2D(texstage) : TextureMngr::EnableTexRECT(texstage);
|
||||||
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();
|
||||||
if (entry.mode.hex != tm0.hex || entry.mode1.hex != tm1.hex)
|
//if (entry.mode.hex != tm0.hex || entry.mode1.hex != tm1.hex)//gl needs this refreshed for every texture to work right
|
||||||
entry.SetTextureParameters(tm0,tm1);
|
entry.SetTextureParameters(tm0,tm1);
|
||||||
//DebugLog("%cC addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_ActiveConfig.bSafeTextureCache ? 'S' : 'U'
|
//DebugLog("%cC addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_ActiveConfig.bSafeTextureCache ? 'S' : 'U'
|
||||||
// , address, tex_format, entry.hash, width, height);
|
// , address, tex_format, entry.hash, width, height);
|
||||||
|
@ -327,11 +326,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.
|
||||||
if (width == entry.w && height == entry.h && (int) FullFormat == entry.fmt && maxlevel <= entry.MipLevels )
|
if (width == entry.w && height == entry.h && (int) FullFormat == entry.fmt)
|
||||||
{
|
{
|
||||||
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();
|
||||||
if (entry.mode.hex != tm0.hex || entry.mode1.hex != tm1.hex)
|
//if (entry.mode.hex != tm0.hex || entry.mode1.hex != tm1.hex) //gl needs this refreshed for every texture to work right
|
||||||
entry.SetTextureParameters(tm0,tm1);
|
entry.SetTextureParameters(tm0,tm1);
|
||||||
skip_texture_create = true;
|
skip_texture_create = true;
|
||||||
}
|
}
|
||||||
|
@ -395,9 +394,9 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
|
|
||||||
bool isPow2 = !((width & (width - 1)) || (height & (height - 1)));
|
bool isPow2 = !((width & (width - 1)) || (height & (height - 1)));
|
||||||
int TexLevels = (width > height)?width:height;
|
int TexLevels = (width > height)?width:height;
|
||||||
TexLevels = (isPow2 && UseNativeMips && (maxlevel > 0)) ? (int)(log((double)TexLevels)/log((double)2)) + 1 : (isPow2? 0 : 1);
|
TexLevels = (isPow2 && UseNativeMips && (maxlevel > 0)) ? (int)(log((double)TexLevels)/log((double)2))+ 1 : (isPow2? 0 : 1);
|
||||||
if(TexLevels > maxlevel && maxlevel > 0)
|
if(TexLevels > (maxlevel + 1) && maxlevel > 0)
|
||||||
TexLevels = maxlevel;
|
TexLevels = (maxlevel + 1);
|
||||||
entry.MipLevels = maxlevel;
|
entry.MipLevels = maxlevel;
|
||||||
bool GenerateMipmaps = TexLevels > 1 || TexLevels == 0;
|
bool GenerateMipmaps = TexLevels > 1 || TexLevels == 0;
|
||||||
entry.bHaveMipMaps = GenerateMipmaps;
|
entry.bHaveMipMaps = GenerateMipmaps;
|
||||||
|
|
|
@ -102,14 +102,16 @@ void SetMultiVSConstant3fv(int const_number, int count, const float *f)
|
||||||
|
|
||||||
void VertexShaderCache::Init()
|
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_FOGPARAMS + 8) * 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));
|
||||||
|
|
||||||
s_displayCompileAlert = true;
|
s_displayCompileAlert = true;
|
||||||
|
|
||||||
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, (GLint *)&s_nMaxVertexInstructions);
|
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, (GLint *)&s_nMaxVertexInstructions);
|
||||||
SetCurrentShader(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexShaderCache::Shutdown()
|
void VertexShaderCache::Shutdown()
|
||||||
|
|
Loading…
Reference in New Issue