aboutsummaryrefslogtreecommitdiff
path: root/src/ConstantBuffers.h
diff options
context:
space:
mode:
authorlbavoil <[email protected]>2018-03-15 11:08:34 +0100
committerlbavoil <[email protected]>2018-03-15 11:08:34 +0100
commit636807e68a85a978473764d171ed0c7cc36f9be6 (patch)
tree784a3d4fa8f48b4c085dd959678505b2af12f425 /src/ConstantBuffers.h
parentRemove test folder (diff)
downloadhbaoplus-636807e68a85a978473764d171ed0c7cc36f9be6.tar.xz
hbaoplus-636807e68a85a978473764d171ed0c7cc36f9be6.zip
HBAO+ 4.0.0.23740451
Diffstat (limited to 'src/ConstantBuffers.h')
-rw-r--r--src/ConstantBuffers.h161
1 files changed, 1 insertions, 160 deletions
diff --git a/src/ConstantBuffers.h b/src/ConstantBuffers.h
index 39a16d8..30f7071 100644
--- a/src/ConstantBuffers.h
+++ b/src/ConstantBuffers.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved.
+* Copyright (c) 2008-2018, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
@@ -332,164 +332,5 @@ private:
} // namespace D3D12
#endif // SUPPORT_D3D12
-#if SUPPORT_GL
-namespace GL
-{
-
-class BaseConstantBuffer
-{
-public:
- BaseConstantBuffer(UINT ByteWidth, GLuint BindingPoint)
- : m_ByteWidth(ByteWidth)
- , m_BufferId(0)
- , m_BindingPoint(BindingPoint)
- {
- }
-
- void Create(const GFSDK_SSAO_GLFunctions& GL)
- {
- ASSERT(!m_BufferId);
- GL.glGenBuffers(1, &m_BufferId);
-
- GL.glBindBuffer(GL_UNIFORM_BUFFER, m_BufferId);
- GL.glBufferData(GL_UNIFORM_BUFFER, m_ByteWidth, NULL, GL_DYNAMIC_DRAW);
- GL.glBindBuffer(GL_UNIFORM_BUFFER, 0);
- ASSERT_GL_ERROR(GL);
- }
-
- void Release(const GFSDK_SSAO_GLFunctions& GL)
- {
- GL.glDeleteBuffers(1, &m_BufferId);
- m_BufferId = 0;
- }
-
- void Unbind(const GFSDK_SSAO_GLFunctions& GL)
- {
- GL.glBindBufferBase(GL_UNIFORM_BUFFER, m_BindingPoint, 0);
- ASSERT_GL_ERROR(GL);
- }
-
- void UpdateCB(const GFSDK_SSAO_GLFunctions& GL, void* pData)
- {
- ASSERT(m_BufferId);
-
- GL.glBindBufferBase(GL_UNIFORM_BUFFER, m_BindingPoint, m_BufferId);
- ASSERT_GL_ERROR(GL);
-
- // Do not use glMapBuffer for updating constant buffers (slow path on GL).
- // glBufferSubData has a fast path for UBO.
- GL.glBufferSubData(GL_UNIFORM_BUFFER, 0, m_ByteWidth, pData);
- ASSERT_GL_ERROR(GL);
- }
-
- GLuint GetBindingPoint()
- {
- return m_BindingPoint;
- }
-
- GLuint GetBufferId()
- {
- return m_BufferId;
- }
-
- enum BindingPoints
- {
- BINDING_POINT_GLOBAL_UBO = 0,
- BINDING_POINT_NORMAL_UBO = 1,
- BINDING_POINT_PER_PASS_UBO = 2,
- };
-
-protected:
- UINT m_ByteWidth;
- GLuint m_BufferId;
- GLuint m_BindingPoint;
-};
-
-//--------------------------------------------------------------------------------
-class GlobalConstantBuffer : public GlobalConstants, public GL::BaseConstantBuffer
-{
-public:
- GlobalConstantBuffer()
- : GlobalConstants()
- , GL::BaseConstantBuffer(sizeof(m_Data), BINDING_POINT_GLOBAL_UBO)
- {
- }
- void UpdateBuffer(const GFSDK_SSAO_GLFunctions& GL, GFSDK_SSAO_RenderMask RenderMask)
- {
- SetRenderMask(RenderMask);
- UpdateCB(GL, &m_Data);
- }
-};
-
-//--------------------------------------------------------------------------------
-class PerPassConstantBuffer : public PerPassConstants, public GL::BaseConstantBuffer
-{
-public:
- PerPassConstantBuffer()
- : PerPassConstants()
- , GL::BaseConstantBuffer(sizeof(m_Data), BINDING_POINT_PER_PASS_UBO)
- {
- }
- void UpdateBuffer(const GFSDK_SSAO_GLFunctions& GL)
- {
- UpdateCB(GL, &m_Data);
- }
-};
-
-//--------------------------------------------------------------------------------
-class PerPassConstantBuffers
-{
-public:
- void Create(const GFSDK_SSAO_GLFunctions& GL)
- {
- for (UINT SliceIndex = 0; SliceIndex < SIZEOF_ARRAY(m_CBs); ++SliceIndex)
- {
- m_CBs[SliceIndex].Create(GL);
-
- UINT JitterX = SliceIndex % 4;
- UINT JitterY = SliceIndex / 4;
-
- m_CBs[SliceIndex].SetOffset(JitterX, JitterY);
- m_CBs[SliceIndex].SetJitter(GetJitterVector(JitterX, JitterY));
- m_CBs[SliceIndex].SetSliceIndex(SliceIndex);
- m_CBs[SliceIndex].UpdateBuffer(GL);
- }
- }
- void Release(const GFSDK_SSAO_GLFunctions& GL)
- {
- for (UINT PassIndex = 0; PassIndex < SIZEOF_ARRAY(m_CBs); ++PassIndex)
- {
- m_CBs[PassIndex].Release(GL);
- }
- }
- GLuint GetBufferId(UINT PassIndex)
- {
- ASSERT(PassIndex < SIZEOF_ARRAY(m_CBs));
- return m_CBs[PassIndex].GetBufferId();
- }
- GLuint GetBindingPoint()
- {
- return m_CBs[0].GetBindingPoint();
- }
- void Unbind(const GFSDK_SSAO_GLFunctions& GL)
- {
- m_CBs[0].Unbind(GL);
- }
-
-private:
- float4 GetJitterVector(UINT JitterX, UINT JitterY)
- {
- // To match the reference D3D11 implementation
- JitterY = 3 - JitterY;
- return m_RandomTexture.GetJitter(JitterY * 4 + JitterX);
- }
-
- PerPassConstantBuffer m_CBs[16];
- GFSDK::SSAO::RandomTexture m_RandomTexture;
-};
-
-} // namespace GL
-#endif // SUPPORT_GL
-
} // namespace SSAO
} // namespace GFSDK