• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
donguow

Disable pixel shader

15 posts in this topic

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
0

Share this post


Link to post
Share on other sites
You can call [url="http://www.opengl.org/wiki/GLAPI/glCullFace"]glCullFace[/url] [left][background=rgb(250, 251, 252)](GL_FRONT_AND_BACK). That will cull all faces of triangles, sending none to the fragment shader.[/background][/left] Edited by larspensjo
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
[quote name='japro' timestamp='1340630612' post='4952649']
What are you trying to achieve? Occlusion culling?
[/quote]
Nope. I just want to measure the processing time when pixel processing stage is disabled.
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
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
0

Share this post


Link to post
Share on other sites
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.
0

Share this post


Link to post
Share on other sites
[quote name='mhagain' timestamp='1340641768' post='4952695']
Any kind of query is going to need to stall the pipeline during readback though.
[/quote]
Only if you read back the result instantly, you can wait until it becomes available and read it back then.
1

Share this post


Link to post
Share on other sites
[quote]Nope. I just want to measure the processing time when pixel processing stage is disabled. [/quote]
gDEBugger does this, you can check the GL_GREMEDY_frame_terminator, GL_GREMEDY_string_marker and GL_ARB_debug_output extensions. Also you may want to check out the gDEBugger docs. Edited by Yours3!f
0

Share this post


Link to post
Share on other sites
[quote name='donguow' timestamp='1340634594' post='4952666']
Nope. I just want to measure the processing time when pixel processing stage is disabled.
[/quote]

It sounds like you want to check whether your program is fragment shader bound.
In that case, just make ultra simple fragment shader and measure execution time.
Otherwise, [b]glEnable(GL_RASTERIZER_DISCARD)[/b] is the way to disable fragment shaders execution.
Also, you could try to discard fragments in the fragment shader. It is, of course, meaningless, but maybe that will trigger some optimization in the drivers and totally eliminate FS.
0

Share this post


Link to post
Share on other sites
[quote name='Aks9' timestamp='1340665466' post='4952826']
[quote name='donguow' timestamp='1340634594' post='4952666']
Nope. I just want to measure the processing time when pixel processing stage is disabled.
[/quote]

It sounds like you want to check whether your program is fragment shader bound.
In that case, just make ultra simple fragment shader and measure execution time.
Otherwise, [b]glEnable(GL_RASTERIZER_DISCARD)[/b] is the way to disable fragment shaders execution.
Also, you could try to discard fragments in the fragment shader. It is, of course, meaningless, but maybe that will trigger some optimization in the drivers and totally eliminate FS.
[/quote]
I did use this way. This happens before rasterization stage. I am now testing with discarding fragments. This way, of course, is not perfectly correct but giving pixel shader as little work as possible seems not a bad idea though.
0

Share this post


Link to post
Share on other sites
I'm probably the worst GLSL programmer in the world , but why you don't try something like :

[CODE]
uniform int enabled;
void main ()
{
if (enabled)
{
RunMyPixelShaderTask();
}
}
[/CODE]

? [img]http://public.gamedev.net//public/style_emoticons/default/unsure.png[/img]
0

Share this post


Link to post
Share on other sites
[quote name='vNeeki' timestamp='1340693309' post='4952928']
[CODE]
uniform int enabled;
void main ()
{
if (enabled)
{
RunMyPixelShaderTask();
}
}
[/CODE]

[/quote]

It is possible to pass [i]varying variable[/i]s and [i]attribute variables [/i]down to pixel shader but I don't think this works for functions. Anw, I still appreciate your idea
What I am doing now is as follows
[code]
void main ()
{
discard;
}
[/code]
However, this, of course, can't give me accurate results. Edited by donguow
0

Share this post


Link to post
Share on other sites
As with your last thread on the subject the results are going to get are not going to be accurate; as I pointed out before ( [url="http://www.gamedev.net/topic/626047-processing-time-at-vertex-shader/page__view__findpost__p__4947729"]http://www.gamedev.net/topic/626047-processing-time-at-vertex-shader/page__view__findpost__p__4947729[/url] ) the only way you are going to get decent results is to the vendor supplied libraries or tools to time things.

More importantly; WHAT are you trying to do with this information?
Currently you are learning nothing useful what so ever...
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0