Cogs.Core
OctRenderer.cpp
1#include "Renderer/Tasks/RenderListTask.h"
2#include "Renderer/Renderer.h"
3#include "Renderer/RenderStateUpdater.h"
4#include "Renderer/Tasks/FilterListTask.h"
5#include "Resources/VertexFormats.h"
6#include "Resources/MaterialManager.h"
7#include "Components/Core/RenderComponent.h"
8#include "Components/Core/SceneComponent.h"
9#include "Systems/Core/CameraSystem.h"
10#include "Systems/Core/TransformSystem.h"
11#include "Renderer/Tasks/RenderListTask.h"
12#include "ExtensionRegistry.h"
13
14#include "OctRenderer.h"
15#include "../Systems/OctSystem.h"
16
17#include "Rendering/RasterizerState.h"
18#include "Rendering/IGraphicsDevice.h"
19#include "Rendering/IBuffers.h"
20#include "Rendering/IRenderTargets.h"
21
22#include "Foundation/Memory/MemoryBuffer.h"
23
24#include <unordered_map>
25#include <iterator>
26
27namespace {
28 using namespace Cogs;
29 using namespace Cogs::Core;
30
31 struct InstanceData
32 {
33 glm::vec4 min; // .w is age shift
34 glm::vec4 max; // .w is currently unused.
35 glm::vec4 texpos;
36 //glm::u16vec4 key;
37 glm::uvec4 key;
38 };
39
40 struct OctParams
41 {
42 glm::vec3 eye_local;
43 float valueMin;
44 glm::vec3 lightdir_local;
45 float valueScale; // 1.0/(max-min)
46 float turbidity;
47 float ageScale;
48 };
49
50 struct DebugConstants
51 {
52 glm::mat4 projectionMatrix;
53 glm::mat4 viewMatrix;
54 glm::mat4 worldMatrix;
55 glm::vec4 diffuseColor;
56 };
57
58 static const uint32_t indices[] = {
59 0, 1, 2,
60 1, 3, 2,
61
62 4, 6, 5,
63 5, 6, 7,
64
65 0, 4, 1,
66 1, 4, 5,
67
68 0, 2, 6,
69 6, 4, 0,
70
71 1, 7, 3,
72 1, 5, 7,
73
74 3, 6, 2,
75 3, 7, 6
76 };
77
78 static const uint32_t edgeIndices[] = {
79 0, 1, 0, 2, 0, 4,
80 1, 3, 1, 5,
81 2, 3, 2, 6,
82 3, 7,
83 4, 5, 4, 6,
84 5, 7,
85 6, 7
86 };
87
88 static const glm::vec3 positions[] = {
89 glm::vec3(0, 0, 0),
90 glm::vec3(1, 0, 0),
91 glm::vec3(0, 1, 0),
92 glm::vec3(1, 1, 0),
93
94 glm::vec3(0, 0, 1),
95 glm::vec3(1, 0, 1),
96 glm::vec3(0, 1, 1),
97 glm::vec3(1, 1, 1),
98 };
99
100 static const glm::vec4 boxColor[4] = {
101 glm::vec4(0.4f, 1.0f, 0.2f, 1.0f),
102 glm::vec4(0.4f, 1.0f, 1.0f, 1.0f),
103 glm::vec4(0.4f, 0.4f, 1.0f, 1.0f),
104 glm::vec4(1.0f, 0.4f, 1.0f, 1.0f),
105 };
106
107 static void octtreeDebugRenderCallback(RenderTaskContext * taskContext, DrawContext * drawContext, const RenderItem * item)
108 {
109 RenderInstrumentationScope(taskContext->device->getImmediateContext(), SCOPE_VOLUMETRIC, "Octtree::debugRenderCallback");
110 auto * device = drawContext->device;
111 auto * context = drawContext->deviceContext;
112 const auto * octtreeData = (Volumetric::OctData*)item->callbackData;
113 const auto * transComp = octtreeData->comp->getComponent<TransformComponent>();
114 auto & worldFromLocal = drawContext->context->transformSystem->getLocalToWorld(transComp);
115
116 Volumetric::OctSystem* octSys = octtreeData->comp->system;
117 if (!octSys->isDebugEffectReady(drawContext->context)) {
118 return;
119 }
120
121 //context->setRasterizerState(drawContext->renderer->renderStates.getRasterizerState(Cogs::RasterizerState::DefaultState()));
122 context->setRasterizerState(taskContext->states->rasterizerStateHandles[drawContext->renderer->getRenderStates().getRasterizerState(Cogs::RasterizerState::DefaultState())]);
123 context->setDepthStencilState(drawContext->renderer->getRenderStates().commonDepthStates[RenderStates::noWriteDepthStencilState]);
124 context->setBlendState(drawContext->renderer->getRenderStates().blendStates[size_t(BlendMode::None)].handle);
125
126 auto cubeIndices = device->getBuffers()->loadIndexBuffer(edgeIndices, sizeof(edgeIndices) / sizeof(uint32_t), sizeof(uint32_t));
127 drawContext->deviceContext->setIndexBuffer(cubeIndices);
128
129 Cogs::VertexBufferHandle cubeVertices = device->getBuffers()->loadVertexBuffer(positions,
130 sizeof(positions) / sizeof(glm::vec3),
131 Cogs::Core::VertexFormats::Pos3f); // format is Vec3f
132 uint32_t strides[] = { sizeof(glm::vec3) };
133 drawContext->deviceContext->setVertexBuffers(&cubeVertices, 1, strides, nullptr);
134
135 context->setInputLayout(octSys->inputLayoutHandle);
136 context->setEffect(octSys->effectHandle);
137
138 Cogs::BufferHandle constantBuffer = device->getBuffers()->loadBuffer(nullptr, sizeof(DebugConstants), Usage::Dynamic, AccessMode::Write, BindFlags::ConstantBuffer);
139
140 auto renderNode = [&](const Volumetric::NodeBlock& node)
141 {
142 glm::mat4 world =
143 worldFromLocal *
144 Volumetric::OctSystem::LocalFromIndexSpaceTransform(*octtreeData->comp, *octtreeData)*
145 glm::translate(glm::mat4(), glm::vec3(node.extentMin)) *
146 glm::scale(glm::mat4(), glm::vec3(node.extentMax - node.extentMin));
147
148 //world = glm::translate(world, glm::vec3(octtreeData->shift.x + node.extentMin.x,
149 // octtreeData->shift.y + node.extentMin.y,
150 // octtreeData->shift.z + node.extentMin.z));
151 //world = glm::scale(world, glm::vec3(node.extentMax - node.extentMin));
152
153 //world = glm::scale(world, glm::vec3(static_cast<float>(1 << node.ix4.w)));
154 //world = glm::translate(world, glm::vec3(node.ix4.x,
155 // node.ix4.y,
156 // node.ix4.z));
157
158 {
159 MappedBuffer<DebugConstants> constants(context, constantBuffer, MapMode::WriteDiscard);
160 if (constants) {
161 constants->projectionMatrix = drawContext->cameraData->projectionMatrix;
162 constants->viewMatrix = drawContext->cameraData->viewMatrix;
163 constants->worldMatrix = world;
164 constants->diffuseColor = boxColor[node.ix4.w & 3];
165 }
166 }
167 context->setConstantBuffer("DebugBuffer", constantBuffer);
168
169 context->drawIndexed(Cogs::PrimitiveType::LineList, 0, 0);
170 };
171
172#if 1
173 for (const auto nodeIx : octtreeData->front) {
174 renderNode(octtreeData->nodes[nodeIx]);
175 }
176#elif 1
177 for (const auto & node : octtreeData->nodes) {
178 //if (node.ix4.w < 1) continue;
179 //if(2 <= node.ix4.w) continue;
180 renderNode(node);
181 }
182#else
183 for (const auto & it : octtreeData->baseBlocks) {
184 const auto & baseBlock = it.second;
185
186 glm::mat4 world = glm::translate(glm::vec3(baseBlock.i - 0x7fff,
187 baseBlock.j - 0x7fff,
188 baseBlock.k - 0x7fff));
189 {
190 MappedBuffer<DebugConstants> constants(context, constantBuffer, MapMode::WriteDiscard);
191 if (constants) {
192 constants->projectionMatrix = drawContext->cameraData->projectionMatrix;
193 constants->viewMatrix = drawContext->cameraData->viewMatrix;
194 constants->worldMatrix = world;
195 constants->diffuseColor = boxColor[node.ix4.w & 3];
196 }
197 }
198 context->setConstantBuffer("DebugBuffer", constantBuffer);
199
200 context->drawIndexed(Cogs::PrimitiveType::LineList, 0, 0);
201 }
202#endif
203
204 device->getBuffers()->releaseBuffer(constantBuffer);
205 device->getBuffers()->releaseIndexBuffer(cubeIndices);
206 device->getBuffers()->releaseVertexBuffer(cubeVertices);
207 }
208
209 static void renderCallback(RenderTaskContext * taskContext, DrawContext * drawContext, RenderListTask* task, const RenderItem * item)
210 {
211 const auto * octData = (Volumetric::OctData*)item->callbackData;
212 const auto * octComp = octData->comp;
213 const auto * camData = drawContext->cameraData;
214 auto * renderer = taskContext->renderer;
215 auto * device = renderer->getDevice();
216 auto * effects = device->getEffects();
217 auto * iContext = device->getImmediateContext();
218 auto * octtreeRenderer = octComp->system->renderer;
219
220 iContext->setViewport(camData->viewportOrigin.x,
221 camData->viewportOrigin.y,
222 camData->viewportSize.x != 0 ? camData->viewportSize.x : renderer->getSize().x,
223 camData->viewportSize.y != 0 ? camData->viewportSize.y : renderer->getSize().y);
224
225 //iContext->setDepthStencilState(item->depthState);
226 iContext->setDepthStencilState(taskContext->states->commonDepthStates[item->depthState]);
227 //iContext->setBlendState(item->transparencyState.blendState);
228 iContext->setBlendState(taskContext->states->blendStates[item->blendState].handle);
229 //iContext->setRasterizerState(getRasterizerState(renderer, item, camData->flipWindingOrder));
230
231 const RenderPassOptions passOptions = initRenderPassOptions(*camData, item->materialInstance);
232 iContext->setRasterizerState(taskContext->states->rasterizerStateHandles[getRasterizerState(renderer, *item, passOptions, camData->flipWindingOrder)]);
233
234 applyMaterialPermutation(taskContext, drawContext, drawContext->binding, item->renderMaterialInstance);
235 task->applyMaterial(*drawContext, *item, drawContext->binding);
236 //updateEnvironmentBindings(drawContext, drawContext->binding);
237 applyMaterialInstance(drawContext, drawContext->binding, item->renderMaterialInstance);
238
239 //auto renderMaterialInstance = renderer->resources.getRenderMaterialInstance(materialInstance);
240 assert(item->renderMaterialInstance);
241
242 Cogs::VertexBufferHandle vertexBuffers[2] = {
243 octtreeRenderer->cubeVertices,
244 octData->instanceBufferHandle
245 };
246
247 //FIXME: Set strides/offsets.
248 iContext->setVertexBuffers(vertexBuffers, 2);
249 iContext->setIndexBuffer(octtreeRenderer->cubeIndices);
250
251 EngineBuffers & engineBuffers = renderer->getEngineBuffers();
252 ObjectBuffer & objectParameters = engineBuffers.objectBuffer;
253
254
255 const auto & worldMatrix = taskContext->context->transformSystem->getLocalToWorld(octComp->getComponent<TransformComponent>());
256 auto worldFromIndex =
257 worldMatrix *
258 Volumetric::OctSystem::LocalFromIndexSpaceTransform(*octComp, *octData);
259
260 objectParameters.encodeWorldMatrix(worldFromIndex);
261
262 auto localToView = camData->viewMatrix * worldFromIndex;
263
264 const auto bindings = drawContext->binding;
265 if(!HandleIsValid(engineBuffers.objectBufferHandle)) return;
266 {
267 Cogs::MappedBuffer<ObjectBuffer> objectBuffer(iContext, engineBuffers.objectBufferHandle, Cogs::MapMode::WriteDiscard);
268 if (objectBuffer) std::memcpy(objectBuffer.get(), &objectParameters, sizeof(ObjectBuffer));
269 }
270 iContext->setConstantBuffer(bindings->objectBufferBinding, engineBuffers.objectBufferHandle);
271 auto octBinding = effects->getConstantBufferBinding(drawContext->binding->renderEffect->effectHandle, "OctParams");
272 if (HandleIsValid(octBinding)) {
273 {
274 auto eye_local = glm::inverse(localToView)*glm::vec4(0, 0, 0, 1);
275 Cogs::MappedBuffer<OctParams> op(iContext, octtreeRenderer->octParamsBuffer, Cogs::MapMode::WriteDiscard);
276
277 if (op) {
278 op->eye_local = (1.f / eye_local.w)*glm::vec3(eye_local);
279 op->valueMin = octComp->valueMin;
280 op->lightdir_local = -glm::normalize(glm::vec3(1, 1, 1));
281 op->valueScale = 1.f / (octComp->valueMax - octComp->valueMin);
282 op->turbidity = std::max(1.f, octComp->turbidity);
283 op->ageScale = octComp->ageScale;
284 }
285 }
286 iContext->setConstantBuffer(octBinding, octtreeRenderer->octParamsBuffer);
287 }
288
289 unsigned unit = (unsigned)item->materialInstance->textureVariables.size();
290 iContext->setTexture("atlasTexture0", unit, octData->atlas.textureAtlas0);
291 iContext->setSamplerState("atlasSampler0", unit, octtreeRenderer->atlasSampler);
292 unit++;
293
294 if (HandleIsValid(octData->atlas.textureAtlas1)) {
295 iContext->setTexture("atlasTexture1", unit, octData->atlas.textureAtlas1);
296 iContext->setSamplerState("atlasSampler1", unit, octtreeRenderer->atlasSampler);
297 unit++;
298 }
299
300 RenderTexture * transferTex = drawContext->renderer->getRenderResources().getRenderTexture(octComp->transferTexture);
301 if (transferTex == nullptr) return;
302
303 iContext->setTexture("transferTexture", unit, transferTex->textureHandle);
304 iContext->setSamplerState("transferSampler", unit, octtreeRenderer->atlasSampler);
305 unit++;
306
307 iContext->drawInstancedIndexed(Cogs::PrimitiveType::TriangleList, 0, octData->instanceCount, 0, 36);
308 }
309}
310
312{
313 octSystem = ExtensionRegistry::getExtensionSystem<OctSystem>(context);
314 this->device = device;
315 this->context = context;
316 auto * buffers = device->getBuffers();
317 auto * textures = device->getTextures();
318
319 octParamsBuffer = buffers->loadBuffer(nullptr, sizeof(OctParams), Usage::Dynamic, AccessMode::Write, BindFlags::ConstantBuffer);
320
321 cubeIndices = device->getBuffers()->loadIndexBuffer(indices, sizeof(indices) / sizeof(uint32_t), sizeof(uint32_t));
322 cubeVertices = device->getBuffers()->loadVertexBuffer(positions, sizeof(positions) / sizeof(glm::vec3), Cogs::Core::VertexFormats::Pos3f);
323
329 atlasSampler = textures->loadSamplerState(sampler);
330
331
332 depthStencilState = device->getRenderTargets()->loadDepthStencilState(DepthStencilState{ true, false, DepthStencilState::Less });
333
334 Cogs::VertexElement elements[] = {
335 { sizeof(float) * 0, Cogs::DataFormat::X32Y32Z32W32_FLOAT, Cogs::ElementSemantic::InstanceVector, 0, Cogs::InputType::InstanceData, 1 },
336 { sizeof(float) * 4, Cogs::DataFormat::X32Y32Z32W32_FLOAT, Cogs::ElementSemantic::InstanceVector, 1, Cogs::InputType::InstanceData, 1 },
337 { sizeof(float) * 8, Cogs::DataFormat::X32Y32Z32W32_FLOAT, Cogs::ElementSemantic::InstanceVector, 2, Cogs::InputType::InstanceData, 1 },
338 { sizeof(float) * 12, Cogs::DataFormat::R32G32B32A32_UINT, Cogs::ElementSemantic::InstanceVector, 3, Cogs::InputType::InstanceData, 1 }
339 };
340
341 octStreamsLayout.vertexFormats[0] = VertexFormats::Pos3f;
342 octStreamsLayout.vertexFormats[1] = Cogs::VertexFormats::createVertexFormat(elements, std::size(elements));
343 octStreamsLayout.numStreams = 2;
344 octStreamsLayout.updateHash();
345
346 defaultMatInstance = context->materialInstanceManager->createMaterialInstance(context->materialManager->getDefaultMaterial());
347}
348
349void Cogs::Core::Volumetric::OctRenderer::handleEvent(uint32_t eventId, const DrawContext * renderingContext)
350{
351 auto * iContext = device->getImmediateContext();
352 auto * buffers = device->getBuffers();
353
354 switch (eventId) {
356 for (auto & octComp : octSystem->pool) {
357 auto & octData = octSystem->getData(&octComp);
358
359 if (octData.gpuCacheWipe) handleAtlasWipe(renderingContext, octComp, octData);
360
361 octData.atlas.handleStaging(renderingContext, octComp, octData, octData.currentTimestamp);
362
363 octData.instanceCount = static_cast<unsigned>(octData.front.size());
364 if (octData.instanceCount) {
365 {
366 static bool missingDataPrev = false;
367
368 bool missingData = false;
369
370 unsigned W = octComp.tileSize * octComp.gpuCacheSize;
371
372 float texW = (octComp.tileSize - 2.f) / W;
373 float texS = 1.f / W;
374
375 octData.instanceBufferHandle = buffers->loadVertexBuffer(nullptr, octData.instanceCount, octStreamsLayout.vertexFormats[1]);
376 Cogs::MappedBuffer<InstanceData> instanceData(iContext, octData.instanceBufferHandle, Cogs::MapMode::WriteDiscard, octData.front.size());
377
378 if (instanceData) {
379 for (size_t i = 0; i < octData.instanceCount; i++) {
380 const auto & node = octData.nodes[octData.front[i]];
381
382 auto slotPos = octData.atlas.slotPosition(octComp, createTileKey(node.ix4, octData.alignMinToZeroShift));
383
384 bool missing = (slotPos.x == 0) && (slotPos.y == 0) && (slotPos.z == 0);
385
386 if (missing) missingData = true;
387
388
389 const float scale = static_cast<float>(1 << node.ix4.w);
390 const glm::uvec3 lll = glm::uvec3(node.ix4.x << node.ix4.w,
391 node.ix4.y << node.ix4.w,
392 node.ix4.z << node.ix4.w);
393
394 float ageShift = 0.f;
395 if (octComp.alphaCallback.func) {
396 ageShift = octComp.alphaCallback.func(octComp.alphaCallback.data,
397 octData.atlas.slots[slotPos.w].clientData);
398 }
399
400 instanceData[i].min = glm::vec4((1.f / scale)*glm::vec3(glm::uvec3(node.extentMin) - lll), ageShift);
401 instanceData[i].max = glm::vec4((1.f / scale)*glm::vec3(glm::uvec3(node.extentMax) - lll), 0.f);
402
403 instanceData[i].texpos = glm::vec4((float)slotPos.x / octComp.gpuCacheSize + texS,
404 (float)slotPos.y / octComp.gpuCacheSize + texS,
405 (float)slotPos.z / octComp.gpuCacheSize + texS,
406 missing ? -1.f : texW);
407
408 assert(0 <= instanceData[i].min.x);
409 assert(0 <= instanceData[i].min.y);
410 assert(0 <= instanceData[i].min.z);
411 assert(instanceData[i].max.x <= 1.f);
412 assert(instanceData[i].max.y <= 1.f);
413 assert(instanceData[i].max.z <= 1.f);
414 instanceData[i].key = node.ix4;
415 }
416 }
417 if (missingDataPrev != missingData) {
418 //std::cerr << "Render tile is " << (missingData ? "" : "not ") << "missing\n";
419 missingDataPrev = missingData;
420 }
421 }
422 }
423 }
424 break;
425
427 for (const auto & octRenderComp : octSystem->pool) {
428 auto & octRenderData = octSystem->getData(&octRenderComp);
429 if (octRenderData.instanceCount) {
430 buffers->releaseVertexBuffer(octRenderData.instanceBufferHandle);
431 }
432 }
433 break;
434 default:
435 break;
436 }
437}
438
439void Cogs::Core::Volumetric::OctRenderer::handleAtlasWipe(const DrawContext * renderingContext, OctComponent& octComp, OctData& octData)
440{
441 octData.gpuCacheWipe = false;
442 octComp.tileRequests.clear();
443
444 while (!octData.tileResponses.empty()) {
445 octData.tileResponsesStash.push_back(std::move(octData.tileResponses.back()));
446 octData.tileResponses.pop_back();
447 }
448 octData.atlas.reset(renderingContext, octData, octComp.tileSize, octComp.gpuCacheSize, octData.currentTimestamp);
449}
450
451void Cogs::Core::Volumetric::OctRenderer::generateCommands(const RenderTaskContext * /*renderingContext*/, RenderList * renderList)
452{
453 for (auto & octComp : octSystem->pool) {
454 auto * sceneComp = octComp.getComponent<SceneComponent>();
455 if (sceneComp->visible == false) continue;
456
457 const auto * transformComponent = octComp.getComponent<TransformComponent>();
458 if (!transformComponent) continue;
459
460 auto & octData = octSystem->getData(&octComp);
461 if (octData.instanceCount == 0) continue;
462
463 if (!HandleIsValid(octData.atlas.textureAtlas0)) continue;
464
465 if (octComp.drawDebug) {
466 auto & item = renderList->createCustom(&debugStreamsLayout);
467 item.layer = RenderLayers::Default;
468 //item.bbox = Geometry::BoundingBox{ glm::vec3(-100.f), glm::vec3(100.f) }; // FIXME: world-space bounds
469
470 //item.material = defaultMatInstance->material;
471 item.materialInstance = defaultMatInstance.resolve();
472
473 item.blendState = (uint16_t)BlendMode::None; // TransparencyState{ renderer->renderStates.noBlendStateHandle, false }; // No transparency for now.
474 item.depthState = (uint16_t)DepthMode::NoWrite;// depthStencilState;
475
476 item.flags = RenderItemFlags::Custom;
477 item.setCallbackData(&octData);
478 item.callback = octtreeDebugRenderCallback;
479 }
480
481 auto & item = renderList->createCustom(&octStreamsLayout);
482 item.layer = RenderLayers::Default;
483 //item.bbox = Geometry::BoundingBox{ glm::vec3(-100.f), glm::vec3(100.f) }; // FIXME
484
485 item.materialInstance = octData.materialInstance.resolve();
486 //item.material = item.materialInstance->material;
487
488 //item.transparencyState = TransparencyState{ renderer->renderStates.noBlendStateHandle, true, 0 };
489 item.blendState = (uint16_t)BlendMode::None; // TransparencyState{ renderer->renderStates.noBlendStateHandle, false }; // No transparency for now.
490 item.depthState = (uint16_t)DepthMode::NoWrite;// depthStencilState;
491
492 item.flags = RenderItemFlags::Custom2 | RenderItemFlags::Transparent;
493 item.setCallbackData(&octData);
494 item.callback2 = renderCallback;
495 }
496}
ComponentType * getComponent() const
Definition: Component.h:159
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
RenderStates & getRenderStates() override
Get the reference to the RenderStates structure.
Definition: Renderer.h:70
IGraphicsDevice * getDevice() override
Get the graphics device used by the renderer.
Definition: Renderer.h:46
Contains information on how the entity behaves in the scene.
Defines a 4x4 transformation matrix for the entity and a global offset for root entities.
Represents a graphics device used to manage graphics resources and issue drawing commands.
virtual IEffects * getEffects()=0
Get a pointer to the effect management interface.
virtual ITextures * getTextures()=0
Get a pointer to the texture management interface.
virtual IContext * getImmediateContext()=0
Get a pointer to the immediate context used to issue commands to the graphics device.
virtual IBuffers * getBuffers()=0
Get a pointer to the buffer management interface.
virtual IRenderTargets * getRenderTargets()=0
Get a pointer to the render target management interface.
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
bool HandleIsValid(const ResourceHandle_t< T > &handle)
Check if the given resource is valid, that is not equal to NoHandle or InvalidHandle.
@ None
No blending enabled for opaque shapes, defaults to Blend for transparent shapes.
@ NoWrite
Depth test enabled, write disabled.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
@ InstanceData
Per instance data.
@ LineList
List of lines.
@ TriangleList
List of triangles.
@ InstanceVector
Instance vector semantic.
@ Write
The buffer can be mapped and written to by the CPU after creation.
Definition: Flags.h:50
@ ConstantBuffer
The buffer can be bound as input to effects as a constant buffer.
Definition: Flags.h:72
std::vector< TextureValue > textureVariables
Texture property values for this instance.
VertexFormatHandle vertexFormats[maxStreams]
COGSCORE_DLL_API void updateHash()
RenderLayers layer
Visibility mask.
Definition: RenderList.h:172
@ PostRender
Rendering has finished for a given rendering context.
Definition: IRenderer.h:101
@ PreRender
Pre rendering happening for a given rendering context.
Definition: IRenderer.h:93
ResourceType * resolve() const
Resolve the handle, returning a pointer to the actual resource.
Representing a block or node in the oct-tree.
Definition: OctSystem.h:49
std::vector< TileRequest > tileRequests
Requests for tiles, populated by OctSystem::update, consumed by provider.
Definition: OctComponent.h:106
void handleEvent(uint32_t eventId, const DrawContext *renderingContext) override
Called when rendering events occur.
void initialize(Context *context, IGraphicsDevice *device) override
Initialize the extension using the given context and device.
bool isDebugEffectReady(Context *context)
Definition: OctSystem.cpp:204
Encapsulates state for depth buffer usage and stencil buffer usage in a state object.
virtual IndexBufferHandle loadIndexBuffer(const void *indexData, const size_t count, const size_t indexSize)=0
Loads a new index buffer and populates it with the given indexData.
virtual VertexBufferHandle loadVertexBuffer(const void *vertexData, const size_t count, const VertexFormat &vertexFormat)=0
Loads a new vertex buffer and populates it with the given data.
virtual void setIndexBuffer(IndexBufferHandle bufferHandle, uint32_t stride=4, uint32_t offset=0)=0
Sets the current index buffer.
virtual void setVertexBuffers(const VertexBufferHandle *vertexBufferHandles, const size_t count, const uint32_t *strides, const uint32_t *offsets)=0
Sets the current vertex buffers.
virtual DepthStencilStateHandle loadDepthStencilState(const DepthStencilState &depthStencilState)=0
Load a depth stencil state object.
@ WriteDiscard
Write access. When unmapping the graphics system will discard the old contents of the resource.
Definition: Flags.h:103
Provides RAII style mapping of a buffer resource.
Definition: IBuffers.h:160
static RasterizerState DefaultState()
Constructs a rasterizer state initialized with the default values.
Encapsulates state for texture sampling in a state object.
Definition: SamplerState.h:12
static SamplerState & DefaultState()
Constructs a sampler state initialized with the default values.
Definition: SamplerState.h:85
AddressMode addressModeW
Specifies the addressing mode along the W axis in texture coordinate space.
Definition: SamplerState.h:67
AddressMode addressModeS
Specifies the addressing mode along the S axis in texture coordinate space.
Definition: SamplerState.h:63
@ Clamp
Texture coordinates are clamped to the [0, 1] range.
Definition: SamplerState.h:17
@ MinMagMipLinear
Linear sampling for both minification and magnification.
Definition: SamplerState.h:35
FilterMode filter
Specifies the filter to use for texture sampling.
Definition: SamplerState.h:70
AddressMode addressModeT
Specifies the addressing mode along the T axis in texture coordinate space.
Definition: SamplerState.h:65
@ Dynamic
Buffer will be loaded and modified with some frequency.
Definition: Flags.h:30
Vertex element structure used to describe a single data element in a vertex for the input assembler.
Definition: VertexFormat.h:38