diff --git a/plugins/GSdx/GLLoader.cpp b/plugins/GSdx/GLLoader.cpp index f7cf030018..d4876f37c3 100644 --- a/plugins/GSdx/GLLoader.cpp +++ b/plugins/GSdx/GLLoader.cpp @@ -139,6 +139,7 @@ PFNGLCOPYTEXTURESUBIMAGE2DPROC glCopyTextureSubImage2D = NUL PFNGLBINDTEXTUREUNITPROC glBindTextureUnit = NULL; PFNGLGETTEXTUREIMAGEPROC glGetTextureImage = NULL; PFNGLTEXTUREPARAMETERIPROC glTextureParameteri = NULL; +PFNGLGENERATETEXTUREMIPMAPPROC glGenerateTextureMipmap = NULL; PFNGLCREATEFRAMEBUFFERSPROC glCreateFramebuffers = NULL; PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glClearNamedFramebufferfv = NULL; diff --git a/plugins/GSdx/GLLoader.h b/plugins/GSdx/GLLoader.h index 55ce89556a..2973672419 100644 --- a/plugins/GSdx/GLLoader.h +++ b/plugins/GSdx/GLLoader.h @@ -318,6 +318,7 @@ extern PFNGLCOPYTEXTURESUBIMAGE2DPROC glCopyTextureSubImage2D; extern PFNGLBINDTEXTUREUNITPROC glBindTextureUnit; extern PFNGLGETTEXTUREIMAGEPROC glGetTextureImage; extern PFNGLTEXTUREPARAMETERIPROC glTextureParameteri; +extern PFNGLGENERATETEXTUREMIPMAPPROC glGenerateTextureMipmap; extern PFNGLCREATEFRAMEBUFFERSPROC glCreateFramebuffers; extern PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glClearNamedFramebufferfv; diff --git a/plugins/GSdx/GSTexture.h b/plugins/GSdx/GSTexture.h index 21f2320d75..51b5598602 100644 --- a/plugins/GSdx/GSTexture.h +++ b/plugins/GSdx/GSTexture.h @@ -46,6 +46,7 @@ public: virtual bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0) = 0; virtual bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) = 0; virtual void Unmap() = 0; + virtual void GenerateMipmap() {} virtual bool Save(const string& fn, bool dds = false) = 0; virtual uint32 GetID() { return 0; } diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 691d661e82..55970991c1 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -153,7 +153,7 @@ namespace PboPool { } GSTextureOGL::GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read, bool mipmap) - : m_pbo_size(0), m_clean(false), m_local_buffer(NULL), m_r_x(0), m_r_y(0), m_r_w(0), m_r_h(0), m_layer(0) + : m_pbo_size(0), m_clean(false), m_generate_mipmap(true), m_local_buffer(NULL), m_r_x(0), m_r_y(0), m_r_w(0), m_r_h(0), m_layer(0) { // OpenGL didn't like dimensions of size 0 m_size.x = max(1,w); @@ -370,6 +370,8 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch, int PboPool::EndTransfer(); #endif + m_generate_mipmap = true; + return true; } @@ -452,10 +454,20 @@ void GSTextureOGL::Unmap() PboPool::EndTransfer(); + m_generate_mipmap = true; + GL_POP(); // PUSH is in Map } } +void GSTextureOGL::GenerateMipmap() +{ + if (m_generate_mipmap && m_max_layer > 1) { + glGenerateTextureMipmap(m_texture_id); + m_generate_mipmap = false; + } +} + bool GSTextureOGL::Save(const string& fn, bool dds) { // Collect the texture data diff --git a/plugins/GSdx/GSTextureOGL.h b/plugins/GSdx/GSTextureOGL.h index 1dd4f37289..8ea6b83a7d 100644 --- a/plugins/GSdx/GSTextureOGL.h +++ b/plugins/GSdx/GSTextureOGL.h @@ -44,6 +44,7 @@ class GSTextureOGL final : public GSTexture int m_pbo_size; GLuint m_fbo_read; bool m_clean; + bool m_generate_mipmap; uint8* m_local_buffer; // Avoid alignment constrain @@ -70,6 +71,7 @@ class GSTextureOGL final : public GSTexture bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0) final; bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) final; void Unmap() final; + void GenerateMipmap() final; bool Save(const string& fn, bool dds = false) final; bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); } diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index ed2d1087cb..1a14fee219 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -146,6 +146,7 @@ void GSWndGL::PopulateGlFunction() GL_EXT_LOAD(glBindTextureUnit); GL_EXT_LOAD(glGetTextureImage); GL_EXT_LOAD(glTextureParameteri); + GL_EXT_LOAD(glGenerateTextureMipmap); GL_EXT_LOAD(glCreateFramebuffers); GL_EXT_LOAD(glClearNamedFramebufferfv);