Missing textures

If you have problems understanding something or getting started, ask here

Moderator: joepal

Re: Missing textures

Postby green-green-avk » Sun Nov 03, 2019 10:13 pm

First of all before blaming drivers, please, be more careful with OpenGL API...
Do you know guys, that index used by glGetActiveUniform() is not equal to the location used by glUniform...()? Please, fix lib/shader.py to get rid of this embarrassment.

To exact (it's short and simple):
Code: Select all
diff -r 04eb677d1568 makehuman/lib/shader.py
--- a/makehuman/lib/shader.py   Wed Mar 07 20:26:47 2018 +0100
+++ b/makehuman/lib/shader.py   Sun Nov 03 13:39:09 2019 -0800
@@ -45,8 +45,9 @@
 from core import G
 
 class Uniform(object):
-    def __init__(self, index, name, pytype, dims):
+    def __init__(self, index, location, name, pytype, dims):
         self.index = index
+        self.location = location
         self.name = name
         self.pytype = pytype
         self.dims = dims
@@ -111,9 +112,9 @@
             cls.uniformTypes2.clear()
         return type in cls.uniformTypes
 
-    def __init__(self, index, name, type):
+    def __init__(self, index, location, name, type):
         dims, dtype, pytype, glfunc, glquery = self.uniformTypes[type]
-        super(VectorUniform, self).__init__(index, name, pytype, dims)
+        super(VectorUniform, self).__init__(index, location, name, pytype, dims)
         self.type = type
         self.dtype = dtype
         self.glfunc = glfunc
@@ -125,13 +126,19 @@
             return
         values = np.asarray(data, dtype=self.dtype).reshape(self.dims)
         if len(self.dims) > 1:
-            self.glfunc(self.index, 1, GL_TRUE, values)
+            self.glfunc(self.location, 1, GL_TRUE, values)
         else:
-            self.glfunc(self.index, len(values)/self.dims[0], values)
+            try:
+              self.glfunc(self.location, len(values)/self.dims[0], values)
+            except GLerror as err:
+              log.error("%s", err.description)
 
     def update(self, pgm):
         values = np.zeros(self.dims, dtype=self.dtype)
-        self.glquery(pgm, self.index, values)
+        try:
+          self.glquery(pgm, self.location, values)
+        except GLerror as err:
+          log.error("%s", err.description)
         if len(self.dims) > 1:
             values = values.T
         self.values = values
@@ -223,9 +230,9 @@
             cls.textureTargets2.clear()
         return type in cls.textureTargets
 
-    def __init__(self, index, name, type):
+    def __init__(self, index, location, name, type):
         target = self.textureTargets[type]
-        super(SamplerUniform, self).__init__(index, name, str, (1,))
+        super(SamplerUniform, self).__init__(index, location, name, str, (1,))
         self.target = target
 
     def set(self, data):
@@ -243,7 +250,10 @@
                 glBindTexture(self.target, 0)
             else:
                 glBindTexture(self.target, tex.textureId)
-        glUniform1i(self.index, cls.currentSampler)
+        try:
+          glUniform1i(self.location, cls.currentSampler)
+        except GLerror as err:
+          log.error("%s", err.description)
         cls.currentSampler += 1
 
     @classmethod
@@ -438,14 +448,17 @@
             self.uniforms = []
             for index in xrange(parameterCount):
                 name, size, type = glGetActiveUniform(self.shaderId, index)
+#                log.debug("%s %d %s", name, size, type)
+                location = glGetUniformLocation(self.shaderId, name)
+#                log.debug("%d == %d", index, location)
                 if name.startswith('gl_'):
                     log.debug("Shader: adding built-in uniform %s", name)
                     self.glUniforms.append(name)
                     continue
                 if VectorUniform.check(type):
-                    uniform = VectorUniform(index, name, type)
+                    uniform = VectorUniform(index, location, name, type)
                 elif SamplerUniform.check(type):
-                    uniform = SamplerUniform(index, name, type)
+                    uniform = SamplerUniform(index, location, name, type)
                 uniform.update(self.shaderId)
                 self.uniforms.append(uniform)
 
green-green-avk
 
Posts: 2
Joined: Sun Nov 03, 2019 10:06 pm

Re: Missing textures

Postby Aranuvir » Sun Nov 03, 2019 11:27 pm

I might be stupid, but is the diff based on the latest version from master? I had been working on that index stuff a while ago...

And you are right, we shouldn't blame drivers before we are absolutely sure our code is correct :oops: .
Aranuvir
 
Posts: 1314
Joined: Sun Oct 12, 2014 2:12 pm

Re: Missing textures

Postby joepal » Mon Nov 04, 2019 7:26 am

I think at least parts of this was fixed two years ago, in https://github.com/makehumancommunity/m ... 7c045540bf

Maybe we've missed a bunch of places where index is erronously used though?
Joel Palmius (LinkedIn)
MakeHuman Infrastructure Manager
http://www.palmius.com/joel
joepal
 
Posts: 4465
Joined: Wed Jun 04, 2008 11:20 am

Re: Missing textures

Postby green-green-avk » Mon Nov 04, 2019 9:59 pm

Oops... I see now. I just thought, such a general patch should be backported to the stable release immediately...
green-green-avk
 
Posts: 2
Joined: Sun Nov 03, 2019 10:06 pm

Re: Missing textures

Postby Aranuvir » Mon Nov 04, 2019 10:34 pm

We consider master rather stable at the moment. But we still would appreciate any help we can get with coding OpenGL. Our goal for the future is to rebase the code on pure Qt-GL-functions and to replace PyQt by Pyside2.
Aranuvir
 
Posts: 1314
Joined: Sun Oct 12, 2014 2:12 pm

Re: Missing textures

Postby Aranuvir » Mon Nov 04, 2019 10:37 pm

I hope it's ok if I assign that issue to you?
Aranuvir
 
Posts: 1314
Joined: Sun Oct 12, 2014 2:12 pm

Previous

Return to Newbies

Who is online

Users browsing this forum: No registered users and 1 guest