[Bf-blender-cvs] [4b88dbb] GPU_data_request: remove short int -> float conversion for vertex normals

Mike Erwin noreply at git.blender.org
Fri Apr 17 07:16:58 CEST 2015


Commit: 4b88dbb06ec201fa62455ca6e047556cb0dd9470
Author: Mike Erwin
Date:   Thu Apr 16 23:23:46 2015 -0400
Branches: GPU_data_request
https://developer.blender.org/rB4b88dbb06ec201fa62455ca6e047556cb0dd9470

remove short int -> float conversion for vertex normals

Performance experiment — thought this might be slowing down large
shaded meshes on Mac + nVidia but it was not. Index buffers in VRAM
fixed the perf issue :)

Keeping normals as GL_SHORT uses less memory. Would be 1/2 but
padding/alignment makes it 2/3. These stay GL_SHORT in VRAM also, and
are converted to floats when loaded by the vertex shader.

===================================================================

M	source/blender/editors/space_view3d/drawobject.c

===================================================================

diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 97ee52e..60c097b 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -4483,21 +4483,10 @@ static bool draw_mesh_object_new_new(Scene *scene, ARegion *ar, View3D *v3d, Reg
 				MFace *faces = dm->getTessFaceArray(dm);
 				dm->gpux_batch->state.common.lighting = true;
 				dm->gpux_batch->state.polygon.draw_back = false;
-#if 1
+
 				GPUx_specify_attrib(verts, 1, GL_NORMAL_ARRAY, GL_SHORT, 3, NORMALIZE_INT_TO_FLOAT);
 				GPUx_fill_attrib_stride(verts, 1, &mverts[0].no, sizeof(MVert));
-#else
-				/* float normals (NOT our performance culprit) */
-				GPUx_specify_attrib(verts, 1, GL_NORMAL_ARRAY, GL_FLOAT, 3, KEEP_FLOAT);
-				for (i = 0; i < vert_ct; ++i) {
-					const float scale = 1.0f / 32768.0f;
-					GPUx_set_attrib_3f(verts, 1, i,
-						scale * mverts[i].no[0],
-						scale * mverts[i].no[1],
-						scale * mverts[i].no[2]
-						);
-				}
-#endif
+
 				/* some tess faces are quads, some triangles
 				 * we draw just triangles, so count quads twice */
 				for (i = 0; i < face_ct; ++i)




More information about the Bf-blender-cvs mailing list