3#include "Foundation/Logging/Logger.h"
6#include "MemoryContext.h"
9#include "RenderPipelineManager.h"
10#include "RenderStateUpdater.h"
11#include "RenderTarget.h"
13#include "CustomRenderer/BoundsRenderer.h"
14#include "CustomRenderer/DebugGeometryRenderers.h"
16#include "Rendering/Factory.h"
17#include "Rendering/ICapabilities.h"
18#include "Rendering/IContext.h"
19#include "Rendering/IGraphicsDevice.h"
20#include "Rendering/ITextures.h"
21#include "Rendering/IRenderTargets.h"
23#include "Resources/ResourceStore.h"
24#include "Resources/Texture.h"
25#include "Services/Variables.h"
26#include "Systems/Core/CameraSystem.h"
27#include "Systems/Core/EnvironmentSystem.h"
28#include "Systems/Core/LightSystem.h"
29#include "Utilities/Parsing.h"
31#include "InspectorGui/InspectorGuiRenderer.h"
33#include <glm/gtc/color_space.hpp>
39 void addLights(std::vector<const LightComponent*>& dst,
size_t& freeSlots, uint32_t& srcCount,
const std::vector<const LightComponent*>& src)
41 srcCount =
static_cast<uint32_t
>(std::min(freeSlots, src.size()));
42 freeSlots -= srcCount;
44 for (
size_t i = 0; i < srcCount; i++) {
45 dst.push_back(src[i]);
49 void buildSortedListOfActiveLights(
Context* context,
ActiveLights& activeLights,
const size_t maxLights)
54 std::vector<const LightComponent*> directionalShadowLights;
55 std::vector<const LightComponent*> pointShadowLights;
56 std::vector<const LightComponent*> directionalLights;
57 std::vector<const LightComponent*> pointLights;
58 const bool shadowsEnabled = context->
variables->get(
"renderer.shadowsEnabled",
false);
64 if (light.
lightType == LightType::Directional) {
65 directionalShadowLights.push_back(&light);
67 else if (light.
lightType == LightType::Point) {
68 pointShadowLights.push_back(&light);
72 if (light.
lightType == LightType::Directional) {
73 directionalLights.push_back(&light);
75 else if (light.
lightType == LightType::Point) {
76 pointLights.push_back(&light);
81 size_t numLightsTotal = directionalShadowLights.size() + directionalLights.size() + pointShadowLights.size() + pointLights.size();
82 if (maxLights < numLightsTotal) {
83 LOG_WARNING_ONCE(logger,
"More active lights (=%zu) than supported (=%zu)", numLightsTotal, maxLights);
86 activeLights.lights.clear();
87 size_t freeLightSlots = maxLights;
88 addLights(activeLights.lights, freeLightSlots, activeLights.numDirectionalShadowLights, directionalShadowLights);
89 addLights(activeLights.lights, freeLightSlots, activeLights.numDirectionalLights, directionalLights);
90 addLights(activeLights.lights, freeLightSlots, activeLights.numPointShadowLights, pointShadowLights);
91 addLights(activeLights.lights, freeLightSlots, activeLights.numPointLights, pointLights);
93 assert(activeLights.lights.size() <= maxLights);
115 renderContext.context = renderer->context;
116 renderContext.renderer = renderer;
117 renderContext.device = renderer->device;
118 renderContext.resources = &renderer->resources;
119 renderContext.states = &renderer->renderStates;
120 renderContext.engineBuffers = &renderer->engineBuffers;
121 renderContext.defaultRenderTarget = renderer->defaultTarget;
123 return renderContext;
130 drawContext.context = renderContext->context;
131 drawContext.renderer = renderContext->renderer;
132 drawContext.device = renderContext->device;
134 drawContext.cameraData = renderContext->cameraData;
135 drawContext.renderTarget = renderContext->defaultRenderTarget;
136 drawContext.engineBuffers = renderContext->engineBuffers;
137 drawContext.taskContext = renderContext;
138 drawContext.permutationIndex = 0;
145Cogs::Core::Renderer::Renderer(
Context * context) :
148 enginePermutations(context),
149 effectBindings(context->memory.get()),
156Cogs::Core::Renderer::~Renderer()
163 LOG_FATAL(logger,
"Cannot initialize renderer with nullptr device.");
167 Instrumentation::initializeGpu(context);
170 this->device = device;
172 auto backColor = context->
variables->get(
"renderer.backgroundColor", glm::vec4(0.5, 0.5, 0.5, 1));
173 setBackgroundColor(backColor);
178 context->
variables->set(
"renderer.DedicatedVideoMemoryMB", (
int)(device_capabilities.DedicatedVideoMemory/(1024*1024)));
179 context->
variables->set(
"renderer.DedicatedSystemMemoryMB", (
int)(device_capabilities.DedicatedSystemMemory/(1024*1024)));
180 context->
variables->set(
"renderer.SharedSystemMemoryMB", (
int)(device_capabilities.SharedSystemMemory/(1024*1024)));
183 enginePermutations.initialize(context);
184 renderStates.initialize(device);
186 resources.initialize(context,
this);
188 defaultTarget = resources.createRenderTarget();
192 renderContext = getRenderTaskContext(
this);
193 pipelineManager->initialize(&renderContext);
195 renderers->boundsRenderer.initialize(
this, device);
196 renderers->debugGeometryRenderer.initialize(
this, device);
197 renderers->imguiRenderer.initialize(context);
198 renderers->engineInspectorGuiRenderer.initialize(context,
this);
201 settings.anisotropicFiltering = context->
variables->get(
"renderer.anisotropicFiltering");
203 for (
auto & extension : extensions) {
204 extension->initialize(context, device);
210 renderers->debugGeometryRenderer.cleanup();
213 resources.releaseResource(defaultTarget);
216 pipelineManager->cleanup(&renderContext);
218 renderers->engineInspectorGuiRenderer.cleanup(context,
this);
219 renderers->imguiRenderer.cleanup();
221 if (context && context->
variables->get(
"renderer.reportLeaks",
false)) {
222 resources.cleanup(context);
225 renderStates.cleanup();
237 bool reverseDepth = context->
variables->get(
"renderer.reverseDepth",
false);
238 if(renderStates.reverseDepth != reverseDepth){
239 renderStates.reverseDepth = reverseDepth;
240 pipelineManager->dirty =
true;
244 renderStates.defaultDepthStencilStateHandle = renderTargets->loadDepthStencilState(defaultState);
245 renderStates.commonDepthStates[(int)
DepthMode::Default] = renderStates.defaultDepthStencilStateHandle;
246 renderStates.setupDepthStates(device);
250 renderStates.leqDepthStencilStateHandle = renderTargets->loadDepthStencilState(leqState);
256 if(reverseDepth) comparisonSamplerState.comparisonFunction = SamplerState::GreaterEqual;
257 else comparisonSamplerState.comparisonFunction = SamplerState::LessEqual;
259 for (
unsigned i = 0; i < 4; i++) {
260 if(reverseDepth) comparisonSamplerState.borderColor[i] = 0.f;
261 else comparisonSamplerState.borderColor[i] = 1.f;
264 renderStates.shadowSampler = textures->loadSamplerState(comparisonSamplerState);
270 renderContext.cameraData = &context->cameraSystem->getMainCameraData();
272 defaultTarget->setName(
"Cogs.BackBuffer");
273 defaultTarget->setOverride();
276 defaultTarget->width =
static_cast<int>(renderContext.cameraData->viewportSize.x);
277 defaultTarget->height =
static_cast<int>(renderContext.cameraData->viewportSize.y);
278 defaultTarget->samples = device->getSettings().
numSamples;
279 defaultTarget->clearColors = { backgroundColor };
281 const bool reloadEffects = context->
variables->get(
"renderer.reloadEffects",
false);
284 effectCache.reload(&renderContext);
285 context->
variables->set(
"renderer.reloadEffects",
false);
288 pipelineManager->setupPipeline(&renderContext);
290 buildSortedListOfActiveLights(context, activeLights, maxLights);
293 const auto eventContext = getDrawContext(&renderContext);
299 int samples = context->
variables->get(
"renderer.samples", 1);
300 context->
variables->set(
"impl.multiSample", samples > 1);
303 pipelineManager->initializeFrame(&renderContext);
304 pipelineManager->applyPipeline(&renderContext);
309 renderers->boundsRenderer.renderBounds(
this, context, *pipelineManager->getRenderList());
313 const auto eventContext = getDrawContext(&renderContext);
318 renderers->engineInspectorGuiRenderer.beginRender(context,
this);
319 renderers->engineInspectorGuiRenderer.render(context,
this);
321 if (context->callbacks.postRenderCallback) {
322 context->callbacks.postRenderCallback(context);
325 renderers->engineInspectorGuiRenderer.endRender(context,
this);
328 const DrawContext eventContext = getDrawContext(&renderContext);
330 context->cameraSystem->postRender(context);
333 pipelineManager->cleanupFrame(&renderContext);
339 this->backgroundColor = glm::vec4(glm::convertSRGBToLinear(glm::vec3(backgroundColor)),
343void Cogs::Core::Renderer::updateEffectFlags()
346 if (context->
variables->get(
"effects.logShaderInfo",
false)) {
349 if (context->
variables->get(
"effects.logShaderSource",
false)) {
355void Cogs::Core::Renderer::updateSettings()
358 if(context->
variables->exist(
"renderer.enableDeferred")){
359 static uint32_t t = 0;
362 LOG_WARNING(logger,
"Variable \"renderer.enableDeferred\" deprecated. Use \"renderer.pipeline\": \"Pipelines/Deferred.pipeline\".");
364 if(context->
variables->get(
"renderer.enableDeferred",
false))
365 context->
variables->set(
"renderer.pipeline",
"Pipelines/Deferred.pipeline");
371 default: settings.transparencyAlgorithm = RenderSettings::TransparencyAlgorithm::Regular;
break;
380 default: settings.blendKernel = RenderSettings::BlendKernel::Alpha;
break;
383 settings.defaultRenderTargetClear = context->
variables->get(
"renderer.backBuffer.clear.enable",
true);
385 if (
Variable* var = context->
variables->get(
"renderer.backBuffer.sRGB"); var->isEmpty()) {
386 switch (context->device->getType()) {
388 settings.defaultRenderTargetExpectsSRGB =
true;
391 settings.defaultRenderTargetExpectsSRGB =
false;
394 var->setBool(settings.defaultRenderTargetExpectsSRGB);
397 settings.defaultRenderTargetExpectsSRGB = var->getBool();
402 if (var->isEmpty()) {
403 var->setValue(
"Exact");
416 settings.sRGBConversion = RenderSettings::SRGBConversion::Exact;
422 if (var->isEmpty()) {
423 var->setValue(
"Filmic");
439 settings.tonemapper = RenderSettings::Tonemapper::Filmic;
443 settings.beersScaleFactor = context->
variables->get(
"renderer.beers.scaleFactor", 1.f);
445 settings.ambientIntensity = context->
variables->get(
"renderer.ambientLightIntensity", 0.f);
446 std::string acStr = context->
variables->get(
"renderer.ambientLightColor",
"1 1 1");
447 static std::string prev;
450 auto acTokens = tokenize(acStr);
451 parseValues(glm::value_ptr(settings.ambientColor), acTokens, 3);
454 settings.ambientColor = glm::convertSRGBToLinear(settings.ambientColor);
462 return projectionMatrix;
465 if(context->
variables->get(
"renderer.reverseDepth",
false)){
466 static glm::mat4 reverse(
472 projectionMatrix = reverse * projectionMatrix;
481 static glm::mat4 depthScale = glm::scale(glm::mat4(1.0f), glm::vec3(1, 1, 0.5f));
482 static glm::mat4 bias(
489 glm::mat4 projection = depthScale * bias * projectionMatrix;
495 static glm::mat4 depthScale = glm::scale(glm::mat4(1.0f), glm::vec3(1, -1, 0.5f));
496 static glm::mat4 bias(
503 glm::mat4 projection = depthScale * bias * projectionMatrix;
510 return projectionMatrix;
513 static glm::mat4 depthScale = glm::scale(glm::mat4(1.0f), glm::vec3(1, 1, 0.5f));
514 static glm::mat4 bias(
521 glm::mat4 projection = depthScale * bias * projectionMatrix;
526 return projectionMatrix;
529 LOG_WARNING(logger,
"Unknown device type.");
530 return projectionMatrix;
536 return inverseProjectionMatrix;
544 glm::vec4 x = glm::vec4(0.1, 0.2, 0.3, 1.0);
545 glm::mat4 clipFromViewport (
551 return inverseProjectionMatrix * clipFromViewport;
556 return inverseProjectionMatrix;
561 glm::mat4 scale = glm::scale(glm::mat4(1.0), glm::vec3(2.0, 2.0, 2.0));
562 static glm::mat4 bias(
568 return inverseProjectionMatrix * bias * scale;
571 glm::mat4 scale = glm::scale(glm::mat4(1.0), glm::vec3(2.0, 2.0, 1.0));
572 static glm::mat4 bias(
578 return inverseProjectionMatrix * bias * scale;
581 return inverseProjectionMatrix;
584 LOG_WARNING(logger,
"Unknown device type.");
585 return inverseProjectionMatrix;
590 if(context->
variables->get(
"renderer.reverseDepth",
false)) {
597 if(context->
variables->get(
"renderer.reverseDepth",
false)) {
619 device->
endFrame(syncInterval, presentFlags);
629 extensions.push_back(extension);
632 extension->initialize(context, device);
638 auto it = std::find(extensions.begin(), extensions.end(), extension);
639 assert(it != extensions.end() &&
"Unregistering unknown IRendererExtension");
640 if (it != extensions.end()) {
641 extensions.erase(it);
652 auto format = TextureFormat::R8G8B8A8_UNORM_SRGB;
654 const size_t size = (size_t)settings.width * (
size_t)settings.height * Cogs::getBlockSize(format);
661 if(settings.numSamples > 1)
662 desc.target = ResourceDimensions::Texture2DMS;
664 desc.target = ResourceDimensions::Texture2D;
665 desc.width = settings.width;
666 desc.height = settings.height;
667 desc.format = format;
668 desc.samples = settings.numSamples;
670 texture = textures->loadTexture(desc,
nullptr);
673 auto renderTarget = renderTargets->createRenderTarget(&texture, 1);
674 auto depthStencilTarget = renderTargets->createDepthStencilTarget(renderTarget);
676 auto camera = context->cameraSystem->getMainCamera();
677 auto restoreViewport = camera->viewportSize;
678 camera->viewportSize = glm::vec2(settings.width, settings.height);
679 context->cameraSystem->update(context);
681 renderContext.cameraData = &context->cameraSystem->getMainCameraData();
683 pipelineManager->setupPipeline(&renderContext);
685 auto restoreRenderTargetHandle = defaultTarget->renderTargetHandle;
686 auto restoreDepthTargetHandle = defaultTarget->depthTargetHandle;
687 auto restoreWidth = defaultTarget->width;
688 auto restoreHeight = defaultTarget->height;
689 auto restoreSamples = defaultTarget->samples;
690 auto restoreColors = std::move(defaultTarget->clearColors);
692 defaultTarget->renderTargetHandle = renderTarget;
693 defaultTarget->depthTargetHandle = depthStencilTarget;
694 defaultTarget->width = settings.width;
695 defaultTarget->height = settings.height;
696 defaultTarget->samples = settings.numSamples;
697 defaultTarget->clearColors = { backgroundColor };
699 pipelineManager->initializeFrame(&renderContext);
700 pipelineManager->applyPipeline(&renderContext);
701 pipelineManager->cleanupFrame(&renderContext);
703 if (settings.numSamples > 1) {
705 auto resolveRt = renderTargets->createRenderTarget(&resolveTexture, 1);
706 auto resolveDt = renderTargets->createDepthStencilTarget(resolveRt);
708 deviceContext->resolveResource(texture, resolveTexture);
710 deviceContext->setRenderTarget(resolveRt, resolveDt);
712 deviceContext->readColorBuffer(readBuffer, 0, 0, settings.width, settings.height,
Framebuffer::Front);
714 renderTargets->releaseDepthStencilTarget(resolveDt);
715 renderTargets->releaseRenderTarget(resolveRt);
716 textures->releaseTexture(resolveTexture);
718 deviceContext->setRenderTarget(renderTarget, depthStencilTarget);
720 deviceContext->readColorBuffer(readBuffer, 0, 0, settings.width, settings.height,
Framebuffer::Front);
727 const size_t bufferSize = data.getStride() ? data.getStride() * settings.height : size;
728 bytes.assign(data.get(), data.get() + bufferSize);
731 *stride = data.getStride();
736 defaultTarget->renderTargetHandle = restoreRenderTargetHandle;
737 defaultTarget->depthTargetHandle = restoreDepthTargetHandle;
738 defaultTarget->width = restoreWidth;
739 defaultTarget->height = restoreHeight;
740 defaultTarget->samples = restoreSamples;
741 defaultTarget->clearColors = std::move(restoreColors);
743 camera->viewportSize = restoreViewport;
745 buffers->releaseBuffer(readBuffer);
746 renderTargets->releaseDepthStencilTarget(depthStencilTarget);
747 renderTargets->releaseRenderTarget(renderTarget);
748 textures->releaseTexture(texture);
753 for (
auto extension : extensions) {
754 extension->handleEvent(eventId, renderingContext);
760 const bool ditherEnabled = context->
variables->get(
"renderer.ditherEnabled",
false);
761 if(permutation->hasVariant(
"Dither"))
762 permutation->setVariant(
"Dither", ditherEnabled);
764 const bool reverseDepth = context->
variables->get(
"renderer.reverseDepth",
false);
765 if(permutation->hasVariant(
"ReverseDepth"))
766 permutation->setVariant(
"ReverseDepth", reverseDepth);
768 if(permutation->hasVariant(
"DepthNegativeOneToOne"))
771 if (!permutation->hasBuiltins())
return;
772 if (!permutation->isShadingPass() || permutation->isDepthOnly())
return;
774 if (
auto ec = context->environmentSystem->getGlobalEnvironment(); ec !=
nullptr) {
775 permutation->setVariant(
"SubseaSupport", ec->subseaSupport);
776 if(ec->imageBasedLighting) {
778 permutation->setVariant(
"ImageBasedLighting",
"PBR");
780 permutation->setVariant(
"ImageBasedLighting",
"Phong");
783 permutation->setVariant(
"ImageBasedLighting",
"Disabled");
788 const bool shadowsEnabled = (activeLights.numDirectionalShadowLights != 0) || (activeLights.numPointShadowLights != 0);
789 permutation->setVariant(
"NumDirectionalShadowLights",
static_cast<int>(activeLights.numDirectionalShadowLights));
790 permutation->setVariant(
"NumPointShadowLights",
static_cast<int>(activeLights.numPointShadowLights));
791 permutation->setVariant(
"NumDirectionalLights",
static_cast<int>(activeLights.numDirectionalLights));
792 permutation->setVariant(
"NumPointLights",
static_cast<int>(activeLights.numPointLights));
793 permutation->setVariant(
"ShadowsEnabled", shadowsEnabled);
794 if (shadowsEnabled) {
795 const Cogs::Core::SoftShadows softShadows = parseEnum<SoftShadows>(context->
variables->get(
"shadows.softShadows",
"Default"));
796 permutation->setVariant(
"SoftShadows", (
int)softShadows);
799 if(permutation->hasVariant(
"sRGBConversion")) {
800 switch (settings.sRGBConversion) {
801 case RenderSettings::SRGBConversion::Fast:
802 permutation->setVariant(
"sRGBConversion",
"Fast");
804 case RenderSettings::SRGBConversion::Approx:
805 permutation->setVariant(
"sRGBConversion",
"Approx");
807 case RenderSettings::SRGBConversion::Exact:
808 permutation->setVariant(
"sRGBConversion",
"Exact");
811 assert(
false &&
"Invalid enum");
816 if (permutation->hasVariant(
"Tonemapper")) {
817 switch (settings.tonemapper) {
818 case RenderSettings::Tonemapper::Reinhard:
819 permutation->setVariant(
"Tonemapper",
"Reinhard");
821 case RenderSettings::Tonemapper::Filmic:
822 permutation->setVariant(
"Tonemapper",
"Filmic");
824 case RenderSettings::Tonemapper::ACESLuminance:
825 permutation->setVariant(
"Tonemapper",
"ACESLuminance");
827 case RenderSettings::Tonemapper::PBRNeutral:
828 permutation->setVariant(
"Tonemapper",
"PBRNeutral");
831 assert(
false &&
"Invalid enum");
839 return &renderers->imguiRenderer;
844 return &renderers->engineInspectorGuiRenderer;
ComponentPool< ComponentType > pool
Pool of components managed by the system.
A Context instance contains all the services, systems and runtime components needed to use Cogs.
std::unique_ptr< class Variables > variables
Variables service instance.
Interface to the render resources.
Defines an extension to the renderer, capable of doing custom rendering.
Defines a single light source and its behavior.
LightType lightType
The type of light.
bool castShadows
If this light should cast shadows.
bool enabled
If the light is enabled.
Holds all LightComponent instances in the system.
void updatePermutation(EnginePermutation *permutation) override
Updates the EnginePermutation.
float getNearDepth() override
Get adjusted near plane depth.
IRenderResources * getResources() override
Get the render resources interface.
void registerExtension(IRendererExtension *extension) override
Registers the given extension with the renderer. Doesn not take ownership of pointer.
void setBackgroundColor(const glm::vec4 &backgroundColor) override
Set the background color applied to the output surface before rendering.
void renderScreenshot(const ScreenshotSettings &settings, std::vector< uint8_t > &bytes, uint32_t *stride=nullptr) override
Render screenshot.
glm::mat4 getViewFromViewportMatrix(glm::mat4 inverseProjectionMatrix) override
Get an adjusted inverse projection matrix mainly used in post processing.
void emitEvent(uint32_t eventId, const DrawContext *renderingContext)
Emits the given render event to all registered extensions.
void endFrame(uint32_t syncInterval=0, Cogs::PresentFlags presentFlags=PresentFlags::None) override
Signals the end of the current frame.
void unregisterExtension(IRendererExtension *extension) override
Unregister an extension with the renderer.
void cleanup() override
Cleanup the renderer, releasing all resources held.
float getClearDepth() override
Get adjusted clear depth used to render.
glm::mat4 getProjectionMatrix(const glm::mat4 projectionMatrix) override
Get an adjusted projection matrix used to render.
void render() override
Kick off the actual rendering, allowing the renderer to produce its output.
void beginFrame() override
Signals the beginning of a new frame.
Represents a graphics device used to manage graphics resources and issue drawing commands.
virtual ITextures * getTextures()=0
Get a pointer to the texture management interface.
virtual ICapabilities * getCapabilities()=0
Get a pointer to the capability management interface used to query the graphics device capability fla...
virtual IContext * getImmediateContext()=0
Get a pointer to the immediate context used to issue commands to the graphics device.
virtual void beginFrame()=0
Signal the beginning of a new frame to the graphics device.
virtual IBuffers * getBuffers()=0
Get a pointer to the buffer management interface.
virtual std::string getIdentifier() const
Get the graphics device identifier.
virtual GraphicsDeviceType getType() const
Get the type of the graphics device.
virtual void endFrame(uint32_t syncInterval=0, PresentFlags presentFlags=PresentFlags::None)=0
Signal the end of a frame to the graphics device.
virtual IRenderTargets * getRenderTargets()=0
Get a pointer to the render target management interface.
Log implementation class.
Provides a weakly referenced view over the contents of a string.
size_t hashLowercase(size_t hashValue=Cogs::hash()) const noexcept
Get the hash code of the string converted to lowercase.
constexpr size_t hash() const noexcept
Get the hash code of the string.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
@ Box
Bounding-box rendering over regular rendering.
@ Default
Default, depth test & write enabled.
constexpr Log getLogger(const char(&name)[LEN]) noexcept
Contains all Cogs related functionality.
@ Direct3D12
Graphics device using the Direct3D 12 API.
@ OpenGLES30
Graphics device using the OpenGLES 3.0 API.
@ Vulkan
Graphics device using the Vulkan API.
@ Direct3D11
Graphics device using the Direct3D 11 API.
@ OpenGL20
Graphics device using OpenGL, supporting at least OpenGL 2.0.
@ Null
Null device that implements no rendering functionality.
@ WebGPU
Graphics device using the WebGPU API Backend.
constexpr size_t hash() noexcept
Simple getter function that returns the initial value for fnv1a hashing.
PresentFlags
Flags controlling presentation.
@ Read
The buffer can be mapped and read from by the CPU after creation.
@ None
The buffer will not be bound to the graphics pipeline. Suitable for staging resources.
Render settings variables.
@ RenderGui
Rendering GUI elements.
@ PostRender
Rendering has finished for a given rendering context.
@ PreRender
Pre rendering happening for a given rendering context.
Screenshot render settings.
Runtime control variable.
Encapsulates state for depth buffer usage and stencil buffer usage in a state object.
@ GreaterOrEqual
Greater or equal depth.
@ LessOrEqual
Less or equal depth.
DepthFunction depthFunction
The depth function to use for depth testing.
static DepthStencilState DefaultState()
Constructs a depth stencil state object initialized with the default values.
EEffectFlags
Effect source flags.
@ LogShaderSource
Log the contents of the shader on error.
@ LogShaderInfo
Log detailed info about shaders.
Contains device capabilities.
bool DepthNegativeOneToOne
If true, min z depth=-1 otherwise it is min z depth = 0 (max z depth = 1).
int numSamples
Number of samples to use for back buffer MSAA.
static const Handle_t NoHandle
Represents a handle to nothing.
virtual const GraphicsDeviceCapabilities & getDeviceCapabilities() const
Gets the device capabilities in a structure.
virtual void setRenderTarget(const RenderTargetHandle handle, const DepthStencilHandle depthStencilHandle)=0
Sets the current render target and an associated depth stencil target.
Provides RAII style mapping of a buffer resource.
Encapsulates state for texture sampling in a state object.
AddressMode addressModeS
Specifies the addressing mode along the S axis in texture coordinate space.
@ Border
Texture color is set to the border color when outside [0, 1] range.
@ ComparisonMinMagMipLinear
Comparison filter for depth sample comparisons using linear interpolation sampling.
@ RenderTarget
The texture can be used as a render target and drawn into.