Fixing a few warnings

This commit is contained in:
2025-05-23 16:12:33 +02:00
parent a78377741c
commit ad725ba9d9
22 changed files with 128 additions and 86 deletions
+18
View File
@@ -50,6 +50,8 @@ void Command::end() {
}
void Command::beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer) {
renderPass->getCommandHandle()->bind();
boundResources.add(renderPass->getCommandHandle());
assert(state == State::Begin);
boundRenderPass = renderPass;
boundFramebuffer = framebuffer;
@@ -265,6 +267,10 @@ void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptor) {
}
}
}
if (descriptorSet->constantsBuffer != nullptr) {
descriptorSet->bind();
boundResources.add(PBufferAllocation(descriptorSet->constantsBuffer));
}
VkDescriptorSet setHandle = descriptorSet->getHandle();
Gfx::PPipelineLayout layout = pipeline != nullptr ? pipeline->getPipelineLayout() : rtPipeline->getPipelineLayout();
@@ -292,6 +298,10 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
}
}
}
if (descriptorSet->constantsBuffer != nullptr) {
descriptorSet->bind();
boundResources.add(PBufferAllocation(descriptorSet->constantsBuffer));
}
sets[layout->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
}
vkCmdBindDescriptorSets(handle, pipeline != nullptr ? VK_PIPELINE_BIND_POINT_GRAPHICS : VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR,
@@ -438,6 +448,10 @@ void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptor) {
}
}
}
if (descriptorSet->constantsBuffer != nullptr) {
descriptorSet->bind();
boundResources.add(PBufferAllocation(descriptorSet->constantsBuffer));
}
VkDescriptorSet setHandle = descriptorSet->getHandle();
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(),
@@ -461,6 +475,10 @@ void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptor
}
}
}
if (descriptorSet->constantsBuffer != nullptr) {
descriptorSet->bind();
boundResources.add(PBufferAllocation(descriptorSet->constantsBuffer));
}
sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
}
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, 0,
@@ -12,7 +12,6 @@ using namespace Seele::Vulkan;
Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::RenderTargetLayout renderTargetLayout)
: graphics(graphics), layout(renderTargetLayout), renderPass(renderPass) {
FramebufferDescription description;
std::memset(&description, 0, sizeof(FramebufferDescription));
Array<VkImageView> attachments;
uint32 width = 0;
uint32 height = 0;
+26 -10
View File
@@ -733,15 +733,6 @@ void Graphics::pickPhysicalDevice() {
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices.data());
VkPhysicalDevice bestDevice = VK_NULL_HANDLE;
uint32 deviceRating = 0;
props.get<VkPhysicalDeviceProperties2>() = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
};
props.get<VkPhysicalDeviceAccelerationStructurePropertiesKHR>() = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR,
};
props.get<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>() = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR,
};
for (auto dev : physicalDevices) {
uint32 currentRating = 0;
vkGetPhysicalDeviceProperties2(dev, &props.get());
@@ -761,7 +752,32 @@ void Graphics::pickPhysicalDevice() {
physicalDevice = bestDevice;
vkGetPhysicalDeviceProperties2(physicalDevice, &props.get());
vkGetPhysicalDeviceFeatures2(physicalDevice, &features.get());
features.get<VkPhysicalDeviceFeatures2>().features = {
.geometryShader = true,
.fillModeNonSolid = true,
.wideLines = true,
.pipelineStatisticsQuery = true,
.fragmentStoresAndAtomics = true,
.shaderInt64 = true,
.shaderInt16 = true,
.inheritedQueries = true,
};
features.get<VkPhysicalDeviceVulkan11Features>().multiview = true;
features.get<VkPhysicalDeviceVulkan11Features>().storageBuffer16BitAccess = true;
features.get<VkPhysicalDeviceVulkan12Features>().descriptorIndexing = true;
features.get<VkPhysicalDeviceVulkan12Features>().descriptorBindingPartiallyBound = true;
features.get<VkPhysicalDeviceVulkan12Features>().bufferDeviceAddress = true;
features.get<VkPhysicalDeviceVulkan12Features>().storageBuffer8BitAccess = true;
features.get<VkPhysicalDeviceVulkan12Features>().shaderInt8 = true;
features.get<VkPhysicalDeviceAccelerationStructureFeaturesKHR>().accelerationStructure = true;
features.get<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>().rayTracingPipeline = true;
features.get<VkPhysicalDeviceMeshShaderFeaturesEXT>().meshShader = true;
features.get<VkPhysicalDeviceMeshShaderFeaturesEXT>().taskShader = true;
features.get<VkPhysicalDeviceMeshShaderFeaturesEXT>().meshShaderQueries = true;
bool rayTracingPipelineSupport = false;
bool accelerationStructureSupport = false;
bool hostOperationsSupport = false;
@@ -233,7 +233,9 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxInfo) {
uint32 hash = CRC::Calculate(&gfxInfo, sizeof(Gfx::MeshPipelineCreateInfo), CRC::CRC_32());
std::cout << hash << std::endl;
if (graphicsPipelines.contains(hash)) {
std::cout << "found exisiting" << std::endl;
return graphicsPipelines[hash];
}
PPipelineLayout layout = Gfx::PPipelineLayout(gfxInfo.pipelineLayout).cast<PipelineLayout>();
+18 -16
View File
@@ -22,7 +22,7 @@ BottomLevelAS::BottomLevelAS(PGraphics graphics, const Gfx::BottomLevelASCreateI
1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
};
VertexData* vertexData = createInfo.mesh->vertexData;
//todo: indices might be split as well
// todo: indices might be split as well
MeshData meshData = vertexData->getMeshData(createInfo.mesh->id);
vertexOffset = vertexData->getMeshOffset(createInfo.mesh->id) * sizeof(Vector);
vertexCount = vertexData->getMeshVertexCount(createInfo.mesh->id);
@@ -77,6 +77,8 @@ TopLevelAS::TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& crea
},
Gfx::QueueType::GRAPHICS);
instanceAllocation->updateContents(0, sizeof(VkAccelerationStructureInstanceKHR) * instances.size(), instances.data());
instanceAllocation->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR);
VkDeviceOrHostAddressConstKHR instanceDeviceAddress = {
.deviceAddress = instanceAllocation->deviceAddress,
};
@@ -138,20 +140,20 @@ TopLevelAS::TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& crea
};
VK_CHECK(vkCreateAccelerationStructureKHR(graphics->getDevice(), &accelerationInfo, nullptr, &handle));
OBufferAllocation scratchBuffer =
new BufferAllocation(graphics, "ScratchBuffer",
VkBufferCreateInfo{
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
.size = buildSizesInfo.buildScratchSize,
.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
OBufferAllocation scratchBuffer = new BufferAllocation(
graphics, "ScratchBuffer",
VkBufferCreateInfo{
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
.size = buildSizesInfo.buildScratchSize,
.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
},
VmaAllocationCreateInfo{
.usage = VMA_MEMORY_USAGE_AUTO,
},
Gfx::QueueType::GRAPHICS, graphics->getAccelerationProperties().minAccelerationStructureScratchOffsetAlignment);
},
VmaAllocationCreateInfo{
.usage = VMA_MEMORY_USAGE_AUTO,
},
Gfx::QueueType::GRAPHICS, graphics->getAccelerationProperties().minAccelerationStructureScratchOffsetAlignment);
VkAccelerationStructureBuildGeometryInfoKHR buildGeometry = {
.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
@@ -188,8 +190,8 @@ TopLevelAS::TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& crea
.offset = 0,
.size = buffer->size,
};
vkCmdPipelineBarrier(cmd->getHandle(), VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR, VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, 0, 0,
nullptr, 1, &barrier, 0, nullptr);
vkCmdPipelineBarrier(cmd->getHandle(), VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, 0, 0, nullptr, 1, &barrier, 0, nullptr);
cmd->bindResource(PBufferAllocation(scratchBuffer));
graphics->getDestructionManager()->queueResourceForDestruction(std::move(scratchBuffer));
+6 -5
View File
@@ -11,7 +11,7 @@ using namespace Seele::Vulkan;
RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> _dependencies, std::string name,
Array<uint32> viewMasks, Array<uint32> correlationMasks)
: Gfx::RenderPass(std::move(_layout), std::move(_dependencies)), name(name), graphics(graphics) {
: Gfx::RenderPass(std::move(_layout), std::move(_dependencies)), graphics(graphics), name(name) {
subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
Array<VkAttachmentDescription2> attachments;
Array<VkAttachmentReference2> inputRefs;
@@ -196,21 +196,22 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
.correlatedViewMaskCount = (uint32)correlationMasks.size(),
.pCorrelatedViewMasks = correlationMasks.data(),
};
VK_CHECK(vkCreateRenderPass2(graphics->getDevice(), &info, nullptr, &renderPass));
VkRenderPass handle;
VK_CHECK(vkCreateRenderPass2(graphics->getDevice(), &info, nullptr, &handle));
VkDebugUtilsObjectNameInfoEXT nameInfo = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
.pNext = nullptr,
.objectType = VK_OBJECT_TYPE_RENDER_PASS,
.objectHandle = (uint64)renderPass,
.objectHandle = (uint64)handle,
.pObjectName = name.c_str(),
};
assert(!name.empty());
vkSetDebugUtilsObjectNameEXT(graphics->getDevice(), &nameInfo);
renderPass = new RenderPassHandle(graphics, name, handle);
}
RenderPass::~RenderPass() {
vkDestroyRenderPass(graphics->getDevice(), renderPass, nullptr);
// graphics->getDestructionManager()->queueRenderPass(graphics->getGraphicsCommands()->getCommands(), renderPass);
graphics->getDestructionManager()->queueResourceForDestruction(std::move(renderPass));
}
uint32 RenderPass::getFramebufferHash() {
+8 -5
View File
@@ -1,26 +1,29 @@
#pragma once
#include "Graphics.h"
#include "Resources.h"
#include "Graphics/RenderTarget.h"
namespace Seele {
namespace Vulkan {
class RenderPass : public Gfx::RenderPass {
public:
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies,
std::string name, Array<uint32> viewMasks = {}, Array<uint32> correlationMasks = {});
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, std::string name,
Array<uint32> viewMasks = {}, Array<uint32> correlationMasks = {});
virtual ~RenderPass();
uint32 getFramebufferHash();
void endRenderPass();
constexpr VkRenderPass getHandle() const { return renderPass; }
constexpr VkRenderPass getHandle() const { return renderPass->getHandle(); }
constexpr size_t getClearValueCount() const { return clearValues.size(); }
constexpr VkClearValue* getClearValues() const { return clearValues.data(); }
constexpr VkSubpassContents getSubpassContents() const { return subpassContents; }
constexpr const std::string& getName() const { return name; }
constexpr PRenderPassHandle getCommandHandle() const { return renderPass; }
private:
std::string name;
PGraphics graphics;
VkRenderPass renderPass;
std::string name;
ORenderPassHandle renderPass;
Array<VkClearValue> clearValues;
VkRect2D renderArea;
VkSubpassContents subpassContents;
+10
View File
@@ -124,6 +124,16 @@ class Sampler : public Gfx::Sampler {
OSamplerHandle handle;
};
DEFINE_REF(Sampler)
struct RenderPassHandle : public CommandBoundResource {
public:
RenderPassHandle(PGraphics graphics, std::string name, VkRenderPass renderPass)
: CommandBoundResource(graphics, name), handle(renderPass) {}
virtual ~RenderPassHandle() {}
constexpr VkRenderPass getHandle() const { return handle; }
private:
VkRenderPass handle;
};
DEFINE_REF(RenderPassHandle)
} // namespace Vulkan
} // namespace Seele