summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-08-23 03:26:49 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-08-23 03:26:49 +0000
commit2771c71fad9cc4311c287ad119d078662ef52c29 (patch)
treea0cf76cd433d6cba40b8a1478ed9d415a2517481 /Graphics/GraphicsEngineOpenGL
parentD3D12 backend: improved command list version detection (diff)
downloadDiligentCore-2771c71fad9cc4311c287ad119d078662ef52c29.tar.gz
DiligentCore-2771c71fad9cc4311c287ad119d078662ef52c29.zip
Added USAGE_UNIFIED usage type (API 240066)
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.hpp3
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp11
2 files changed, 12 insertions, 2 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.hpp b/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.hpp
index 332fc304..a93528ec 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.hpp
+++ b/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.hpp
@@ -71,6 +71,8 @@ inline GLenum TypeToGLType(VALUE_TYPE Value)
inline GLenum UsageToGLUsage(const BufferDesc& Desc)
{
+ static_assert(USAGE_NUM_USAGES == 5, "Please update this function to handle the new usage type");
+
// http://www.informit.com/articles/article.aspx?p=2033340&seqNum=2
// https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glBufferData.xml
switch (Desc.Usage)
@@ -82,6 +84,7 @@ inline GLenum UsageToGLUsage(const BufferDesc& Desc)
// clang-format off
case USAGE_STATIC: return GL_STATIC_DRAW;
case USAGE_DEFAULT: return GL_STATIC_DRAW;
+ case USAGE_UNIFIED: return GL_STATIC_DRAW;
case USAGE_DYNAMIC: return GL_DYNAMIC_DRAW;
case USAGE_STAGING:
if(Desc.CPUAccessFlags & CPU_ACCESS_READ)
diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp
index 70df3725..e05d72ff 100644
--- a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp
@@ -89,8 +89,15 @@ BufferGLImpl::BufferGLImpl(IReferenceCounters* pRefCounters,
m_GLUsageHint {UsageToGLUsage(BuffDesc)}
// clang-format on
{
- if (BuffDesc.Usage == USAGE_STATIC && (pBuffData == nullptr || pBuffData->pData == nullptr))
- LOG_ERROR_AND_THROW("Static buffer must be initialized with data at creation time");
+ ValidateBufferInitData(BuffDesc, pBuffData);
+
+ if (m_Desc.Usage == USAGE_UNIFIED)
+ {
+ DecayUnifiedBuffer();
+ }
+
+ if (m_Desc.Usage == USAGE_STATIC)
+ VERIFY(pBuffData != nullptr && pBuffData->pData != nullptr, "Initial data must not be null for static buffers");
// TODO: find out if it affects performance if the buffer is originally bound to one target
// and then bound to another (such as first to GL_ARRAY_BUFFER and then to GL_UNIFORM_BUFFER)