Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
IMPrimitive.cpp
Go to the documentation of this file.
1
2
4
7
14
15namespace Divide {
16
17namespace {
19 inline size_t GetSizeFactor(const NS_GLIM::GLIM_ENUM dataType) noexcept {
20 switch (dataType) {
23 case NS_GLIM::GLIM_ENUM::GLIM_4UB: return 1u;
24
26 case NS_GLIM::GLIM_ENUM::GLIM_2I: return 2u;
27
29 case NS_GLIM::GLIM_ENUM::GLIM_3I: return 3u;
30
32 case NS_GLIM::GLIM_ENUM::GLIM_4I: return 4u;
33
34 default: break;
35 }
36
38 return 0u;
39 }
40
42 switch (type) {
47
48 default: break;
49 }
50
52 }
53};
54
56{
63}
64
66 : _name(name)
67 , _context(context)
68{
69 _imInterface = std::make_unique<NS_GLIM::GLIM_BATCH>();
70
71 _dataBuffer = context.newGVD(1, name.c_str());
72
73 reset();
74}
75
77 clearBatch();
78 _drawFlags.fill(false);
79 _indexCount.fill(0u);
80 _indexBufferId.fill(0u);
81 _pipelines.fill(nullptr);
82
83 // Create general purpose render state blocks
86
88 desc._vertexBindingIndex = 0u;
89 desc._componentsPerElement = 3u;
91 desc._normalized = false;
92 desc._strideInBytes = 0;
93}
94
95
96void IMPrimitive::beginBatch(const bool reserveBuffers, const U32 vertexCount, const U32 attributeCount) {
97 _imInterface->BeginBatch(reserveBuffers, vertexCount, attributeCount);
98}
99
101 _imInterface->Clear(true, 64 * 3, 1);
102}
103
104bool IMPrimitive::hasBatch() const noexcept {
105 return !_imInterface->isCleared();
106}
107
109 _imInterface->Begin(glimPrimitiveType[to_U32(type)]);
110}
111
112void IMPrimitive::vertex(const F32 x, const F32 y, const F32 z) {
113 _imInterface->Vertex(x, y, z);
114}
115
116void IMPrimitive::attribute1f(const U32 attribLocation, const F32 value) {
117 _imInterface->Attribute1f(attribLocation, value);
118
120 desc._normalized = false;
121 desc._strideInBytes = 0u;
122 desc._componentsPerElement = 1u;
124}
125
126void IMPrimitive::attribute2f(const U32 attribLocation, const vec2<F32> value) {
127 _imInterface->Attribute2f(attribLocation, value.x, value.y);
129 desc._normalized = false;
130 desc._strideInBytes = 0u;
131 desc._componentsPerElement = 2u;
133}
134
135void IMPrimitive::attribute3f(const U32 attribLocation, const vec3<F32> value) {
136 _imInterface->Attribute3f(attribLocation, value.x, value.y, value.z);
138 desc._normalized = false;
139 desc._strideInBytes = 0u;
140 desc._componentsPerElement = 3u;
142}
143
144void IMPrimitive::attribute4ub(const U32 attribLocation, const U8 x, const U8 y, const U8 z, const U8 w) {
145 _imInterface->Attribute4ub(attribLocation, x, y, z, w);
147 desc._normalized = false;
148 desc._strideInBytes = 0u;
149 desc._componentsPerElement = 4u;
151}
152
153void IMPrimitive::attribute4f(const U32 attribLocation, const F32 x, const F32 y, const F32 z, const F32 w) {
154 _imInterface->Attribute4f(attribLocation, x, y, z, w);
156 desc._normalized = false;
157 desc._strideInBytes = 0u;
158 desc._componentsPerElement = 4u;
160}
161
162void IMPrimitive::attribute1i(const U32 attribLocation, const I32 value) {
163 _imInterface->Attribute1i(attribLocation, value);
165 desc._normalized = false;
166 desc._strideInBytes = 0u;
167 desc._componentsPerElement = 1u;
169}
170
172 _imInterface->End();
173}
174
175void IMPrimitive::endBatch() noexcept {
176 auto& batchData = _imInterface->EndBatch();
177
178 _drawFlags[to_base(NS_GLIM::GLIM_BUFFER_TYPE::TRIANGLES)] = !batchData.m_IndexBuffer_Triangles.empty();
179 _drawFlags[to_base(NS_GLIM::GLIM_BUFFER_TYPE::WIREFRAME)] = !batchData.m_IndexBuffer_Wireframe.empty();
180 _drawFlags[to_base(NS_GLIM::GLIM_BUFFER_TYPE::LINES)] = !batchData.m_IndexBuffer_Lines.empty();
181 _drawFlags[to_base(NS_GLIM::GLIM_BUFFER_TYPE::POINTS)] = !batchData.m_IndexBuffer_Points.empty();
182 _memCmd._bufferLocks.resize(0);
183
186 params._bufferParams._flags._updateUsage = BufferUpdateUsage::CPU_TO_GPU;
187 params._bufferParams._elementSize = sizeof(NS_GLIM::Glim4ByteData);
188
190 idxBuff.smallIndices = false;
191 idxBuff.dynamic = true;
192
194
195 // Set positions
196 {
197 params._bindConfig = { ._bufferIdx = 0u, ._bindIdx = 0u };
198 params._bufferParams._elementCount = to_U32(batchData.m_PositionData.size());
199 params._initialData = { batchData.m_PositionData.data(), batchData.m_PositionData.size() * sizeof(NS_GLIM::Glim4ByteData) };
200 params._elementStride = sizeof(NS_GLIM::Glim4ByteData) * 3;
201 params._bufferParams._flags._usageType = BufferUsageType::VERTEX_BUFFER;
202
203 _memCmd._bufferLocks.emplace_back(_dataBuffer->setBuffer(params));
204
205 auto& vertBinding = _basePipelineDescriptor._vertexFormat._vertexBindings.emplace_back();
206 vertBinding._bufferBindIndex = params._bindConfig._bindIdx;
207 vertBinding._strideInBytes = 3 * sizeof( F32 );
208 }
209
210 U8 bufferIdx = 1u;
211 // now upload each attribute array one after another
212 for (auto& [index, data] : batchData.m_Attributes) {
213 assert(index != 0u);
214 params._bindConfig = { ._bufferIdx = bufferIdx++, ._bindIdx = to_U16(index) };
215 params._bufferParams._elementCount = to_U32(data.m_ArrayData.size());
216 params._initialData = { data.m_ArrayData.data(), data.m_ArrayData.size() * sizeof(NS_GLIM::Glim4ByteData) };
217 params._elementStride = sizeof(NS_GLIM::Glim4ByteData) * GetSizeFactor(data.m_DataType);
218 _memCmd._bufferLocks.emplace_back(_dataBuffer->setBuffer(params));
219
221 desc._vertexBindingIndex = params._bindConfig._bindIdx;
222
223 auto& vertBinding = _basePipelineDescriptor._vertexFormat._vertexBindings.emplace_back();
224 vertBinding._bufferBindIndex = desc._vertexBindingIndex;
225 vertBinding._strideInBytes = params._elementStride;
226 }
227
228 idxBuff.id = 0u;
229 for (U8 i = 0u; i < to_base(NS_GLIM::GLIM_BUFFER_TYPE::COUNT); ++i) {
230 if (!_drawFlags[i]) {
231 continue;
232 }
233 const NS_GLIM::GLIM_BUFFER_TYPE glimType = static_cast<NS_GLIM::GLIM_BUFFER_TYPE>(i);
234
235 _basePipelineDescriptor._primitiveTopology = GetTopology(glimType);
237
238 switch (glimType) {
240 idxBuff.count = batchData.m_IndexBuffer_Lines.size();
241 idxBuff.data = batchData.m_IndexBuffer_Lines.data();
242 } break;
244 idxBuff.count = batchData.m_IndexBuffer_Points.size();
245 idxBuff.data = batchData.m_IndexBuffer_Points.data();
246 } break;
248 idxBuff.count = batchData.m_IndexBuffer_Triangles.size();
249 idxBuff.data = batchData.m_IndexBuffer_Triangles.data();
250 } break;
252 idxBuff.count = batchData.m_IndexBuffer_Wireframe.size();
253 idxBuff.data = batchData.m_IndexBuffer_Wireframe.data();
254 } break;
257 } break;
258 }
259
260 _memCmd._bufferLocks.emplace_back(_dataBuffer->setIndexBuffer(idxBuff));
261 _indexCount[i] = idxBuff.count;
262 _indexBufferId[i] = idxBuff.id;
263 ++idxBuff.id;
264 }
265
266 // free the temporary buffer in RAM
267 for (auto& [index, data] : batchData.m_Attributes) {
268 efficient_clear( data.m_ArrayData );
269 }
270
271 efficient_clear( batchData.m_PositionData );
272 efficient_clear( batchData.m_IndexBuffer_Wireframe );
273 efficient_clear( batchData.m_IndexBuffer_Triangles );
274 efficient_clear( batchData.m_IndexBuffer_Lines );
275 efficient_clear( batchData.m_IndexBuffer_Points );
276}
277
279 fromLines(lines._lines.data(), lines._lines.size());
280}
281
282void IMPrimitive::fromLines(const IM::LineDescriptor* lines, size_t count) {
283 for (size_t i = 0u; i < count; ++i) {
284 fromLines(lines[i]._lines.data(), lines[i]._lines.size());
285 }
286}
288 fromFrustums(&frustum, 1u);
289}
290
291void IMPrimitive::fromFrustums(const IM::FrustumDescriptor* frustums, size_t count) {
292 Line temp = {};
293 std::array<Line, to_base(FrustumPlane::COUNT) * 2> lines = {};
294 std::array<vec3<F32>, to_base(FrustumPoints::COUNT)> corners = {};
295
296 // Create the object containing all of the lines
297 beginBatch(true, to_U32(lines.size() * count) * 2u, 2);
298
299 for (size_t i = 0u; i < count; ++i) {
300 U8 lineCount = 0;
301
302 frustums[i].frustum.getCornersWorldSpace(corners);
303 const UColour4& endColour = frustums[i].colour;
304 const UColour4 startColour = Util::ToByteColour( Util::ToFloatColour( frustums[i].colour ) * 0.25f);
305
306 // Draw Near Plane
309 temp._colourStart = startColour;
310 temp._colourEnd = startColour;
311 lines[lineCount++] = temp;
312
315 temp._colourStart = startColour;
316 temp._colourEnd = startColour;
317 lines[lineCount++] = temp;
318
321 temp._colourStart = startColour;
322 temp._colourEnd = startColour;
323 lines[lineCount++] = temp;
324
327 temp._colourStart = startColour;
328 temp._colourEnd = startColour;
329 lines[lineCount++] = temp;
330
331 // Draw Far Plane
334 temp._colourStart = endColour;
335 temp._colourEnd = endColour;
336 lines[lineCount++] = temp;
337
340 temp._colourStart = endColour;
341 temp._colourEnd = endColour;
342 lines[lineCount++] = temp;
343
346 temp._colourStart = endColour;
347 temp._colourEnd = endColour;
348 lines[lineCount++] = temp;
349
352 temp._colourStart = endColour;
353 temp._colourEnd = endColour;
354 lines[lineCount++] = temp;
355
356 // Connect Planes
359 temp._colourStart = endColour;
360 temp._colourEnd = startColour;
361 lines[lineCount++] = temp;
362
365 temp._colourStart = endColour;
366 temp._colourEnd = startColour;
367 lines[lineCount++] = temp;
368
371 temp._colourStart = endColour;
372 temp._colourEnd = startColour;
373 lines[lineCount++] = temp;
374
377 temp._colourStart = endColour;
378 temp._colourEnd = startColour;
379 lines[lineCount++] = temp;
380 fromLinesInternal(lines.data(), lineCount);
381 }
382 endBatch();
383}
384
386 fromOBBs(&box, 1u);
387}
388
389void IMPrimitive::fromOBBs(const IM::OBBDescriptor* boxes, const size_t count) {
390 if (count == 0u) {
391 return;
392 }
393 std::array<Line, 12> lines = {};
394
395 // Create the object containing all of the lines
396 beginBatch(true, 12 * to_U32(count) * 2 * 14, 2);
397 for (size_t i = 0u; i < count; ++i) {
398 const IM::OBBDescriptor& descriptor = boxes[i];
399 OBB::OOBBEdgeList edges = descriptor.box.edgeList();
400 for (U8 j = 0u; j < 12u; ++j)
401 {
402 lines[j]._positionStart = edges[j]._start;
403 lines[j]._positionEnd = edges[j]._end;
404 lines[j]._colourStart = descriptor.colour;
405 lines[j]._colourEnd = descriptor.colour;
406 }
407
408 fromLinesInternal(lines.data(), lines.size());
409 }
410 endBatch();
411}
412
414 fromBoxes(&box, 1u);
415}
416
417void IMPrimitive::fromBoxes(const IM::BoxDescriptor* boxes, const size_t count) {
418 if (count == 0u) {
419 return;
420 }
421
422 // Create the object
423 beginBatch(true, to_U32(count * 16u), 1);
425 for (size_t i = 0u; i < count; ++i) {
426 const IM::BoxDescriptor& box = boxes[i];
427 const UColour4& colour = box.colour;
428 const vec3<F32>& min = box.min;
429 const vec3<F32>& max = box.max;
430
431 // Set it's colour
433 // Draw the bottom loop
435 vertex(min.x, min.y, min.z);
436 vertex(max.x, min.y, min.z);
437 vertex(max.x, min.y, max.z);
438 vertex(min.x, min.y, max.z);
439 vertex(min.x, min.y, min.z);
440 end();
441 // Draw the top loop
443 vertex(min.x, max.y, min.z);
444 vertex(max.x, max.y, min.z);
445 vertex(max.x, max.y, max.z);
446 vertex(min.x, max.y, max.z);
447 vertex(min.x, max.y, min.z);
448 end();
449 // Connect the top to the bottom
451 vertex(min.x, min.y, min.z);
452 vertex(min.x, max.y, min.z);
453 vertex(max.x, min.y, min.z);
454 vertex(max.x, max.y, min.z);
455 vertex(max.x, min.y, max.z);
456 vertex(max.x, max.y, max.z);
457 vertex(min.x, min.y, max.z);
458 vertex(min.x, max.y, max.z);
459 end();
460 }
461 // Finish our object
462 endBatch();
463}
464
466 fromSpheres(&sphere, 1u);
467}
468
469void IMPrimitive::fromSpheres(const IM::SphereDescriptor* spheres, const size_t count) {
470 if (count == 0u) {
471 return;
472 }
473
474 beginBatch(true, 32u * ((32u + 1) * 2), 1);
476
477 for (size_t c = 0u; c < count; ++c) {
478 const IM::SphereDescriptor& sphere = spheres[c];
479 const F32 drho = M_PI_f / sphere.stacks;
480 const F32 dtheta = 2.f * M_PI_f / sphere.slices;
481
482 // Create the object
485 vec3<F32> startVert{};
486 for (U32 i = 0u; i < sphere.stacks; i++) {
487 const F32 rho = i * drho;
488 const F32 srho = std::sin(rho);
489 const F32 crho = std::cos(rho);
490 const F32 srhodrho = std::sin(rho + drho);
491 const F32 crhodrho = std::cos(rho + drho);
492 for (U32 j = 0; j <= sphere.slices; j++) {
493 const F32 theta = j == sphere.slices ? 0.0f : j * dtheta;
494 const F32 stheta = -std::sin(theta);
495 const F32 ctheta = std::cos(theta);
496
497 F32 x = stheta * srho;
498 F32 y = ctheta * srho;
499 F32 z = crho;
500 const vec3<F32> vert1{
501 x * sphere.radius + sphere.center.x,
502 y * sphere.radius + sphere.center.y,
503 z * sphere.radius + sphere.center.z
504 };
505 vertex(vert1);
506 x = stheta * srhodrho;
507 y = ctheta * srhodrho;
508 z = crhodrho;
509 vertex(x * sphere.radius + sphere.center.x,
510 y * sphere.radius + sphere.center.y,
511 z * sphere.radius + sphere.center.z);
512
513 if (i == 0 && j == 0) {
514 startVert = vert1;
515 }
516 }
517 }
518 vertex(startVert.x, startVert.y, startVert.z);
519 end();
520 }
521 endBatch();
522}
523
524//ref: http://www.freemancw.com/2012/06/opengl-cone-function/
526 fromCones(&cone, 1u);
527}
528
529void IMPrimitive::fromCones(const IM::ConeDescriptor* cones, const size_t count) {
530 if (count == 0u) {
531 return;
532 }
533
534 beginBatch(true, to_U32(count * (32u + 1)), 1u);
536
537 for (size_t i = 0u; i < count; ++i) {
538 const IM::ConeDescriptor& cone = cones[i];
539
540 const U8 slices = std::min(cone.slices, to_U8(32u));
541 const F32 angInc = 360.0f / slices * M_PIDIV180_f;
542 const vec3<F32> invDirection = -cone.direction;
543 const vec3<F32> c = cone.root + -invDirection * cone.length;
544 const vec3<F32> e0 = Perpendicular(invDirection);
545 const vec3<F32> e1 = Cross(e0, invDirection);
546
547 // calculate points around directrix
548 std::array<vec3<F32>, 32u> pts = {};
549 for (size_t j = 0u; j < slices; ++j) {
550 const F32 rad = angInc * j;
551 pts[j] = c + (e0 * std::cos(rad) + e1 * std::sin(rad)) * cone.radius;
552 }
553
554 // draw cone top
556 // Top
558 vertex(cone.root);
559 for (U8 j = 0u; j < slices; ++j) {
560 vertex(pts[j]);
561 }
562 end();
563
564 // Bottom
566 vertex(c);
567 for (I8 j = slices - 1; j >= 0; --j) {
568 vertex(pts[j]);
569 }
570 end();
571 }
572 endBatch();
573}
574
575void IMPrimitive::fromLines(const Line* lines, const size_t count) {
576 if (count == 0u) {
577 return;
578 }
579
580 // Check if we have a valid list. The list can be programmatically
581 // generated, so this check is required
582 // Create the object containing all of the lines
583 beginBatch(true, to_U32(count) * 2 * 14, 2);
584 fromLinesInternal(lines, count);
585 // Finish our object
586 endBatch();
587}
588
589void IMPrimitive::fromLinesInternal(const Line* lines, size_t count) {
590 if (count == 0u) {
591 return;
592 }
593
596 // Set the mode to line rendering
598 // Add every line in the list to the batch
599 for (size_t i = 0u; i < count; ++i) {
600 const Line& line = lines[i];
604
607 vertex(line._positionEnd);
608
609 }
610 end();
611}
612
614{
615 _fastData = fastData;
616}
617
619{
620 _additionalUniforms = constants;
621}
622
624{
625 _additionalUniforms = constants;
626 _fastData = fastData;
627}
628
630 DIVIDE_ASSERT(descriptor._vertexFormat._vertexBindings.empty());
631
632 const AttributeMap existingAttributes = _basePipelineDescriptor._vertexFormat;
633 _basePipelineDescriptor = descriptor;
634 _basePipelineDescriptor._vertexFormat = existingAttributes;
635}
636
637void IMPrimitive::setTexture(const ImageView& texture, const SamplerDescriptor sampler)
638{
639 _texture = texture;
640 _sampler = sampler;
641}
642
644{
645 getCommandBuffer(MAT4_IDENTITY, commandBufferInOut, memCmdInOut);
646}
647
648void IMPrimitive::getCommandBuffer(const mat4<F32>& worldMatrix, GFX::CommandBuffer& commandBufferInOut, GFX::MemoryBarrierCommand& memCmdInOut )
649{
650 if (!_imInterface->PrepareRender()) {
651 return;
652 }
653
654 const bool useTexture = TargetType( _texture ) != TextureType::COUNT;
655 if (useTexture )
656 {
657 _basePipelineDescriptor._shaderProgramHandle = _context.imShaders()->imWorldShader();
658 }
659 else
660 {
661 _basePipelineDescriptor._shaderProgramHandle = _context.imShaders()->imWorldShaderNoTexture();
662 }
663 DIVIDE_ASSERT(_basePipelineDescriptor._shaderProgramHandle != INVALID_HANDLE<ShaderProgram>, "IMPrimitive error: Draw call received without a valid shader defined!");
664
665 _additionalUniforms.set(_ID("dvd_WorldMatrix"), PushConstantType::MAT4, worldMatrix);
666 _additionalUniforms.set(_ID("useTexture"), PushConstantType::BOOL, useTexture);
667
668 GenericDrawCommand drawCmd{};
669 drawCmd._drawCount = 1u;
670 drawCmd._cmd.instanceCount = 1u;
671 drawCmd._sourceBuffer = _dataBuffer->handle();
672
673 GFX::EnqueueCommand<GFX::BeginDebugScopeCommand>(commandBufferInOut)->_scopeName = _name.c_str();
674 {
675 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>(commandBufferInOut);
676 cmd->_usage = DescriptorSetUsage::PER_DRAW;
678
680 {
682 }
683 else
684 {
685 Set( binding._data, _texture, _sampler );
686 }
687
688 for (U8 i = 0u; i < to_base(NS_GLIM::GLIM_BUFFER_TYPE::COUNT); ++i) {
689 if (_drawFlags[i]) {
690 const NS_GLIM::GLIM_BUFFER_TYPE glimType = static_cast<NS_GLIM::GLIM_BUFFER_TYPE>(i);
691 if ((glimType == NS_GLIM::GLIM_BUFFER_TYPE::TRIANGLES && _forceWireframe) ||
692 (glimType == NS_GLIM::GLIM_BUFFER_TYPE::WIREFRAME && !_forceWireframe))
693 {
694 continue;
695 }
696 drawCmd._cmd.indexCount = to_U32(_indexCount[i]);
697 drawCmd._bufferFlag = _indexBufferId[i];
698
699 GFX::EnqueueCommand<GFX::BindPipelineCommand>(commandBufferInOut)->_pipeline = _pipelines[i];
700 auto pushConstantsCmd = GFX::EnqueueCommand<GFX::SendPushConstantsCommand>(commandBufferInOut);
701 pushConstantsCmd->_uniformData = &_additionalUniforms;
702 pushConstantsCmd->_fastData = _fastData;
703 GFX::EnqueueCommand<GFX::DrawCommand>(commandBufferInOut)->_drawCommands.emplace_back(drawCmd);
704 }
705 }
706 }
707
708 GFX::EnqueueCommand<GFX::EndDebugScopeCommand>(commandBufferInOut);
709
710 if ( !_memCmd._bufferLocks.empty() )
711 {
712 memCmdInOut._bufferLocks.insert( memCmdInOut._bufferLocks.cend(), _memCmd._bufferLocks.cbegin(), _memCmd._bufferLocks.cend() );
713 _memCmd._bufferLocks.resize(0);
714 }
715}
716
717} //namespace Divide
#define DIVIDE_ASSERT(...)
#define DIVIDE_UNEXPECTED_CALL()
void getCornersWorldSpace(std::array< vec3< F32 >, to_base(FrustumPoints::COUNT)> &cornersWS) const noexcept
Definition: Frustum.cpp:208
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
Pipeline * newPipeline(const PipelineDescriptor &descriptor)
Create and return a new graphics pipeline. This is only used for caching and doesn't use the object a...
Definition: GFXDevice.cpp:3074
GenericVertexData_ptr newGVD(U32 ringBufferLength, std::string_view name)
Definition: GFXDevice.inl:219
void attribute1f(U32 attribLocation, F32 value)
void getCommandBuffer(GFX::CommandBuffer &commandBufferInOut, GFX::MemoryBarrierCommand &memCmdInOut)
void beginBatch(bool reserveBuffers, U32 vertexCount, U32 attributeCount)
Definition: IMPrimitive.cpp:96
GFX::MemoryBarrierCommand _memCmd
Definition: IMPrimitive.h:154
void attribute4ub(U32 attribLocation, U8 x, U8 y, U8 z, U8 w)
void setUniformData(const UniformData &constants)
void vertex(F32 x, F32 y, F32 z)
IMPrimitive(GFXDevice &context, const Str< 64 > &name)
Definition: IMPrimitive.cpp:65
bool hasBatch() const noexcept
void fromOBB(const IM::OBBDescriptor &box)
PushConstantsStruct _fastData
Definition: IMPrimitive.h:143
GFXDevice & context() noexcept
Definition: IMPrimitive.h:135
std::array< size_t, to_base(NS_GLIM::GLIM_BUFFER_TYPE::COUNT)> _indexCount
Definition: IMPrimitive.h:149
GenericVertexData_ptr _dataBuffer
Definition: IMPrimitive.h:152
void attribute1i(U32 attribLocation, I32 value)
UniformData _additionalUniforms
Definition: IMPrimitive.h:142
void fromLinesInternal(const Line *lines, size_t count)
void fromSpheres(const IM::SphereDescriptor *spheres, size_t count)
void fromCones(const IM::ConeDescriptor *cones, size_t count)
void fromOBBs(const IM::OBBDescriptor *boxes, size_t count)
NS_GLIM::GLIM_BATCH_uptr _imInterface
Definition: IMPrimitive.h:144
std::array< bool, to_base(NS_GLIM::GLIM_BUFFER_TYPE::COUNT)> _drawFlags
Definition: IMPrimitive.h:148
void setPipelineDescriptor(const PipelineDescriptor &descriptor)
void fromFrustums(const IM::FrustumDescriptor *frustums, size_t count)
void fromBox(const IM::BoxDescriptor &box)
void fromCone(const IM::ConeDescriptor &cone)
void attribute4f(U32 attribLocation, F32 x, F32 y, F32 z, F32 w)
void fromBoxes(const IM::BoxDescriptor *boxes, size_t count)
void fromLines(const IM::LineDescriptor &lines)
std::array< Pipeline *, to_base(NS_GLIM::GLIM_BUFFER_TYPE::COUNT)> _pipelines
Definition: IMPrimitive.h:150
void attribute3f(U32 attribLocation, vec3< F32 > value)
void attribute2f(U32 attribLocation, vec2< F32 > value)
SamplerDescriptor _sampler
Definition: IMPrimitive.h:147
void fromFrustum(const IM::FrustumDescriptor &frustum)
static void InitStaticData()
Definition: IMPrimitive.cpp:55
void setPushConstants(const PushConstantsStruct &fastData)
std::array< U8, to_base(NS_GLIM::GLIM_BUFFER_TYPE::COUNT)> _indexBufferId
Definition: IMPrimitive.h:151
void setTexture(const ImageView &texture, SamplerDescriptor sampler)
PipelineDescriptor _basePipelineDescriptor
Definition: IMPrimitive.h:145
GFXDevice & _context
Definition: IMPrimitive.h:141
void setUniformDataAndConstants(const UniformData &constants, const PushConstantsStruct &fastData)
void begin(PrimitiveTopology type)
void endBatch() noexcept
void fromSphere(const IM::SphereDescriptor &sphere)
std::array< LineSegment, 12 > OOBBEdgeList
Definition: OBB.h:52
OOBBEdgeList edgeList() const noexcept
Definition: OBB.cpp:152
static const SamplerDescriptor DefaultSampler() noexcept
Definition: Texture.cpp:100
static Handle< Texture > DefaultTexture2D() noexcept
Definition: Texture.cpp:90
UColour4 ToByteColour(const FColour4 &floatColour) noexcept
Definition: MathHelper.cpp:256
FColour4 ToFloatColour(const UColour4 &byteColour) noexcept
Definition: MathHelper.cpp:268
std::array< NS_GLIM::GLIM_ENUM, to_base(PrimitiveTopology::COUNT)> glimPrimitiveType
Definition: IMPrimitive.cpp:18
PrimitiveTopology GetTopology(const NS_GLIM::GLIM_BUFFER_TYPE type)
Definition: IMPrimitive.cpp:41
size_t GetSizeFactor(const NS_GLIM::GLIM_ENUM dataType) noexcept
Definition: IMPrimitive.cpp:19
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
constexpr F32 M_PI_f
Definition: MathHelper.h:86
constexpr U32 to_U32(const T value)
TextureType TargetType(const ImageView &imageView) noexcept
constexpr U16 to_U16(const T value)
int32_t I32
uint8_t U8
vec3< T > Perpendicular(const vec3< T > &v) noexcept
void Set(DescriptorSetBindingData &dataInOut, ShaderBuffer *buffer, const BufferRange range) noexcept
constexpr U64 _ID(const char *const str, const U64 value=val_64_const) noexcept
DescriptorSetBinding & AddBinding(DescriptorSet &setInOut, U8 slot, U16 stageVisibilityMask)
void efficient_clear(eastl::fixed_vector< T, nodeCount, bEnableOverflow, OverflowAllocator > &fixed_vector)
Definition: Vector.h:52
constexpr U8 to_U8(const T value)
vec2< T > Cross(vec2< T > v1, vec2< T > v2) noexcept
general vec2 cross function
Definition: MathVectors.inl:80
constexpr F32 M_PIDIV180_f
Definition: MathHelper.h:90
static const mat4< F32 > MAT4_IDENTITY
Definition: MathMatrices.h:740
uint32_t U32
constexpr auto to_base(const Type value) -> Type
GLIM_BUFFER_TYPE
Definition: Declarations.h:43
GLIM_ENUM
The enum holding all important GLIM configuration values.
Definition: Declarations.h:17
@ GLIM_LINES
Can be passed to GLIM::Begin.
@ GLIM_LINE_STRIP
Can be passed to GLIM::Begin.
@ GLIM_TRIANGLE_STRIP
Can be passed to GLIM::Begin (not yet implemented)
@ GLIM_POINTS
Can be passed to GLIM::Begin.
@ GLIM_TRIANGLE_FAN
Can be passed to GLIM::Begin.
@ GLIM_TRIANGLES
Can be passed to GLIM::Begin.
VertexBindings _vertexBindings
BufferUpdateFrequency _updateFrequency
Definition: BufferParams.h:39
BufferFlags _flags
Definition: BufferParams.h:48
DescriptorSetBindingData _data
vec3< F32 > _positionStart
Definition: Line.h:42
F32 _widthStart
Definition: Line.h:46
vec3< F32 > _positionEnd
Definition: Line.h:43
UColour4 _colourStart
Definition: Line.h:44
F32 _widthEnd
Definition: Line.h:47
UColour4 _colourEnd
Definition: Line.h:45
PrimitiveTopology _primitiveTopology
Definition: Pipeline.h:48
AttributeMap _vertexFormat
Definition: Pipeline.h:49
Handle< ShaderProgram > _shaderProgramHandle
Definition: Pipeline.h:47
void set(U64 bindingHash, PushConstantType type, const T &value)