opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
liboscar
graphics
shared_depth_stencil_render_buffer.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
liboscar/graphics/anti_aliasing_level.h
>
4
#include <
liboscar/graphics/depth_stencil_render_buffer_format.h
>
5
#include <
liboscar/graphics/texture_dimensionality.h
>
6
#include <
liboscar/maths/vector.h
>
7
8
#include <memory>
9
10
namespace
osc
{
struct
DepthStencilRenderBufferParams; }
11
12
namespace
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.
49
class
SharedDepthStencilRenderBuffer
final
{
50
public
:
51
explicit
SharedDepthStencilRenderBuffer
();
52
explicit
SharedDepthStencilRenderBuffer
(
const
DepthStencilRenderBufferParams
&);
53
54
friend
bool
operator==
(
const
SharedDepthStencilRenderBuffer
&,
const
SharedDepthStencilRenderBuffer
&) =
default
;
55
56
SharedDepthStencilRenderBuffer
clone
()
const
;
57
58
// Returns the dimensions of the buffer in physical pixels.
59
Vector2i
pixel_dimensions
()
const
;
60
TextureDimensionality
dimensionality
()
const
;
61
AntiAliasingLevel
anti_aliasing_level
()
const
;
62
DepthStencilRenderBufferFormat
format
()
const
;
63
64
class
DepthStencilRenderBuffer
;
65
const
DepthStencilRenderBuffer
&
impl
()
const
{
return
*impl_; }
66
private
:
67
friend
class
Camera
;
68
friend
class
GraphicsBackend
;
69
friend
class
RenderTexture
;
70
71
explicit
SharedDepthStencilRenderBuffer
(
const
DepthStencilRenderBuffer
&);
72
73
bool
has_been_rendered_to()
const
;
74
75
std::shared_ptr<DepthStencilRenderBuffer> impl_;
76
};
77
}
anti_aliasing_level.h
osc::AntiAliasingLevel
Definition
anti_aliasing_level.h:11
osc::Camera
Definition
camera.h:27
osc::RenderTexture
Definition
render_texture.h:18
osc::SharedDepthStencilRenderBuffer
Definition
shared_depth_stencil_render_buffer.h:49
osc::SharedDepthStencilRenderBuffer::SharedDepthStencilRenderBuffer
SharedDepthStencilRenderBuffer(const DepthStencilRenderBufferParams &)
osc::SharedDepthStencilRenderBuffer::impl
const DepthStencilRenderBuffer & impl() const
Definition
shared_depth_stencil_render_buffer.h:65
osc::SharedDepthStencilRenderBuffer::GraphicsBackend
friend class GraphicsBackend
Definition
shared_depth_stencil_render_buffer.h:68
osc::SharedDepthStencilRenderBuffer::clone
SharedDepthStencilRenderBuffer clone() const
osc::SharedDepthStencilRenderBuffer::dimensionality
TextureDimensionality dimensionality() const
osc::SharedDepthStencilRenderBuffer::anti_aliasing_level
AntiAliasingLevel anti_aliasing_level() const
osc::SharedDepthStencilRenderBuffer::SharedDepthStencilRenderBuffer
SharedDepthStencilRenderBuffer()
osc::SharedDepthStencilRenderBuffer::operator==
friend bool operator==(const SharedDepthStencilRenderBuffer &, const SharedDepthStencilRenderBuffer &)=default
osc::SharedDepthStencilRenderBuffer::pixel_dimensions
Vector2i pixel_dimensions() const
osc::SharedDepthStencilRenderBuffer::format
DepthStencilRenderBufferFormat format() const
osc::Vector< int, 2 >
depth_stencil_render_buffer_format.h
osc
Definition
custom_decoration_generator.h:5
osc::DepthStencilRenderBufferFormat
DepthStencilRenderBufferFormat
Definition
depth_stencil_render_buffer_format.h:13
osc::to
constexpr U to(T &&value)
Definition
conversion.h:56
osc::TextureDimensionality
TextureDimensionality
Definition
texture_dimensionality.h:5
osc::DepthStencilRenderBufferParams
Definition
depth_stencil_render_buffer_params.h:10
texture_dimensionality.h
vector.h
Generated by
1.9.8