Cogs.Core
IRenderTargets.h
1#pragma once
2
3#include "Common.h"
4#include "RasterizerState.h"
5#include "DepthStencilState.h"
6#include "BlendState.h"
7
8#include "Foundation/StringView.h"
9
10namespace Cogs
11{
17 {
21 uint16_t layerIndex;
23 uint16_t numLayers;
25 uint8_t levelIndex;
26 };
27
33 {
37 uint16_t layerIndex;
39 uint16_t numLayers;
41 uint8_t levelIndex;
42 };
43
49 uint8_t samples;
51 uint8_t baseIndex;
53 uint8_t count;
54 };
55
56
61 {
65 virtual void annotate(RenderTargetHandle handle, const StringView& name) { (void)handle; (void)name; }
66
70 virtual void annotate(DepthStencilHandle handle, const StringView& name) { (void)handle; (void)name; }
71
79 {
80 return createRenderTarget(&textureHandle, 1);
81 }
82
90 virtual RenderTargetHandle createRenderTarget(TextureHandle * textureHandles, const size_t numTextureHandles)
91 {
92 RenderTargetViewDescription view_desc[8] = {};
93 for(size_t i=0; i<numTextureHandles; i++){
94 view_desc[i].texture = textureHandles[i];
95 view_desc[i].layerIndex = 0;
96 view_desc[i].numLayers = 1;
97 view_desc[i].levelIndex = 0;
98 }
99 return createRenderTarget(view_desc, numTextureHandles);
100 }
101
110 virtual RenderTargetHandle createRenderTarget(const RenderTargetViewDescription * renderTargetViews, const size_t numViews) = 0;
111
112 virtual RenderTargetHandle createRenderTarget(const RenderTargetViewDescription* /*renderTargetViews*/, const size_t /*numViews*/, const MultiViewDescription& /*multiView*/)
113 {
115 }
116
122 virtual void releaseRenderTarget(RenderTargetHandle renderTargetHandle) = 0;
123
132
142 virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle handle, const TextureHandle textureHandle) = 0;
143
153
154
155 virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle /*handle*/, const DepthStencilViewDescription& /*depthStencilView*/, const MultiViewDescription& /*multiView*/)
156 {
158 }
159
165 virtual void releaseDepthStencilTarget(DepthStencilHandle depthStencilHandle) = 0;
166
174
181
188 virtual RasterizerStateHandle loadRasterizerState(const RasterizerState & rasterizerState) = 0;
189
196
203 virtual BlendStateHandle loadBlendState(const BlendState & blendState) = 0;
204
212 virtual BlendStateHandle loadBlendState(const BlendState& blendStateColor, const BlendState& /*blendStateAlpha*/) { return loadBlendState(blendStateColor); }
213
214 virtual BlendStateHandle loadBlendState(const BlendState& blendStateColor, const BlendState& blendStateAlpha, const BlendFlags /*flags*/) { return loadBlendState(blendStateColor, blendStateAlpha); }
215
216 virtual BlendStateHandle loadBlendState(const BlendState* /*blendStateColor*/, const BlendState* /*blendStateAlpha*/, const uint32_t /*numBlendStates*/, const BlendFlags /*flags*/) { return BlendStateHandle::NoHandle; }
217
223 virtual void releaseBlendState(BlendStateHandle handle) = 0;
224
228 virtual void releaseResources() = 0;
229 };
230}
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
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.
Describes a single depth stencil view and which resources to use from the underlying texture.
TextureHandle texture
Texture handle.
uint16_t numLayers
Number of available layers to write to.
uint8_t levelIndex
Index of the mipmap level to render to.
uint16_t layerIndex
Index of the first layer (if array) to write depth to.
static const Handle_t NoHandle
Represents a handle to nothing.
Definition: Common.h:78
static const Handle_t InvalidHandle
Represents an invalid handle.
Definition: Common.h:81
Provides render target management functionality.
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 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 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.
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.
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 BlendStateHandle loadBlendState(const BlendState &blendStateColor, const BlendState &)
Load a blend state object with separate blending for alpha channel.
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.
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.
Describes multiview framebuffer layout.
uint8_t samples
Number of multisample samples, 0 and 1 implies no multisampling.
uint8_t baseIndex
Texture array index for first texture slice to render into.
uint8_t count
Number of texture array slices to render into.
Encapsulates state for primitive rasterization in a state object.
Describes a single render target view and which resources to use from the underlying texture.
uint16_t layerIndex
Index of the first layer (if array) to render to.
uint16_t numLayers
Number of available layers to render to.
TextureHandle texture
Texture handle.
uint8_t levelIndex
Index of the mipmap level to render to.