improve texture mipmap count
GL_TEXTURE_MAX_LEVEL set how many mipmaps should be allocated, but all of them must be created. GL_TEXTURE_MAX_LOD set how many mipmaps may be used.
This commit is contained in:
parent
8a7f1e9264
commit
b778b86e26
|
@ -214,7 +214,7 @@ TextureCache::TCacheEntryBase* TextureCache::CreateTexture(unsigned int width,
|
||||||
entry.gl_type = gl_type;
|
entry.gl_type = gl_type;
|
||||||
entry.pcfmt = pcfmt;
|
entry.pcfmt = pcfmt;
|
||||||
|
|
||||||
entry.bHaveMipMaps = tex_levels != 1;
|
entry.m_tex_levels = tex_levels;
|
||||||
|
|
||||||
return &entry;
|
return &entry;
|
||||||
}
|
}
|
||||||
|
@ -224,21 +224,19 @@ void TextureCache::TCacheEntry::Load(unsigned int width, unsigned int height,
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
//GL_REPORT_ERRORD();
|
//GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
if(level == 0 && m_tex_levels != 0)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, m_tex_levels - 1);
|
||||||
|
|
||||||
if (pcfmt != PC_TEX_FMT_DXT1)
|
if (pcfmt != PC_TEX_FMT_DXT1)
|
||||||
{
|
{
|
||||||
if (expanded_width != width)
|
if (expanded_width != width)
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, expanded_width);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, expanded_width);
|
||||||
|
|
||||||
if (bHaveMipMaps && autogen_mips)
|
glTexImage2D(GL_TEXTURE_2D, level, gl_iformat, width, height, 0, gl_format, gl_type, temp);
|
||||||
{
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, level, gl_iformat, width, height, 0, gl_format, gl_type, temp);
|
if (autogen_mips)
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, level, gl_iformat, width, height, 0, gl_format, gl_type, temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (expanded_width != width)
|
if (expanded_width != width)
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
@ -263,12 +261,9 @@ TextureCache::TCacheEntryBase* TextureCache::CreateRenderTargetTexture(
|
||||||
gl_format = GL_RGBA,
|
gl_format = GL_RGBA,
|
||||||
gl_iformat = GL_RGBA,
|
gl_iformat = GL_RGBA,
|
||||||
gl_type = GL_UNSIGNED_BYTE;
|
gl_type = GL_UNSIGNED_BYTE;
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
entry->m_tex_levels = 1;
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, gl_iformat, scaled_tex_w, scaled_tex_h, 0, gl_format, gl_type, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, gl_iformat, scaled_tex_w, scaled_tex_h, 0, gl_format, gl_type, NULL);
|
||||||
|
|
||||||
|
@ -424,7 +419,7 @@ void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, co
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||||
(newmode.mag_filter || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST);
|
(newmode.mag_filter || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST);
|
||||||
|
|
||||||
if (bHaveMipMaps)
|
if (m_tex_levels != 1)
|
||||||
{
|
{
|
||||||
// TODO: not used anywhere
|
// TODO: not used anywhere
|
||||||
if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4)
|
if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4)
|
||||||
|
@ -432,8 +427,8 @@ void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, co
|
||||||
|
|
||||||
int filt = newmode.min_filter;
|
int filt = newmode.min_filter;
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt & 7]);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt & 7]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, newmode1.min_lod >> 4);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, newmode1.min_lod >> 4);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, newmode1.max_lod >> 4);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, newmode1.max_lod >> 4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||||
|
|
|
@ -46,7 +46,7 @@ private:
|
||||||
int gl_iformat;
|
int gl_iformat;
|
||||||
int gl_type;
|
int gl_type;
|
||||||
|
|
||||||
bool bHaveMipMaps;
|
int m_tex_levels;
|
||||||
|
|
||||||
//TexMode0 mode; // current filter and clamp modes that texture is set to
|
//TexMode0 mode; // current filter and clamp modes that texture is set to
|
||||||
//TexMode1 mode1; // current filter and clamp modes that texture is set to
|
//TexMode1 mode1; // current filter and clamp modes that texture is set to
|
||||||
|
|
Loading…
Reference in New Issue