diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-09-17 17:51:49 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-09-17 17:51:49 +0000 |
| commit | 4d291ac4a902fbdae476a83dc11a9995189fb52a (patch) | |
| tree | d9668de9b3032a0949fdfb58dde7763b713d0a5f /Graphics/GraphicsEngine | |
| parent | Fixed strncpy_s errors (diff) | |
| download | DiligentCore-4d291ac4a902fbdae476a83dc11a9995189fb52a.tar.gz DiligentCore-4d291ac4a902fbdae476a83dc11a9995189fb52a.zip | |
Updated unified buffers logic: removed implicit decay to DEFAULT bufers
Diffstat (limited to 'Graphics/GraphicsEngine')
| -rw-r--r-- | Graphics/GraphicsEngine/include/BufferBase.hpp | 25 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/interface/GraphicsTypes.h | 11 | ||||
| -rw-r--r-- | Graphics/GraphicsEngine/src/BufferBase.cpp | 5 |
3 files changed, 9 insertions, 32 deletions
diff --git a/Graphics/GraphicsEngine/include/BufferBase.hpp b/Graphics/GraphicsEngine/include/BufferBase.hpp index 0095cabb..9ae6db92 100644 --- a/Graphics/GraphicsEngine/include/BufferBase.hpp +++ b/Graphics/GraphicsEngine/include/BufferBase.hpp @@ -41,7 +41,7 @@ namespace Diligent { void ValidateBufferInitData(const BufferDesc& Desc, const BufferData* pBuffData); -void ValidateBufferDesc(const BufferDesc& Desc); +void ValidateBufferDesc(const BufferDesc& Desc, const DeviceCaps& deviceCaps); /// Template class implementing base functionality for a buffer object @@ -80,7 +80,7 @@ public: m_pDefaultUAV{nullptr, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>(BuffViewObjAllocator)}, m_pDefaultSRV{nullptr, STDDeleter<BufferViewImplType, TBuffViewObjAllocator>(BuffViewObjAllocator)} { - ValidateBufferDesc(this->m_Desc); + ValidateBufferDesc(this->m_Desc, pDevice->GetDeviceCaps()); Uint64 DeviceQueuesMask = pDevice->GetCommandQueueMask(); DEV_CHECK_ERR((this->m_Desc.CommandQueueMask & DeviceQueuesMask) != 0, "No bits in the command queue mask (0x", std::hex, this->m_Desc.CommandQueueMask, ") correspond to one of ", pDevice->GetCommandQueueCount(), " available device command queues"); @@ -134,27 +134,6 @@ protected: /// Corrects buffer view description and validates view parameters. void CorrectBufferViewDesc(struct BufferViewDesc& ViewDesc); - void DecayUnifiedBuffer() - { - VERIFY_EXPR(this->m_Desc.Usage == USAGE_UNIFIED); - VERIFY_EXPR(this->m_Desc.CPUAccessFlags != CPU_ACCESS_NONE); - if (this->m_Desc.CPUAccessFlags == CPU_ACCESS_WRITE) - { - this->m_Desc.Usage = USAGE_DEFAULT; - this->m_Desc.CPUAccessFlags = CPU_ACCESS_NONE; - } - else if (this->m_Desc.CPUAccessFlags == CPU_ACCESS_READ) - { - this->m_Desc.Usage = USAGE_STAGING; - } - else - { - LOG_ERROR_AND_THROW("Unified buffer '", this->m_Desc.Name, - "' cannot be automatically converted to a non-unified buffer " - "because it uses both CPU_ACCESS_WRITE and CPU_ACCESS_READ flags"); - } - } - #ifdef DILIGENT_DEBUG TBuffViewObjAllocator& m_dbgBuffViewAllocator; #endif diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index b87cce67..e83d7e9d 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -126,15 +126,10 @@ DILIGENT_TYPED_ENUM(USAGE, Uint8) /// 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 - /// If it is not possible to create a unified resource, the engine will attempt to create a non-unified - /// resource as follows: - /// - If CPU_ACCESS_WRITE flag is specified, default-usage resource will be created. - /// - If CPU_ACCESS_READ flag is specified, staging resource will be created. - /// - If both CPU_ACCESS_WRITE and CPU_ACCESS_READ flags are used, an error will be generated. - /// An application must check the actual usage after the resource has been created. /// - /// Unified buffers are natively supported in Vulkan backend only. In other backends - /// they decay into default or staging buffers as described above. + /// 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). USAGE_UNIFIED, /// Helper value indicating the total number of elements in the enum diff --git a/Graphics/GraphicsEngine/src/BufferBase.cpp b/Graphics/GraphicsEngine/src/BufferBase.cpp index 106fd671..350ffc0f 100644 --- a/Graphics/GraphicsEngine/src/BufferBase.cpp +++ b/Graphics/GraphicsEngine/src/BufferBase.cpp @@ -43,7 +43,7 @@ namespace Diligent } while (false) -void ValidateBufferDesc(const BufferDesc& Desc) +void ValidateBufferDesc(const BufferDesc& Desc, const DeviceCaps& deviceCaps) { constexpr Uint32 AllowedBindFlags = BIND_VERTEX_BUFFER | @@ -88,6 +88,9 @@ void ValidateBufferDesc(const BufferDesc& Desc) break; case USAGE_UNIFIED: + VERIFY_BUFFER(deviceCaps.AdapterInfo.UnifiedMemory != 0, + "Unified memory is not present on this device. Check the amount of available unified memory " + "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."); break; |
