Imagination PowerVR SDK Blog

Using Discard and Colour Writes on SGX540

pvrtrace

#1

Hi,



This is with a Samsung Galaxy Nexus I9250



We have a situation where we’d like to use discard + a texture to mask out stencil areas that we cannot do easily with geo. Unfortunately on the SGX540 this seems to mean that when we disable colour writes during the stencil pass, the call gets ignored and the shader output is written to the colour buffer. Is this a hardware level thing to do with discard? Or is there some unknown state/driver issue in GLES 2.0 and perhaps the Galaxy Nexus? SGX535 and SGX543 deal with this fine (on iphone).



Below is command buffer data for one of the stencil writes:



glUseProgram(1050015)

glDisable(GL_BLEND)

glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE)

glDisable(GL_DEPTH_TEST)

glEnable(GL_STENCIL_TEST)

glStencilFuncSeparate(GL_FRONT,GL_NOTEQUAL,255,255)

glStencilFuncSeparate(GL_BACK,GL_ALWAYS,255,255)

glDepthFunc(GL_ALWAYS)

glDepthMask(GL_FALSE)

glStencilMask(255)

glStencilOpSeparate(GL_FRONT,GL_KEEP,GL_KEEP,GL_INCR)

glStencilOpSeparate(GL_BACK,GL_KEEP,GL_KEEP,GL_KEEP)

glActiveTexture(GL_TEXTURE0)

glBindTexture(GL_TEXTURE_2D,4900070)

glUniform1i(4,0)

glBindBuffer(GL_ARRAY_BUFFER,0)

glBindBuffer(GL_ARRAY_BUFFER,2450035)

glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,16,NULL)

glVertexAttribPointer(5,2,GL_UNSIGNED_BYTE,GL_TRUE,16,0xc)

glDrawArrays(GL_TRIANGLE_STRIP,0,4,)


#2

Hi Rcannell,



Do you have a small test app that displays this behaviour? Or possibly a PVRTrace capture? Otherwise I’ll try to port your command buffer code into a small test App myself, but if you happen to have one already that would obviously speed things up :slight_smile:



Thanks,

Tobias


#3

Hi Tobias,



I’ll see if I can get you a test app, but probably won’t be able to do it until early next week. Or I can send you the complete PVRTrace if you want - it is about 10mb I think because I captured across multiple pages.


#4

It looks like I can export one frame out of my mega capture, so I’ll do that and then I can send that :slight_smile:



Is there an ftp/email/upload place for files?


#5

Hi Rcannell,



If you could attach your trace to a support ticket that’d be great, thanks :slight_smile:



Tobias