Skip to main content
gamedev.net
🔒 Locked

register

Started by luasitdown Dec 20, 2005 at 5:03 PM 2 replies 450+ views
Original Post
luasitdown
luasitdown
when I define variable in HLSL. How can I know which variable is constant register or temperor register or input/output register? for example :

//=============================================================================
// terrain_multitexture.fx by Frank Luna (C) 2004 All Rights Reserved.
//=============================================================================

uniform extern float4x4 gWVP;
uniform extern float2   gTexScale;
uniform extern float3   gDirToSunW; // Assumed to be unit length.
 
uniform extern texture  gLayerMap0;
uniform extern texture  gLayerMap1;
uniform extern texture  gLayerMap2;
uniform extern texture  gBlendMap;

sampler LayerMap0Sampler = sampler_state
{
    Texture   = <gLayerMap0>;
    MinFilter = LINEAR; 
    MagFilter = LINEAR;
    MipFilter = LINEAR;
    AddressU  = WRAP;
    AddressV  = WRAP;
};

sampler LayerMap1Sampler = sampler_state
{
	Texture   = <gLayerMap1>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU  = WRAP;
    AddressV  = WRAP;
};

sampler LayerMap2Sampler = sampler_state
{
    Texture   = <gLayerMap2>;
    MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
	AddressU  = WRAP;
    AddressV  = WRAP;
};

sampler BlendMapSampler = sampler_state
{
    Texture   = <gBlendMap>;
    MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = LINEAR;
};

struct OutputVS
{
    float4 posH         : POSITION0;
    float  shade        : TEXCOORD0;
    float2 tiledTexC    : TEXCOORD1; 
    float2 nonTiledTexC : TEXCOORD2;
};

OutputVS Terrain_MultiTexVS(float4 posL         : POSITION0, 
                            float3 normalL      : NORMAL0,  // Assumed to be unit length
                            float2 tiledTexC    : TEXCOORD0,
                            float2 nonTiledTexC : TEXCOORD1)
{
	OutputVS outVS = (OutputVS)0;


	// Project position homogeneous clip space.
    outVS.posH  = mul(posL, gWVP); 
    
    // Do basic diffuse lighting calculating to compute vertex shade.
    outVS.shade = max(0.0f, dot(normalL, gDirToSunW));
    
    // Scale tiled tex-coords as specified by the application.
    outVS.tiledTexC.x  = tiledTexC.x * gTexScale.x;
    outVS.tiledTexC.y  = tiledTexC.y * gTexScale.y;
    
    // Forward non-tiled tex-coords to pixel shader.
    outVS.nonTiledTexC = nonTiledTexC;
    
  
    return outVS;
}

float4 Terrain_MultiTexPS(float  shade        : TEXCOORD0,
                          float2 tiledTexC    : TEXCOORD1,
			  float2 nonTiledTexC : TEXCOORD2) : COLOR
{
	// Layer maps are tiled
    float3 c0 = tex2D(LayerMap0Sampler, tiledTexC);
    float3 c1 = tex2D(LayerMap1Sampler, tiledTexC);
    float3 c2 = tex2D(LayerMap2Sampler, tiledTexC);
    
    // Blendmap is not tiled.
    float3 B = tex2D(BlendMapSampler, nonTiledTexC);

	// Find the inverse of all the blend weights so that we can
	// scale the total color to the range [0, 1].
    float totalInverse = 1.0f / (B.r + B.g + B.b);
    
    c0 *= B.r * totalInverse;
    c1 *= B.g * totalInverse;
    c2 *= B.b * totalInverse;
    
    float3 final = (c0 + c1 + c2) * shade;
 
    return float4(final, 1.0f);
}

technique Terrain_MultiTex
{
    pass P0
    {
        vertexShader = compile vs_2_0 Terrain_MultiTexVS();
        pixelShader  = compile ps_2_0 Terrain_MultiTexPS();

		// DO NOT SET SAMPLERS IN EFFECT
    }
}



2. keyword in .fx file is superset of HLSL language? If their keywork is the same meaning of the keyword is the same too?
jollyjeffers
jollyjeffers
Quote:
Original post by luasitdown
when I define variable in HLSL.
How can I know which variable is constant register or temperor register or input/output register?

Do you mean, which constants you can configure from within your application?

If so, you can query the effect file via the ID3DXBaseEffect (or the ID3DXConstantTable) for descriptions of their HLSL name and what registers they resolved to.

Quote:
Original post by luasitdown
2. keyword in .fx file is superset of HLSL language? If their keywork is the same meaning of the keyword is the same too?

Yes, thats pretty much the case... all of the effect/HLSL details are well documented - I suggest you go have a look through them if there are any you don't understand.

hth
JAck
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
luasitdown
luasitdown
I mean shader put data in register :input regiest output register temperor register constant regiester .If I use assembly ,I can use register manualy.
If I use HLSL I declaration some variable ,how do I know which is in input register ,which is in temperor registere ....
darookie
darookie
It's not important - just trust the compiler. Future versions of Direct3D won't support assembly shaders anyway.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.