Merge pull request #1629 from attilaz/39-assao-buffer-atomic
39-assao: use buffer for atomic to support metal
This commit is contained in:
commit
1375463e14
@ -363,7 +363,7 @@ namespace
|
||||
m_recreateFrameBuffers = false;
|
||||
createFramebuffers();
|
||||
|
||||
m_loadCounter = bgfx::createTexture2D(1, 1, false, 1, bgfx::TextureFormat::R32U, BGFX_TEXTURE_COMPUTE_WRITE);
|
||||
m_loadCounter = bgfx::createDynamicIndexBuffer(1, BGFX_BUFFER_COMPUTE_READ_WRITE | BGFX_BUFFER_INDEX32);
|
||||
|
||||
// Vertex decl
|
||||
PosTexCoord0Vertex::init();
|
||||
@ -630,7 +630,7 @@ namespace
|
||||
|
||||
if (!adaptiveBasePass && (m_settings.m_qualityLevel == 3))
|
||||
{
|
||||
bgfx::setImage(3, m_loadCounter, 0, bgfx::Access::Read, bgfx::TextureFormat::R32U);
|
||||
bgfx::setBuffer(3, m_loadCounter, bgfx::Access::Read);
|
||||
bgfx::setTexture(4, s_importanceMap, m_importanceMap, SAMPLER_LINEAR_CLAMP);
|
||||
bgfx::setImage(5, m_finalResults, 0, bgfx::Access::Read, bgfx::TextureFormat::RG8);
|
||||
}
|
||||
@ -697,13 +697,13 @@ namespace
|
||||
bgfx::setTexture(1, s_importanceMap, m_importanceMap);
|
||||
bgfx::dispatch(view, m_postprocessImportanceMapAProgram, (m_quarterSize[0] + 7) / 8, (m_quarterSize[1] + 7) / 8);
|
||||
|
||||
bgfx::setImage(0, m_loadCounter, 0, bgfx::Access::ReadWrite, bgfx::TextureFormat::R32U);
|
||||
bgfx::setBuffer(0, m_loadCounter, bgfx::Access::ReadWrite);
|
||||
bgfx::dispatch(view, m_loadCounterClearProgram, 1,1);
|
||||
|
||||
m_uniforms.submit();
|
||||
bgfx::setImage(0, m_importanceMap, 0, bgfx::Access::Write, bgfx::TextureFormat::R8);
|
||||
bgfx::setTexture(1, s_importanceMap, m_importanceMapPong);
|
||||
bgfx::setImage(2, m_loadCounter, 0, bgfx::Access::ReadWrite, bgfx::TextureFormat::R32U);
|
||||
bgfx::setBuffer(2, m_loadCounter, bgfx::Access::ReadWrite);
|
||||
bgfx::dispatch(view, m_postprocessImportanceMapBProgram, (m_quarterSize[0]+7) / 8, (m_quarterSize[1]+7) / 8);
|
||||
++view;
|
||||
}
|
||||
@ -1159,7 +1159,7 @@ namespace
|
||||
// Only needed for quality level 3 (adaptive quality)
|
||||
bgfx::TextureHandle m_importanceMap;
|
||||
bgfx::TextureHandle m_importanceMapPong;
|
||||
bgfx::TextureHandle m_loadCounter;
|
||||
bgfx::DynamicIndexBufferHandle m_loadCounter;
|
||||
|
||||
struct Model
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ CONST(uint g_numTaps[5]) = { 3, 5, 12, 0, 0 };
|
||||
SAMPLER2D(s_viewspaceDepthSource, 0);
|
||||
SAMPLER2D(s_viewspaceDepthSourceMirror, 1);
|
||||
IMAGE2D_RO(s_normalmapSource, rgba8, 2);
|
||||
UIMAGE2D_RO(s_loadCounter, r32ui, 3);
|
||||
BUFFER_RO(s_loadCounter, uint, 3);
|
||||
SAMPLER2D(s_importanceMap, 4);
|
||||
IMAGE2D_ARRAY_RO(s_baseSSAO, rg8, 5);
|
||||
IMAGE2D_ARRAY_WR(s_target, rg8, 6);
|
||||
@ -410,7 +410,7 @@ void GenerateSSAOShadowsInternal( out float outShadowTerm, out vec4 outEdges, ou
|
||||
float edgeCount = dot( 1.0-edgesLRTB, vec4( 1.0, 1.0, 1.0, 1.0 ) );
|
||||
//importance += edgeCount / (float)SSAO_ADAPTIVE_TAP_FLEXIBLE_COUNT;
|
||||
|
||||
float avgTotalImportance = float(imageLoad(s_loadCounter,ivec2(0,0)).x) * u_loadCounterAvgDiv;
|
||||
float avgTotalImportance = float(s_loadCounter[0]) * u_loadCounterAvgDiv;
|
||||
|
||||
float importanceLimiter = saturate( u_adaptiveSampleCountLimit / avgTotalImportance );
|
||||
importance *= importanceLimiter;
|
||||
|
@ -6,10 +6,10 @@
|
||||
#include "bgfx_compute.sh"
|
||||
#include "uniforms.sh"
|
||||
|
||||
UIMAGE2D_WR(s_loadCounterOutputUAV, r32ui, 0);
|
||||
BUFFER_WR(s_loadCounter, uint, 0);
|
||||
|
||||
NUM_THREADS(1, 1, 1)
|
||||
void main()
|
||||
{
|
||||
imageStore(s_loadCounterOutputUAV, ivec2(0, 0), uvec4(0,0,0,0));
|
||||
s_loadCounter[0] = 0;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
IMAGE2D_WR(s_target, r8, 0);
|
||||
SAMPLER2D(s_importanceMap, 1);
|
||||
UIMAGE2D_RW(s_loadCounterOutputUAV, r32ui, 2);
|
||||
BUFFER_RW(s_loadCounter, uint, 2);
|
||||
|
||||
CONST(float cSmoothenImportance) = 1.0;
|
||||
|
||||
@ -49,7 +49,7 @@ void main()
|
||||
#else
|
||||
if( ((dtID.x % 3) + (dtID.y % 3)) == 0 )
|
||||
#endif
|
||||
imageAtomicAdd(s_loadCounterOutputUAV, ivec2(0, 0), sum );
|
||||
atomicAdd(s_loadCounter[0], sum );
|
||||
imageStore(s_target, ivec2(dtID.xy), retVal.xxxx);
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user