Sign in to follow this  
Linuxhippy3

How many different shaders are possible?

Recommended Posts

Linuxhippy3    122
Hi there, I am working on a program which will have many different versions of the same shader (to avoid branching, ...). I wonder whether there's a limit how many shaders (or shader-instructions, or whatever) can be uploaded to the card simultaneously? Does anybody know where the programs are storen on the GPU-Board, are they stored in VRAM? Thank you in advance, lg Clemens

Share this post


Link to post
Share on other sites
deathkrush    350
Shader programs are very small in size, you can store hundreds of them in VRAM and not even notice. I don't know of any built-in limit, other than the amount of memory available. Internally, shaders are stored in main RAM (microcode and GLSL headers) and parts are typically copied into VRAM, probably just the microcode, although this depends on the card and the OpenGL driver.

There is a hard limit of how many instructions a shader can have. This entirely depends on the amount of microcode memory the card has and the profile (Shader Model 2, Shader Model 3, etc)

I know in D3D there is D3DCAPS9.MaxPixelShader30InstructionSlots, I'm not sure what the equivalent in OpenGL is.

[Edited by - deathkrush on October 10, 2007 1:00:03 AM]

Share this post


Link to post
Share on other sites
zedz    291
i know of instances where ppl are using 1000s (though perhaps not all simultaneously), personally ive had ~200 loaded + used in a frame

Share this post


Link to post
Share on other sites
V-man    813
This has a list of cards, driver versions, different GL info
http://delphi3d.net/hardware/index.php

For example, the 8800 supports 32 texture units in the vertex shader. NV_vertex_program3 was used to query that feature.

ARB_vertex_program and ARB_fragment_program can be used to get some details.
The GLSL functions don't offer much in terms of quering the card's capabilities.

Share this post


Link to post
Share on other sites
Linuxhippy3    122
Thats really good news for me :)

Oh, a last question ... how expensive is it to attach/detach a shader from a program (is this thre preferred way if disabling a shader?)? Of course this depends heavily on driver and GPU but I read that in general it can be quite expensive.
What I have to do is to render many small quads (maybe between 20x20 and 100x100) maybe with other shaders, and well it would be cool to know when using a faster shader would be benefitial and when the switch would eat up all benefits.

Thanks, lg Clemens

Share this post


Link to post
Share on other sites
zedz    291
yes there is someoverhead with shader switching, if youre only gonna draw a few fragments than changing uniforms etc is perhaps a better way to go (benchmark to see)
though one thing ive seen is with fullscreen effects eg blurring
ive seen ppl use the same shader for horizontal as well as vertical + just change the uniforms so its either blurring horizontally + then vertically. in such a case its better to have 2 different shaders

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