0
\$\begingroup\$

My render pass consist in four passes.

3 first have 2 rendertargets and two unordered access view.

RTV0 = RG88 //store normal.xy

RTV1 = R32 //store depth

UAV0 = R32UINT //store color1

UAV1 = R32UINT//store color2

4th has one RTV and one UAV.

RTV0 = RG88//store normal.xy

UAV0 = R32UINT//store color1

I’m setting viewport and scissor rect as the screen size. So I set OMSetRenderTargetsAndUnorderedAccessViews(2, RTVs, DSV, 2, 2, UAVs, NULL) for the 3 first and OMSetRenderTargetsAndUnorderedAccessViews(1, RTVs, DSV, 1, 1, UAVs, NULL) for the last.

In my shader

    RWTexture2D<uint> UAVDiffuse0  : register( u2 );
    RWTexture2D<uint> UAVDiffuse1  : register( u3 );
    
    struct PS_INPUT
    {
        float4 Pos : SV_POSITION;
        float3 Norm : NORMAL;
        float4 Col : COLOR0;
        float2 Tex : TEXCOORD0;
        float3 Tan : TANGENT;
        float3 BiN : BINORMAL;
    };
    
    struct PS_DEFERRED
    {
        float2 NormalSSR : SV_TARGET0;
        float Depth : SV_TARGET1;
    };
    
    Float4 psdeferred (PS_INPUT Input)
    {
    PS_DEFERRED Output;
    Some code to calculate Data and N from Input
    //SM_SCREENX and Y are the screen sizes
        UAVDiffuse0[Input.Tex*float2(SM_SCREENX,SM_SCREENY)] = Data;
        UAVDiffuse1[Input.Tex*float2(SM_SCREENX,SM_SCREENY)] = Data&0xFFFF7FFF;
        Output.NormalSSR = mad(N.xy,0.5,0.5);
        Output.Depth = Input.Pos.z+0.00003f;
    }
    
    struct PS_DEFERRED2 
    {
        float2 NormalSSR : SV_TARGET0;
    };
    Float4 psdeferred2 (PS_INPUT Input)
    {
    PS_DEFERRED2 Output;
    Some code to calculate Data and N from Input
        UAVDiffuse0[Input.Tex*float2(SM_SCREENX,SM_SCREENY)] = Data;
        Output.NormalSSR = mad(N.xy,0.5,0.5);
    }

Things work fine for the RTVs but are weird for UAVs as shown in the picture. In my previous code I was using RTV only and everything was working fine so I’m sure that the Data and N calculations are correct. I’m surely missing something. I have no debug errors.

enter image description here

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

I fill stupid... The answer was there already. We need to use the SV_POSITION xy as UAV coordinates for writing the right pixel.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.