Package: gem
Version: 1:0.93.3-1
Severity: normal
Tags: patch

Dear Maintainer, dear me

running Pd/Gem on my laptop (with a [Radeon HD 6310] card and the proprietary
fglrx drivers), Pd will print "GL: invalid enumerant" for each render-cycle,
even in the most simple patch (only a [gemwin] that's created and rendering
on).

Upstream assumes that this is a bug in the driver (wrongly reporting the 
ARB_imaging extension when querying MAX_COLOR_MATRIX_DEPTH fails), but has
nevertheless implemented a workaround, so that the error-message is only
triggered once and not permanently.

the attached patch is a backport of upstreams patch.

fgmasdr
IOhannes

PS: i use the bug-tracker, since the VCS is not updated to include the last
upload of Gem...

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.1.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages gem depends on:
ii  libc6                     2.13-24
ii  libftgl2                  2.1.3~rc5-4
ii  libgcc1                   1:4.6.2-11
ii  libgl1-mesa-glx [libgl1]  7.11.2-1
ii  libglew1.6                1.6.0-4
ii  libglu1-mesa [libglu1]    7.11.2-1
ii  libice6                   2:1.0.7-2
ii  libsm6                    2:1.2.0-2
ii  libstdc++6                4.6.2-11
ii  libxxf86vm1               1:1.1.1-2
ii  puredata [pd]             0.43.1-1
ii  puredata-core [pd]        0.43.1-1
ii  zlib1g                    1:1.2.3.4.dfsg-3

Versions of packages gem recommends:
ii  gem-doc                               1:0.93.3-1
ii  gem-extra                             1:0.93.3-1
ii  gem-plugin-gmerlin [gem-plugin-film]  1:0.93.3-1
ii  gem-plugin-lqt [gem-plugin-record]    1:0.93.3-1
ii  gem-plugin-magick [gem-plugin-image]  1:0.93.3-1
ii  gem-plugin-v4l2 [gem-plugin-video]    1:0.93.3-1

Versions of packages gem suggests:
ii  pd-zexy     2.2.5-1
ii  ttf-dejavu  2.33-2

-- no debconf information
>From ee377190573aebc106cb88c99d4e543e2115ba57 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= <zmoel...@iem.at>
Date: Mon, 9 Jan 2012 18:22:47 +0100
Subject: [PATCH 2/2] backported GLstack sanitizer

on some broken(?) drivers, Gem will output an 'invalid enumerant' in each render-cycle
this should fix problems with the matrix stacks
---
 debian/patches/sanitize-glstack.patch |  187 +++++++++++++++++++++++++++++++++
 debian/patches/series                 |    1 +
 2 files changed, 188 insertions(+), 0 deletions(-)
 create mode 100644 debian/patches/sanitize-glstack.patch
 create mode 100644 debian/patches/series

