More Ray tracing changes
This commit is contained in:
Vendored
+1
-1
Submodule external/slang updated: 4b8ceed9d6...f83fe55a8c
@@ -1,5 +1,4 @@
|
|||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "Buffer.h"
|
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Gfx;
|
using namespace Seele::Gfx;
|
||||||
@@ -42,6 +41,7 @@ IndexBuffer::IndexBuffer(QueueFamilyMapping mapping, uint64 size, Gfx::SeIndexTy
|
|||||||
IndexBuffer::~IndexBuffer()
|
IndexBuffer::~IndexBuffer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UniformBuffer::UniformBuffer(QueueFamilyMapping mapping, const DataSource& sourceData)
|
UniformBuffer::UniformBuffer(QueueFamilyMapping mapping, const DataSource& sourceData)
|
||||||
: Buffer(mapping, sourceData.owner)
|
: Buffer(mapping, sourceData.owner)
|
||||||
{}
|
{}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
|
#include "Initializer.h"
|
||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|||||||
@@ -14,10 +14,13 @@ target_sources(Engine
|
|||||||
Initializer.h
|
Initializer.h
|
||||||
Mesh.h
|
Mesh.h
|
||||||
Mesh.cpp
|
Mesh.cpp
|
||||||
|
MeshData.h
|
||||||
Meshlet.h
|
Meshlet.h
|
||||||
Meshlet.cpp
|
Meshlet.cpp
|
||||||
Pipeline.h
|
Pipeline.h
|
||||||
Pipeline.cpp
|
Pipeline.cpp
|
||||||
|
RayTracing.h
|
||||||
|
RayTracing.cpp
|
||||||
RenderTarget.h
|
RenderTarget.h
|
||||||
RenderTarget.cpp
|
RenderTarget.cpp
|
||||||
Resources.h
|
Resources.h
|
||||||
@@ -47,7 +50,9 @@ target_sources(Engine
|
|||||||
Initializer.h
|
Initializer.h
|
||||||
Mesh.h
|
Mesh.h
|
||||||
Meshlet.h
|
Meshlet.h
|
||||||
|
MeshData.h
|
||||||
Pipeline.h
|
Pipeline.h
|
||||||
|
RayTracing.h
|
||||||
RenderTarget.h
|
RenderTarget.h
|
||||||
Resources.h
|
Resources.h
|
||||||
Shader.h
|
Shader.h
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
#include <compare>
|
#include "Initializer.h"
|
||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
@@ -19,17 +19,19 @@ DECLARE_REF(DescriptorPool)
|
|||||||
DECLARE_REF(DescriptorSet)
|
DECLARE_REF(DescriptorSet)
|
||||||
class DescriptorLayout {
|
class DescriptorLayout {
|
||||||
public:
|
public:
|
||||||
DescriptorLayout(const std::string& name);
|
DescriptorLayout(const std::string &name);
|
||||||
DescriptorLayout(const DescriptorLayout& other);
|
DescriptorLayout(const DescriptorLayout &other);
|
||||||
DescriptorLayout& operator=(const DescriptorLayout& other);
|
DescriptorLayout &operator=(const DescriptorLayout &other);
|
||||||
virtual ~DescriptorLayout();
|
virtual ~DescriptorLayout();
|
||||||
void addDescriptorBinding(DescriptorBinding binding);
|
void addDescriptorBinding(DescriptorBinding binding);
|
||||||
void reset();
|
void reset();
|
||||||
PDescriptorSet allocateDescriptorSet();
|
PDescriptorSet allocateDescriptorSet();
|
||||||
virtual void create() = 0;
|
virtual void create() = 0;
|
||||||
constexpr const Array<DescriptorBinding>& getBindings() const { return descriptorBindings; }
|
constexpr const Array<DescriptorBinding> &getBindings() const {
|
||||||
|
return descriptorBindings;
|
||||||
|
}
|
||||||
constexpr uint32 getHash() const { return hash; }
|
constexpr uint32 getHash() const { return hash; }
|
||||||
constexpr const std::string& getName() const { return name; }
|
constexpr const std::string &getName() const { return name; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Array<DescriptorBinding> descriptorBindings;
|
Array<DescriptorBinding> descriptorBindings;
|
||||||
@@ -61,40 +63,48 @@ public:
|
|||||||
virtual void writeChanges() = 0;
|
virtual void writeChanges() = 0;
|
||||||
virtual void updateBuffer(uint32 binding, PUniformBuffer uniformBuffer) = 0;
|
virtual void updateBuffer(uint32 binding, PUniformBuffer uniformBuffer) = 0;
|
||||||
virtual void updateBuffer(uint32 binding, PShaderBuffer ShaderBuffer) = 0;
|
virtual void updateBuffer(uint32 binding, PShaderBuffer ShaderBuffer) = 0;
|
||||||
virtual void updateBuffer(uint32_t binding, uint32 index, Gfx::PShaderBuffer uniformBuffer) = 0;
|
virtual void updateBuffer(uint32_t binding, uint32 index,
|
||||||
|
Gfx::PShaderBuffer uniformBuffer) = 0;
|
||||||
virtual void updateSampler(uint32 binding, PSampler sampler) = 0;
|
virtual void updateSampler(uint32 binding, PSampler sampler) = 0;
|
||||||
virtual void updateTexture(uint32 binding, PTexture texture, PSampler samplerState = nullptr) = 0;
|
virtual void updateTexture(uint32 binding, PTexture texture,
|
||||||
virtual void updateTextureArray(uint32_t binding, Array<PTexture> texture) = 0;
|
PSampler samplerState = nullptr) = 0;
|
||||||
|
virtual void updateTextureArray(uint32_t binding,
|
||||||
|
Array<PTexture> texture) = 0;
|
||||||
bool operator<(PDescriptorSet other);
|
bool operator<(PDescriptorSet other);
|
||||||
|
|
||||||
constexpr PDescriptorLayout getLayout() const { return layout; }
|
constexpr PDescriptorLayout getLayout() const { return layout; }
|
||||||
constexpr const std::string& getName() const { return layout->getName(); }
|
constexpr const std::string &getName() const { return layout->getName(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PDescriptorLayout layout;
|
PDescriptorLayout layout;
|
||||||
};
|
};
|
||||||
DEFINE_REF(DescriptorSet)
|
DEFINE_REF(DescriptorSet)
|
||||||
|
|
||||||
|
DECLARE_REF(PipelineLayout)
|
||||||
class PipelineLayout {
|
class PipelineLayout {
|
||||||
public:
|
public:
|
||||||
PipelineLayout(const std::string& name);
|
PipelineLayout(const std::string &name);
|
||||||
PipelineLayout(const std::string& name, PPipelineLayout baseLayout);
|
PipelineLayout(const std::string &name, PPipelineLayout baseLayout);
|
||||||
virtual ~PipelineLayout();
|
virtual ~PipelineLayout();
|
||||||
virtual void create() = 0;
|
virtual void create() = 0;
|
||||||
void addDescriptorLayout(PDescriptorLayout layout);
|
void addDescriptorLayout(PDescriptorLayout layout);
|
||||||
void addPushConstants(const SePushConstantRange& pushConstants);
|
void addPushConstants(const SePushConstantRange &pushConstants);
|
||||||
constexpr uint32 getHash() const { return layoutHash; }
|
constexpr uint32 getHash() const { return layoutHash; }
|
||||||
constexpr const Map<std::string, PDescriptorLayout>& getLayouts() const { return descriptorSetLayouts; }
|
constexpr const Map<std::string, PDescriptorLayout> &getLayouts() const {
|
||||||
constexpr uint32 findParameter(const std::string& param) const { return parameterMapping[param]; }
|
return descriptorSetLayouts;
|
||||||
void addMapping(Map<std::string, uint32> mapping);
|
}
|
||||||
constexpr std::string getName() const {return name;};
|
constexpr uint32 findParameter(const std::string ¶m) const {
|
||||||
|
return parameterMapping[param];
|
||||||
|
}
|
||||||
|
void addMapping(Map<std::string, uint32> mapping);
|
||||||
|
constexpr std::string getName() const { return name; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32 layoutHash = 0;
|
uint32 layoutHash = 0;
|
||||||
Map<std::string, PDescriptorLayout> descriptorSetLayouts;
|
Map<std::string, PDescriptorLayout> descriptorSetLayouts;
|
||||||
Map<std::string, uint32> parameterMapping;
|
Map<std::string, uint32> parameterMapping;
|
||||||
Array<SePushConstantRange> pushConstants;
|
Array<SePushConstantRange> pushConstants;
|
||||||
std::string name;
|
std::string name;
|
||||||
};
|
};
|
||||||
DEFINE_REF(PipelineLayout)
|
DEFINE_REF(PipelineLayout)
|
||||||
} // namespace Gfx
|
} // namespace Gfx
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ DECLARE_REF(GraphicsPipeline)
|
|||||||
DECLARE_REF(ComputePipeline)
|
DECLARE_REF(ComputePipeline)
|
||||||
DECLARE_REF(RenderCommand)
|
DECLARE_REF(RenderCommand)
|
||||||
DECLARE_REF(ComputeCommand)
|
DECLARE_REF(ComputeCommand)
|
||||||
|
DECLARE_REF(BottomLevelAS)
|
||||||
|
DECLARE_REF(TopLevelAS)
|
||||||
class Graphics
|
class Graphics
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -88,6 +90,10 @@ public:
|
|||||||
virtual void resolveTexture(Gfx::PTexture source, Gfx::PTexture destination) = 0;
|
virtual void resolveTexture(Gfx::PTexture source, Gfx::PTexture destination) = 0;
|
||||||
|
|
||||||
bool supportMeshShading() const { return meshShadingEnabled; }
|
bool supportMeshShading() const { return meshShadingEnabled; }
|
||||||
|
|
||||||
|
// Ray Tracing
|
||||||
|
virtual OBottomLevelAS createBottomLevelAccelerationStructure(const BottomLevelASCreateInfo& createInfo) = 0;
|
||||||
|
virtual OTopLevelAS createTopLevelAccelerationStructure(const TopLevelASCreateInfo& createInfo) = 0;
|
||||||
protected:
|
protected:
|
||||||
QueueFamilyMapping queueMapping;
|
QueueFamilyMapping queueMapping;
|
||||||
OShaderCompiler shaderCompiler;
|
OShaderCompiler shaderCompiler;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
#include "Containers/Map.h"
|
#include "Containers/Map.h"
|
||||||
#include "Math/Math.h"
|
#include "Math/Math.h"
|
||||||
|
#include "MinimalEngine.h"
|
||||||
|
#include "MeshData.h"
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
@@ -113,6 +115,7 @@ namespace Seele
|
|||||||
DataSource sourceData = DataSource();
|
DataSource sourceData = DataSource();
|
||||||
uint64 numElements = 1;
|
uint64 numElements = 1;
|
||||||
uint8 dynamic = 0;
|
uint8 dynamic = 0;
|
||||||
|
uint8 vertexBuffer = 0;
|
||||||
std::string name = "Unnamed";
|
std::string name = "Unnamed";
|
||||||
};
|
};
|
||||||
DECLARE_NAME_REF(Gfx, PipelineLayout)
|
DECLARE_NAME_REF(Gfx, PipelineLayout)
|
||||||
@@ -144,6 +147,7 @@ namespace Seele
|
|||||||
Array<VertexInputBinding> bindings;
|
Array<VertexInputBinding> bindings;
|
||||||
Array<VertexInputAttribute> attributes;
|
Array<VertexInputAttribute> attributes;
|
||||||
};
|
};
|
||||||
|
DECLARE_REF(MaterialInstance)
|
||||||
namespace Gfx
|
namespace Gfx
|
||||||
{
|
{
|
||||||
struct SePushConstantRange
|
struct SePushConstantRange
|
||||||
@@ -244,5 +248,19 @@ namespace Seele
|
|||||||
Gfx::PComputeShader computeShader = nullptr;
|
Gfx::PComputeShader computeShader = nullptr;
|
||||||
Gfx::PPipelineLayout pipelineLayout = nullptr;
|
Gfx::PPipelineLayout pipelineLayout = nullptr;
|
||||||
};
|
};
|
||||||
|
DECLARE_REF(ShaderBuffer)
|
||||||
|
struct BottomLevelASCreateInfo
|
||||||
|
{
|
||||||
|
PShaderBuffer positionBuffer;
|
||||||
|
PShaderBuffer indexBuffer;
|
||||||
|
MeshData meshData;
|
||||||
|
PMaterialInstance material;
|
||||||
|
uint64 verticesOffset;
|
||||||
|
uint64 indicesOffset;
|
||||||
|
};
|
||||||
|
struct TopLevelASCreateInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
} // namespace Gfx
|
} // namespace Gfx
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Math/AABB.h"
|
||||||
|
namespace Seele
|
||||||
|
{
|
||||||
|
struct MeshData
|
||||||
|
{
|
||||||
|
AABB bounding;
|
||||||
|
uint32 numMeshlets = 0;
|
||||||
|
uint32 meshletOffset = 0;
|
||||||
|
uint32 firstIndex = 0;
|
||||||
|
uint32 numIndices = 0;
|
||||||
|
};
|
||||||
|
struct InstanceData
|
||||||
|
{
|
||||||
|
Matrix4 transformMatrix;
|
||||||
|
Matrix4 inverseTransformMatrix;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#include "RayTracing.h"
|
||||||
|
|
||||||
|
using namespace Seele::Gfx;
|
||||||
|
|
||||||
|
BottomLevelAS::BottomLevelAS()
|
||||||
|
{}
|
||||||
|
|
||||||
|
BottomLevelAS::~BottomLevelAS()
|
||||||
|
{}
|
||||||
|
|
||||||
|
TopLevelAS::TopLevelAS()
|
||||||
|
{}
|
||||||
|
|
||||||
|
TopLevelAS::~TopLevelAS()
|
||||||
|
{}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Resources.h"
|
||||||
|
|
||||||
|
namespace Seele
|
||||||
|
{
|
||||||
|
namespace Gfx
|
||||||
|
{
|
||||||
|
class BottomLevelAS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BottomLevelAS();
|
||||||
|
~BottomLevelAS();
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
DEFINE_REF(BottomLevelAS)
|
||||||
|
class TopLevelAS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TopLevelAS();
|
||||||
|
~TopLevelAS();
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
DEFINE_REF(TopLevelAS)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,16 @@ namespace Seele
|
|||||||
{
|
{
|
||||||
class RayTracingPass : public RenderPass
|
class RayTracingPass : public RenderPass
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
RayTracingPass(Gfx::PGraphics graphics, PScene scene);
|
||||||
|
RayTracingPass(RayTracingPass&& other) = default;
|
||||||
|
RayTracingPass& operator=(RayTracingPass&& other) = default;
|
||||||
|
virtual void beginFrame(const Component::Camera& cam) override;
|
||||||
|
virtual void render() override;
|
||||||
|
virtual void endFrame() override;
|
||||||
|
virtual void publishOutputs() override;
|
||||||
|
virtual void createRenderPass() override;
|
||||||
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,6 @@
|
|||||||
#include "Math/Math.h"
|
#include "Math/Math.h"
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
#include "Containers/Array.h"
|
#include "Containers/Array.h"
|
||||||
#include "Containers/List.h"
|
|
||||||
#include "Initializer.h"
|
|
||||||
#include "Descriptor.h"
|
|
||||||
#include "CRC.h"
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef ENABLE_VALIDATION
|
#ifndef ENABLE_VALIDATION
|
||||||
#define ENABLE_VALIDATION 1
|
#define ENABLE_VALIDATION 1
|
||||||
|
|||||||
@@ -201,9 +201,11 @@ void StaticMeshVertexData::resizeBuffers()
|
|||||||
},
|
},
|
||||||
.numElements = verticesAllocated * 3,
|
.numElements = verticesAllocated * 3,
|
||||||
.dynamic = false,
|
.dynamic = false,
|
||||||
|
.vertexBuffer = 1,
|
||||||
.name = "Positions",
|
.name = "Positions",
|
||||||
};
|
};
|
||||||
positions = graphics->createShaderBuffer(createInfo);
|
positions = graphics->createShaderBuffer(createInfo);
|
||||||
|
createInfo.vertexBuffer = false;
|
||||||
createInfo.name = "Normals";
|
createInfo.name = "Normals";
|
||||||
normals = graphics->createShaderBuffer(createInfo);
|
normals = graphics->createShaderBuffer(createInfo);
|
||||||
createInfo.name = "Tangents";
|
createInfo.name = "Tangents";
|
||||||
|
|||||||
@@ -4,10 +4,9 @@
|
|||||||
#include "Material/Material.h"
|
#include "Material/Material.h"
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
#include "Graphics/Descriptor.h"
|
#include "Graphics/Descriptor.h"
|
||||||
#include "Component/Mesh.h"
|
|
||||||
#include "Graphics/Shader.h"
|
#include "Graphics/Shader.h"
|
||||||
#include "Graphics/Mesh.h"
|
#include "Graphics/Mesh.h"
|
||||||
#include "Containers/Set.h"
|
#include "Material/MaterialInstance.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|
||||||
@@ -114,7 +113,6 @@ void VertexData::createDescriptors()
|
|||||||
instanceData.clear();
|
instanceData.clear();
|
||||||
instanceMeshData.clear();
|
instanceMeshData.clear();
|
||||||
|
|
||||||
uint32 numMeshlets = 0;
|
|
||||||
Array<uint32> cullingOffsets;
|
Array<uint32> cullingOffsets;
|
||||||
for (auto &mat : materialData)
|
for (auto &mat : materialData)
|
||||||
{
|
{
|
||||||
@@ -130,7 +128,6 @@ void VertexData::createDescriptors()
|
|||||||
instanceMeshData.add(instance.instanceMeshData[i]);
|
instanceMeshData.add(instance.instanceMeshData[i]);
|
||||||
// instance.numMeshlets += instance.instanceMeshData[i].numMeshlets;
|
// instance.numMeshlets += instance.instanceMeshData[i].numMeshlets;
|
||||||
// cullingOffsets.add(numMeshlets);
|
// cullingOffsets.add(numMeshlets);
|
||||||
numMeshlets += instance.instanceMeshData[i].numMeshlets;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+120
-141
@@ -1,156 +1,135 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Graphics/Initializer.h"
|
|
||||||
#include "Material/MaterialInstance.h"
|
|
||||||
#include "Component/Transform.h"
|
#include "Component/Transform.h"
|
||||||
#include "Containers/List.h"
|
#include "Containers/List.h"
|
||||||
|
#include "Graphics/Buffer.h"
|
||||||
#include "Graphics/Command.h"
|
#include "Graphics/Command.h"
|
||||||
#include "Graphics/Descriptor.h"
|
#include "Graphics/Descriptor.h"
|
||||||
#include "Graphics/Buffer.h"
|
#include "MeshData.h"
|
||||||
#include "Meshlet.h"
|
#include "Meshlet.h"
|
||||||
#include <entt/entt.hpp>
|
#include <entt/entt.hpp>
|
||||||
|
|
||||||
|
|
||||||
constexpr uint64 MAX_TEXCOORDS = 8;
|
constexpr uint64 MAX_TEXCOORDS = 8;
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele {
|
||||||
{
|
DECLARE_REF(MaterialInstance)
|
||||||
DECLARE_REF(Mesh)
|
DECLARE_REF(Mesh)
|
||||||
struct MeshId
|
struct MeshId {
|
||||||
{
|
uint64 id;
|
||||||
uint64 id;
|
std::strong_ordering operator<=>(const MeshId &other) const {
|
||||||
std::strong_ordering operator<=>(const MeshId &other) const
|
return id <=> other.id;
|
||||||
{
|
}
|
||||||
return id <=> other.id;
|
bool operator==(const MeshId &other) const { return id == other.id; }
|
||||||
}
|
};
|
||||||
bool operator==(const MeshId &other) const
|
class VertexData {
|
||||||
{
|
public:
|
||||||
return id == other.id;
|
struct DrawCallOffsets {
|
||||||
}
|
uint32 instanceOffset = 0;
|
||||||
};
|
};
|
||||||
class VertexData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct InstanceData
|
|
||||||
{
|
|
||||||
Matrix4 transformMatrix;
|
|
||||||
Matrix4 inverseTransformMatrix;
|
|
||||||
};
|
|
||||||
struct MeshData
|
|
||||||
{
|
|
||||||
AABB bounding;
|
|
||||||
uint32 numMeshlets = 0;
|
|
||||||
uint32 meshletOffset = 0;
|
|
||||||
uint32 firstIndex = 0;
|
|
||||||
uint32 numIndices = 0;
|
|
||||||
};
|
|
||||||
struct DrawCallOffsets
|
|
||||||
{
|
|
||||||
uint32 instanceOffset = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MeshletCullingInfo
|
struct MeshletCullingInfo {
|
||||||
{
|
uint64_t cull[256 / 64];
|
||||||
uint64_t cull[256 / 64];
|
};
|
||||||
};
|
struct BatchedDrawCall {
|
||||||
struct BatchedDrawCall
|
PMaterialInstance materialInstance;
|
||||||
{
|
DrawCallOffsets offsets;
|
||||||
PMaterialInstance materialInstance;
|
|
||||||
DrawCallOffsets offsets;
|
|
||||||
Array<InstanceData> instanceData;
|
|
||||||
Array<MeshData> instanceMeshData;
|
|
||||||
Array<uint32> cullingOffsets;
|
|
||||||
};
|
|
||||||
struct MaterialData
|
|
||||||
{
|
|
||||||
PMaterial material;
|
|
||||||
Array<BatchedDrawCall> instances;
|
|
||||||
};
|
|
||||||
void resetMeshData();
|
|
||||||
void updateMesh(entt::entity id, uint32 meshIndex, PMesh mesh, Component::Transform &transform);
|
|
||||||
void createDescriptors();
|
|
||||||
void loadMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
|
|
||||||
MeshId allocateVertexData(uint64 numVertices);
|
|
||||||
uint64 getMeshOffset(MeshId id);
|
|
||||||
uint64 getMeshVertexCount(MeshId id);
|
|
||||||
virtual void serializeMesh(MeshId id, uint64 numVertices, ArchiveBuffer &buffer) = 0;
|
|
||||||
virtual void deserializeMesh(MeshId id, ArchiveBuffer &buffer) = 0;
|
|
||||||
virtual void bindBuffers(Gfx::PRenderCommand command) = 0;
|
|
||||||
virtual Gfx::PDescriptorLayout getVertexDataLayout() = 0;
|
|
||||||
virtual Gfx::PDescriptorSet getVertexDataSet() = 0;
|
|
||||||
virtual std::string getTypeName() const = 0;
|
|
||||||
Gfx::PIndexBuffer getIndexBuffer() { return indexBuffer; }
|
|
||||||
Gfx::PDescriptorLayout getInstanceDataLayout() { return instanceDataLayout; }
|
|
||||||
Gfx::PDescriptorSet getInstanceDataSet() { return descriptorSet; }
|
|
||||||
const Array<MaterialData> &getMaterialData() const { return materialData; }
|
|
||||||
const MeshData &getMeshData(MeshId id) { return meshData[id]; }
|
|
||||||
uint64 getIndicesOffset(uint32 meshletIndex) { return meshlets[meshletIndex].indicesOffset; }
|
|
||||||
uint64 getNumInstances() const { return instanceData.size(); }
|
|
||||||
static List<VertexData *> getList();
|
|
||||||
static VertexData *findByTypeName(std::string name);
|
|
||||||
virtual void init(Gfx::PGraphics graphics);
|
|
||||||
virtual void destroy();
|
|
||||||
|
|
||||||
struct CullingMapping
|
|
||||||
{
|
|
||||||
uint64 instanceId;
|
|
||||||
uint32 cullingOffset;
|
|
||||||
};
|
|
||||||
static CullingMapping getCullingMapping(entt::entity id, uint32 meshIndex, uint32 numMeshlets);
|
|
||||||
static uint64 getInstanceCount() { return instanceCount; }
|
|
||||||
static uint64 getMeshletCount() { return meshletCount; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void resizeBuffers() = 0;
|
|
||||||
virtual void updateBuffers() = 0;
|
|
||||||
VertexData();
|
|
||||||
struct MeshletDescription
|
|
||||||
{
|
|
||||||
AABB bounding;
|
|
||||||
uint32 vertexCount;
|
|
||||||
uint32 primitiveCount;
|
|
||||||
uint32 vertexOffset;
|
|
||||||
uint32 primitiveOffset;
|
|
||||||
Vector color;
|
|
||||||
uint32 indicesOffset = 0;
|
|
||||||
};
|
|
||||||
std::mutex materialDataLock;
|
|
||||||
Array<MaterialData> materialData;
|
|
||||||
std::mutex vertexDataLock;
|
|
||||||
Map<MeshId, MeshData> meshData;
|
|
||||||
Map<MeshId, uint64> meshOffsets;
|
|
||||||
Map<MeshId, uint64> meshVertexCounts;
|
|
||||||
Array<MeshletDescription> meshlets;
|
|
||||||
Array<uint8> primitiveIndices;
|
|
||||||
Array<uint32> vertexIndices;
|
|
||||||
Array<uint32> indices;
|
|
||||||
|
|
||||||
struct MeshMapping
|
|
||||||
{
|
|
||||||
entt::entity id;
|
|
||||||
uint32 meshId;
|
|
||||||
auto operator<=>(const MeshMapping& other) const = default;
|
|
||||||
};
|
|
||||||
static Map<MeshMapping, CullingMapping> instanceIdMap;
|
|
||||||
static uint64 instanceCount;
|
|
||||||
static uint64 meshletCount;
|
|
||||||
|
|
||||||
Gfx::PGraphics graphics;
|
|
||||||
Gfx::ODescriptorLayout instanceDataLayout;
|
|
||||||
// for mesh shading
|
|
||||||
Gfx::OShaderBuffer meshletBuffer;
|
|
||||||
Gfx::OShaderBuffer vertexIndicesBuffer;
|
|
||||||
Gfx::OShaderBuffer primitiveIndicesBuffer;
|
|
||||||
Gfx::OShaderBuffer cullingOffsetBuffer;
|
|
||||||
// for legacy pipeline
|
|
||||||
Gfx::OIndexBuffer indexBuffer;
|
|
||||||
// Material data
|
|
||||||
Array<InstanceData> instanceData;
|
Array<InstanceData> instanceData;
|
||||||
Gfx::OShaderBuffer instanceBuffer;
|
|
||||||
Array<MeshData> instanceMeshData;
|
Array<MeshData> instanceMeshData;
|
||||||
Gfx::OShaderBuffer instanceMeshDataBuffer;
|
Array<uint32> cullingOffsets;
|
||||||
Gfx::PDescriptorSet descriptorSet;
|
|
||||||
uint64 idCounter;
|
|
||||||
uint64 head;
|
|
||||||
uint64 verticesAllocated;
|
|
||||||
bool dirty;
|
|
||||||
};
|
};
|
||||||
}
|
struct MaterialData {
|
||||||
|
PMaterial material;
|
||||||
|
Array<BatchedDrawCall> instances;
|
||||||
|
};
|
||||||
|
void resetMeshData();
|
||||||
|
void updateMesh(entt::entity id, uint32 meshIndex, PMesh mesh,
|
||||||
|
Component::Transform &transform);
|
||||||
|
void createDescriptors();
|
||||||
|
void loadMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
|
||||||
|
MeshId allocateVertexData(uint64 numVertices);
|
||||||
|
uint64 getMeshOffset(MeshId id);
|
||||||
|
uint64 getMeshVertexCount(MeshId id);
|
||||||
|
virtual void serializeMesh(MeshId id, uint64 numVertices,
|
||||||
|
ArchiveBuffer &buffer) = 0;
|
||||||
|
virtual void deserializeMesh(MeshId id, ArchiveBuffer &buffer) = 0;
|
||||||
|
virtual void bindBuffers(Gfx::PRenderCommand command) = 0;
|
||||||
|
virtual Gfx::PDescriptorLayout getVertexDataLayout() = 0;
|
||||||
|
virtual Gfx::PDescriptorSet getVertexDataSet() = 0;
|
||||||
|
virtual std::string getTypeName() const = 0;
|
||||||
|
Gfx::PIndexBuffer getIndexBuffer() { return indexBuffer; }
|
||||||
|
Gfx::PDescriptorLayout getInstanceDataLayout() { return instanceDataLayout; }
|
||||||
|
Gfx::PDescriptorSet getInstanceDataSet() { return descriptorSet; }
|
||||||
|
const Array<MaterialData> &getMaterialData() const { return materialData; }
|
||||||
|
const MeshData &getMeshData(MeshId id) { return meshData[id]; }
|
||||||
|
uint64 getIndicesOffset(uint32 meshletIndex) {
|
||||||
|
return meshlets[meshletIndex].indicesOffset;
|
||||||
|
}
|
||||||
|
uint64 getNumInstances() const { return instanceData.size(); }
|
||||||
|
static List<VertexData *> getList();
|
||||||
|
static VertexData *findByTypeName(std::string name);
|
||||||
|
virtual void init(Gfx::PGraphics graphics);
|
||||||
|
virtual void destroy();
|
||||||
|
|
||||||
|
struct CullingMapping {
|
||||||
|
uint64 instanceId;
|
||||||
|
uint32 cullingOffset;
|
||||||
|
};
|
||||||
|
static CullingMapping getCullingMapping(entt::entity id, uint32 meshIndex,
|
||||||
|
uint32 numMeshlets);
|
||||||
|
static uint64 getInstanceCount() { return instanceCount; }
|
||||||
|
static uint64 getMeshletCount() { return meshletCount; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void resizeBuffers() = 0;
|
||||||
|
virtual void updateBuffers() = 0;
|
||||||
|
VertexData();
|
||||||
|
struct MeshletDescription {
|
||||||
|
AABB bounding;
|
||||||
|
uint32 vertexCount;
|
||||||
|
uint32 primitiveCount;
|
||||||
|
uint32 vertexOffset;
|
||||||
|
uint32 primitiveOffset;
|
||||||
|
Vector color;
|
||||||
|
uint32 indicesOffset = 0;
|
||||||
|
};
|
||||||
|
std::mutex materialDataLock;
|
||||||
|
Array<MaterialData> materialData;
|
||||||
|
std::mutex vertexDataLock;
|
||||||
|
Map<MeshId, MeshData> meshData;
|
||||||
|
Map<MeshId, uint64> meshOffsets;
|
||||||
|
Map<MeshId, uint64> meshVertexCounts;
|
||||||
|
Array<MeshletDescription> meshlets;
|
||||||
|
Array<uint8> primitiveIndices;
|
||||||
|
Array<uint32> vertexIndices;
|
||||||
|
Array<uint32> indices;
|
||||||
|
|
||||||
|
struct MeshMapping {
|
||||||
|
entt::entity id;
|
||||||
|
uint32 meshId;
|
||||||
|
auto operator<=>(const MeshMapping &other) const = default;
|
||||||
|
};
|
||||||
|
static Map<MeshMapping, CullingMapping> instanceIdMap;
|
||||||
|
static uint64 instanceCount;
|
||||||
|
static uint64 meshletCount;
|
||||||
|
|
||||||
|
Gfx::PGraphics graphics;
|
||||||
|
Gfx::ODescriptorLayout instanceDataLayout;
|
||||||
|
// for mesh shading
|
||||||
|
Gfx::OShaderBuffer meshletBuffer;
|
||||||
|
Gfx::OShaderBuffer vertexIndicesBuffer;
|
||||||
|
Gfx::OShaderBuffer primitiveIndicesBuffer;
|
||||||
|
Gfx::OShaderBuffer cullingOffsetBuffer;
|
||||||
|
// for legacy pipeline
|
||||||
|
Gfx::OIndexBuffer indexBuffer;
|
||||||
|
// Material data
|
||||||
|
Array<InstanceData> instanceData;
|
||||||
|
Gfx::OShaderBuffer instanceBuffer;
|
||||||
|
Array<MeshData> instanceMeshData;
|
||||||
|
Gfx::OShaderBuffer instanceMeshDataBuffer;
|
||||||
|
Gfx::PDescriptorSet descriptorSet;
|
||||||
|
uint64 idCounter;
|
||||||
|
uint64 head;
|
||||||
|
uint64 verticesAllocated;
|
||||||
|
bool dirty;
|
||||||
|
};
|
||||||
|
} // namespace Seele
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@ public:
|
|||||||
VmaAllocationInfo info = VmaAllocationInfo();
|
VmaAllocationInfo info = VmaAllocationInfo();
|
||||||
VkMemoryPropertyFlags properties = 0;
|
VkMemoryPropertyFlags properties = 0;
|
||||||
uint64 size = 0;
|
uint64 size = 0;
|
||||||
|
VkDeviceAddress deviceAddress;
|
||||||
};
|
};
|
||||||
DEFINE_REF(BufferAllocation);
|
DEFINE_REF(BufferAllocation);
|
||||||
class Buffer {
|
class Buffer {
|
||||||
@@ -24,6 +25,9 @@ public:
|
|||||||
Gfx::QueueType &queueType, bool dynamic, std::string name);
|
Gfx::QueueType &queueType, bool dynamic, std::string name);
|
||||||
virtual ~Buffer();
|
virtual ~Buffer();
|
||||||
VkBuffer getHandle() const { return buffers[currentBuffer]->buffer; }
|
VkBuffer getHandle() const { return buffers[currentBuffer]->buffer; }
|
||||||
|
VkDeviceAddress getDeviceAddress() const {
|
||||||
|
return buffers[currentBuffer]->deviceAddress;
|
||||||
|
}
|
||||||
PBufferAllocation getAlloc() const { return buffers[currentBuffer]; }
|
PBufferAllocation getAlloc() const { return buffers[currentBuffer]; }
|
||||||
uint64 getSize() const { return buffers[currentBuffer]->size; }
|
uint64 getSize() const { return buffers[currentBuffer]->size; }
|
||||||
void *map(bool writeOnly = true);
|
void *map(bool writeOnly = true);
|
||||||
@@ -130,7 +134,8 @@ public:
|
|||||||
virtual ~ShaderBuffer();
|
virtual ~ShaderBuffer();
|
||||||
virtual void
|
virtual void
|
||||||
updateContents(const ShaderBufferCreateInfo &createInfo) override;
|
updateContents(const ShaderBufferCreateInfo &createInfo) override;
|
||||||
virtual void rotateBuffer(uint64 size, bool preserveContents = false) override;
|
virtual void rotateBuffer(uint64 size,
|
||||||
|
bool preserveContents = false) override;
|
||||||
virtual void *mapRegion(uint64 offset, uint64 size, bool writeOnly) override;
|
virtual void *mapRegion(uint64 offset, uint64 size, bool writeOnly) override;
|
||||||
virtual void unmap() override;
|
virtual void unmap() override;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ target_sources(Engine
|
|||||||
PipelineCache.cpp
|
PipelineCache.cpp
|
||||||
Queue.h
|
Queue.h
|
||||||
Queue.cpp
|
Queue.cpp
|
||||||
|
RayTracing.h
|
||||||
|
RayTracing.cpp
|
||||||
RenderPass.h
|
RenderPass.h
|
||||||
RenderPass.cpp
|
RenderPass.cpp
|
||||||
Resources.h
|
Resources.h
|
||||||
@@ -47,6 +49,7 @@ target_sources(Engine
|
|||||||
Pipeline.h
|
Pipeline.h
|
||||||
PipelineCache.h
|
PipelineCache.h
|
||||||
Queue.h
|
Queue.h
|
||||||
|
RayTracing.h
|
||||||
RenderPass.h
|
RenderPass.h
|
||||||
Resources.h
|
Resources.h
|
||||||
Shader.h
|
Shader.h
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
#include "CRC.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "RenderPass.h"
|
#include "RenderPass.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
#include "CRC.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include "Allocator.h"
|
#include "Allocator.h"
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "Graphics/Enums.h"
|
#include "Graphics/Enums.h"
|
||||||
|
#include "Graphics/Graphics.h"
|
||||||
|
#include "Graphics/Initializer.h"
|
||||||
#include "PipelineCache.h"
|
#include "PipelineCache.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "Descriptor.h"
|
#include "Descriptor.h"
|
||||||
@@ -10,6 +12,7 @@
|
|||||||
#include "RenderPass.h"
|
#include "RenderPass.h"
|
||||||
#include "Framebuffer.h"
|
#include "Framebuffer.h"
|
||||||
#include "Shader.h"
|
#include "Shader.h"
|
||||||
|
#include "RayTracing.h"
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
@@ -291,14 +294,24 @@ void Graphics::resolveTexture(Gfx::PTexture source, Gfx::PTexture destination)
|
|||||||
vkCmdResolveImage(getGraphicsCommands()->getCommands()->getHandle(), sourceTex->getImage(), cast(sourceTex->getLayout()), destinationTex->getImage(), cast(destinationTex->getLayout()), 1, &resolve);
|
vkCmdResolveImage(getGraphicsCommands()->getCommands()->getHandle(), sourceTex->getImage(), cast(sourceTex->getLayout()), destinationTex->getImage(), cast(destinationTex->getLayout()), 1, &resolve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::vkCmdDrawMeshTasksEXT(VkCommandBuffer handle, uint32 groupX, uint32 groupY, uint32 groupZ)
|
Gfx::OBottomLevelAS Graphics::createBottomLevelAccelerationStructure(const Gfx::BottomLevelASCreateInfo& createInfo)
|
||||||
{
|
{
|
||||||
cmdDrawMeshTasks(handle, groupX, groupY, groupZ);
|
return new BottomLevelAS(this, createInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::vkCmdDrawMeshTasksIndirectEXT(VkCommandBuffer handle, VkBuffer buffer, uint64 offset, uint32 drawCount, uint32 stride)
|
Gfx::OTopLevelAS Graphics::createTopLevelAccelerationStructure(const Gfx::TopLevelASCreateInfo& createInfo)
|
||||||
{
|
{
|
||||||
cmdDrawMeshTasksIndirect(handle, buffer, offset, drawCount, stride);
|
return new TopLevelAS(this, createInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Graphics::vkCmdDrawMeshTasksEXT(VkCommandBuffer cmd, uint32 groupX, uint32 groupY, uint32 groupZ)
|
||||||
|
{
|
||||||
|
cmdDrawMeshTasks(cmd, groupX, groupY, groupZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Graphics::vkCmdDrawMeshTasksIndirectEXT(VkCommandBuffer cmd, VkBuffer buffer, uint64 offset, uint32 drawCount, uint32 stride)
|
||||||
|
{
|
||||||
|
cmdDrawMeshTasksIndirect(cmd, buffer, offset, drawCount, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::vkSetDebugUtilsObjectNameEXT(VkDebugUtilsObjectNameInfoEXT* info)
|
void Graphics::vkSetDebugUtilsObjectNameEXT(VkDebugUtilsObjectNameInfoEXT* info)
|
||||||
@@ -395,6 +408,7 @@ void Graphics::initInstance(GraphicsInitializer initInfo)
|
|||||||
assert(glfwVulkanSupported());
|
assert(glfwVulkanSupported());
|
||||||
VkApplicationInfo appInfo = {
|
VkApplicationInfo appInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
.pApplicationName = initInfo.applicationName,
|
.pApplicationName = initInfo.applicationName,
|
||||||
.applicationVersion = VK_MAKE_VERSION(0, 0, 1),
|
.applicationVersion = VK_MAKE_VERSION(0, 0, 1),
|
||||||
.pEngineName = initInfo.engineName,
|
.pEngineName = initInfo.engineName,
|
||||||
@@ -415,6 +429,7 @@ void Graphics::initInstance(GraphicsInitializer initInfo)
|
|||||||
#endif
|
#endif
|
||||||
VkInstanceCreateInfo info = {
|
VkInstanceCreateInfo info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
.flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR,
|
.flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR,
|
||||||
#endif
|
#endif
|
||||||
@@ -562,6 +577,7 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
|||||||
.flags = 0,
|
.flags = 0,
|
||||||
.queueFamilyIndex = familyIndex,
|
.queueFamilyIndex = familyIndex,
|
||||||
.queueCount = numQueuesForFamily,
|
.queueCount = numQueuesForFamily,
|
||||||
|
.pQueuePriorities = nullptr,
|
||||||
};
|
};
|
||||||
numPriorities += numQueuesForFamily;
|
numPriorities += numQueuesForFamily;
|
||||||
queueInfos.add(info);
|
queueInfos.add(info);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Enums.h"
|
|
||||||
#include "Graphics/Graphics.h"
|
#include "Graphics/Graphics.h"
|
||||||
#include <vk_mem_alloc.h>
|
#include <vk_mem_alloc.h>
|
||||||
|
|
||||||
@@ -70,6 +69,10 @@ public:
|
|||||||
|
|
||||||
virtual void resolveTexture(Gfx::PTexture source, Gfx::PTexture destination) override;
|
virtual void resolveTexture(Gfx::PTexture source, Gfx::PTexture destination) override;
|
||||||
|
|
||||||
|
// Ray Tracing
|
||||||
|
virtual Gfx::OBottomLevelAS createBottomLevelAccelerationStructure(const Gfx::BottomLevelASCreateInfo& createInfo) override;
|
||||||
|
virtual Gfx::OTopLevelAS createTopLevelAccelerationStructure(const Gfx::TopLevelASCreateInfo& createInfo) override;
|
||||||
|
|
||||||
void vkCmdDrawMeshTasksEXT(VkCommandBuffer handle, uint32 groupX, uint32 groupY, uint32 groupZ);
|
void vkCmdDrawMeshTasksEXT(VkCommandBuffer handle, uint32 groupX, uint32 groupY, uint32 groupZ);
|
||||||
void vkCmdDrawMeshTasksIndirectEXT(VkCommandBuffer handle, VkBuffer buffer, uint64 offset, uint32 drawCount, uint32 stride);
|
void vkCmdDrawMeshTasksIndirectEXT(VkCommandBuffer handle, VkBuffer buffer, uint64 offset, uint32 drawCount, uint32 stride);
|
||||||
void vkSetDebugUtilsObjectNameEXT(VkDebugUtilsObjectNameInfoEXT* info);
|
void vkSetDebugUtilsObjectNameEXT(VkDebugUtilsObjectNameInfoEXT* info);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
#include "Allocator.h"
|
#include "Allocator.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
#include "Enums.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
#include "RayTracing.h"
|
||||||
|
#include "Buffer.h"
|
||||||
|
#include "Graphics/Initializer.h"
|
||||||
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
|
using namespace Seele::Vulkan;
|
||||||
|
|
||||||
|
BottomLevelAS::BottomLevelAS(PGraphics graphics, const Gfx::BottomLevelASCreateInfo& createInfo)
|
||||||
|
{
|
||||||
|
VkDeviceOrHostAddressConstKHR vertexDataDeviceAddress = {
|
||||||
|
.deviceAddress = createInfo.positionBuffer.cast<Buffer>()->getDeviceAddress() + createInfo.verticesOffset,
|
||||||
|
};
|
||||||
|
VkDeviceOrHostAddressConstKHR indexDataDeviceAddress = {
|
||||||
|
.deviceAddress = createInfo.indexBuffer.cast<Buffer>()->getDeviceAddress() + createInfo.indicesOffset,
|
||||||
|
};
|
||||||
|
VkAccelerationStructureGeometryKHR accelerationStructureGeometry = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR,
|
||||||
|
.geometry = {.triangles = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.vertexFormat = VK_FORMAT_R32G32B32_SFLOAT,
|
||||||
|
.vertexData = vertexDataDeviceAddress,
|
||||||
|
.vertexStride = sizeof(Vector),
|
||||||
|
.maxVertex = createInfo.positionBuffer->getNumElements(),
|
||||||
|
.indexType = VK_INDEX_TYPE_UINT32,
|
||||||
|
.indexData = indexDataDeviceAddress,
|
||||||
|
}},
|
||||||
|
.flags = VK_GEOMETRY_OPAQUE_BIT_KHR,
|
||||||
|
};
|
||||||
|
|
||||||
|
VkAccelerationStructureBuildRangeInfoKHR buildRangeInfo = {
|
||||||
|
.primitiveCount = createInfo.meshData.numIndices / 3,
|
||||||
|
.primitiveOffset = 0,
|
||||||
|
.firstVertex = 0,
|
||||||
|
.transformOffset = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
VkAccelerationStructureBuildGeometryInfoKHR buildGeometry = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR,
|
||||||
|
.flags = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR,
|
||||||
|
};
|
||||||
|
|
||||||
|
VkAccelerationStructureCreateInfoKHR info = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.createFlags = 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
BottomLevelAS::~BottomLevelAS()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TopLevelAS::TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& createInfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TopLevelAS::~TopLevelAS()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Graphics/Initializer.h"
|
||||||
|
#include "Graphics.h"
|
||||||
|
#include "Graphics/RayTracing.h"
|
||||||
|
#include <vulkan/vulkan_core.h>
|
||||||
|
|
||||||
|
namespace Seele
|
||||||
|
{
|
||||||
|
namespace Vulkan
|
||||||
|
{
|
||||||
|
class BottomLevelAS : public Gfx::BottomLevelAS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BottomLevelAS(PGraphics graphics, const Gfx::BottomLevelASCreateInfo& createInfo);
|
||||||
|
~BottomLevelAS();
|
||||||
|
private:
|
||||||
|
PGraphics graphics;
|
||||||
|
VkAccelerationStructureKHR handle;
|
||||||
|
};
|
||||||
|
DEFINE_REF(BottomLevelAS)
|
||||||
|
class TopLevelAS : public Gfx::TopLevelAS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& createInfo);
|
||||||
|
~TopLevelAS();
|
||||||
|
private:
|
||||||
|
PGraphics graphics;
|
||||||
|
VkAccelerationStructureKHR handle;
|
||||||
|
};
|
||||||
|
DEFINE_REF(TopLevelAS)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
#include "CRC.h"
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::Vulkan;
|
using namespace Seele::Vulkan;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
#include "Enums.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Initializer.h"
|
#include "Initializer.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace Seele
|
namespace Seele
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user