diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-06 03:46:51 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-06 23:13:06 +0300 |
commit | 4ea93029c65fd4cdb8b707494855120c0f792952 (patch) | |
tree | a02801daaaf0f0a4e1bb7be84d34e27759b32a36 /source/blender/gpu/GPU_index_buffer.h | |
parent | 84d67bd0a937e842618ee7843958f3147ba6af58 (diff) |
GPUIndexBuf: GL backend Isolation
This is part of the Vulkan backend task T68990.
There is no real change, only making some code re-organisation.
This also make the IndexBuf completely abstract from outside the
GPU module.
Diffstat (limited to 'source/blender/gpu/GPU_index_buffer.h')
-rw-r--r-- | source/blender/gpu/GPU_index_buffer.h | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/source/blender/gpu/GPU_index_buffer.h b/source/blender/gpu/GPU_index_buffer.h index b966eabefae..09c12c6e177 100644 --- a/source/blender/gpu/GPU_index_buffer.h +++ b/source/blender/gpu/GPU_index_buffer.h @@ -31,40 +31,21 @@ extern "C" { #endif -#define GPU_TRACK_INDEX_RANGE 1 - -typedef enum { - GPU_INDEX_U16, - GPU_INDEX_U32, -} GPUIndexBufType; - -typedef struct GPUIndexBuf { - uint index_start; - uint index_len; - bool is_subrange; -#if GPU_TRACK_INDEX_RANGE - GPUIndexBufType index_type; - uint32_t gl_index_type; - uint base_index; -#endif - uint32_t ibo_id; /* 0 indicates not yet sent to VRAM */ - union { - void *data; /* non-NULL indicates not yet sent to VRAM */ - struct GPUIndexBuf *src; /* if is_subrange is true, this is the source buffer. */ - }; -} GPUIndexBuf; +/** + * IMPORTANT: Do not allocate manually as the real struct is bigger (i.e: GLIndexBuf). This is only + * the common and "public" part of the struct. Use the provided allocator. + * TODO(fclem) Make the content of this struct hidden and expose getters/setters. + **/ +typedef struct GPUIndexBuf GPUIndexBuf; GPUIndexBuf *GPU_indexbuf_calloc(void); -void GPU_indexbuf_use(GPUIndexBuf *); -uint GPU_indexbuf_size_get(const GPUIndexBuf *); - typedef struct GPUIndexBufBuilder { uint max_allowed_index; uint max_index_len; uint index_len; GPUPrimType prim_type; - uint *data; + uint32_t *data; } GPUIndexBufBuilder; /* supports all primitive types. */ @@ -102,6 +83,8 @@ void GPU_indexbuf_create_subrange_in_place(GPUIndexBuf *elem, void GPU_indexbuf_discard(GPUIndexBuf *); +bool GPU_indexbuf_is_init(GPUIndexBuf *ibo); + int GPU_indexbuf_primitive_len(GPUPrimType prim_type); /* Macros */ |