Debian Codegraph @

Sources/nCine/Graphics/RHI/GU/GuRenderTarget.cpp

raw
1 #include "GuRenderTarget.h"
2 #include "GuDevice.h"
3 #include "GuTexture.h"
4
5 namespace nCine::RHI::GU
6 {
7 GuRenderTarget::GuRenderTarget()
8 : _numDrawBuffers(1)
9 {
10 for (std::uint32_t i = 0; i < MaxColorAttachments; i++) {
11 _colorTextures[i] = nullptr;
12 }
13 }
14
15 GuRenderTarget::~GuRenderTarget()
16 {
17 // Clear from the device so a destroyed target can't dangle as _currentRenderTarget
18 GuDevice::UnbindRenderTarget(this);
19 }
20
21 void GuRenderTarget::AttachColorTexture(GuTexture& texture, std::uint32_t index)
22 {
23 if (index < MaxColorAttachments) {
24 _colorTextures[index] = &texture;
25 // Tag the texture so the rasterizer treats its store as bottom-up (GL framebuffer convention)
26 // both when drawing into it and when later sampling it as a source
27 texture.SetRenderTarget(true);
28 }
29 }
30
31 void GuRenderTarget::DetachColorTexture(std::uint32_t index)
32 {
33 if (index < MaxColorAttachments) {
34 _colorTextures[index] = nullptr;
35 }
36 }
37
38 void GuRenderTarget::AttachDepthStencil(DepthStencilFormat format, std::int32_t width, std::int32_t height)
39 {
40 static_cast<void>(format);
41 static_cast<void>(width);
42 static_cast<void>(height);
43 }
44
45 void GuRenderTarget::DetachDepthStencil(DepthStencilFormat format)
46 {
47 static_cast<void>(format);
48 }
49
50 void GuRenderTarget::BindDraw()
51 {
52 GuDevice::SetRenderTarget(this);
53 }
54
55 void GuRenderTarget::UnbindDraw()
56 {
57 GuDevice::SetRenderTarget(nullptr);
58 }
59
60 bool GuRenderTarget::SetDrawBuffers(std::uint32_t numColorAttachments)
61 {
62 _numDrawBuffers = numColorAttachments;
63 return true;
64 }
65
66 bool GuRenderTarget::IsStatusComplete()
67 {
68 return (_colorTextures[0] != nullptr);
69 }
70
71 void GuRenderTarget::InvalidateDepthStencil(DepthStencilFormat format)
72 {
73 static_cast<void>(format);
74 }
75
76 void GuRenderTarget::SetObjectLabel(StringView label)
77 {
78 static_cast<void>(label);
79 }
80 }