Disable pixel shader

Started by
14 comments, last by _the_phantom_ 11 years, 10 months ago
Hi guys,

For some reasons, I want to disable the pixel shader (fragment shader). It means that the hardware will throw fragments away right after they come out of the rasterization stage so that the fragments can't be able to get into the next stage (pixel shader).

I know that we can disable rasterization stage by enabling RASTERIZER_DISCARD, is there any similarity with pixel? or any trick to do that?

Thank in advance,
-D
Advertisement
You can call glCullFace

[background=rgb(250, 251, 252)](GL_FRONT_AND_BACK). That will cull all faces of triangles, sending none to the fragment shader.[/background]

[size=2]Current project: Ephenation.
[size=2]Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/
glCullFace won't let the data get into the rasterization stage, but in my case, I still want primitives to be processed at rasterization stage.
What are you trying to achieve? Occlusion culling?
The general approach is to use glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE) but documentation I could find suggests that this just prevents the output colour from being written to the framebuffer - the shader will still run. Maybe your driver might be able to make an intelligent optimization, or maybe you can write a simple passthrough fragment shader for this purpose.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


What are you trying to achieve? Occlusion culling?

Nope. I just want to measure the processing time when pixel processing stage is disabled.
I doubt you're going to get a meaningful measurement here. OpenGL API calls are asynchronous and operate in parallel with work on your CPU, so the calls you make with the PS disabled may not have even started executing on the GPU yet when you take your measurement.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

You can use GL_TIME_ELAPSED queries tough. But i would also say trying to measure the vertex stage alone is not that useful since the measurement is totally synthetic and not relevant for real use cases. If anything just measure with a trivial fragment shader
Any kind of query is going to need to stall the pipeline during readback though, which will skew the results. The best way is probably to set up a test case without the pixel shader (or with it disabled) and let it run for a few minutes - because transient conditions on your PC may also skew the results when measured over a short timescale. Compare that against the same case run with the full pixel shader and you should get a meaningful enough relative measurement.

Even that won't be 100% perfect though as in a real program there will be all kinds of other stuff going on - CPU/GPU concurrency and concurrency of pipeline stages may even mean that an apparently complex pixel shader can be had for free.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


Any kind of query is going to need to stall the pipeline during readback though.

Only if you read back the result instantly, you can wait until it becomes available and read it back then.

This topic is closed to new replies.

Advertisement