Foundation
Loading...
Searching...
No Matches
CSDebugText.hpp
Go to the documentation of this file.
1#pragma once
4{
5 using namespace RenderCore;
6#pragma pack(push,1)
8 {
9 int x = 0u, y = 0u, scale = 2u, col32 = -1;
10 char szText[28 * 4]; // Zero terminated
11
13 {
14 size_t len = std::min(str.size(), sizeof(szText) - 1);
15 std::memcpy(szText, str.data(), len);
16 szText[len] = '\0';
17 }
18 int SetColor(int r, int g, int b, int a = 255)
19 {
20 return col32 = a << 24 | b << 16 | g << 8 | r;
21 }
22 };
23#pragma pack(pop)
29 {
30 return r->CreatePass(
31 name, RHIDeviceQueueType::Graphics, 0u,
32 [=](PassHandle self, Renderer* r)
33 {
34 r->BindBackbufferUAV(self, 0u);
35 r->BindShader(self, RHIShaderStageBits::Compute, "debugText", r->GetApplication()->ResolveRelativePathBase("Data/Shaders/CSDebugText.spv"));
36 r->BindPushConstant(self, RHIShaderStageBits::Compute, 0, sizeof(CSDebugTextData));
37 },
38 [=](PassHandle self, Renderer* r, RHICommandList* cmd)
39 {
40 r->CmdSetPipeline(self, cmd);
41 for (auto const& line : lines)
42 {
43 if (size_t len = strlen(line.szText))
44 {
45 r->CmdSetPushConstant(self, cmd, RHIShaderStageBits::Compute, 0, line);
46 cmd->Dispatch(len,1,1);
47 }
48 }
49 });
50 }
51} // namespace Foundation::RenderUtils
virtual String ResolveRelativePathBase(StringView path="") const =0
Retrives path relative to the application executable.
Definition Command.hpp:42
Renderer implementing a Frame Graph system with automatic resource tracking and synchronization.
Definition Renderer.hpp:377
PassHandle CreatePass(StringView name, RHIDeviceQueueType queue, size_t priority, FSetup &&setup, FRecord &&record)
Create a render pass from a Setup(Renderer*, PassHandle) and Record(Renderer*, PassHandle,...
Definition Renderer.hpp:680
const RHIApplication * GetApplication() const
Get the RHIApplication this Renderer was constructed with.
Definition Renderer.hpp:1034
void CmdSetPipeline(PassHandle pass, RHICommandList *cmd) const
Helper that sets the current pass's PSO and descriptor sets to the current command list.
Definition Renderer.cpp:2174
void BindPushConstant(PassHandle pass, RHIShaderStage stage, size_t offset, size_t size) const
Declares a range of Push Constant used in a stage.
Definition Renderer.cpp:241
void BindShader(PassHandle pass, RHIShaderStage stage, StringView entry_point, StringView shader_path, Span< const char > specializationData={}, uint32_t rtHitGroupIndex=0, RHIPipelineState::PipelineStateDesc::RayTracingHitGroupType rtHitGroupType=RHIPipelineState::PipelineStateDesc::RayTracingHitGroupType::Triangles) const
Binds shader file path to a certain pass at a certain stage.
Definition Renderer.cpp:221
void CmdSetPushConstant(PassHandle pass, RHICommandList *cmd, RHIShaderStage stage, size_t offset, T const &data)
Helper that sets a Push Constant range data with a single l-value.
Definition Renderer.hpp:1184
void BindBackbufferUAV(PassHandle pass, int set_index) const
Binds the backbuffer as RW access at binding 0 of set index.
Definition Renderer.cpp:444
std::basic_string_view< char > StringView
Alias for std::basic_string_view<char>
Definition Container.hpp:56
std::span< T > Span
Alias for std::span
Definition Container.hpp:62
Handle PassHandle
Definition Renderer.hpp:21
Definition CSClearBuffer.hpp:5
PassHandle createCSDebugTextPassBackBuffer(Renderer *r, StringView name, Span< const CSDebugTextData > lines)
Definition CSDebugText.hpp:28
Definition CSDebugText.hpp:8
int scale
Definition CSDebugText.hpp:9
int SetColor(int r, int g, int b, int a=255)
Definition CSDebugText.hpp:18
int x
Definition CSDebugText.hpp:9
void SetText(StringView str)
Definition CSDebugText.hpp:12
int y
Definition CSDebugText.hpp:9
int col32
Definition CSDebugText.hpp:9
char szText[28 *4]
Definition CSDebugText.hpp:10