Blender V4.5
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(GPUStorageBuf *indirect_buf, intptr_t offset) override;
95 void multi_draw_indirect(GPUStorageBuf *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 GLVertBuf *inst_(const int index) const
112 {
113 return static_cast<GLVertBuf *>(inst[index]);
114 }
115
117};
118
119} // namespace gpu
120} // namespace blender
unsigned int uint
Read Guarded memory(de)allocation.
void init()
void multi_draw_indirect(GPUStorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride) override
Definition gl_batch.cc:293
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 * inst_(const int index) const
Definition gl_batch.hh:111
GLVertBuf * verts_(const int index) const
Definition gl_batch.hh:107
void draw_indirect(GPUStorageBuf *indirect_buf, intptr_t offset) override
Definition gl_batch.cc:273
GLVaoCache vao_cache_
Definition gl_batch.hh:90
struct blender::gpu::GLVaoCache::@264364121066041311013037146331125154053361242167::@130210132160105214134353253032145373115215137120 static_vaos
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
struct blender::gpu::GLVaoCache::@264364121066041311013037146331125154053361242167::@161167340272207057142031313234371167342341014331 dynamic_vaos
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
void remove(const GLShaderInterface *interface)
Definition gl_batch.cc:117
static float verts[][3]
struct @064345207361167251075330302113175271221317160336::@113254110077376341056327177062323111323010325277 batch
int count
#define GPU_VAO_STATIC_LEN
Definition mtl_batch.hh:26