Cogs.Rendering
Loading...
Searching...
No Matches
IRenderTargets.h
Go to the documentation of this file.
1#pragma once
2
3#include "Common.h"
4#include "RasterizerState.h"
5#include "DepthStencilState.h"
6#include "BlendState.h"
7
8namespace Cogs
9{
15 {
19 uint16_t layerIndex;
21 uint16_t numLayers;
23 uint8_t levelIndex;
24 };
25
31 {
35 uint16_t layerIndex;
37 uint16_t numLayers;
39 uint8_t levelIndex;
40 };
41
47 uint8_t samples;
49 uint8_t baseIndex;
51 uint8_t count;
52 };
53
54
59 {
63 virtual void annotate(RenderTargetHandle handle, const StringView& name) { (void)handle; (void)name; }
64
68 virtual void annotate(DepthStencilHandle handle, const StringView& name) { (void)handle; (void)name; }
69
77 {
78 return createRenderTarget(&textureHandle, 1);
79 }
80
88 virtual RenderTargetHandle createRenderTarget(TextureHandle * textureHandles, const size_t numTextureHandles)
89 {
90 RenderTargetViewDescription view_desc[8] = {};
91 for(size_t i=0; i<numTextureHandles; i++){
92 view_desc[i].texture = textureHandles[i];
93 view_desc[i].layerIndex = 0;
94 view_desc[i].numLayers = 1;
95 view_desc[i].levelIndex = 0;
96 }
97 return createRenderTarget(view_desc, numTextureHandles);
98 }
99
108 virtual RenderTargetHandle createRenderTarget(const RenderTargetViewDescription * renderTargetViews, const size_t numViews) = 0;
109
110 virtual RenderTargetHandle createRenderTarget(const RenderTargetViewDescription* /*renderTargetViews*/, const size_t /*numViews*/, const MultiViewDescription& /*multiView*/)
111 {
113 }
114
120 virtual void releaseRenderTarget(RenderTargetHandle renderTargetHandle) = 0;
121
130
140 virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle handle, const TextureHandle textureHandle) = 0;
141
151
152
153 virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle /*handle*/, const DepthStencilViewDescription& /*depthStencilView*/, const MultiViewDescription& /*multiView*/)
154 {
156 }
157
163 virtual void releaseDepthStencilTarget(DepthStencilHandle depthStencilHandle) = 0;
164
172
179
186 virtual RasterizerStateHandle loadRasterizerState(const RasterizerState & rasterizerState) = 0;
187
194
201 virtual BlendStateHandle loadBlendState(const BlendState & blendState) = 0;
202
210 virtual BlendStateHandle loadBlendState(const BlendState & blendStateColor, const BlendState& blendStateAlpha) { (void)blendStateAlpha; return loadBlendState(blendStateColor); }
211
212 virtual BlendStateHandle loadBlendState(const BlendState & blendStateColor, const BlendState& blendStateAlpha, const uint32_t flags) { (void)flags; return loadBlendState(blendStateColor, blendStateAlpha); }
213
214 virtual BlendStateHandle loadBlendState(const BlendState * blendStateColor, const BlendState * blendStateAlpha, const uint32_t numBlendStates, const uint32_t flags) { (void)blendStateColor; (void)blendStateAlpha; (void)numBlendStates; (void)flags; return BlendStateHandle::NoHandle; }
215
221 virtual void releaseBlendState(BlendStateHandle handle) = 0;
222
226 virtual void releaseResources() = 0;
227 };
228}
Definition: Base.h:24
Encapsulates blend state for the graphics pipeline in a state object.
Definition: BlendState.h:9
Encapsulates state for depth buffer usage and stencil buffer usage in a state object.
Definition: DepthStencilState.h:13
Describes a single depth stencil view and which resources to use from the underlying texture.
Definition: IRenderTargets.h:31
TextureHandle texture
Texture handle.
Definition: IRenderTargets.h:33
uint16_t numLayers
Number of available layers to write to.
Definition: IRenderTargets.h:37
uint8_t levelIndex
Index of the mipmap level to render to.
Definition: IRenderTargets.h:39
uint16_t layerIndex
Index of the first layer (if array) to write depth to.
Definition: IRenderTargets.h:35
static const Handle_t NoHandle
Represents a handle to nothing.
Definition: Common.h:77
static const Handle_t InvalidHandle
Represents an invalid handle.
Definition: Common.h:80
Provides render target management functionality.
Definition: IRenderTargets.h:59
virtual void releaseRasterizerState(RasterizerStateHandle handle)=0
Release the rasterizer state with the given handle.
virtual BlendStateHandle loadBlendState(const BlendState &blendState)=0
Load a blend state object.
virtual RenderTargetHandle createRenderTarget(const RenderTargetViewDescription *renderTargetViews, const size_t numViews)=0
Create a render target using the given view descriptions.
virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle handle)=0
Creates a depth/stencil target to back the render target with the given handle.
virtual BlendStateHandle loadBlendState(const BlendState &blendStateColor, const BlendState &blendStateAlpha, const uint32_t flags)
Definition: IRenderTargets.h:212
virtual void releaseDepthStencilState(DepthStencilStateHandle handle)=0
Release the depth stencil state with the given handle.
virtual void releaseResources()=0
Release all allocated render target resources.
virtual BlendStateHandle loadBlendState(const BlendState *blendStateColor, const BlendState *blendStateAlpha, const uint32_t numBlendStates, const uint32_t flags)
Definition: IRenderTargets.h:214
virtual void releaseDepthStencilTarget(DepthStencilHandle depthStencilHandle)=0
Release the depth target with the given depthStencilHandle.
virtual void annotate(RenderTargetHandle handle, const StringView &name)
Associate a name with an object for use in graphics debugging.
Definition: IRenderTargets.h:63
virtual RenderTargetHandle createRenderTarget(const RenderTargetViewDescription *, const size_t, const MultiViewDescription &)
Definition: IRenderTargets.h:110
virtual void releaseBlendState(BlendStateHandle handle)=0
Release the blend state with the given handle.
virtual RasterizerStateHandle loadRasterizerState(const RasterizerState &rasterizerState)=0
Load a rasterizer state object.
virtual void annotate(DepthStencilHandle handle, const StringView &name)
Associate a name with an object for use in graphics debugging.
Definition: IRenderTargets.h:68
virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle handle, const TextureHandle textureHandle)=0
Creates a depth/stencil target to back the render target with the given handle.
virtual DepthStencilStateHandle loadDepthStencilState(const DepthStencilState &depthStencilState)=0
Load a depth stencil state object.
virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle, const DepthStencilViewDescription &, const MultiViewDescription &)
Definition: IRenderTargets.h:153
virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle handle, const DepthStencilViewDescription &depthStencilView)=0
Creates a depth stencil view using the given description.
virtual RenderTargetHandle createRenderTarget(TextureHandle *textureHandles, const size_t numTextureHandles)
Create a multi render target (MRT) with using the given textures to render into.
Definition: IRenderTargets.h:88
virtual void releaseRenderTarget(RenderTargetHandle renderTargetHandle)=0
Release the render target with the given renderTargetHandle.
virtual RenderTargetHandle createRenderTarget(TextureHandle textureHandle)
Create a render target using the given texture to render into.
Definition: IRenderTargets.h:76
virtual BlendStateHandle loadBlendState(const BlendState &blendStateColor, const BlendState &blendStateAlpha)
Load a blend state object with separate blending for alpha channel.
Definition: IRenderTargets.h:210
Describes multiview framebuffer layout.
Definition: IRenderTargets.h:45
uint8_t samples
Number of multisample samples, 0 and 1 implies no multisampling.
Definition: IRenderTargets.h:47
uint8_t baseIndex
Texture array index for first texture slice to render into.
Definition: IRenderTargets.h:49
uint8_t count
Number of texture array slices to render into.
Definition: IRenderTargets.h:51
Encapsulates state for primitive rasterization in a state object.
Definition: RasterizerState.h:12
Describes a single render target view and which resources to use from the underlying texture.
Definition: IRenderTargets.h:15
uint16_t layerIndex
Index of the first layer (if array) to render to.
Definition: IRenderTargets.h:19
uint16_t numLayers
Number of available layers to render to.
Definition: IRenderTargets.h:21
TextureHandle texture
Texture handle.
Definition: IRenderTargets.h:17
uint8_t levelIndex
Index of the mipmap level to render to.
Definition: IRenderTargets.h:23