Blender V4.3
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
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;
25class GLShaderInterface;
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 multi_draw_indirect(GPUStorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride) override
Definition gl_batch.cc:294
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:250
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:274
GLVaoCache vao_cache_
Definition gl_batch.hh:90
struct blender::gpu::GLVaoCache::@655::@657 static_vaos
GLuint lookup(const GLShaderInterface *interface)
Definition gl_batch.cc:181
struct blender::gpu::GLVaoCache::@655::@658 dynamic_vaos
const GLShaderInterface ** interfaces
Definition gl_batch.hh:56
const GLShaderInterface * interfaces[GPU_VAO_STATIC_LEN]
Definition gl_batch.hh:50
GLuint vao_get(Batch *batch)
Definition gl_batch.cc:211
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:118
static float verts[][3]
struct @620::@622 batch
int count
#define GPU_VAO_STATIC_LEN
Definition mtl_batch.hh:26
_W64 int intptr_t
Definition stdint.h:118