Foundation
Loading...
Searching...
No Matches
PSFullscreen.hpp
Go to the documentation of this file.
1#pragma once
3namespace Foundation::Rendering {
4 using namespace RenderCore;
11 template<typename FSetup, typename FRecord>
13 Renderer* r,
14 StringView name,
15 FSetup&& setup,
17 ) {
18 return createPass(r, name, RHIDeviceQueueType::Graphics,
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 auto const& img_wh = r->GetSwapchainExtent();
26 r->CmdBeginGraphics(self, cmd, img_wh, {}, {});
27 r->CmdSetPipeline(self, cmd);
28 record(self, r, cmd);
29 cmd->SetViewport(0, 0, img_wh.x, img_wh.y)
30 .SetScissor(0, 0, img_wh.x, img_wh.y);
31 cmd->Draw(3);
32 cmd->EndGraphics();
33 });
34 }
35 template<typename FSetup>
37 Renderer* r,
38 StringView name,
39 FSetup&& setup)
40 {
41 return createPSFullscreenPass(r, name, std::forward<FSetup>(setup), FRecordDefault{});
42 }
48 Renderer* r,
49 StringView name,
52 RHIResourceFormat srcFormat = RHIResourceFormat::R8G8B8A8Unorm
53 ) {
55 r,
56 name,
57 [=](PassHandle self, Renderer* r) {
58 r->BindTextureSampler(self, copy_sampler, "sampler");
59 r->BindTextureSRV(self, copy_source, "srcTexture", RHIPipelineStageBits::FragmentShader, {
60 .format = srcFormat,
62 });
63 r->BindShader(self, RHIShaderStageBits::Fragment, "fragMain", "data/shaders/PSCopy.spv");
64 },
66 );
67 }
68}
Definition Command.hpp:34
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:53
std::unique_ptr< T, StlDeleter< T > > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:161
RHIResourceFormat
Definition Common.hpp:20
LambdaPass< FSetup, FRecord, FSkip > * createPass(Renderer *r, StringView name, RHIDeviceQueueType queue, FSetup &&setup, FRecord &&record, FSkip &&skip={})
Convenient functional wrapper to create a pass from Setup/Record lambdas.
Definition Renderer.hpp:1000
size_t ResourceHandle
Definition RenderPass.hpp:12
size_t PassHandle
Definition RenderPass.hpp:11
Reference implementations of real-time rendering routines.
Definition Application.hpp:18
auto * 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
auto * 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:47
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:122
Default "no-op" functor for Record()
Definition RenderPass.hpp:65