Replacing std::format with fmt::format

This commit is contained in:
Dynamitos
2024-01-16 19:24:49 +01:00
parent c0da7d77a1
commit 861c146b46
55 changed files with 304 additions and 186 deletions
+11 -27
View File
@@ -1,6 +1,8 @@
#include "DebugPass.h"
#include "Graphics/Graphics.h"
#include "Graphics/RenderTarget.h"
#include "Graphics/Pipeline.h"
#include "Graphics/Shader.h"
using namespace Seele;
@@ -74,10 +76,6 @@ void DebugPass::publishOutputs()
descriptorLayout = graphics->createDescriptorLayout("DebugDescLayout");
descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
descriptorLayout->create();
pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
pipelineLayout->create();
}
void DebugPass::createRenderPass()
@@ -92,43 +90,29 @@ void DebugPass::createRenderPass()
};
renderPass = graphics->createRenderPass(std::move(layout), viewport);
Gfx::OPipelineLayout pipelineLayout = graphics->createPipelineLayout();
pipelineLayout->addDescriptorLayout(0, descriptorLayout);
pipelineLayout->create();
ShaderCreateInfo createInfo;
createInfo.name = "DebugVertex";
createInfo.mainModule = "Debug";
createInfo.entryPoint = "vertexMain";
createInfo.defines["INDEX_VIEW_PARAMS"] = "0";
Gfx::PVertexShader vertexShader = graphics->createVertexShader(createInfo);
vertexShader = graphics->createVertexShader(createInfo);
createInfo.name = "DebugFragment";
createInfo.entryPoint = "fragmentMain";
Gfx::PFragmentShader fragmentShader = graphics->createFragmentShader(createInfo);
fragmentShader = graphics->createFragmentShader(createInfo);
Gfx::OVertexDeclaration vertexDecl = graphics->createVertexDeclaration({
Gfx::VertexElement {
.streamIndex = 0,
.offset = offsetof(DebugVertex, position),
.vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
.attributeIndex = 0,
.stride = sizeof(DebugVertex),
},
Gfx::VertexElement {
.streamIndex = 0,
.offset = offsetof(DebugVertex, color),
.vertexFormat = Gfx::SE_FORMAT_R32G32B32_SFLOAT,
.attributeIndex = 1,
.stride = sizeof(DebugVertex),
}
});
GraphicsPipelineCreateInfo gfxInfo;
gfxInfo.vertexDeclaration = vertexDecl;
Gfx::LegacyPipelineCreateInfo gfxInfo;
gfxInfo.vertexShader = vertexShader;
gfxInfo.fragmentShader = fragmentShader;
gfxInfo.rasterizationState.polygonMode = Gfx::SE_POLYGON_MODE_LINE;
gfxInfo.rasterizationState.lineWidth = 5.f;
gfxInfo.topology = Gfx::SE_PRIMITIVE_TOPOLOGY_LINE_LIST;
gfxInfo.pipelineLayout = pipelineLayout;
gfxInfo.pipelineLayout = std::move(pipelineLayout);
gfxInfo.renderPass = renderPass;
pipeline = graphics->createGraphicsPipeline(gfxInfo);
pipeline = graphics->createGraphicsPipeline(std::move(gfxInfo));
}
+3 -2
View File
@@ -25,8 +25,9 @@ private:
Gfx::OUniformBuffer viewParamsBuffer;
Gfx::ODescriptorLayout descriptorLayout;
Gfx::PDescriptorSet descriptorSet;
Gfx::OPipelineLayout pipelineLayout;
Gfx::OGraphicsPipeline pipeline;
Gfx::OVertexShader vertexShader;
Gfx::OFragmentShader fragmentShader;
Gfx::PGraphicsPipeline pipeline;
};
DEFINE_REF(DebugPass)
} // namespace Seele
@@ -1,4 +1,5 @@
#include "RenderGraphResources.h"
#include <iostream>
using namespace Seele;
@@ -23,7 +23,6 @@ SkyboxRenderPass::~SkyboxRenderPass()
void SkyboxRenderPass::beginFrame(const Component::Camera& cam)
{
RenderPass::beginFrame(cam);
DataSource uniformUpdate;
skyboxDataLayout->reset();
textureLayout->reset();
+1 -1
View File
@@ -83,7 +83,7 @@ void UIPass::publishOutputs()
colorBuffer = graphics->createTexture2D(colorBufferInfo);
renderTarget =
new Gfx::RenderTargetAttachment(colorBuffer, Gfx::SE_ATTACHMENT_LOAD_OP_CLEAR, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
renderTarget->clear.color = { 0.0f, 0.0f, 0.0f, 1.0f };
renderTarget->clear.color = { {0.0f, 0.0f, 0.0f, 1.0f} };
resources->registerRenderPassOutput("UIPASS_COLOR", renderTarget);
}
+2 -2
View File
@@ -2,7 +2,7 @@
#include "Graphics/Initializer.h"
#include "Graphics/RenderPass/DepthPrepass.h"
#include "Graphics/RenderPass/BasePass.h"
#include <format>
#include <fmt/core.h>
using namespace Seele;
using namespace Seele::Gfx;
@@ -97,7 +97,7 @@ void ShaderCompiler::createShaders(ShaderPermutation permutation)
ShaderCollection collection;
ShaderCreateInfo createInfo;
createInfo.name = std::format("Material {0}", permutation.materialName);
createInfo.name = fmt::format("Material {0}", permutation.materialName);
if (std::strlen(permutation.materialName) > 0)
{
createInfo.additionalModules.add(permutation.materialName);
+6 -6
View File
@@ -71,36 +71,36 @@ struct ShaderPermutation
{
std::memset(taskFile, 0, sizeof(taskFile));
hasTaskShader = 1;
strncpy_s(taskFile, sizeof(taskFile), name.data(), 32);
strncpy(taskFile, name.data(), sizeof(taskFile));
}
void setVertexFile(std::string_view name)
{
std::memset(vertexMeshFile, 0, sizeof(vertexMeshFile));
useMeshShading = 0;
strncpy_s(vertexMeshFile, sizeof(vertexMeshFile), name.data(), 32);
strncpy(vertexMeshFile, name.data(), sizeof(vertexMeshFile));
}
void setMeshFile(std::string_view name)
{
std::memset(vertexMeshFile, 0, sizeof(vertexMeshFile));
useMeshShading = 1;
strncpy_s(vertexMeshFile, sizeof(vertexMeshFile), name.data(), 32);
strncpy(vertexMeshFile, name.data(), sizeof(vertexMeshFile));
}
void setFragmentFile(std::string_view name)
{
std::memset(fragmentFile, 0, sizeof(fragmentFile));
hasFragment = 1;
strncpy_s(fragmentFile, sizeof(fragmentFile), name.data(), 32);
strncpy(fragmentFile, name.data(), sizeof(fragmentFile));
}
void setVertexData(std::string_view name)
{
std::memset(vertexDataName, 0, sizeof(vertexDataName));
strncpy_s(vertexDataName, sizeof(vertexDataName), name.data(), 32);
strncpy(vertexDataName, name.data(), sizeof(vertexDataName));
}
void setMaterial(std::string_view name)
{
std::memset(materialName, 0, sizeof(materialName));
useMaterial = 1;
strncpy_s(materialName, sizeof(materialName), name.data(), 32);
strncpy(materialName, name.data(), sizeof(materialName));
}
};
//Hashed ShaderPermutation for fast lookup
+1 -1
View File
@@ -261,8 +261,8 @@ uint32 Allocator::findMemoryType(uint32 typeFilter, VkMemoryPropertyFlags proper
StagingBuffer::StagingBuffer(PGraphics graphics, OSubAllocation allocation, VkBuffer buffer, VkDeviceSize size, Gfx::QueueType owner)
: owner(owner)
, graphics(graphics)
, allocation(std::move(allocation))
, graphics(graphics)
, buffer(buffer)
, size(size)
{
+22 -22
View File
@@ -59,19 +59,19 @@ class UniformBuffer : public Gfx::UniformBuffer, public Buffer
public:
UniformBuffer(PGraphics graphics, const UniformBufferCreateInfo &sourceData);
virtual ~UniformBuffer();
virtual bool updateContents(const DataSource &sourceData);
virtual bool updateContents(const DataSource &sourceData) override;
virtual void* map(bool writeOnly = true) override;
virtual void unmap() override;
protected:
// Inherited via Vulkan::Buffer
virtual VkAccessFlags getSourceAccessMask();
virtual VkAccessFlags getDestAccessMask();
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner);
virtual VkAccessFlags getSourceAccessMask() override;
virtual VkAccessFlags getDestAccessMask() override;
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override;
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
private:
OStagingBuffer dedicatedStagingBuffer;
@@ -83,19 +83,19 @@ class ShaderBuffer : public Gfx::ShaderBuffer, public Buffer
public:
ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo &sourceData);
virtual ~ShaderBuffer();
virtual bool updateContents(const DataSource &sourceData);
virtual bool updateContents(const DataSource &sourceData) override;
virtual void* map(bool writeOnly = true) override;
virtual void unmap() override;
protected:
// Inherited via Vulkan::Buffer
virtual VkAccessFlags getSourceAccessMask();
virtual VkAccessFlags getDestAccessMask();
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner);
virtual VkAccessFlags getSourceAccessMask() override;
virtual VkAccessFlags getDestAccessMask() override;
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override;
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
private:
OStagingBuffer dedicatedStagingBuffer;
};
@@ -111,13 +111,13 @@ public:
virtual void download(Array<uint8>& buffer) override;
protected:
// Inherited via Vulkan::Buffer
virtual VkAccessFlags getSourceAccessMask();
virtual VkAccessFlags getDestAccessMask();
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner);
virtual VkAccessFlags getSourceAccessMask() override;
virtual VkAccessFlags getDestAccessMask() override;
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override;
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
};
DEFINE_REF(VertexBuffer)
@@ -130,13 +130,13 @@ public:
virtual void download(Array<uint8>& buffer) override;
protected:
// Inherited via Vulkan::Buffer
virtual VkAccessFlags getSourceAccessMask();
virtual VkAccessFlags getDestAccessMask();
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner);
virtual VkAccessFlags getSourceAccessMask() override;
virtual VkAccessFlags getDestAccessMask() override;
virtual void requestOwnershipTransfer(Gfx::QueueType newOwner) override;
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
};
DEFINE_REF(IndexBuffer)
}
+1
View File
@@ -2,6 +2,7 @@
#include "Queue.h"
#include "Graphics/Command.h"
#include "Buffer.h"
#include <thread>
namespace Seele
{
+1 -1
View File
@@ -126,7 +126,7 @@ public:
DescriptorPool(PGraphics graphics, DescriptorLayout &layout);
virtual ~DescriptorPool();
virtual Gfx::PDescriptorSet allocateDescriptorSet() override;
virtual void reset();
virtual void reset() override;
constexpr VkDescriptorPool getHandle() const
{
+1
View File
@@ -2,6 +2,7 @@
#include "Graphics/Enums.h"
#include <vulkan/vulkan.h>
#include <iostream>
#include <thread>
#define VK_CHECK(f) \
{ \
+6 -6
View File
@@ -583,28 +583,28 @@ void Graphics::createDevice(GraphicsInitializer initializer)
cmdDrawMeshTasks = (PFN_vkCmdDrawMeshTasksEXT)vkGetDeviceProcAddr(handle, "vkCmdDrawMeshTasksEXT");
graphicsQueue = new Queue(this, Gfx::QueueType::GRAPHICS, graphicsQueueInfo.familyIndex, 0);
graphicsQueue = new Queue(this, graphicsQueueInfo.familyIndex, 0);
if (Gfx::useAsyncCompute && asyncComputeInfo.familyIndex != -1)
{
if (asyncComputeInfo.familyIndex == graphicsQueueInfo.familyIndex)
{
// Same family as graphics, but different queue
computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, asyncComputeInfo.familyIndex, 1);
computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 1);
}
else
{
// Different family
computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, asyncComputeInfo.familyIndex, 0);
computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 0);
}
}
else
{
computeQueue = new Queue(this, Gfx::QueueType::COMPUTE, computeQueueInfo.familyIndex, 0);
computeQueue = new Queue(this, computeQueueInfo.familyIndex, 0);
}
transferQueue = new Queue(this, Gfx::QueueType::TRANSFER, transferQueueInfo.familyIndex, 0);
transferQueue = new Queue(this, transferQueueInfo.familyIndex, 0);
if (dedicatedTransferQueueInfo.familyIndex != -1)
{
dedicatedTransferQueue = new Queue(this, Gfx::QueueType::DEDICATED_TRANSFER, dedicatedTransferQueueInfo.familyIndex, 0);
dedicatedTransferQueue = new Queue(this, dedicatedTransferQueueInfo.familyIndex, 0);
}
queueMapping.graphicsFamily = graphicsQueue->getFamilyIndex();
queueMapping.computeFamily = computeQueue->getFamilyIndex();
+1 -1
View File
@@ -36,7 +36,7 @@ PipelineCache::PipelineCache(PGraphics graphics, const std::string& cacheFilePat
PipelineCache::~PipelineCache()
{
VkDeviceSize cacheSize;
size_t cacheSize;
VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, nullptr));
Array<uint8> cacheData(cacheSize);
VK_CHECK(vkGetPipelineCacheData(graphics->getDevice(), cache, &cacheSize, cacheData.data()));
+1 -2
View File
@@ -6,10 +6,9 @@
using namespace Seele;
using namespace Seele::Vulkan;
Queue::Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex)
Queue::Queue(PGraphics graphics, uint32 familyIndex, uint32 queueIndex)
: graphics(graphics)
, familyIndex(familyIndex)
, queueType(queueType)
{
vkGetDeviceQueue(graphics->getDevice(), familyIndex, queueIndex, &queue);
}
+1 -2
View File
@@ -10,7 +10,7 @@ DECLARE_REF(Graphics)
class Queue
{
public:
Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex);
Queue(PGraphics graphics, uint32 familyIndex, uint32 queueIndex);
virtual ~Queue();
void submitCommandBuffer(PCommand command, const Array<VkSemaphore>& signalSemaphore);
constexpr uint32 getFamilyIndex() const
@@ -27,7 +27,6 @@ private:
PGraphics graphics;
VkQueue queue;
uint32 familyIndex;
Gfx::QueueType queueType;
};
DEFINE_REF(Queue)
} // namespace Vulkan
+6 -6
View File
@@ -125,9 +125,9 @@ public:
protected:
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
};
DEFINE_REF(Texture2D)
@@ -166,9 +166,9 @@ public:
protected:
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
};
DEFINE_REF(Texture3D)
@@ -206,9 +206,9 @@ public:
virtual void download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Array<uint8>& buffer) override;
protected:
// Inherited via QueueOwnedResource
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner);
virtual void executeOwnershipBarrier(Gfx::QueueType newOwner) override;
virtual void executePipelineBarrier(VkAccessFlags srcAccess, VkPipelineStageFlags srcStage,
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage);
VkAccessFlags dstAccess, VkPipelineStageFlags dstStage) override;
};
DEFINE_REF(TextureCube)
}
+1 -1
View File
@@ -23,7 +23,7 @@ public:
virtual void setMouseButtonCallback(std::function<void(MouseButton, InputAction, KeyModifier)> callback) override;
virtual void setScrollCallback(std::function<void(double, double)> callback) override;
virtual void setFileCallback(std::function<void(int, const char**)> callback) override;
virtual void setCloseCallback(std::function<void()> callback);
virtual void setCloseCallback(std::function<void()> callback) override;
virtual void setResizeCallback(std::function<void(uint32, uint32)> callback) override;
void keyPress(KeyCode code, InputAction action, KeyModifier modifier);