Foundation
Loading...
Searching...
No Matches
PSFullscreen.hpp
Go to the documentation of this file.
1#pragma once
4 using namespace RenderCore;
11 template<typename FSetup, typename FRecord>
13 Renderer* r,
14 StringView name,
15 FSetup&& setup,
17 ) {
18 return r->CreatePass(name, RHIDeviceQueueType::Graphics, 0u,
19 [=](PassHandle self, Renderer* r) {
20 r->BindBackbufferRTV(self);
21 r->BindShader(self, RHIShaderStageBits::Vertex, "vertMain", "data/shaders/VSFullscreen.spv");
22 setup(self, r);
23 },
25 {
26 auto const& img_wh = r->GetSwapchainExtent();
27 r->CmdSetPipeline(self, cmd);
28 record(self, r, cmd);
29 r->CmdBeginGraphics(self, cmd, img_wh, {{RHIClearColor{}}}, {});
30 cmd->SetViewport(0, 0, img_wh.x, img_wh.y)
31 .SetScissor(0, 0, img_wh.x, img_wh.y);
32 cmd->Draw(3);
33 cmd->EndGraphics();
34 });
35 }
36 template<typename FSetup>
38 Renderer* r,
39 StringView name,
40 FSetup&& setup)
41 {
42 return createPSFullscreenPass(r, name, std::forward<FSetup>(setup), FRecordDefault{});
43 }
49 Renderer* r,
50 StringView name,
53 RHIResourceFormat srcFormat = RHIResourceFormat::R8G8B8A8Unorm
54 ) {
56 r,
57 name,
58 [=](PassHandle self, Renderer*) {
59 r->BindTextureSampler(self, copy_sampler, "sampler");
60 r->BindTextureSRV(self, copy_source, "srcTexture", RHIPipelineStageBits::FragmentShader, {
61 .format = srcFormat,
63 });
64 r->BindShader(self, RHIShaderStageBits::Fragment, "fragMain", "data/shaders/PSCopy.spv");
65 },
67 );
68 }
69}
Definition Command.hpp:35
Renderer implementing a Frame Graph system with automatic resource tracking and synchronization.
Definition Renderer.hpp:78
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:149
glm::vec< 4, float > RHIClearColor
Definition Common.hpp:16
RHIResourceFormat
Definition Common.hpp:20
size_t ResourceHandle
Definition RenderPass.hpp:11
size_t PassHandle
Definition RenderPass.hpp:10
Definition CSClearBuffer.hpp:5
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:12
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:48
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:146
Default "no-op" functor for Record()
Definition RenderPass.hpp:53