37 lines
1.1 KiB
HLSL
37 lines
1.1 KiB
HLSL
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "../Common.ush"
|
|
|
|
RWTexture2D<uint> RWOutputTexture;
|
|
Texture2D<uint> SourceTexture0;
|
|
Texture2D<uint> SourceTexture1;
|
|
|
|
uint2 DecodeShadingRate(uint EncodedRate)
|
|
{
|
|
uint2 DecodedRate;
|
|
DecodedRate.x = ((1U << SHADING_RATE_DIMENSION_BITS) - 1U) & (EncodedRate >> SHADING_RATE_DIMENSION_BITS);
|
|
DecodedRate.y = ((1U << SHADING_RATE_DIMENSION_BITS) - 1U) & EncodedRate;
|
|
return DecodedRate;
|
|
}
|
|
|
|
uint EncodeShadingRate(uint2 DecodedRate)
|
|
{
|
|
return (DecodedRate.x << SHADING_RATE_DIMENSION_BITS) + DecodedRate.y;
|
|
}
|
|
|
|
uint ShadingRateMax(uint InputRate0, uint InputRate1)
|
|
{
|
|
uint2 DecodedRate0 = DecodeShadingRate(InputRate0);
|
|
uint2 DecodedRate1 = DecodeShadingRate(InputRate1);
|
|
uint2 DecodedMaxRate = max(DecodedRate0, DecodedRate1);
|
|
return EncodeShadingRate(DecodedMaxRate);
|
|
}
|
|
|
|
[numthreads(THREADGROUP_SIZE_XY, THREADGROUP_SIZE_XY, 1)]
|
|
void CombineShadingRateTextures(uint3 DispatchThreadId : SV_DispatchThreadID)
|
|
{
|
|
const uint2 TexelCoord = DispatchThreadId.xy;
|
|
RWOutputTexture[TexelCoord] = ShadingRateMax(SourceTexture0[TexelCoord], SourceTexture1[TexelCoord]);
|
|
}
|
|
|