mirror of https://github.com/PCSX2/pcsx2.git
gsdx mipmap:ogl: add capabilities to automatically generate mipmap layer
This commit is contained in:
parent
510eccd471
commit
1b9b47dd6a
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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); }
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue