Codestyle fixes and optimizations
This commit is contained in:
@@ -129,15 +129,13 @@ void CmdBufferVulkan::RefreshFenceStatus()
|
|||||||
{
|
{
|
||||||
if (_state == State::Submitted)
|
if (_state == State::Submitted)
|
||||||
{
|
{
|
||||||
auto fenceManager = _fence->GetOwner();
|
if (_device->FenceManager.IsFenceSignaled(_fence))
|
||||||
if (fenceManager->IsFenceSignaled(_fence))
|
|
||||||
{
|
{
|
||||||
_state = State::ReadyForBegin;
|
_state = State::ReadyForBegin;
|
||||||
|
|
||||||
_submittedWaitSemaphores.Clear();
|
_submittedWaitSemaphores.Clear();
|
||||||
|
|
||||||
vkResetCommandBuffer(_commandBuffer, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT);
|
vkResetCommandBuffer(_commandBuffer, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT);
|
||||||
_fence->GetOwner()->ResetFence(_fence);
|
_device->FenceManager.ResetFence(_fence);
|
||||||
_fenceSignaledCounter++;
|
_fenceSignaledCounter++;
|
||||||
|
|
||||||
if (_descriptorPoolSetContainer)
|
if (_descriptorPoolSetContainer)
|
||||||
@@ -149,7 +147,7 @@ void CmdBufferVulkan::RefreshFenceStatus()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(!_fence->IsSignaled());
|
ASSERT(!_fence->IsSignaled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,8 +156,8 @@ CmdBufferVulkan::CmdBufferVulkan(GPUDeviceVulkan* device, CmdBufferPoolVulkan* p
|
|||||||
, _commandBuffer(VK_NULL_HANDLE)
|
, _commandBuffer(VK_NULL_HANDLE)
|
||||||
, _state(State::ReadyForBegin)
|
, _state(State::ReadyForBegin)
|
||||||
, _fence(nullptr)
|
, _fence(nullptr)
|
||||||
, _fenceSignaledCounter(0)
|
|
||||||
, _submittedFenceCounter(0)
|
, _submittedFenceCounter(0)
|
||||||
|
, _fenceSignaledCounter(0)
|
||||||
, _commandBufferPool(pool)
|
, _commandBufferPool(pool)
|
||||||
{
|
{
|
||||||
VkCommandBufferAllocateInfo createCmdBufInfo;
|
VkCommandBufferAllocateInfo createCmdBufInfo;
|
||||||
@@ -167,7 +165,6 @@ CmdBufferVulkan::CmdBufferVulkan(GPUDeviceVulkan* device, CmdBufferPoolVulkan* p
|
|||||||
createCmdBufInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
createCmdBufInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||||
createCmdBufInfo.commandBufferCount = 1;
|
createCmdBufInfo.commandBufferCount = 1;
|
||||||
createCmdBufInfo.commandPool = _commandBufferPool->GetHandle();
|
createCmdBufInfo.commandPool = _commandBufferPool->GetHandle();
|
||||||
|
|
||||||
VALIDATE_VULKAN_RESULT(vkAllocateCommandBuffers(_device->Device, &createCmdBufInfo, &_commandBuffer));
|
VALIDATE_VULKAN_RESULT(vkAllocateCommandBuffers(_device->Device, &createCmdBufInfo, &_commandBuffer));
|
||||||
_fence = _device->FenceManager.AllocateFence();
|
_fence = _device->FenceManager.AllocateFence();
|
||||||
}
|
}
|
||||||
@@ -217,17 +214,16 @@ CmdBufferPoolVulkan::~CmdBufferPoolVulkan()
|
|||||||
{
|
{
|
||||||
for (int32 i = 0; i < _cmdBuffers.Count(); i++)
|
for (int32 i = 0; i < _cmdBuffers.Count(); i++)
|
||||||
{
|
{
|
||||||
Delete(_cmdBuffers[i]);
|
Delete(_cmdBuffers.Get()[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
vkDestroyCommandPool(_device->Device, _handle, nullptr);
|
vkDestroyCommandPool(_device->Device, _handle, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdBufferPoolVulkan::RefreshFenceStatus(CmdBufferVulkan* skipCmdBuffer)
|
void CmdBufferPoolVulkan::RefreshFenceStatus(const CmdBufferVulkan* skipCmdBuffer)
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < _cmdBuffers.Count(); i++)
|
for (int32 i = 0; i < _cmdBuffers.Count(); i++)
|
||||||
{
|
{
|
||||||
auto cmdBuffer = _cmdBuffers[i];
|
const auto cmdBuffer = _cmdBuffers.Get()[i];
|
||||||
if (cmdBuffer != skipCmdBuffer)
|
if (cmdBuffer != skipCmdBuffer)
|
||||||
{
|
{
|
||||||
cmdBuffer->RefreshFenceStatus();
|
cmdBuffer->RefreshFenceStatus();
|
||||||
@@ -250,9 +246,8 @@ void CmdBufferManagerVulkan::SubmitActiveCmdBuffer(SemaphoreVulkan* signalSemaph
|
|||||||
if (!_activeCmdBuffer->IsSubmitted() && _activeCmdBuffer->HasBegun())
|
if (!_activeCmdBuffer->IsSubmitted() && _activeCmdBuffer->HasBegun())
|
||||||
{
|
{
|
||||||
if (_activeCmdBuffer->IsInsideRenderPass())
|
if (_activeCmdBuffer->IsInsideRenderPass())
|
||||||
{
|
|
||||||
_activeCmdBuffer->EndRenderPass();
|
_activeCmdBuffer->EndRenderPass();
|
||||||
}
|
|
||||||
|
|
||||||
#if VULKAN_USE_QUERIES
|
#if VULKAN_USE_QUERIES
|
||||||
// Pause all active queries
|
// Pause all active queries
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class CmdBufferVulkan
|
|||||||
friend QueueVulkan;
|
friend QueueVulkan;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum class State
|
enum class State
|
||||||
{
|
{
|
||||||
ReadyForBegin,
|
ReadyForBegin,
|
||||||
@@ -32,7 +31,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
VkCommandBuffer _commandBuffer;
|
VkCommandBuffer _commandBuffer;
|
||||||
State _state;
|
State _state;
|
||||||
@@ -57,13 +55,11 @@ private:
|
|||||||
DescriptorPoolSetContainerVulkan* _descriptorPoolSetContainer = nullptr;
|
DescriptorPoolSetContainerVulkan* _descriptorPoolSetContainer = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CmdBufferVulkan(GPUDeviceVulkan* device, CmdBufferPoolVulkan* pool);
|
CmdBufferVulkan(GPUDeviceVulkan* device, CmdBufferPoolVulkan* pool);
|
||||||
|
|
||||||
~CmdBufferVulkan();
|
~CmdBufferVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CmdBufferPoolVulkan* GetOwner() const
|
CmdBufferPoolVulkan* GetOwner() const
|
||||||
{
|
{
|
||||||
return _commandBufferPool;
|
return _commandBufferPool;
|
||||||
@@ -120,7 +116,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void AddWaitSemaphore(VkPipelineStageFlags waitFlags, SemaphoreVulkan* waitSemaphore);
|
void AddWaitSemaphore(VkPipelineStageFlags waitFlags, SemaphoreVulkan* waitSemaphore);
|
||||||
|
|
||||||
void Begin();
|
void Begin();
|
||||||
@@ -147,8 +142,8 @@ public:
|
|||||||
class CmdBufferPoolVulkan
|
class CmdBufferPoolVulkan
|
||||||
{
|
{
|
||||||
friend class CmdBufferManagerVulkan;
|
friend class CmdBufferManagerVulkan;
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
VkCommandPool _handle;
|
VkCommandPool _handle;
|
||||||
Array<CmdBufferVulkan*> _cmdBuffers;
|
Array<CmdBufferVulkan*> _cmdBuffers;
|
||||||
@@ -158,25 +153,22 @@ private:
|
|||||||
void Create(uint32 queueFamilyIndex);
|
void Create(uint32 queueFamilyIndex);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CmdBufferPoolVulkan(GPUDeviceVulkan* device);
|
CmdBufferPoolVulkan(GPUDeviceVulkan* device);
|
||||||
~CmdBufferPoolVulkan();
|
~CmdBufferPoolVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline VkCommandPool GetHandle() const
|
inline VkCommandPool GetHandle() const
|
||||||
{
|
{
|
||||||
ASSERT(_handle != VK_NULL_HANDLE);
|
ASSERT(_handle != VK_NULL_HANDLE);
|
||||||
return _handle;
|
return _handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RefreshFenceStatus(CmdBufferVulkan* skipCmdBuffer = nullptr);
|
void RefreshFenceStatus(const CmdBufferVulkan* skipCmdBuffer = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CmdBufferManagerVulkan
|
class CmdBufferManagerVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
CmdBufferPoolVulkan _pool;
|
CmdBufferPoolVulkan _pool;
|
||||||
QueueVulkan* _queue;
|
QueueVulkan* _queue;
|
||||||
@@ -184,11 +176,9 @@ private:
|
|||||||
Array<GPUTimerQueryVulkan*> _queriesInProgress;
|
Array<GPUTimerQueryVulkan*> _queriesInProgress;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CmdBufferManagerVulkan(GPUDeviceVulkan* device, GPUContextVulkan* context);
|
CmdBufferManagerVulkan(GPUDeviceVulkan* device, GPUContextVulkan* context);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FORCE_INLINE VkCommandPool GetHandle() const
|
FORCE_INLINE VkCommandPool GetHandle() const
|
||||||
{
|
{
|
||||||
return _pool.GetHandle();
|
return _pool.GetHandle();
|
||||||
@@ -217,7 +207,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void SubmitActiveCmdBuffer(SemaphoreVulkan* signalSemaphore = nullptr);
|
void SubmitActiveCmdBuffer(SemaphoreVulkan* signalSemaphore = nullptr);
|
||||||
|
|
||||||
void WaitForCmdBuffer(CmdBufferVulkan* cmdBuffer, float timeInSecondsToWait = 1.0f);
|
void WaitForCmdBuffer(CmdBufferVulkan* cmdBuffer, float timeInSecondsToWait = 1.0f);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default amount of frames to wait until resource delete.
|
/// Default amount of frames to wait until resource delete.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
#define VULKAN_RESOURCE_DELETE_SAFE_FRAMES_COUNT 10
|
#define VULKAN_RESOURCE_DELETE_SAFE_FRAMES_COUNT 20
|
||||||
|
|
||||||
#define VULKAN_ENABLE_API_DUMP 0
|
#define VULKAN_ENABLE_API_DUMP 0
|
||||||
#define VULKAN_RESET_QUERY_POOLS 0
|
#define VULKAN_RESET_QUERY_POOLS 0
|
||||||
|
|||||||
@@ -12,29 +12,12 @@
|
|||||||
#include "Engine/Threading/Threading.h"
|
#include "Engine/Threading/Threading.h"
|
||||||
#include "Engine/Engine/Engine.h"
|
#include "Engine/Engine/Engine.h"
|
||||||
|
|
||||||
void DescriptorSetLayoutInfoVulkan::CacheTypesUsageID()
|
|
||||||
{
|
|
||||||
static CriticalSection locker;
|
|
||||||
static uint32 uniqueID = 1;
|
|
||||||
static Dictionary<uint32, uint32> typesUsageHashMap;
|
|
||||||
|
|
||||||
const uint32 typesUsageHash = Crc::MemCrc32(_layoutTypes, sizeof(_layoutTypes));
|
|
||||||
ScopeLock lock(locker);
|
|
||||||
uint32 id;
|
|
||||||
if (!typesUsageHashMap.TryGet(typesUsageHash, id))
|
|
||||||
{
|
|
||||||
id = uniqueID++;
|
|
||||||
typesUsageHashMap.Add(typesUsageHash, id);
|
|
||||||
}
|
|
||||||
_typesUsageID = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DescriptorSetLayoutInfoVulkan::AddBindingsForStage(VkShaderStageFlagBits stageFlags, DescriptorSet::Stage descSet, const SpirvShaderDescriptorInfo* descriptorInfo)
|
void DescriptorSetLayoutInfoVulkan::AddBindingsForStage(VkShaderStageFlagBits stageFlags, DescriptorSet::Stage descSet, const SpirvShaderDescriptorInfo* descriptorInfo)
|
||||||
{
|
{
|
||||||
const int32 descriptorSetIndex = descSet;
|
const int32 descriptorSetIndex = descSet;
|
||||||
if (descriptorSetIndex >= _setLayouts.Count())
|
if (descriptorSetIndex >= SetLayouts.Count())
|
||||||
_setLayouts.Resize(descriptorSetIndex + 1);
|
SetLayouts.Resize(descriptorSetIndex + 1);
|
||||||
SetLayout& descSetLayout = _setLayouts[descriptorSetIndex];
|
SetLayout& descSetLayout = SetLayouts[descriptorSetIndex];
|
||||||
|
|
||||||
VkDescriptorSetLayoutBinding binding;
|
VkDescriptorSetLayoutBinding binding;
|
||||||
binding.stageFlags = stageFlags;
|
binding.stageFlags = stageFlags;
|
||||||
@@ -46,25 +29,26 @@ void DescriptorSetLayoutInfoVulkan::AddBindingsForStage(VkShaderStageFlagBits st
|
|||||||
binding.descriptorType = descriptor.DescriptorType;
|
binding.descriptorType = descriptor.DescriptorType;
|
||||||
binding.descriptorCount = descriptor.Count;
|
binding.descriptorCount = descriptor.Count;
|
||||||
|
|
||||||
_layoutTypes[binding.descriptorType]++;
|
LayoutTypes[binding.descriptorType]++;
|
||||||
descSetLayout.LayoutBindings.Add(binding);
|
descSetLayout.Add(binding);
|
||||||
_hash = Crc::MemCrc32(&binding, sizeof(binding), _hash);
|
Hash = Crc::MemCrc32(&binding, sizeof(binding), Hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DescriptorSetLayoutInfoVulkan::operator==(const DescriptorSetLayoutInfoVulkan& other) const
|
bool DescriptorSetLayoutInfoVulkan::operator==(const DescriptorSetLayoutInfoVulkan& other) const
|
||||||
{
|
{
|
||||||
if (other._setLayouts.Count() != _setLayouts.Count())
|
if (other.SetLayouts.Count() != SetLayouts.Count())
|
||||||
return false;
|
return false;
|
||||||
if (other._typesUsageID != _typesUsageID)
|
if (other.TypesUsageID != TypesUsageID)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int32 index = 0; index < other._setLayouts.Count(); index++)
|
for (int32 index = 0; index < other.SetLayouts.Count(); index++)
|
||||||
{
|
{
|
||||||
const int32 bindingsCount = _setLayouts[index].LayoutBindings.Count();
|
auto& setLayout = SetLayouts[index];
|
||||||
if (other._setLayouts[index].LayoutBindings.Count() != bindingsCount)
|
auto& setLayoutOther = other.SetLayouts[index];
|
||||||
|
if (setLayoutOther.Count() != setLayout.Count())
|
||||||
return false;
|
return false;
|
||||||
if (bindingsCount != 0 && Platform::MemoryCompare(other._setLayouts[index].LayoutBindings.Get(), _setLayouts[index].LayoutBindings.Get(), bindingsCount * sizeof(VkDescriptorSetLayoutBinding)))
|
if (setLayout.Count() != 0 && Platform::MemoryCompare(setLayoutOther.Get(), setLayout.Get(), setLayout.Count() * sizeof(VkDescriptorSetLayoutBinding)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,51 +56,63 @@ bool DescriptorSetLayoutInfoVulkan::operator==(const DescriptorSetLayoutInfoVulk
|
|||||||
}
|
}
|
||||||
|
|
||||||
DescriptorSetLayoutVulkan::DescriptorSetLayoutVulkan(GPUDeviceVulkan* device)
|
DescriptorSetLayoutVulkan::DescriptorSetLayoutVulkan(GPUDeviceVulkan* device)
|
||||||
: _device(device)
|
: Device(device)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorSetLayoutVulkan::~DescriptorSetLayoutVulkan()
|
DescriptorSetLayoutVulkan::~DescriptorSetLayoutVulkan()
|
||||||
{
|
{
|
||||||
for (VkDescriptorSetLayout& handle : _handles)
|
for (VkDescriptorSetLayout& handle : Handles)
|
||||||
{
|
{
|
||||||
_device->DeferredDeletionQueue.EnqueueResource(DeferredDeletionQueueVulkan::Type::DescriptorSetLayout, handle);
|
Device->DeferredDeletionQueue.EnqueueResource(DeferredDeletionQueueVulkan::Type::DescriptorSetLayout, handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorSetLayoutVulkan::Compile()
|
void DescriptorSetLayoutVulkan::Compile()
|
||||||
{
|
{
|
||||||
ASSERT(_handles.IsEmpty());
|
ASSERT(Handles.IsEmpty());
|
||||||
|
|
||||||
// Validate device limits for the engine
|
// Validate device limits for the engine
|
||||||
const VkPhysicalDeviceLimits& limits = _device->PhysicalDeviceLimits;
|
const VkPhysicalDeviceLimits& limits = Device->PhysicalDeviceLimits;
|
||||||
ASSERT(_layoutTypes[VK_DESCRIPTOR_TYPE_SAMPLER] + _layoutTypes[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER] < limits.maxDescriptorSetSamplers);
|
ASSERT(LayoutTypes[VK_DESCRIPTOR_TYPE_SAMPLER] + LayoutTypes[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER] < limits.maxDescriptorSetSamplers);
|
||||||
ASSERT(_layoutTypes[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER]+ _layoutTypes[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC] < limits.maxDescriptorSetUniformBuffers);
|
ASSERT(LayoutTypes[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER]+ LayoutTypes[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC] < limits.maxDescriptorSetUniformBuffers);
|
||||||
ASSERT(_layoutTypes[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC] < limits.maxDescriptorSetUniformBuffersDynamic);
|
ASSERT(LayoutTypes[VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC] < limits.maxDescriptorSetUniformBuffersDynamic);
|
||||||
ASSERT(_layoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER] + _layoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC] < limits.maxDescriptorSetStorageBuffers);
|
ASSERT(LayoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER] + LayoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC] < limits.maxDescriptorSetStorageBuffers);
|
||||||
ASSERT(_layoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC] < limits.maxDescriptorSetStorageBuffersDynamic);
|
ASSERT(LayoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC] < limits.maxDescriptorSetStorageBuffersDynamic);
|
||||||
ASSERT(_layoutTypes[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER] + _layoutTypes[VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE] + _layoutTypes[VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER] < limits.maxDescriptorSetSampledImages);
|
ASSERT(LayoutTypes[VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER] + LayoutTypes[VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE] + LayoutTypes[VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER] < limits.maxDescriptorSetSampledImages);
|
||||||
ASSERT(_layoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_IMAGE] + _layoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER]< limits.maxDescriptorSetStorageImages);
|
ASSERT(LayoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_IMAGE] + LayoutTypes[VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER]< limits.maxDescriptorSetStorageImages);
|
||||||
|
|
||||||
_handles.Resize(_setLayouts.Count());
|
Handles.Resize(SetLayouts.Count());
|
||||||
for (int32 i = 0; i < _setLayouts.Count(); i++)
|
for (int32 i = 0; i < SetLayouts.Count(); i++)
|
||||||
{
|
{
|
||||||
auto& layout = _setLayouts[i];
|
auto& layout = SetLayouts[i];
|
||||||
VkDescriptorSetLayoutCreateInfo layoutInfo;
|
VkDescriptorSetLayoutCreateInfo layoutInfo;
|
||||||
RenderToolsVulkan::ZeroStruct(layoutInfo, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO);
|
RenderToolsVulkan::ZeroStruct(layoutInfo, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO);
|
||||||
layoutInfo.bindingCount = layout.LayoutBindings.Count();
|
layoutInfo.bindingCount = layout.Count();
|
||||||
layoutInfo.pBindings = layout.LayoutBindings.Get();
|
layoutInfo.pBindings = layout.Get();
|
||||||
VALIDATE_VULKAN_RESULT(vkCreateDescriptorSetLayout(_device->Device, &layoutInfo, nullptr, &_handles[i]));
|
VALIDATE_VULKAN_RESULT(vkCreateDescriptorSetLayout(Device->Device, &layoutInfo, nullptr, &Handles[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_typesUsageID == ~0)
|
if (TypesUsageID == ~0)
|
||||||
{
|
{
|
||||||
CacheTypesUsageID();
|
// Cache usage ID
|
||||||
|
static uint32 uniqueID = 1;
|
||||||
|
static Dictionary<uint32, uint32> typesUsageHashMap;
|
||||||
|
const uint32 typesUsageHash = Crc::MemCrc32(LayoutTypes, sizeof(LayoutTypes));
|
||||||
|
uint32 id;
|
||||||
|
Device->Locker.Lock();
|
||||||
|
if (!typesUsageHashMap.TryGet(typesUsageHash, id))
|
||||||
|
{
|
||||||
|
id = uniqueID++;
|
||||||
|
typesUsageHashMap.Add(typesUsageHash, id);
|
||||||
|
}
|
||||||
|
Device->Locker.Unlock();
|
||||||
|
TypesUsageID = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderToolsVulkan::ZeroStruct(_allocateInfo, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO);
|
RenderToolsVulkan::ZeroStruct(AllocateInfo, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO);
|
||||||
_allocateInfo.descriptorSetCount = _handles.Count();
|
AllocateInfo.descriptorSetCount = Handles.Count();
|
||||||
_allocateInfo.pSetLayouts = _handles.Get();
|
AllocateInfo.pSetLayouts = Handles.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
DescriptorPoolVulkan::DescriptorPoolVulkan(GPUDeviceVulkan* device, const DescriptorSetLayoutVulkan& layout)
|
DescriptorPoolVulkan::DescriptorPoolVulkan(GPUDeviceVulkan* device, const DescriptorSetLayoutVulkan& layout)
|
||||||
@@ -131,11 +127,11 @@ DescriptorPoolVulkan::DescriptorPoolVulkan(GPUDeviceVulkan* device, const Descri
|
|||||||
|
|
||||||
// The maximum amount of descriptor sets layout allocations to hold
|
// The maximum amount of descriptor sets layout allocations to hold
|
||||||
const uint32 MaxSetsAllocations = 256;
|
const uint32 MaxSetsAllocations = 256;
|
||||||
_descriptorSetsMax = MaxSetsAllocations * (VULKAN_HASH_POOLS_WITH_TYPES_USAGE_ID ? 1 : _layout.GetLayouts().Count());
|
_descriptorSetsMax = MaxSetsAllocations * (VULKAN_HASH_POOLS_WITH_TYPES_USAGE_ID ? 1 : _layout.SetLayouts.Count());
|
||||||
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
||||||
{
|
{
|
||||||
const VkDescriptorType descriptorType = (VkDescriptorType)typeIndex;
|
const VkDescriptorType descriptorType = (VkDescriptorType)typeIndex;
|
||||||
const uint32 typesUsed = _layout.GetTypesUsed(descriptorType);
|
const uint32 typesUsed = _layout.LayoutTypes[descriptorType];
|
||||||
if (typesUsed > 0)
|
if (typesUsed > 0)
|
||||||
{
|
{
|
||||||
VkDescriptorPoolSize& type = types.AddOne();
|
VkDescriptorPoolSize& type = types.AddOne();
|
||||||
@@ -167,22 +163,22 @@ void DescriptorPoolVulkan::Track(const DescriptorSetLayoutVulkan& layout)
|
|||||||
#if !BUILD_RELEASE
|
#if !BUILD_RELEASE
|
||||||
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
||||||
{
|
{
|
||||||
ASSERT(_layout.GetTypesUsed((VkDescriptorType)typeIndex) == layout.GetTypesUsed((VkDescriptorType)typeIndex));
|
ASSERT(_layout.LayoutTypes[typeIndex] == layout.LayoutTypes[typeIndex]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
_allocatedDescriptorSetsCount += layout.GetLayouts().Count();
|
_allocatedDescriptorSetsCount += layout.SetLayouts.Count();
|
||||||
_allocatedDescriptorSetsCountMax = Math::Max(_allocatedDescriptorSetsCount, _allocatedDescriptorSetsCountMax);
|
_allocatedDescriptorSetsCountMax = Math::Max(_allocatedDescriptorSetsCount, _allocatedDescriptorSetsCountMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorPoolVulkan::TrackRemoveUsage(const DescriptorSetLayoutVulkan& layout)
|
void DescriptorPoolVulkan::TrackRemoveUsage(const DescriptorSetLayoutVulkan& layout)
|
||||||
{
|
{
|
||||||
// Check and increment our current type usage
|
#if !BUILD_RELEASE
|
||||||
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
for (uint32 typeIndex = VULKAN_DESCRIPTOR_TYPE_BEGIN; typeIndex <= VULKAN_DESCRIPTOR_TYPE_END; typeIndex++)
|
||||||
{
|
{
|
||||||
ASSERT(_layout.GetTypesUsed((VkDescriptorType)typeIndex) == layout.GetTypesUsed((VkDescriptorType)typeIndex));
|
ASSERT(_layout.LayoutTypes[typeIndex] == layout.LayoutTypes[typeIndex]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
_allocatedDescriptorSetsCount -= layout.GetLayouts().Count();
|
_allocatedDescriptorSetsCount -= layout.SetLayouts.Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptorPoolVulkan::Reset()
|
void DescriptorPoolVulkan::Reset()
|
||||||
@@ -214,11 +210,10 @@ TypedDescriptorPoolSetVulkan::~TypedDescriptorPoolSetVulkan()
|
|||||||
|
|
||||||
bool TypedDescriptorPoolSetVulkan::AllocateDescriptorSets(const DescriptorSetLayoutVulkan& layout, VkDescriptorSet* outSets)
|
bool TypedDescriptorPoolSetVulkan::AllocateDescriptorSets(const DescriptorSetLayoutVulkan& layout, VkDescriptorSet* outSets)
|
||||||
{
|
{
|
||||||
const auto& layoutHandles = layout.GetHandles();
|
if (layout.Handles.HasItems())
|
||||||
if (layoutHandles.HasItems())
|
|
||||||
{
|
{
|
||||||
auto* pool = _poolListCurrent->Element;
|
auto* pool = _poolListCurrent->Element;
|
||||||
while (!pool->AllocateDescriptorSets(layout.GetAllocateInfo(), outSets))
|
while (!pool->AllocateDescriptorSets(layout.AllocateInfo, outSets))
|
||||||
{
|
{
|
||||||
pool = GetFreePool(true);
|
pool = GetFreePool(true);
|
||||||
}
|
}
|
||||||
@@ -279,7 +274,7 @@ DescriptorPoolSetContainerVulkan::~DescriptorPoolSetContainerVulkan()
|
|||||||
|
|
||||||
TypedDescriptorPoolSetVulkan* DescriptorPoolSetContainerVulkan::AcquireTypedPoolSet(const DescriptorSetLayoutVulkan& layout)
|
TypedDescriptorPoolSetVulkan* DescriptorPoolSetContainerVulkan::AcquireTypedPoolSet(const DescriptorSetLayoutVulkan& layout)
|
||||||
{
|
{
|
||||||
const uint32 hash = VULKAN_HASH_POOLS_WITH_TYPES_USAGE_ID ? layout.GetTypesUsageID() : GetHash(layout);
|
const uint32 hash = VULKAN_HASH_POOLS_WITH_TYPES_USAGE_ID ? layout.TypesUsageID : layout.Hash;
|
||||||
TypedDescriptorPoolSetVulkan* typedPool;
|
TypedDescriptorPoolSetVulkan* typedPool;
|
||||||
if (!_typedDescriptorPools.TryGet(hash, typedPool))
|
if (!_typedDescriptorPools.TryGet(hash, typedPool))
|
||||||
{
|
{
|
||||||
@@ -361,12 +356,10 @@ PipelineLayoutVulkan::PipelineLayoutVulkan(GPUDeviceVulkan* device, const Descri
|
|||||||
_descriptorSetLayout.CopyFrom(layout);
|
_descriptorSetLayout.CopyFrom(layout);
|
||||||
_descriptorSetLayout.Compile();
|
_descriptorSetLayout.Compile();
|
||||||
|
|
||||||
const auto& layoutHandles = _descriptorSetLayout.GetHandles();
|
|
||||||
|
|
||||||
VkPipelineLayoutCreateInfo createInfo;
|
VkPipelineLayoutCreateInfo createInfo;
|
||||||
RenderToolsVulkan::ZeroStruct(createInfo, VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO);
|
RenderToolsVulkan::ZeroStruct(createInfo, VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO);
|
||||||
createInfo.setLayoutCount = layoutHandles.Count();
|
createInfo.setLayoutCount = _descriptorSetLayout.Handles.Count();
|
||||||
createInfo.pSetLayouts = layoutHandles.Get();
|
createInfo.pSetLayouts = _descriptorSetLayout.Handles.Get();
|
||||||
VALIDATE_VULKAN_RESULT(vkCreatePipelineLayout(_device->Device, &createInfo, nullptr, &_handle));
|
VALIDATE_VULKAN_RESULT(vkCreatePipelineLayout(_device->Device, &createInfo, nullptr, &_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,106 +54,62 @@ namespace DescriptorSet
|
|||||||
class DescriptorSetLayoutInfoVulkan
|
class DescriptorSetLayoutInfoVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef Array<VkDescriptorSetLayoutBinding> SetLayout;
|
||||||
|
|
||||||
struct SetLayout
|
uint32 Hash = 0;
|
||||||
{
|
uint32 TypesUsageID = ~0;
|
||||||
Array<VkDescriptorSetLayoutBinding> LayoutBindings;
|
Array<SetLayout> SetLayouts;
|
||||||
};
|
uint32 LayoutTypes[VULKAN_DESCRIPTOR_TYPE_END];
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
uint32 _layoutTypes[VULKAN_DESCRIPTOR_TYPE_END];
|
|
||||||
Array<SetLayout> _setLayouts;
|
|
||||||
uint32 _hash = 0;
|
|
||||||
uint32 _typesUsageID = ~0;
|
|
||||||
|
|
||||||
void CacheTypesUsageID();
|
void CacheTypesUsageID();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DescriptorSetLayoutInfoVulkan()
|
DescriptorSetLayoutInfoVulkan()
|
||||||
{
|
{
|
||||||
Platform::MemoryClear(_layoutTypes, sizeof(_layoutTypes));
|
Platform::MemoryClear(LayoutTypes, sizeof(LayoutTypes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
inline uint32 GetTypesUsed(VkDescriptorType type) const
|
|
||||||
{
|
|
||||||
return _layoutTypes[type];
|
|
||||||
}
|
|
||||||
|
|
||||||
const Array<SetLayout>& GetLayouts() const
|
|
||||||
{
|
|
||||||
return _setLayouts;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline uint32 GetTypesUsageID() const
|
|
||||||
{
|
|
||||||
return _typesUsageID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void AddBindingsForStage(VkShaderStageFlagBits stageFlags, DescriptorSet::Stage descSet, const SpirvShaderDescriptorInfo* descriptorInfo);
|
void AddBindingsForStage(VkShaderStageFlagBits stageFlags, DescriptorSet::Stage descSet, const SpirvShaderDescriptorInfo* descriptorInfo);
|
||||||
|
|
||||||
void CopyFrom(const DescriptorSetLayoutInfoVulkan& info)
|
void CopyFrom(const DescriptorSetLayoutInfoVulkan& info)
|
||||||
{
|
{
|
||||||
Platform::MemoryCopy(_layoutTypes, info._layoutTypes, sizeof(_layoutTypes));
|
Platform::MemoryCopy(LayoutTypes, info.LayoutTypes, sizeof(LayoutTypes));
|
||||||
_hash = info._hash;
|
Hash = info.Hash;
|
||||||
_typesUsageID = info._typesUsageID;
|
TypesUsageID = info.TypesUsageID;
|
||||||
_setLayouts = info._setLayouts;
|
SetLayouts = info.SetLayouts;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const DescriptorSetLayoutInfoVulkan& other) const;
|
bool operator==(const DescriptorSetLayoutInfoVulkan& other) const;
|
||||||
|
|
||||||
friend inline uint32 GetHash(const DescriptorSetLayoutInfoVulkan& key)
|
friend inline uint32 GetHash(const DescriptorSetLayoutInfoVulkan& key)
|
||||||
{
|
{
|
||||||
return key._hash;
|
return key.Hash;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DescriptorSetLayoutVulkan : public DescriptorSetLayoutInfoVulkan
|
class DescriptorSetLayoutVulkan : public DescriptorSetLayoutInfoVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef Array<VkDescriptorSetLayout, FixedAllocation<DescriptorSet::Max>> HandlesArray;
|
||||||
|
|
||||||
typedef Array<VkDescriptorSetLayout, FixedAllocation<DescriptorSet::Max>> DescriptorSetLayoutHandlesArray;
|
GPUDeviceVulkan* Device;
|
||||||
|
HandlesArray Handles;
|
||||||
private:
|
VkDescriptorSetAllocateInfo AllocateInfo;
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
|
||||||
DescriptorSetLayoutHandlesArray _handles;
|
|
||||||
VkDescriptorSetAllocateInfo _allocateInfo;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
DescriptorSetLayoutVulkan(GPUDeviceVulkan* device);
|
DescriptorSetLayoutVulkan(GPUDeviceVulkan* device);
|
||||||
~DescriptorSetLayoutVulkan();
|
~DescriptorSetLayoutVulkan();
|
||||||
|
|
||||||
public:
|
void Compile();
|
||||||
|
|
||||||
inline const DescriptorSetLayoutHandlesArray& GetHandles() const
|
|
||||||
{
|
|
||||||
return _handles;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const VkDescriptorSetAllocateInfo& GetAllocateInfo() const
|
|
||||||
{
|
|
||||||
return _allocateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend inline uint32 GetHash(const DescriptorSetLayoutVulkan& key)
|
friend inline uint32 GetHash(const DescriptorSetLayoutVulkan& key)
|
||||||
{
|
{
|
||||||
return key._hash;
|
return key.Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Compile();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DescriptorPoolVulkan
|
class DescriptorPoolVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
VkDescriptorPool _handle;
|
VkDescriptorPool _handle;
|
||||||
|
|
||||||
@@ -164,12 +120,10 @@ private:
|
|||||||
const DescriptorSetLayoutVulkan& _layout;
|
const DescriptorSetLayoutVulkan& _layout;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DescriptorPoolVulkan(GPUDeviceVulkan* device, const DescriptorSetLayoutVulkan& layout);
|
DescriptorPoolVulkan(GPUDeviceVulkan* device, const DescriptorSetLayoutVulkan& layout);
|
||||||
~DescriptorPoolVulkan();
|
~DescriptorPoolVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline VkDescriptorPool GetHandle() const
|
inline VkDescriptorPool GetHandle() const
|
||||||
{
|
{
|
||||||
return _handle;
|
return _handle;
|
||||||
@@ -182,7 +136,7 @@ public:
|
|||||||
|
|
||||||
inline bool CanAllocate(const DescriptorSetLayoutVulkan& layout) const
|
inline bool CanAllocate(const DescriptorSetLayoutVulkan& layout) const
|
||||||
{
|
{
|
||||||
return _descriptorSetsMax > _allocatedDescriptorSetsCount + layout.GetLayouts().Count();
|
return _descriptorSetsMax > _allocatedDescriptorSetsCount + layout.SetLayouts.Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint32 GetAllocatedDescriptorSetsCount() const
|
inline uint32 GetAllocatedDescriptorSetsCount() const
|
||||||
@@ -191,7 +145,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Track(const DescriptorSetLayoutVulkan& layout);
|
void Track(const DescriptorSetLayoutVulkan& layout);
|
||||||
void TrackRemoveUsage(const DescriptorSetLayoutVulkan& layout);
|
void TrackRemoveUsage(const DescriptorSetLayoutVulkan& layout);
|
||||||
void Reset();
|
void Reset();
|
||||||
@@ -205,7 +158,6 @@ class TypedDescriptorPoolSetVulkan
|
|||||||
friend DescriptorPoolSetContainerVulkan;
|
friend DescriptorPoolSetContainerVulkan;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
const DescriptorPoolSetContainerVulkan* _owner;
|
const DescriptorPoolSetContainerVulkan* _owner;
|
||||||
const DescriptorSetLayoutVulkan& _layout;
|
const DescriptorSetLayoutVulkan& _layout;
|
||||||
@@ -213,7 +165,6 @@ private:
|
|||||||
class PoolList
|
class PoolList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DescriptorPoolVulkan* Element;
|
DescriptorPoolVulkan* Element;
|
||||||
PoolList* Next;
|
PoolList* Next;
|
||||||
|
|
||||||
@@ -228,7 +179,6 @@ private:
|
|||||||
PoolList* _poolListCurrent = nullptr;
|
PoolList* _poolListCurrent = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TypedDescriptorPoolSetVulkan(GPUDeviceVulkan* device, const DescriptorPoolSetContainerVulkan* owner, const DescriptorSetLayoutVulkan& layout)
|
TypedDescriptorPoolSetVulkan(GPUDeviceVulkan* device, const DescriptorPoolSetContainerVulkan* owner, const DescriptorSetLayoutVulkan& layout)
|
||||||
: _device(device)
|
: _device(device)
|
||||||
, _owner(owner)
|
, _owner(owner)
|
||||||
@@ -247,7 +197,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
DescriptorPoolVulkan* GetFreePool(bool forceNewPool = false);
|
DescriptorPoolVulkan* GetFreePool(bool forceNewPool = false);
|
||||||
DescriptorPoolVulkan* PushNewPool();
|
DescriptorPoolVulkan* PushNewPool();
|
||||||
void Reset();
|
void Reset();
|
||||||
@@ -256,20 +205,16 @@ private:
|
|||||||
class DescriptorPoolSetContainerVulkan
|
class DescriptorPoolSetContainerVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
Dictionary<uint32, TypedDescriptorPoolSetVulkan*> _typedDescriptorPools;
|
Dictionary<uint32, TypedDescriptorPoolSetVulkan*> _typedDescriptorPools;
|
||||||
uint64 _lastFrameUsed;
|
uint64 _lastFrameUsed;
|
||||||
bool _used;
|
bool _used;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DescriptorPoolSetContainerVulkan(GPUDeviceVulkan* device);
|
DescriptorPoolSetContainerVulkan(GPUDeviceVulkan* device);
|
||||||
|
|
||||||
~DescriptorPoolSetContainerVulkan();
|
~DescriptorPoolSetContainerVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TypedDescriptorPoolSetVulkan* AcquireTypedPoolSet(const DescriptorSetLayoutVulkan& layout);
|
TypedDescriptorPoolSetVulkan* AcquireTypedPoolSet(const DescriptorSetLayoutVulkan& layout);
|
||||||
void Reset();
|
void Reset();
|
||||||
void SetUsed(bool used);
|
void SetUsed(bool used);
|
||||||
@@ -288,13 +233,11 @@ public:
|
|||||||
class DescriptorPoolsManagerVulkan
|
class DescriptorPoolsManagerVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device = nullptr;
|
GPUDeviceVulkan* _device = nullptr;
|
||||||
CriticalSection _locker;
|
CriticalSection _locker;
|
||||||
Array<DescriptorPoolSetContainerVulkan*> _poolSets;
|
Array<DescriptorPoolSetContainerVulkan*> _poolSets;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DescriptorPoolsManagerVulkan(GPUDeviceVulkan* device);
|
DescriptorPoolsManagerVulkan(GPUDeviceVulkan* device);
|
||||||
~DescriptorPoolsManagerVulkan();
|
~DescriptorPoolsManagerVulkan();
|
||||||
|
|
||||||
@@ -306,25 +249,20 @@ public:
|
|||||||
class PipelineLayoutVulkan
|
class PipelineLayoutVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
VkPipelineLayout _handle;
|
VkPipelineLayout _handle;
|
||||||
DescriptorSetLayoutVulkan _descriptorSetLayout;
|
DescriptorSetLayoutVulkan _descriptorSetLayout;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PipelineLayoutVulkan(GPUDeviceVulkan* device, const DescriptorSetLayoutInfoVulkan& layout);
|
PipelineLayoutVulkan(GPUDeviceVulkan* device, const DescriptorSetLayoutInfoVulkan& layout);
|
||||||
~PipelineLayoutVulkan();
|
~PipelineLayoutVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline VkPipelineLayout GetHandle() const
|
inline VkPipelineLayout GetHandle() const
|
||||||
{
|
{
|
||||||
return _handle;
|
return _handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
inline const DescriptorSetLayoutVulkan& GetDescriptorSetLayout() const
|
inline const DescriptorSetLayoutVulkan& GetDescriptorSetLayout() const
|
||||||
{
|
{
|
||||||
return _descriptorSetLayout;
|
return _descriptorSetLayout;
|
||||||
@@ -332,7 +270,7 @@ public:
|
|||||||
|
|
||||||
inline bool HasDescriptors() const
|
inline bool HasDescriptors() const
|
||||||
{
|
{
|
||||||
return _descriptorSetLayout.GetLayouts().HasItems();
|
return _descriptorSetLayout.SetLayouts.HasItems();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -357,14 +295,12 @@ struct DescriptorSetWriteContainerVulkan
|
|||||||
class DescriptorSetWriterVulkan
|
class DescriptorSetWriterVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VkWriteDescriptorSet* WriteDescriptors = nullptr;
|
VkWriteDescriptorSet* WriteDescriptors = nullptr;
|
||||||
byte* BindingToDynamicOffset = nullptr;
|
byte* BindingToDynamicOffset = nullptr;
|
||||||
uint32* DynamicOffsets = nullptr;
|
uint32* DynamicOffsets = nullptr;
|
||||||
uint32 WritesCount = 0;
|
uint32 WritesCount = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
uint32 SetupDescriptorWrites(const SpirvShaderDescriptorInfo& info, VkWriteDescriptorSet* writeDescriptors, VkDescriptorImageInfo* imageInfo, VkDescriptorBufferInfo* bufferInfo, VkBufferView* texelBufferView, byte* bindingToDynamicOffset);
|
uint32 SetupDescriptorWrites(const SpirvShaderDescriptorInfo& info, VkWriteDescriptorSet* writeDescriptors, VkDescriptorImageInfo* imageInfo, VkDescriptorBufferInfo* bufferInfo, VkBufferView* texelBufferView, byte* bindingToDynamicOffset);
|
||||||
|
|
||||||
bool WriteUniformBuffer(uint32 descriptorIndex, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range, uint32 index = 0) const
|
bool WriteUniformBuffer(uint32 descriptorIndex, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range, uint32 index = 0) const
|
||||||
@@ -451,9 +387,7 @@ public:
|
|||||||
void SetDescriptorSet(VkDescriptorSet descriptorSet) const
|
void SetDescriptorSet(VkDescriptorSet descriptorSet) const
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i < WritesCount; i++)
|
for (uint32 i = 0; i < WritesCount; i++)
|
||||||
{
|
|
||||||
WriteDescriptors[i].dstSet = descriptorSet;
|
WriteDescriptors[i].dstSet = descriptorSet;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
class GPUAdapterVulkan : public GPUAdapter
|
class GPUAdapterVulkan : public GPUAdapter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUAdapterVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUAdapterVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -38,7 +37,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The GPU device handle.
|
/// The GPU device handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -55,7 +53,6 @@ public:
|
|||||||
String Description;
|
String Description;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUAdapter]
|
// [GPUAdapter]
|
||||||
bool IsValid() const override
|
bool IsValid() const override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
class GPUBufferViewVulkan : public GPUBufferView, public DescriptorOwnerResourceVulkan
|
class GPUBufferViewVulkan : public GPUBufferView, public DescriptorOwnerResourceVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GPUBufferViewVulkan()
|
GPUBufferViewVulkan()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -26,7 +25,6 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GPUDeviceVulkan* Device = nullptr;
|
GPUDeviceVulkan* Device = nullptr;
|
||||||
GPUBufferVulkan* Owner = nullptr;
|
GPUBufferVulkan* Owner = nullptr;
|
||||||
VkBuffer Buffer = VK_NULL_HANDLE;
|
VkBuffer Buffer = VK_NULL_HANDLE;
|
||||||
@@ -34,13 +32,10 @@ public:
|
|||||||
VkDeviceSize Size = 0;
|
VkDeviceSize Size = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Init(GPUDeviceVulkan* device, GPUBufferVulkan* owner, VkBuffer buffer, VkDeviceSize size, VkBufferUsageFlags usage, PixelFormat format);
|
void Init(GPUDeviceVulkan* device, GPUBufferVulkan* owner, VkBuffer buffer, VkDeviceSize size, VkBufferUsageFlags usage, PixelFormat format);
|
||||||
|
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUResourceView]
|
// [GPUResourceView]
|
||||||
void* GetNativePtr() const override
|
void* GetNativePtr() const override
|
||||||
{
|
{
|
||||||
@@ -59,13 +54,11 @@ public:
|
|||||||
class GPUBufferVulkan : public GPUResourceVulkan<GPUBuffer>
|
class GPUBufferVulkan : public GPUResourceVulkan<GPUBuffer>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
VkBuffer _buffer = VK_NULL_HANDLE;
|
VkBuffer _buffer = VK_NULL_HANDLE;
|
||||||
VmaAllocation _allocation = VK_NULL_HANDLE;
|
VmaAllocation _allocation = VK_NULL_HANDLE;
|
||||||
GPUBufferViewVulkan _view;
|
GPUBufferViewVulkan _view;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUBufferVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUBufferVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -77,7 +70,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Vulkan buffer handle.
|
/// Gets the Vulkan buffer handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -105,14 +97,12 @@ public:
|
|||||||
GPUBufferVulkan* Counter = nullptr;
|
GPUBufferVulkan* Counter = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUBuffer]
|
// [GPUBuffer]
|
||||||
GPUBufferView* View() const override;
|
GPUBufferView* View() const override;
|
||||||
void* Map(GPUResourceMapMode mode) override;
|
void* Map(GPUResourceMapMode mode) override;
|
||||||
void Unmap() override;
|
void Unmap() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// [GPUBuffer]
|
// [GPUBuffer]
|
||||||
bool OnInit() override;
|
bool OnInit() override;
|
||||||
void OnReleaseGPU() override;
|
void OnReleaseGPU() override;
|
||||||
|
|||||||
@@ -20,18 +20,18 @@
|
|||||||
// Ensure to match the indirect commands arguments layout
|
// Ensure to match the indirect commands arguments layout
|
||||||
static_assert(sizeof(GPUDispatchIndirectArgs) == sizeof(VkDispatchIndirectCommand), "Wrong size of GPUDrawIndirectArgs.");
|
static_assert(sizeof(GPUDispatchIndirectArgs) == sizeof(VkDispatchIndirectCommand), "Wrong size of GPUDrawIndirectArgs.");
|
||||||
static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountX) == OFFSET_OF(VkDispatchIndirectCommand, x), "Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountX");
|
static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountX) == OFFSET_OF(VkDispatchIndirectCommand, x), "Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountX");
|
||||||
static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountY) == OFFSET_OF(VkDispatchIndirectCommand, y),"Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountY");
|
static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountY) == OFFSET_OF(VkDispatchIndirectCommand, y), "Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountY");
|
||||||
static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountZ) == OFFSET_OF(VkDispatchIndirectCommand, z), "Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountZ");
|
static_assert(OFFSET_OF(GPUDispatchIndirectArgs, ThreadGroupCountZ) == OFFSET_OF(VkDispatchIndirectCommand, z), "Wrong offset for GPUDrawIndirectArgs::ThreadGroupCountZ");
|
||||||
//
|
//
|
||||||
static_assert(sizeof(GPUDrawIndirectArgs) == sizeof(VkDrawIndirectCommand), "Wrong size of GPUDrawIndirectArgs.");
|
static_assert(sizeof(GPUDrawIndirectArgs) == sizeof(VkDrawIndirectCommand), "Wrong size of GPUDrawIndirectArgs.");
|
||||||
static_assert(OFFSET_OF(GPUDrawIndirectArgs, VerticesCount) == OFFSET_OF(VkDrawIndirectCommand, vertexCount), "Wrong offset for GPUDrawIndirectArgs::VerticesCount");
|
static_assert(OFFSET_OF(GPUDrawIndirectArgs, VerticesCount) == OFFSET_OF(VkDrawIndirectCommand, vertexCount), "Wrong offset for GPUDrawIndirectArgs::VerticesCount");
|
||||||
static_assert(OFFSET_OF(GPUDrawIndirectArgs, InstanceCount) == OFFSET_OF(VkDrawIndirectCommand, instanceCount),"Wrong offset for GPUDrawIndirectArgs::InstanceCount");
|
static_assert(OFFSET_OF(GPUDrawIndirectArgs, InstanceCount) == OFFSET_OF(VkDrawIndirectCommand, instanceCount), "Wrong offset for GPUDrawIndirectArgs::InstanceCount");
|
||||||
static_assert(OFFSET_OF(GPUDrawIndirectArgs, StartVertex) == OFFSET_OF(VkDrawIndirectCommand, firstVertex), "Wrong offset for GPUDrawIndirectArgs::StartVertex");
|
static_assert(OFFSET_OF(GPUDrawIndirectArgs, StartVertex) == OFFSET_OF(VkDrawIndirectCommand, firstVertex), "Wrong offset for GPUDrawIndirectArgs::StartVertex");
|
||||||
static_assert(OFFSET_OF(GPUDrawIndirectArgs, StartInstance) == OFFSET_OF(VkDrawIndirectCommand, firstInstance), "Wrong offset for GPUDrawIndirectArgs::StartInstance");
|
static_assert(OFFSET_OF(GPUDrawIndirectArgs, StartInstance) == OFFSET_OF(VkDrawIndirectCommand, firstInstance), "Wrong offset for GPUDrawIndirectArgs::StartInstance");
|
||||||
//
|
//
|
||||||
static_assert(sizeof(GPUDrawIndexedIndirectArgs) == sizeof(VkDrawIndexedIndirectCommand), "Wrong size of GPUDrawIndexedIndirectArgs.");
|
static_assert(sizeof(GPUDrawIndexedIndirectArgs) == sizeof(VkDrawIndexedIndirectCommand), "Wrong size of GPUDrawIndexedIndirectArgs.");
|
||||||
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, IndicesCount) == OFFSET_OF(VkDrawIndexedIndirectCommand, indexCount), "Wrong offset for GPUDrawIndexedIndirectArgs::IndicesCount");
|
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, IndicesCount) == OFFSET_OF(VkDrawIndexedIndirectCommand, indexCount), "Wrong offset for GPUDrawIndexedIndirectArgs::IndicesCount");
|
||||||
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, InstanceCount) == OFFSET_OF(VkDrawIndexedIndirectCommand, instanceCount),"Wrong offset for GPUDrawIndexedIndirectArgs::InstanceCount");
|
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, InstanceCount) == OFFSET_OF(VkDrawIndexedIndirectCommand, instanceCount), "Wrong offset for GPUDrawIndexedIndirectArgs::InstanceCount");
|
||||||
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, StartIndex) == OFFSET_OF(VkDrawIndexedIndirectCommand, firstIndex), "Wrong offset for GPUDrawIndexedIndirectArgs::StartIndex");
|
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, StartIndex) == OFFSET_OF(VkDrawIndexedIndirectCommand, firstIndex), "Wrong offset for GPUDrawIndexedIndirectArgs::StartIndex");
|
||||||
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, StartVertex) == OFFSET_OF(VkDrawIndexedIndirectCommand, vertexOffset), "Wrong offset for GPUDrawIndexedIndirectArgs::StartVertex");
|
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, StartVertex) == OFFSET_OF(VkDrawIndexedIndirectCommand, vertexOffset), "Wrong offset for GPUDrawIndexedIndirectArgs::StartVertex");
|
||||||
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, StartInstance) == OFFSET_OF(VkDrawIndexedIndirectCommand, firstInstance), "Wrong offset for GPUDrawIndexedIndirectArgs::StartInstance");
|
static_assert(OFFSET_OF(GPUDrawIndexedIndirectArgs, StartInstance) == OFFSET_OF(VkDrawIndexedIndirectCommand, firstInstance), "Wrong offset for GPUDrawIndexedIndirectArgs::StartInstance");
|
||||||
@@ -337,7 +337,7 @@ DescriptorPoolVulkan* GPUContextVulkan::AllocateDescriptorSets(const VkDescripto
|
|||||||
VkDescriptorSetAllocateInfo allocateInfo = descriptorSetAllocateInfo;
|
VkDescriptorSetAllocateInfo allocateInfo = descriptorSetAllocateInfo;
|
||||||
DescriptorPoolVulkan* pool = nullptr;
|
DescriptorPoolVulkan* pool = nullptr;
|
||||||
|
|
||||||
const uint32 hash = VULKAN_HASH_POOLS_WITH_TYPES_USAGE_ID ? layout.GetTypesUsageID() : GetHash(layout);
|
const uint32 hash = VULKAN_HASH_POOLS_WITH_TYPES_USAGE_ID ? layout.TypesUsageID : layout.Hash;
|
||||||
DescriptorPoolArray* typedDescriptorPools = _descriptorPools.TryGet(hash);
|
DescriptorPoolArray* typedDescriptorPools = _descriptorPools.TryGet(hash);
|
||||||
|
|
||||||
if (typedDescriptorPools != nullptr)
|
if (typedDescriptorPools != nullptr)
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ class DescriptorSetLayoutVulkan;
|
|||||||
struct PipelineBarrierVulkan
|
struct PipelineBarrierVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VkPipelineStageFlags SourceStage = 0;
|
VkPipelineStageFlags SourceStage = 0;
|
||||||
VkPipelineStageFlags DestStage = 0;
|
VkPipelineStageFlags DestStage = 0;
|
||||||
Array<VkImageMemoryBarrier, FixedAllocation<VK_BARRIER_BUFFER_SIZE>> ImageBarriers;
|
Array<VkImageMemoryBarrier, FixedAllocation<VK_BARRIER_BUFFER_SIZE>> ImageBarriers;
|
||||||
@@ -51,7 +50,6 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline void Reset()
|
inline void Reset()
|
||||||
{
|
{
|
||||||
SourceStage = 0;
|
SourceStage = 0;
|
||||||
@@ -85,7 +83,6 @@ public:
|
|||||||
class GPUContextVulkan : public GPUContext
|
class GPUContextVulkan : public GPUContext
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
QueueVulkan* _queue;
|
QueueVulkan* _queue;
|
||||||
CmdBufferManagerVulkan* _cmdBufferManager;
|
CmdBufferManagerVulkan* _cmdBufferManager;
|
||||||
@@ -116,7 +113,6 @@ private:
|
|||||||
Dictionary<uint32, DescriptorPoolArray> _descriptorPools;
|
Dictionary<uint32, DescriptorPoolArray> _descriptorPools;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUContextVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUContextVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -130,7 +126,6 @@ public:
|
|||||||
~GPUContextVulkan();
|
~GPUContextVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QueueVulkan* GetQueue() const
|
QueueVulkan* GetQueue() const
|
||||||
{
|
{
|
||||||
return _queue;
|
return _queue;
|
||||||
@@ -157,14 +152,12 @@ public:
|
|||||||
void EndRenderPass();
|
void EndRenderPass();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void UpdateDescriptorSets(const struct SpirvShaderDescriptorInfo& descriptorInfo, class DescriptorSetWriterVulkan& dsWriter, bool& needsWrite);
|
void UpdateDescriptorSets(const struct SpirvShaderDescriptorInfo& descriptorInfo, class DescriptorSetWriterVulkan& dsWriter, bool& needsWrite);
|
||||||
void UpdateDescriptorSets(GPUPipelineStateVulkan* pipelineState);
|
void UpdateDescriptorSets(GPUPipelineStateVulkan* pipelineState);
|
||||||
void UpdateDescriptorSets(ComputePipelineStateVulkan* pipelineState);
|
void UpdateDescriptorSets(ComputePipelineStateVulkan* pipelineState);
|
||||||
void OnDrawCall();
|
void OnDrawCall();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUContext]
|
// [GPUContext]
|
||||||
void FrameBegin() override;
|
void FrameBegin() override;
|
||||||
void FrameEnd() override;
|
void FrameEnd() override;
|
||||||
|
|||||||
@@ -250,23 +250,18 @@ void SetupDebugLayerCallback()
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
createInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
|
createInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
|
||||||
// Fall-through...
|
|
||||||
case 4:
|
case 4:
|
||||||
createInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
|
createInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT;
|
||||||
// Fall-through...
|
|
||||||
case 3:
|
case 3:
|
||||||
createInfo.messageType |= VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
createInfo.messageType |= VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
|
||||||
// Fall-through...
|
|
||||||
case 2:
|
case 2:
|
||||||
createInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
|
createInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT;
|
||||||
createInfo.messageType |= VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT;
|
createInfo.messageType |= VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT;
|
||||||
// Fall-through...
|
|
||||||
case 1:
|
case 1:
|
||||||
createInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
createInfo.messageSeverity |= VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
|
||||||
createInfo.messageType |= VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT;
|
createInfo.messageType |= VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
// Nothing to do
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const VkResult result = vkCreateDebugUtilsMessengerEXT(GPUDeviceVulkan::Instance, &createInfo, nullptr, &Messenger);
|
const VkResult result = vkCreateDebugUtilsMessengerEXT(GPUDeviceVulkan::Instance, &createInfo, nullptr, &Messenger);
|
||||||
@@ -288,21 +283,16 @@ void SetupDebugLayerCallback()
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
createInfo.flags |= VK_DEBUG_REPORT_DEBUG_BIT_EXT;
|
createInfo.flags |= VK_DEBUG_REPORT_DEBUG_BIT_EXT;
|
||||||
// Fall-through...
|
|
||||||
case 4:
|
case 4:
|
||||||
createInfo.flags |= VK_DEBUG_REPORT_INFORMATION_BIT_EXT;
|
createInfo.flags |= VK_DEBUG_REPORT_INFORMATION_BIT_EXT;
|
||||||
// Fall-through...
|
|
||||||
case 3:
|
case 3:
|
||||||
createInfo.flags |= VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
createInfo.flags |= VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
||||||
// Fall-through...
|
|
||||||
case 2:
|
case 2:
|
||||||
createInfo.flags |= VK_DEBUG_REPORT_WARNING_BIT_EXT;
|
createInfo.flags |= VK_DEBUG_REPORT_WARNING_BIT_EXT;
|
||||||
// Fall-through...
|
|
||||||
case 1:
|
case 1:
|
||||||
createInfo.flags |= VK_DEBUG_REPORT_ERROR_BIT_EXT;
|
createInfo.flags |= VK_DEBUG_REPORT_ERROR_BIT_EXT;
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
// Nothing to do
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const VkResult result = vkCreateDebugReportCallbackEXT(GPUDeviceVulkan::Instance, &createInfo, nullptr, &MsgCallback);
|
const VkResult result = vkCreateDebugReportCallbackEXT(GPUDeviceVulkan::Instance, &createInfo, nullptr, &MsgCallback);
|
||||||
@@ -354,14 +344,14 @@ DeferredDeletionQueueVulkan::~DeferredDeletionQueueVulkan()
|
|||||||
ASSERT(_entries.IsEmpty());
|
ASSERT(_entries.IsEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredDeletionQueueVulkan::ReleaseResources(bool deleteImmediately)
|
void DeferredDeletionQueueVulkan::ReleaseResources(bool immediately)
|
||||||
{
|
{
|
||||||
const uint64 checkFrame = Engine::FrameCount - VULKAN_RESOURCE_DELETE_SAFE_FRAMES_COUNT;
|
const uint64 checkFrame = Engine::FrameCount - VULKAN_RESOURCE_DELETE_SAFE_FRAMES_COUNT;
|
||||||
ScopeLock lock(_locker);
|
ScopeLock lock(_locker);
|
||||||
for (int32 i = 0; i < _entries.Count(); i++)
|
for (int32 i = 0; i < _entries.Count(); i++)
|
||||||
{
|
{
|
||||||
Entry* e = &_entries.Get()[i];
|
Entry* e = &_entries.Get()[i];
|
||||||
if (deleteImmediately || (checkFrame > e->FrameNumber && (e->CmdBuffer == nullptr || e->FenceCounter < e->CmdBuffer->GetFenceSignaledCounter())))
|
if (immediately || (checkFrame > e->FrameNumber && (e->CmdBuffer == nullptr || e->FenceCounter < e->CmdBuffer->GetFenceSignaledCounter())))
|
||||||
{
|
{
|
||||||
if (e->AllocationHandle == VK_NULL_HANDLE)
|
if (e->AllocationHandle == VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
@@ -2077,7 +2067,6 @@ GPUConstantBuffer* GPUDeviceVulkan::CreateConstantBuffer(uint32 size, const Stri
|
|||||||
SemaphoreVulkan::SemaphoreVulkan(GPUDeviceVulkan* device)
|
SemaphoreVulkan::SemaphoreVulkan(GPUDeviceVulkan* device)
|
||||||
: _device(device)
|
: _device(device)
|
||||||
{
|
{
|
||||||
// Create semaphore
|
|
||||||
VkSemaphoreCreateInfo info;
|
VkSemaphoreCreateInfo info;
|
||||||
RenderToolsVulkan::ZeroStruct(info, VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO);
|
RenderToolsVulkan::ZeroStruct(info, VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO);
|
||||||
VALIDATE_VULKAN_RESULT(vkCreateSemaphore(device->Device, &info, nullptr, &_semaphoreHandle));
|
VALIDATE_VULKAN_RESULT(vkCreateSemaphore(device->Device, &info, nullptr, &_semaphoreHandle));
|
||||||
@@ -2090,21 +2079,6 @@ SemaphoreVulkan::~SemaphoreVulkan()
|
|||||||
_semaphoreHandle = VK_NULL_HANDLE;
|
_semaphoreHandle = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FenceVulkan::~FenceVulkan()
|
|
||||||
{
|
|
||||||
ASSERT(_handle == VK_NULL_HANDLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
FenceVulkan::FenceVulkan(GPUDeviceVulkan* device, FenceManagerVulkan* owner, bool createSignaled)
|
|
||||||
: _signaled(createSignaled)
|
|
||||||
, _owner(owner)
|
|
||||||
{
|
|
||||||
VkFenceCreateInfo info;
|
|
||||||
RenderToolsVulkan::ZeroStruct(info, VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
|
|
||||||
info.flags = createSignaled ? VK_FENCE_CREATE_SIGNALED_BIT : 0;
|
|
||||||
VALIDATE_VULKAN_RESULT(vkCreateFence(device->Device, &info, nullptr, &_handle));
|
|
||||||
}
|
|
||||||
|
|
||||||
FenceManagerVulkan::~FenceManagerVulkan()
|
FenceManagerVulkan::~FenceManagerVulkan()
|
||||||
{
|
{
|
||||||
ASSERT(_usedFences.IsEmpty());
|
ASSERT(_usedFences.IsEmpty());
|
||||||
@@ -2113,68 +2087,63 @@ FenceManagerVulkan::~FenceManagerVulkan()
|
|||||||
void FenceManagerVulkan::Dispose()
|
void FenceManagerVulkan::Dispose()
|
||||||
{
|
{
|
||||||
ScopeLock lock(_device->_fenceLock);
|
ScopeLock lock(_device->_fenceLock);
|
||||||
|
|
||||||
ASSERT(_usedFences.IsEmpty());
|
ASSERT(_usedFences.IsEmpty());
|
||||||
for (FenceVulkan* fence : _freeFences)
|
for (FenceVulkan* fence : _freeFences)
|
||||||
{
|
|
||||||
DestroyFence(fence);
|
DestroyFence(fence);
|
||||||
}
|
|
||||||
_freeFences.Clear();
|
_freeFences.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
FenceVulkan* FenceManagerVulkan::AllocateFence(bool createSignaled)
|
FenceVulkan* FenceManagerVulkan::AllocateFence(bool createSignaled)
|
||||||
{
|
{
|
||||||
ScopeLock lock(_device->_fenceLock);
|
ScopeLock lock(_device->_fenceLock);
|
||||||
|
|
||||||
FenceVulkan* fence;
|
FenceVulkan* fence;
|
||||||
if (_freeFences.HasItems())
|
if (_freeFences.HasItems())
|
||||||
{
|
{
|
||||||
fence = _freeFences.Last();
|
fence = _freeFences.Last();
|
||||||
_freeFences.RemoveLast();
|
_freeFences.RemoveLast();
|
||||||
_usedFences.Add(fence);
|
_usedFences.Add(fence);
|
||||||
|
|
||||||
if (createSignaled)
|
if (createSignaled)
|
||||||
{
|
fence->IsSignaled = true;
|
||||||
fence->_signaled = true;
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
return fence;
|
fence = New<FenceVulkan>();
|
||||||
|
fence->IsSignaled = createSignaled;
|
||||||
|
VkFenceCreateInfo info;
|
||||||
|
RenderToolsVulkan::ZeroStruct(info, VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
|
||||||
|
info.flags = createSignaled ? VK_FENCE_CREATE_SIGNALED_BIT : 0;
|
||||||
|
VALIDATE_VULKAN_RESULT(vkCreateFence(_device->Device, &info, nullptr, &fence->Handle));
|
||||||
|
_usedFences.Add(fence);
|
||||||
}
|
}
|
||||||
|
|
||||||
fence = New<FenceVulkan>(_device, this, createSignaled);
|
|
||||||
_usedFences.Add(fence);
|
|
||||||
return fence;
|
return fence;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FenceManagerVulkan::WaitForFence(FenceVulkan* fence, uint64 timeInNanoseconds)
|
bool FenceManagerVulkan::WaitForFence(FenceVulkan* fence, uint64 timeInNanoseconds) const
|
||||||
{
|
{
|
||||||
ASSERT(_usedFences.Contains(fence));
|
ASSERT(_usedFences.Contains(fence));
|
||||||
ASSERT(!fence->_signaled);
|
ASSERT(!fence->IsSignaled);
|
||||||
|
const VkResult result = vkWaitForFences(_device->Device, 1, &fence->Handle, true, timeInNanoseconds);
|
||||||
const VkResult result = vkWaitForFences(_device->Device, 1, &fence->_handle, true, timeInNanoseconds);
|
|
||||||
LOG_VULKAN_RESULT(result);
|
LOG_VULKAN_RESULT(result);
|
||||||
if (result == VK_SUCCESS)
|
if (result == VK_SUCCESS)
|
||||||
{
|
{
|
||||||
fence->_signaled = true;
|
fence->IsSignaled = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FenceManagerVulkan::ResetFence(FenceVulkan* fence)
|
void FenceManagerVulkan::ResetFence(FenceVulkan* fence) const
|
||||||
{
|
{
|
||||||
if (fence->_signaled)
|
if (fence->IsSignaled)
|
||||||
{
|
{
|
||||||
VALIDATE_VULKAN_RESULT(vkResetFences(_device->Device, 1, &fence->_handle));
|
VALIDATE_VULKAN_RESULT(vkResetFences(_device->Device, 1, &fence->Handle));
|
||||||
fence->_signaled = false;
|
fence->IsSignaled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FenceManagerVulkan::ReleaseFence(FenceVulkan*& fence)
|
void FenceManagerVulkan::ReleaseFence(FenceVulkan*& fence)
|
||||||
{
|
{
|
||||||
ScopeLock lock(_device->_fenceLock);
|
ScopeLock lock(_device->_fenceLock);
|
||||||
|
|
||||||
ResetFence(fence);
|
ResetFence(fence);
|
||||||
_usedFences.Remove(fence);
|
_usedFences.Remove(fence);
|
||||||
_freeFences.Add(fence);
|
_freeFences.Add(fence);
|
||||||
@@ -2184,37 +2153,31 @@ void FenceManagerVulkan::ReleaseFence(FenceVulkan*& fence)
|
|||||||
void FenceManagerVulkan::WaitAndReleaseFence(FenceVulkan*& fence, uint64 timeInNanoseconds)
|
void FenceManagerVulkan::WaitAndReleaseFence(FenceVulkan*& fence, uint64 timeInNanoseconds)
|
||||||
{
|
{
|
||||||
ScopeLock lock(_device->_fenceLock);
|
ScopeLock lock(_device->_fenceLock);
|
||||||
|
if (!fence->IsSignaled)
|
||||||
if (!fence->IsSignaled())
|
|
||||||
{
|
|
||||||
WaitForFence(fence, timeInNanoseconds);
|
WaitForFence(fence, timeInNanoseconds);
|
||||||
}
|
|
||||||
|
|
||||||
ResetFence(fence);
|
ResetFence(fence);
|
||||||
_usedFences.Remove(fence);
|
_usedFences.Remove(fence);
|
||||||
_freeFences.Add(fence);
|
_freeFences.Add(fence);
|
||||||
fence = nullptr;
|
fence = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FenceManagerVulkan::CheckFenceState(FenceVulkan* fence)
|
bool FenceManagerVulkan::CheckFenceState(FenceVulkan* fence) const
|
||||||
{
|
{
|
||||||
ASSERT(_usedFences.Contains(fence));
|
ASSERT(_usedFences.Contains(fence));
|
||||||
ASSERT(!fence->_signaled);
|
ASSERT(!fence->IsSignaled);
|
||||||
|
const VkResult result = vkGetFenceStatus(_device->Device, fence->Handle);
|
||||||
const VkResult result = vkGetFenceStatus(_device->Device, fence->GetHandle());
|
|
||||||
if (result == VK_SUCCESS)
|
if (result == VK_SUCCESS)
|
||||||
{
|
{
|
||||||
fence->_signaled = true;
|
fence->IsSignaled = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FenceManagerVulkan::DestroyFence(FenceVulkan* fence)
|
void FenceManagerVulkan::DestroyFence(FenceVulkan* fence) const
|
||||||
{
|
{
|
||||||
vkDestroyFence(_device->Device, fence->GetHandle(), nullptr);
|
vkDestroyFence(_device->Device, fence->Handle, nullptr);
|
||||||
fence->_handle = VK_NULL_HANDLE;
|
fence->Handle = VK_NULL_HANDLE;
|
||||||
Delete(fence);
|
Delete(fence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ class GPUAdapterVulkan;
|
|||||||
class GPUSwapChainVulkan;
|
class GPUSwapChainVulkan;
|
||||||
class CmdBufferVulkan;
|
class CmdBufferVulkan;
|
||||||
class QueueVulkan;
|
class QueueVulkan;
|
||||||
class FenceVulkan;
|
|
||||||
class GPUTextureVulkan;
|
class GPUTextureVulkan;
|
||||||
class GPUBufferVulkan;
|
class GPUBufferVulkan;
|
||||||
class GPUTimerQueryVulkan;
|
class GPUTimerQueryVulkan;
|
||||||
@@ -31,12 +30,10 @@ class DescriptorPoolsManagerVulkan;
|
|||||||
class SemaphoreVulkan
|
class SemaphoreVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
VkSemaphore _semaphoreHandle;
|
VkSemaphore _semaphoreHandle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SemaphoreVulkan"/> class.
|
/// Initializes a new instance of the <see cref="SemaphoreVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -58,59 +55,23 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FenceVulkan
|
struct FenceVulkan
|
||||||
{
|
{
|
||||||
friend FenceManagerVulkan;
|
VkFence Handle;
|
||||||
|
bool IsSignaled;
|
||||||
private:
|
|
||||||
VkFence _handle;
|
|
||||||
bool _signaled;
|
|
||||||
FenceManagerVulkan* _owner;
|
|
||||||
|
|
||||||
public:
|
|
||||||
FenceVulkan(GPUDeviceVulkan* device, FenceManagerVulkan* owner, bool createSignaled);
|
|
||||||
~FenceVulkan();
|
|
||||||
|
|
||||||
public:
|
|
||||||
inline VkFence GetHandle() const
|
|
||||||
{
|
|
||||||
return _handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsSignaled() const
|
|
||||||
{
|
|
||||||
return _signaled;
|
|
||||||
}
|
|
||||||
|
|
||||||
FenceManagerVulkan* GetOwner() const
|
|
||||||
{
|
|
||||||
return _owner;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FenceManagerVulkan
|
class FenceManagerVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
GPUDeviceVulkan* _device = nullptr;
|
||||||
GPUDeviceVulkan* _device;
|
|
||||||
Array<FenceVulkan*> _freeFences;
|
Array<FenceVulkan*> _freeFences;
|
||||||
Array<FenceVulkan*> _usedFences;
|
Array<FenceVulkan*> _usedFences;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FenceManagerVulkan()
|
|
||||||
: _device(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~FenceManagerVulkan();
|
~FenceManagerVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes the specified device.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="device">The graphics device.</param>
|
|
||||||
void Init(GPUDeviceVulkan* device)
|
void Init(GPUDeviceVulkan* device)
|
||||||
{
|
{
|
||||||
_device = device;
|
_device = device;
|
||||||
@@ -120,20 +81,15 @@ public:
|
|||||||
|
|
||||||
FenceVulkan* AllocateFence(bool createSignaled = false);
|
FenceVulkan* AllocateFence(bool createSignaled = false);
|
||||||
|
|
||||||
inline bool IsFenceSignaled(FenceVulkan* fence)
|
FORCE_INLINE bool IsFenceSignaled(FenceVulkan* fence) const
|
||||||
{
|
{
|
||||||
if (fence->IsSignaled())
|
return fence->IsSignaled || CheckFenceState(fence);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CheckFenceState(fence);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if waiting timed out or failed, false otherwise.
|
// Returns true if waiting timed out or failed, false otherwise.
|
||||||
bool WaitForFence(FenceVulkan* fence, uint64 timeInNanoseconds);
|
bool WaitForFence(FenceVulkan* fence, uint64 timeInNanoseconds) const;
|
||||||
|
|
||||||
void ResetFence(FenceVulkan* fence);
|
void ResetFence(FenceVulkan* fence) const;
|
||||||
|
|
||||||
// Sets the fence handle to null
|
// Sets the fence handle to null
|
||||||
void ReleaseFence(FenceVulkan*& fence);
|
void ReleaseFence(FenceVulkan*& fence);
|
||||||
@@ -142,17 +98,15 @@ public:
|
|||||||
void WaitAndReleaseFence(FenceVulkan*& fence, uint64 timeInNanoseconds);
|
void WaitAndReleaseFence(FenceVulkan*& fence, uint64 timeInNanoseconds);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Returns true if fence was signaled, otherwise false.
|
// Returns true if fence was signaled, otherwise false.
|
||||||
bool CheckFenceState(FenceVulkan* fence);
|
bool CheckFenceState(FenceVulkan* fence) const;
|
||||||
|
|
||||||
void DestroyFence(FenceVulkan* fence);
|
void DestroyFence(FenceVulkan* fence) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DeferredDeletionQueueVulkan
|
class DeferredDeletionQueueVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum Type
|
enum Type
|
||||||
{
|
{
|
||||||
RenderPass,
|
RenderPass,
|
||||||
@@ -172,7 +126,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct Entry
|
struct Entry
|
||||||
{
|
{
|
||||||
uint64 FenceCounter;
|
uint64 FenceCounter;
|
||||||
@@ -188,7 +141,6 @@ private:
|
|||||||
Array<Entry> _entries;
|
Array<Entry> _entries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="DeferredDeletionQueueVulkan"/> class.
|
/// Initializes a new instance of the <see cref="DeferredDeletionQueueVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -201,7 +153,6 @@ public:
|
|||||||
~DeferredDeletionQueueVulkan();
|
~DeferredDeletionQueueVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void EnqueueResource(Type type, T handle)
|
inline void EnqueueResource(Type type, T handle)
|
||||||
{
|
{
|
||||||
@@ -216,17 +167,15 @@ public:
|
|||||||
EnqueueGenericResource(type, (uint64)handle, allocation);
|
EnqueueGenericResource(type, (uint64)handle, allocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReleaseResources(bool deleteImmediately = false);
|
void ReleaseResources(bool immediately = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void EnqueueGenericResource(Type type, uint64 handle, VmaAllocation allocation);
|
void EnqueueGenericResource(Type type, uint64 handle, VmaAllocation allocation);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderTargetLayoutVulkan
|
class RenderTargetLayoutVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int32 RTsCount;
|
int32 RTsCount;
|
||||||
MSAALevel MSAA;
|
MSAALevel MSAA;
|
||||||
bool ReadDepth;
|
bool ReadDepth;
|
||||||
@@ -238,7 +187,6 @@ public:
|
|||||||
uint32 Layers;
|
uint32 Layers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool operator==(const RenderTargetLayoutVulkan& other) const
|
bool operator==(const RenderTargetLayoutVulkan& other) const
|
||||||
{
|
{
|
||||||
return Platform::MemoryCompare(this, &other, sizeof(RenderTargetLayoutVulkan)) == 0;
|
return Platform::MemoryCompare(this, &other, sizeof(RenderTargetLayoutVulkan)) == 0;
|
||||||
@@ -250,7 +198,6 @@ uint32 GetHash(const RenderTargetLayoutVulkan& key);
|
|||||||
class FramebufferVulkan
|
class FramebufferVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct Key
|
struct Key
|
||||||
{
|
{
|
||||||
RenderPassVulkan* RenderPass;
|
RenderPassVulkan* RenderPass;
|
||||||
@@ -258,7 +205,6 @@ public:
|
|||||||
VkImageView Attachments[GPU_MAX_RT_BINDED + 1];
|
VkImageView Attachments[GPU_MAX_RT_BINDED + 1];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool operator==(const Key& other) const
|
bool operator==(const Key& other) const
|
||||||
{
|
{
|
||||||
return Platform::MemoryCompare(this, &other, sizeof(Key)) == 0;
|
return Platform::MemoryCompare(this, &other, sizeof(Key)) == 0;
|
||||||
@@ -266,23 +212,19 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
VkFramebuffer _handle;
|
VkFramebuffer _handle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FramebufferVulkan(GPUDeviceVulkan* device, Key& key, VkExtent2D& extent, uint32 layers);
|
FramebufferVulkan(GPUDeviceVulkan* device, Key& key, VkExtent2D& extent, uint32 layers);
|
||||||
~FramebufferVulkan();
|
~FramebufferVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VkImageView Attachments[GPU_MAX_RT_BINDED + 1];
|
VkImageView Attachments[GPU_MAX_RT_BINDED + 1];
|
||||||
VkExtent2D Extent;
|
VkExtent2D Extent;
|
||||||
uint32 Layers;
|
uint32 Layers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline VkFramebuffer GetHandle()
|
inline VkFramebuffer GetHandle()
|
||||||
{
|
{
|
||||||
return _handle;
|
return _handle;
|
||||||
@@ -296,21 +238,17 @@ uint32 GetHash(const FramebufferVulkan::Key& key);
|
|||||||
class RenderPassVulkan
|
class RenderPassVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
VkRenderPass _handle;
|
VkRenderPass _handle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RenderTargetLayoutVulkan Layout;
|
RenderTargetLayoutVulkan Layout;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RenderPassVulkan(GPUDeviceVulkan* device, const RenderTargetLayoutVulkan& layout);
|
RenderPassVulkan(GPUDeviceVulkan* device, const RenderTargetLayoutVulkan& layout);
|
||||||
~RenderPassVulkan();
|
~RenderPassVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline VkRenderPass GetHandle() const
|
inline VkRenderPass GetHandle() const
|
||||||
{
|
{
|
||||||
return _handle;
|
return _handle;
|
||||||
@@ -320,7 +258,6 @@ public:
|
|||||||
class QueryPoolVulkan
|
class QueryPoolVulkan
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
struct Range
|
struct Range
|
||||||
{
|
{
|
||||||
uint32 Start;
|
uint32 Start;
|
||||||
@@ -338,12 +275,10 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QueryPoolVulkan(GPUDeviceVulkan* device, int32 capacity, VkQueryType type);
|
QueryPoolVulkan(GPUDeviceVulkan* device, int32 capacity, VkQueryType type);
|
||||||
~QueryPoolVulkan();
|
~QueryPoolVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline VkQueryPool GetHandle() const
|
inline VkQueryPool GetHandle() const
|
||||||
{
|
{
|
||||||
return _handle;
|
return _handle;
|
||||||
@@ -357,7 +292,6 @@ public:
|
|||||||
class BufferedQueryPoolVulkan : public QueryPoolVulkan
|
class BufferedQueryPoolVulkan : public QueryPoolVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Array<uint64> _queryOutput;
|
Array<uint64> _queryOutput;
|
||||||
Array<uint64> _usedQueryBits;
|
Array<uint64> _usedQueryBits;
|
||||||
Array<uint64> _startedQueryBits;
|
Array<uint64> _startedQueryBits;
|
||||||
@@ -367,7 +301,6 @@ private:
|
|||||||
int32 _lastBeginIndex;
|
int32 _lastBeginIndex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
BufferedQueryPoolVulkan(GPUDeviceVulkan* device, int32 capacity, VkQueryType type);
|
BufferedQueryPoolVulkan(GPUDeviceVulkan* device, int32 capacity, VkQueryType type);
|
||||||
bool AcquireQuery(uint32& resultIndex);
|
bool AcquireQuery(uint32& resultIndex);
|
||||||
void ReleaseQuery(uint32 queryIndex);
|
void ReleaseQuery(uint32 queryIndex);
|
||||||
@@ -382,7 +315,6 @@ public:
|
|||||||
class HelperResourcesVulkan
|
class HelperResourcesVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
GPUTextureVulkan* _dummyTextures[6];
|
GPUTextureVulkan* _dummyTextures[6];
|
||||||
GPUBufferVulkan* _dummyBuffer;
|
GPUBufferVulkan* _dummyBuffer;
|
||||||
@@ -390,11 +322,9 @@ private:
|
|||||||
VkSampler _staticSamplers[GPU_STATIC_SAMPLERS_COUNT];
|
VkSampler _staticSamplers[GPU_STATIC_SAMPLERS_COUNT];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
HelperResourcesVulkan(GPUDeviceVulkan* device);
|
HelperResourcesVulkan(GPUDeviceVulkan* device);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VkSampler* GetStaticSamplers();
|
VkSampler* GetStaticSamplers();
|
||||||
GPUTextureVulkan* GetDummyTexture(SpirvShaderResourceType type);
|
GPUTextureVulkan* GetDummyTexture(SpirvShaderResourceType type);
|
||||||
GPUBufferVulkan* GetDummyBuffer();
|
GPUBufferVulkan* GetDummyBuffer();
|
||||||
@@ -408,7 +338,6 @@ public:
|
|||||||
class StagingManagerVulkan
|
class StagingManagerVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct PendingEntry
|
struct PendingEntry
|
||||||
{
|
{
|
||||||
GPUBuffer* Buffer;
|
GPUBuffer* Buffer;
|
||||||
@@ -435,7 +364,6 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
StagingManagerVulkan(GPUDeviceVulkan* device);
|
StagingManagerVulkan(GPUDeviceVulkan* device);
|
||||||
GPUBuffer* AcquireBuffer(uint32 size, GPUResourceUsage usage);
|
GPUBuffer* AcquireBuffer(uint32 size, GPUResourceUsage usage);
|
||||||
void ReleaseBuffer(CmdBufferVulkan* cmdBuffer, GPUBuffer*& buffer);
|
void ReleaseBuffer(CmdBufferVulkan* cmdBuffer, GPUBuffer*& buffer);
|
||||||
@@ -453,7 +381,6 @@ class GPUDeviceVulkan : public GPUDevice
|
|||||||
friend FenceManagerVulkan;
|
friend FenceManagerVulkan;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
CriticalSection _fenceLock;
|
CriticalSection _fenceLock;
|
||||||
mutable void* _nativePtr[2];
|
mutable void* _nativePtr[2];
|
||||||
|
|
||||||
@@ -463,7 +390,6 @@ private:
|
|||||||
// TODO: use mutex to protect those collections BUT use 2 pools per cache: one lock-free with lookup only and second protected with mutex synced on frame end!
|
// TODO: use mutex to protect those collections BUT use 2 pools per cache: one lock-free with lookup only and second protected with mutex synced on frame end!
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static GPUDevice* Create();
|
static GPUDevice* Create();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -479,7 +405,6 @@ public:
|
|||||||
~GPUDeviceVulkan();
|
~GPUDeviceVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct OptionalVulkanDeviceExtensions
|
struct OptionalVulkanDeviceExtensions
|
||||||
{
|
{
|
||||||
uint32 HasKHRMaintenance1 : 1;
|
uint32 HasKHRMaintenance1 : 1;
|
||||||
@@ -497,7 +422,6 @@ public:
|
|||||||
static OptionalVulkanDeviceExtensions OptionalDeviceExtensions;
|
static OptionalVulkanDeviceExtensions OptionalDeviceExtensions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Vulkan instance.
|
/// The Vulkan instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -514,7 +438,6 @@ public:
|
|||||||
static Array<const char*> InstanceLayers;
|
static Array<const char*> InstanceLayers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main Vulkan commands context.
|
/// The main Vulkan commands context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -652,7 +575,6 @@ public:
|
|||||||
void OnImageViewDestroy(VkImageView imageView);
|
void OnImageViewDestroy(VkImageView imageView);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Setups the present queue to be ready for the given window surface.
|
/// Setups the present queue to be ready for the given window surface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -667,7 +589,7 @@ public:
|
|||||||
/// <param name="optimalTiling">If set to <c>true</c> the optimal tiling should be used, otherwise use linear tiling.</param>
|
/// <param name="optimalTiling">If set to <c>true</c> the optimal tiling should be used, otherwise use linear tiling.</param>
|
||||||
/// <returns>The output format.</returns>
|
/// <returns>The output format.</returns>
|
||||||
PixelFormat GetClosestSupportedPixelFormat(PixelFormat format, GPUTextureFlags flags, bool optimalTiling);
|
PixelFormat GetClosestSupportedPixelFormat(PixelFormat format, GPUTextureFlags flags, bool optimalTiling);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves the pipeline cache.
|
/// Saves the pipeline cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -683,11 +605,9 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool IsVkFormatSupported(VkFormat vkFormat, VkFormatFeatureFlags wantedFeatureFlags, bool optimalTiling) const;
|
bool IsVkFormatSupported(VkFormat vkFormat, VkFormatFeatureFlags wantedFeatureFlags, bool optimalTiling) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUDevice]
|
// [GPUDevice]
|
||||||
GPUContext* GetMainContext() override;
|
GPUContext* GetMainContext() override;
|
||||||
GPUAdapter* GetAdapter() const override;
|
GPUAdapter* GetAdapter() const override;
|
||||||
@@ -713,7 +633,6 @@ template<class BaseType>
|
|||||||
class GPUResourceVulkan : public GPUResourceBase<GPUDeviceVulkan, BaseType>
|
class GPUResourceVulkan : public GPUResourceBase<GPUDeviceVulkan, BaseType>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUResourceVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUResourceVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -731,7 +650,6 @@ public:
|
|||||||
class DescriptorOwnerResourceVulkan
|
class DescriptorOwnerResourceVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finalizes an instance of the <see cref="DescriptorOwnerResourceVulkan"/> class.
|
/// Finalizes an instance of the <see cref="DescriptorOwnerResourceVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -740,7 +658,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the sampler descriptor.
|
/// Gets the sampler descriptor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ ComputePipelineStateVulkan* GPUShaderProgramCSVulkan::GetOrCreateState()
|
|||||||
_pipelineState = New<ComputePipelineStateVulkan>(_device, pipeline, layout);
|
_pipelineState = New<ComputePipelineStateVulkan>(_device, pipeline, layout);
|
||||||
_pipelineState->DescriptorInfo = &DescriptorInfo;
|
_pipelineState->DescriptorInfo = &DescriptorInfo;
|
||||||
_pipelineState->DescriptorSetsLayout = &layout->GetDescriptorSetLayout();
|
_pipelineState->DescriptorSetsLayout = &layout->GetDescriptorSetLayout();
|
||||||
_pipelineState->DescriptorSetHandles.AddZeroed(_pipelineState->DescriptorSetsLayout->GetHandles().Count());
|
_pipelineState->DescriptorSetHandles.AddZeroed(_pipelineState->DescriptorSetsLayout->Handles.Count());
|
||||||
uint32 dynamicOffsetsCount = 0;
|
uint32 dynamicOffsetsCount = 0;
|
||||||
if (DescriptorInfo.DescriptorTypesCount != 0)
|
if (DescriptorInfo.DescriptorTypesCount != 0)
|
||||||
{
|
{
|
||||||
@@ -136,9 +136,7 @@ PipelineLayoutVulkan* GPUPipelineStateVulkan::GetLayout()
|
|||||||
|
|
||||||
#define INIT_SHADER_STAGE(set, bit) \
|
#define INIT_SHADER_STAGE(set, bit) \
|
||||||
if (DescriptorInfoPerStage[DescriptorSet::set]) \
|
if (DescriptorInfoPerStage[DescriptorSet::set]) \
|
||||||
{ \
|
descriptorSetLayoutInfo.AddBindingsForStage(bit, DescriptorSet::set, DescriptorInfoPerStage[DescriptorSet::set])
|
||||||
descriptorSetLayoutInfo.AddBindingsForStage(bit, DescriptorSet::set, DescriptorInfoPerStage[DescriptorSet::set]); \
|
|
||||||
}
|
|
||||||
INIT_SHADER_STAGE(Vertex, VK_SHADER_STAGE_VERTEX_BIT);
|
INIT_SHADER_STAGE(Vertex, VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
INIT_SHADER_STAGE(Hull, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
|
INIT_SHADER_STAGE(Hull, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
|
||||||
INIT_SHADER_STAGE(Domain, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
|
INIT_SHADER_STAGE(Domain, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT);
|
||||||
@@ -149,7 +147,7 @@ PipelineLayoutVulkan* GPUPipelineStateVulkan::GetLayout()
|
|||||||
_layout = _device->GetOrCreateLayout(descriptorSetLayoutInfo);
|
_layout = _device->GetOrCreateLayout(descriptorSetLayoutInfo);
|
||||||
ASSERT(_layout);
|
ASSERT(_layout);
|
||||||
DescriptorSetsLayout = &_layout->GetDescriptorSetLayout();
|
DescriptorSetsLayout = &_layout->GetDescriptorSetLayout();
|
||||||
DescriptorSetHandles.AddZeroed(DescriptorSetsLayout->GetHandles().Count());
|
DescriptorSetHandles.AddZeroed(DescriptorSetsLayout->Handles.Count());
|
||||||
|
|
||||||
return _layout;
|
return _layout;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,28 +14,15 @@ class PipelineLayoutVulkan;
|
|||||||
class ComputePipelineStateVulkan
|
class ComputePipelineStateVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
VkPipeline _handle;
|
VkPipeline _handle;
|
||||||
PipelineLayoutVulkan* _layout;
|
PipelineLayoutVulkan* _layout;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ComputePipelineStateVulkan"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="device">The graphics device.</param>
|
|
||||||
/// <param name="pipeline">The pipeline object.</param>
|
|
||||||
/// <param name="layout">The pipeline layout.</param>
|
|
||||||
ComputePipelineStateVulkan(GPUDeviceVulkan* device, VkPipeline pipeline, PipelineLayoutVulkan* layout);
|
ComputePipelineStateVulkan(GPUDeviceVulkan* device, VkPipeline pipeline, PipelineLayoutVulkan* layout);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Finalizes an instance of the <see cref="GPUPipelineStateVulkan"/> class.
|
|
||||||
/// </summary>
|
|
||||||
~ComputePipelineStateVulkan();
|
~ComputePipelineStateVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The cached shader descriptor infos for compute shader.
|
/// The cached shader descriptor infos for compute shader.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -71,7 +58,6 @@ public:
|
|||||||
Array<uint32> DynamicOffsets;
|
Array<uint32> DynamicOffsets;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Bind(CmdBufferVulkan* cmdBuffer)
|
void Bind(CmdBufferVulkan* cmdBuffer)
|
||||||
{
|
{
|
||||||
vkCmdBindDescriptorSets(
|
vkCmdBindDescriptorSets(
|
||||||
@@ -86,7 +72,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VkPipeline GetHandle() const
|
VkPipeline GetHandle() const
|
||||||
{
|
{
|
||||||
return _handle;
|
return _handle;
|
||||||
@@ -104,7 +89,6 @@ public:
|
|||||||
class GPUPipelineStateVulkan : public GPUResourceVulkan<GPUPipelineState>
|
class GPUPipelineStateVulkan : public GPUResourceVulkan<GPUPipelineState>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Dictionary<RenderPassVulkan*, VkPipeline> _pipelines;
|
Dictionary<RenderPassVulkan*, VkPipeline> _pipelines;
|
||||||
VkGraphicsPipelineCreateInfo _desc;
|
VkGraphicsPipelineCreateInfo _desc;
|
||||||
VkPipelineShaderStageCreateInfo _shaderStages[ShaderStage_Count - 1];
|
VkPipelineShaderStageCreateInfo _shaderStages[ShaderStage_Count - 1];
|
||||||
@@ -121,7 +105,6 @@ private:
|
|||||||
PipelineLayoutVulkan* _layout;
|
PipelineLayoutVulkan* _layout;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUPipelineStateVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUPipelineStateVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -129,7 +112,6 @@ public:
|
|||||||
GPUPipelineStateVulkan(GPUDeviceVulkan* device);
|
GPUPipelineStateVulkan(GPUDeviceVulkan* device);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The bitmask of stages that exist in this pipeline.
|
/// The bitmask of stages that exist in this pipeline.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -187,7 +169,6 @@ public:
|
|||||||
Array<uint32> DynamicOffsets;
|
Array<uint32> DynamicOffsets;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Bind(CmdBufferVulkan* cmdBuffer)
|
void Bind(CmdBufferVulkan* cmdBuffer)
|
||||||
{
|
{
|
||||||
vkCmdBindDescriptorSets(
|
vkCmdBindDescriptorSets(
|
||||||
@@ -215,13 +196,11 @@ public:
|
|||||||
VkPipeline GetState(RenderPassVulkan* renderPass);
|
VkPipeline GetState(RenderPassVulkan* renderPass);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUPipelineState]
|
// [GPUPipelineState]
|
||||||
bool IsValid() const final override;
|
bool IsValid() const final override;
|
||||||
bool Init(const Description& desc) final override;
|
bool Init(const Description& desc) final override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// [GPUResourceVulkan]
|
// [GPUResourceVulkan]
|
||||||
void OnReleaseGPU() override;
|
void OnReleaseGPU() override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
class GPUSamplerVulkan : public GPUResourceVulkan<GPUSampler>
|
class GPUSamplerVulkan : public GPUResourceVulkan<GPUSampler>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GPUSamplerVulkan(GPUDeviceVulkan* device)
|
GPUSamplerVulkan(GPUDeviceVulkan* device)
|
||||||
: GPUResourceVulkan<GPUSampler>(device, StringView::Empty)
|
: GPUResourceVulkan<GPUSampler>(device, StringView::Empty)
|
||||||
{
|
{
|
||||||
@@ -22,7 +21,6 @@ public:
|
|||||||
VkSampler Sampler = VK_NULL_HANDLE;
|
VkSampler Sampler = VK_NULL_HANDLE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// [GPUSamplerVulkan]
|
// [GPUSamplerVulkan]
|
||||||
bool OnInit() override;
|
bool OnInit() override;
|
||||||
void OnReleaseGPU() override;
|
void OnReleaseGPU() override;
|
||||||
|
|||||||
@@ -18,11 +18,9 @@ template<typename BaseType>
|
|||||||
class GPUShaderProgramVulkan : public BaseType
|
class GPUShaderProgramVulkan : public BaseType
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
GPUDeviceVulkan* _device;
|
GPUDeviceVulkan* _device;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUShaderProgramVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUShaderProgramVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -50,7 +48,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Vulkan shader module.
|
/// The Vulkan shader module.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -62,7 +59,6 @@ public:
|
|||||||
SpirvShaderDescriptorInfo DescriptorInfo;
|
SpirvShaderDescriptorInfo DescriptorInfo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [BaseType]
|
// [BaseType]
|
||||||
uint32 GetBufferSize() const override
|
uint32 GetBufferSize() const override
|
||||||
{
|
{
|
||||||
@@ -81,7 +77,6 @@ public:
|
|||||||
class GPUShaderProgramVSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramVS>
|
class GPUShaderProgramVSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramVS>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUShaderProgramVSVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUShaderProgramVSVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -95,13 +90,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VkPipelineVertexInputStateCreateInfo VertexInputState;
|
VkPipelineVertexInputStateCreateInfo VertexInputState;
|
||||||
VkVertexInputBindingDescription VertexBindingDescriptions[VERTEX_SHADER_MAX_INPUT_ELEMENTS];
|
VkVertexInputBindingDescription VertexBindingDescriptions[VERTEX_SHADER_MAX_INPUT_ELEMENTS];
|
||||||
VkVertexInputAttributeDescription VertexAttributeDescriptions[VERTEX_SHADER_MAX_INPUT_ELEMENTS];
|
VkVertexInputAttributeDescription VertexAttributeDescriptions[VERTEX_SHADER_MAX_INPUT_ELEMENTS];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUShaderProgramVulkan]
|
// [GPUShaderProgramVulkan]
|
||||||
void* GetInputLayout() const override
|
void* GetInputLayout() const override
|
||||||
{
|
{
|
||||||
@@ -120,7 +113,6 @@ public:
|
|||||||
class GPUShaderProgramHSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramHS>
|
class GPUShaderProgramHSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramHS>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUShaderProgramHSVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUShaderProgramHSVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -142,7 +134,6 @@ public:
|
|||||||
class GPUShaderProgramDSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramDS>
|
class GPUShaderProgramDSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramDS>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUShaderProgramDSVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUShaderProgramDSVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -162,7 +153,6 @@ public:
|
|||||||
class GPUShaderProgramGSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramGS>
|
class GPUShaderProgramGSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramGS>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUShaderProgramGSVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUShaderProgramGSVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -182,7 +172,6 @@ public:
|
|||||||
class GPUShaderProgramPSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramPS>
|
class GPUShaderProgramPSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramPS>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUShaderProgramPSVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUShaderProgramPSVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -202,11 +191,9 @@ public:
|
|||||||
class GPUShaderProgramCSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramCS>
|
class GPUShaderProgramCSVulkan : public GPUShaderProgramVulkan<GPUShaderProgramCS>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ComputePipelineStateVulkan* _pipelineState;
|
ComputePipelineStateVulkan* _pipelineState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUShaderProgramCSVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUShaderProgramCSVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -226,7 +213,6 @@ public:
|
|||||||
~GPUShaderProgramCSVulkan();
|
~GPUShaderProgramCSVulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the state of the pipeline for the compute shader execution or creates a new one if missing.
|
/// Gets the state of the pipeline for the compute shader execution or creates a new one if missing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
class UniformBufferUploaderVulkan : public GPUResourceVulkan<GPUResource>, public ResourceOwnerVulkan
|
class UniformBufferUploaderVulkan : public GPUResourceVulkan<GPUResource>, public ResourceOwnerVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct Allocation
|
struct Allocation
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -42,7 +41,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
VkBuffer _buffer;
|
VkBuffer _buffer;
|
||||||
VmaAllocation _allocation;
|
VmaAllocation _allocation;
|
||||||
uint64 _size;
|
uint64 _size;
|
||||||
@@ -53,7 +51,6 @@ private:
|
|||||||
uint64 _fenceCounter;
|
uint64 _fenceCounter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="UniformBufferUploaderVulkan"/> class.
|
/// Initializes a new instance of the <see cref="UniformBufferUploaderVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -61,11 +58,9 @@ public:
|
|||||||
UniformBufferUploaderVulkan(GPUDeviceVulkan* device);
|
UniformBufferUploaderVulkan(GPUDeviceVulkan* device);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Allocation Allocate(uint64 size, uint32 alignment, GPUContextVulkan* context);
|
Allocation Allocate(uint64 size, uint32 alignment, GPUContextVulkan* context);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUResourceVulkan]
|
// [GPUResourceVulkan]
|
||||||
GPUResourceType GetResourceType() const final override
|
GPUResourceType GetResourceType() const final override
|
||||||
{
|
{
|
||||||
@@ -79,7 +74,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// [GPUResourceVulkan]
|
// [GPUResourceVulkan]
|
||||||
void OnReleaseGPU() override;
|
void OnReleaseGPU() override;
|
||||||
};
|
};
|
||||||
@@ -90,7 +84,6 @@ protected:
|
|||||||
class GPUConstantBufferVulkan : public GPUResourceVulkan<GPUConstantBuffer>, public DescriptorOwnerResourceVulkan
|
class GPUConstantBufferVulkan : public GPUResourceVulkan<GPUConstantBuffer>, public DescriptorOwnerResourceVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUConstantBufferVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUConstantBufferVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -103,14 +96,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The last uploaded data inside the shared uniforms uploading ring buffer.
|
/// The last uploaded data inside the shared uniforms uploading ring buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
UniformBufferUploaderVulkan::Allocation Allocation;
|
UniformBufferUploaderVulkan::Allocation Allocation;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [DescriptorOwnerResourceVulkan]
|
// [DescriptorOwnerResourceVulkan]
|
||||||
void DescriptorAsDynamicUniformBuffer(GPUContextVulkan* context, VkBuffer& buffer, VkDeviceSize& offset, VkDeviceSize& range, uint32& dynamicOffset) override
|
void DescriptorAsDynamicUniformBuffer(GPUContextVulkan* context, VkBuffer& buffer, VkDeviceSize& offset, VkDeviceSize& range, uint32& dynamicOffset) override
|
||||||
{
|
{
|
||||||
@@ -127,7 +118,6 @@ public:
|
|||||||
class GPUShaderVulkan : public GPUResourceVulkan<GPUShader>
|
class GPUShaderVulkan : public GPUResourceVulkan<GPUShader>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUShaderVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUShaderVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -139,7 +129,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// [GPUShader]
|
// [GPUShader]
|
||||||
GPUShaderProgram* CreateGPUShaderProgram(ShaderStage type, const GPUShaderProgramInitializer& initializer, byte* cacheBytes, uint32 cacheSize, MemoryReadStream& stream) override;
|
GPUShaderProgram* CreateGPUShaderProgram(ShaderStage type, const GPUShaderProgramInitializer& initializer, byte* cacheBytes, uint32 cacheSize, MemoryReadStream& stream) override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
class BackBufferVulkan : public ResourceOwnerVulkan
|
class BackBufferVulkan : public ResourceOwnerVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The device.
|
/// The device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -36,12 +35,10 @@ public:
|
|||||||
GPUTextureViewVulkan Handle;
|
GPUTextureViewVulkan Handle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Setup(GPUSwapChainVulkan* window, VkImage backbuffer, PixelFormat format, VkExtent3D extent);
|
void Setup(GPUSwapChainVulkan* window, VkImage backbuffer, PixelFormat format, VkExtent3D extent);
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [ResourceOwnerVulkan]
|
// [ResourceOwnerVulkan]
|
||||||
GPUResource* AsGPUResource() const override
|
GPUResource* AsGPUResource() const override
|
||||||
{
|
{
|
||||||
@@ -58,7 +55,6 @@ class GPUSwapChainVulkan : public GPUResourceVulkan<GPUSwapChain>, public Resour
|
|||||||
friend GPUDeviceVulkan;
|
friend GPUDeviceVulkan;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
VkSurfaceKHR _surface;
|
VkSurfaceKHR _surface;
|
||||||
VkSwapchainKHR _swapChain;
|
VkSwapchainKHR _swapChain;
|
||||||
int32 _currentImageIndex;
|
int32 _currentImageIndex;
|
||||||
@@ -68,11 +64,9 @@ private:
|
|||||||
SemaphoreVulkan* _acquiredSemaphore;
|
SemaphoreVulkan* _acquiredSemaphore;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GPUSwapChainVulkan(GPUDeviceVulkan* device, Window* window);
|
GPUSwapChainVulkan(GPUDeviceVulkan* device, Window* window);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Vulkan surface.
|
/// Gets the Vulkan surface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -92,7 +86,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum class Status
|
enum class Status
|
||||||
{
|
{
|
||||||
Ok = 0,
|
Ok = 0,
|
||||||
@@ -108,12 +101,10 @@ public:
|
|||||||
int32 AcquireNextImage(SemaphoreVulkan** outSemaphore);
|
int32 AcquireNextImage(SemaphoreVulkan** outSemaphore);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void ReleaseBackBuffer();
|
void ReleaseBackBuffer();
|
||||||
bool CreateSwapChain(int32 width, int32 height);
|
bool CreateSwapChain(int32 width, int32 height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUSwapChain]
|
// [GPUSwapChain]
|
||||||
bool IsFullscreen() override;
|
bool IsFullscreen() override;
|
||||||
void SetFullscreen(bool isFullscreen) override;
|
void SetFullscreen(bool isFullscreen) override;
|
||||||
@@ -129,7 +120,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// [GPUResourceVulkan]
|
// [GPUResourceVulkan]
|
||||||
void OnReleaseGPU() override;
|
void OnReleaseGPU() override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
class GPUTextureViewVulkan : public GPUTextureView, public DescriptorOwnerResourceVulkan
|
class GPUTextureViewVulkan : public GPUTextureView, public DescriptorOwnerResourceVulkan
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GPUTextureViewVulkan()
|
GPUTextureViewVulkan()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -44,7 +43,6 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GPUDeviceVulkan* Device = nullptr;
|
GPUDeviceVulkan* Device = nullptr;
|
||||||
ResourceOwnerVulkan* Owner = nullptr;
|
ResourceOwnerVulkan* Owner = nullptr;
|
||||||
VkImage Image = VK_NULL_HANDLE;
|
VkImage Image = VK_NULL_HANDLE;
|
||||||
@@ -58,7 +56,6 @@ public:
|
|||||||
VkImageLayout LayoutSRV;
|
VkImageLayout LayoutSRV;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void Init(GPUDeviceVulkan* device, ResourceOwnerVulkan* owner, VkImage image, int32 totalMipLevels, PixelFormat format, MSAALevel msaa, VkExtent3D extent, VkImageViewType viewType, int32 mipLevels = 1, int32 firstMipIndex = 0, int32 arraySize = 1, int32 firstArraySlice = 0, bool readOnlyDepth = false);
|
void Init(GPUDeviceVulkan* device, ResourceOwnerVulkan* owner, VkImage image, int32 totalMipLevels, PixelFormat format, MSAALevel msaa, VkExtent3D extent, VkImageViewType viewType, int32 mipLevels = 1, int32 firstMipIndex = 0, int32 arraySize = 1, int32 firstArraySlice = 0, bool readOnlyDepth = false);
|
||||||
|
|
||||||
VkImageView GetFramebufferView();
|
VkImageView GetFramebufferView();
|
||||||
@@ -66,7 +63,6 @@ public:
|
|||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUResourceView]
|
// [GPUResourceView]
|
||||||
void* GetNativePtr() const override
|
void* GetNativePtr() const override
|
||||||
{
|
{
|
||||||
@@ -84,7 +80,6 @@ public:
|
|||||||
class GPUTextureVulkan : public GPUResourceVulkan<GPUTexture>, public ResourceOwnerVulkan, public DescriptorOwnerResourceVulkan
|
class GPUTextureVulkan : public GPUResourceVulkan<GPUTexture>, public ResourceOwnerVulkan, public DescriptorOwnerResourceVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
VkImage _image = VK_NULL_HANDLE;
|
VkImage _image = VK_NULL_HANDLE;
|
||||||
VmaAllocation _allocation = VK_NULL_HANDLE;
|
VmaAllocation _allocation = VK_NULL_HANDLE;
|
||||||
GPUTextureViewVulkan _handleArray;
|
GPUTextureViewVulkan _handleArray;
|
||||||
@@ -95,7 +90,6 @@ private:
|
|||||||
Array<Array<GPUTextureViewVulkan>> _handlesPerMip; // [slice][mip]
|
Array<Array<GPUTextureViewVulkan>> _handlesPerMip; // [slice][mip]
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUTextureVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUTextureVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -107,7 +101,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Vulkan image handle.
|
/// Gets the Vulkan image handle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -127,11 +120,9 @@ public:
|
|||||||
VkImageAspectFlags DefaultAspectMask;
|
VkImageAspectFlags DefaultAspectMask;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void initHandles();
|
void initHandles();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUTexture]
|
// [GPUTexture]
|
||||||
GPUTextureView* View(int32 arrayOrDepthIndex) const override
|
GPUTextureView* View(int32 arrayOrDepthIndex) const override
|
||||||
{
|
{
|
||||||
@@ -178,7 +169,6 @@ public:
|
|||||||
void DescriptorAsStorageImage(GPUContextVulkan* context, VkImageView& imageView, VkImageLayout& layout) override;
|
void DescriptorAsStorageImage(GPUContextVulkan* context, VkImageView& imageView, VkImageLayout& layout) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// [GPUTexture]
|
// [GPUTexture]
|
||||||
bool OnInit() override;
|
bool OnInit() override;
|
||||||
void OnResidentMipsChanged() override;
|
void OnResidentMipsChanged() override;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
class GPUTimerQueryVulkan : public GPUResourceVulkan<GPUTimerQuery>
|
class GPUTimerQueryVulkan : public GPUResourceVulkan<GPUTimerQuery>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct Query
|
struct Query
|
||||||
{
|
{
|
||||||
BufferedQueryPoolVulkan* Pool;
|
BufferedQueryPoolVulkan* Pool;
|
||||||
@@ -35,7 +34,6 @@ private:
|
|||||||
Array<QueryPair, InlinedAllocation<8>> _queries;
|
Array<QueryPair, InlinedAllocation<8>> _queries;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GPUTimerQueryVulkan"/> class.
|
/// Initializes a new instance of the <see cref="GPUTimerQueryVulkan"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -43,7 +41,6 @@ public:
|
|||||||
GPUTimerQueryVulkan(GPUDeviceVulkan* device);
|
GPUTimerQueryVulkan(GPUDeviceVulkan* device);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interrupts an in-progress query, allowing the command buffer to submitted. Interrupted queries must be resumed using Resume().
|
/// Interrupts an in-progress query, allowing the command buffer to submitted. Interrupted queries must be resumed using Resume().
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -57,14 +54,12 @@ public:
|
|||||||
void Resume(CmdBufferVulkan* cmdBuffer);
|
void Resume(CmdBufferVulkan* cmdBuffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool GetResult(Query& query);
|
bool GetResult(Query& query);
|
||||||
void WriteTimestamp(CmdBufferVulkan* cmdBuffer, Query& query, VkPipelineStageFlagBits stage) const;
|
void WriteTimestamp(CmdBufferVulkan* cmdBuffer, Query& query, VkPipelineStageFlagBits stage) const;
|
||||||
bool TryGetResult();
|
bool TryGetResult();
|
||||||
bool UseQueries();
|
bool UseQueries();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// [GPUTimerQuery]
|
// [GPUTimerQuery]
|
||||||
void Begin() override;
|
void Begin() override;
|
||||||
void End() override;
|
void End() override;
|
||||||
@@ -72,7 +67,6 @@ public:
|
|||||||
float GetResult() override;
|
float GetResult() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// [GPUResourceVulkan]
|
// [GPUResourceVulkan]
|
||||||
void OnReleaseGPU() override;
|
void OnReleaseGPU() override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,17 +14,16 @@ QueueVulkan::QueueVulkan(GPUDeviceVulkan* device, uint32 familyIndex)
|
|||||||
, _device(device)
|
, _device(device)
|
||||||
, _lastSubmittedCmdBuffer(nullptr)
|
, _lastSubmittedCmdBuffer(nullptr)
|
||||||
, _lastSubmittedCmdBufferFenceCounter(0)
|
, _lastSubmittedCmdBufferFenceCounter(0)
|
||||||
, _submitCounter(0)
|
|
||||||
{
|
{
|
||||||
vkGetDeviceQueue(device->Device, familyIndex, 0, &_queue);
|
vkGetDeviceQueue(device->Device, familyIndex, 0, &_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueVulkan::Submit(CmdBufferVulkan* cmdBuffer, uint32 numSignalSemaphores, VkSemaphore* signalSemaphores)
|
void QueueVulkan::Submit(CmdBufferVulkan* cmdBuffer, uint32 signalSemaphoresCount, const VkSemaphore* signalSemaphores)
|
||||||
{
|
{
|
||||||
ASSERT(cmdBuffer->HasEnded());
|
ASSERT(cmdBuffer->HasEnded());
|
||||||
|
|
||||||
auto fence = cmdBuffer->GetFence();
|
auto fence = cmdBuffer->GetFence();
|
||||||
ASSERT(!fence->IsSignaled());
|
ASSERT(!fence->IsSignaled);
|
||||||
|
|
||||||
const VkCommandBuffer cmdBuffers[] = { cmdBuffer->GetHandle() };
|
const VkCommandBuffer cmdBuffers[] = { cmdBuffer->GetHandle() };
|
||||||
|
|
||||||
@@ -32,7 +31,7 @@ void QueueVulkan::Submit(CmdBufferVulkan* cmdBuffer, uint32 numSignalSemaphores,
|
|||||||
RenderToolsVulkan::ZeroStruct(submitInfo, VK_STRUCTURE_TYPE_SUBMIT_INFO);
|
RenderToolsVulkan::ZeroStruct(submitInfo, VK_STRUCTURE_TYPE_SUBMIT_INFO);
|
||||||
submitInfo.commandBufferCount = 1;
|
submitInfo.commandBufferCount = 1;
|
||||||
submitInfo.pCommandBuffers = cmdBuffers;
|
submitInfo.pCommandBuffers = cmdBuffers;
|
||||||
submitInfo.signalSemaphoreCount = numSignalSemaphores;
|
submitInfo.signalSemaphoreCount = signalSemaphoresCount;
|
||||||
submitInfo.pSignalSemaphores = signalSemaphores;
|
submitInfo.pSignalSemaphores = signalSemaphores;
|
||||||
|
|
||||||
Array<VkSemaphore, InlinedAllocation<8>> waitSemaphores;
|
Array<VkSemaphore, InlinedAllocation<8>> waitSemaphores;
|
||||||
@@ -48,7 +47,7 @@ void QueueVulkan::Submit(CmdBufferVulkan* cmdBuffer, uint32 numSignalSemaphores,
|
|||||||
submitInfo.pWaitDstStageMask = cmdBuffer->_waitFlags.Get();
|
submitInfo.pWaitDstStageMask = cmdBuffer->_waitFlags.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
VALIDATE_VULKAN_RESULT(vkQueueSubmit(_queue, 1, &submitInfo, fence->GetHandle()));
|
VALIDATE_VULKAN_RESULT(vkQueueSubmit(_queue, 1, &submitInfo, fence->Handle));
|
||||||
|
|
||||||
// Mark semaphores as submitted
|
// Mark semaphores as submitted
|
||||||
cmdBuffer->_state = CmdBufferVulkan::State::Submitted;
|
cmdBuffer->_state = CmdBufferVulkan::State::Submitted;
|
||||||
@@ -78,21 +77,16 @@ void QueueVulkan::Submit(CmdBufferVulkan* cmdBuffer, uint32 numSignalSemaphores,
|
|||||||
void QueueVulkan::GetLastSubmittedInfo(CmdBufferVulkan*& cmdBuffer, uint64& fenceCounter) const
|
void QueueVulkan::GetLastSubmittedInfo(CmdBufferVulkan*& cmdBuffer, uint64& fenceCounter) const
|
||||||
{
|
{
|
||||||
_locker.Lock();
|
_locker.Lock();
|
||||||
|
|
||||||
cmdBuffer = _lastSubmittedCmdBuffer;
|
cmdBuffer = _lastSubmittedCmdBuffer;
|
||||||
fenceCounter = _lastSubmittedCmdBufferFenceCounter;
|
fenceCounter = _lastSubmittedCmdBufferFenceCounter;
|
||||||
|
|
||||||
_locker.Unlock();
|
_locker.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueVulkan::UpdateLastSubmittedCommandBuffer(CmdBufferVulkan* cmdBuffer)
|
void QueueVulkan::UpdateLastSubmittedCommandBuffer(CmdBufferVulkan* cmdBuffer)
|
||||||
{
|
{
|
||||||
_locker.Lock();
|
_locker.Lock();
|
||||||
|
|
||||||
_lastSubmittedCmdBuffer = cmdBuffer;
|
_lastSubmittedCmdBuffer = cmdBuffer;
|
||||||
_lastSubmittedCmdBufferFenceCounter = cmdBuffer->GetFenceSignaledCounter();
|
_lastSubmittedCmdBufferFenceCounter = cmdBuffer->GetFenceSignaledCounter();
|
||||||
_submitCounter++;
|
|
||||||
|
|
||||||
_locker.Unlock();
|
_locker.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class CmdBufferVulkan;
|
|||||||
class QueueVulkan
|
class QueueVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
VkQueue _queue;
|
VkQueue _queue;
|
||||||
uint32 _familyIndex;
|
uint32 _familyIndex;
|
||||||
uint32 _queueIndex;
|
uint32 _queueIndex;
|
||||||
@@ -25,10 +24,8 @@ private:
|
|||||||
CriticalSection _locker;
|
CriticalSection _locker;
|
||||||
CmdBufferVulkan* _lastSubmittedCmdBuffer;
|
CmdBufferVulkan* _lastSubmittedCmdBuffer;
|
||||||
uint64 _lastSubmittedCmdBufferFenceCounter;
|
uint64 _lastSubmittedCmdBufferFenceCounter;
|
||||||
uint64 _submitCounter;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QueueVulkan(GPUDeviceVulkan* device, uint32 familyIndex);
|
QueueVulkan(GPUDeviceVulkan* device, uint32 familyIndex);
|
||||||
|
|
||||||
inline uint32 GetFamilyIndex() const
|
inline uint32 GetFamilyIndex() const
|
||||||
@@ -36,7 +33,7 @@ public:
|
|||||||
return _familyIndex;
|
return _familyIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Submit(CmdBufferVulkan* cmdBuffer, uint32 numSignalSemaphores = 0, VkSemaphore* signalSemaphores = nullptr);
|
void Submit(CmdBufferVulkan* cmdBuffer, uint32 signalSemaphoresCount = 0, const VkSemaphore* signalSemaphores = nullptr);
|
||||||
|
|
||||||
inline void Submit(CmdBufferVulkan* cmdBuffer, VkSemaphore signalSemaphore)
|
inline void Submit(CmdBufferVulkan* cmdBuffer, VkSemaphore signalSemaphore)
|
||||||
{
|
{
|
||||||
@@ -50,13 +47,7 @@ public:
|
|||||||
|
|
||||||
void GetLastSubmittedInfo(CmdBufferVulkan*& cmdBuffer, uint64& fenceCounter) const;
|
void GetLastSubmittedInfo(CmdBufferVulkan*& cmdBuffer, uint64& fenceCounter) const;
|
||||||
|
|
||||||
inline uint64 GetSubmitCount() const
|
|
||||||
{
|
|
||||||
return _submitCounter;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void UpdateLastSubmittedCommandBuffer(CmdBufferVulkan* cmdBuffer);
|
void UpdateLastSubmittedCommandBuffer(CmdBufferVulkan* cmdBuffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "Engine/Core/Types/StringBuilder.h"
|
#include "Engine/Core/Types/StringBuilder.h"
|
||||||
#include "Engine/Core/Log.h"
|
#include "Engine/Core/Log.h"
|
||||||
|
|
||||||
|
// @formatter:off
|
||||||
|
|
||||||
VkFormat RenderToolsVulkan::PixelFormatToVkFormat[108] =
|
VkFormat RenderToolsVulkan::PixelFormatToVkFormat[108] =
|
||||||
{
|
{
|
||||||
VK_FORMAT_UNDEFINED,
|
VK_FORMAT_UNDEFINED,
|
||||||
@@ -163,6 +165,8 @@ VkCompareOp RenderToolsVulkan::ComparisonFuncToVkCompareOp[9] =
|
|||||||
VK_COMPARE_OP_ALWAYS, // Always
|
VK_COMPARE_OP_ALWAYS, // Always
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// @formatter:on
|
||||||
|
|
||||||
#define VKERR(x) case x: sb.Append(TEXT(#x)); break
|
#define VKERR(x) case x: sb.Append(TEXT(#x)); break
|
||||||
|
|
||||||
#if GPU_ENABLE_RESOURCE_NAMING
|
#if GPU_ENABLE_RESOURCE_NAMING
|
||||||
|
|||||||
@@ -34,14 +34,12 @@
|
|||||||
class RenderToolsVulkan
|
class RenderToolsVulkan
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static VkFormat PixelFormatToVkFormat[static_cast<int32>(PixelFormat::MAX)];
|
static VkFormat PixelFormatToVkFormat[static_cast<int32>(PixelFormat::MAX)];
|
||||||
static VkBlendFactor BlendToVkBlendFactor[static_cast<int32>(BlendingMode::Blend::MAX)];
|
static VkBlendFactor BlendToVkBlendFactor[static_cast<int32>(BlendingMode::Blend::MAX)];
|
||||||
static VkBlendOp OperationToVkBlendOp[static_cast<int32>(BlendingMode::Operation::MAX)];
|
static VkBlendOp OperationToVkBlendOp[static_cast<int32>(BlendingMode::Operation::MAX)];
|
||||||
static VkCompareOp ComparisonFuncToVkCompareOp[static_cast<int32>(ComparisonFunc::MAX)];
|
static VkCompareOp ComparisonFuncToVkCompareOp[static_cast<int32>(ComparisonFunc::MAX)];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
#if GPU_ENABLE_RESOURCE_NAMING
|
#if GPU_ENABLE_RESOURCE_NAMING
|
||||||
static void SetObjectName(VkDevice device, uint64 objectHandle, VkObjectType objectType, const String& name);
|
static void SetObjectName(VkDevice device, uint64 objectHandle, VkObjectType objectType, const String& name);
|
||||||
static void SetObjectName(VkDevice device, uint64 objectHandle, VkObjectType objectType, const char* name);
|
static void SetObjectName(VkDevice device, uint64 objectHandle, VkObjectType objectType, const char* name);
|
||||||
@@ -80,13 +78,13 @@ public:
|
|||||||
stageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
stageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
||||||
break;
|
break;
|
||||||
#if VK_KHR_maintenance2
|
#if VK_KHR_maintenance2
|
||||||
case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT:
|
case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT:
|
||||||
case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT:
|
case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT:
|
||||||
stageFlags = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
stageFlags = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
CRASH;
|
CRASH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return stageFlags;
|
return stageFlags;
|
||||||
@@ -130,17 +128,17 @@ public:
|
|||||||
stageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
stageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
||||||
break;
|
break;
|
||||||
#if VK_KHR_maintenance2
|
#if VK_KHR_maintenance2
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR:
|
case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR:
|
||||||
accessFlags = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
accessFlags = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
||||||
stageFlags = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
stageFlags = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case VK_IMAGE_LAYOUT_GENERAL:
|
case VK_IMAGE_LAYOUT_GENERAL:
|
||||||
accessFlags = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
accessFlags = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
||||||
stageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
stageFlags = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CRASH;
|
CRASH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return stageFlags;
|
return stageFlags;
|
||||||
@@ -213,7 +211,7 @@ public:
|
|||||||
result = VK_SAMPLER_MIPMAP_MODE_LINEAR;
|
result = VK_SAMPLER_MIPMAP_MODE_LINEAR;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CRASH;
|
CRASH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -237,7 +235,7 @@ public:
|
|||||||
result = VK_FILTER_LINEAR;
|
result = VK_FILTER_LINEAR;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CRASH;
|
CRASH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -261,7 +259,7 @@ public:
|
|||||||
result = VK_FILTER_LINEAR;
|
result = VK_FILTER_LINEAR;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CRASH;
|
CRASH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -285,7 +283,7 @@ public:
|
|||||||
result = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
result = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CRASH;
|
CRASH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -303,7 +301,7 @@ public:
|
|||||||
result = VK_COMPARE_OP_NEVER;
|
result = VK_COMPARE_OP_NEVER;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CRASH;
|
CRASH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -30,13 +30,11 @@ class ResourceOwnerVulkan
|
|||||||
friend GPUContextVulkan;
|
friend GPUContextVulkan;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~ResourceOwnerVulkan()
|
virtual ~ResourceOwnerVulkan()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The resource state tracking helper. Used for resource barriers.
|
/// The resource state tracking helper. Used for resource barriers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -48,7 +46,6 @@ public:
|
|||||||
int32 ArraySlices;
|
int32 ArraySlices;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets resource owner object as a GPUResource type or returns null if cannot perform cast.
|
/// Gets resource owner object as a GPUResource type or returns null if cannot perform cast.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -56,7 +53,6 @@ public:
|
|||||||
virtual GPUResource* AsGPUResource() const = 0;
|
virtual GPUResource* AsGPUResource() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void initResource(VkImageLayout initialState, int32 mipLevels = 1, int32 arraySize = 1, bool usePerSubresourceTracking = false)
|
void initResource(VkImageLayout initialState, int32 mipLevels = 1, int32 arraySize = 1, bool usePerSubresourceTracking = false)
|
||||||
{
|
{
|
||||||
State.Initialize(mipLevels * arraySize, initialState, usePerSubresourceTracking);
|
State.Initialize(mipLevels * arraySize, initialState, usePerSubresourceTracking);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ enum class VulkanValidationLevel
|
|||||||
class VulkanPlatformBase
|
class VulkanPlatformBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void GetInstanceExtensions(Array<const char*>& extensions, Array<const char*>& layers)
|
static void GetInstanceExtensions(Array<const char*>& extensions, Array<const char*>& layers)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user