Blender V4.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
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 private:
54 bool is_active() const;
55 void strip_restart_indices() override
56 {
57 /* No-op. */
58 }
59
60 MEM_CXX_CLASS_ALLOC_FUNCS("GLIndexBuf")
61};
62
63static inline GLenum to_gl(GPUIndexBufType type)
64{
65 return (type == GPU_INDEX_U32) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT;
66}
67
68} // namespace blender::gpu
unsigned int uint
Read Guarded memory(de)allocation.
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_
int len
static GLenum to_gl(const GPUAttachmentType type)
unsigned int uint32_t
Definition stdint.h:80
_W64 int intptr_t
Definition stdint.h:118