浏览代码

Optimize the SSS shader for ALU

/RenderPassXR_Sandbox
Evgenii Golubev 7 年前
当前提交
a67be182
共有 1 个文件被更改,包括 10 次插入10 次删除
  1. 20
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.compute

20
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.compute


// 6656 bytes used. It appears that the reserved LDS space must be a multiple of 512 bytes.
#if SSS_USE_LDS_CACHE
groupshared float4 textureCache[TEXTURE_CACHE_SIZE_1D][TEXTURE_CACHE_SIZE_1D]; // {irradiance, linearDepth}
groupshared float4 textureCache[TEXTURE_CACHE_SIZE_1D * TEXTURE_CACHE_SIZE_1D]; // {irradiance, linearDepth}
int2 tileCoord = pixelCoord >> 3; // Divide by 8
bool passedStencilTest;
int2 tileCoord = pixelCoord >> 3; // Divide by 8
bool passedStencilTest = stencilRef == LOAD_TEXTURE2D(_HTile, tileCoord).r;
passedStencilTest = stencilRef == LOAD_TEXTURE2D(_HTile, tileCoord).r;
[branch] if (passedStencilTest)
#else

bool passedStencilTest = false;
#endif
{
// Unfortunately, our copy of HTile does not allow to accept at the tile rate.

#if SSS_USE_LDS_CACHE
float4 LoadSampleFromCacheMemory(int2 cacheCoord)
{
return textureCache[cacheCoord.x][cacheCoord.y];
return textureCache[Mad24(TEXTURE_CACHE_SIZE_1D, cacheCoord.y, cacheCoord.x)];
}
#endif

float4 LoadSample(int2 pixelCoord, int2 cacheAnchor)
{
int2 cacheCoord = pixelCoord - cacheAnchor;
bool isInCache = cacheCoord.x >= 0 && cacheCoord.x < TEXTURE_CACHE_SIZE_1D &&
cacheCoord.y >= 0 && cacheCoord.y < TEXTURE_CACHE_SIZE_1D;
bool isInCache = max((uint)cacheCoord.x, (uint)cacheCoord.y) < TEXTURE_CACHE_SIZE_1D;
#if SSS_USE_LDS_CACHE
[branch] if (isInCache)

float linearDepth = textureSample.a;
// Check the results of the stencil test.
[flatten] if (linearDepth > 0)
if (linearDepth > 0)
{
// Apply bilateral weighting.
float z = linearDepth - centerPosVS.z;

#if SSS_USE_LDS_CACHE
// Populate the central region of the LDS cache.
textureCache[cacheCoord.x][cacheCoord.y] = cachedValue;
textureCache[Mad24(TEXTURE_CACHE_SIZE_1D, cacheCoord.y, cacheCoord.x)] = cachedValue;
uint numBorderQuadsPerWave = TEXTURE_CACHE_SIZE_1D / 2 - 1;
uint halfCacheWidthInQuads = TEXTURE_CACHE_SIZE_1D / 4;

}
// Populate the border region of the LDS cache.
textureCache[cacheCoord2.x][cacheCoord2.y] = cachedValue2;
textureCache[Mad24(TEXTURE_CACHE_SIZE_1D, cacheCoord2.y, cacheCoord2.x)] = cachedValue2;
}
// Wait for the LDS.

正在加载...
取消
保存