Cogs.Core
ClearResourceTask.cpp
1#include "ClearResourceTask.h"
2
3#include "Context.h"
4#include "Services/Time.h"
5#include "Renderer/RenderBuffer.h"
6#include "Platform/Instrumentation.h"
7
8#include "Rendering/IGraphicsDevice.h"
9#include "Rendering/IContext.h"
10
11#include "Foundation/Logging/Logger.h"
12
13namespace
14{
15 Cogs::Logging::Log logger = Cogs::Logging::getLogger("ClearResourceTask");
16}
17
18void Cogs::Core::ClearResourceTask::apply(RenderTaskContext * renderContext)
19{
20 RenderInstrumentationScope(renderContext->device->getImmediateContext(), SCOPE_RENDERING, "ClearResourceTask::apply");
21
22 auto device = renderContext->device;
23 auto deviceContext = device->getImmediateContext();
24
25 for (auto & r : output.resources) {
26 assert(r.type == RenderResourceType::RenderBuffer);
27 auto outputBuffer = output.get(RenderResourceType::RenderBuffer)->renderBuffer;
28
29 if (outputBuffer) {
30 if(fill_float){
31 deviceContext->clearResource(outputBuffer->getHandle(destinationIndex), fill.FValues);
32 }
33 else{
34 deviceContext->clearResource(outputBuffer->getHandle(destinationIndex), fill.UValues);
35 }
36 outputBuffer->setFrame(destinationIndex, renderContext->context->time->getFrame());
37 } else {
38 LOG_ERROR(logger, "Input/output buffers not valid.");
39 }
40 }
41}
Log implementation class.
Definition: LogManager.h:139
constexpr Log getLogger(const char(&name)[LEN]) noexcept
Definition: LogManager.h:180