Home Game Development directx11 – Looking for an recommendation on methods to presumably enhance my compute shader

directx11 – Looking for an recommendation on methods to presumably enhance my compute shader

0
directx11 – Looking for an recommendation on methods to presumably enhance my compute shader

[ad_1]

I’ve 4 rendertargets R10G10B10A2 every getting used to retailer coloration and regular in a compact double RGB 555 bits format. When I’m doing the lighting go I’m obliged to have additional rendertargets as a result of if I can learn(extract) the traditional/coloration, I am unable to write again immediately the lit coloration to those surfaces.

So I moved to a compute shader to realize this objective (DX11 CS5). I’ve discovered that I’m restricted to R32_UINT for learn/write in DX11 CS5. I’ve thus tailored my encoding/decoding to have issues work superb, though the ultimate colours are slightly bit hugly with my encoding.

Unfortunately the ultimate body fee is decrease than the common pixel shader even when I’ve to do 4 copyresources from the intermediate rendertargets with my earlier methodology.

I’ve applied the CS ranging from these discovered within the legacy DX11 samples. My code is like this:

CPU calls:

 //some CSbufferConstant and CSshaderresourceview settings (e.g. shadowmaps, depth textures
 gpDC11->CSSetShader(pCS, 0, 0);
 //I' mworking on 4 UAV on the similar time within the CSshader. With just one it's even slower
 gpDC11->CSSetUnorderedAccessViews(0, 4, gSRDeffered.ppUAV, (UINT*)(&gSRDeffered.ppUAV));
 gpDC11->Dispatch(960, 540, 1);//the scale of my display

GPU CS shader:

[numthreads(1,1,1)]
void CS_PostDeferred( uint3 nGid : SV_GroupID, uint3 nDTid : SV_DispatchThreadID, uint3 nGTid : SV_GroupThreadID )//solely nDTid is used the truth is right here
{
    uint Output;
    float2 Tex = float2(nDTid.x/960.0, nDTid.y/540.0);
    float Depth1 = txDepth1.SampleLevel(samPoint, Tex, 0).r;
    float Depth2 = txDepth2.SampleLevel(samPoint, Tex, 0).r;
    float Depth3 = txDepth3.SampleLevel(samPoint, Tex, 0).r;
    float Depth4 = txDepth4.SampleLevel(samPoint, Tex, 0).r;

    Output = UAVDiffuse0[nDTid.xy];
    if ( Depth1 < 1 ) Output = GetLColorUnPackPack_CS(Depth1, Tex, Output);
    UAVDiffuse0[nDTid.xy]=Output;
    Output = UAVDiffuse1[nDTid.xy];
    if ( Depth2 < 1 ) Output = GetLColorUnPackPack_CS(Depth2, Tex, Output);
    UAVDiffuse1[nDTid.xy]=Output;
    Output = UAVDiffuse2[nDTid.xy];
    if ( Depth3 < 1 ) Output = GetLColorUnPackPack_CS(Depth3, Tex, Output);
    UAVDiffuse2[nDTid.xy]=Output;
    Output = UAVDiffuse3[nDTid.xy];
    if ( Depth4 < 1 ) Output = GetLColorUnPackPack_CS(Depth4, Tex, Output);
    UAVDiffuse3[nDTid.xy]=Output;
}

The uint GetLColorUnPackPack_CS (float Depth, float2 UV, uint Data) is the operate extracting the colour and regular as 2 float3 from the R32_UINT Data param, calculating as ordinary lighting and shadows for the pixel after which recompacting the ultimate coloration to the R32_UINT (the traditional will not be modified). The Depth and UV params are used to get well the place in view area wanted for the purpose lights I’m utilizing.

Any recommendation welcome

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here