OpenGL: Fix texture wrapping of render targets.

This commit is contained in:
Henrik Rydgård 2018-03-28 11:23:41 +02:00
parent b2941014f2
commit 01d81ffa72
6 changed files with 15 additions and 10 deletions

View File

@ -169,16 +169,16 @@ void TextureCacheGLES::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferH
minFilt &= 1; // framebuffers can't mipmap.
float aniso = 0.0f;
render_->SetTextureSampler(0, sClamp ? GL_CLAMP_TO_EDGE : GL_REPEAT, tClamp ? GL_CLAMP_TO_EDGE : GL_REPEAT, MagFiltGL[magFilt], MinFiltGL[minFilt], aniso);
// Often the framebuffer will not match the texture size. We'll wrap/clamp in the shader in that case.
// This happens whether we have OES_texture_npot or not.
int w = gstate.getTextureWidth(0);
int h = gstate.getTextureHeight(0);
if (w != bufferWidth || h != bufferHeight) {
return;
sClamp = true;
tClamp = true;
}
float aniso = 0.0f;
render_->SetTextureSampler(0, sClamp ? GL_CLAMP_TO_EDGE : GL_REPEAT, tClamp ? GL_CLAMP_TO_EDGE : GL_REPEAT, MagFiltGL[magFilt], MinFiltGL[minFilt], aniso);
}
static void ConvertColors(void *dstBuf, const void *srcBuf, GLuint dstFmt, int numPixels) {

View File

@ -112,6 +112,8 @@ static std::string PostShaderTranslateName(const char *value) {
const ShaderInfo *info = GetPostShaderInfo(value);
if (info) {
return ps->T(value, info ? info->name.c_str() : value);
} else {
return value;
}
}

View File

@ -149,7 +149,8 @@ void DebugCallbackARB(GLenum source, GLenum type, GLuint id, GLenum severity,
case GL_DEBUG_TYPE_OTHER_ARB:
default:
INFO_LOG(G3D, "GL: %s", finalMessage);
// These are just performance warnings.
VERBOSE_LOG(G3D, "GL: %s", finalMessage);
break;
}
}

View File

@ -28,6 +28,10 @@ inline float Float16ToFloat(float16 ix) {
return x;
}
inline bool isPowerOf2(int n) {
return n == 1 || (n & (n - 1)) == 0;
}
inline uint32_t RoundUpToPowerOf2(uint32_t v) {
v--;
v |= v >> 1;

View File

@ -8,6 +8,7 @@
#include "gfx/gl_debug_log.h"
#include "gfx_es2/gpu_features.h"
#include "math/dataconv.h"
#include "math/math_util.h"
#define TEXCACHE_NAME_CACHE_SIZE 16
@ -326,7 +327,7 @@ void GLQueueRunner::InitCreateFramebuffer(const GLRInitStep &step) {
fbo->color_texture.wrapT = GL_CLAMP_TO_EDGE;
fbo->color_texture.magFilter = GL_LINEAR;
fbo->color_texture.minFilter = GL_LINEAR;
fbo->color_texture.canWrap = false;
fbo->color_texture.canWrap = isPowerOf2(fbo->width) && isPowerOf2(fbo->height);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, fbo->color_texture.wrapS);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, fbo->color_texture.wrapT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, fbo->color_texture.magFilter);

View File

@ -7,6 +7,7 @@
#include "base/logging.h"
#include "math/dataconv.h"
#include "math/math_util.h"
#include "math/lin/matrix4x4.h"
#include "thin3d/thin3d.h"
#include "thin3d/DataFormatGL.h"
@ -573,10 +574,6 @@ GLuint TypeToTarget(TextureType type) {
}
}
inline bool isPowerOf2(int n) {
return n == 1 || (n & (n - 1)) == 0;
}
class OpenGLTexture : public Texture {
public:
OpenGLTexture(GLRenderManager *render, const TextureDesc &desc);