Blender V5.3
gl_index_buffer.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "MEM_guardedalloc.h"
12
13#include "GPU_index_buffer.hh"
14
15#include <epoxy/gl.h>
16
17namespace blender::gpu {
18
19class GLIndexBuf : public IndexBuf {
20 friend class GLBatch;
21 friend class GLDrawList;
22 friend class GLShader; /* For compute shaders. */
23
24 private:
25 GLuint ibo_id_ = 0;
26
27 public:
29
30 void bind();
31 void bind_as_ssbo(uint binding) override;
32
33 void read(uint32_t *data) const override;
34
35 void *offset_ptr(uint additional_vertex_offset) const
36 {
37 additional_vertex_offset += index_start_;
39 return reinterpret_cast<void *>(intptr_t(additional_vertex_offset) * sizeof(GLuint));
40 }
41 return reinterpret_cast<void *>(intptr_t(additional_vertex_offset) * sizeof(GLushort));
42 }
43
44 GLuint restart_index() const
45 {
46 return (index_type_ == GPU_INDEX_U16) ? 0xFFFFu : 0xFFFFFFFFu;
47 }
48
49 void upload_data() override;
50
51 void update_sub(uint start, uint len, const void *data) override;
52
53 void copy_sub(IndexBuf &source_buf,
54 uint source_first_index,
55 uint dest_first_index,
56 uint index_len) override;
57
58 private:
59 bool is_active() const;
60 void strip_restart_indices() override
61 {
62 /* No-op. */
63 }
64
65 MEM_CXX_CLASS_ALLOC_FUNCS("GLIndexBuf")
66};
67
68static inline GLenum to_gl(GPUIndexBufType type)
69{
70 return (type == GPU_INDEX_U32) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT;
71}
72
73} // namespace blender::gpu
Read Blender memory allocation and freeing.
void copy_sub(IndexBuf &source_buf, uint source_first_index, uint dest_first_index, uint index_len) override
Copy part of source index buffer into this index buffer.
void bind_as_ssbo(uint binding) override
void * offset_ptr(uint additional_vertex_offset) const
void update_sub(uint start, uint len, const void *data) override
void read(uint32_t *data) const override
GPUIndexBufType index_type_
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
GLenum to_gl(eGPUDataFormat format)
unsigned int uint
Definition BKE_text.h:55
unsigned int uint32_t
Definition BKE_text.h:81
BMesh const char void * data
_W64 int intptr_t
Definition BKE_text.h:119