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
-1
View File
@@ -28,7 +28,6 @@
"res/shaders/", "res/shaders/",
"res/shaders/lib" "res/shaders/lib"
], ],
"slang.slangdLocation": "C:\\Users\\Dynamitos\\slang\\build\\Release\\bin\\slangd.exe",
"slang.searchInAllWorkspaceDirectories": false, "slang.searchInAllWorkspaceDirectories": false,
"files.associations": { "files.associations": {
"type_traits": "cpp", "type_traits": "cpp",
+1 -1
View File
@@ -5,7 +5,7 @@
using namespace Seele; using namespace Seele;
SVGLoader::SVGLoader(Gfx::PGraphics graphic) {} SVGLoader::SVGLoader(Gfx::PGraphics) {}
SVGLoader::~SVGLoader() {} SVGLoader::~SVGLoader() {}
+2 -2
View File
@@ -8,6 +8,6 @@ EnvironmentMapAsset::EnvironmentMapAsset(std::string_view folderPath, std::strin
EnvironmentMapAsset::~EnvironmentMapAsset() {} EnvironmentMapAsset::~EnvironmentMapAsset() {}
void EnvironmentMapAsset::save(ArchiveBuffer& buffer) const {} void EnvironmentMapAsset::save(ArchiveBuffer&) const {}
void EnvironmentMapAsset::load(ArchiveBuffer& buffer) {} void EnvironmentMapAsset::load(ArchiveBuffer&) {}
+2 -2
View File
@@ -8,7 +8,7 @@ FontAsset::FontAsset() {}
FontAsset::FontAsset(std::string_view folderPath, std::string_view name) : Asset(folderPath, name) { FontAsset::FontAsset(std::string_view folderPath, std::string_view name) : Asset(folderPath, name) {
FT_Error error = FT_Init_FreeType(&ft); FT_Error error = FT_Init_FreeType(&ft);
assert(!error); if(error) abort();
} }
FontAsset::~FontAsset() { FontAsset::~FontAsset() {
@@ -29,7 +29,7 @@ void FontAsset::load(ArchiveBuffer& buffer) {
void FontAsset::loadFace() { void FontAsset::loadFace() {
FT_Error error = FT_New_Memory_Face(ft, (unsigned char*)ttfFile.data(), (uint32)ttfFile.size(), 0, &ft_face); FT_Error error = FT_New_Memory_Face(ft, (unsigned char*)ttfFile.data(), (uint32)ttfFile.size(), 0, &ft_face);
assert(!error); if(error) abort();
blob = hb_blob_create(ttfFile.data(), (uint32)ttfFile.size(), HB_MEMORY_MODE_DUPLICATE, nullptr, nullptr); blob = hb_blob_create(ttfFile.data(), (uint32)ttfFile.size(), HB_MEMORY_MODE_DUPLICATE, nullptr, nullptr);
hb_face = hb_face_create(blob, 0); hb_face = hb_face_create(blob, 0);
hb_font = hb_font_create(hb_face); hb_font = hb_font_create(hb_face);
+1 -5
View File
@@ -185,8 +185,4 @@ bool addTriangle(const Array<Vector>& positions, Meshlet& current, Triangle& tri
current.primitiveLayout[current.numPrimitives * 3 + 2] = uint8(f3); current.primitiveLayout[current.numPrimitives * 3 + 2] = uint8(f3);
current.numPrimitives++; current.numPrimitives++;
return true; return true;
} }
void Meshlet::build(const Array<Vector>& positions, const Array<uint32>& indices, Array<Meshlet>& meshlets) {
}
-1
View File
@@ -10,6 +10,5 @@ struct Meshlet {
uint32 numVertices; uint32 numVertices;
uint32 numPrimitives; uint32 numPrimitives;
uint32 lod = 0; uint32 lod = 0;
static void build(const Array<Vector>& positions, const Array<uint32>& indices, Array<Meshlet>& meshlets);
}; };
} // namespace Seele } // namespace Seele
+23 -29
View File
@@ -28,7 +28,7 @@ void Seele::addDebugVertex(DebugVertex vert) { gDebugVertices.add(vert); }
void Seele::addDebugVertices(Array<DebugVertex> verts) { gDebugVertices.addAll(verts); } void Seele::addDebugVertices(Array<DebugVertex> verts) { gDebugVertices.addAll(verts); }
BasePass::BasePass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics), scene(scene) { BasePass::BasePass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics), scene(scene) {
//waterRenderer = new WaterRenderer(graphics, scene, viewParamsLayout); // waterRenderer = new WaterRenderer(graphics, scene, viewParamsLayout);
basePassLayout = graphics->createPipelineLayout("BasePassLayout"); basePassLayout = graphics->createPipelineLayout("BasePassLayout");
basePassLayout->addDescriptorLayout(viewParamsLayout); basePassLayout->addDescriptorLayout(viewParamsLayout);
@@ -98,8 +98,8 @@ void BasePass::beginFrame(const Component::Camera& cam, const Component::Transfo
opaqueCulling = lightCullingLayout->allocateDescriptorSet(); opaqueCulling = lightCullingLayout->allocateDescriptorSet();
transparentCulling = lightCullingLayout->allocateDescriptorSet(); transparentCulling = lightCullingLayout->allocateDescriptorSet();
//waterRenderer->beginFrame(); // waterRenderer->beginFrame();
//terrainRenderer->beginFrame(viewParamsSet, cam); // terrainRenderer->beginFrame(viewParamsSet, cam);
// Debug vertices // Debug vertices
{ {
@@ -122,7 +122,7 @@ void BasePass::beginFrame(const Component::Camera& cam, const Component::Transfo
skyboxDataLayout->reset(); skyboxDataLayout->reset();
textureLayout->reset(); textureLayout->reset();
skyboxData.transformMatrix = glm::rotate(skyboxData.transformMatrix, (float)(Gfx::getCurrentFrameDelta()), Vector(0, 1, 0)); skyboxData.transformMatrix = glm::rotate(skyboxData.transformMatrix, (float)(Gfx::getCurrentFrameDelta()), Vector(0, 1, 0));
skyboxDataSet = skyboxDataLayout->allocateDescriptorSet(); skyboxDataSet = skyboxDataLayout->allocateDescriptorSet();
skyboxDataSet->updateConstants("transformMatrix", 0, &skyboxData.transformMatrix); skyboxDataSet->updateConstants("transformMatrix", 0, &skyboxData.transformMatrix);
skyboxDataSet->updateConstants("fogBlend", 0, &skyboxData.fogColor); skyboxDataSet->updateConstants("fogBlend", 0, &skyboxData.fogColor);
@@ -194,7 +194,7 @@ void BasePass::render() {
}, },
.rasterizationState = .rasterizationState =
{ {
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT, .cullMode = twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT,
}, },
.colorBlend = .colorBlend =
{ {
@@ -214,7 +214,7 @@ void BasePass::render() {
}, },
.rasterizationState = .rasterizationState =
{ {
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT, .cullMode = twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT,
}, },
.colorBlend = .colorBlend =
{ {
@@ -246,11 +246,10 @@ void BasePass::render() {
graphics->executeCommands(std::move(commands)); graphics->executeCommands(std::move(commands));
graphics->endDebugRegion(); graphics->endDebugRegion();
} }
// commands.add(waterRenderer->render(viewParamsSet));
//commands.add(waterRenderer->render(viewParamsSet)); // commands.add(terrainRenderer->render(viewParamsSet));
//commands.add(terrainRenderer->render(viewParamsSet));
// Skybox // Skybox
{ {
graphics->beginDebugRegion("Skybox"); graphics->beginDebugRegion("Skybox");
@@ -413,7 +412,7 @@ void BasePass::publishOutputs() {
.samples = Gfx::SE_SAMPLE_COUNT_4_BIT, .samples = Gfx::SE_SAMPLE_COUNT_4_BIT,
.usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | Gfx::SE_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, .usage = Gfx::SE_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | Gfx::SE_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
}); });
msBasePassColor = graphics->createTexture2D(TextureCreateInfo{ msBasePassColor = graphics->createTexture2D(TextureCreateInfo{
.format = Gfx::SE_FORMAT_R32G32B32A32_SFLOAT, .format = Gfx::SE_FORMAT_R32G32B32A32_SFLOAT,
.width = viewport->getOwner()->getFramebufferWidth(), .width = viewport->getOwner()->getFramebufferWidth(),
@@ -422,17 +421,18 @@ void BasePass::publishOutputs() {
.usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | Gfx::SE_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, .usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | Gfx::SE_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
}); });
depthAttachment = depthAttachment = Gfx::RenderTargetAttachment(Gfx::PTexture2D(basePassDepth), Gfx::SE_IMAGE_LAYOUT_UNDEFINED,
Gfx::RenderTargetAttachment(Gfx::PTexture2D(basePassDepth), Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE); Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
msDepthAttachment = msDepthAttachment =
Gfx::RenderTargetAttachment(msBasePassDepth, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, Gfx::RenderTargetAttachment(msBasePassDepth, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_DONT_CARE); Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_DONT_CARE);
msDepthAttachment.clear.depthStencil.depth = 0.0f; msDepthAttachment.clear.depthStencil.depth = 0.0f;
colorAttachment = Gfx::RenderTargetAttachment(basePassColor, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, colorAttachment =
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE); Gfx::RenderTargetAttachment(basePassColor, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
msColorAttachment = msColorAttachment =
Gfx::RenderTargetAttachment(msBasePassColor, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, Gfx::RenderTargetAttachment(msBasePassColor, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
@@ -451,8 +451,8 @@ void BasePass::publishOutputs() {
} }
void BasePass::createRenderPass() { void BasePass::createRenderPass() {
//RenderPass::beginFrame(Component::Camera()); // RenderPass::beginFrame(Component::Camera());
//terrainRenderer = new TerrainRenderer(graphics, scene, viewParamsLayout, viewParamsSet); // terrainRenderer = new TerrainRenderer(graphics, scene, viewParamsLayout, viewParamsSet);
cullingBuffer = resources->requestBuffer("CULLINGBUFFER"); cullingBuffer = resources->requestBuffer("CULLINGBUFFER");
timestamps = resources->requestTimestampQuery("TIMESTAMPS"); timestamps = resources->requestTimestampQuery("TIMESTAMPS");
@@ -494,8 +494,8 @@ void BasePass::createRenderPass() {
oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID"); oLightGrid = resources->requestTexture("LIGHTCULLING_OLIGHTGRID");
tLightGrid = resources->requestTexture("LIGHTCULLING_TLIGHTGRID"); tLightGrid = resources->requestTexture("LIGHTCULLING_TLIGHTGRID");
//waterRenderer->setViewport(viewport, renderPass); // waterRenderer->setViewport(viewport, renderPass);
//terrainRenderer->setViewport(viewport, renderPass); // terrainRenderer->setViewport(viewport, renderPass);
// Debug rendering // Debug rendering
{ {
@@ -569,14 +569,8 @@ void BasePass::createRenderPass() {
// Skybox // Skybox
{ {
skyboxDataLayout = graphics->createDescriptorLayout("pSkyboxData"); skyboxDataLayout = graphics->createDescriptorLayout("pSkyboxData");
skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{ skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "transformMatrix", .uniformLength = sizeof(Matrix4)});
.name = "transformMatrix", skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.name = "fogBlend", .uniformLength = sizeof(Vector4)});
.uniformLength = sizeof(Matrix4)
});
skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{
.name = "fogBlend",
.uniformLength = sizeof(Vector4)
});
skyboxDataLayout->create(); skyboxDataLayout->create();
textureLayout = graphics->createDescriptorLayout("pSkyboxTextures"); textureLayout = graphics->createDescriptorLayout("pSkyboxTextures");
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{ textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{
@@ -79,7 +79,6 @@ void ShadowPass::render() {
.offset = {0, 0}, .offset = {0, 0},
}, },
"Shadow"); "Shadow");
auto light = scene->getLightEnvironment()->getDirectionalLight(shadowIndex);
Component::Camera lightCamera = Component::Camera{ Component::Camera lightCamera = Component::Camera{
.nearPlane = -100.f, .nearPlane = -100.f,
.farPlane = 100.0f, .farPlane = 100.0f,
@@ -105,7 +104,7 @@ void ShadowPass::render() {
.pipelineLayout = collection->pipelineLayout, .pipelineLayout = collection->pipelineLayout,
.rasterizationState = .rasterizationState =
{ {
.cullMode = Gfx::SE_CULL_MODE_NONE, .cullMode = Gfx::SE_CULL_MODE_FRONT_BIT,
.depthBiasEnable = true, .depthBiasEnable = true,
.depthBiasConstantFactor = depthBiasConstant, .depthBiasConstantFactor = depthBiasConstant,
.depthBiasSlopeFactor = depthBiasSlope, .depthBiasSlopeFactor = depthBiasSlope,
@@ -121,7 +120,7 @@ void ShadowPass::render() {
.pipelineLayout = collection->pipelineLayout, .pipelineLayout = collection->pipelineLayout,
.rasterizationState = .rasterizationState =
{ {
.cullMode = Gfx::SE_CULL_MODE_NONE, .cullMode = Gfx::SE_CULL_MODE_FRONT_BIT,
.depthBiasEnable = true, .depthBiasEnable = true,
.depthBiasConstantFactor = depthBiasConstant, .depthBiasConstantFactor = depthBiasConstant,
.depthBiasSlopeFactor = depthBiasSlope, .depthBiasSlopeFactor = depthBiasSlope,
+1 -1
View File
@@ -75,7 +75,7 @@ void ShaderCompiler::compile() {
} else { } else {
for (int x = 0; x < 2; x++) { for (int x = 0; x < 2; x++) {
for (int y = 0; y < 2; y++) { for (int y = 0; y < 2; y++) {
work.add([=]() { work.add([=, this]() {
ShaderPermutation permutation = getTemplate(name); ShaderPermutation permutation = getTemplate(name);
permutation.setPositionOnly(x); permutation.setPositionOnly(x);
permutation.setDepthCulling(y); permutation.setDepthCulling(y);
+1 -1
View File
@@ -131,7 +131,7 @@ struct ShaderPermutation {
} }
void setVertexData(std::string_view name) { void setVertexData(std::string_view name) {
std::memset(vertexDataName, 0, sizeof(vertexDataName)); std::memset(vertexDataName, 0, sizeof(vertexDataName));
strncpy(vertexDataName, name.data(), name.size()); strncpy(vertexDataName, name.data(), sizeof(vertexDataName));
} }
void setMaterial(std::string_view name, std::string_view brdf) { void setMaterial(std::string_view name, std::string_view brdf) {
std::memset(materialName, 0, sizeof(materialName)); std::memset(materialName, 0, sizeof(materialName));
+4 -1
View File
@@ -251,7 +251,10 @@ Array<VertexData::MeshletGroup> VertexData::groupMeshlets(std::span<MeshletDescr
int result = METIS_PartGraphKway(&vertexCount, &ncon, xadjacency.data(), edgeAdjacency.data(), nullptr, nullptr, edgeWeights.data(), int result = METIS_PartGraphKway(&vertexCount, &ncon, xadjacency.data(), edgeAdjacency.data(), nullptr, nullptr, edgeWeights.data(),
&nparts, nullptr, nullptr, options, &edgeCut, partition.data()); &nparts, nullptr, nullptr, options, &edgeCut, partition.data());
assert(result == METIS_OK); if(result != METIS_OK)
{
abort();
}
Array<MeshletGroup> groups; Array<MeshletGroup> groups;
groups.resize(nparts); groups.resize(nparts);
+18
View File
@@ -50,6 +50,8 @@ void Command::end() {
} }
void Command::beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer) { void Command::beginRenderPass(PRenderPass renderPass, PFramebuffer framebuffer) {
renderPass->getCommandHandle()->bind();
boundResources.add(renderPass->getCommandHandle());
assert(state == State::Begin); assert(state == State::Begin);
boundRenderPass = renderPass; boundRenderPass = renderPass;
boundFramebuffer = framebuffer; 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(); VkDescriptorSet setHandle = descriptorSet->getHandle();
Gfx::PPipelineLayout layout = pipeline != nullptr ? pipeline->getPipelineLayout() : rtPipeline->getPipelineLayout(); 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(); sets[layout->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
} }
vkCmdBindDescriptorSets(handle, pipeline != nullptr ? VK_PIPELINE_BIND_POINT_GRAPHICS : VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, 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(); VkDescriptorSet setHandle = descriptorSet->getHandle();
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 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(); sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
} }
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, 0, 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) Framebuffer::Framebuffer(PGraphics graphics, PRenderPass renderPass, Gfx::RenderTargetLayout renderTargetLayout)
: graphics(graphics), layout(renderTargetLayout), renderPass(renderPass) { : graphics(graphics), layout(renderTargetLayout), renderPass(renderPass) {
FramebufferDescription description; FramebufferDescription description;
std::memset(&description, 0, sizeof(FramebufferDescription));
Array<VkImageView> attachments; Array<VkImageView> attachments;
uint32 width = 0; uint32 width = 0;
uint32 height = 0; uint32 height = 0;
+26 -10
View File
@@ -733,15 +733,6 @@ void Graphics::pickPhysicalDevice() {
vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices.data()); vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices.data());
VkPhysicalDevice bestDevice = VK_NULL_HANDLE; VkPhysicalDevice bestDevice = VK_NULL_HANDLE;
uint32 deviceRating = 0; 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) { for (auto dev : physicalDevices) {
uint32 currentRating = 0; uint32 currentRating = 0;
vkGetPhysicalDeviceProperties2(dev, &props.get()); vkGetPhysicalDeviceProperties2(dev, &props.get());
@@ -761,7 +752,32 @@ void Graphics::pickPhysicalDevice() {
physicalDevice = bestDevice; physicalDevice = bestDevice;
vkGetPhysicalDeviceProperties2(physicalDevice, &props.get()); 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 rayTracingPipelineSupport = false;
bool accelerationStructureSupport = false; bool accelerationStructureSupport = false;
bool hostOperationsSupport = false; bool hostOperationsSupport = false;
@@ -233,7 +233,9 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxInfo) { PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxInfo) {
uint32 hash = CRC::Calculate(&gfxInfo, sizeof(Gfx::MeshPipelineCreateInfo), CRC::CRC_32()); uint32 hash = CRC::Calculate(&gfxInfo, sizeof(Gfx::MeshPipelineCreateInfo), CRC::CRC_32());
std::cout << hash << std::endl;
if (graphicsPipelines.contains(hash)) { if (graphicsPipelines.contains(hash)) {
std::cout << "found exisiting" << std::endl;
return graphicsPipelines[hash]; return graphicsPipelines[hash];
} }
PPipelineLayout layout = Gfx::PPipelineLayout(gfxInfo.pipelineLayout).cast<PipelineLayout>(); 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, 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; 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); MeshData meshData = vertexData->getMeshData(createInfo.mesh->id);
vertexOffset = vertexData->getMeshOffset(createInfo.mesh->id) * sizeof(Vector); vertexOffset = vertexData->getMeshOffset(createInfo.mesh->id) * sizeof(Vector);
vertexCount = vertexData->getMeshVertexCount(createInfo.mesh->id); vertexCount = vertexData->getMeshVertexCount(createInfo.mesh->id);
@@ -77,6 +77,8 @@ TopLevelAS::TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& crea
}, },
Gfx::QueueType::GRAPHICS); Gfx::QueueType::GRAPHICS);
instanceAllocation->updateContents(0, sizeof(VkAccelerationStructureInstanceKHR) * instances.size(), instances.data()); 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 = { VkDeviceOrHostAddressConstKHR instanceDeviceAddress = {
.deviceAddress = instanceAllocation->deviceAddress, .deviceAddress = instanceAllocation->deviceAddress,
}; };
@@ -138,20 +140,20 @@ TopLevelAS::TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& crea
}; };
VK_CHECK(vkCreateAccelerationStructureKHR(graphics->getDevice(), &accelerationInfo, nullptr, &handle)); VK_CHECK(vkCreateAccelerationStructureKHR(graphics->getDevice(), &accelerationInfo, nullptr, &handle));
OBufferAllocation scratchBuffer = OBufferAllocation scratchBuffer = new BufferAllocation(
new BufferAllocation(graphics, "ScratchBuffer", graphics, "ScratchBuffer",
VkBufferCreateInfo{ VkBufferCreateInfo{
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr, .pNext = nullptr,
.flags = 0, .flags = 0,
.size = buildSizesInfo.buildScratchSize, .size = buildSizesInfo.buildScratchSize,
.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, .usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
}, },
VmaAllocationCreateInfo{ VmaAllocationCreateInfo{
.usage = VMA_MEMORY_USAGE_AUTO, .usage = VMA_MEMORY_USAGE_AUTO,
}, },
Gfx::QueueType::GRAPHICS, graphics->getAccelerationProperties().minAccelerationStructureScratchOffsetAlignment); Gfx::QueueType::GRAPHICS, graphics->getAccelerationProperties().minAccelerationStructureScratchOffsetAlignment);
VkAccelerationStructureBuildGeometryInfoKHR buildGeometry = { VkAccelerationStructureBuildGeometryInfoKHR buildGeometry = {
.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR, .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
@@ -188,8 +190,8 @@ TopLevelAS::TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& crea
.offset = 0, .offset = 0,
.size = buffer->size, .size = buffer->size,
}; };
vkCmdPipelineBarrier(cmd->getHandle(), VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR, VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, 0, 0, vkCmdPipelineBarrier(cmd->getHandle(), VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR,
nullptr, 1, &barrier, 0, nullptr); VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, 0, 0, nullptr, 1, &barrier, 0, nullptr);
cmd->bindResource(PBufferAllocation(scratchBuffer)); cmd->bindResource(PBufferAllocation(scratchBuffer));
graphics->getDestructionManager()->queueResourceForDestruction(std::move(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, RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Array<Gfx::SubPassDependency> _dependencies, std::string name,
Array<uint32> viewMasks, Array<uint32> correlationMasks) 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; subpassContents = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS;
Array<VkAttachmentDescription2> attachments; Array<VkAttachmentDescription2> attachments;
Array<VkAttachmentReference2> inputRefs; Array<VkAttachmentReference2> inputRefs;
@@ -196,21 +196,22 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
.correlatedViewMaskCount = (uint32)correlationMasks.size(), .correlatedViewMaskCount = (uint32)correlationMasks.size(),
.pCorrelatedViewMasks = correlationMasks.data(), .pCorrelatedViewMasks = correlationMasks.data(),
}; };
VK_CHECK(vkCreateRenderPass2(graphics->getDevice(), &info, nullptr, &renderPass)); VkRenderPass handle;
VK_CHECK(vkCreateRenderPass2(graphics->getDevice(), &info, nullptr, &handle));
VkDebugUtilsObjectNameInfoEXT nameInfo = { VkDebugUtilsObjectNameInfoEXT nameInfo = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT, .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
.pNext = nullptr, .pNext = nullptr,
.objectType = VK_OBJECT_TYPE_RENDER_PASS, .objectType = VK_OBJECT_TYPE_RENDER_PASS,
.objectHandle = (uint64)renderPass, .objectHandle = (uint64)handle,
.pObjectName = name.c_str(), .pObjectName = name.c_str(),
}; };
assert(!name.empty()); assert(!name.empty());
vkSetDebugUtilsObjectNameEXT(graphics->getDevice(), &nameInfo); vkSetDebugUtilsObjectNameEXT(graphics->getDevice(), &nameInfo);
renderPass = new RenderPassHandle(graphics, name, handle);
} }
RenderPass::~RenderPass() { RenderPass::~RenderPass() {
vkDestroyRenderPass(graphics->getDevice(), renderPass, nullptr); graphics->getDestructionManager()->queueResourceForDestruction(std::move(renderPass));
// graphics->getDestructionManager()->queueRenderPass(graphics->getGraphicsCommands()->getCommands(), renderPass);
} }
uint32 RenderPass::getFramebufferHash() { uint32 RenderPass::getFramebufferHash() {
+8 -5
View File
@@ -1,26 +1,29 @@
#pragma once #pragma once
#include "Graphics.h" #include "Graphics.h"
#include "Resources.h"
#include "Graphics/RenderTarget.h" #include "Graphics/RenderTarget.h"
namespace Seele { namespace Seele {
namespace Vulkan { namespace Vulkan {
class RenderPass : public Gfx::RenderPass { class RenderPass : public Gfx::RenderPass {
public: public:
RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, RenderPass(PGraphics graphics, Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, std::string name,
std::string name, Array<uint32> viewMasks = {}, Array<uint32> correlationMasks = {}); Array<uint32> viewMasks = {}, Array<uint32> correlationMasks = {});
virtual ~RenderPass(); virtual ~RenderPass();
uint32 getFramebufferHash(); uint32 getFramebufferHash();
void endRenderPass(); void endRenderPass();
constexpr VkRenderPass getHandle() const { return renderPass; } constexpr VkRenderPass getHandle() const { return renderPass->getHandle(); }
constexpr size_t getClearValueCount() const { return clearValues.size(); } constexpr size_t getClearValueCount() const { return clearValues.size(); }
constexpr VkClearValue* getClearValues() const { return clearValues.data(); } constexpr VkClearValue* getClearValues() const { return clearValues.data(); }
constexpr VkSubpassContents getSubpassContents() const { return subpassContents; } constexpr VkSubpassContents getSubpassContents() const { return subpassContents; }
constexpr const std::string& getName() const { return name; } constexpr const std::string& getName() const { return name; }
constexpr PRenderPassHandle getCommandHandle() const { return renderPass; }
private: private:
std::string name;
PGraphics graphics; PGraphics graphics;
VkRenderPass renderPass; std::string name;
ORenderPassHandle renderPass;
Array<VkClearValue> clearValues; Array<VkClearValue> clearValues;
VkRect2D renderArea; VkRect2D renderArea;
VkSubpassContents subpassContents; VkSubpassContents subpassContents;
+10
View File
@@ -124,6 +124,16 @@ class Sampler : public Gfx::Sampler {
OSamplerHandle handle; OSamplerHandle handle;
}; };
DEFINE_REF(Sampler) 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 Vulkan
} // namespace Seele } // namespace Seele
+1 -1
View File
@@ -33,6 +33,7 @@ class LightEnvironment {
const Array<Gfx::OTexture2D>& getShadowMaps() const { return shadowMaps; } const Array<Gfx::OTexture2D>& getShadowMaps() const { return shadowMaps; }
private: private:
Gfx::PGraphics graphics;
Gfx::OShaderBuffer directionalLights; Gfx::OShaderBuffer directionalLights;
Array<Gfx::OTexture2D> shadowMaps; Array<Gfx::OTexture2D> shadowMaps;
Array<Gfx::OSampler> shadowSamplers; Array<Gfx::OSampler> shadowSamplers;
@@ -44,7 +45,6 @@ class LightEnvironment {
Gfx::OSampler environmentSampler; Gfx::OSampler environmentSampler;
Gfx::ODescriptorLayout layout; Gfx::ODescriptorLayout layout;
Gfx::PDescriptorSet set; Gfx::PDescriptorSet set;
Gfx::PGraphics graphics;
}; };
DEFINE_REF(LightEnvironment) DEFINE_REF(LightEnvironment)
} // namespace Seele } // namespace Seele
+1 -1
View File
@@ -53,7 +53,7 @@ void ArchiveBuffer::seek(int64 s, SeekOp op) {
break; break;
} }
assert(newPos >= 0 && size_t(newPos) < memory.size()); assert(newPos >= 0 && size_t(newPos) < memory.size());
newPos = position; position = newPos;
} }
bool ArchiveBuffer::eof() const { return position == memory.size(); } bool ArchiveBuffer::eof() const { return position == memory.size(); }
+1
View File
@@ -54,6 +54,7 @@ class Element {
case InnerDisplayType::Flow: case InnerDisplayType::Flow:
flowLayout(); flowLayout();
break; break;
default:break;
} }
} }
// normal flow of the elements, inline elements go left to right, blocks get their own new lines // normal flow of the elements, inline elements go left to right, blocks get their own new lines