Huge changes for 3d
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <sophia/types.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
// After Vulkan, which it expects to already be declared.
|
||||
#include <tracy/TracyVulkan.hpp>
|
||||
|
||||
#include "vulkan/access.hpp"
|
||||
#include "vulkan/image.hpp"
|
||||
@@ -31,7 +34,7 @@ using ClearColor = std::array<float, 4>;
|
||||
* buffer. Passes run in the order they were added; the graph's job is to
|
||||
* work out the barriers and layout transitions between them from what each
|
||||
* pass says it does to each image, and to begin/end rendering for passes that
|
||||
* write color attachments.
|
||||
* write color or depth attachments.
|
||||
*
|
||||
* Built fresh every frame:
|
||||
*
|
||||
@@ -53,7 +56,8 @@ class RenderGraph {
|
||||
using SetupFn = std::function<void(PassBuilder&)>;
|
||||
using ExecuteFn = std::function<void(vk::CommandBuffer)>;
|
||||
|
||||
RenderGraph() = default;
|
||||
explicit RenderGraph(TracyVkCtx tracyContext = nullptr)
|
||||
: tracyContext{tracyContext} {}
|
||||
|
||||
RenderGraph(const RenderGraph&) = delete;
|
||||
RenderGraph& operator=(const RenderGraph&) = delete;
|
||||
@@ -67,8 +71,8 @@ class RenderGraph {
|
||||
/**
|
||||
* Adds a pass. `setup` runs immediately and declares what the pass does to
|
||||
* images; `execute` runs later, from execute(), with the barriers already
|
||||
* recorded and (if the pass writes color) rendering begun. `name` labels
|
||||
* the pass's commands in debugging tools such as RenderDoc.
|
||||
* recorded and (if the pass writes color or depth) rendering begun. `name`
|
||||
* labels the pass's commands in debugging tools such as RenderDoc.
|
||||
*/
|
||||
void addPass(std::string name, const SetupFn& setup, ExecuteFn execute);
|
||||
|
||||
@@ -89,10 +93,17 @@ class RenderGraph {
|
||||
ClearColor clearColor;
|
||||
};
|
||||
|
||||
struct DepthAttachment {
|
||||
ImageRef image;
|
||||
vk::AttachmentLoadOp loadOp;
|
||||
float clearDepth;
|
||||
};
|
||||
|
||||
struct Pass {
|
||||
std::string name;
|
||||
std::vector<ImageUse> uses;
|
||||
std::vector<ColorAttachment> colorAttachments;
|
||||
std::optional<DepthAttachment> depthAttachment;
|
||||
ExecuteFn execute;
|
||||
};
|
||||
|
||||
@@ -113,6 +124,7 @@ class RenderGraph {
|
||||
void recordPass(vk::CommandBuffer commandBuffer, Pass& pass);
|
||||
void recordRendering(vk::CommandBuffer commandBuffer, Pass& pass);
|
||||
|
||||
TracyVkCtx tracyContext;
|
||||
std::vector<ImportedImage> images;
|
||||
std::vector<Pass> passes;
|
||||
};
|
||||
@@ -129,6 +141,15 @@ class RenderGraph::PassBuilder {
|
||||
vk::AttachmentLoadOp loadOp = vk::AttachmentLoadOp::eClear,
|
||||
ClearColor clearColor = {0.f, 0.f, 0.f, 1.f});
|
||||
|
||||
/**
|
||||
* Renders with `image` as the depth attachment, which must be the same size
|
||||
* as any color attachments. At most one per pass.
|
||||
*/
|
||||
PassBuilder& writeDepth(
|
||||
ImageRef image,
|
||||
vk::AttachmentLoadOp loadOp = vk::AttachmentLoadOp::eClear,
|
||||
float clearDepth = 1.f);
|
||||
|
||||
/** Samples `image` in a shader. */
|
||||
PassBuilder& sample(ImageRef image);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user