45 glUniformBlockBinding(
program, block_index, block_index);
56 glGetActiveUniformsiv(
program, 1, &uniform_index, GL_UNIFORM_TYPE, &
type);
63 case GL_SAMPLER_CUBE_MAP_ARRAY_ARB:
64 case GL_SAMPLER_1D_SHADOW:
65 case GL_SAMPLER_2D_SHADOW:
66 case GL_SAMPLER_1D_ARRAY:
67 case GL_SAMPLER_2D_ARRAY:
68 case GL_SAMPLER_1D_ARRAY_SHADOW:
69 case GL_SAMPLER_2D_ARRAY_SHADOW:
70 case GL_SAMPLER_2D_MULTISAMPLE:
71 case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
72 case GL_SAMPLER_CUBE_SHADOW:
73 case GL_SAMPLER_BUFFER:
74 case GL_INT_SAMPLER_1D:
75 case GL_INT_SAMPLER_2D:
76 case GL_INT_SAMPLER_3D:
77 case GL_INT_SAMPLER_CUBE:
78 case GL_INT_SAMPLER_1D_ARRAY:
79 case GL_INT_SAMPLER_2D_ARRAY:
80 case GL_INT_SAMPLER_2D_MULTISAMPLE:
81 case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
82 case GL_INT_SAMPLER_BUFFER:
83 case GL_UNSIGNED_INT_SAMPLER_1D:
84 case GL_UNSIGNED_INT_SAMPLER_2D:
85 case GL_UNSIGNED_INT_SAMPLER_3D:
86 case GL_UNSIGNED_INT_SAMPLER_CUBE:
87 case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
88 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
89 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
90 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
91 case GL_UNSIGNED_INT_SAMPLER_BUFFER: {
94 int binding = *sampler_len;
95 glUniform1i(uniform_location, binding);
111 glGetActiveUniformsiv(
program, 1, &uniform_index, GL_UNIFORM_TYPE, &
type);
119 int binding = *image_len;
120 glUniform1i(uniform_location, binding);
139 GLint max_attr_name_len = 0, attr_len = 0;
140 glGetProgramiv(
program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attr_name_len);
141 glGetProgramiv(
program, GL_ACTIVE_ATTRIBUTES, &attr_len);
143 GLint max_ubo_name_len = 0, ubo_len = 0;
144 glGetProgramiv(
program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len);
145 glGetProgramiv(
program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_len);
147 GLint max_uniform_name_len = 0, active_uniform_len = 0, uniform_len = 0;
148 glGetProgramiv(
program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_uniform_name_len);
149 glGetProgramiv(
program, GL_ACTIVE_UNIFORMS, &active_uniform_len);
150 uniform_len = active_uniform_len;
152 BLI_assert(ubo_len <= 16 &&
"enabled_ubo_mask_ is uint16_t");
156 if (attr_len > 0 && max_attr_name_len == 0) {
157 max_attr_name_len = 256;
159 if (ubo_len > 0 && max_ubo_name_len == 0) {
160 max_ubo_name_len = 256;
162 if (uniform_len > 0 && max_uniform_name_len == 0) {
163 max_uniform_name_len = 256;
168 GLint max_ubo_uni_len = 0;
169 for (
int i = 0; i < ubo_len; i++) {
171 glGetActiveUniformBlockiv(
program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &ubo_uni_len);
172 max_ubo_uni_len =
max_ii(max_ubo_uni_len, ubo_uni_len);
173 uniform_len -= ubo_uni_len;
178 GLint *ubo_uni_ids = (GLint *)
MEM_mallocN(
sizeof(GLint) * max_ubo_uni_len, __func__);
179 for (
int i = 0; i < ubo_len; i++) {
181 glGetActiveUniformBlockiv(
program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &ubo_uni_len);
182 glGetActiveUniformBlockiv(
program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, ubo_uni_ids);
183 for (
int u = 0; u < ubo_uni_len; u++) {
189 int input_tot_len = attr_len + ubo_len + uniform_len;
192 const uint32_t name_buffer_len = attr_len * max_attr_name_len + ubo_len * max_ubo_name_len +
193 uniform_len * max_uniform_name_len;
199 for (
int i = 0; i < attr_len; i++) {
201 GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
202 GLsizei name_len = 0;
206 glGetActiveAttrib(
program, i, remaining_buffer, &name_len, &
size, &
type, name);
207 GLint location = glGetAttribLocation(
program, name);
209 if (location == -1) {
221 for (
int i = 0; i < ubo_len; i++) {
223 GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
224 GLsizei name_len = 0;
226 glGetActiveUniformBlockName(
program, i, remaining_buffer, &name_len, name);
231 name_buffer_offset += this->
set_input_name(input, name, name_len);
236 for (
int i = 0, sampler = 0, image = 0; i < active_uniform_len; i++) {
241 GLsizei remaining_buffer = name_buffer_len - name_buffer_offset;
242 GLsizei name_len = 0;
244 glGetActiveUniformName(
program, i, remaining_buffer, &name_len, name);
250 name_buffer_offset += this->
set_input_name(input, name, name_len);
276 if (name_buffer_offset < name_buffer_len) {
287 for (
auto *ref : refs_) {
288 if (ref !=
nullptr) {
302 for (
int i = 0; i < refs_.size(); i++) {
303 if (refs_[i] ==
NULL) {
313 for (
int i = 0; i < refs_.size(); i++) {
314 if (refs_[i] == ref) {
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_NEW(_tot, _alloc_string)
MINLINE int max_ii(int a, int b)
_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
#define MEM_reallocN(vmemh, len)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
GLShaderInterface(GLuint program)
void ref_add(GLVaoCache *ref)
void ref_remove(GLVaoCache *ref)
const ShaderInput * ubo_get(const char *name) const
uint64_t enabled_tex_mask_
uint32_t set_input_name(ShaderInput *input, char *name, uint32_t name_len) const
static const char * builtin_uniform_block_name(GPUUniformBlockBuiltin u)
uint8_t enabled_ima_mask_
int32_t builtin_blocks_[GPU_NUM_UNIFORM_BLOCKS]
int32_t builtins_[GPU_NUM_UNIFORMS]
uint16_t enabled_attr_mask_
uint16_t enabled_ubo_mask_
static const char * builtin_uniform_name(GPUUniformBuiltin u)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
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 image_binding(int32_t program, uint32_t uniform_index, int32_t uniform_location, int *image_len)