Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/opengl/gl_vertex_array.cc
| Show All 22 Lines | |||||
| #include "gpu_shader_interface.hh" | #include "gpu_shader_interface.hh" | ||||
| #include "gpu_vertex_buffer_private.hh" | #include "gpu_vertex_buffer_private.hh" | ||||
| #include "gpu_vertex_format_private.h" | #include "gpu_vertex_format_private.h" | ||||
| #include "gl_batch.hh" | #include "gl_batch.hh" | ||||
| #include "gl_context.hh" | #include "gl_context.hh" | ||||
| #include "gl_index_buffer.hh" | #include "gl_index_buffer.hh" | ||||
| #include "gl_vertex_buffer.hh" | |||||
| #include "gl_vertex_array.hh" | #include "gl_vertex_array.hh" | ||||
| namespace blender::gpu { | namespace blender::gpu { | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Vertex Array Bindings | /** \name Vertex Array Bindings | ||||
| * \{ */ | * \{ */ | ||||
| Show All 18 Lines | if (format->deinterleaved) { | ||||
| offset += ((a_idx == 0) ? 0 : format->attrs[a_idx - 1].sz) * v_len; | offset += ((a_idx == 0) ? 0 : format->attrs[a_idx - 1].sz) * v_len; | ||||
| stride = a->sz; | stride = a->sz; | ||||
| } | } | ||||
| else { | else { | ||||
| offset = a->offset; | offset = a->offset; | ||||
| } | } | ||||
| const GLvoid *pointer = (const GLubyte *)0 + offset + v_first * stride; | const GLvoid *pointer = (const GLubyte *)0 + offset + v_first * stride; | ||||
| const GLenum type = convert_comp_type_to_gl(static_cast<GPUVertCompType>(a->comp_type)); | const GLenum type = to_gl(static_cast<GPUVertCompType>(a->comp_type)); | ||||
| for (uint n_idx = 0; n_idx < a->name_len; n_idx++) { | for (uint n_idx = 0; n_idx < a->name_len; n_idx++) { | ||||
| const char *name = GPU_vertformat_attr_name_get(format, a, n_idx); | const char *name = GPU_vertformat_attr_name_get(format, a, n_idx); | ||||
| const ShaderInput *input = interface->attr_get(name); | const ShaderInput *input = interface->attr_get(name); | ||||
| if (input == NULL) { | if (input == NULL) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| Show All 29 Lines | for (uint n_idx = 0; n_idx < a->name_len; n_idx++) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return enabled_attrib; | return enabled_attrib; | ||||
| } | } | ||||
| /* Update the Attrib Binding of the currently bound VAO. */ | /* Update the Attrib Binding of the currently bound VAO. */ | ||||
| void GLVertArray::update_bindings(const GLuint vao, | void GLVertArray::update_bindings(const GLuint vao, | ||||
| const GPUBatch *batch, | const GPUBatch *batch_, /* Should be GLBatch. */ | ||||
| const ShaderInterface *interface, | const ShaderInterface *interface, | ||||
| const int base_instance) | const int base_instance) | ||||
| { | { | ||||
| const GLBatch *batch = static_cast<const GLBatch *>(batch_); | |||||
| uint16_t attr_mask = interface->enabled_attr_mask_; | uint16_t attr_mask = interface->enabled_attr_mask_; | ||||
| glBindVertexArray(vao); | glBindVertexArray(vao); | ||||
| /* Reverse order so first VBO'S have more prevalence (in term of attribute override). */ | /* Reverse order so first VBO'S have more prevalence (in term of attribute override). */ | ||||
| for (int v = GPU_BATCH_VBO_MAX_LEN - 1; v > -1; v--) { | for (int v = GPU_BATCH_VBO_MAX_LEN - 1; v > -1; v--) { | ||||
| GPUVertBuf *vbo = batch->verts[v]; | GLVertBuf *vbo = batch->verts_(v); | ||||
| if (vbo) { | if (vbo) { | ||||
| GPU_vertbuf_use(vbo); | vbo->bind(); | ||||
| attr_mask &= ~vbo_bind(interface, &vbo->format, 0, vbo->vertex_len, false); | attr_mask &= ~vbo_bind(interface, &vbo->format, 0, vbo->vertex_len, false); | ||||
| } | } | ||||
| } | } | ||||
| for (int v = GPU_BATCH_INST_VBO_MAX_LEN - 1; v > -1; v--) { | for (int v = GPU_BATCH_INST_VBO_MAX_LEN - 1; v > -1; v--) { | ||||
| GPUVertBuf *vbo = batch->inst[v]; | GLVertBuf *vbo = batch->inst_(v); | ||||
| if (vbo) { | if (vbo) { | ||||
| GPU_vertbuf_use(vbo); | vbo->bind(); | ||||
| attr_mask &= ~vbo_bind(interface, &vbo->format, base_instance, vbo->vertex_len, true); | attr_mask &= ~vbo_bind(interface, &vbo->format, base_instance, vbo->vertex_len, true); | ||||
| } | } | ||||
| } | } | ||||
| if (attr_mask != 0 && GLEW_ARB_vertex_attrib_binding) { | if (attr_mask != 0 && GLEW_ARB_vertex_attrib_binding) { | ||||
| for (uint16_t mask = 1, a = 0; a < 16; a++, mask <<= 1) { | for (uint16_t mask = 1, a = 0; a < 16; a++, mask <<= 1) { | ||||
| if (attr_mask & mask) { | if (attr_mask & mask) { | ||||
| GLContext *ctx = static_cast<GLContext *>(GPU_context_active_get()); | GLContext *ctx = static_cast<GLContext *>(GPU_context_active_get()); | ||||
| Show All 22 Lines | void GLVertArray::update_bindings(const GLuint vao, | ||||
| glBindVertexArray(vao); | glBindVertexArray(vao); | ||||
| vbo_bind(interface, format, v_first, 0, false); | vbo_bind(interface, format, v_first, 0, false); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| } // namespace blender::gpu | } // namespace blender::gpu | ||||
| No newline at end of file | No newline at end of file | ||||