InitView() fails due to mPrint3d.SeTextures

This topic contains 19 replies, has 3 voices, and was last updated by  golden_gate 4 years, 3 months ago.

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #31344

    EDITED to make it clear that I added an additional shader, so there are two shader programs created in LoadShaders()

    I am running the OGLES2ParallaxBumpMap application in SDK 3.0.

    There is a LoadShaders() function. I have added my own shader into the application IN ADDITION to the one that is already in the example/App. So now there are two shader programs being created in load LoadShaders() I receive no error handling messages. For some reason InitView fails due to m_Print3D.SetTextures.

    The error I get is :

    PVRTTextureLoadFromPointer failed: glBindTexture() failed.
    Exit message has been set to: “ERROR: Cannot initialise Print3D

    It happens in the following block.

    if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS)
    {
    PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3Dn");
    return false;
    }

    The following is my code that I added into LoadShaders(). Again, I get no error handling messages. But what I noticed is that when I comment out PVRTCreateProgram() the program does not crash (succesfully go through InitView).

    I receive no error handling messages for PVRTCreateProgram() when InitView fails. I googled the error messages and saw that there could be some state issues. I am not trying to load up any additional textures. Is there some resource/state issue I have caused by trying to create another shader program?

    The code I am using is the same code in the original LoadShaders() function –> OGLES2ParallaxBumpMap::LoadShaders(CPVRTString* pErrorStr)

    if (PVRTShaderLoadFromFile(
    media_szVertShaderBinFile, media_szVertShaderSrcFile, GL_VERTEX_SHADER, GL_SGX_BINARY_IMG, &media_VertShader, pErrorStr) != PVR_SUCCESS)
    {
    return false;
    }

    if (PVRTShaderLoadFromFile(
    media_szFragShaderBinFile, media_szFragShaderSrcFile, GL_FRAGMENT_SHADER, GL_SGX_BINARY_IMG, &media_FragShader, pErrorStr) != PVR_SUCCESS)
    {
    return false;
    }

    /*
    Set up and link the shader program
    */

    if (PVRTCreateProgram(&media_ShaderProgram.uiId, media_VertShader, media_FragShader, media_aszAttribNames, eMediaNumAttribs, pErrorStr) != PVR_SUCCESS)
    {

    PVRShellSet(prefExitMessage, pErrorStr->c_str());
    return false;
    }

    // Store the location of uniforms for later use
    for (int i = 0; i < eMediaNumUniforms; ++i)
    {
    media_ShaderProgram.auiLoc = glGetUniformLocation(media_ShaderProgram.uiId, media_aszUniformNames);
    }

    #37677

    dgu
    Member

    Hi Sir,

    it’ seems that there is a problem in the Shader that you added ,you can test it with PVR Shaman to see is there is nothing wrong ?

    i did a quick fast and dirty test base on the sample that you mention with two shaders and no prob at all

    bool OGLES2ParallaxBumpMap::LoadShaders(CPVRTString* pErrorStr)
    {
    /*
    Load and compile the shaders from files.
    Binary shaders are tried first, source shaders
    are used as fallback.
    */
    if (PVRTShaderLoadFromFile(
    c_szVertShaderBinFile, c_szVertShaderSrcFile, GL_VERTEX_SHADER, GL_SGX_BINARY_IMG, &m_uiVertShader, pErrorStr) != PVR_SUCCESS) {
    return false;
    }

    if (PVRTShaderLoadFromFile(
    c_szFragShaderBinFile, c_szFragShaderSrcFile, GL_FRAGMENT_SHADER, GL_SGX_BINARY_IMG, &m_uiFragShader, pErrorStr) != PVR_SUCCESS) {
    return false;
    }

    /*
    Load and compile the shaders from files.
    Binary shaders are tried first, source shaders
    are used as fallback.
    */
    if (PVRTShaderLoadFromFile(c_szFastVsBinFile,
    c_szFastVsSrcFile,
    GL_VERTEX_SHADER,
    GL_SGX_BINARY_IMG,
    &m_uiFastVertShader,
    pErrorStr) != PVR_SUCCESS) {
    *pErrorStr = CPVRTString("From file '") + c_szFastVsBinFile +
    "' or '" + c_szFastVsSrcFile + "':n" + *pErrorStr;
    PVRShellSet(prefExitMessage, pErrorStr->c_str());
    return false;
    }

    if (PVRTShaderLoadFromFile(c_szFastFsBinFile,
    c_szFastFsSrcFile,
    GL_FRAGMENT_SHADER,
    GL_SGX_BINARY_IMG,
    &m_uiFastFragShader,
    pErrorStr) != PVR_SUCCESS) {
    *pErrorStr = CPVRTString("From file '") + c_szFastVsBinFile +
    "' or '" + c_szFastVsSrcFile + "':n" + *pErrorStr;
    PVRShellSet(prefExitMessage, pErrorStr->c_str());
    return false;
    }
    /*
    Set up and link the shader programs
    */
    const char* aszAttribs[] = { "inVertex", "inNormal" };
    if (
    (PVRTCreateProgram(&m_FastShader.uiId, m_uiFastVertShader, m_uiFastFragShader, aszAttribs, 2, pErrorStr) != PVR_SUCCESS) ) {
    PVRShellSet(prefExitMessage, pErrorStr->c_str());
    return false;
    }

    /*
    Store the location of uniforms for later use
    */
    m_FastShader.uiMVPMatrixLoc = glGetUniformLocation(m_FastShader.uiId, "MVPMatrix");
    m_FastShader.uiMsLightDirLoc = glGetUniformLocation(m_FastShader.uiId, "msLightDir");
    m_FastShader.uiMsEyePosLoc = glGetUniformLocation(m_FastShader.uiId, "msEyePos");

    /*
    Set up and link the shader program
    */
    if (PVRTCreateProgram(&m_ShaderProgram.uiId, m_uiVertShader, m_uiFragShader, g_aszAttribNames, eNumAttribs, pErrorStr) != PVR_SUCCESS) {
    PVRShellSet(prefExitMessage, pErrorStr->c_str());
    return false;
    }

    // Store the location of uniforms for later use
    for (int i = 0;
    i < eNumUniforms;
    ++i) {
    m_ShaderProgram.auiLoc = glGetUniformLocation(m_ShaderProgram.uiId, g_aszUniformNames);
    }

    return true;
    }

    #37678

    Edit : I ran the my vertex and fragment shaders in PVRShaman … There were no issues.

    Hi Dgu, you mentioned that you tried on two different shaders. My issue was running the code base in the LoadShaders() two time in a row (sequentially). Load 2 different shaders one after another in the same app VERSUS running one shader at at a time.

    Can you confirm?

    Thanks

    #37679

    dgu
    Member

    maybe you should load all your shades and bind them in the same method then or use parameters , index to load then by using function argument.
    calling load shader twice is allow of course if you dont affect twice the same VBO , maybe some shaderName is passed as argument
    Initview () is where rendering API are initialized,that is all , it should not be call twice manually as well .

    kind regards
    david

    #37680

    Hi @dgu. Thanks for your response. I load and bind them in the same method as mentioned in my original post.

    I am aware of InitView()..and understand that it can not be called twice.

    #37681

    dgu
    Member

    in the code you provided , you use only one shader media_szFragShader right ?

    #37682

    Thanks for responding. The code I provided loads media_szFragShader and media_szVertShaderSrcFile. As mentioned its in LoadShaders(). Before this code snipet runs there is code that loads another vertex/fragment shader pair … fo course with different variables.

    I have looked in xcode where InitView fails and all shaders are loaded. I have read several other e-mails about mprint3d and it can cause some state issues. i don’t know why even there would be bind texture issue when I am not even doing that.

    #37683

    dgu
    Member

    Hello

    Joe mention once :

    Print3D has to change the OpenGL ES renderstate before it can render, for example enable blending if it is disabled. Print3D should revert the renderstate once it has finished rendering.

    As a test, can you reset your renderstate at the start of your RenderScene() function? If this fixes the problem, then this suggests that there is a bug in Print3D’s renderstate revert mechanism.

    #37684

    Edit: I don’t know that would help anyway. I can’t get to the RenderScene() function if I can’t succeed with InitView as I have mentioned in the original post. Thanks for your help though.

    Yes, I have seen that statement before … how do you specifically reset your renderstate.. thats vague

    #37685

    dgu
    Member

    is it possible to see your test code ? it will be more easy by my side if it s ok with you ?

    #37686

    dgu
    Member

    many apologize , it s not clear at all for me because i dont understand why you bind twice the same &media_ShaderProgram.uiId

    regardsd
    avid

    #37687

    No worries 🙂 .. I don’t bind the same shader program twice.. I have two different shader programs that I did not create .. two different shader programs that I can use at run time. So when I try to load two different shaders there is a state issue lock somewhere.

    #37688

    Here is the entire LoadShaders() method –>
    I just run the same load/create shader methods twice.. of course with different variables for the shader programs.

    I don’t why this would produce state issues.

    /*!****************************************************************************
    @Function LoadShaders
    @Output pErrorStr A string describing the error on failure
    @Return bool true if no error occurred
    @Description Loads and compiles the shaders and links the shader programs
    required for this training course
    ******************************************************************************/
    bool OGLES2ParallaxBumpMap::LoadShaders(CPVRTString* pErrorStr)
    {
    /*
    Load and compile the shaders from files.
    Binary shaders are tried first, source shaders
    are used as fallback.
    */

    if (PVRTShaderLoadFromFile(
    c_szVertShaderBinFile, c_szVertShaderSrcFile, GL_VERTEX_SHADER, GL_SGX_BINARY_IMG, &m_uiVertShader, pErrorStr) != PVR_SUCCESS)
    {
    return false;
    }

    if (PVRTShaderLoadFromFile(
    c_szFragShaderBinFile, c_szFragShaderSrcFile, GL_FRAGMENT_SHADER, GL_SGX_BINARY_IMG, &m_uiFragShader, pErrorStr) != PVR_SUCCESS)
    {
    return false;
    }

    /*
    Set up and link the shader program
    */

    if (PVRTCreateProgram(&m_ShaderProgram.uiId, m_uiVertShader, m_uiFragShader, g_aszAttribNames, eNumAttribs, pErrorStr) != PVR_SUCCESS)
    {
    PVRShellSet(prefExitMessage, pErrorStr->c_str());
    return false;
    }

    // Store the location of uniforms for later use
    for (int i = 0; i < eNumUniforms; ++i)
    {
    m_ShaderProgram.auiLoc = glGetUniformLocation(m_ShaderProgram.uiId, g_aszUniformNames);
    }

    // OK NOW LETS DO THE SAME FLOW FOR MULTIMEDIA SHADERS/RESOURCES

    if (PVRTShaderLoadFromFile(
    media_szVertShaderBinFile, media_szVertShaderSrcFile, GL_VERTEX_SHADER, GL_SGX_BINARY_IMG, &media_VertShader, pErrorStr) != PVR_SUCCESS)
    {
    return false;
    }

    if (PVRTShaderLoadFromFile(
    media_szFragShaderBinFile, media_szFragShaderSrcFile, GL_FRAGMENT_SHADER, GL_SGX_BINARY_IMG, &media_FragShader, pErrorStr) != PVR_SUCCESS)
    {
    return false;
    }

    /*
    Set up and link the shader program
    */

    if (PVRTCreateProgram(&media_ShaderProgram.uiId, media_VertShader, media_FragShader, media_aszAttribNames, eMediaNumAttribs, pErrorStr) != PVR_SUCCESS)
    {
    NSLog(@"right here in the mist");
    PVRShellSet(prefExitMessage, pErrorStr->c_str());
    return false;
    }

    // Store the location of uniforms for later use
    for (int i = 0; i < eMediaNumUniforms; ++i)
    {
    media_ShaderProgram.auiLoc
    = glGetUniformLocation(media_ShaderProgram.uiId, media_aszUniformNames);
    }

    return true;
    }

    #37689

    Can someone from the IMG team comment on the state issues ( @Joe Davis )

    #37690

    dgu
    Member

    That is wierd , in the first post i sent to you i was doing the same , and it work.

Viewing 15 posts - 1 through 15 (of 20 total)
You must be logged in to reply to this topic.