Minor Vulkan fixes
This commit is contained in:
@@ -307,7 +307,7 @@ void CmdBufferManagerVulkan::WaitForCmdBuffer(CmdBufferVulkan* cmdBuffer, float
|
||||
cmdBuffer->RefreshFenceStatus();
|
||||
}
|
||||
|
||||
void CmdBufferManagerVulkan::PrepareForNewActiveCommandBuffer()
|
||||
void CmdBufferManagerVulkan::GetNewActiveCommandBuffer()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
ASSERT_LOW_LAYER(_activeCmdBuffer == nullptr)
|
||||
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
FORCE_INLINE CmdBufferVulkan* GetCmdBuffer()
|
||||
{
|
||||
if (!_activeCmdBuffer)
|
||||
PrepareForNewActiveCommandBuffer();
|
||||
GetNewActiveCommandBuffer();
|
||||
return _activeCmdBuffer;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public:
|
||||
{
|
||||
_pool.RefreshFenceStatus(skipCmdBuffer);
|
||||
}
|
||||
void PrepareForNewActiveCommandBuffer();
|
||||
void GetNewActiveCommandBuffer();
|
||||
|
||||
#if VULKAN_USE_TIMER_QUERIES && GPU_VULKAN_PAUSE_QUERIES
|
||||
void OnTimerQueryBegin(QueryType query);
|
||||
|
||||
@@ -49,6 +49,7 @@ void GPUBufferViewVulkan::Release()
|
||||
|
||||
void GPUBufferViewVulkan::DescriptorAsUniformTexelBuffer(GPUContextVulkan* context, VkBufferView& bufferView)
|
||||
{
|
||||
// Buffer SRV
|
||||
ASSERT_LOW_LAYER(View != VK_NULL_HANDLE);
|
||||
bufferView = View;
|
||||
context->AddBufferBarrier(Owner, VK_ACCESS_SHADER_READ_BIT);
|
||||
@@ -56,18 +57,20 @@ void GPUBufferViewVulkan::DescriptorAsUniformTexelBuffer(GPUContextVulkan* conte
|
||||
|
||||
void GPUBufferViewVulkan::DescriptorAsStorageBuffer(GPUContextVulkan* context, VkBuffer& buffer, VkDeviceSize& offset, VkDeviceSize& range)
|
||||
{
|
||||
// Buffer UAV
|
||||
ASSERT_LOW_LAYER(Buffer);
|
||||
buffer = Buffer;
|
||||
offset = 0;
|
||||
range = Size;
|
||||
context->AddBufferBarrier(Owner, VK_ACCESS_SHADER_READ_BIT);
|
||||
context->AddBufferBarrier(Owner, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
|
||||
}
|
||||
|
||||
void GPUBufferViewVulkan::DescriptorAsStorageTexelBuffer(GPUContextVulkan* context, VkBufferView& bufferView)
|
||||
{
|
||||
// Buffer UAV
|
||||
ASSERT_LOW_LAYER(View != VK_NULL_HANDLE);
|
||||
bufferView = View;
|
||||
context->AddBufferBarrier(Owner, VK_ACCESS_SHADER_READ_BIT);
|
||||
context->AddBufferBarrier(Owner, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT);
|
||||
}
|
||||
|
||||
GPUBufferView* GPUBufferVulkan::View() const
|
||||
|
||||
@@ -1443,7 +1443,7 @@ void GPUContextVulkan::Flush()
|
||||
|
||||
// Execute commands
|
||||
_cmdBufferManager->SubmitActiveCmdBuffer();
|
||||
_cmdBufferManager->PrepareForNewActiveCommandBuffer();
|
||||
_cmdBufferManager->GetNewActiveCommandBuffer();
|
||||
ASSERT(_cmdBufferManager->HasPendingActiveCmdBuffer() && _cmdBufferManager->GetActiveCmdBuffer()->GetState() == CmdBufferVulkan::State::IsInsideBegin);
|
||||
}
|
||||
|
||||
|
||||
@@ -241,13 +241,16 @@ static VKAPI_ATTR VkBool32 VKAPI_PTR DebugUtilsCallback(VkDebugUtilsMessageSever
|
||||
}
|
||||
|
||||
#if !BUILD_RELEASE
|
||||
if (auto* context = (GPUContextVulkan*)GPUDevice::Instance->GetMainContext())
|
||||
if (GPUDevice::Instance)
|
||||
{
|
||||
if (auto* state = (GPUPipelineStateVulkan*)context->GetState())
|
||||
if (auto* context = (GPUContextVulkan*)GPUDevice::Instance->GetMainContext())
|
||||
{
|
||||
GPUPipelineState::DebugName name;
|
||||
state->GetDebugName(name);
|
||||
LOG(Warning, "[Vulkan] Error during rendering with {}", String(name.Get(), name.Count() - 1));
|
||||
if (auto* state = (GPUPipelineStateVulkan*)context->GetState())
|
||||
{
|
||||
GPUPipelineState::DebugName name;
|
||||
state->GetDebugName(name);
|
||||
LOG(Warning, "[Vulkan] Error during rendering with {}", String(name.Get(), name.Count() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -438,13 +441,6 @@ void DeferredDeletionQueueVulkan::EnqueueGenericResource(Type type, uint64 handl
|
||||
entry.FrameNumber = Engine::FrameCount;
|
||||
|
||||
ScopeLock lock(_locker);
|
||||
#if BUILD_DEBUG && 0
|
||||
const Function<bool(const Entry&)> ContainsHandle = [handle](const Entry& e)
|
||||
{
|
||||
return e.Handle == handle;
|
||||
};
|
||||
ASSERT(!ArrayExtensions::Any(_entries, ContainsHandle));
|
||||
#endif
|
||||
_entries.Add(entry);
|
||||
}
|
||||
|
||||
@@ -1539,29 +1535,17 @@ void* GPUDeviceVulkan::GetNativePtr() const
|
||||
static int32 GetMaxSampleCount(VkSampleCountFlags counts)
|
||||
{
|
||||
if (counts & VK_SAMPLE_COUNT_64_BIT)
|
||||
{
|
||||
return VK_SAMPLE_COUNT_64_BIT;
|
||||
}
|
||||
if (counts & VK_SAMPLE_COUNT_32_BIT)
|
||||
{
|
||||
return VK_SAMPLE_COUNT_32_BIT;
|
||||
}
|
||||
if (counts & VK_SAMPLE_COUNT_16_BIT)
|
||||
{
|
||||
return VK_SAMPLE_COUNT_16_BIT;
|
||||
}
|
||||
if (counts & VK_SAMPLE_COUNT_8_BIT)
|
||||
{
|
||||
return VK_SAMPLE_COUNT_8_BIT;
|
||||
}
|
||||
if (counts & VK_SAMPLE_COUNT_4_BIT)
|
||||
{
|
||||
return VK_SAMPLE_COUNT_4_BIT;
|
||||
}
|
||||
if (counts & VK_SAMPLE_COUNT_2_BIT)
|
||||
{
|
||||
return VK_SAMPLE_COUNT_2_BIT;
|
||||
}
|
||||
return VK_SAMPLE_COUNT_1_BIT;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ GPUTextureView* GPUSwapChainVulkan::GetBackBufferView()
|
||||
// Submit here so we can add a dependency with the acquired semaphore
|
||||
cmdBuffer->AddWaitSemaphore(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, _acquiredSemaphore);
|
||||
cmdBufferManager->SubmitActiveCmdBuffer();
|
||||
cmdBufferManager->PrepareForNewActiveCommandBuffer();
|
||||
cmdBufferManager->GetNewActiveCommandBuffer();
|
||||
ASSERT(cmdBufferManager->HasPendingActiveCmdBuffer() && cmdBufferManager->GetActiveCmdBuffer()->GetState() == CmdBufferVulkan::State::IsInsideBegin);
|
||||
}
|
||||
return &_backBuffers[_acquiredImageIndex].Handle;
|
||||
@@ -302,36 +302,18 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height)
|
||||
{
|
||||
uint32 presentModesCount = 0;
|
||||
VALIDATE_VULKAN_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, _surface, &presentModesCount, nullptr));
|
||||
Array<VkPresentModeKHR, InlinedAllocation<4>> presentModes;
|
||||
Array<VkPresentModeKHR, InlinedAllocation<8>> presentModes;
|
||||
presentModes.Resize(presentModesCount);
|
||||
VALIDATE_VULKAN_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, _surface, &presentModesCount, presentModes.Get()));
|
||||
bool foundPresentModeMailbox = false;
|
||||
bool foundPresentModeImmediate = false;
|
||||
bool foundPresentModeFifo = false;
|
||||
for (size_t i = 0; i < presentModesCount; i++)
|
||||
{
|
||||
switch (presentModes[(int32)i])
|
||||
{
|
||||
case VK_PRESENT_MODE_MAILBOX_KHR:
|
||||
foundPresentModeMailbox = true;
|
||||
break;
|
||||
case VK_PRESENT_MODE_IMMEDIATE_KHR:
|
||||
foundPresentModeImmediate = true;
|
||||
break;
|
||||
case VK_PRESENT_MODE_FIFO_KHR:
|
||||
foundPresentModeFifo = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundPresentModeMailbox)
|
||||
if (presentModes.Contains(VK_PRESENT_MODE_MAILBOX_KHR))
|
||||
{
|
||||
presentMode = VK_PRESENT_MODE_MAILBOX_KHR;
|
||||
}
|
||||
else if (foundPresentModeImmediate)
|
||||
else if (presentModes.Contains(VK_PRESENT_MODE_IMMEDIATE_KHR))
|
||||
{
|
||||
presentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
|
||||
}
|
||||
else if (foundPresentModeFifo)
|
||||
else if (presentModes.Contains(VK_PRESENT_MODE_FIFO_KHR))
|
||||
{
|
||||
presentMode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
}
|
||||
|
||||
@@ -160,6 +160,7 @@ void GPUTextureViewVulkan::Release()
|
||||
|
||||
void GPUTextureViewVulkan::DescriptorAsImage(GPUContextVulkan* context, VkImageView& imageView, VkImageLayout& layout)
|
||||
{
|
||||
// Texture SRV
|
||||
imageView = View;
|
||||
layout = LayoutSRV;
|
||||
const VkImageAspectFlags aspectMask = Info.subresourceRange.aspectMask;
|
||||
@@ -190,6 +191,7 @@ void GPUTextureViewVulkan::DescriptorAsImage(GPUContextVulkan* context, VkImageV
|
||||
|
||||
void GPUTextureViewVulkan::DescriptorAsStorageImage(GPUContextVulkan* context, VkImageView& imageView, VkImageLayout& layout)
|
||||
{
|
||||
// Texture UAV
|
||||
imageView = View;
|
||||
layout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
context->AddImageBarrier(this, VK_IMAGE_LAYOUT_GENERAL);
|
||||
|
||||
Reference in New Issue
Block a user