Fix showing savestate screenshots (needed mips)

This commit is contained in:
Henrik Rydgård 2017-12-14 17:08:45 +01:00
parent 1241abc887
commit 7c17cb6754
5 changed files with 20 additions and 26 deletions

View File

@ -651,12 +651,13 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry, bool replaceImag
// Mipmapping only enable when texture scaling disable
int texMaxLevel = 0;
bool genMips = false;
if (maxLevel > 0 && scaleFactor == 1) {
if (gstate_c.Supports(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) {
if (badMipSizes) {
// WARN_LOG(G3D, "Bad mipmap for texture sized %dx%dx%d - autogenerating", w, h, (int)format);
if (canAutoGen) {
render_->GenerateMipmap();
genMips = true;
} else {
texMaxLevel = 0;
maxLevel = 0;
@ -671,7 +672,7 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry, bool replaceImag
// Avoid PowerVR driver bug
if (canAutoGen && w > 1 && h > 1 && !(h > w && (gl_extensions.bugs & BUG_PVR_GENMIPMAP_HEIGHT_GREATER))) { // Really! only seems to fail if height > width
// NOTICE_LOG(G3D, "Generating mipmap for texture sized %dx%d%d", w, h, (int)format);
render_->GenerateMipmap();
genMips = true;
} else {
maxLevel = 0;
}
@ -689,7 +690,7 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry, bool replaceImag
entry->SetAlphaStatus(TexCacheEntry::TexStatus(replaced.AlphaStatus()));
}
render_->FinalizeTexture(entry->textureName, texMaxLevel);
render_->FinalizeTexture(entry->textureName, texMaxLevel, genMips);
// This will rebind it, but that's okay.
// Need to actually bind it now - it might only have gotten bound in the init phase.

View File

@ -183,10 +183,10 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps) {
glTexImage2D(tex->target, step.texture_image.level, step.texture_image.internalFormat, step.texture_image.width, step.texture_image.height, 0, step.texture_image.format, step.texture_image.type, step.texture_image.data);
delete[] step.texture_image.data;
CHECK_GL_ERROR_IF_DEBUG();
glTexParameteri(step.texture_finalize.texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(step.texture_finalize.texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(step.texture_finalize.texture->target, GL_TEXTURE_MAG_FILTER, step.texture_image.linearFilter ? GL_LINEAR : GL_NEAREST);
glTexParameteri(step.texture_finalize.texture->target, GL_TEXTURE_MIN_FILTER, step.texture_image.linearFilter ? GL_LINEAR : GL_NEAREST);
glTexParameteri(tex->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(tex->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(tex->target, GL_TEXTURE_MAG_FILTER, step.texture_image.linearFilter ? GL_LINEAR : GL_NEAREST);
glTexParameteri(tex->target, GL_TEXTURE_MIN_FILTER, step.texture_image.linearFilter ? GL_LINEAR : GL_NEAREST);
break;
}
case GLRInitStepType::TEXTURE_FINALIZE:
@ -196,7 +196,10 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps) {
glBindTexture(tex->target, tex->texture);
boundTexture = tex->texture;
}
glTexParameteri(step.texture_finalize.texture->target, GL_TEXTURE_MAX_LEVEL, step.texture_finalize.maxLevel);
glTexParameteri(tex->target, GL_TEXTURE_MAX_LEVEL, step.texture_finalize.maxLevel);
if (step.texture_finalize.genMips) {
glGenerateMipmap(tex->target);
}
break;
}
default:

View File

@ -233,6 +233,7 @@ struct GLRInitStep {
struct {
GLRTexture *texture;
int maxLevel;
bool genMips;
} texture_finalize;
};
};

View File

@ -317,10 +317,11 @@ public:
initSteps_.push_back(step);
}
void FinalizeTexture(GLRTexture *texture, int maxLevels) {
void FinalizeTexture(GLRTexture *texture, int maxLevels, bool genMips) {
GLRInitStep step{ GLRInitStepType::TEXTURE_FINALIZE };
step.texture_finalize.texture = texture;
step.texture_finalize.maxLevel = maxLevels;
step.texture_finalize.genMips = genMips;
initSteps_.push_back(step);
}
@ -374,12 +375,6 @@ public:
curRenderStep_->commands.push_back(data);
}
void GenerateMipmap() {
_dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
GLRRenderData data{ GLRRenderCommand::GENMIPS };
curRenderStep_->commands.push_back(data);
}
void SetDepth(bool enabled, bool write, GLenum func) {
_dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER);
GLRRenderData data{ GLRRenderCommand::DEPTH };

View File

@ -598,8 +598,6 @@ public:
render_->BindTexture(stage, tex_);
}
void AutoGenMipmaps();
private:
void SetImageData(int x, int y, int z, int width, int height, int depth, int level, int stride, const uint8_t *data);
@ -638,10 +636,14 @@ OpenGLTexture::OpenGLTexture(GLRenderManager *render, const TextureDesc &desc) :
}
mipLevels_ = desc.generateMips ? desc.mipLevels : level;
bool genMips = false;
if ((int)desc.initData.size() < desc.mipLevels && desc.generateMips) {
ILOG("Generating mipmaps");
AutoGenMipmaps();
// Assumes the texture is bound for editing
genMips = true;
generatedMips_ = true;
}
render->FinalizeTexture(tex_, mipLevels_, genMips);
}
@ -653,14 +655,6 @@ OpenGLTexture::~OpenGLTexture() {
}
}
void OpenGLTexture::AutoGenMipmaps() {
if (!generatedMips_) {
// Assumes the texture is bound for editing
render_->GenerateMipmap();
generatedMips_ = true;
}
}
class OpenGLFramebuffer : public Framebuffer {
public:
OpenGLFramebuffer(GLRenderManager *render) : render_(render) {}