GPUBatch: Move allocator to backend
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "gpu_context_private.hh"
|
||||
#include "gpu_drawlist_private.hh"
|
||||
#include "gpu_batch_private.hh"
|
||||
|
||||
namespace blender {
|
||||
namespace gpu {
|
||||
@@ -38,7 +39,12 @@ class GPUBackend {
|
||||
static GPUBackend *get(void);
|
||||
|
||||
virtual GPUContext *context_alloc(void *ghost_window) = 0;
|
||||
|
||||
virtual Batch *batch_alloc(void) = 0;
|
||||
virtual DrawList *drawlist_alloc(int list_length) = 0;
|
||||
// virtual FrameBuffer *framebuffer_alloc(void) = 0;
|
||||
// virtual Shader *shader_alloc(void) = 0;
|
||||
// virtual Texture *texture_alloc(void) = 0;
|
||||
};
|
||||
|
||||
} // namespace gpu
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "GPU_platform.h"
|
||||
#include "GPU_shader.h"
|
||||
|
||||
#include "gpu_backend.hh"
|
||||
#include "gpu_batch_private.hh"
|
||||
#include "gpu_context_private.hh"
|
||||
#include "gpu_primitive_private.h"
|
||||
@@ -43,6 +44,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
using namespace blender::gpu;
|
||||
|
||||
static GLuint g_default_attr_vbo = 0;
|
||||
|
||||
static void gpu_batch_bind(GPUBatch *batch);
|
||||
@@ -86,9 +89,11 @@ void GPU_batch_vao_cache_clear(GPUBatch *batch)
|
||||
batch->context = NULL;
|
||||
}
|
||||
|
||||
GPUBatch *GPU_batch_calloc(uint count)
|
||||
GPUBatch *GPU_batch_calloc(void)
|
||||
{
|
||||
return (GPUBatch *)MEM_callocN(sizeof(GPUBatch) * count, "GPUBatch");
|
||||
GPUBatch *batch = GPUBackend::get()->batch_alloc();
|
||||
memset(batch, 0, sizeof(*batch));
|
||||
return batch;
|
||||
}
|
||||
|
||||
GPUBatch *GPU_batch_create_ex(GPUPrimType prim_type,
|
||||
@@ -96,7 +101,7 @@ GPUBatch *GPU_batch_create_ex(GPUPrimType prim_type,
|
||||
GPUIndexBuf *elem,
|
||||
eGPUBatchFlag owns_flag)
|
||||
{
|
||||
GPUBatch *batch = GPU_batch_calloc(1);
|
||||
GPUBatch *batch = GPU_batch_calloc();
|
||||
GPU_batch_init_ex(batch, prim_type, verts, elem, owns_flag);
|
||||
return batch;
|
||||
}
|
||||
@@ -163,7 +168,8 @@ void GPU_batch_clear(GPUBatch *batch)
|
||||
void GPU_batch_discard(GPUBatch *batch)
|
||||
{
|
||||
GPU_batch_clear(batch);
|
||||
MEM_freeN(batch);
|
||||
|
||||
delete static_cast<Batch *>(batch);
|
||||
}
|
||||
|
||||
/* NOTE: Override ONLY the first instance vbo (and free them if owned). */
|
||||
|
||||
@@ -30,4 +30,18 @@
|
||||
#include "GPU_context.h"
|
||||
#include "GPU_shader_interface.h"
|
||||
|
||||
namespace blender {
|
||||
namespace gpu {
|
||||
|
||||
class Batch : public GPUBatch {
|
||||
public:
|
||||
Batch(){};
|
||||
virtual ~Batch(){};
|
||||
|
||||
virtual void draw(int v_first, int v_count, int i_first, int i_count) = 0;
|
||||
};
|
||||
|
||||
} // namespace gpu
|
||||
} // namespace blender
|
||||
|
||||
void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *interface);
|
||||
|
||||
Reference in New Issue
Block a user