Foundation
Loading...
Searching...
No Matches
CSClearBuffer.hpp
Go to the documentation of this file.
1#pragma once
2#include <Math/Math.hpp>
5{
6 using namespace RenderCore;
7#pragma pack(push,1)
9 {
10 float4 color;
12 };
13#pragma pack(pop)
14 inline PassHandle createCSClearBackBuffer(Renderer* r, StringView name, float4 clearColor = {})
15 {
16 return r->CreatePass(
17 name, RHIDeviceQueueType::Graphics, 0u,
18 [=](PassHandle self, Renderer* r)
19 {
20 r->BindBackbufferUAV(self, 0u);
21 r->BindShader(self, RHIShaderStageBits::Compute, "main", "data/shaders/CSClearBuffer.spv");
22 r->BindPushConstant(self, RHIShaderStageBits::Compute, 0, sizeof(CSClearBufferData));
23 },
24 [=](PassHandle self, Renderer* r, RHICommandList* cmd)
25 {
26 RHIExtent2D wh = r->GetSwapchainExtent();
27 CSClearBufferData cdata{clearColor, wh.x, wh.y};
28 r->CmdSetPipeline(self, cmd);
29 r->CmdSetPushConstant(self, cmd, RHIShaderStageBits::Compute, 0, cdata);
30 r->CmdDispatch(self, cmd, {cdata.w, cdata.h, 1});
31 });
32 }
34 {
35 return r->CreatePass(
36 name, RHIDeviceQueueType::Graphics, 0u,
38 {
39 r->BindTextureUAV(self, resource, "texture", RHIPipelineStageBits::ComputeShader, viewDesc);
40 r->BindShader(self, RHIShaderStageBits::Compute, "main", "data/shaders/CSClearBuffer.spv");
41 r->BindPushConstant(self, RHIShaderStageBits::Compute, 0, sizeof(CSClearBufferData));
42 },
44 {
45 RHIExtent2D wh = r->GetSwapchainExtent();
46 CSClearBufferData cdata{clearColor, wh.x, wh.y};
47 r->CmdSetPipeline(self, cmd);
48 r->CmdSetPushConstant(self, cmd, RHIShaderStageBits::Compute, 0, cdata);
49 r->CmdDispatch(self, cmd, {cdata.w, cdata.h, 1});
50 });
51 }
52} // namespace Foundation::RenderUtils
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< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
size_t ResourceHandle
Definition RenderPass.hpp:11
size_t PassHandle
Definition RenderPass.hpp:10
Definition CSClearBuffer.hpp:5
PassHandle createCSClearTexture(Renderer *r, StringView name, ResourceHandle resource, RHITextureViewDesc viewDesc, float4 clearColor)
Definition CSClearBuffer.hpp:33
PassHandle createCSClearBackBuffer(Renderer *r, StringView name, float4 clearColor={})
Definition CSClearBuffer.hpp:14
Definition Resource.hpp:164
Definition CSClearBuffer.hpp:9
float4 color
Definition CSClearBuffer.hpp:10
uint32_t h
Definition CSClearBuffer.hpp:11
uint32_t w
Definition CSClearBuffer.hpp:11