Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/opengl/gl_vertex_array.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2016 by Mike Erwin. All rights reserved. */ | * Copyright 2016 by Mike Erwin. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup gpu | * \ingroup gpu | ||||
| */ | */ | ||||
| #include "gpu_shader_interface.hh" | #include "gpu_shader_interface.hh" | ||||
| #include "gpu_vertex_buffer_private.hh" | #include "gpu_vertex_buffer_private.hh" | ||||
| #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_storage_buffer.hh" | |||||
| #include "gl_vertex_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 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | void GLVertArray::update_bindings(const GLuint vao, | ||||
| 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--) { | ||||
| GLVertBuf *vbo = batch->inst_(v); | GLVertBuf *vbo = batch->inst_(v); | ||||
| if (vbo) { | if (vbo) { | ||||
| vbo->bind(); | 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 (batch->resource_id_buf) { | |||||
| const ShaderInput *input = interface->attr_get("drw_ResourceID"); | |||||
| if (input) { | |||||
| dynamic_cast<GLStorageBuf *>(unwrap(batch->resource_id_buf))->bind_as(GL_ARRAY_BUFFER); | |||||
| glEnableVertexAttribArray(input->location); | |||||
| glVertexAttribDivisor(input->location, 1); | |||||
| glVertexAttribIPointer( | |||||
| input->location, 1, to_gl(GPU_COMP_I32), sizeof(uint32_t), (GLvoid *)nullptr); | |||||
| attr_mask &= ~(1 << input->location); | |||||
| } | |||||
| } | |||||
| if (attr_mask != 0 && GLContext::vertex_attrib_binding_support) { | if (attr_mask != 0 && GLContext::vertex_attrib_binding_support) { | ||||
| 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 = GLContext::get(); | GLContext *ctx = GLContext::get(); | ||||
| /* This replaces glVertexAttrib4f(a, 0.0f, 0.0f, 0.0f, 1.0f); with a more modern style. | /* This replaces glVertexAttrib4f(a, 0.0f, 0.0f, 0.0f, 1.0f); with a more modern style. | ||||
| * Fix issues for some drivers (see T75069). */ | * Fix issues for some drivers (see T75069). */ | ||||
| glBindVertexBuffer(a, ctx->default_attr_vbo_, (intptr_t)0, (intptr_t)0); | glBindVertexBuffer(a, ctx->default_attr_vbo_, (intptr_t)0, (intptr_t)0); | ||||
| glEnableVertexAttribArray(a); | glEnableVertexAttribArray(a); | ||||
| Show All 25 Lines | |||||