diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-07 00:45:51 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-07 14:59:51 +0300 |
commit | bb2aeb4504907cab1cf8c4afc4dd1d6495c940e4 (patch) | |
tree | 550d043273b767d55ef32409e58de17cb75e724e /source/blender/gpu/intern/gpu_vertex_buffer_private.hh | |
parent | 99e3541d3b1a1fc62fcd24e9f0d12a631e4caead (diff) |
GPUVertBuf: Rename GPUVertBuf to VertBuf and add some getters
to avoid more typecasts.
Diffstat (limited to 'source/blender/gpu/intern/gpu_vertex_buffer_private.hh')
-rw-r--r-- | source/blender/gpu/intern/gpu_vertex_buffer_private.hh | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/source/blender/gpu/intern/gpu_vertex_buffer_private.hh b/source/blender/gpu/intern/gpu_vertex_buffer_private.hh index 24e95a729c7..eb7e0bc8b9b 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer_private.hh +++ b/source/blender/gpu/intern/gpu_vertex_buffer_private.hh @@ -27,20 +27,40 @@ #include "GPU_vertex_buffer.h" -struct GPUVertBuf { - GPUVertFormat format; +namespace blender::gpu { + +struct VertBuf { + static size_t memory_usage; + + GPUVertFormat format = {}; /** Number of verts we want to draw. */ - uint vertex_len; + uint vertex_len = 0; /** Number of verts data. */ - uint vertex_alloc; + uint vertex_alloc = 0; /** 0 indicates not yet allocated. */ - uint32_t vbo_id; + uint32_t vbo_id = 0; /** Usage hint for GL optimisation. */ - GPUUsageType usage; + GPUUsageType usage = GPU_USAGE_STATIC; /** Status flag. */ - GPUVertBufStatus flag; + GPUVertBufStatus flag = GPU_VERTBUF_INVALID; /** This counter will only avoid freeing the GPUVertBuf, not the data. */ - char handle_refcount; + char handle_refcount = 0; /** NULL indicates data in VRAM (unmapped) */ - uchar *data; -};
\ No newline at end of file + uchar *data = NULL; +}; + +/* Syntacting suggar. */ +static inline GPUVertBuf *wrap(VertBuf *vert) +{ + return reinterpret_cast<GPUVertBuf *>(vert); +} +static inline VertBuf *unwrap(GPUVertBuf *vert) +{ + return reinterpret_cast<VertBuf *>(vert); +} +static inline const VertBuf *unwrap(const GPUVertBuf *vert) +{ + return reinterpret_cast<const VertBuf *>(vert); +} + +} // namespace blender::gpu
\ No newline at end of file |