Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/Graphics/Enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ enum class BufferUsage : uint8_t
{
vertexBuffer = 1 << 0,
indexBuffer = 1 << 1,
uniformBuffer [[deprecated("use constantBuffer")]] = 1 << 2 ,
constantBuffer = 1 << 2,
structuredBuffer = 1 << 3,
copySource = 1 << 4,
Expand Down
17 changes: 14 additions & 3 deletions src/Vulkan/VulkanCommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Vulkan/VulkanTexture.hpp"
#include "Vulkan/VulkanEnums.hpp"
#include <memory>
#include <utility>
#if defined(GFX_IMGUI_ENABLED)
# include "Vulkan/imgui_impl_vulkan.h"
#endif
Expand Down Expand Up @@ -227,9 +228,19 @@ void VulkanCommandBuffer::setParameterBlock(const std::shared_ptr<const Paramete
if ((binding.usages & BindingUsage::fragmentRead) || (binding.usages & BindingUsage::fragmentWrite))
syncReq.stageMask |= vk::PipelineStageFlagBits2::eFragmentShader;

if (static_cast<bool>(binding.usages & (BindingUsage::vertexRead | BindingUsage::fragmentRead))) {
assert(binding.type == BindingType::constantBuffer); // currently only constant buffer are implemented
syncReq.accessMask |= vk::AccessFlagBits2::eUniformRead;
if (static_cast<bool>(binding.usages & (BindingUsage::vertexRead | BindingUsage::fragmentRead)))
{
switch (binding.type)
{
case BindingType::constantBuffer:
syncReq.accessMask |= vk::AccessFlagBits2::eUniformRead;
break;
case BindingType::structuredBuffer:
syncReq.accessMask |= vk::AccessFlagBits2::eShaderStorageRead;
break;
default:
std::unreachable();
}
}
if (static_cast<bool>(binding.usages & (BindingUsage::vertexWrite | BindingUsage::fragmentWrite))) {
throw std::runtime_error("not implemented");
Expand Down
9 changes: 1 addition & 8 deletions src/Vulkan/VulkanEnums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,13 @@ constexpr vk::Format toVkFormat(VertexAttributeFormat fmt)

constexpr vk::BufferUsageFlags toVkBufferUsageFlags(BufferUsages use)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
vk::BufferUsageFlags vkUsages;

if (use & BufferUsage::vertexBuffer)
vkUsages |= vk::BufferUsageFlagBits::eVertexBuffer;
if (use & BufferUsage::indexBuffer)
vkUsages |= vk::BufferUsageFlagBits::eIndexBuffer;
if (use & BufferUsage::uniformBuffer || use & BufferUsage::constantBuffer)
if (use & BufferUsage::constantBuffer)
vkUsages |= vk::BufferUsageFlagBits::eUniformBuffer;
if (use & BufferUsage::structuredBuffer)
vkUsages |= vk::BufferUsageFlagBits::eStorageBuffer;
Expand All @@ -129,16 +127,12 @@ constexpr vk::BufferUsageFlags toVkBufferUsageFlags(BufferUsages use)
vkUsages |= vk::BufferUsageFlagBits::eTransferDst;

return vkUsages;
#pragma GCC diagnostic pop
}

constexpr vk::DescriptorType toVkDescriptorType(BindingType tpe)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
switch (tpe)
{
case BindingType::uniformBuffer:
case BindingType::constantBuffer:
return vk::DescriptorType::eUniformBuffer;
case BindingType::structuredBuffer:
Expand All @@ -150,7 +144,6 @@ constexpr vk::DescriptorType toVkDescriptorType(BindingType tpe)
default:
throw std::runtime_error("not implemented");
}
#pragma GCC diagnostic pop
}

constexpr vk::ShaderStageFlags toVkShaderStageFlags(BindingUsages use)
Expand Down
3 changes: 2 additions & 1 deletion src/Vulkan/VulkanParameterBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "Vulkan/VulkanParameterBlock.hpp"
#include "Vulkan/VulkanBuffer.hpp"
#include "Vulkan/VulkanDevice.hpp"
#include "Vulkan/VulkanEnums.hpp"
#include "Vulkan/VulkanParameterBlockPool.hpp"
#include "Vulkan/VulkanParameterBlockLayout.hpp"

Expand Down Expand Up @@ -54,7 +55,7 @@ void VulkanParameterBlock::setBinding(uint32_t idx, const std::shared_ptr<Buffer
.setDstBinding(idx)
.setDstArrayElement(0)
.setDescriptorCount(1)
.setDescriptorType(vk::DescriptorType::eUniformBuffer)
.setDescriptorType(toVkDescriptorType(m_layout->bindings()[idx].type))
.setBufferInfo(bufferDescriptorInfo);

m_device->vkDevice().updateDescriptorSets(writeDescriptorSet, {});
Expand Down
Loading