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