1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef GPU_SHADER
# include "GPU_shader_shared_utils.h"
# ifndef __cplusplus
typedef struct gpMaterial gpMaterial;
typedef struct gpLight gpLight;
typedef enum gpMaterialFlag gpMaterialFlag;
typedef enum gpLightType gpLightType;
# endif
#endif
enum gpMaterialFlag {
GP_STROKE_ALIGNMENT_STROKE = 1u,
GP_STROKE_ALIGNMENT_OBJECT = 2u,
GP_STROKE_ALIGNMENT_FIXED = 3u,
GP_STROKE_ALIGNMENT = 0x3u,
GP_STROKE_OVERLAP = (1u << 2u),
GP_STROKE_TEXTURE_USE = (1u << 3u),
GP_STROKE_TEXTURE_STENCIL = (1u << 4u),
GP_STROKE_TEXTURE_PREMUL = (1u << 5u),
GP_STROKE_DOTS = (1u << 6u),
GP_STROKE_HOLDOUT = (1u << 7u),
GP_FILL_HOLDOUT = (1u << 8u),
GP_FILL_TEXTURE_USE = (1u << 10u),
GP_FILL_TEXTURE_PREMUL = (1u << 11u),
GP_FILL_TEXTURE_CLIP = (1u << 12u),
GP_FILL_GRADIENT_USE = (1u << 13u),
GP_FILL_GRADIENT_RADIAL = (1u << 14u),
GP_FILL_FLAGS = (GP_FILL_TEXTURE_USE | GP_FILL_TEXTURE_PREMUL | GP_FILL_TEXTURE_CLIP |
GP_FILL_GRADIENT_USE | GP_FILL_GRADIENT_RADIAL | GP_FILL_HOLDOUT),
};
enum gpLightType {
GP_LIGHT_TYPE_POINT = 0u,
GP_LIGHT_TYPE_SPOT = 1u,
GP_LIGHT_TYPE_SUN = 2u,
GP_LIGHT_TYPE_AMBIENT = 3u,
};
/* Avoid compiler funkiness with enum types not being strongly typed in C. */
#ifndef GPU_SHADER
# define gpMaterialFlag uint
# define gpLightType uint
#endif
struct gpMaterial {
float4 stroke_color;
float4 fill_color;
float4 fill_mix_color;
float4 fill_uv_rot_scale;
#ifndef GPU_SHADER
float2 fill_uv_offset;
float2 alignment_rot;
float stroke_texture_mix;
float stroke_u_scale;
float fill_texture_mix;
gpMaterialFlag flag;
#else
/* Some drivers are completely messing the alignment or the fetches here.
* We are forced to pack these into vec4 otherwise we only get 0.0 as value. */
/* NOTE(@fclem): This was the case on MacOS OpenGL implementation.
* This might be fixed in newer APIs. */
float4 packed1;
float4 packed2;
# define _fill_uv_offset packed1.xy
# define _alignment_rot packed1.zw
# define _stroke_texture_mix packed2.x
# define _stroke_u_scale packed2.y
# define _fill_texture_mix packed2.z
/** NOTE(@fclem): Needs floatBitsToUint(). */
# define _flag packed2.w
#endif
};
BLI_STATIC_ASSERT_ALIGN(gpMaterial, 16)
struct gpLight {
#ifndef GPU_SHADER
float3 color;
gpLightType type;
float3 right;
float spot_size;
float3 up;
float spot_blend;
float3 forward;
float _pad0;
float3 position;
float _pad1;
#else
/* Some drivers are completely messing the alignment or the fetches here.
* We are forced to pack these into vec4 otherwise we only get 0.0 as value. */
/* NOTE(@fclem): This was the case on MacOS OpenGL implementation.
* This might be fixed in newer APIs. */
float4 packed0;
float4 packed1;
float4 packed2;
float4 packed3;
float4 packed4;
# define _color packed0.xyz
# define _type packed0.w
# define _right packed1.xyz
# define _spot_size packed1.w
# define _up packed2.xyz
# define _spot_blend packed2.w
# define _forward packed3.xyz
# define _position packed4.xyz
#endif
};
BLI_STATIC_ASSERT_ALIGN(gpLight, 16)
#ifndef GPU_SHADER
# undef gpMaterialFlag
# undef gpLightType
#endif
|