Blender
V3.3
source
blender
gpu
opengl
gl_vertex_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
12
#include "
glew-mx.h
"
13
14
#include "
GPU_texture.h
"
15
16
#include "
gpu_vertex_buffer_private.hh
"
17
18
namespace
blender
{
19
namespace
gpu {
20
21
class
GLVertBuf
:
public
VertBuf
{
22
friend
class
GLTexture
;
/* For buffer texture. */
23
friend
class
GLShader
;
/* For transform feedback. */
24
friend
class
GLStorageBuf
;
/* For sub copy. */
25
26
private
:
28
GLuint vbo_id_ = 0;
30
struct ::GPUTexture
*buffer_texture_ =
nullptr
;
33
bool
is_wrapper_ =
false
;
35
size_t
vbo_size_ = 0;
36
37
public
:
38
void
bind
();
39
40
void
update_sub
(
uint
start,
uint
len
,
const
void
*
data
)
override
;
41
42
const
void
*
read
()
const override
;
43
void
*
unmap
(
const
void
*mapped_data)
const override
;
44
45
void
wrap_handle
(
uint64_t
handle)
override
;
46
47
protected
:
48
void
acquire_data
()
override
;
49
void
resize_data
()
override
;
50
void
release_data
()
override
;
51
void
upload_data
()
override
;
52
void
duplicate_data
(
VertBuf
*dst)
override
;
53
void
bind_as_ssbo
(
uint
binding)
override
;
54
void
bind_as_texture
(
uint
binding)
override
;
55
56
private
:
57
bool
is_active()
const
;
58
59
MEM_CXX_CLASS_ALLOC_FUNCS(
"GLVertBuf"
);
60
};
61
62
static
inline
GLenum
to_gl
(
GPUUsageType
type
)
63
{
64
switch
(
type
) {
65
case
GPU_USAGE_STREAM
:
66
return
GL_STREAM_DRAW;
67
case
GPU_USAGE_DYNAMIC
:
68
return
GL_DYNAMIC_DRAW;
69
case
GPU_USAGE_STATIC
:
70
case
GPU_USAGE_DEVICE_ONLY
:
71
return
GL_STATIC_DRAW;
72
default
:
73
BLI_assert
(0);
74
return
GL_STATIC_DRAW;
75
}
76
}
77
78
static
inline
GLenum
to_gl
(
GPUVertCompType
type
)
79
{
80
switch
(
type
) {
81
case
GPU_COMP_I8
:
82
return
GL_BYTE;
83
case
GPU_COMP_U8
:
84
return
GL_UNSIGNED_BYTE;
85
case
GPU_COMP_I16
:
86
return
GL_SHORT;
87
case
GPU_COMP_U16
:
88
return
GL_UNSIGNED_SHORT;
89
case
GPU_COMP_I32
:
90
return
GL_INT;
91
case
GPU_COMP_U32
:
92
return
GL_UNSIGNED_INT;
93
case
GPU_COMP_F32
:
94
return
GL_FLOAT;
95
case
GPU_COMP_I10
:
96
return
GL_INT_2_10_10_10_REV;
97
default
:
98
BLI_assert
(0);
99
return
GL_FLOAT;
100
}
101
}
102
103
}
// namespace gpu
104
}
// namespace blender
BLI_assert
#define BLI_assert(a)
Definition:
BLI_assert.h:46
uint
unsigned int uint
Definition:
BLI_sys_types.h:67
type
_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
Definition:
GPU_legacy_stubs.h:151
GPU_texture.h
GPUTexture
struct GPUTexture GPUTexture
Definition:
GPU_texture.h:17
GPUUsageType
GPUUsageType
Definition:
GPU_vertex_buffer.h:41
GPU_USAGE_STATIC
@ GPU_USAGE_STATIC
Definition:
GPU_vertex_buffer.h:44
GPU_USAGE_STREAM
@ GPU_USAGE_STREAM
Definition:
GPU_vertex_buffer.h:43
GPU_USAGE_DYNAMIC
@ GPU_USAGE_DYNAMIC
Definition:
GPU_vertex_buffer.h:45
GPU_USAGE_DEVICE_ONLY
@ GPU_USAGE_DEVICE_ONLY
Definition:
GPU_vertex_buffer.h:46
GPUVertCompType
GPUVertCompType
Definition:
GPU_vertex_format.h:28
GPU_COMP_U16
@ GPU_COMP_U16
Definition:
GPU_vertex_format.h:32
GPU_COMP_I10
@ GPU_COMP_I10
Definition:
GPU_vertex_format.h:38
GPU_COMP_F32
@ GPU_COMP_F32
Definition:
GPU_vertex_format.h:36
GPU_COMP_I32
@ GPU_COMP_I32
Definition:
GPU_vertex_format.h:33
GPU_COMP_I8
@ GPU_COMP_I8
Definition:
GPU_vertex_format.h:29
GPU_COMP_U32
@ GPU_COMP_U32
Definition:
GPU_vertex_format.h:34
GPU_COMP_I16
@ GPU_COMP_I16
Definition:
GPU_vertex_format.h:31
GPU_COMP_U8
@ GPU_COMP_U8
Definition:
GPU_vertex_format.h:30
MEM_guardedalloc.h
Read Guarded memory(de)allocation.
blender::gpu::GLShader
Definition:
gl_shader.hh:23
blender::gpu::GLStorageBuf
Definition:
gl_storage_buffer.hh:22
blender::gpu::GLTexture
Definition:
gl_texture.hh:23
blender::gpu::GLVertBuf
Definition:
gl_vertex_buffer.hh:21
blender::gpu::GLVertBuf::bind_as_texture
void bind_as_texture(uint binding) override
Definition:
gl_vertex_buffer.cc:118
blender::gpu::GLVertBuf::upload_data
void upload_data() override
Definition:
gl_vertex_buffer.cc:78
blender::gpu::GLVertBuf::unmap
void * unmap(const void *mapped_data) const override
Definition:
gl_vertex_buffer.cc:135
blender::gpu::GLVertBuf::bind_as_ssbo
void bind_as_ssbo(uint binding) override
Definition:
gl_vertex_buffer.cc:111
blender::gpu::GLVertBuf::wrap_handle
void wrap_handle(uint64_t handle) override
Definition:
gl_vertex_buffer.cc:142
blender::gpu::GLVertBuf::duplicate_data
void duplicate_data(VertBuf *dst) override
Definition:
gl_vertex_buffer.cc:52
blender::gpu::GLVertBuf::resize_data
void resize_data() override
Definition:
gl_vertex_buffer.cc:27
blender::gpu::GLVertBuf::update_sub
void update_sub(uint start, uint len, const void *data) override
Definition:
gl_vertex_buffer.cc:162
blender::gpu::GLVertBuf::acquire_data
void acquire_data() override
Definition:
gl_vertex_buffer.cc:16
blender::gpu::GLVertBuf::read
const void * read() const override
Definition:
gl_vertex_buffer.cc:128
blender::gpu::GLVertBuf::release_data
void release_data() override
Definition:
gl_vertex_buffer.cc:36
blender::gpu::GLVertBuf::bind
void bind()
Definition:
gl_vertex_buffer.cc:83
blender::gpu::VertBuf
Definition:
gpu_vertex_buffer_private.hh:20
blender::gpu::VertBuf::data
uchar * data
Definition:
gpu_vertex_buffer_private.hh:32
len
int len
Definition:
draw_manager.c:108
glew-mx.h
gpu_vertex_buffer_private.hh
blender::gpu::to_gl
static GLenum to_gl(const GPUAttachmentType type)
Definition:
gl_framebuffer.hh:116
blender
Definition:
BKE_action.hh:16
uint64_t
unsigned __int64 uint64_t
Definition:
stdint.h:90
Generated on Sat Jul 27 2024 14:57:55 for Blender by
doxygen
1.9.1