Blender  V3.3
gl_index_buffer.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 #include "MEM_guardedalloc.h"
11 
13 
14 #include "glew-mx.h"
15 
16 namespace blender::gpu {
17 
18 class GLIndexBuf : public IndexBuf {
19  friend class GLBatch;
20  friend class GLDrawList;
21  friend class GLShader; /* For compute shaders. */
22 
23  private:
24  GLuint ibo_id_ = 0;
25 
26  public:
27  ~GLIndexBuf();
28 
29  void bind();
30  void bind_as_ssbo(uint binding) override;
31 
32  const uint32_t *read() const override;
33 
34  void *offset_ptr(uint additional_vertex_offset) const
35  {
36  additional_vertex_offset += index_start_;
37  if (index_type_ == GPU_INDEX_U32) {
38  return (GLuint *)0 + additional_vertex_offset;
39  }
40  return (GLushort *)0 + additional_vertex_offset;
41  }
42 
43  GLuint restart_index() const
44  {
45  return (index_type_ == GPU_INDEX_U16) ? 0xFFFFu : 0xFFFFFFFFu;
46  }
47 
48  void upload_data() override;
49 
50  void update_sub(uint start, uint len, const void *data) override;
51 
52  private:
53  bool is_active() const;
54 
55  MEM_CXX_CLASS_ALLOC_FUNCS("GLIndexBuf")
56 };
57 
58 static inline GLenum to_gl(GPUIndexBufType type)
59 {
60  return (type == GPU_INDEX_U32) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT;
61 }
62 
63 } // namespace blender::gpu
unsigned int uint
Definition: BLI_sys_types.h:67
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
GLuint restart_index() const
void bind_as_ssbo(uint binding) override
const uint32_t * read() const override
void update_sub(uint start, uint len, const void *data) override
void upload_data() override
void * offset_ptr(uint additional_vertex_offset) const
int len
Definition: draw_manager.c:108
static GLenum to_gl(const GPUAttachmentType type)
unsigned int uint32_t
Definition: stdint.h:80