Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/mythtv/libs/libmythui/mythrender_opengl.cpp b/mythtv/libs/libmythui/mythrender_opengl.cpp
- index f8eeb8c258..8f4f05a55b 100644
- --- a/mythtv/libs/libmythui/mythrender_opengl.cpp
- +++ b/mythtv/libs/libmythui/mythrender_opengl.cpp
- @@ -510,7 +510,7 @@ void MythRenderOpenGL::UpdateTexture(uint tex, void *buf)
- doneCurrent();
- }
- -int MythRenderOpenGL::GetTextureType(bool &rect)
- +int MythRenderOpenGL::GetTextureType(bool &rect, bool ¶metric)
- {
- static bool rects = true;
- static bool check = true;
- @@ -523,27 +523,30 @@ int MythRenderOpenGL::GetTextureType(bool &rect)
- }
- int ret = GL_TEXTURE_2D;
- -
- + bool forcerect = false;
- if (m_extensions.contains("GL_NV_texture_rectangle") && rects)
- ret = GL_TEXTURE_RECTANGLE_NV;
- else if (m_extensions.contains("GL_ARB_texture_rectangle") && rects)
- ret = GL_TEXTURE_RECTANGLE_ARB;
- else if (m_extensions.contains("GL_EXT_texture_rectangle") && rects)
- ret = GL_TEXTURE_RECTANGLE_EXT;
- + else if (m_extensions.contains("GL_ARB_texture_non_power_of_two") && rects)
- + forcerect = true;
- - rect = (ret != GL_TEXTURE_2D);
- + rect = forcerect || (ret != GL_TEXTURE_2D);
- + parametric = (ret == GL_TEXTURE_2D);
- return ret;
- }
- -bool MythRenderOpenGL::IsRectTexture(uint type)
- +bool MythRenderOpenGL::IsTextureParametric(uint type)
- {
- if (type == GL_TEXTURE_RECTANGLE_NV)
- - return true;
- + return false;
- if (type == GL_TEXTURE_RECTANGLE_ARB)
- - return true;
- + return false;
- if (type == GL_TEXTURE_RECTANGLE_EXT)
- - return true;
- - return false;
- + return false;
- + return true;
- }
- uint MythRenderOpenGL::CreateTexture(QSize act_size, bool use_pbo,
- @@ -605,7 +608,7 @@ uint MythRenderOpenGL::CreateTexture(QSize act_size, bool use_pbo,
- QSize MythRenderOpenGL::GetTextureSize(uint type, const QSize &size)
- {
- - if (IsRectTexture(type))
- + if (!IsTextureParametric(type))
- return size;
- int w = 64;
- @@ -644,7 +647,7 @@ void MythRenderOpenGL::SetTextureFilters(uint tex, uint filt, uint wrap)
- return;
- bool mipmaps = (m_exts_used & kGLMipMaps) &&
- - !IsRectTexture(m_textures[tex].m_type);
- + IsTextureParametric(m_textures[tex].m_type);
- if (filt == GL_LINEAR_MIPMAP_LINEAR && !mipmaps)
- filt = GL_LINEAR;
- @@ -1068,9 +1071,12 @@ bool MythRenderOpenGL::InitFeatures(void)
- m_extensions = (const char*) glGetString(GL_EXTENSIONS);
- bool rects;
- - m_default_texture_type = GetTextureType(rects);
- + bool parametric;
- + m_default_texture_type = GetTextureType(rects, parametric);
- if (rects)
- m_exts_supported += kGLExtRect;
- + if (parametric)
- + m_exts_supported += kGLExtNPOT;
- if (m_extensions.contains("GL_ARB_multitexture") &&
- m_glActiveTexture && multitexture)
- @@ -1149,6 +1155,9 @@ bool MythRenderOpenGL::InitFeatures(void)
- .arg(m_max_tex_size).arg(m_max_tex_size));
- LOG(VB_GENERAL, LOG_INFO, LOC + QString("Max texture units: %1")
- .arg(m_max_units));
- + LOG(VB_GENERAL, LOG_INFO, LOC + QString("Rectangular textures: %1 (Parametric: %2)")
- + .arg((m_exts_supported & kGLExtRect) ? "Yes" : "No")
- + .arg((m_exts_supported & kGLExtNPOT) ? "Yes" : "No - Good"));
- LOG(VB_GENERAL, LOG_INFO, LOC + QString("Direct rendering: %1")
- .arg(IsDirectRendering() ? "Yes" : "No"));
- LOG(VB_GENERAL, LOG_INFO, LOC + QString("Extensions Supported: %1")
- @@ -1331,7 +1340,7 @@ bool MythRenderOpenGL::UpdateTextureVertices(uint tex, const QRect *src,
- data[6 + TEX_OFFSET] = src->left() + width;
- data[7 + TEX_OFFSET] = src->top();
- - if (!IsRectTexture(m_textures[tex].m_type))
- + if (IsTextureParametric(m_textures[tex].m_type))
- {
- data[0 + TEX_OFFSET] /= (float)size.width();
- data[6 + TEX_OFFSET] /= (float)size.width();
- @@ -1366,7 +1375,7 @@ bool MythRenderOpenGL::UpdateTextureVertices(uint tex, const QRectF *src,
- data[6 + TEX_OFFSET] = src->left() + src->width();
- data[7 + TEX_OFFSET] = src->top();
- - if (!IsRectTexture(m_textures[tex].m_type))
- + if (IsTextureParametric(m_textures[tex].m_type))
- {
- data[0 + TEX_OFFSET] /= (float)m_textures[tex].m_size.width();
- data[6 + TEX_OFFSET] /= (float)m_textures[tex].m_size.width();
- diff --git a/mythtv/libs/libmythui/mythrender_opengl.h b/mythtv/libs/libmythui/mythrender_opengl.h
- index 7e48e12e48..4167b925ee 100644
- --- a/mythtv/libs/libmythui/mythrender_opengl.h
- +++ b/mythtv/libs/libmythui/mythrender_opengl.h
- @@ -60,7 +60,8 @@ typedef enum
- kGLSL = 0x0400,
- kGLVertexArray = 0x0800,
- kGLExtVBO = 0x1000,
- - kGLMaxFeat = 0x2000,
- + kGLExtNPOT = 0x2000, // NPOT texture but parametric addressing in shaders
- + kGLMaxFeat = 0x4000,
- } GLFeatures;
- #define MYTHTV_UYVY 0x8A1F
- @@ -173,8 +174,8 @@ class MUI_PUBLIC MythRenderOpenGL : protected MythRenderContext, public MythRend
- void* GetTextureBuffer(uint tex, bool create_buffer = true);
- void UpdateTexture(uint tex, void *buf);
- - int GetTextureType(bool &rect);
- - bool IsRectTexture(uint type);
- + int GetTextureType(bool &rect, bool ¶metric);
- + bool IsTextureParametric(uint type);
- uint CreateTexture(QSize act_size, bool use_pbo, uint type,
- uint data_type = GL_UNSIGNED_BYTE,
- uint data_fmt = GL_BGRA, uint internal_fmt = GL_RGBA8,
- @@ -210,6 +211,7 @@ class MUI_PUBLIC MythRenderOpenGL : protected MythRenderContext, public MythRend
- const QBrush &fillBrush, const QPen &linePen,
- int alpha);
- virtual bool RectanglesAreAccelerated(void) { return false; }
- + static uint GetBufferSize(QSize size, uint fmt, uint type);
- protected:
- virtual ~MythRenderOpenGL() = default;
- @@ -247,7 +249,6 @@ class MUI_PUBLIC MythRenderOpenGL : protected MythRenderContext, public MythRend
- void GetCachedVBO(GLuint type, const QRect &area);
- void ExpireVBOS(uint max = 0);
- bool ClearTexture(uint tex);
- - uint GetBufferSize(QSize size, uint fmt, uint type);
- static void StoreBicubicWeights(float x, float *dst);
- diff --git a/mythtv/libs/libmythui/mythrender_opengl2.cpp b/mythtv/libs/libmythui/mythrender_opengl2.cpp
- index 288e84d8d7..37c7afebd5 100644
- --- a/mythtv/libs/libmythui/mythrender_opengl2.cpp
- +++ b/mythtv/libs/libmythui/mythrender_opengl2.cpp
- @@ -896,7 +896,8 @@ void MythRenderOpenGL2::OptimiseShaderSource(QString &source)
- QString sampler = "sampler2D";
- QString texture = "texture2D";
- - if ((m_exts_used & kGLExtRect) && source.contains("GLSL_SAMPLER"))
- + if ((m_exts_used & kGLExtRect) && source.contains("GLSL_SAMPLER") &&
- + !(m_exts_used & kGLExtNPOT))
- {
- extensions += "#extension GL_ARB_texture_rectangle : enable\n";
- sampler += "Rect";
- diff --git a/mythtv/libs/libmythui/mythrender_opengl2es.h b/mythtv/libs/libmythui/mythrender_opengl2es.h
- index be743c523c..d0905930f1 100644
- --- a/mythtv/libs/libmythui/mythrender_opengl2es.h
- +++ b/mythtv/libs/libmythui/mythrender_opengl2es.h
- @@ -158,6 +158,13 @@ class MUI_PUBLIC MythRenderOpenGL2ES : public MythRenderOpenGL2
- m_exts_supported += (glslshaders ? kGLSL : 0) |
- (vertexbuffers ? kGLExtVBO : 0) | kGLVertexArray |
- kGLMultiTex;
- +
- + if (m_extensions.contains("GL_OES_texture_npot") ||
- + m_extensions.contains("GL_ARB_texture_non_power_of_two"))
- + {
- + m_exts_supported += kGLExtRect;
- + m_exts_supported += kGLExtNPOT;
- + }
- m_default_texture_type = GL_TEXTURE_2D;
- // GL_OES_framebuffer_object
- @@ -206,6 +213,9 @@ class MUI_PUBLIC MythRenderOpenGL2ES : public MythRenderOpenGL2
- .arg(m_max_tex_size).arg(m_max_tex_size));
- LOG(VB_GENERAL, LOG_INFO, LOC + QString("Max texture units: %1")
- .arg(m_max_units));
- + LOG(VB_GENERAL, LOG_INFO, LOC + QString("Rectangular textures: %1 (Parametric: %2)")
- + .arg((m_exts_supported & kGLExtRect) ? "Yes" : "No")
- + .arg((m_exts_supported & kGLExtNPOT) ? "Yes" : "No - Good"));
- LOG(VB_GENERAL, LOG_INFO, LOC + QString("Direct rendering: %1")
- .arg(IsDirectRendering() ? "Yes" : "No"));
- LOG(VB_GENERAL, LOG_INFO, LOC + QString("Extensions Supported: %1")
Add Comment
Please, Sign In to add comment