Guest User

Untitled

a guest
Dec 12th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.39 KB | None | 0 0
  1. diff --git a/mythtv/libs/libmythui/mythrender_opengl.cpp b/mythtv/libs/libmythui/mythrender_opengl.cpp
  2. index f8eeb8c258..8f4f05a55b 100644
  3. --- a/mythtv/libs/libmythui/mythrender_opengl.cpp
  4. +++ b/mythtv/libs/libmythui/mythrender_opengl.cpp
  5. @@ -510,7 +510,7 @@ void MythRenderOpenGL::UpdateTexture(uint tex, void *buf)
  6. doneCurrent();
  7. }
  8.  
  9. -int MythRenderOpenGL::GetTextureType(bool &rect)
  10. +int MythRenderOpenGL::GetTextureType(bool &rect, bool &parametric)
  11. {
  12. static bool rects = true;
  13. static bool check = true;
  14. @@ -523,27 +523,30 @@ int MythRenderOpenGL::GetTextureType(bool &rect)
  15. }
  16.  
  17. int ret = GL_TEXTURE_2D;
  18. -
  19. + bool forcerect = false;
  20. if (m_extensions.contains("GL_NV_texture_rectangle") && rects)
  21. ret = GL_TEXTURE_RECTANGLE_NV;
  22. else if (m_extensions.contains("GL_ARB_texture_rectangle") && rects)
  23. ret = GL_TEXTURE_RECTANGLE_ARB;
  24. else if (m_extensions.contains("GL_EXT_texture_rectangle") && rects)
  25. ret = GL_TEXTURE_RECTANGLE_EXT;
  26. + else if (m_extensions.contains("GL_ARB_texture_non_power_of_two") && rects)
  27. + forcerect = true;
  28.  
  29. - rect = (ret != GL_TEXTURE_2D);
  30. + rect = forcerect || (ret != GL_TEXTURE_2D);
  31. + parametric = (ret == GL_TEXTURE_2D);
  32. return ret;
  33. }
  34.  
  35. -bool MythRenderOpenGL::IsRectTexture(uint type)
  36. +bool MythRenderOpenGL::IsTextureParametric(uint type)
  37. {
  38. if (type == GL_TEXTURE_RECTANGLE_NV)
  39. - return true;
  40. + return false;
  41. if (type == GL_TEXTURE_RECTANGLE_ARB)
  42. - return true;
  43. + return false;
  44. if (type == GL_TEXTURE_RECTANGLE_EXT)
  45. - return true;
  46. - return false;
  47. + return false;
  48. + return true;
  49. }
  50.  
  51. uint MythRenderOpenGL::CreateTexture(QSize act_size, bool use_pbo,
  52. @@ -605,7 +608,7 @@ uint MythRenderOpenGL::CreateTexture(QSize act_size, bool use_pbo,
  53.  
  54. QSize MythRenderOpenGL::GetTextureSize(uint type, const QSize &size)
  55. {
  56. - if (IsRectTexture(type))
  57. + if (!IsTextureParametric(type))
  58. return size;
  59.  
  60. int w = 64;
  61. @@ -644,7 +647,7 @@ void MythRenderOpenGL::SetTextureFilters(uint tex, uint filt, uint wrap)
  62. return;
  63.  
  64. bool mipmaps = (m_exts_used & kGLMipMaps) &&
  65. - !IsRectTexture(m_textures[tex].m_type);
  66. + IsTextureParametric(m_textures[tex].m_type);
  67. if (filt == GL_LINEAR_MIPMAP_LINEAR && !mipmaps)
  68. filt = GL_LINEAR;
  69.  
  70. @@ -1068,9 +1071,12 @@ bool MythRenderOpenGL::InitFeatures(void)
  71.  
  72. m_extensions = (const char*) glGetString(GL_EXTENSIONS);
  73. bool rects;
  74. - m_default_texture_type = GetTextureType(rects);
  75. + bool parametric;
  76. + m_default_texture_type = GetTextureType(rects, parametric);
  77. if (rects)
  78. m_exts_supported += kGLExtRect;
  79. + if (parametric)
  80. + m_exts_supported += kGLExtNPOT;
  81.  
  82. if (m_extensions.contains("GL_ARB_multitexture") &&
  83. m_glActiveTexture && multitexture)
  84. @@ -1149,6 +1155,9 @@ bool MythRenderOpenGL::InitFeatures(void)
  85. .arg(m_max_tex_size).arg(m_max_tex_size));
  86. LOG(VB_GENERAL, LOG_INFO, LOC + QString("Max texture units: %1")
  87. .arg(m_max_units));
  88. + LOG(VB_GENERAL, LOG_INFO, LOC + QString("Rectangular textures: %1 (Parametric: %2)")
  89. + .arg((m_exts_supported & kGLExtRect) ? "Yes" : "No")
  90. + .arg((m_exts_supported & kGLExtNPOT) ? "Yes" : "No - Good"));
  91. LOG(VB_GENERAL, LOG_INFO, LOC + QString("Direct rendering: %1")
  92. .arg(IsDirectRendering() ? "Yes" : "No"));
  93. LOG(VB_GENERAL, LOG_INFO, LOC + QString("Extensions Supported: %1")
  94. @@ -1331,7 +1340,7 @@ bool MythRenderOpenGL::UpdateTextureVertices(uint tex, const QRect *src,
  95. data[6 + TEX_OFFSET] = src->left() + width;
  96. data[7 + TEX_OFFSET] = src->top();
  97.  
  98. - if (!IsRectTexture(m_textures[tex].m_type))
  99. + if (IsTextureParametric(m_textures[tex].m_type))
  100. {
  101. data[0 + TEX_OFFSET] /= (float)size.width();
  102. data[6 + TEX_OFFSET] /= (float)size.width();
  103. @@ -1366,7 +1375,7 @@ bool MythRenderOpenGL::UpdateTextureVertices(uint tex, const QRectF *src,
  104. data[6 + TEX_OFFSET] = src->left() + src->width();
  105. data[7 + TEX_OFFSET] = src->top();
  106.  
  107. - if (!IsRectTexture(m_textures[tex].m_type))
  108. + if (IsTextureParametric(m_textures[tex].m_type))
  109. {
  110. data[0 + TEX_OFFSET] /= (float)m_textures[tex].m_size.width();
  111. data[6 + TEX_OFFSET] /= (float)m_textures[tex].m_size.width();
  112. diff --git a/mythtv/libs/libmythui/mythrender_opengl.h b/mythtv/libs/libmythui/mythrender_opengl.h
  113. index 7e48e12e48..4167b925ee 100644
  114. --- a/mythtv/libs/libmythui/mythrender_opengl.h
  115. +++ b/mythtv/libs/libmythui/mythrender_opengl.h
  116. @@ -60,7 +60,8 @@ typedef enum
  117. kGLSL = 0x0400,
  118. kGLVertexArray = 0x0800,
  119. kGLExtVBO = 0x1000,
  120. - kGLMaxFeat = 0x2000,
  121. + kGLExtNPOT = 0x2000, // NPOT texture but parametric addressing in shaders
  122. + kGLMaxFeat = 0x4000,
  123. } GLFeatures;
  124.  
  125. #define MYTHTV_UYVY 0x8A1F
  126. @@ -173,8 +174,8 @@ class MUI_PUBLIC MythRenderOpenGL : protected MythRenderContext, public MythRend
  127.  
  128. void* GetTextureBuffer(uint tex, bool create_buffer = true);
  129. void UpdateTexture(uint tex, void *buf);
  130. - int GetTextureType(bool &rect);
  131. - bool IsRectTexture(uint type);
  132. + int GetTextureType(bool &rect, bool &parametric);
  133. + bool IsTextureParametric(uint type);
  134. uint CreateTexture(QSize act_size, bool use_pbo, uint type,
  135. uint data_type = GL_UNSIGNED_BYTE,
  136. uint data_fmt = GL_BGRA, uint internal_fmt = GL_RGBA8,
  137. @@ -210,6 +211,7 @@ class MUI_PUBLIC MythRenderOpenGL : protected MythRenderContext, public MythRend
  138. const QBrush &fillBrush, const QPen &linePen,
  139. int alpha);
  140. virtual bool RectanglesAreAccelerated(void) { return false; }
  141. + static uint GetBufferSize(QSize size, uint fmt, uint type);
  142.  
  143. protected:
  144. virtual ~MythRenderOpenGL() = default;
  145. @@ -247,7 +249,6 @@ class MUI_PUBLIC MythRenderOpenGL : protected MythRenderContext, public MythRend
  146. void GetCachedVBO(GLuint type, const QRect &area);
  147. void ExpireVBOS(uint max = 0);
  148. bool ClearTexture(uint tex);
  149. - uint GetBufferSize(QSize size, uint fmt, uint type);
  150.  
  151. static void StoreBicubicWeights(float x, float *dst);
  152.  
  153. diff --git a/mythtv/libs/libmythui/mythrender_opengl2.cpp b/mythtv/libs/libmythui/mythrender_opengl2.cpp
  154. index 288e84d8d7..37c7afebd5 100644
  155. --- a/mythtv/libs/libmythui/mythrender_opengl2.cpp
  156. +++ b/mythtv/libs/libmythui/mythrender_opengl2.cpp
  157. @@ -896,7 +896,8 @@ void MythRenderOpenGL2::OptimiseShaderSource(QString &source)
  158. QString sampler = "sampler2D";
  159. QString texture = "texture2D";
  160.  
  161. - if ((m_exts_used & kGLExtRect) && source.contains("GLSL_SAMPLER"))
  162. + if ((m_exts_used & kGLExtRect) && source.contains("GLSL_SAMPLER") &&
  163. + !(m_exts_used & kGLExtNPOT))
  164. {
  165. extensions += "#extension GL_ARB_texture_rectangle : enable\n";
  166. sampler += "Rect";
  167. diff --git a/mythtv/libs/libmythui/mythrender_opengl2es.h b/mythtv/libs/libmythui/mythrender_opengl2es.h
  168. index be743c523c..d0905930f1 100644
  169. --- a/mythtv/libs/libmythui/mythrender_opengl2es.h
  170. +++ b/mythtv/libs/libmythui/mythrender_opengl2es.h
  171. @@ -158,6 +158,13 @@ class MUI_PUBLIC MythRenderOpenGL2ES : public MythRenderOpenGL2
  172. m_exts_supported += (glslshaders ? kGLSL : 0) |
  173. (vertexbuffers ? kGLExtVBO : 0) | kGLVertexArray |
  174. kGLMultiTex;
  175. +
  176. + if (m_extensions.contains("GL_OES_texture_npot") ||
  177. + m_extensions.contains("GL_ARB_texture_non_power_of_two"))
  178. + {
  179. + m_exts_supported += kGLExtRect;
  180. + m_exts_supported += kGLExtNPOT;
  181. + }
  182. m_default_texture_type = GL_TEXTURE_2D;
  183.  
  184. // GL_OES_framebuffer_object
  185. @@ -206,6 +213,9 @@ class MUI_PUBLIC MythRenderOpenGL2ES : public MythRenderOpenGL2
  186. .arg(m_max_tex_size).arg(m_max_tex_size));
  187. LOG(VB_GENERAL, LOG_INFO, LOC + QString("Max texture units: %1")
  188. .arg(m_max_units));
  189. + LOG(VB_GENERAL, LOG_INFO, LOC + QString("Rectangular textures: %1 (Parametric: %2)")
  190. + .arg((m_exts_supported & kGLExtRect) ? "Yes" : "No")
  191. + .arg((m_exts_supported & kGLExtNPOT) ? "Yes" : "No - Good"));
  192. LOG(VB_GENERAL, LOG_INFO, LOC + QString("Direct rendering: %1")
  193. .arg(IsDirectRendering() ? "Yes" : "No"));
  194. LOG(VB_GENERAL, LOG_INFO, LOC + QString("Extensions Supported: %1")
Add Comment
Please, Sign In to add comment