Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Having an application that uses shaders that have been wrote in GLSL, what is the best strategy for the distribution in the real world and for the desktop and mobile?

I'm aiming to distribute this in a binary form or as plain serialized text, i would like a good suggestion on this.

share|improve this question
add comment

1 Answer 1

up vote 13 down vote accepted

The main rationale for using binary shaders is if compiling the text shaders is too big of a workload for your target device. Binary GLSL shaders don't have a standardized format, so you'd need different ones for each GPU/driver you plan to support. I'd recommend you distribute the shaders in source form and then on the first run cache them into binary form and subsequently load from there. Then again I'd first test if you really have a performance bottleneck there to justify using the binaries at all.

One thing to consider is also an offline text shader optimizer that can have a great effect with crappy mobile shader compilers.

share|improve this answer
    
I'd actually be surprised if you could find any device where shader compilation is a bottleneck. The amount of code, even in large shaders, is a trivial amount of code in terms of compilation. –  edA-qa mort-ora-y Aug 27 '12 at 9:44
1  
The big engines out there usually compile shaders offline, and/or cache them on the first run, as Tapio suggests. Maybe there's a trivial amount of code per shader, but you can have a lot of them. –  Laurent Couvidou Aug 27 '12 at 10:44
    
so i have to buy a random ATI videocard and another random one from Nvidia, compile my shaders and distribute only the compiled version? How i can check at runtime what is the brand of the targeted video card? There is something reliable for that? –  user827992 Aug 27 '12 at 14:17
1  
@user827992 The binary format may be different for different generations of GPUs/drivers even if the vendor is the same. And don't forget there's also lot's of Intel GPUs out there, let alone all the mobile ones, like Qualcomm and PowerVR. So again: I suggest you don't distribute compiled shaders, but rather cache them on first run on the user's device. Regarding GPU detection, you could try parsing GL_VENDOR, GL_VERSION and GL_RENDERER strings form glGetString(), but their format varies from vendor to vendor. –  Tapio Aug 27 '12 at 16:17
    
@Tapio ok thanks, i will go for the plain text :) –  user827992 Aug 27 '12 at 16:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.