Forums - GL_INT and GL_UNSIGNED_BYTE in glVertexAttribPointer + Transform Feedback

18 posts / 0 new
Last post
GL_INT and GL_UNSIGNED_BYTE in glVertexAttribPointer + Transform Feedback
RelativeGames
Profile picture
Join Date: 16 Apr 13
Posts: 56
Posted: Tue, 2014-01-14 06:38

 

Hm, my post just got deleted, I think I'm not allowed to edit my post more than 2 times ? I was just refining the information and fixing typos though.

So using GL_INT in call to glVertexAttribPointer on Adreno 320/Nexus 4 (Android 4.4 drivers) results in a crash. This should be legal on GLES3.
Using GL_UNSIGNED_BYTE results in an undefined behavior. I'm trying to do skinning and my bone indices are GL_UNSIGNED_BYTE, it seems it doesn't get displayed right. I'm also using vec3 inside the shader, so I know it's getting converted to floats in shaders.

Next up is Transform feedback, after glEndTransformFeedback(), I get this error from glDrawElements()

01-14 16:21:23.629: W/Adreno200-ES20(22368): <core_glDrawElementsInstancedXXX:871>: GL_INVALID_OPERATION

While I only do Transform Feedback on one object it seems it doesn't stop at glEndTransformFeedback(). I also get 0 from a query on
GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN .

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Tue, 2014-01-14 13:43

Hi..

 

Any chance for a simple repro case or psuedo code for the transform feedback problem?

The Adreno SDK has a tutorial (22)  on using transform feedback (drawing triangles) and includes a call to query GL_TRANSFORM_FEEDBACK.which might be worth comparing against...

glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, g_hQuery);

glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, g_hFeedbackName);

glBeginTransformFeedback(GL_TRIANGLES);

glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

glEndTransformFeedback();

glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);

glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);

 

GLuint PrimitivesWritten = 0;

glGetQueryObjectuiv(g_hQuery, GL_QUERY_RESULT, &PrimitivesWritten);

 

 

 

 

 

  • Up0
  • Down0
Sonicadvance1
Join Date: 2 Nov 12
Posts: 51
Posted: Tue, 2014-01-14 15:06

I'll reiterate here since the last thread got deleted alongside my post.

I too am having issues with UNSIGNED_BYTE with glVertexAttribPointer giving me the wrong values in my shaders. Which I am converting to an integer and using as a index in a UBO array for a transformation matrix.

  • Up0
  • Down0
RelativeGames
Profile picture
Join Date: 16 Apr 13
Posts: 56
Posted: Tue, 2014-01-14 15:30

 

It would be much easier if I could just send a test APK with instructions (like touch button X). I have a large scene I use as the background for this test. I'm also rendering into a shadow map when doing the Transform Feedback and then using the streamed buffer in a normal pass. It's a lot of code. Should there be any problem though with indexing into a

mat BoneMatrices[30];

from vertex data provided as GL_UNSIGNED_BYTE ? I know I read on this forum that someone said it's not mandatory in GLES2, but what about GLES3 ?

  • Up0
  • Down0
RelativeGames
Profile picture
Join Date: 16 Apr 13
Posts: 56
Posted: Tue, 2014-01-14 15:43

Side note, just installed the Adreno SDK, says "Emulator failure. Could not initialized ES11 entry point:__es11Initialize". I tried running "AdrenoShaders" in its Assets directory too and there it crashes unexpectedly.

  • Up0
  • Down0
RelativeGames
Profile picture
Join Date: 16 Apr 13
Posts: 56
Posted: Tue, 2014-01-14 15:50

I looked over the tutorial, it seems to me it just exports a single Attribute for Transform Feedback, I'm trying to export 3, I'll post my VS here :

#define EnableStreamOut

#define IsSkinned

in vec4 POSITION;

uniform mat4 WorldMatrix;
uniform mat4 ProjectionMatrix;

#ifdef EnableStreamOut
    in vec2 TEXCOORD;
    in vec3 NORMAL;

    out vec3 WorldPosOut;
    out vec2 TexcoordOut;
    out vec3 NormalOut;
#endif


#ifdef IsSkinned
    attribute vec4 BONE_INDICES;
    attribute vec4 BONE_WEIGHTS;

    uniform mat4 BoneMatrix[30];
#endif

void main()
{
    vec3 WorldPos;
    #if defined(IsSkinned)
        mat4 SkinTransform = BoneMatrix[ int(BONE_INDICES.x) ] * BONE_WEIGHTS.x;
    
        SkinTransform += BoneMatrix[ int(BONE_INDICES.y) ] *  BONE_WEIGHTS.y;
        SkinTransform += BoneMatrix[ int(BONE_INDICES.z) ] *  BONE_WEIGHTS.z;
        SkinTransform += BoneMatrix[ int(BONE_INDICES.w) ] *  BONE_WEIGHTS.w;
        
        WorldPos = ( SkinTransform * vec4( POSITION.xyz, 1) ).xyz;
    #else
        WorldPos = POSITION.xyz;
    #endif

    #ifdef EnableStreamOut
        WorldPosOut = WorldPos;
        TexcoordOut = TEXCOORD;
        NormalOut = NORMAL;
    #endif

    vec3 WorldPosShadow = ( WorldMatrix * vec4(WorldPos, 1) ).xyz;
    gl_Position = ProjectionMatrix * vec4(WorldPosShadow, 1);
}

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Tue, 2014-01-14 16:09

We’ve typically seen this when the developer has an older version of the emulator libraries that their app is linking with.

Basically the error is caused by linking with older emulator libraries. We no longer distribute the ES11 libraries, so if these older emulator libraries are being linked against they’re going to try to load those ES11 libraries that no longer exist, causing the error.

 

  • Up0
  • Down0
