[Bf-blender-cvs] [27fe135] GPU_data_request: reduce VRAM usage for loop normals

Mike Erwin noreply at git.blender.org
Wed Apr 22 08:14:08 CEST 2015


Commit: 27fe1353add75c3073d74b8c73b1fd3a5bbf86de
Author: Mike Erwin
Date:   Wed Apr 22 02:13:42 2015 -0400
Branches: GPU_data_request
https://developer.blender.org/rB27fe1353add75c3073d74b8c73b1fd3a5bbf86de

reduce VRAM usage for loop normals

Use GL_SHORT instead of GL_FLOAT for normal attribute. Savings scale
proportional to loop count.

stock Suzanne mesh
507 verts, 1005 edges, 500 polys, 500 faces, 1968 loops

mode = NORMAL_DRAW_LOOP

vec3f normals
GPUx batch size: 53040 bytes

vec3s normals (+padding)
GPUx batch size: 45166 bytes

vec3s normals (no padding)
GPUx batch size: 41232 bytes

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

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 d685ecc..1551144 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -5007,10 +5007,13 @@ static bool draw_mesh_object_new_new(Scene *scene, ARegion *ar, View3D *v3d, Reg
 #endif
 						verts = GPUx_vertex_buffer_create(2, new_vert_ct);
 						GPUx_specify_attrib(verts, 0, GL_VERTEX_ARRAY, GL_FLOAT, 3, KEEP_FLOAT);
-						GPUx_specify_attrib(verts, 1, GL_NORMAL_ARRAY, GL_FLOAT, 3, KEEP_FLOAT);
-						for (v = 0; v < loop_ct; ++v)
+						GPUx_specify_attrib(verts, 1, GL_NORMAL_ARRAY, GL_SHORT, 3, NORMALIZE_INT_TO_FLOAT);
+						for (v = 0; v < loop_ct; ++v) {
+							short normal[3];
+							normal_float_to_short_v3(normal, lnor[v]);
 							GPUx_set_attrib(verts, 0, v, &mverts[loops[v].v].co);
-						GPUx_fill_attrib(verts, 1, lnor);
+							GPUx_set_attrib(verts, 1, v, normal);
+						}
 
 						elem = GPUx_element_list_create(GL_TRIANGLES, tri_ct, new_vert_ct - 1);




More information about the Bf-blender-cvs mailing list