[***MetalGL ERROR***] GL_INVALID_OPERATION. glTexParameteri()


Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #743
    anchor
    Participant

      hello 🙂

      i integrated MetalGL into our existing app as described in the doc, and i got the following error at app launch:

      [mgl-info] OpenGL functionality using Metal provided by MetalGL 0.10.0 (build 1) using 64-bit build.
      [mgl-info] You require a MetalGL license for the OpenGL ES 2.0 Core feature set. Reverting to evaluation mode.
      [mgl-info] You require a MetalGL license for the OpenGL ES 2.0 Extensions feature set. The function glTexParameteri() uses functionality found in OpenGL ES 2.0 extension ‘EXT_texture_filter_anisotropic’. Reverting to evaluation mode.
      [***MetalGL ERROR***] GL_INVALID_OPERATION. glTexParameteri(): The default texture cannot be changed.
      2015-11-05 17:42:16.047 App_MetalGL[721:84235] applicationDidBecomeActive
      (lldb)

      and the app crashes (release build). am i missed something?

      with debug build, the app launches fine, but 32 bit mentioned:
      [mgl-info] OpenGL functionality using Metal provided by MetalGL 0.10.0 (build 1) using 32-bit build.

      (xcode 7.1 , iOS 9.1 , iPadMini2)

      any idea? 🙂

      EDIT: if i remove the glTexParameteri(GL_TEXTURE_COMPARE…) calls the error not showed, but the app still crashes somewhere in UIApplicationMain()
      We use Horde3D render engine ES2 port. (http://horde3d.org)

      #746
      Bill Hollings
      Keymaster

        @anchor

        The glTexParameter() call is likely failing because texture ID = 0 is bound to the GL engine when you make that call. OpenGL ES forbids modifying the default texture in any way, but if your app is getting away with it elsewhere, it might be ignored by the native OpenGL ES driver.

        Is the first logging above coming from a Release build? And is the glTexParameter() actually causing the crash due to an assertion? It should not be performing assertions in a Release build unless you have added the DEBUG build setting, or unless you have enabled either the GL_ERROR_ASSERTION_MGL or GL_DEBUG_MODE_MGL MetalGL capabilities (using glEnable()).

        The 32-bit build you mention is likely coming from the build settings in your app project. Can you double-check them?

        When you use Horde3D, are you compiling the Horde3D library with MetalGL as well, or just your app code? It is important that all code that issues OpenGL ES calls be compiled against MetalGL, including any library code.

        …Bill

        #747
        anchor
        Participant

          hello Bill, thanks for the quick reply.

          yes, the first log is coming from release build. the second one from debug version is just one line.
          horde3d compiled by source, not as lib. shadow feature is not used, and i commented out its setup in horde3d, but the crash still occurs.
          xcode cant help to determine where, so i grabbed the crash log from the device:

          
          Hardware Model: iPad4,5
          Process: IronWar_MetalGL [705]
          Path: /private/var/mobile/Containers/Bundle/Application/747D5775-1364-439E-8DC8-3731A00A8436/IronWar_MetalGL.app/IronWar_MetalGL
          Identifier: com.herocraft.ironwar
          Version: 0.0.27 (0.0.27)
          Code Type: ARM-64 (Native)
          Parent Process: launchd [1]
          
          Date/Time: 2015-11-05 17:41:07.07 +0100
          Launch Time: 2015-11-05 17:40:59.59 +0100
          OS Version: iOS 9.1 (13B143)
          Report Version: 105
          
          Exception Type: EXC_BAD_ACCESS (SIGBUS)
          Exception Subtype: KERN_PROTECTION_FAILURE at 0x0000000155e57710
          Triggered by Thread: 0
          
          Filtered syslog:
          None found
          
          Breadcrumb Trail: (reverse chronological seconds)
          0 GC Framework: startAuthenticationForExistingPrimaryPlayer
          
          Thread 0 name: Dispatch queue: com.apple.main-thread
          Thread 0 Crashed:
          0 ??? 0x0000000155e57710 0 + 5736068880
          1 GLKit 0x0000000185511030 0x1854f0000 + 135216
          2 GLKit 0x0000000185511294 0x1854f0000 + 135828
          3 QuartzCore 0x00000001891d74d8 0x1891b0000 + 160984
          4 QuartzCore 0x00000001891b9944 0x1891b0000 + 39236
          5 QuartzCore 0x00000001891b9630 0x1891b0000 + 38448
          6 QuartzCore 0x00000001891b8cc0 0x1891b0000 + 36032
          7 QuartzCore 0x00000001891b8a08 0x1891b0000 + 35336
          8 QuartzCore 0x00000001891b20f8 0x1891b0000 + 8440
          9 CoreFoundation 0x00000001843e7bd0 0x18430c000 + 900048
          10 CoreFoundation 0x00000001843e5974 0x18430c000 + 891252
          11 CoreFoundation 0x0000000184314cc0 0x18430c000 + 36032
          12 UIKit 0x0000000189a321c8 0x1899ac000 + 549320
          13 UIKit 0x0000000189a2cffc 0x1899ac000 + 528380
          14 IronWar_MetalGL 0x00000001000bdb80 0x1000b8000 + 23424
          15 libdyld.dylib 0x00000001999a28b8 0x1999a0000 + 10424
          

          in release build no DEBUG is defined, and im not used the mentioned metal debug flags.
          yes, in debug mode only armv7 version generated, that is why i see 32bit version.
          if i generating only 32bit version in release mode, it is also working fine. this crash
          happening only with 64bit version. alas i did not see any fps increase with MetalGL in 32 bit release build.
          maybe Metal available only with 64bit? because debug 64bit also crashes before the first update call

          NOTE: i read about 2bpp pvrtc textures in another thread. we use many 2bpp pvrtc textures 🙂

          thanks 😉

          #748
          Bill Hollings
          Keymaster

            @anchor

            Yes, MetalGL in 32-bit mode currently bypasses Metal, so that 32-bit-only devices don’t try to use it. So, when running in 32-bit mode, you are running native OpenGL ES. We could look into supporting 32-bit mode, but since Apple actively discourages using 32–bit mode on 64-bit devices, it’s not a critical long-term strategy.

            Based on your crash log, it looks like you are using GLKit. How much of GLKit are you using? The only part of GLKit that MetalGL supports is GLKView. If you are using GLKView, the README-UserGuide.md document explains how to use it with MetalGL. Specifically, if you have an Storyboard that uses GLKView, you need to establish and use an empty GLKView subclass, so that the Storyboard loader won’t try to load the default system GLKView class (and thereby bypass the MetalGL overrides).

            If 2bpp PVRTC textures are critical, we can look to add support for them sooner rather than later.

            …Bill

            #749
            anchor
            Participant

              thanks for the explanation, now our app is cooperating with MetalGL. unfortunately the 2D overlays are not showing at all, only the 3D part.
              so we have no buttons / texts / gui-screens. the only 2D thing is the blinking MetalGL logo 🙂

              NOTE: as i see 2bpp pvr textures loaded and rendered fine. so it is supported somehow 🙂

              debug output about shader conversion:

              
              [mgl-info] Converting GLSL:
              #version 100
              
              uniform mat4 viewProjMat;
              uniform mat4 worldMat;
              attribute vec3 vertPos;
              void main() {
              	gl_Position = viewProjMat * worldMat * vec4( vertPos, 1.0 );
              }
              
              End GLSL
              
              [mgl-info] Converted MSL:
              #include <metal_stdlib>
              using namespace metal;
              struct xlatMtlShaderInput {
                float3 vertPos [[attribute(0)]];
              };
              struct xlatMtlShaderOutput {
                float4 gl_Position [[position]];
              };
              struct xlatMtlShaderUniform {
                float4x4 viewProjMat;
                float4x4 worldMat;
              };
              vertex xlatMtlShaderOutput VertexShader1 (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
              {
                xlatMtlShaderOutput _mtl_o;
                float4 tmpvar_1;
                tmpvar_1.w = 1.0;
                tmpvar_1.xyz = _mtl_i.vertPos;
                _mtl_o.gl_Position = ((_mtl_u.viewProjMat * _mtl_u.worldMat) * tmpvar_1);
                return _mtl_o;
              }
              
              End MSL
              
              [mgl-info] Converting GLSL:
              #version 100
              
              uniform  vec4 color;
              void main() {
              	gl_FragColor = color;
              }
              
              End GLSL
              
              [mgl-info] Converted MSL:
              #include <metal_stdlib>
              using namespace metal;
              struct xlatMtlShaderInput {
              };
              struct xlatMtlShaderOutput {
                half4 gl_FragColor;
              };
              struct xlatMtlShaderUniform {
                float4 color;
              };
              fragment xlatMtlShaderOutput FragmentShader2 (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
              {
                xlatMtlShaderOutput _mtl_o;
                _mtl_o.gl_FragColor = half4(_mtl_u.color);
                return _mtl_o;
              }
              
              End MSL
              
              [mgl-info] Converting GLSL:
              #version 100
              
              uniform mat4 projMat;
              attribute vec2 vertPos;
              attribute vec2 texCoords0;
              varying vec2 texCoords;
              void main( void )
              {
              	texCoords = vec2( texCoords0.s, -texCoords0.t ); 
              	gl_Position = projMat * vec4( vertPos.x, vertPos.y, 1, 1 );
              }
              
              End GLSL
              
              [mgl-info] Converted MSL:
              #include <metal_stdlib>
              using namespace metal;
              struct xlatMtlShaderInput {
                float2 vertPos [[attribute(0)]];
                float2 texCoords0 [[attribute(1)]];
              };
              struct xlatMtlShaderOutput {
                float4 gl_Position [[position]];
                float2 texCoords;
              };
              struct xlatMtlShaderUniform {
                float4x4 projMat;
              };
              vertex xlatMtlShaderOutput VertexShader3 (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
              {
                xlatMtlShaderOutput _mtl_o;
                float2 tmpvar_1;
                tmpvar_1.x = _mtl_i.texCoords0.x;
                tmpvar_1.y = -(_mtl_i.texCoords0.y);
                _mtl_o.texCoords = tmpvar_1;
                float4 tmpvar_2;
                tmpvar_2.zw = float2(1.0, 1.0);
                tmpvar_2.xy = _mtl_i.vertPos;
                _mtl_o.gl_Position = (_mtl_u.projMat * tmpvar_2);
                return _mtl_o;
              }
              
              End MSL
              
              [mgl-info] Converting GLSL:
              #version 100
              
              uniform  vec4 olayColor;
              uniform sampler2D albedoMap;
              #ifdef _F01_
               uniform sampler2D aiMap;
              #endif
              varying  vec2 texCoords;
              void main( void )
              {
              	 vec4 albedo = texture2D( albedoMap, texCoords );
              	gl_FragColor = albedo * olayColor;
              #ifdef _F01_
              	 vec4 aicolor = texture2D( aiMap, vec2(texCoords.s,texCoords.t) );
              	gl_FragColor.rgb *= aicolor.a;
              #endif
              }
              
              End GLSL
              
              [mgl-info] Converted MSL:
              #include <metal_stdlib>
              using namespace metal;
              struct xlatMtlShaderInput {
                float2 texCoords;
              };
              struct xlatMtlShaderOutput {
                half4 gl_FragColor;
              };
              struct xlatMtlShaderUniform {
                float4 olayColor;
              };
              fragment xlatMtlShaderOutput FragmentShader4 (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
                ,   texture2d<half> albedoMap [[texture(0)]], sampler _mtlsmp_albedoMap [[sampler(0)]])
              {
                xlatMtlShaderOutput _mtl_o;
                half4 tmpvar_1;
                tmpvar_1 = albedoMap.sample(_mtlsmp_albedoMap, (float2)(_mtl_i.texCoords.x, (1.0 - _mtl_i.texCoords.y)));
                _mtl_o.gl_FragColor = ((half4)((float4)tmpvar_1 * _mtl_u.olayColor));
                return _mtl_o;
              }
              
              End MSL
              
              #751
              Bill Hollings
              Keymaster

                @anchor

                Strange. There is no difference between 2D and 3D components in OpenGL (or MetalGL). Are the 2D components being rendered by Horde as well, or are they being rendered from a different library that might not be compiled with MetalGL?

                You can try capturing a GPU frame to track down what’s happening with the 2D draw calls in Metal. That Apple doc describes capturing an OpenGL ES frame, but when running on Metal, it will capture a Metal frame.

                Capturing a GPU frame requires you to be in Debug mode, and have enabled frame capture in the Options pane of the Xcode Scheme Editor:

                Xcode Scheme Editor Options pane

                …Bill

                #753
                anchor
                Participant

                  yes, everything is rendered with horde3d. i captured gpu frames, but i dont know what should i see.
                  uploaded them to: gpu capture
                  some transparent 3d mesh also not rendered, or invisible.

                  EDIT1: the gpu capture made in debug mode, and with options showed above.

                  EDIT2: i tried to capture one original es2 frame without MetalGL, and it looks somehow totally different.

                Viewing 7 posts - 1 through 7 (of 7 total)
                • The forum ‘MoltenGL Support’ is closed to new topics and replies.