Blender V4.3
gl_shader_interface.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2016 by Mike Erwin. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11#include "BLI_bitmap.h"
12
13#include "gl_batch.hh"
14#include "gl_context.hh"
15
17
18#include "GPU_capabilities.hh"
19
20using namespace blender::gpu::shader;
21namespace blender::gpu {
22
23/* -------------------------------------------------------------------- */
30static inline int block_binding(int32_t program, uint32_t block_index)
31{
32 /* For now just assign a consecutive index. In the future, we should set it in
33 * the shader using layout(binding = i) and query its value. */
34 glUniformBlockBinding(program, block_index, block_index);
35 return block_index;
36}
37
38static inline int sampler_binding(int32_t program,
39 uint32_t uniform_index,
40 int32_t uniform_location,
41 int *sampler_len)
42{
43 /* Identify sampler uniforms and assign sampler units to them. */
44 GLint type;
45 glGetActiveUniformsiv(program, 1, &uniform_index, GL_UNIFORM_TYPE, &type);
46
47 switch (type) {
48 case GL_SAMPLER_1D:
49 case GL_SAMPLER_2D:
50 case GL_SAMPLER_3D:
51 case GL_SAMPLER_CUBE:
52 case GL_SAMPLER_CUBE_MAP_ARRAY_ARB: /* OpenGL 4.0 */
53 case GL_SAMPLER_1D_SHADOW:
54 case GL_SAMPLER_2D_SHADOW:
55 case GL_SAMPLER_1D_ARRAY:
56 case GL_SAMPLER_2D_ARRAY:
57 case GL_SAMPLER_1D_ARRAY_SHADOW:
58 case GL_SAMPLER_2D_ARRAY_SHADOW:
59 case GL_SAMPLER_2D_MULTISAMPLE:
60 case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
61 case GL_SAMPLER_CUBE_SHADOW:
62 case GL_SAMPLER_BUFFER:
63 case GL_INT_SAMPLER_1D:
64 case GL_INT_SAMPLER_2D:
65 case GL_INT_SAMPLER_3D:
66 case GL_INT_SAMPLER_CUBE:
67 case GL_INT_SAMPLER_1D_ARRAY:
68 case GL_INT_SAMPLER_2D_ARRAY:
69 case GL_INT_SAMPLER_2D_MULTISAMPLE:
70 case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
71 case GL_INT_SAMPLER_BUFFER:
72 case GL_UNSIGNED_INT_SAMPLER_1D:
73 case GL_UNSIGNED_INT_SAMPLER_2D:
74 case GL_UNSIGNED_INT_SAMPLER_3D:
75 case GL_UNSIGNED_INT_SAMPLER_CUBE:
76 case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
77 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
78 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
79 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
80 case GL_UNSIGNED_INT_SAMPLER_BUFFER: {
81 /* For now just assign a consecutive index. In the future, we should set it in
82 * the shader using layout(binding = i) and query its value. */
83 int binding = *sampler_len;
84 glUniform1i(uniform_location, binding);
85 (*sampler_len)++;
86 return binding;
87 }
88 default:
89 return -1;
90 }
91}
92
93static inline int image_binding(int32_t program,
94 uint32_t uniform_index,
95 int32_t uniform_location,
96 int *image_len)
97{
98 /* Identify image uniforms and assign image units to them. */
99 GLint type;
100 glGetActiveUniformsiv(program, 1, &uniform_index, GL_UNIFORM_TYPE, &type);
101
102 switch (type) {
103 case GL_IMAGE_1D:
104 case GL_IMAGE_2D:
105 case GL_IMAGE_3D:
106 case GL_IMAGE_CUBE:
107 case GL_IMAGE_BUFFER:
108 case GL_IMAGE_1D_ARRAY:
109 case GL_IMAGE_2D_ARRAY:
110 case GL_IMAGE_CUBE_MAP_ARRAY:
111 case GL_INT_IMAGE_1D:
112 case GL_INT_IMAGE_2D:
113 case GL_INT_IMAGE_3D:
114 case GL_INT_IMAGE_CUBE:
115 case GL_INT_IMAGE_BUFFER:
116 case GL_INT_IMAGE_1D_ARRAY:
117 case GL_INT_IMAGE_2D_ARRAY:
118 case GL_INT_IMAGE_CUBE_MAP_ARRAY:
119 case GL_UNSIGNED_INT_IMAGE_1D:
120 case GL_UNSIGNED_INT_IMAGE_2D:
121 case GL_UNSIGNED_INT_IMAGE_3D:
122 case GL_UNSIGNED_INT_IMAGE_CUBE:
123 case GL_UNSIGNED_INT_IMAGE_BUFFER:
124 case GL_UNSIGNED_INT_IMAGE_1D_ARRAY:
125 case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
126 case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY: {
127 /* For now just assign a consecutive index. In the future, we should set it in
128 * the shader using layout(binding = i) and query its value. */
129 int binding = *image_len;
130 glUniform1i(uniform_location, binding);
131 (*image_len)++;
132 return binding;
133 }
134 default:
135 return -1;
136 }
137}
138
139static inline int ssbo_binding(int32_t program, uint32_t ssbo_index)
140{
141 GLint binding = -1;
142 GLenum property = GL_BUFFER_BINDING;
143 GLint values_written = 0;
144 glGetProgramResourceiv(
145 program, GL_SHADER_STORAGE_BLOCK, ssbo_index, 1, &property, 1, &values_written, &binding);
146
147 return binding;
148}
149
152/* -------------------------------------------------------------------- */
156static Type gpu_type_from_gl_type(int gl_type)
157{
158 switch (gl_type) {
159 case GL_FLOAT:
160 return Type::FLOAT;
161 case GL_FLOAT_VEC2:
162 return Type::VEC2;
163 case GL_FLOAT_VEC3:
164 return Type::VEC3;
165 case GL_FLOAT_VEC4:
166 return Type::VEC4;
167 case GL_FLOAT_MAT3:
168 return Type::MAT3;
169 case GL_FLOAT_MAT4:
170 return Type::MAT4;
171 case GL_UNSIGNED_INT:
172 return Type::UINT;
173 case GL_UNSIGNED_INT_VEC2:
174 return Type::UVEC2;
175 case GL_UNSIGNED_INT_VEC3:
176 return Type::UVEC3;
177 case GL_UNSIGNED_INT_VEC4:
178 return Type::UVEC4;
179 case GL_INT:
180 return Type::INT;
181 case GL_INT_VEC2:
182 return Type::IVEC2;
183 case GL_INT_VEC3:
184 return Type::IVEC3;
185 case GL_INT_VEC4:
186 return Type::IVEC4;
187 case GL_BOOL:
188 return Type::BOOL;
189 case GL_FLOAT_MAT2:
190 case GL_FLOAT_MAT2x3:
191 case GL_FLOAT_MAT2x4:
192 case GL_FLOAT_MAT3x2:
193 case GL_FLOAT_MAT3x4:
194 case GL_FLOAT_MAT4x2:
195 case GL_FLOAT_MAT4x3:
196 default:
197 BLI_assert(0);
198 }
199 return Type::FLOAT;
200}
201
203{
204 GLuint last_program;
205 glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *)&last_program);
206
207 /* Necessary to make #glUniform works. */
208 glUseProgram(program);
209
210 GLint max_attr_name_len = 0, attr_len = 0;
211 glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attr_name_len);
212 glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attr_len);
213
214 GLint max_ubo_name_len = 0, ubo_len = 0;
215 glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len);
216 glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_len);
217
218 GLint max_uniform_name_len = 0, active_uniform_len = 0, uniform_len = 0;
219 glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_uniform_name_len);
220 glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &active_uniform_len);
221 uniform_len = active_uniform_len;
222
223 GLint max_ssbo_name_len = 0, ssbo_len = 0;
224 glGetProgramInterfaceiv(program, GL_SHADER_STORAGE_BLOCK, GL_ACTIVE_RESOURCES, &ssbo_len);
225 glGetProgramInterfaceiv(
226 program, GL_SHADER_STORAGE_BLOCK, GL_MAX_NAME_LENGTH, &max_ssbo_name_len);
227
228 BLI_assert_msg(ubo_len <= 16, "enabled_ubo_mask_ is uint16_t");
229
230 /* Work around driver bug with Intel HD 4600 on Windows 7/8, where
231 * GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH does not work. */
232 if (attr_len > 0 && max_attr_name_len == 0) {
233 max_attr_name_len = 256;
234 }
235 if (ubo_len > 0 && max_ubo_name_len == 0) {
236 max_ubo_name_len = 256;
237 }
238 if (uniform_len > 0 && max_uniform_name_len == 0) {
239 max_uniform_name_len = 256;
240 }
241 if (ssbo_len > 0 && max_ssbo_name_len == 0) {
242 max_ssbo_name_len = 256;
243 }
244
245 /* GL_ACTIVE_UNIFORMS lied to us! Remove the UBO uniforms from the total before
246 * allocating the uniform array. */
247 GLint max_ubo_uni_len = 0;
248 for (int i = 0; i < ubo_len; i++) {
249 GLint ubo_uni_len;
250 glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &ubo_uni_len);
251 max_ubo_uni_len = max_ii(max_ubo_uni_len, ubo_uni_len);
252 uniform_len -= ubo_uni_len;
253 }
254 /* Bit set to true if uniform comes from a uniform block. */
255 BLI_bitmap *uniforms_from_blocks = BLI_BITMAP_NEW(active_uniform_len, __func__);
256 /* Set uniforms from block for exclusion. */
257 GLint *ubo_uni_ids = (GLint *)MEM_mallocN(sizeof(GLint) * max_ubo_uni_len, __func__);
258 for (int i = 0; i < ubo_len; i++) {
259 GLint ubo_uni_len;
260 glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &ubo_uni_len);
261 glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, ubo_uni_ids);
262 for (int u = 0; u < ubo_uni_len; u++) {
263 BLI_BITMAP_ENABLE(uniforms_from_blocks, ubo_uni_ids[u]);
264 }
265 }
266 MEM_freeN(ubo_uni_ids);
267
268 int input_tot_len = attr_len + ubo_len + uniform_len + ssbo_len;
269 inputs_ = (ShaderInput *)MEM_callocN(sizeof(ShaderInput) * input_tot_len, __func__);
270
271 const uint32_t name_buffer_len = attr_len * max_attr_name_len + ubo_len * max_ubo_name_len +
272 uniform_len * max_uniform_name_len +
273 ssbo_len * max_ssbo_name_len;
274 name_buffer_ = (char *)MEM_mallocN(name_buffer_len, "name_buffer");
275 uint32_t name_buffer_offset = 0;
276
277 /* Attributes */
279 for (int i = 0; i < attr_len; i++) {
280 char *name = name_buffer_ + name_buffer_offset;
281 GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
282 GLsizei name_len = 0;
283 GLenum type;
284 GLint size;
285
286 glGetActiveAttrib(program, i, remaining_buffer, &name_len, &size, &type, name);
287 GLint location = glGetAttribLocation(program, name);
288 /* Ignore OpenGL names like `gl_BaseInstanceARB`, `gl_InstanceID` and `gl_VertexID`. */
289 if (location == -1) {
290 continue;
291 }
292
293 ShaderInput *input = &inputs_[attr_len_++];
294 input->location = input->binding = location;
295
296 name_buffer_offset += set_input_name(input, name, name_len);
297 enabled_attr_mask_ |= (1 << input->location);
298
299 /* Used in `GPU_shader_get_attribute_info`. */
300 attr_types_[input->location] = uint8_t(gpu_type_from_gl_type(type));
301 }
302
303 /* Uniform Blocks */
304 for (int i = 0; i < ubo_len; i++) {
305 char *name = name_buffer_ + name_buffer_offset;
306 GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
307 GLsizei name_len = 0;
308
309 glGetActiveUniformBlockName(program, i, remaining_buffer, &name_len, name);
310
311 ShaderInput *input = &inputs_[attr_len_ + ubo_len_++];
312 input->binding = input->location = block_binding(program, i);
313
314 name_buffer_offset += this->set_input_name(input, name, name_len);
315 enabled_ubo_mask_ |= (1 << input->binding);
316 }
317
318 /* Uniforms & samplers & images */
319 for (int i = 0, sampler = 0, image = 0; i < active_uniform_len; i++) {
320 if (BLI_BITMAP_TEST(uniforms_from_blocks, i)) {
321 continue;
322 }
323 char *name = name_buffer_ + name_buffer_offset;
324 GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
325 GLsizei name_len = 0;
326
327 glGetActiveUniformName(program, i, remaining_buffer, &name_len, name);
328
330 input->location = glGetUniformLocation(program, name);
331 input->binding = sampler_binding(program, i, input->location, &sampler);
332
333 name_buffer_offset += this->set_input_name(input, name, name_len);
334 enabled_tex_mask_ |= (input->binding != -1) ? (1lu << input->binding) : 0lu;
335
336 if (input->binding == -1) {
337 input->binding = image_binding(program, i, input->location, &image);
338
339 enabled_ima_mask_ |= (input->binding != -1) ? (1lu << input->binding) : 0lu;
340 }
341 }
342
343 /* SSBOs */
344 for (int i = 0; i < ssbo_len; i++) {
345 char *name = name_buffer_ + name_buffer_offset;
346 GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
347 GLsizei name_len = 0;
348 glGetProgramResourceName(
349 program, GL_SHADER_STORAGE_BLOCK, i, remaining_buffer, &name_len, name);
350
351 const GLint binding = ssbo_binding(program, i);
352
354 input->binding = input->location = binding;
355
356 name_buffer_offset += this->set_input_name(input, name, name_len);
357 enabled_ssbo_mask_ |= (input->binding != -1) ? (1lu << input->binding) : 0lu;
358 }
359
360 /* Builtin Uniforms */
361 for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORMS; u_int++) {
362 GPUUniformBuiltin u = static_cast<GPUUniformBuiltin>(u_int);
363 builtins_[u] = glGetUniformLocation(program, builtin_uniform_name(u));
364 }
365
366 /* Builtin Uniforms Blocks */
367 for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORM_BLOCKS; u_int++) {
368 GPUUniformBlockBuiltin u = static_cast<GPUUniformBlockBuiltin>(u_int);
369 const ShaderInput *block = this->ubo_get(builtin_uniform_block_name(u));
370 builtin_blocks_[u] = (block != nullptr) ? block->binding : -1;
371 }
372
373 MEM_freeN(uniforms_from_blocks);
374
375 /* Resize name buffer to save some memory. */
376 if (name_buffer_offset < name_buffer_len) {
377 name_buffer_ = (char *)MEM_reallocN(name_buffer_, name_buffer_offset);
378 }
379
380 // this->debug_print();
381
382 this->sort_inputs();
383
384 glUseProgram(last_program);
385}
386
388{
389 using namespace blender::gpu::shader;
390
391 attr_len_ = info.vertex_inputs_.size();
392 uniform_len_ = info.push_constants_.size();
394 ubo_len_ = 0;
395 ssbo_len_ = 0;
396
398
399 for (ShaderCreateInfo::Resource &res : all_resources) {
400 switch (res.bind_type) {
401 case ShaderCreateInfo::Resource::BindType::UNIFORM_BUFFER:
402 ubo_len_++;
403 break;
404 case ShaderCreateInfo::Resource::BindType::STORAGE_BUFFER:
405 ssbo_len_++;
406 break;
407 case ShaderCreateInfo::Resource::BindType::SAMPLER:
408 uniform_len_++;
409 break;
410 case ShaderCreateInfo::Resource::BindType::IMAGE:
411 uniform_len_++;
412 break;
413 }
414 }
415
416 size_t workaround_names_size = 0;
417 Vector<StringRefNull> workaround_uniform_names;
418 auto check_enabled_uniform = [&](const char *uniform_name) {
419 if (glGetUniformLocation(program, uniform_name) != -1) {
420 workaround_uniform_names.append(uniform_name);
421 workaround_names_size += StringRefNull(uniform_name).size() + 1;
422 uniform_len_++;
423 }
424 };
425
427 check_enabled_uniform("gpu_BaseInstance");
428 }
429
430 BLI_assert_msg(ubo_len_ <= 16, "enabled_ubo_mask_ is uint16_t");
431
432 int input_tot_len = attr_len_ + ubo_len_ + uniform_len_ + ssbo_len_ + constant_len_;
433 inputs_ = (ShaderInput *)MEM_callocN(sizeof(ShaderInput) * input_tot_len, __func__);
434 ShaderInput *input = inputs_;
435
436 name_buffer_ = (char *)MEM_mallocN(info.interface_names_size_ + workaround_names_size,
437 "name_buffer");
438 uint32_t name_buffer_offset = 0;
439
440 /* Necessary to make #glUniform works. TODO(fclem) Remove. */
441 GLuint last_program;
442 glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *)&last_program);
443
444 glUseProgram(program);
445
446 /* Attributes */
447 for (const ShaderCreateInfo::VertIn &attr : info.vertex_inputs_) {
448 copy_input_name(input, attr.name, name_buffer_, name_buffer_offset);
450 input->location = input->binding = glGetAttribLocation(program, attr.name.c_str());
451 }
452 else {
453 input->location = input->binding = attr.index;
454 }
455 if (input->location != -1) {
456 enabled_attr_mask_ |= (1 << input->location);
457
458 /* Used in `GPU_shader_get_attribute_info`. */
459 attr_types_[input->location] = uint8_t(attr.type);
460 }
461
462 input++;
463 }
464
465 /* Uniform Blocks */
466 for (const ShaderCreateInfo::Resource &res : all_resources) {
467 if (res.bind_type == ShaderCreateInfo::Resource::BindType::UNIFORM_BUFFER) {
468 copy_input_name(input, res.uniformbuf.name, name_buffer_, name_buffer_offset);
470 input->location = glGetUniformBlockIndex(program, name_buffer_ + input->name_offset);
471 glUniformBlockBinding(program, input->location, res.slot);
472 }
473 input->binding = res.slot;
474 enabled_ubo_mask_ |= (1 << input->binding);
475 input++;
476 }
477 }
478
479 /* Uniforms & samplers & images */
480 for (const ShaderCreateInfo::Resource &res : all_resources) {
481 if (res.bind_type == ShaderCreateInfo::Resource::BindType::SAMPLER) {
482 copy_input_name(input, res.sampler.name, name_buffer_, name_buffer_offset);
483 /* Until we make use of explicit uniform location or eliminate all
484 * sampler manually changing. */
486 input->location = glGetUniformLocation(program, res.sampler.name.c_str());
487 glUniform1i(input->location, res.slot);
488 }
489 input->binding = res.slot;
490 enabled_tex_mask_ |= (1ull << input->binding);
491 input++;
492 }
493 else if (res.bind_type == ShaderCreateInfo::Resource::BindType::IMAGE) {
494 copy_input_name(input, res.image.name, name_buffer_, name_buffer_offset);
495 /* Until we make use of explicit uniform location. */
497 input->location = glGetUniformLocation(program, res.image.name.c_str());
498 glUniform1i(input->location, res.slot);
499 }
500 input->binding = res.slot;
501 enabled_ima_mask_ |= (1 << input->binding);
502 input++;
503 }
504 }
505 for (const ShaderCreateInfo::PushConst &uni : info.push_constants_) {
506 copy_input_name(input, uni.name, name_buffer_, name_buffer_offset);
507 input->location = glGetUniformLocation(program, name_buffer_ + input->name_offset);
508 input->binding = -1;
509 input++;
510 }
511
512 /* Compatibility uniforms. */
513 for (auto &name : workaround_uniform_names) {
514 copy_input_name(input, name, name_buffer_, name_buffer_offset);
515 input->location = glGetUniformLocation(program, name_buffer_ + input->name_offset);
516 input->binding = -1;
517 input++;
518 }
519
520 /* SSBOs */
521 for (const ShaderCreateInfo::Resource &res : all_resources) {
522 if (res.bind_type == ShaderCreateInfo::Resource::BindType::STORAGE_BUFFER) {
523 copy_input_name(input, res.storagebuf.name, name_buffer_, name_buffer_offset);
524 input->location = input->binding = res.slot;
525 enabled_ssbo_mask_ |= (1 << input->binding);
526 input++;
527 }
528 }
529
530 for (const ShaderCreateInfo::Resource &res : info.geometry_resources_) {
531 if (res.bind_type == ShaderCreateInfo::Resource::BindType::STORAGE_BUFFER) {
532 ssbo_attr_mask_ |= (1 << res.slot);
533 }
534 else {
535 BLI_assert_msg(0, "Resource type is not supported for Geometry frequency");
536 }
537 }
538
539 /* Constants */
540 int constant_id = 0;
541 for (const SpecializationConstant &constant : info.specialization_constants_) {
542 copy_input_name(input, constant.name, name_buffer_, name_buffer_offset);
543 input->location = constant_id++;
544 input++;
545 }
546
547 this->sort_inputs();
548
549 /* Resolving builtins must happen after the inputs have been sorted. */
550 /* Builtin Uniforms */
551 for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORMS; u_int++) {
552 GPUUniformBuiltin u = static_cast<GPUUniformBuiltin>(u_int);
553 const ShaderInput *uni = this->uniform_get(builtin_uniform_name(u));
554 builtins_[u] = (uni != nullptr) ? uni->location : -1;
555 }
556
557 /* Builtin Uniforms Blocks */
558 for (int32_t u_int = 0; u_int < GPU_NUM_UNIFORM_BLOCKS; u_int++) {
559 GPUUniformBlockBuiltin u = static_cast<GPUUniformBlockBuiltin>(u_int);
560 const ShaderInput *block = this->ubo_get(builtin_uniform_block_name(u));
561 builtin_blocks_[u] = (block != nullptr) ? block->binding : -1;
562 }
563
564 // this->debug_print();
565
566 glUseProgram(last_program);
567}
568
570{
571 for (auto *ref : refs_) {
572 if (ref != nullptr) {
573 ref->remove(this);
574 }
575 }
576}
577
580/* -------------------------------------------------------------------- */
585{
586 for (int i = 0; i < refs_.size(); i++) {
587 if (refs_[i] == nullptr) {
588 refs_[i] = ref;
589 return;
590 }
591 }
592 refs_.append(ref);
593}
594
596{
597 for (int i = 0; i < refs_.size(); i++) {
598 if (refs_[i] == ref) {
599 refs_[i] = nullptr;
600 break; /* cannot have duplicates */
601 }
602 }
603}
604
607/* -------------------------------------------------------------------- */
614} // namespace blender::gpu
#define BLI_assert(a)
Definition BLI_assert.h:50
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57
#define BLI_BITMAP_NEW(_num, _alloc_string)
Definition BLI_bitmap.h:41
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition BLI_bitmap.h:65
#define BLI_BITMAP_ENABLE(_bitmap, _index)
Definition BLI_bitmap.h:82
unsigned int BLI_bitmap
Definition BLI_bitmap.h:17
MINLINE int max_ii(int a, int b)
#define GPU_NUM_UNIFORMS
GPUUniformBuiltin
GPUUniformBlockBuiltin
@ GPU_NUM_UNIFORM_BLOCKS
#define MEM_reallocN(vmemh, len)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
constexpr int64_t size() const
void append(const T &value)
static bool shader_draw_parameters_support
Definition gl_context.hh:60
static bool explicit_location_support
Definition gl_context.hh:53
GLShaderInterface(GLuint program, const shader::ShaderCreateInfo &info)
void copy_input_name(ShaderInput *input, const StringRefNull &name, char *name_buffer, uint32_t &name_buffer_offset) const
const ShaderInput * ubo_get(const char *name) const
uint32_t set_input_name(ShaderInput *input, char *name, uint32_t name_len) const
static const char * builtin_uniform_block_name(GPUUniformBlockBuiltin u)
int32_t builtin_blocks_[GPU_NUM_UNIFORM_BLOCKS]
int32_t builtins_[GPU_NUM_UNIFORMS]
const ShaderInput * uniform_get(const char *name) const
uint8_t attr_types_[GPU_VERT_ATTR_MAX_LEN]
static const char * builtin_uniform_name(GPUUniformBuiltin u)
local_group_size(16, 16) .push_constant(Type local_group_size(16, 16) .push_constant(Type input_tx sampler(1, ImageType::FLOAT_2D, "matte_tx") .image(0
void *(* MEM_mallocN)(size_t len, const char *str)
Definition mallocn.cc:44
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
static Type gpu_type_from_gl_type(int gl_type)
static int block_binding(int32_t program, uint32_t block_index)
static int sampler_binding(int32_t program, uint32_t uniform_index, int32_t uniform_location, int *sampler_len)
static int ssbo_binding(int32_t program, uint32_t ssbo_index)
static int image_binding(int32_t program, uint32_t uniform_index, int32_t uniform_location, int *image_len)
unsigned int uint32_t
Definition stdint.h:80
signed int int32_t
Definition stdint.h:77
unsigned char uint8_t
Definition stdint.h:78
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
Vector< SpecializationConstant > specialization_constants_