mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 03:10:22 +00:00
TINYGL: Added linear allocator for frames draw call data.
This commit is contained in:
parent
98a77b2801
commit
a0a17717be
@ -192,6 +192,10 @@ void glInit(void *zbuffer1, int textureSize) {
|
||||
|
||||
c->color_mask = (1 << 24) | (1 << 16) | (1 << 8) | (1 << 0);
|
||||
|
||||
c->_currentAllocatorIndex = 0;
|
||||
c->_drawCallAllocator[0].initialize(5 * 1024 * 1024);
|
||||
c->_drawCallAllocator[1].initialize(5 * 1024 * 1024);
|
||||
|
||||
Graphics::Internal::tglBlitScissorRect(0, 0, c->fb->xsize, c->fb->ysize);
|
||||
}
|
||||
|
||||
|
@ -163,6 +163,43 @@ struct GLSharedState {
|
||||
GLTexture **texture_hash_table;
|
||||
};
|
||||
|
||||
class LinearAllocator {
|
||||
public:
|
||||
LinearAllocator() {
|
||||
_memoryBuffer = nullptr;
|
||||
_memorySize = 0;
|
||||
_memoryPosition = 0;
|
||||
}
|
||||
|
||||
void initialize(size_t newSize) {
|
||||
assert(_memoryBuffer == nullptr);
|
||||
void *newBuffer = gl_malloc(newSize);
|
||||
_memoryBuffer = newBuffer;
|
||||
_memorySize = newSize;
|
||||
}
|
||||
|
||||
~LinearAllocator() {
|
||||
if (_memoryBuffer != nullptr) {
|
||||
gl_free(_memoryBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void *allocate(size_t size) {
|
||||
assert (_memoryPosition + size < _memorySize);
|
||||
int returnPos = _memoryPosition;
|
||||
_memoryPosition += size;
|
||||
return ((char *)_memoryBuffer) + returnPos;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_memoryPosition = 0;
|
||||
}
|
||||
private:
|
||||
void *_memoryBuffer;
|
||||
int _memorySize;
|
||||
int _memoryPosition;
|
||||
};
|
||||
|
||||
struct GLContext;
|
||||
|
||||
typedef void (*gl_draw_triangle_func)(GLContext *c, GLVertex *p0, GLVertex *p1, GLVertex *p2);
|
||||
@ -300,6 +337,8 @@ struct GLContext {
|
||||
// Draw call queue
|
||||
Common::List<Graphics::DrawCall *> _drawCallsQueue;
|
||||
Common::List<Graphics::DrawCall *> _previousFrameDrawCallsQueue;
|
||||
int _currentAllocatorIndex;
|
||||
LinearAllocator _drawCallAllocator[2];
|
||||
};
|
||||
|
||||
extern GLContext *gl_ctx;
|
||||
|
Loading…
Reference in New Issue
Block a user