Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Video Crash from glDrawArrays API Call in Native Plugin iOS

Discussion in 'Audio & Video' started by superbderrick, Nov 6, 2018.

  1. superbderrick

    superbderrick

    Joined:
    Mar 21, 2017
    Posts:
    2
    Hi, All

    Currently I am making Simple VideoPlayer using Unity NativePlugin External Texture API for iOS
    Using iOS VideoToolbox API , I got CVPixelbuffer and made images with CVOpenGLESTextureCacheCreateTextureFromImage API

    it is working well just Image to pass to C# layer without any GL actions

    However when I tried to pass texture with some GL actions to make fit screen in Texture , it occurs Metal Crash ,

    Crash message
    --
    GLDRendererMetal command buffer completion error: Error Domain=MTLCommandBufferErrorDomain Code=4 "Ignored (for causing prior/excessive GPU errors) (IOAF code 4)" UserInfo={NSLocalizedDescription=Ignored (for causing prior/excessive GPU errors) (IOAF code 4)}
    --


    I am working on Unity 2018.1.1f1 version and I set up for the Graphic API's order only OpenGL mode

    I have configured my shader codes below

    static const char *vshadersrc =

    "attribute vec4 position;\n"

    "attribute vec2 texCoord;\n"

    "uniform float preferredRotation;\n"

    "uniform float translation;\n"

    "uniform float scale;\n"

    "\n"


    "varying vec2 texCoordVarying;\n"

    "\n"

    "void main()\n"

    "{\n"

    " mat3 window_scale = mat3(\n"

    " vec3(scale, 0.0, 0.0),\n"

    " vec3( 0.0, scale, 0.0),\n"

    " vec3( 0.0, 0.0, 1.0)\n"

    " );\n"

    " gl_Position = vec4(position.xyz * window_scale, 1.0);\n"

    " texCoordVarying = texCoord;\n"

    "}\n"

    ;

    static const char *fshadersrc_cvpixelbuffer =

    "varying highp vec2 texCoordVarying;\n"

    "precision mediump float;\n"

    "\n"

    "uniform sampler2D SamplerY;\n"

    "\n"

    "void main()\n"

    "{\n"

    " gl_FragColor = texture2D(SamplerY, texCoordVarying);\n"

    "}\n"

    ;


    and after made images with CVOpenGLESTextureCacheCreateTextureFromImage API

    I called like this

    GLint oldTexBinding = 0;
    GLES_CHK(glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexBinding));

    GLES_CHK( glActiveTexture(GL_TEXTURE0) );

    GLES_CHK(glBindTexture(GL_TEXTURE_2D, (GLuint)retTex));

    GLES_CHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));

    GLES_CHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));

    GLES_CHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));

    GLES_CHK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));

    GLES_CHK(glBindTexture(GL_TEXTURE_2D, oldTexBinding));


    glClearColor(0.0f, 0.0f, 0.1f, 1.0f);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    GLES_CHK(glUseProgram(program));

    GLint uniform_y = glGetUniformLocation(program, "SamplerY");

    glUniform1i(uniform_y, NEX_GLTEXTURE_INDEX_0);



    ShaderParams params;

    params.translation = 0;

    params.scale = 0.5;

    _setShaderParams(program, params);

    _drawArrays(program, 1, 1);



    crash occurs after the call to the drawArrays function


    Is there anybody who can give me a solution?