[Resolved]A few questions about selecting codepaths in HLSL

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

Recommended Posts

Hey everyone, I've got a few questions. In my engine, I'm going to use a different shader for every shader level. What I mean is, Shader 1 has a SM 1 and 2 codepath Shader 2 has a SM 1, 2 and 3 codepath In my application, I want to define the highest shader codepath it will compile. Example, SM2 Shader 1 will compile the SM2 codepath Shader 2 will compile the SM3 codepath How would I go about doing that? I was thinking
technique RenderLightingPass
{
pass p0
{
VertexShader = compile vs_1_1 LightingPassVS();
#IF shaderver >= 2
PixelShader = compile ps_2_0 LightingPassPS_SM2();
#ELSEIF shaderver = 1
PixelShader = compile ps_1_1 LightingPassPS_SM1();
#ENDIF
}
}


But I don't know how to pass in shaderver. Anyone? [Edited by - CadeF on March 13, 2006 12:55:16 AM]

Share on other sites
In the case you use the effect framework you should use different techniques for this.

technique ShaderModel1{    pass p0    {        VertexShader = compile vs_1_1 LightingPassVS();        PixelShader = compile ps_1_1 LightingPassPS_SM1();    }}technique ShaderModel2{    pass p0    {        VertexShader = compile vs_1_1 LightingPassVS();        PixelShader = compile ps_2_0 LightingPassPS_SM2();    }}

You can now select the technique you want to use with “SetTechnique”. You will need some additional code that maps from the caps to the right Technique. The easiest way is to use always the same technique names. But with some additional code you can make it much more flexible and configurable.

Share on other sites
Thanks, but I'm looking for other methods, in which no higher version is compiled.

Share on other sites
Quote:
 Original post by CadeFThanks, but I'm looking for other methods, in which no higher version is compiled.

I have found the easiest way to do this is to simply place the higher-profile techniques above the lower-profile techniques. This way, no compile errors are generated, but they aren't validated either. Then your application can simply use the first validated technique.

If you *really* want to avoid compiling them at all, you could just #define different identifiers from within the application (remember the effect compiler allows you to add in different defines at runtime). For example, #define SM_3_0 and whatnot.

Share on other sites
In Direct3D.Effect.FromFile, where do I pass in "#define ShaderModel == 2;"?
Or, if not Effect.FromFile, which function?

[Edited by - CadeF on March 12, 2006 5:36:12 PM]

Share on other sites
Quote:
 Original post by CadeFIn Direct3D.Effect.FromFile, where do I pass in "#define ShaderModel == 2;"?Or, if not Effect.FromFile, which function?

Well, I have only use the unmanaged version (D3DXCreateEffectFromFile()). There, you just specify a null-terminated array of defines for the pDefines structure.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• Forum Statistics

• Total Topics
631426
• Total Posts
3000019
×

Important Information

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

Sign me up!