Created
March 16, 2026 13:49
-
-
Save equalent/fa1155f43f246384831eaaa65f34da59 to your computer and use it in GitHub Desktop.
dump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include "Gpu/Types.h" | |
| #include "Pipeline.h" | |
| enum class FGAccess : uint8 | |
| { | |
| None = 0, | |
| Read = 1 << 0, | |
| Write = 1 << 1 | |
| }; | |
| ENUM_FLAGS(FGAccess); | |
| struct FGTextureBarrierState | |
| { | |
| Flags<GpuPipelineStage> stages; | |
| Flags<GpuAccess> access; | |
| GpuTextureLayout layout; | |
| GpuQueue queue; | |
| }; | |
| struct FGBufferBarrierState | |
| { | |
| Flags<GpuPipelineStage> stages; | |
| Flags<GpuAccess> access; | |
| GpuQueue queue; | |
| }; | |
| struct FGResource | |
| { | |
| // Resource index in FG | |
| uint32 idx; | |
| // Resource version, incremented on every write access. This is used to track resource dependencies and ensure correct synchronization. | |
| uint32 version; | |
| }; | |
| struct FGTexture : public FGResource | |
| { | |
| }; | |
| struct FGBuffer : public FGResource | |
| { | |
| }; | |
| // FG descriptor handle. Can be resolved to actual | |
| struct FGDescriptor | |
| { | |
| GpuDescriptorType type; | |
| // Descriptor index in FG | |
| uint32 idx; | |
| }; | |
| struct FGRenderEncoder : public GpuRenderEncoder | |
| { | |
| // ... | |
| }; | |
| struct FGComputeEncoder : public GpuComputeEncoder | |
| { | |
| // ... | |
| }; | |
| struct FGCopyEncoder : public GpuCommandEncoder | |
| { | |
| // ... | |
| }; | |
| struct FGPassContext | |
| { | |
| virtual uint getDescriptorIndex(FGDescriptor descriptor) = 0; | |
| }; | |
| struct FGRenderPassBuilder | |
| { | |
| // Adds a render target and returns the next version of the texture | |
| virtual FGTexture addRenderTarget( | |
| FGTexture texture, | |
| GpuTextureViewDimension viewDim = GpuTextureViewDimension::Texture2D, | |
| GpuPixelFormat viewFormat = GpuPixelFormat::Unknown, | |
| const GpuTextureSubresourceRange& viewSubresourceRange = {}, | |
| const GpuRenderPassBegin& begin, | |
| const GpuRenderPassEnd& end) = 0; | |
| // Adds a depth stencil and returns the next version of the texture | |
| virtual FGTexture addDepthStencil( | |
| FGTexture texture, | |
| GpuTextureViewDimension viewDim = GpuTextureViewDimension::Texture2D, | |
| GpuPixelFormat viewFormat = GpuPixelFormat::Unknown, | |
| const GpuTextureSubresourceRange& viewSubresourceRange = {}, | |
| const GpuRenderPassBegin& depthBegin = GpuRenderPassBegin::preserve(), | |
| const GpuRenderPassEnd& depthEnd = GpuRenderPassEnd::preserve(), | |
| const GpuRenderPassBegin& stencilBegin = GpuRenderPassBegin::preserve(), | |
| const GpuRenderPassEnd& stencilEnd = GpuRenderPassEnd::preserve()) = 0; | |
| virtual FGDescriptor addShaderResource( | |
| FGTexture texture, | |
| GpuTextureViewDimension viewDim = GpuTextureViewDimension::Texture2D, | |
| GpuPixelFormat viewFormat = GpuPixelFormat::Unknown, | |
| const GpuTextureSubresourceRange& viewSubresourceRange = {}) = 0; | |
| virtual FGDescriptor addShaderResource(FGBuffer buffer) = 0; | |
| virtual FGDescriptor addUnorderedAccess( | |
| FGTexture texture, | |
| Flags<FGAccess> access, | |
| GpuTextureViewDimension viewDim = GpuTextureViewDimension::Texture2D, | |
| GpuPixelFormat viewFormat = GpuPixelFormat::Unknown, | |
| const GpuTextureSubresourceRange& viewSubresourceRange = {}) = 0; | |
| virtual FGDescriptor addUnorderedAccess(FGBuffer buffer, | |
| Flags<FGAccess> access) = 0; | |
| virtual FGDescriptor addConstantBuffer(FGBuffer buffer) = 0; | |
| virtual void addIndirectArgumentBuffer(FGBuffer buffer) = 0; | |
| virtual void addVertexBuffer(FGBuffer buffer) = 0; | |
| virtual void addIndexBuffer(FGBuffer buffer) = 0; | |
| virtual void execute( | |
| const Func<void(FGPassContext&, FGRenderEncoder&)>& func) = 0; | |
| }; | |
| struct FGComputePassBuilder | |
| { | |
| virtual FGDescriptor addShaderResource(FGTexture texture) = 0; | |
| virtual FGDescriptor addShaderResource(FGBuffer buffer) = 0; | |
| virtual FGDescriptor addUnorderedAccess(FGTexture texture, | |
| Flags<FGAccess> access) = 0; | |
| virtual FGDescriptor addUnorderedAccess(FGBuffer buffer, | |
| Flags<FGAccess> access) = 0; | |
| virtual FGDescriptor addConstantBuffer(FGBuffer buffer) = 0; | |
| virtual void addIndirectArgumentBuffer(FGBuffer buffer) = 0; | |
| virtual void execute( | |
| const Func<void(FGPassContext&, FGComputeEncoder&)>& func) = 0; | |
| }; | |
| struct FGCopyPassBuilder | |
| { | |
| virtual void copySource(FGTexture texture) = 0; | |
| virtual void copySource(FGBuffer buffer) = 0; | |
| virtual void copyDestination(FGTexture texture) = 0; | |
| virtual void copyDestination(FGBuffer buffer) = 0; | |
| virtual void execute(const Func<void(FGCopyEncoder&)>& func) = 0; | |
| }; | |
| struct FGBuilder | |
| { | |
| virtual FGTexture createTexture(Name name, const GpuTextureDesc& desc) = 0; | |
| virtual FGBuffer createBuffer(Name name, const GpuBufferDesc& desc) = 0; | |
| // Import texture created outside of FG | |
| virtual FGTexture importTexture( | |
| Name name, | |
| GpuTexture* texture, | |
| const FGTextureBarrierState& graphBeginState, | |
| const FGTextureBarrierState& graphEndState) = 0; | |
| // Import buffer created outside of FG | |
| virtual FGBuffer importBuffer( | |
| Name name, | |
| GpuBuffer* buffer, | |
| const FGBufferBarrierState& graphBeginState, | |
| const FGBufferBarrierState& graphEndState) = 0; | |
| virtual FGRenderPassBuilder& addRenderPass(Name name) = 0; | |
| virtual FGComputePassBuilder& addComputePass(Name name) = 0; | |
| virtual FGCopyPassBuilder& addCopyPass(Name name) = 0; | |
| }; | |
| class FrameGraph final | |
| { | |
| GpuDevice* m_device; | |
| public: | |
| ENGINE_API FrameGraph(GpuDevice* device); | |
| ENGINE_API ~FrameGraph(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment