Jump to content
  • Advertisement
Sign in to follow this  
therealremi

how do those Nvidia's SPUs affect me as a shader developer?

This topic is 4254 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm learning shader development using Cg and I'd like to know how GPU architecture can affect my programming. Currently I test my shaders only on 2 cards so I can't see big portability issues right now but I'm aware they are there, waiting for me. For example I have the issue that on my older card (Radeon 9600XT) I cannot compile a shader that takes 60 4x4 matrices as its argument. Is there a way I can know beforhand that such a shader won't run on a particular GPU? What should I look at? The number of Vertex Shader Units? As for the new Nvidia 8xx cards: how is the number of SPUs in those cards tied to the complexity of shaders I can write for them? Does the fact that they are all Shader Model 4 mean that the shader that runs on 8800GTX will also run on 8500GT and the only difference will be speed of rendering? Or can there be a shader that compiles on 8800GTX but won't compile on 8500GT?

Share this post


Link to post
Share on other sites
Advertisement
The number of SPUs on a card doesn't really affect anything except performance as far as I know. What matters is the shader version number. Version 1 vertex shaders, for example, are not guaranteed to have as many available constant registers as Version 2 (or 3 or 4). The only way to make flexible shaders that I know of is to just write multiple functions that target different shader models, and select them at runtime based on the card capabilities.

All the 8 series GeForce cards should support VS/PS4. You still need to consider performance though. A shader that runs fast on the high end 8 series may not on the low end.

Share this post


Link to post
Share on other sites
This is the reason you set a base line of hardware support for your project.

As stanlo pointed out, the shader version is the most important factor as you can (in theory) safely stick to the minimum specifications of those versions. When you develop your shaders, make sure you specify the shader version you want to compile for.

Share this post


Link to post
Share on other sites
You can always query the capabilities of the card to see how many shader constans you have, what shader model, and so on, but usually the way to go is to just do everything with the minimum requirement for the particular shader model in mind.

Share this post


Link to post
Share on other sites
So, any shader that compiles on 8800GTX is guaranteed to compile on 8500GT, since they are both Shader Model 4? (of course the difference will be in performance).
And a shader that compiles on 8500GT is not guaranteed to compile on Radeon 1950XT, since 1950XT is only Shader Model 3?

Share this post


Link to post
Share on other sites
The 8500 should run 8800 compatible shaders.

One thing to watch out for is not instruction support, but things like floating-point linear blending of textures. For instance, the 9600 supports this, but the 9200 doesn't. The results can be extremely different when using textures to store and retrieve volumetric data (ie: on the 9200, one can get clouds of gas that look like they're made out of Lego).

Share this post


Link to post
Share on other sites
You aren't required to know the finer details of the hardware implementation - and in general you'd need to be a registered ATI/Nvidia developer to get a lot of the more useful information. For the most part drivers won't report to the API any implementation details.

It is a very advanced form of profiling and optimization to try and implement your shaders to fit specific architectures....

Quote:
Original post by therealremi
So, any shader that compiles on 8800GTX is guaranteed to compile on 8500GT, since they are both Shader Model 4? (of course the difference will be in performance).
And a shader that compiles on 8500GT is not guaranteed to compile on Radeon 1950XT, since 1950XT is only Shader Model 3?
At least in the context of Direct3D (not sure about OpenGL) you should seperate the idea of compiling and the type of GPU.

The shader models (1,2,3 and 4) are SOFTWARE - yes you can compile them at runtime, but you don't have to. You are writing your shader to conform to a baseline target profile as defined by the API.

Technically the hardware is not doing any compiling, the D3D API delivers standardised byte code to the driver which then translates it to hardware-specific micro code.

I could quite happily compile v4 shaders on my system when it had a 7300LE installed - just the driver wouldn't accept the byte code (in simplistic terms!).

The driver will report to the API which models it supports and that's all you really need to worry about for functional results.


hth
JAck

Share this post


Link to post
Share on other sites
Jack is bang on with respect to writing a shader to an API, rather than specific hardware (at least in DirectX this is the model). Then the hardware can compete on the performance front, rather than the features front.

There is one thing to note about the 8000 series cards though with respect to shader authoring: they have *scalar* processors rather than vector ones. What this means is that there's no point in trying vectorize at the instruction level where it would require extra data movements. The compiler *may* be able to get rid of these automatically, but the point is that there's no need to make your code ugly since there will be no performance gain: purely (shader instruction level) scalar code runs at 100% speed on the 8000 series.

That's the only thing that I do somewhat differently when targeting 8000 series hardware, and it's fairly minor in most cases (the exception being when a vector processor would require a non-trivial data rotation to perform efficiently, while on the G80 that would just waste time).

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
At least in the context of Direct3D (not sure about OpenGL) you should seperate the idea of compiling and the type of GPU.

The shader models (1,2,3 and 4) are SOFTWARE - yes you can compile them at runtime, but you don't have to. You are writing your shader to conform to a baseline target profile as defined by the API.

Technically the hardware is not doing any compiling, the D3D API delivers standardised byte code to the driver which then translates it to hardware-specific micro code.

I could quite happily compile v4 shaders on my system when it had a 7300LE installed - just the driver wouldn't accept the byte code (in simplistic terms!).

The driver will report to the API which models it supports and that's all you really need to worry about for functional results.
For OpenGL it's slightly different as it is the vendor specific divers that are doing the compiling and not OpenGL itself (as it is more of an a API standard rather than finished code), now this means that it is better to compile at runtime so that the compiler can optimize the code generated for that specific GPU(and not just translating standardized byte code, which it can do).
And while it's often possible to compile and even run most code on SM2 hardware(not as effective though, and you may end up with way to large programs), not all SM4 things will work on a SM2 or 3 GPU, like geometry shaders, which is hardware and not software.

Share this post


Link to post
Share on other sites
Quote:
Original post by taby
The 8500 should run 8800 compatible shaders.

One thing to watch out for is not instruction support, but things like floating-point linear blending of textures. For instance, the 9600 supports this, but the 9200 doesn't. The results can be extremely different when using textures to store and retrieve volumetric data (ie: on the 9200, one can get clouds of gas that look like they're made out of Lego).


That's true, but to be fair the 9200 is *not* a DirectX 9 (SM2) card, its a DirectX 8.1 (SM1) card which for some (marketting) reason was marked with its 9x00 moniker.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!