Foundation
Loading...
Searching...
No Matches
PSFullscreen.hpp
Go to the documentation of this file.
1#pragma once
2#include <Core/Paths.hpp>
5 using namespace RenderCore;
12 template<typename FSetup, typename FRecord>
14 Renderer* r,
15 StringView name,
16 FSetup&& setup,
18 ) {
19 return r->CreatePass(name, RHIDeviceQueueType::Graphics, 0u,
20 [=](PassHandle self, Renderer* r) {
21 r->BindBackbufferRTV(self);
22 r->BindShader(self, RHIShaderStageBits::Vertex, "vertMain", Foundation::Core::PathsResolve("Data/Shaders/VSFullscreen.spv"));
23 setup(self, r);
24 },
26 {
27 auto const& img_wh = r->GetSwapchainExtent();
28 r->CmdSetPipeline(self, cmd);
29 record(self, r, cmd);
30 r->CmdBeginGraphics(self, cmd, img_wh, {{RHIColorAttachmentLoad{RHIAttachmentLoadOp::DontCare}}},
31 {RHIAttachmentLoadOp::DontCare}); // No clear necessary
32 cmd->SetViewport(0, 0, img_wh.x, img_wh.y)
33 .SetScissor(0, 0, img_wh.x, img_wh.y);
34 cmd->Draw(3);
35 cmd->EndGraphics();
36 });
37 }
38 template<typename FSetup>
40 Renderer* r,
41 StringView name,
42 FSetup&& setup)
43 {
44 return createPSFullscreenPass(r, name, std::forward<FSetup>(setup), FRecordDefault{});
45 }
55 template<typename FSetup, typename FRecord>
57 Renderer* r,
58 StringView name,
61 RHIExtent2D extent,
62 FSetup&& setup,
64 ) {
65 return r->CreatePass(name, RHIDeviceQueueType::Graphics, 0u,
66 [=](PassHandle self, Renderer* r) {
67 r->BindTextureRTV(self, rtvTexture, rtvViewDesc);
68 r->BindShader(self, RHIShaderStageBits::Vertex, "vertMain", Foundation::Core::PathsResolve("Data/Shaders/VSFullscreen.spv"));
69 setup(self, r);
70 },
72 {
73 RHIExtent2D img_wh = extent.x != 0u && extent.y != 0u ? extent : r->GetSwapchainExtent();
74 r->CmdSetPipeline(self, cmd);
75 record(self, r, cmd);
76 r->CmdBeginGraphics(self, cmd, img_wh, {{RHIColorAttachmentLoad{RHIAttachmentLoadOp::DontCare}}},
77 {RHIAttachmentLoadOp::DontCare});
78 cmd->SetViewport(0, 0, img_wh.x, img_wh.y)
79 .SetScissor(0, 0, img_wh.x, img_wh.y);
80 cmd->Draw(3);
81 cmd->EndGraphics();
82 });
83 }
84 template<typename FSetup>
100 Renderer* r,
101 StringView name,
104 RHIResourceFormat srcFormat = RHIResourceFormat::R8G8B8A8Unorm
105 ) {
107 r,
108 name,
109 [=](PassHandle self, Renderer*) {
110 r->BindTextureSampler(self, copy_sampler, "sampler");
111 r->BindTextureSRV(self, copy_source, "srcTexture", RHIPipelineStageBits::FragmentShader, {
112 .format = srcFormat,
114 });
115 r->BindShader(self, RHIShaderStageBits::Fragment, "fragMain", Foundation::Core::PathsResolve("Data/Shaders/PSCopy.spv"));
116 },
118 );
119 }
120}
Definition Command.hpp:42
Renderer implementing a Frame Graph system with automatic resource tracking and synchronization.
Definition Renderer.hpp:89
std::basic_string_view< char > StringView
Alias for std::basic_string_view<char>
Definition Container.hpp:55
T * Construct(Allocator *resource, Args &&...args)
Convenience placement new with object of type T using a Foundation::Core::Allocator.
Definition Allocator.hpp:153
String PathsResolve(StringView relPath)
Definition Paths.cpp:18
RHIResourceFormat
Definition Common.hpp:34
glm::vec< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
Handle ResourceHandle
Definition RenderPass.hpp:11
Handle PassHandle
Definition RenderPass.hpp:10
Definition CSClearBuffer.hpp:6
PassHandle createPSFullscreenPass(Renderer *r, StringView name, FSetup &&setup, FRecord &&record)
Creates a full-screen triangle pass that writes to the current backbuffer.
Definition PSFullscreen.hpp:13
PassHandle createPSBackbufferBlitPass(Renderer *r, StringView name, ResourceHandle copy_sampler, ResourceHandle copy_source, RHIResourceFormat srcFormat=RHIResourceFormat::R8G8B8A8Unorm)
Creates a full-screen triangle pass that renders a texture to the current backbuffer.
Definition PSFullscreen.hpp:99
PassHandle createPSFullscreenPassRTV(Renderer *r, StringView name, ResourceHandle rtvTexture, RHITextureViewDesc const &rtvViewDesc, RHIExtent2D extent, FSetup &&setup, FRecord &&record)
Creates a full-screen triangle pass that writes to an arbitrary texture RTV instead of the backbuffer...
Definition PSFullscreen.hpp:56
static RHITextureSubresourceRange Create(RHITextureAspectFlag aspect=RHITextureAspectFlagBits::Color, uint32_t base_mip_level=0, uint32_t mip_count=1, uint32_t base_array_layer=0, uint32_t layer_count=1)
Helper function to create a Subresource Range with default parameters.
Definition Resource.hpp:191
Definition Resource.hpp:210
Default "no-op" functor for Record()
Definition RenderPass.hpp:53