diff --git a/debian/patches/sanitize-glstack.patch b/debian/patches/sanitize-glstack.patch
new file mode 100644
index 0000000..85acf3e
--- /dev/null
+++ b/debian/patches/sanitize-glstack.patch
@@ -0,0 +1,187 @@
+Author: IOhannes m zmoelnig <zmoel...@umlauto.umlaeute.mur.at>
+Description: check whether querying the matrix depths is really possible
+and if not, stop throwing an error for each render-cycle;
+this has been backported from upstream's HEAD
+Forwarded: not-needed
+
+--- gem.orig/src/Gem/GLStack.cpp
++++ gem/src/Gem/GLStack.cpp
+@@ -25,6 +25,8 @@
+ /* need GLUtil for glReportError */ 
+ #include "Gem/GemGL.h"
+ #include "Utils/GLUtil.h"
++#include <map>
++
+ #define GLDEBUG if(glReportError())::startpost("glError @ %s:%d[%s] ", __FILE__, __LINE__, __FUNCTION__), ::post
+ 
+ using namespace gem;
+@@ -46,76 +48,39 @@
+ };
+ };
+ 
+-static GLenum id2maxdepth(enum GLStack::GemStackId id) {
+-  GLenum result=0;
+-  switch(id) {
+-  case GLStack::MODELVIEW:
+-    result=GL_MAX_MODELVIEW_STACK_DEPTH; 
+-    break;
+-  case GLStack::PROJECTION: 
+-    result=GL_MAX_PROJECTION_STACK_DEPTH; 
+-    break;
+-  case GLStack::TEXTURE: 
+-    result=GL_MAX_TEXTURE_STACK_DEPTH; 
+-    break;
+-  case GLStack::COLOR: 
+-    result=GL_MAX_COLOR_MATRIX_STACK_DEPTH; 
+-    break;
+-  default:
+-    //    ::error("GLStack: illegal stack matrix: %d");
+-    break;
+-  }
+-  return result;
+-}
+-
+-
+-static GLenum id2depth(enum GLStack::GemStackId id) {
+-  GLenum result=0;
+-  switch(id) {
+-  case GLStack::MODELVIEW:
+-    result=GL_MODELVIEW_STACK_DEPTH; 
+-    break;
+-  case GLStack::PROJECTION: 
+-    result=GL_PROJECTION_STACK_DEPTH; 
+-    break;
+-  case GLStack::TEXTURE: 
+-    result=GL_TEXTURE_STACK_DEPTH; 
+-    break;
+-  case GLStack::COLOR: 
+-    result=GL_COLOR_MATRIX_STACK_DEPTH; 
+-    break;
+-  default:
+-    //    ::error("GLStack: illegal stack matrix: %d");
+-    break;
+-  }
+-  return result;
+-}
+-
+-
+-static GLenum id2mode(enum GLStack::GemStackId id) {
+-  GLenum result=0;
+-  switch(id) {
+-  case GLStack::MODELVIEW:
+-    result=GL_MODELVIEW; 
+-    break;
+-  case GLStack::PROJECTION: 
+-    result=GL_PROJECTION; 
+-    break;
+-  case GLStack::TEXTURE: 
+-    result=GL_TEXTURE; 
+-    break;
+-  case GLStack::COLOR: 
+-    result=GL_COLOR; 
+-    break;
+-  default:
+-    //    ::error("GLStack: illegal stack matrix: %d");
+-    break;
+-  }
+-  return result;
++namespace {
++  static std::map<enum GLStack::GemStackId, GLenum>s_id2mode;
++  static std::map<enum GLStack::GemStackId, GLenum>s_id2depth;
++  static std::map<enum GLStack::GemStackId, GLenum>s_id2maxdepth;
++  static std::map<enum GLStack::GemStackId, bool>s_id2init;
+ }
+ 
+ 
+ GLStack:: GLStack(bool haveValidContext) : data(new Data()) {
++  static bool firsttime=true;
++  if(firsttime) {
++    s_id2mode[MODELVIEW] =GL_MODELVIEW;
++    s_id2mode[PROJECTION]=GL_PROJECTION;
++    s_id2mode[TEXTURE]   =GL_TEXTURE;
++    s_id2mode[COLOR]     =GL_COLOR;
++
++    s_id2depth[MODELVIEW] =GL_MODELVIEW_STACK_DEPTH;
++    s_id2depth[PROJECTION]=GL_PROJECTION_STACK_DEPTH;
++    s_id2depth[TEXTURE]   =GL_TEXTURE_STACK_DEPTH;
++    s_id2depth[COLOR]     =GL_COLOR_MATRIX_STACK_DEPTH;
++
++    s_id2maxdepth[MODELVIEW] =GL_MAX_MODELVIEW_STACK_DEPTH;
++    s_id2maxdepth[PROJECTION]=GL_MAX_PROJECTION_STACK_DEPTH;
++    s_id2maxdepth[TEXTURE]   =GL_MAX_TEXTURE_STACK_DEPTH;
++    s_id2maxdepth[COLOR]     =GL_MAX_COLOR_MATRIX_STACK_DEPTH;
++
++    s_id2init[MODELVIEW] =false;
++    s_id2init[PROJECTION]=false;
++    s_id2init[TEXTURE]   =false;
++    s_id2init[COLOR]     =false;
++  }
++  firsttime=false;
++
+   if(haveValidContext) {
+     reset();
+   }
+@@ -129,7 +94,7 @@
+   // changing the texunit (e.g. in [pix_texture]) makes the 
+   // local depthcounter a useless, and we get a lot of 
+   // stack under/overflows
+-#endif  
++#endif
+ 
+ 
+ /** push the given matrix to the stack if the maximum has not been reached 
+@@ -137,7 +102,7 @@
+  * NOTE: needs valid openGL context
+  */
+ bool GLStack::push(enum GemStackId id) {
+-  GLenum mode=id2mode(id);
++  GLenum mode=s_id2mode[id];
+   if(!mode)return false;
+   if(data->stackDepth[id]<data->maxDepth[id]) {
+     glMatrixMode(mode);
+@@ -163,7 +128,7 @@
+  * NOTE: needs valid openGL context
+  */
+ bool GLStack::pop(enum GemStackId id) {
+-  GLenum mode=id2mode(id);
++  GLenum mode=s_id2mode[id];
+   if(!mode)return false;
+ 
+   data->stackDepth[id]--;
+@@ -197,14 +162,30 @@
+  * NOTE: needs valid openGL context
+  */
+ int GLStack::reset(enum GemStackId id) {
+-  GLenum maxdepth=id2maxdepth(id);
+-  GLenum depth=id2depth(id);
++  bool firsttime=!(s_id2init[id]);
++  if(firsttime) {
++    s_id2init[id]=true;
++
++    if(COLOR == id && !GLEW_ARB_imaging) {
++      s_id2maxdepth[id]=0;
++      s_id2depth[id]=0;
++    }
++    glReportError(); // clear any errors so far
++  }
++
++
++  GLenum maxdepth=s_id2maxdepth[id];
++  GLenum depth=s_id2depth[id];
+ 
+   if(maxdepth && depth) {
+-    if(COLOR != id || GLEW_ARB_imaging) {
+-      glGetIntegerv(maxdepth, data->maxDepth+id);
+-      glGetIntegerv(depth, data->stackDepth+id);
+-    }
++    /* hmm, some ati-cards (with fglrx) report GLEW_ARB_imaging support but fail the 'depth' test for COLOR */
++
++    glGetIntegerv(maxdepth, data->maxDepth+id);
++    if(firsttime && glReportError())s_id2maxdepth[id]=0;
++
++    glGetIntegerv(depth, data->stackDepth+id);
++    if(firsttime && glReportError())s_id2depth[id]=0;
++
+     data->orgDepth[id]=data->stackDepth[id];
+     return data->stackDepth[id];
+   }
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..fd79fd1
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+sanitize-glstack.patch
-- 
1.7.7.3

Reply via email to