Cogs.Core
IRenderTargets.h
1#pragma once
2
3#include "Common.h"
4#include "DataFormat.h"
5#include "RasterizerState.h"
6#include "DepthStencilState.h"
7#include "BlendState.h"
8
9#include "Foundation/StringView.h"
10
11namespace Cogs
12{
18 {
22 uint16_t layerIndex;
24 uint16_t numLayers;
26 uint8_t levelIndex;
27 };
28
34 {
38 uint16_t layerIndex;
40 uint16_t numLayers;
42 uint8_t levelIndex;
43 };
44
50 uint8_t samples;
52 uint8_t baseIndex;
54 uint8_t count;
55 };
56
57
62 {
64 TextureFormat colorFormats[8] = {};
66 TextureFormat depthStencilFormat = TextureFormat::Unknown;
68 uint8_t numColorTargets = 0;
70 uint8_t samples = 1;
71 };
72
77 {
81 virtual void annotate(RenderTargetHandle handle, const StringView& name) { (void)handle; (void)name; }
82
86 virtual void annotate(DepthStencilHandle handle, const StringView& name) { (void)handle; (void)name; }
87
95 {
96 return createRenderTarget(&textureHandle, 1);
97 }
98
106 virtual RenderTargetHandle createRenderTarget(TextureHandle * textureHandles, const size_t numTextureHandles)
107 {
108 RenderTargetViewDescription view_desc[8] = {};
109 for(size_t i=0; i<numTextureHandles; i++){
110 view_desc[i].texture = textureHandles[i];
111 view_desc[i].layerIndex = 0;
112 view_desc[i].numLayers = 1;
113 view_desc[i].levelIndex = 0;
114 }
115 return createRenderTarget(view_desc, numTextureHandles);
116 }
117
126 virtual RenderTargetHandle createRenderTarget(const RenderTargetViewDescription * renderTargetViews, const size_t numViews) = 0;
127
128 virtual RenderTargetHandle createRenderTarget(const RenderTargetViewDescription* /*renderTargetViews*/, const size_t /*numViews*/, const MultiViewDescription& /*multiView*/)
129 {
131 }
132
138 virtual void releaseRenderTarget(RenderTargetHandle renderTargetHandle) = 0;
139
147 virtual RenderTargetLayout getLayout(const RenderTargetHandle renderTargetHandle, const DepthStencilHandle depthStencilHandle) = 0;
148
157
167 virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle handle, const TextureHandle textureHandle) = 0;
168
178
179
180 virtual DepthStencilHandle createDepthStencilTarget(const RenderTargetHandle /*handle*/, const DepthStencilViewDescription& /*depthStencilView*/, const MultiViewDescription& /*multiView*/)
181 {
183 }
184
190 virtual void releaseDepthStencilTarget(DepthStencilHandle depthStencilHandle) = 0;
191
199
206
213 virtual RasterizerStateHandle loadRasterizerState(const RasterizerState & rasterizerState) = 0;
214
221
228 virtual BlendStateHandle loadBlendState(const BlendState & blendState) = 0;
229
237 virtual BlendStateHandle loadBlendState(const BlendState& blendStateColor, const BlendState& /*blendStateAlpha*/) { return loadBlendState(blendStateColor); }
238
239 virtual BlendStateHandle loadBlendState(const BlendState& blendStateColor, const BlendState& blendStateAlpha, const BlendFlags /*flags*/) { return loadBlendState(blendStateColor, blendStateAlpha); }
240
241 virtual BlendStateHandle loadBlendState(const BlendState* /*blendStateColor*/, const BlendState* /*blendStateAlpha*/, const uint32_t /*numBlendStates*/, const BlendFlags /*flags*/) { return BlendStateHandle::NoHandle; }
242
248 virtual void releaseBlendState(BlendStateHandle handle) = 0;
249
253 virtual void releaseResources() = 0;
254 };
255}
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:50
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 RenderTargetLayout getLayout(const RenderTargetHandle renderTargetHandle, const DepthStencilHandle depthStencilHandle)=0
Get the view layout for the given render target / depth stencil target pair.
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 the formats and sample count of a render target's attachments.
TextureFormat colorFormats[8]
Formats of the color targets, only the first numColorTargets entries are valid.
TextureFormat depthStencilFormat
Format of the depth stencil target, TextureFormat::Unknown if there is none.
uint8_t samples
Number of samples, 1 implies no multisampling.
uint8_t numColorTargets
Number of valid entries in colorFormats.
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.