Blender
V4.5
source
blender
draw
intern
draw_subdiv_shader_shared.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2025 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
9
#pragma once
10
11
#include "
draw_subdiv_defines.hh
"
12
13
#ifndef GPU_SHADER
14
# include "
GPU_shader_shared_utils.hh
"
15
#endif
16
17
struct
DRWSubdivUboStorage
{
18
/* Offsets in the buffers data where the source and destination data start. */
19
int
src_offset
;
20
int
dst_offset
;
21
22
/* Parameters for the DRWPatchMap. */
23
int
min_patch_face
;
24
int
max_patch_face
;
25
int
max_depth
;
26
bool32_t
patches_are_triangular
;
27
28
/* Coarse topology information. */
29
int
coarse_face_count
;
30
uint
edge_loose_offset
;
31
32
/* Refined topology information. */
33
uint
num_subdiv_loops
;
34
35
/* The sculpt mask data layer may be null. */
36
bool32_t
has_sculpt_mask
;
37
38
/* Masks for the extra coarse face data. */
39
uint
coarse_face_select_mask
;
40
uint
coarse_face_smooth_mask
;
41
uint
coarse_face_active_mask
;
42
uint
coarse_face_hidden_mask
;
43
uint
coarse_face_loopstart_mask
;
44
45
/* Number of elements to process in the compute shader (can be the coarse quad count, or the
46
* final vertex count, depending on which compute pass we do). This is used to early out in case
47
* of out of bond accesses as compute dispatch are of fixed size. */
48
uint
total_dispatch_size
;
49
50
bool32_t
is_edit_mode
;
51
bool32_t
use_hide
;
52
int
_pad3
;
53
int
_pad4
;
54
};
55
BLI_STATIC_ASSERT_ALIGN
(
DRWSubdivUboStorage
, 16)
56
57
struct
SculptData
{
58
uint
face_set_color
;
59
float
mask
;
60
};
61
62
/* Duplicate of #PosNorLoop from the mesh extract CPU code.
63
* We do not use a float3 for the position as it will be padded to a float4 which is incompatible
64
* with the format. */
65
struct
PosNorLoop
{
66
float
x
,
y
,
z
;
67
float
nx
,
ny
,
nz
;
68
float
flag
;
69
};
70
71
/* Mirror of #UVStretchAngle in the C++ code, but using floats until proper data compression
72
* is implemented for all subdivision data. */
73
struct
UVStretchAngle
{
74
float
angle
;
75
float
uv_angle0
;
76
float
uv_angle1
;
77
};
78
79
struct
LoopNormal
{
80
float
nx
,
ny
,
nz
;
81
float
flag
;
82
};
83
84
struct
CustomNormal
{
85
float
x
;
86
float
y
;
87
float
z
;
88
};
89
90
/* Structure for #CompressedPatchCoord. */
91
struct
BlenderPatchCoord
{
92
int
patch_index
;
93
uint
encoded_uv
;
94
};
95
96
/* Patch evaluation - F-dots. */
97
/* float3 is padded to float4, but the format used for face-dots does not have any padding. */
98
struct
FDotVert
{
99
float
x
,
y
,
z
;
100
};
101
102
/* Same here, do not use float3. */
103
struct
FDotNor
{
104
float
x
,
y
,
z
;
105
float
flag
;
106
};
107
108
/* This structure is a carbon copy of OpenSubDiv's #PatchTable::PatchHandle. */
109
struct
PatchHandle
{
110
int
array_index
;
111
int
patch_index
;
112
int
vertex_index
;
113
};
114
115
/* This structure is a carbon copy of OpenSubDiv's #PatchCoord. */
116
struct
PatchCoord
{
117
int
array_index
;
118
int
patch_index
;
119
int
vertex_index
;
120
float
u
;
121
float
v
;
122
};
123
124
/* This structure is a carbon copy of OpenSubDiv's #PatchCoord.QuadNode.
125
* Each child is a bit-field. */
126
struct
QuadNode
{
127
uint4
child
;
128
};
129
130
/* When not using OSD we need to defined the structs as they subdiv_info still refer to them. */
131
#if !defined(USE_GPU_SHADER_CREATE_INFO) || \
132
(!defined(OSD_PATCH_BASIS_GLSL) && !defined(OSD_PATCH_BASIS_METAL))
133
/* This structure is a carbon copy of OpenSubDiv's #Osd::PatchParam. */
134
struct
OsdPatchParam
{
135
int
field0
;
136
int
field1
;
137
float
sharpness
;
138
};
139
140
/* This structure is a carbon copy of OpenSubDiv's #Osd::PatchArray. */
141
struct
OsdPatchArray
{
142
int
regDesc
;
143
int
desc
;
144
int
numPatches
;
145
int
indexBase
;
146
int
stride
;
147
int
primitiveIdBase
;
148
};
149
150
/* This structure is a carbon copy of OpenSubDiv's #Osd::PatchCoord. */
151
struct
OsdPatchCoord
{
152
int
arrayIndex
;
153
int
patchIndex
;
154
int
vertIndex
;
155
float
s
;
156
float
t
;
157
};
158
159
#endif
BLI_STATIC_ASSERT_ALIGN
#define BLI_STATIC_ASSERT_ALIGN(st, align)
Definition
BLI_assert.h:86
uint
unsigned int uint
Definition
BLI_sys_types.h:64
GPU_shader_shared_utils.hh
bool32_t
int32_t bool32_t
Definition
GPU_shader_shared_utils.hh:84
draw_subdiv_defines.hh
BlenderPatchCoord
Definition
draw_subdiv_shader_shared.hh:91
BlenderPatchCoord::patch_index
int patch_index
Definition
draw_subdiv_shader_shared.hh:92
BlenderPatchCoord::encoded_uv
uint encoded_uv
Definition
draw_subdiv_shader_shared.hh:93
CustomNormal
Definition
draw_subdiv_shader_shared.hh:84
CustomNormal::z
float z
Definition
draw_subdiv_shader_shared.hh:87
CustomNormal::x
float x
Definition
draw_subdiv_shader_shared.hh:85
CustomNormal::y
float y
Definition
draw_subdiv_shader_shared.hh:86
DRWSubdivUboStorage
Definition
draw_subdiv_shader_shared.hh:17
DRWSubdivUboStorage::has_sculpt_mask
bool32_t has_sculpt_mask
Definition
draw_subdiv_shader_shared.hh:36
DRWSubdivUboStorage::coarse_face_active_mask
uint coarse_face_active_mask
Definition
draw_subdiv_shader_shared.hh:41
DRWSubdivUboStorage::src_offset
int src_offset
Definition
draw_subdiv_shader_shared.hh:19
DRWSubdivUboStorage::is_edit_mode
bool32_t is_edit_mode
Definition
draw_subdiv_shader_shared.hh:50
DRWSubdivUboStorage::coarse_face_loopstart_mask
uint coarse_face_loopstart_mask
Definition
draw_subdiv_shader_shared.hh:43
DRWSubdivUboStorage::patches_are_triangular
bool32_t patches_are_triangular
Definition
draw_subdiv_shader_shared.hh:26
DRWSubdivUboStorage::num_subdiv_loops
uint num_subdiv_loops
Definition
draw_subdiv_shader_shared.hh:33
DRWSubdivUboStorage::edge_loose_offset
uint edge_loose_offset
Definition
draw_subdiv_shader_shared.hh:30
DRWSubdivUboStorage::coarse_face_select_mask
uint coarse_face_select_mask
Definition
draw_subdiv_shader_shared.hh:39
DRWSubdivUboStorage::coarse_face_smooth_mask
uint coarse_face_smooth_mask
Definition
draw_subdiv_shader_shared.hh:40
DRWSubdivUboStorage::max_depth
int max_depth
Definition
draw_subdiv_shader_shared.hh:25
DRWSubdivUboStorage::coarse_face_hidden_mask
uint coarse_face_hidden_mask
Definition
draw_subdiv_shader_shared.hh:42
DRWSubdivUboStorage::min_patch_face
int min_patch_face
Definition
draw_subdiv_shader_shared.hh:23
DRWSubdivUboStorage::_pad4
int _pad4
Definition
draw_subdiv_shader_shared.hh:53
DRWSubdivUboStorage::_pad3
int _pad3
Definition
draw_subdiv_shader_shared.hh:52
DRWSubdivUboStorage::max_patch_face
int max_patch_face
Definition
draw_subdiv_shader_shared.hh:24
DRWSubdivUboStorage::use_hide
bool32_t use_hide
Definition
draw_subdiv_shader_shared.hh:51
DRWSubdivUboStorage::dst_offset
int dst_offset
Definition
draw_subdiv_shader_shared.hh:20
DRWSubdivUboStorage::total_dispatch_size
uint total_dispatch_size
Definition
draw_subdiv_shader_shared.hh:48
DRWSubdivUboStorage::coarse_face_count
int coarse_face_count
Definition
draw_subdiv_shader_shared.hh:29
FDotNor
Definition
draw_subdiv_shader_shared.hh:103
FDotNor::x
float x
Definition
draw_subdiv_shader_shared.hh:104
FDotNor::z
float z
Definition
draw_subdiv_shader_shared.hh:104
FDotNor::y
float y
Definition
draw_subdiv_shader_shared.hh:104
FDotNor::flag
float flag
Definition
draw_subdiv_shader_shared.hh:105
FDotVert
Definition
draw_subdiv_shader_shared.hh:98
FDotVert::y
float y
Definition
draw_subdiv_shader_shared.hh:99
FDotVert::x
float x
Definition
draw_subdiv_shader_shared.hh:99
FDotVert::z
float z
Definition
draw_subdiv_shader_shared.hh:99
LoopNormal
Definition
draw_subdiv_shader_shared.hh:79
LoopNormal::nx
float nx
Definition
draw_subdiv_shader_shared.hh:80
LoopNormal::flag
float flag
Definition
draw_subdiv_shader_shared.hh:81
LoopNormal::nz
float nz
Definition
draw_subdiv_shader_shared.hh:80
LoopNormal::ny
float ny
Definition
draw_subdiv_shader_shared.hh:80
OsdPatchArray
Definition
draw_subdiv_shader_shared.hh:141
OsdPatchArray::stride
int stride
Definition
draw_subdiv_shader_shared.hh:146
OsdPatchArray::desc
int desc
Definition
draw_subdiv_shader_shared.hh:143
OsdPatchArray::regDesc
int regDesc
Definition
draw_subdiv_shader_shared.hh:142
OsdPatchArray::indexBase
int indexBase
Definition
draw_subdiv_shader_shared.hh:145
OsdPatchArray::numPatches
int numPatches
Definition
draw_subdiv_shader_shared.hh:144
OsdPatchArray::primitiveIdBase
int primitiveIdBase
Definition
draw_subdiv_shader_shared.hh:147
OsdPatchCoord
Definition
draw_subdiv_shader_shared.hh:151
OsdPatchCoord::patchIndex
int patchIndex
Definition
draw_subdiv_shader_shared.hh:153
OsdPatchCoord::arrayIndex
int arrayIndex
Definition
draw_subdiv_shader_shared.hh:152
OsdPatchCoord::s
float s
Definition
draw_subdiv_shader_shared.hh:155
OsdPatchCoord::vertIndex
int vertIndex
Definition
draw_subdiv_shader_shared.hh:154
OsdPatchCoord::t
float t
Definition
draw_subdiv_shader_shared.hh:156
OsdPatchParam
Definition
draw_subdiv_shader_shared.hh:134
OsdPatchParam::sharpness
float sharpness
Definition
draw_subdiv_shader_shared.hh:137
OsdPatchParam::field0
int field0
Definition
draw_subdiv_shader_shared.hh:135
OsdPatchParam::field1
int field1
Definition
draw_subdiv_shader_shared.hh:136
PatchCoord
Definition
draw_subdiv_shader_shared.hh:116
PatchCoord::vertex_index
int vertex_index
Definition
draw_subdiv_shader_shared.hh:119
PatchCoord::patch_index
int patch_index
Definition
draw_subdiv_shader_shared.hh:118
PatchCoord::u
float u
Definition
draw_subdiv_shader_shared.hh:120
PatchCoord::v
float v
Definition
draw_subdiv_shader_shared.hh:121
PatchCoord::array_index
int array_index
Definition
draw_subdiv_shader_shared.hh:117
PatchHandle
Definition
draw_subdiv_shader_shared.hh:109
PatchHandle::patch_index
int patch_index
Definition
draw_subdiv_shader_shared.hh:111
PatchHandle::vertex_index
int vertex_index
Definition
draw_subdiv_shader_shared.hh:112
PatchHandle::array_index
int array_index
Definition
draw_subdiv_shader_shared.hh:110
PosNorLoop
Definition
draw_subdiv_shader_shared.hh:65
PosNorLoop::nx
float nx
Definition
draw_subdiv_shader_shared.hh:67
PosNorLoop::ny
float ny
Definition
draw_subdiv_shader_shared.hh:67
PosNorLoop::y
float y
Definition
draw_subdiv_shader_shared.hh:66
PosNorLoop::z
float z
Definition
draw_subdiv_shader_shared.hh:66
PosNorLoop::flag
float flag
Definition
draw_subdiv_shader_shared.hh:68
PosNorLoop::x
float x
Definition
draw_subdiv_shader_shared.hh:66
PosNorLoop::nz
float nz
Definition
draw_subdiv_shader_shared.hh:67
QuadNode
Definition
draw_subdiv_shader_shared.hh:126
QuadNode::child
uint4 child
Definition
draw_subdiv_shader_shared.hh:127
SculptData
Definition
draw_subdiv_shader_shared.hh:57
SculptData::mask
float mask
Definition
draw_subdiv_shader_shared.hh:59
SculptData::face_set_color
uint face_set_color
Definition
draw_subdiv_shader_shared.hh:58
UVStretchAngle
Definition
draw_subdiv_shader_shared.hh:73
UVStretchAngle::uv_angle1
float uv_angle1
Definition
draw_subdiv_shader_shared.hh:76
UVStretchAngle::angle
float angle
Definition
draw_subdiv_shader_shared.hh:74
UVStretchAngle::uv_angle0
float uv_angle0
Definition
draw_subdiv_shader_shared.hh:75
uint4
Definition
types_uint4.h:12
Generated on Fri Apr 3 2026 06:33:18 for Blender by
doxygen
1.11.0