35#include "CEGUI/RenderEffect.h"
36#include "CEGUI/Vertex.h"
43#ifndef GLM_FORCE_DEPTH_ZERO_TO_ONE
44#define GLM_FORCE_DEPTH_ZERO_TO_ONE
48#include "glm/gtc/quaternion.hpp"
49#include "glm/gtc/matrix_transform.hpp"
58 , _bufferSize(1 << 8u)
60 thread_local size_t BUFFER_IDX = 0u;
79 Divide::Rect<I32>& clipRect = GFX::EnqueueCommand<GFX::SetScissorCommand>( *cmdBuffer )->_rect;
107 for (
int pass = 0; pass < pass_count; ++pass)
112 _effect->performPreRenderFunctions(pass);
118 if ( currentBatch.vertexCount == 0u )
125 if (currentBatch.texture != Divide::INVALID_HANDLE<Divide::Texture> )
127 auto cmd = GFX::EnqueueCommand<GFX::BindShaderResourcesCommand>( *cmdBuffer );
128 cmd->_usage = DescriptorSetUsage::PER_DRAW;
134 drawCmd._cmd.baseVertex = pos;
135 drawCmd._cmd.vertexCount = currentBatch.vertexCount;
137 GFX::EnqueueCommand<GFX::DrawCommand>( *cmdBuffer )->_drawCommands.emplace_back(drawCmd);
139 pos += currentBatch.vertexCount;
146 _effect->performPostRenderFunctions();
155 _batches.back().vertexCount += vertex_count;
159 const Vertex* vs = vbuff;
160 for ( uint i = 0u; i < vertex_count; ++i, ++vs )
163 vd.
tex[0] = vs->tex_coords.d_x;
164 vd.tex[1] = vs->tex_coords.d_y;
165 vd.colour[0] = vs->colour_val.getRed();
166 vd.colour[1] = vs->colour_val.getGreen();
167 vd.colour[2] = vs->colour_val.getBlue();
168 vd.colour[3] = vs->colour_val.getAlpha();
169 vd.position[0] = vs->position.d_x;
170 vd.position[1] = vs->position.d_y;
171 vd.position[2] = vs->position.d_z;
212 if ( vertexCount > 0u )
214 bool needNewBuffer =
false;
217 needNewBuffer =
true;
264 glm::mat4& modelMatrix =
_matrix;
265 modelMatrix = glm::mat4( 1.f );
271 modelMatrix = glm::translate( modelMatrix, final_trans );
274 const glm::mat4 rotation_matrix = glm::mat4_cast( rotationQuat );
276 modelMatrix = modelMatrix * rotation_matrix;
279 const glm::mat4 translMatrix = glm::translate( glm::mat4( 1.f ), transl );
280 modelMatrix = modelMatrix * translMatrix;
Divide::GFX::CommandBuffer * cmdBuffer() const
Divide::GFXDevice & context()
bool flipClippingHeight() const noexcept
const Rectf & getActiveViewPort() const
Divide::GFX::MemoryBarrierCommand * memCmd() const
const glm::mat4 & getViewProjectionMatrix() const noexcept
void bindDefaultState(bool scissor, BlendMode mode, const glm::mat4 &viewProjMat)
void draw() const override
BatchList _batches
list of texture batches added to the geometry buffer
Rectf _clipRect
rectangular clip region
Vector3f _pivot
pivot point for rotation
RenderEffect * _effect
RenderEffect that will be used by the GeometryBuffer.
Vector3f _translation
translation vector
VertexList _vertices
container where added geometry is stored.
DVDGeometryBuffer(CEGUIRenderer &owner)
bool _clippingActive
whether clipping will be active for the current batch
uint _bufferSize
Size of the buffer that is currently in use.
DVDTexture * _activeTexture
last texture that was set as active
void recreateBuffer(Divide::Byte *initialData, size_t intialDataSize)
recreates the Divide specific geometry buffer. Usually called if "initialDataSize" is larger than the...
bool _matrixValid
true when d_matrix is valid and up to date
void updateMatrix() const
update cached matrix
void appendGeometry(const Vertex *vbuff, uint vertex_count) override
CEGUIRenderer * _owner
CEGUIRenderer that owns the GeometryBuffer.
void performBatchManagement()
perform batch management operations prior to adding new geometry.
Divide::GenericVertexData_ptr _gvd
Divide specific geometry buffer.
const glm::mat4 & getMatrix() const
Quaternion _rotation
rotation quaternion
glm::mat4 _matrix
model matrix cache - we use double because gluUnproject takes double
Divide::SamplerDescriptor _sampler
Sampler hash to use if the current batch needs a texture bound.
Divide::Handle< Divide::Texture > getDVDTexture() const
Return the internal Divide::Texture pointer used by this Texture object.
GenericVertexData_ptr newGVD(U32 ringBufferLength, std::string_view name)
constexpr U8 MAX_FRAMES_IN_FLIGHT
Maximum number of active frames until we start waiting on a fence/sync.
Str StringFormat(const char *fmt, Args &&...args)
Handle console commands that start with a forward slash.
constexpr U32 to_U32(const T value)
type to track info for per-texture sub batches of geometry
Divide::Handle< Divide::Texture > texture
BufferUpdateUsage _updateUsage
BufferUpdateFrequency _updateFrequency
size_t _elementSize
Buffer primitive size in bytes.
DescriptorSetBindingData _data
std::pair< bufferPtr, size_t > _initialData
BufferBindConfig _bindConfig
BufferParams _bufferParams
TextureWrap _wrapU
Texture wrap mode (Or S-R-T)
U8 _anisotropyLevel
The value must be in the range [0...255] and is automatically clamped by the max HW supported level.