37#ifdef KICAD_GAL_PROFILE
75 DisplayError(
nullptr, wxT(
"Could not get the shader attribute location" ) );
117 unsigned int offset = aItem->
GetOffset();
118 unsigned int size = aItem->
GetSize();
126 m_vranges.emplace_back( offset, offset + size - 1,
false );
132 m_vranges.emplace_back( offset, offset + size - 1,
true );
154 glEnable( GL_DEPTH_TEST );
156 glDisable( GL_DEPTH_TEST );
159 glEnableClientState( GL_VERTEX_ARRAY );
160 glEnableClientState( GL_COLOR_ARRAY );
184 while( n < n_ranges )
192 glDrawElements( GL_TRIANGLES, icnt, GL_UNSIGNED_INT,
m_indices.get() );
204 for( GLuint i = cur->
m_start; i <= cur->m_end; i++ )
216 glDrawElements( GL_TRIANGLES, icnt, GL_UNSIGNED_INT,
m_indices.get() );
223#ifdef KICAD_GAL_PROFILE
225 "Cached manager size: VBO size %u iranges %zu max elt size %u drawcalls %u",
230 glBindBuffer( GL_ARRAY_BUFFER, 0 );
234 glDisableClientState( GL_COLOR_ARRAY );
235 glDisableClientState( GL_VERTEX_ARRAY );
272 wxASSERT_MSG(
false, wxT(
"Not implemented yet" ) );
278#ifdef KICAD_GAL_PROFILE
286 GLfloat* coordinates = (GLfloat*) ( vertices );
287 GLubyte* colors = (GLubyte*) ( vertices ) +
COLOR_OFFSET;
290 glEnable( GL_DEPTH_TEST );
292 glDisable( GL_DEPTH_TEST );
295 glEnableClientState( GL_VERTEX_ARRAY );
296 glEnableClientState( GL_COLOR_ARRAY );
303 GLfloat* shaders = (GLfloat*) ( vertices ) +
SHADER_OFFSET /
sizeof( GLfloat );
311 glDrawArrays( GL_TRIANGLES, 0,
m_container->GetSize() );
313#ifdef KICAD_GAL_PROFILE
318 glDisableClientState( GL_COLOR_ARRAY );
319 glDisableClientState( GL_VERTEX_ARRAY );
329#ifdef KICAD_GAL_PROFILE
330 totalRealTime.
Stop();
331 wxLogTrace(
traceGalProfile, wxT(
"GPU_NONCACHED_MANAGER::EndDrawing(): %.1f ms" ),
332 totalRealTime.
msecs() );
Class to store VERTEX instances with caching.
virtual unsigned int GetBufferHandle() const =0
Return handle to the vertex buffer.
virtual unsigned int AllItemsSize() const
virtual bool IsMapped() const =0
Return true if vertex buffer is currently mapped.
virtual void Unmap() override=0
Finish the vertices updates stage.
int m_totalHuge
Number of regular VRANGEs (small items) pooled into single draw call.
std::vector< VRANGE > m_vranges
Number of huge VRANGEs (i.e. large zones) with separate draw calls.
unsigned int m_indexBufMaxSize
Size of the current VRANGE.
unsigned int m_indicesCapacity
Ranges of visible vertex indices to render.
~GPU_CACHED_MANAGER()
Prepare the stored data to be drawn.
unsigned int m_curVrangeSize
GPU_CACHED_MANAGER(VERTEX_CONTAINER *aContainer)
virtual void DrawIndices(const VERTEX_ITEM *aItem) override
Clear the container after drawing routines.
virtual void BeginDrawing() override
Make the GPU draw given range of vertices.
bool m_buffersInitialized
Pointer to the current indices buffer.
int m_totalNormal
Current size of index buffer.
boost::scoped_array< GLuint > m_indices
Current indices buffer size.
unsigned int m_indexBufSize
Maximum size taken by the index buffer for all frames rendered so far.
void resizeIndices(unsigned int aNewSize)
< Resizes the indices buffer to aNewSize if necessary
virtual void EndDrawing() override
Map vertex buffer stored in GPU memory.
GPU_MANAGER(VERTEX_CONTAINER *aContainer)
Drawing status flag.
int m_shaderAttrib
true: enable Z test when drawing
virtual void SetShader(SHADER &aShader)
Allow using shaders with the stored data.
void EnableDepthTest(bool aEnabled)
Enable/disable Z buffer depth test.
VERTEX_CONTAINER * m_container
Shader handling.
bool m_isDrawing
Container that stores vertices data.
static GPU_MANAGER * MakeManager(VERTEX_CONTAINER *aContainer)
SHADER * m_shader
Location of shader attributes (for glVertexAttribPointer)
virtual void BeginDrawing() override
Make the GPU draw given range of vertices.
GPU_NONCACHED_MANAGER(VERTEX_CONTAINER *aContainer)
Prepare the stored data to be drawn.
virtual void EndDrawing() override
Clear the container after drawing routines.
virtual void DrawIndices(const VERTEX_ITEM *aItem) override
Clear the container after drawing routines.
Provide the access to the OpenGL shaders.
virtual bool IsCached() const =0
Return true if the container caches vertex data in RAM or video memory.
void ClearDirty()
Clear the dirty flag to prevent reuploading vertices to the GPU memory.
unsigned int GetOffset() const
Return data offset in the container.
unsigned int GetSize() const
Return information about number of vertices stored.
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
double msecs(bool aSinceLast=false)
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
The Cairo implementation of the graphics abstraction layer.
static constexpr size_t COLOR_OFFSET
static constexpr size_t COORD_OFFSET
static constexpr size_t VERTEX_SIZE
static constexpr size_t SHADER_OFFSET
static constexpr size_t COLOR_STRIDE
static constexpr size_t SHADER_STRIDE
static constexpr size_t COORD_STRIDE
Class to store instances of VERTEX without caching.
wxLogTrace helper definitions.
Class to handle an item held in a container.