0
votes

I'm working with legacy code that is using vs_2_0 and ps_2_0 assembly shader code in an effect file. I'm looking to add some pixel shaders to work with existing the vertex shader, but would like to use HLSL. Is it possible to add an HLSL pixel shader in the same technique with the asm vertex shader? If so, how do I access the vertex shader output (oT0, oT1) in my HLSL pixel shader? I'm new to shaders in general, so the simpler the better.

1
DirectX shader assembly hasn't been supported in a very long time. What version of DirectX SDk are you using?Chuck Walbourn

1 Answers

0
votes

If you're using dx9 effect framework, then for the technique setup, you can

technique tech {
pass p0
    {
        VertexShader = 
        asm {
           // vertex shader assembly code goes here
           // ...
        };
        // compile MyAwsomePS as ps_2_0 and assign to PixelShader.
        PixelShader= compile ps_2_0 myAwsomePS();
    
    }
}

As shown in MSDN

And for matching vs outputs, check out DirectX 9 hlsl Semetics, and ps_2_0 input registers, what's available to ps_2_0 is TEXCOORD# COLOR# which will compile to t# and v# respectively.

For example:

struct PSInput
{
    float4 txcoord : TEXCOORD2;  // this will be t2
    float4 color : COLOR0; // this will be v0

};

float4 myAwsomePS(PSInput IN) : COLOR
{
    return IN.color + IN.txcoord;
}

compiles to

    ps_2_0
    dcl t2
    dcl v0
    mov r0, v0
    add r0, r0, t2
    mov oC0, r0

I would also recommend using hlsl offline compiler (fxc) to list assembly output and check for yourself if things has lined up. or considered using the handy online shader compiler by Tim Jones