• 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
cippyboy

Have you used GL_ARB_shader_subroutine or DX Dynamic Shader Linking ?

7 posts in this topic

Have you used GL_ARB_shader_subroutine or DX Dynamic Shader Linking ?

 

I'm curious to know the performance advantages/disadvantages you got from implementing this over a bigger number of shader swaps. So far I've only tested this on a Shadow Map pass where I write only to the Z buffer, and made a shader that has skinning on/off based on the subroutines. I only got 1 skinned object though and 100 other ones. This was the quickest change I could make to observe the performance difference and to my surprise I have 1% lower overall performance. I imagine there's a number of shader swaps at which point it's faster to use subroutines. I'm also using an AMD HD7850 and I noticed lower GPU usage ratio when using subroutines, as if the driver is doing more work. This is very similar with separate shader objects where I observe a 50% drop in performance and a 50% drop in GPU usage while driver calls like glBindProgramPipeline take a whole lot more than glUseProgram, so I'm also questioning driver quality for this feature.

0

Share this post


Link to post
Share on other sites

Ok, so after a lot more work I managed to set up subroutines for all my 60 or so monolithic shaders. So basically instead of swapping 60 different shaders it uses a single shader with around 5 subroutine types ( skinning on/off, normals/lighting on/off, texturing on/off and alpha testing on/off ), 2 in VS and 3 in FS (the normals one is in both VS and FS). My conclusion is that it's slower even though I get 98% GPU usage.

 

I now get 118 FPS with subroutines versus 163 FPS without them.

 

However, there's some slight differences. Especially in the skinning department. Since the shader takes bone indices and weights for ALL objects, I assume there's some wasted caching involved when the current object does not present indices & weights, even though they're not used by the active subroutines set up, they might be fetched.

 

I also tried testing the shader without any object skinning, so the only difference in inputs is with and without normals/texcoords. Still about 50+ shader swaps, different camera angle though, the perf is 148 with subroutines vs 180 without. Still in the minus with performance, so I'm really wondering what is the threshold for a performance boost, or if the AMD driver is just really poor.

0

Share this post


Link to post
Share on other sites

I honestly would just build the shaders using #ifdefs, as it's the safest bet. You don't have to do alot of extra work just to see if it works. I combine shaders by implementing my own #include preprocessor statement, and since I do this before sending the shader to OpenGL I can be sure it will the fastest. I also use #ifdefs liberally mostly from configuration settings. So if a setting has changed, I'd have to recompile the shader, but it's trivial. smile.png

 

I also have to wonder if this is something that could get better in the future. The GPU is lots of weaker cores running in parallell, so with that in mind the fastest solution will always be the one that can run sequentially on many cores in parallell. Imagining that the driver makers have abstracted this functionality into shader --> subshader[0], subshader[1], all it would do is introduce another (albeit small) step when binding a shader. It's what I would do anyways, as it sounds like a ridicolous feature. :P

Edited by Kaptein
0

Share this post


Link to post
Share on other sites

I already have macros, that's my standard way of getting 50 different shader combinations out of an uber shader that has it all. The number is larger purely because in GL you need to have a monolithic program. In DX it's more like 30.

 

Ideally, the subroutines should just be jumps in the shader code, or even better, when the shader code is copied from GPU memory to L1 cache or whatever for instruction interpretation, it should copy only the currently bound subroutines' code.

0

Share this post


Link to post
Share on other sites

 


The number is larger purely because in GL you need to have a monolithic program.

 

Uhm, no. http://www.opengl.org/registry/specs/ARB/separate_shader_objects.txt

 

Subroutines are available in 4.0 and separate shader objects are available in 4.1, so if you are already using one its not much of a stretch to use the other.

 

 

Have you ever used separate shader objects ? I already said in this post I get a negative performance benefit of 50% if I use them on AMD hardware.

0

Share this post


Link to post
Share on other sites

Have you ever used separate shader objects ? I already said in this post I get a negative performance benefit of 50% if I use them on AMD hardware.

 

I missed that. That doesn't sound right at all. You could try posting on the AMD devguru website, but I wouldn't hold my breath for a response. I was having so many issues with AMD and OpenGL that I just gave up and bought a new GPU from Nvidia.

Edited by Chris_F
0

Share this post


Link to post
Share on other sites

 


Have you ever used separate shader objects ? I already said in this post I get a negative performance benefit of 50% if I use them on AMD hardware.

 

I missed that. That doesn't sound right at all. You could try posting on the AMD devguru website, but I wouldn't hold my breath for a response. I was having so many issues with AMD and OpenGL that I just gave up and bought a new GPU from Nvidia.

 

 

So what is your performance difference on Nvidia hardware with separate shader object ? The same ? faster/slower ?

0

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