31 const bool use_instancing)
37 GLuint divisor = (use_instancing) ? 1 : 0;
39 for (
uint a_idx = 0; a_idx < attr_len; a_idx++) {
42 if (
format->deinterleaved) {
43 offset += ((a_idx == 0) ? 0 :
format->attrs[a_idx - 1].size) * v_len;
51 const GLvoid *pointer = (
const GLubyte *)
intptr_t(offset + v_first * stride);
54 for (
uint n_idx = 0; n_idx < a->name_len; n_idx++) {
58 if (input ==
nullptr || input->location == -1) {
62 enabled_attrib |= (1 << input->location);
64 if (
ELEM(a->comp_len, 16, 12, 8)) {
67 for (
int i = 0; i < a->comp_len / 4; i++) {
68 glEnableVertexAttribArray(input->location + i);
69 glVertexAttribDivisor(input->location + i, divisor);
70 glVertexAttribPointer(
71 input->location + i, 4, type, GL_FALSE, stride, (
const GLubyte *)pointer + i * 16);
75 glEnableVertexAttribArray(input->location);
76 glVertexAttribDivisor(input->location, divisor);
78 switch (a->fetch_mode) {
81 glVertexAttribPointer(input->location, a->comp_len, type, GL_FALSE, stride, pointer);
84 glVertexAttribPointer(input->location, a->comp_len, type, GL_TRUE, stride, pointer);
87 glVertexAttribIPointer(input->location, a->comp_len, type, stride, pointer);
93 return enabled_attrib;
99 const int base_instance)
104 glBindVertexArray(vao);
119 attr_mask &= ~vbo_bind(interface, &vbo->
format, base_instance, vbo->
vertex_len,
true);
123 if (
batch->resource_id_buf) {
125 int component_len = 1;
126 if (input ==
nullptr) {
128 input = interface->
attr_get(
"vertex_in_drw_ResourceID");
133 glEnableVertexAttribArray(input->location);
134 glVertexAttribDivisor(input->location, 1);
135 glVertexAttribIPointer(
137 attr_mask &= ~(1 << input->location);
141 if (attr_mask != 0) {
142 for (
uint16_t mask = 1, a = 0; a < 16; a++, mask <<= 1) {
143 if (attr_mask & mask) {
148 glEnableVertexAttribArray(a);
149 glVertexAttribFormat(a, 4, GL_FLOAT, GL_FALSE, 0);
150 glVertexAttribBinding(a, a);