Files
Seele/src/Engine/Graphics/Vulkan/RayTracing.h
T

76 lines
2.3 KiB
C++
Raw Normal View History

2024-06-09 10:44:24 +02:00
#pragma once
2024-07-10 21:07:10 +02:00
#include "Buffer.h"
2024-06-09 10:44:24 +02:00
#include "Graphics.h"
2024-06-09 12:20:04 +02:00
#include "Graphics/Initializer.h"
2024-06-09 10:44:24 +02:00
#include "Graphics/RayTracing.h"
#include <vulkan/vulkan_core.h>
2024-06-09 12:20:04 +02:00
namespace Seele {
namespace Vulkan {
class BottomLevelAS : public Gfx::BottomLevelAS {
public:
2024-06-09 10:44:24 +02:00
BottomLevelAS(PGraphics graphics, const Gfx::BottomLevelASCreateInfo& createInfo);
~BottomLevelAS();
2024-07-10 21:07:10 +02:00
uint64 getDeviceAddress() const { return buffer->deviceAddress; }
2024-06-09 12:20:04 +02:00
private:
2024-06-09 10:44:24 +02:00
PGraphics graphics;
VkAccelerationStructureKHR handle;
2024-06-14 22:12:26 +02:00
OBufferAllocation buffer;
2024-07-08 13:46:49 +02:00
PMaterialInstance material;
2024-06-09 10:44:24 +02:00
};
DEFINE_REF(BottomLevelAS)
2024-06-09 12:20:04 +02:00
class TopLevelAS : public Gfx::TopLevelAS {
public:
2024-06-09 10:44:24 +02:00
TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& createInfo);
~TopLevelAS();
2024-07-10 21:07:10 +02:00
const VkAccelerationStructureKHR getHandle() const { return handle; }
2024-06-09 12:20:04 +02:00
private:
2024-06-09 10:44:24 +02:00
PGraphics graphics;
VkAccelerationStructureKHR handle;
2024-07-10 21:07:10 +02:00
OBufferAllocation instanceAllocation;
OBufferAllocation buffer;
2024-06-09 10:44:24 +02:00
};
DEFINE_REF(TopLevelAS)
2024-06-18 09:48:00 +02:00
2024-07-10 21:07:10 +02:00
class RayTracingPipeline : public Gfx::RayTracingPipeline {
2024-06-18 09:48:00 +02:00
public:
2024-07-10 21:07:10 +02:00
RayTracingPipeline(PGraphics graphics, VkPipeline handle, OBufferAllocation rayGen, uint64 rayGenStride, OBufferAllocation hit,
uint64 hitStride, OBufferAllocation miss, uint64 missStride, Gfx::PPipelineLayout layout);
2024-06-18 23:33:03 +02:00
virtual ~RayTracingPipeline();
2024-07-10 21:07:10 +02:00
void bind(VkCommandBuffer handle);
VkStridedDeviceAddressRegionKHR getRayGenRegion() {
return VkStridedDeviceAddressRegionKHR{
.deviceAddress = rayGen->deviceAddress,
.stride = rayGenStride,
.size = rayGen->size,
};
}
VkStridedDeviceAddressRegionKHR getHitRegion() {
return VkStridedDeviceAddressRegionKHR{
.deviceAddress = hit->deviceAddress,
.stride = hitStride,
.size = hit->size,
};
}
VkStridedDeviceAddressRegionKHR getMissRegion() {
return VkStridedDeviceAddressRegionKHR{
.deviceAddress = miss->deviceAddress,
.stride = missStride,
.size = miss->size,
};
}
2024-06-18 09:48:00 +02:00
private:
2024-06-18 23:33:03 +02:00
PGraphics graphics;
VkPipeline pipeline;
2024-07-10 21:07:10 +02:00
OBufferAllocation rayGen;
uint64 rayGenStride;
OBufferAllocation hit;
uint64 hitStride;
OBufferAllocation miss;
uint64 missStride;
2024-06-18 09:48:00 +02:00
};
DEFINE_REF(RayTracingPipeline)
2024-06-09 12:20:04 +02:00
} // namespace Vulkan
} // namespace Seele