Imagination PowerVR SDK Blog

Colours turn to Black on using Print3D


#1

Hi,



I had got all the colourful objects in my scene. Then, I started using Print3D class to print information like FPS etc on the screen. But, when I run the program, every object turns black although the text is printed correctly on the screen. During running, I also get the following warnings :



PVR:(Warning): UnpackRevision: The SGX core flag is 0x535 but we expected 0x544. [312, /binshader.c]

PVR:(Warning): UnpackRevision: The GLSL compiled Uniflex interface revision flag is 0x0 but we expected 0x2. [1138, /binshader.c]

PVR:(Warning): UnpackRevision: The Unipatch input revision flag is 0x0 but we expected 0x25. [1145, /binshader.c]

PVR:(Warning): UnpackRevision: Couldn’t find a revision that matches the current hardware and driver. [1176, /binshader.c]



Can someone help ?


#2

Hello



did you define the usageof the default texture

m_Print3D.SetTextures(NULL, uiWidth, uiHeight, bRotate);

did you FLush ?

m_Print3D.Flush();

what will be your clear color :

// Clears the color and depth buffer

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



like describe in the sample OGLES2IntroducingPrint3 ?



regards

david


#3

Yes, I did all the above things. I will give you a brief overview of the code :



InitView()

{

//Compiling shaders



rotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);



if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), rotate) != PVR_SUCCESS)

{

PVRShellSet(prefExitMessage, “ERROR: Cannot initialise Print3Dn”);

return false;

}

}



RenderScene()

{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



//Camera Calculations



for(i=0;i<nummeshes;i++)

{

glBindBuffer(GL_ARRAY_BUFFER, m_ui32Vbo);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ui32Ibo);



glEnableVertexAttribArray(VERTEX_ARRAY);

glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, 0);

glEnableVertexAttribArray(COLOUR_ARRAY);

glVertexAttribPointer(COLOUR_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, 0);



glDrawElements(GL_TRIANGLES, facecount * 3, GL_UNSIGNED_SHORT, NULL);



glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

}





m_Print3D.DisplayDefaultTitle(“HELLO”, “”, NULL);

m_Print3D.Flush();

}


#4

can you set a clear color in the InitView to see

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


#5

Right now, I have set it to be :



glClearColor(0.7f, 0.85f, 1.0f, 1.0f);



I can see the blue sky. Only the objects have turned black.


#6

so it s the color array that you set then


#7

I didn’t get you.


#8

Hi,



Q1: Are your objects still black when you remove Print3D from your render (i.e. disable m_Print3D.Flush();)?



Q2: The “PVR:(Warning): UnpackRevision: …” output sounds like an issue with shader binaries. Are you compiling shaders from GLSL ES source on each application run, or are you trying to use shader program binaries you’ve pre-compiled?



Thanks,

Joe


#9

When I comment every line containing the Print3D variable, the colours are fine. I compile the shaders on each run.


#10

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.



Thanks,

Joe


#11

I will do that first thing tomorrow…


#12

something is probably wrong in the shader implementation then no?


#13

The shader codes are merely 2 lines of code. What can be wrong in them ?


#14

Joe, what did you mean exactly by resetting the render state of OpenGL ES ?


#15

You need to reset anything that has been toggled with glEnable/glDisable and bind shaders, textures & buffers needed by your draw calls.



Based on the code snippets you’ve supplied, it may just be glUseProgram() that needs to be set again. To be safe, you should reset all of your render state and bindings.



Thanks,

Joe


#16

I did reset every thing in my RenderScene(). After that, both the colours and the text were visible, but after 1 second, the application hangs and exits abruptly with many error messages like glBuffer can’t allocate space, etc.


#17

These are the error messages :



PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff97: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff99: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff9b: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff9d: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xff9f: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa1: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa3: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa5: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa7: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffa9: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffab: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffad: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffaf: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb1: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb3: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb5: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb7: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffb9: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffbb: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffbd: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffbf: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffc1: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Error): PVRPMapKMem: mmap(2) failed: Mapping handle=0xffc3: Cannot allocate memory [133, /pvr_mmap.c]

PVR:(Error): PVRSRVAllocDeviceMem : PVRPMapKMem failed for syncdata [1005, /bridged_pvr_glue.c]

PVR:(Error): glBufferData: Can’t allocate memory for object [2076, /bufobj.c]

PVR:(Fatal): Debug assertion failed! [1324, /drawvarray.c]



#18

Hi,



Have you moved your buffer creation code to RenderScene()? From the errors, I think you may be creating new buffers every frame without releasing any existing memory, which is causing the graphics driver to run out of memory.



You should only move the bind operations to the RenderScene() function to make sure the correct shaders, buffers & textures are bound when your draw calls are submitted.



Thanks,

Joe


#19

Thanks Joe. That was the problem indeed. I mistakenly copied the buffer creation code too. Now it’s working fine.