[Bf-blender-cvs] [8e35657] master: OpenGL: fewer state changes for wireframe PBVH
Mike Erwin
noreply at git.blender.org
Fri Jan 22 03:08:01 CET 2016
Commit: 8e35657beb595e0b5f1ac2a594ab36bb306cbf6e
Author: Mike Erwin
Date: Thu Jan 21 21:07:17 2016 -0500
Branches: master
https://developer.blender.org/rB8e35657beb595e0b5f1ac2a594ab36bb306cbf6e
OpenGL: fewer state changes for wireframe PBVH
Wireframe drawing doesn’t use the following GL state, so don’t update
these:
- ShadeModel
- NormalPointer
- ColorPointer
Normal & color data are still uploaded as part of the interleaved VBO,
but those attributes are disabled for wireframe.
===================================================================
M source/blender/gpu/intern/gpu_buffers.c
===================================================================
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 45a2632..072ff52 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -1832,8 +1832,6 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
}
}
- glShadeModel((buffers->smooth || buffers->face_indices_len) ? GL_SMOOTH : GL_FLAT);
-
if (buffers->vert_buf) {
char *base = NULL;
char *index_base = NULL;
@@ -1859,6 +1857,8 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
if (wireframe)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ else
+ glShadeModel((buffers->smooth || buffers->face_indices_len) ? GL_SMOOTH : GL_FLAT);
if (buffers->tot_quad) {
const char *offset = base;
@@ -1868,10 +1868,12 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat),
offset + offsetof(VertexBufferFormat, co));
- glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
- offset + offsetof(VertexBufferFormat, no));
- glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
- offset + offsetof(VertexBufferFormat, color));
+ if (!wireframe) {
+ glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
+ offset + offsetof(VertexBufferFormat, no));
+ glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
+ offset + offsetof(VertexBufferFormat, color));
+ }
glMultiDrawElementsBaseVertex(GL_TRIANGLES, buffers->baseelemarray, buffers->index_type,
(const void * const *)buffers->baseindex,
@@ -1884,10 +1886,12 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
for (i = 0; i < last; i++) {
glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat),
offset + offsetof(VertexBufferFormat, co));
- glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
- offset + offsetof(VertexBufferFormat, no));
- glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
- offset + offsetof(VertexBufferFormat, color));
+ if (!wireframe) {
+ glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
+ offset + offsetof(VertexBufferFormat, no));
+ glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
+ offset + offsetof(VertexBufferFormat, color));
+ }
if (do_fast)
glDrawElements(GL_TRIANGLES, buffers->totgrid * 6, buffers->index_type, index_base);
@@ -1903,10 +1907,13 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat),
(void *)(base + offsetof(VertexBufferFormat, co)));
- glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
- (void *)(base + offsetof(VertexBufferFormat, no)));
- glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
- (void *)(base + offsetof(VertexBufferFormat, color)));
+
+ if (!wireframe) {
+ glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat),
+ (void *)(base + offsetof(VertexBufferFormat, no)));
+ glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat),
+ (void *)(base + offsetof(VertexBufferFormat, color)));
+ }
if (buffers->index_buf)
glDrawElements(GL_TRIANGLES, totelem, buffers->index_type, index_base);
More information about the Bf-blender-cvs
mailing list