summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-09-17 20:20:42 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-09-17 20:20:42 +0000
commit8b4002ff14b534c526a2c1cc4867aac582488243 (patch)
treec86c378f126f505dd36f6686574b8405d9434df9 /Graphics/GraphicsEngine
parentUpdated unified buffers logic: removed implicit decay to DEFAULT bufers (diff)
downloadDiligentCore-8b4002ff14b534c526a2c1cc4867aac582488243.tar.gz
DiligentCore-8b4002ff14b534c526a2c1cc4867aac582488243.zip
Added UnifiedMemoryCPUAccess member to GraphicsAdapterInfo struct (API Version 240072)
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/interface/APIInfo.h2
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h11
-rw-r--r--Graphics/GraphicsEngine/src/BufferBase.cpp12
3 files changed, 21 insertions, 4 deletions
diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h
index 4baac91d..8856ee6b 100644
--- a/Graphics/GraphicsEngine/interface/APIInfo.h
+++ b/Graphics/GraphicsEngine/interface/APIInfo.h
@@ -30,7 +30,7 @@
/// \file
/// Diligent API information
-#define DILIGENT_API_VERSION 240070
+#define DILIGENT_API_VERSION 240072
#include "../../../Primitives/interface/BasicTypes.h"
diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
index e83d7e9d..93295972 100644
--- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h
+++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
@@ -125,11 +125,13 @@ DILIGENT_TYPED_ENUM(USAGE, Uint8)
/// A resource residing in a unified memory (e.g. memory shared between CPU and GPU),
/// that can be read and written by GPU and can also be directly accessed by CPU.
///
- /// \remarks Unified resources must use at least one of CPU_ACCESS_WRITE or CPU_ACCESS_READ flags.\n
- ///
- /// An application should check if unified memory is available on the device by quering
+ /// \remarks An application should check if unified memory is available on the device by quering
/// the device caps (see Diligent::IRenderDevice::GetDeviceCaps and Diligent::GraphicsAdapterInfo).
/// If there is no unified memory, an application should choose another usage type (typically, USAGE_DEFAULT).
+ ///
+ /// Unified resources must use at least one of CPU_ACCESS_WRITE or CPU_ACCESS_READ flags.
+ /// An application should check supported unified memory CPU access types by quering the device caps.
+ /// (see Diligent::GraphicsAdapterInfo::UnifiedMemoryCPUAccess).
USAGE_UNIFIED,
/// Helper value indicating the total number of elements in the enum
@@ -1690,6 +1692,9 @@ struct GraphicsAdapterInfo
/// resourecs with other usages may be allocated as well if there is no corresponding
/// memory type.
Uint64 UnifiedMemory DEFAULT_INITIALIZER(0);
+
+ /// Supported access types for the unified memory.
+ CPU_ACCESS_FLAGS UnifiedMemoryCPUAccess DEFAULT_INITIALIZER(CPU_ACCESS_NONE);
};
typedef struct GraphicsAdapterInfo GraphicsAdapterInfo;
diff --git a/Graphics/GraphicsEngine/src/BufferBase.cpp b/Graphics/GraphicsEngine/src/BufferBase.cpp
index 350ffc0f..4aff91a0 100644
--- a/Graphics/GraphicsEngine/src/BufferBase.cpp
+++ b/Graphics/GraphicsEngine/src/BufferBase.cpp
@@ -93,6 +93,18 @@ void ValidateBufferDesc(const BufferDesc& Desc, const DeviceCaps& deviceCaps)
"in the device caps before creating unified buffers.");
VERIFY_BUFFER(Desc.CPUAccessFlags != CPU_ACCESS_NONE,
"at least one of CPU_ACCESS_WRITE or CPU_ACCESS_READ flags must be specified for a unified buffer.");
+ if (Desc.CPUAccessFlags & CPU_ACCESS_WRITE)
+ {
+ VERIFY_BUFFER(deviceCaps.AdapterInfo.UnifiedMemoryCPUAccess & CPU_ACCESS_WRITE,
+ "Unified memory on this device does not support write access. Check the available access flags "
+ "in the device caps before creating unified buffers.");
+ }
+ if (Desc.CPUAccessFlags & CPU_ACCESS_READ)
+ {
+ VERIFY_BUFFER(deviceCaps.AdapterInfo.UnifiedMemoryCPUAccess & CPU_ACCESS_READ,
+ "Unified memory on this device does not support read access. Check the available access flags "
+ "in the device caps before creating unified buffers.");
+ }
break;
default: