Jump to content
  • Advertisement
Sign in to follow this  
Woodchuck

quick shader questions

This topic is 4913 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

Do the vertex declaration and the vertex shader input must correspond ? And what about the texture stage, do the vertex shader cancelled the texture stage ? the pixel shader ? Thank you !

Share this post


Link to post
Share on other sites
Advertisement
The declaration must include the items the shader needs. Other than that, extra vertex info can be present.

The pixel shader replaces COLOROP, COLORARGn, ALPHAOP, ALPHAARGn, and RESULTARG.

The vertex shader replaces TEXCOORDINDEX, TEXTURETRANSFORMFLAGS.

The vertex shader also replaces many renderstates, such as LIGHTING, DIFFUSEMATERIALSOURCE, SPECULARMATERIALSOURCE, AMBIENTMATERIALSOURCE, EMISSIVEMATERIALSOURCE, parts of SPECULARENABLE, LOCALVIEWER, NORMALIZENORMALS, FOGSTART, FOGEND, FOGDENSITY, AMBIENT, COLORVERTEX.

Share this post


Link to post
Share on other sites
I have writen my fist vertex shader today and a problem of performance appear. The problem come from the fact i need to have 2 fx to render my scene : one for the scene strips and one for the invisible occluders. Then for each strip i need to run fx->Begin() and fx->Pass(). The performance are very bad like this (but relatively good when i render all with the same fx).
I think one reason is i use HLSL and the VShader is compile on the fly for each strip. But i'm not sure.
Then if i compile the vs offline, do the fx flipping be still slow ? What must i do to perform this ?

Thx !

Share this post


Link to post
Share on other sites
Ok I compile the vertex shader outside the rendering loop, and this always slow.
I need to switch between two passes for each rendered strip, is it possible fastly ?

Share this post


Link to post
Share on other sites
I don't use HLSL or the effects framework, so I can't help you out there. I have my own effects system and use assembly shaders. You should be able to precompile the shaders once, and then quickly bind them and use them. You'll want to sort by effect, so you're not changing it back and forth too many times per frame, as that does kill performance. You shouldn't see a performance change if you just switch to using a shader, but otherwise drawing in the same order as you did before.

Perhaps you should do an fx->begin, fx->pass, draw *all* strips, then do the next fx->pass until you're done all passes, then fx->end. You can then repeat that for your second effect. It's possibly that doing the pass call per strip is asking D3D to setup the shader and constants over and over.

A small code snippet may get you a better response from someone.

Share this post


Link to post
Share on other sites
Thank you for reply. I'm happy to learn that you can bind shader many many times per frame without have a lack of performance.

In my engine, i must draw strips and then draw bounding box for knowing if the next strips are visible. I must then often switch between 2 effects. I do test and this is really the call of fx->Pass (Begin can be done at the beginning) that kill the performance. Even is the fx contain only a texture stage description. I don't undestant why it is slow ! It's incredible. Do the fx object read or compile the fx on the fly on the HD ?!
My code is very simple, the fx describe a texture stage, and the engine call fx->pass for each ten strips, and the result is very slow (300fps give 50fps!!!).
I'm thinking about write my own fx class but it will be the same so it's ridiculous.

Share this post


Link to post
Share on other sites
Yes i try it. First, it seems that even if i describe a texture stage, the effect do a SetPixelShader and a SetVertexShader. It is one things i dumby have forgot, and this is a good reason for the fx->Pass() to be slow when it is ran for each strip. I try without effect and it is almost slow like the D3D fx but it is faster nevertheless during my test. So, their is maybe no problem with D3D9 fx object. So sorry.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!