Fixing missing includes

This commit is contained in:
2025-05-16 13:04:43 +02:00
parent 507e424053
commit 56ec1aa97a
25 changed files with 176 additions and 94 deletions
+5 -3
View File
@@ -11,6 +11,7 @@
#include "Texture.h"
#include "vulkan/vulkan_core.h"
#include <algorithm>
#include <mutex>
#include <ranges>
using namespace Seele;
@@ -201,7 +202,9 @@ DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner)
boundResources.resize(owner->getLayout()->getBindings().size());
for (uint32 i = 0; i < boundResources.size(); ++i) {
boundResources[i].resize(owner->getLayout()->getBindings()[i].descriptorCount);
std::memset(boundResources[i].data(), 0, sizeof(PCommandBoundResource) * boundResources[i].size());
for (size_t x = 0; x < boundResources[i].size(); ++x) {
boundResources[i][x] = nullptr;
}
}
constantData.resize(owner->getLayout()->constantsSize);
}
@@ -220,7 +223,7 @@ void DescriptorSet::updateBuffer(const std::string& mappingName, uint32 index, G
// if the buffer is empty
if (vulkanBuffer->getAlloc() == nullptr)
return;
bufferInfos.add(VkDescriptorBufferInfo{
.buffer = vulkanBuffer->getHandle(),
.offset = 0,
@@ -247,7 +250,6 @@ void DescriptorSet::updateBuffer(const std::string& mappingName, uint32 index, G
// if the buffer is empty
if (vulkanBuffer->getAlloc() == nullptr)
return;
bufferInfos.add(VkDescriptorBufferInfo{
.buffer = vulkanBuffer->getHandle(),
+5 -5
View File
@@ -10,11 +10,11 @@ struct FramebufferDescription {
StaticArray<VkImageView, 16> inputAttachments;
StaticArray<VkImageView, 16> colorAttachments;
StaticArray<VkImageView, 16> resolveAttachments;
VkImageView depthAttachment;
VkImageView depthResolveAttachment;
uint32 numInputAttachments;
uint32 numColorAttachments;
uint32 numResolveAttachments;
VkImageView depthAttachment = VK_NULL_HANDLE;
VkImageView depthResolveAttachment = VK_NULL_HANDLE;
uint32 numInputAttachments = 0;
uint32 numColorAttachments = 0;
uint32 numResolveAttachments = 0;
};
class Framebuffer {
public:
+44 -11
View File
@@ -18,6 +18,7 @@
#include "Window.h"
#include <GLFW/glfw3.h>
#include <cstring>
#include <numeric>
#include <vulkan/vulkan_core.h>
#define VMA_IMPLEMENTATION
@@ -171,9 +172,9 @@ Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreate
return new Viewport(owner, viewportInfo);
}
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name,
Array<uint32> viewMasks, Array<uint32> correlationMasks) {
// todo: re-introduce render area to renderpass
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea,
std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks) {
// todo: re-introduce render area to renderpass
return new RenderPass(this, std::move(layout), std::move(dependencies), name, std::move(viewMasks), std::move(correlationMasks));
}
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass) {
@@ -284,9 +285,7 @@ Gfx::PComputePipeline Graphics::createComputePipeline(Gfx::ComputePipelineCreate
return pipelineCache->createPipeline(std::move(createInfo));
}
Gfx::OSampler Graphics::createSampler(const SamplerCreateInfo& createInfo) {
return new Sampler(this, createInfo);
}
Gfx::OSampler Graphics::createSampler(const SamplerCreateInfo& createInfo) { return new Sampler(this, createInfo); }
Gfx::ODescriptorLayout Graphics::createDescriptorLayout(const std::string& name) { return new DescriptorLayout(this, name); }
@@ -450,7 +449,7 @@ void Graphics::buildBottomLevelAccelerationStructures(Array<Gfx::PBottomLevelAS>
};
Array<VkTransformMatrixKHR> matrices;
for (const auto gfxBlas : data) {
for (const auto& gfxBlas : data) {
const auto blas = gfxBlas.cast<BottomLevelAS>();
matrices.add(blas->getTransform());
}
@@ -765,11 +764,15 @@ void Graphics::pickPhysicalDevice() {
physicalDevice = bestDevice;
vkGetPhysicalDeviceProperties2(physicalDevice, &props);
bufferDeviceAddressFeatures = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES,
.pNext = nullptr,
.bufferDeviceAddress = true,
};
rayTracingFeatures = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR,
.pNext = nullptr,
.pNext = &bufferDeviceAddressFeatures,
.rayTracingPipeline = true,
.rayTraversalPrimitiveCulling = true,
};
accelerationFeatures = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR,
@@ -780,6 +783,8 @@ void Graphics::pickPhysicalDevice() {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT,
.taskShader = true,
.meshShader = true,
.multiviewMeshShader = true,
.primitiveFragmentShadingRateMeshShader = false,
.meshShaderQueries = true,
};
features12 = {
@@ -825,6 +830,11 @@ void Graphics::pickPhysicalDevice() {
};
bool rayTracingPipelineSupport = false;
bool accelerationStructureSupport = false;
bool hostOperationsSupport = false;
bool deviceAddressSupport = false;
bool descriptorIndexingSupport = false;
bool spirv14Support = false;
bool shaderFloatControls = false;
uint32 count = 0;
vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &count, nullptr);
Array<VkExtensionProperties> extensionProps(count);
@@ -833,7 +843,6 @@ void Graphics::pickPhysicalDevice() {
if (Gfx::useMeshShading) {
if (std::strcmp(VK_EXT_MESH_SHADER_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
meshShadingEnabled = true;
break;
}
}
if (std::strcmp(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
@@ -842,8 +851,24 @@ void Graphics::pickPhysicalDevice() {
if (std::strcmp(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
accelerationStructureSupport = true;
}
if (std::strcmp(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
hostOperationsSupport = true;
}
if (std::strcmp(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
deviceAddressSupport = true;
}
if (std::strcmp(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
descriptorIndexingSupport = true;
}
if (std::strcmp(VK_KHR_SPIRV_1_4_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
spirv14Support = true;
}
if (std::strcmp(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, extensionProps[i].extensionName) == 0) {
shaderFloatControls = true;
}
}
rayTracingEnabled = rayTracingPipelineSupport && accelerationStructureSupport;
rayTracingEnabled = rayTracingPipelineSupport && accelerationStructureSupport && hostOperationsSupport && deviceAddressSupport &&
descriptorIndexingSupport && spirv14Support && shaderFloatControls;
if (meshShadingEnabled) {
features12.pNext = &meshShaderFeatures;
}
@@ -927,9 +952,17 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
initializer.deviceExtensions.add(VK_EXT_MESH_SHADER_EXTENSION_NAME);
}
if (supportRayTracing()) {
// ray tracing itself
initializer.deviceExtensions.add(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME);
initializer.deviceExtensions.add(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME);
// required by acceleration_structure
initializer.deviceExtensions.add(VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME);
initializer.deviceExtensions.add(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
initializer.deviceExtensions.add(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
// required for ray tracing pipeline
initializer.deviceExtensions.add(VK_KHR_SPIRV_1_4_EXTENSION_NAME);
// required for spirv_1_4
initializer.deviceExtensions.add(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME);
}
initializer.deviceExtensions.add(VK_KHR_MULTIVIEW_EXTENSION_NAME);
#ifdef __APPLE__
+37 -4
View File
@@ -9,6 +9,35 @@ DECLARE_REF(CommandPool)
DECLARE_REF(Queue)
DECLARE_REF(PipelineCache)
DECLARE_REF(Framebuffer)
template <typename T>
concept chainable_struct = requires(T t) { t.pNext; };
template <chainable_struct... T> struct StructChain;
template <> struct StructChain<> {
};
template<chainable_struct Base> struct StructChain<Base> : StructChain<> {
StructChain(Base b):b(b) {}
StructChain(const StructChain<>&, Base b) : b(b) {}
template <chainable_struct Next> StructChain<Next, Base> append(Next next) { return StructChain<Next, Base>(*this, next); }
Base b;
Base& operator*(){
return b;
}
};
template <chainable_struct This, chainable_struct... Right> struct StructChain<This, Right...> : StructChain<Right...> {
StructChain(const StructChain<Right...>& parent, This t) : StructChain<Right...>(parent), t(t) {}
template <chainable_struct Next> StructChain<Next, This, Right...> append(Next next) {
return StructChain<Next, This, Right...>(*this, next);
}
auto& operator*() {
auto& base = StructChain<Right...>::operator*();
t.pNext = base.pNext;
base.pNext = &t;
return base;
}
This t;
};
class Graphics : public Gfx::Graphics {
public:
Graphics();
@@ -34,8 +63,8 @@ class Graphics : public Gfx::Graphics {
virtual Gfx::OWindow createWindow(const WindowCreateInfo& createInfo) override;
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo& createInfo) override;
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea, std::string name,
Array<uint32> viewMasks, Array<uint32> correlationMasks) override;
virtual Gfx::ORenderPass createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, URect renderArea,
std::string name, Array<uint32> viewMasks, Array<uint32> correlationMasks) override;
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
virtual void endRenderPass() override;
virtual void waitDeviceIdle() override;
@@ -117,16 +146,20 @@ class Graphics : public Gfx::Graphics {
thread_local static PCommandPool transferCommands;
std::mutex poolLock;
Array<OCommandPool> pools;
VkQueueFamilyProperties graphicsProps;
VkPhysicalDeviceProperties2 props;
VkPhysicalDeviceRayTracingPipelinePropertiesKHR rayTracingProperties;
VkPhysicalDeviceAccelerationStructurePropertiesKHR accelerationProperties;
VkPhysicalDeviceFeatures2 features;
VkPhysicalDeviceVulkan11Features features11;
VkPhysicalDeviceVulkan12Features features12;
VkPhysicalDeviceMeshShaderFeaturesEXT meshShaderFeatures;
VkPhysicalDeviceBufferDeviceAddressFeatures bufferDeviceAddressFeatures;
VkPhysicalDeviceAccelerationStructureFeaturesKHR accelerationFeatures;
VkPhysicalDeviceAccelerationStructurePropertiesKHR accelerationProperties;
VkPhysicalDeviceRayTracingPipelineFeaturesKHR rayTracingFeatures;
VkPhysicalDeviceRayTracingPipelinePropertiesKHR rayTracingProperties;
VkDebugUtilsMessengerEXT callback;
Map<uint32, OFramebuffer> allocatedFramebuffers;
VmaAllocator allocator;
+1
View File
@@ -2,6 +2,7 @@
#include "Buffer.h"
#include "Graphics.h"
#include "Graphics/Query.h"
#include <condition_variable>
namespace Seele {
namespace Vulkan {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "Command.h"
#include "Enums.h"
#include "Graphics.h"
#include <mutex>
using namespace Seele;
using namespace Seele::Vulkan;
+1 -1
View File
@@ -43,7 +43,7 @@ class TopLevelAS : public Gfx::TopLevelAS {
public:
TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& createInfo);
~TopLevelAS();
const VkAccelerationStructureKHR getHandle() const { return handle; }
VkAccelerationStructureKHR getHandle() const { return handle; }
private:
PGraphics graphics;
@@ -215,7 +215,6 @@ RenderPass::~RenderPass() {
uint32 RenderPass::getFramebufferHash() {
FramebufferDescription description;
std::memset(&description, 0, sizeof(FramebufferDescription));
for (auto& inputAttachment : layout.inputAttachments) {
PTextureBase tex = inputAttachment.getTexture().cast<TextureBase>();
description.inputAttachments[description.numInputAttachments++] = tex->getView();