Blender V5.0
gl_batch.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
11
12#pragma once
13
14#include "MEM_guardedalloc.h"
15
16#include "GPU_batch.hh"
17
18#include "gl_index_buffer.hh"
19#include "gl_vertex_buffer.hh"
20
21namespace blender {
22namespace gpu {
23
24class GLContext;
26
27#define GPU_VAO_STATIC_LEN 3
28
35 private:
37 GLContext *context_ = nullptr;
39 GLShaderInterface *interface_ = nullptr;
41 GLuint vao_id_ = 0;
43 GLuint vao_base_instance_ = 0;
44 int base_instance_ = 0;
45
46 bool is_dynamic_vao_count = false;
47 union {
49 struct {
54 struct {
57 GLuint *vao_ids;
59 };
60
61 public:
62 GLVaoCache();
64
65 GLuint vao_get(Batch *batch);
66
70 GLuint lookup(const GLShaderInterface *interface);
74 void insert(const GLShaderInterface *interface, GLuint vao_id);
75 void remove(const GLShaderInterface *interface);
76 void clear();
77
78 private:
79 void init();
84 void context_check();
85};
86
87class GLBatch : public Batch {
88 public:
91
92 public:
93 void draw(int v_first, int v_count, int i_first, int i_count) override;
94 void draw_indirect(StorageBuf *indirect_buf, intptr_t offset) override;
95 void multi_draw_indirect(StorageBuf *indirect_buf,
96 int count,
97 intptr_t offset,
98 intptr_t stride) override;
99 void bind();
100
101 /* Convenience getters. */
102
104 {
105 return static_cast<GLIndexBuf *>(elem);
106 }
107 GLVertBuf *verts_(const int index) const
108 {
109 return static_cast<GLVertBuf *>(verts[index]);
110 }
111
113};
114
115} // namespace gpu
116} // namespace blender
unsigned int uint
Read Guarded memory(de)allocation.
void init()
MEM_CXX_CLASS_ALLOC_FUNCS("GLBatch")
GLIndexBuf * elem_() const
Definition gl_batch.hh:103
void draw(int v_first, int v_count, int i_first, int i_count) override
Definition gl_batch.cc:249
GLVertBuf * verts_(const int index) const
Definition gl_batch.hh:107
void multi_draw_indirect(StorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride) override
Definition gl_batch.cc:293
void draw_indirect(StorageBuf *indirect_buf, intptr_t offset) override
Definition gl_batch.cc:273
GLVaoCache vao_cache_
Definition gl_batch.hh:90
GLuint lookup(const GLShaderInterface *interface)
Definition gl_batch.cc:180
const GLShaderInterface * interfaces[GPU_VAO_STATIC_LEN]
Definition gl_batch.hh:50
GLuint vao_get(Batch *batch)
Definition gl_batch.cc:210
void insert(const GLShaderInterface *interface, GLuint vao_id)
Definition gl_batch.cc:60
GLuint vao_ids[GPU_VAO_STATIC_LEN]
Definition gl_batch.hh:51
struct blender::gpu::GLVaoCache::@157236110271242160153365376064020364322222010350::@314007012112177177054114203301226370061215216002 static_vaos
struct blender::gpu::GLVaoCache::@157236110271242160153365376064020364322222010350::@162033253374111303027310313277133152141252374306 dynamic_vaos
void remove(const GLShaderInterface *interface)
Definition gl_batch.cc:117
static float verts[][3]
struct @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 batch
int count
#define GPU_VAO_STATIC_LEN
Definition mtl_batch.hh:26