opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
shared_depth_stencil_render_buffer.h
Go to the documentation of this file.
1#pragma once
2
7
8#include <memory>
9
10namespace osc { struct DepthStencilRenderBufferParams; }
11
12namespace osc
13{
14 // A render buffer that's shareable between `Material`s, `RenderTarget`s,
15 // and `RenderTexture`s.
16 //
17 // Unlike most of `osc`'s graphics classes, this one _doesn't_ have value
18 // semantics. Instead, it should be thought of as a `std::shared_ptr<RenderBuffer>`. The
19 // reason for this change of style is to support typical use-cases, such as:
20 //
21 // - Calling code allocates a `RenderTexture` (i.e. color + depth `RenderBuffer`s)
22 // (owners: `RenderTexture`)
23 //
24 // - Calling code wants to render to only the color part of the `RenderTexture`, so it
25 // creates a `RenderTarget` that points to the `RenderTexture`'s color `RenderBuffer`
26 // (owners: `RenderTexture`, `RenderTarget`)
27 //
28 // - After a render pass to the `RenderTarget`, calling code then wants to sample from
29 // the `RenderBuffer` in a downstream pass (e.g. for deferred shading, or similar), so
30 // the code sets the `RenderBuffer` in a `Material` or `MaterialPropertyBlock`
31 // (owners: `RenderTexture`, `RenderTarget`, `Material`)
32 //
33 // You might (rightfully) be thinking that the last step should be solved by explicitly
34 // blitting the `RenderBuffer` to (e.g.) a `Texture2D`, followed by assigning that `Texture2D`
35 // to the `Material`. However, in typical multi-frame rendering operations that potentially
36 // allocates an additional `Texture2D`, because the calling code would have to:
37 //
38 // - First blit the `RenderBuffer` to a new `Texture2D`
39 // - Then assign the new `Texture2D` over the old one present in the `Material` from the
40 // last frame
41 //
42 // The second step is problematic, because it implies there exists a point in time where
43 // there's two instances of `Texture2D` hanging around. Callers would have to explicitly
44 // remember to `unset` the `Texture2D` after sampling it in the downstream `Material`, which
45 // is a pain in the ass to remember. Whereas `SharedRenderBuffer`s just keep everything as
46 // shared references and it's assumed that the calling code knows when/where to share it.
47 // This also makes it easier for graph traversal algorithms to figure out the dependency
48 // chains between render passes.
50 public:
53
55
57
58 // Returns the dimensions of the buffer in physical pixels.
63
65 const DepthStencilRenderBuffer& impl() const { return *impl_; }
66 private:
67 friend class Camera;
68 friend class GraphicsBackend;
69 friend class RenderTexture;
70
72
73 bool has_been_rendered_to() const;
74
75 std::shared_ptr<DepthStencilRenderBuffer> impl_;
76 };
77}
Definition anti_aliasing_level.h:11
Definition camera.h:27
Definition render_texture.h:18
Definition shared_depth_stencil_render_buffer.h:49
SharedDepthStencilRenderBuffer(const DepthStencilRenderBufferParams &)
const DepthStencilRenderBuffer & impl() const
Definition shared_depth_stencil_render_buffer.h:65
friend class GraphicsBackend
Definition shared_depth_stencil_render_buffer.h:68
SharedDepthStencilRenderBuffer clone() const
TextureDimensionality dimensionality() const
AntiAliasingLevel anti_aliasing_level() const
friend bool operator==(const SharedDepthStencilRenderBuffer &, const SharedDepthStencilRenderBuffer &)=default
DepthStencilRenderBufferFormat format() const
Definition custom_decoration_generator.h:5
DepthStencilRenderBufferFormat
Definition depth_stencil_render_buffer_format.h:13
constexpr U to(T &&value)
Definition conversion.h:56
TextureDimensionality
Definition texture_dimensionality.h:5
Definition depth_stencil_render_buffer_params.h:10