Sign in to follow this  

some problems about ps_2_a

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

Because I wanna use dynamic flow control, so using ps_2_a write HLSL. The code as follows for some testing:
float4x4 WVP : WorldViewProjection;

texture ColorTexture <
	string ResourceName = "..\\..\\media\\layingrock_Mip_DXT5.dds";
	string ResourceType = "2D";
>;

sampler2D ColorMap = sampler_state {
	Texture = <ColorTexture>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU  = Wrap;
	AddressV  = Wrap;
	AddressW  = Wrap;
};


//////////////
struct MeshData {
	float4 pos	: POSITION;
	float3 Normal	: NORMAL0;
	float2 TexCoord0	: TEXCOORD0;
};

struct VsOut
{
	float4 pos:      POSITION;
	float2 TexCoord0: TEXCOORD0;
};

VsOut VS_main(MeshData IN ){
	VsOut Out;
	Out.pos = mul( IN.pos, WVP );
	Out.TexCoord0 = IN.TexCoord0;
	return Out;
}

float testConst = 0.9f;

float4 PS_main( VsOut IN ) : COLOR {
	float4 OUT;

	float4 BaseColor = tex2D(ColorMap, IN.TexCoord0.xy).rgba;

	OUT.rgb = BaseColor.rgb * 0.9f;
	OUT.a = BaseColor.a;
	
	return OUT;
}

technique Test
{
	pass p0
	{
		VertexShader = compile vs_2_a VS_main();
		PixelShader  = compile ps_2_a PS_main();
	}
}

The problems is that debuger(FX Composer) give me a error message.
Test.fx: Failed to validate technique: Test; An undetermined error occurred 
* Check that the hardware supports the Vertex Shader & Pixel Shader profile you are using. 
* Device max profiles: vs_2_0, ps_2_b 
Test.fx: Couldn't find a valid technique for effect D:\Visual Studio 2005\Projects2\MadCatEngine\Shader\Test.fx 
Technique: Test Failed to validate on this hardware 
Failed to find a valid technique on device for effect: D:\Visual Studio 2005\Projects2\MadCatEngine\Shader\Test.fx 
Effect will be displayed in blue wireframe. 
If I change " OUT.rgb = BaseColor.rgb * 0.9f;" to " OUT.rgb = BaseColor.rgb * testConst;" , or delete "* 0.9f" , or change pixel shader version ps_2_a to ps_2_b, ps_2_0, then FX Composer would working. The other problem about array. float4 LightColor[MAX_LIGHT]; When I using array index accessing the LightColor array, as follows LightColor[LightIndex].rgb; debuger would give me same error message. If change LightIndex to a constant, for instance LightColor[0].rgb, LightColor[2].rgb and so on. It would no any error. My graphics card is ATI X800. Isn't it ps_2_a has some limit?

Share this post


Link to post
Share on other sites
Whilst it is generally true, there isn't any requirement that says you MUST support N if you support N+1 (e.g. whilst pointless you could create an SM2 GPU that does not support SM1).

From memory this was the case with ps_2_a and ps_2_b - they were effectively Nvidia and ATI's extensions to the SM2 spec in the intermediary before they had SM3 hardware available. Supporting 'b' does not imply you also support 'a'...

That would explain why you get it working by changing it to ps_2_b or ps_2_0 solves the problem.

As for just changing the code and getting it to compile under ps_2_a I'd imagine you just got lucky here. I forget the details, but 'a' allows for longer programs and a few extra instructions/capabilities. Your default implementation is causing the compiler to take advantage of these extensions but your modified version is not - for whatever reason the compiler did NOT need to use the 'a' extensions and it actually generated valid 2.0 code...

hth
Jack

EDIT: damnit, beaten by 21 seconds [lol]

Share this post


Link to post
Share on other sites

This topic is 3854 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.

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