RelativeGames
Profile picture
Join Date: 16 Apr 13
Posts: 56
Posted: Wed, 2014-01-15 04:19

Ok, but I never installed this SDK up until now, I just built with VS2012 and got this. The post link step kind of fails, and must be from Windows 8, you can't easily modify PATH in Win8. As I see it links with

libEGL_d.lib
libGLESv2_d.lib
DelayImp.lib

So it doesn't like with ES 1.1. Does it manually call LoadLibrary ?

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Wed, 2014-01-15 08:02

Might need more information about which library needs to be loaded.  There shouldn't be a reason to link to ES1.1 libraries anymore.

  • Up0
  • Down0
RelativeGames
Profile picture
Join Date: 16 Apr 13
Posts: 56
Posted: Thu, 2014-01-23 19:50

I looked a bit more into it and it seems it fails in

EGLDisplay eglDisplay = eglGetDisplay( EGL_DEFAULT_DISPLAY );

This is the stack for when I get the message "Emulator failure. Could not initialized ES11 entry pointL __es11Initialize" :

     user32.dll!WaitMessage() + 12 bytes    Unknown
     [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]    
     user32.dll!EnumThreadWindows() + 543 bytes    Unknown
     user32.dll!DrawFocusRect() + 316 bytes    Unknown
     user32.dll!SoftModalMessageBox() + 1689 bytes    Unknown
     user32.dll!CheckRadioButton() + 3294 bytes    Unknown
     libEGL.dll!_eglDestroyImageKHR@8() + 4449 bytes    Unknown
     KernelBase.dll!LoadLibraryExA() + 50 bytes    Unknown
     libEGL.dll!_eglGetDisplay@4() + 103 bytes    Unknown
>    TransformFeedbackES3.exe!WinMain(HINSTANCE__ * __formal=0x00400000, HINSTANCE__ * __formal=0x00000000, char * __formal=0x002457be, int __formal=10) Line 817    C++
     TransformFeedbackES3.exe!__tmainCRTStartup() Line 528    C
 

So basically nothing starts. VS tells me libEGL.dll and libGLESv2.dll have been loaded so no idea it's trying to load, maybe it tries to fetch some weird extension that doesn't exist on my AMD GPU ? Was this tested on Windows 8 + AMD GPUs ?

  • Up0
  • Down0
RelativeGames
Profile picture
Join Date: 16 Apr 13
Posts: 56
Posted: Thu, 2014-01-23 20:02

Ok, so I have found the issue. It's because I already have the PowerVR SDK installed, it installed libEGL.dll, libGLES_CM.dll and libGLESv2.dll to my C:\Windows\SysWOW64 directory so there was a chance that those were loaded instead of the ones from the Adreno SDK. The weird thing is that the Adreno SDK doesn't contain libGLES_CM.dll but it was being loaded anyway ! Because of that I think it was calling PowerVR code that failed.

  • Up0
  • Down0
RelativeGames
Profile picture
Join Date: 16 Apr 13
Posts: 56
Posted: Thu, 2014-01-23 20:28

Ok, so after about an hour spent into understanding the transform feedback sample I realize it doesn't even do what it's intended and is completely wrong !

First odd point is this : it tries to render to a transform feedback buffer set up with GL_STATIC_DRAW, this is incorrect as it only resides in GPU memory, GL_STATIC_COPY is the right parameter.

Secondly, the transform feedback buffer that is being outputted is NEVER USED. The demo just renders from In memory data and from buffer data (kinda weird too to mix them up) to the transform feedback buffer and then doesn't touch that buffer again, it could work well or it could not work at all you never know.

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Tue, 2014-02-18 15:38

After reviewing the sample, we agree that the feedback buffer is not read and also that GL_STATIC_DRAW is not the correct parameter (GL_DYNAMIC_COPY is more appropriate).  We'll be making changes to this sample in an upcoming SDK release.

  • Up0
  • Down0
Sonicadvance1
Join Date: 2 Nov 12
Posts: 51
Posted: Thu, 2014-04-24 02:19

Testing with the latest development drivers, there is still the issue of GL_UNSIGNED_BYTE producing undefined results with glVertexAttribPointer. Seems to have the same outcome with glVertexAttribIPointer as well.

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Mon, 2014-04-28 07:56

Thanks again for reporting.

1) Is it just GL_UNSIGNED_BYTE - what about GL_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, or GL_INT

2) What feedback do you get to conclude undefined results? (is it crashing?)

3) Any glError returned?

4) Is there a simple test apk you can provide?

 

 

 

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Mon, 2014-04-28 07:56

Thanks again for reporting.

1) Is it just GL_UNSIGNED_BYTE - what about GL_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, or GL_INT

2) What feedback do you get to conclude undefined results? (is it crashing?)

3) Any glError returned?

4) Is there a simple test apk you can provide?

 

 

 

  • Up0
  • Down0
RelativeGames
Profile picture
Join Date: 16 Apr 13
Posts: 56
Posted: Tue, 2014-04-29 02:19

 

Side note on this one, the official GLES3 specs say that glDrawElements is not supported when doing transform feedback, only glDrawArrays ( I was testing on Desktop AMD hardware where this works btw ).

And secondly, is dynamic uniform access fixed in qualcomm drivers ? like if I have

uniform vec4 somefloats[20];

vec4 Func()

{

return somefloats[ int(PerVertexAttrib.x)];

}

does it work as expected ? I know a moderator said it's optional in GLES2 but I think it should be mandatory in GLES3, is it not ?

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Tue, 2014-04-29 07:01

Array indxing with uniforms using non-constant values should work in our current drivers.  Let me know which driver it is failing on.

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.