Debian Codegraph @

Sources/nCine/Graphics/RHI/GX/GxRenderTarget.cpp

raw
1 #include "GxRenderTarget.h"
2 #include "GxDevice.h"
3 #include "GxTexture.h"
4
5 namespace nCine::RHI::GX
6 {
7 GxRenderTarget::GxRenderTarget()
8 : _numDrawBuffers(1)
9 {
10 for (std::uint32_t i = 0; i < MaxColorAttachments; i++) {
11 _colorTextures[i] = nullptr;
12 }
13 }
14
15 GxRenderTarget::~GxRenderTarget()
16 {
17 // Clear from the device so a destroyed target can't dangle as _currentRenderTarget
18 GxDevice::UnbindRenderTarget(this);
19 }
20
21 void GxRenderTarget::AttachColorTexture(GxTexture& 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 GxRenderTarget::DetachColorTexture(std::uint32_t index)
32 {
33 if (index < MaxColorAttachments) {
34 _colorTextures[index] = nullptr;
35 }
36 }
37
38 void GxRenderTarget::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 GxRenderTarget::DetachDepthStencil(DepthStencilFormat format)
46 {
47 static_cast<void>(format);
48 }
49
50 void GxRenderTarget::BindDraw()
51 {
52 GxDevice::SetRenderTarget(this);
53 }
54
55 void GxRenderTarget::UnbindDraw()
56 {
57 GxDevice::SetRenderTarget(nullptr);
58 }
59
60 bool GxRenderTarget::SetDrawBuffers(std::uint32_t numColorAttachments)
61 {
62 _numDrawBuffers = numColorAttachments;
63 return true;
64 }
65
66 bool GxRenderTarget::IsStatusComplete()
67 {
68 return (_colorTextures[0] != nullptr);
69 }
70
71 void GxRenderTarget::InvalidateDepthStencil(DepthStencilFormat format)
72 {
73 static_cast<void>(format);
74 }
75
76 void GxRenderTarget::SetObjectLabel(StringView label)
77 {
78 static_cast<void>(label);
79 }
80 }