[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58811] branches/soc-2013-viewport_fx/ source/blender: In progress applying GPU_simple_shader to implemented shading on ES/COre

Jason Wilkins Jason.A.Wilkins at gmail.com
Fri Aug 2 00:18:02 CEST 2013


Revision: 58811
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58811
Author:   jwilkins
Date:     2013-08-01 22:18:01 +0000 (Thu, 01 Aug 2013)
Log Message:
-----------
In progress applying GPU_simple_shader to implemented shading on ES/COre

Broken build because I ran out of steam while replacing calls to glShadeModel.
Will resume after I get some sleep :-)

Modified Paths:
--------------
    branches/soc-2013-viewport_fx/source/blender/blenfont/intern/blf.c
    branches/soc-2013-viewport_fx/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/editderivedmesh.c
    branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/subsurf_ccg.c
    branches/soc-2013-viewport_fx/source/blender/blenlib/BLI_math_matrix.h
    branches/soc-2013-viewport_fx/source/blender/blenlib/intern/math_matrix.c
    branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_icons.c
    branches/soc-2013-viewport_fx/source/blender/editors/interface/interface_widgets.c
    branches/soc-2013-viewport_fx/source/blender/editors/space_sequencer/sequencer_draw.c
    branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/drawarmature.c
    branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/drawmesh.c
    branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2013-viewport_fx/source/blender/editors/space_view3d/view3d_view.c
    branches/soc-2013-viewport_fx/source/blender/gpu/CMakeLists.txt
    branches/soc-2013-viewport_fx/source/blender/gpu/GPU_compatibility.h
    branches/soc-2013-viewport_fx/source/blender/gpu/GPU_extensions.h
    branches/soc-2013-viewport_fx/source/blender/gpu/GPU_matrix.h
    branches/soc-2013-viewport_fx/source/blender/gpu/GPU_object.h
    branches/soc-2013-viewport_fx/source/blender/gpu/GPU_simple_shader.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspect.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspectfuncs.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_aspectfuncs.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_buffers.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_codegen.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_draw.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extension_wrapper.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extensions.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_gl11.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_glsl.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_lighting.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_lighting.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_lighting_inline.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_matrix.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_object.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_object_gl11.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_object_gles.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_object_gles.h
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_safety.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_simple_shader.c
    branches/soc-2013-viewport_fx/source/blender/gpu/shaders/gpu_shader_material.glsl
    branches/soc-2013-viewport_fx/source/blender/gpu/shaders/gpu_shader_simple_frag.glsl
    branches/soc-2013-viewport_fx/source/blender/gpu/shaders/gpu_shader_simple_vert.glsl
    branches/soc-2013-viewport_fx/source/blender/gpu/shaders/gpu_shader_vertex.glsl

Added Paths:
-----------
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_known.c
    branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_known.h
    branches/soc-2013-viewport_fx/source/blender/gpu/shaders/gpu_shader_font_frag.glsl
    branches/soc-2013-viewport_fx/source/blender/gpu/shaders/gpu_shader_font_vert.glsl
    branches/soc-2013-viewport_fx/source/blender/gpu/shaders/gpu_shader_known_attribs.glsl
    branches/soc-2013-viewport_fx/source/blender/gpu/shaders/gpu_shader_known_constants.glsl
    branches/soc-2013-viewport_fx/source/blender/gpu/shaders/gpu_shader_known_uniforms.glsl

Modified: branches/soc-2013-viewport_fx/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/blenfont/intern/blf.c	2013-08-01 18:33:35 UTC (rev 58810)
+++ branches/soc-2013-viewport_fx/source/blender/blenfont/intern/blf.c	2013-08-01 22:18:01 UTC (rev 58811)
@@ -600,8 +600,6 @@
 	/* always bind the texture for the first glyph */
 	font->tex_bind_state = -1;
 
-	gpuMatrixCommit();
-
 	draw_lock(font);
 }
 

Modified: branches/soc-2013-viewport_fx/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/blenkernel/BKE_DerivedMesh.h	2013-08-01 18:33:35 UTC (rev 58810)
+++ branches/soc-2013-viewport_fx/source/blender/blenkernel/BKE_DerivedMesh.h	2013-08-01 22:18:01 UTC (rev 58811)
@@ -385,6 +385,8 @@
 	 * gpuShadeModel called with GL_SMOOTH. Otherwise the face normal should
 	 * be set and gpuShadeModel called with GL_FLAT.
 	 *
+	 * XXX jwilkins: the above comment needs to be reevaluated since shadeModel is going away
+	 *
 	 * The setDrawOptions is allowed to not set drawSmooth (for example, when
 	 * lighting is disabled), in which case the implementation should draw as
 	 * smooth shaded.

Modified: branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/cdderivedmesh.c	2013-08-01 18:33:35 UTC (rev 58810)
+++ branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/cdderivedmesh.c	2013-08-01 22:18:01 UTC (rev 58811)
@@ -63,6 +63,7 @@
 #include "GPU_extensions.h"
 #include "GPU_material.h"
 #include "GPU_compatibility.h"
+#include "GPU_simple_shader.h"
 
 #include <string.h>
 #include <limits.h>
@@ -341,7 +342,7 @@
 	}
 	else {  /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
 		GPU_vertex_setup(dm);
-		gpuMatrixCommit();
+		GPU_commit_matrixes();
 		if (!GPU_buffer_legacy(dm)) {
 			if (dm->drawObject->tot_triangle_point)
 				glDrawArrays(GL_POINTS, 0, dm->drawObject->tot_triangle_point);
@@ -562,17 +563,17 @@
 
 	if (cddm->pbvh && cddm->pbvh_draw) {
 		if (dm->numTessFaceData) {
-			float (*face_nors)[3] = CustomData_get_layer(&dm->faceData, CD_NORMAL);
+			float (*face_nors)[3] = (float(*)[3])CustomData_get_layer(&dm->faceData, CD_NORMAL);
 
-			BKE_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors,
-			              setMaterial, FALSE);
-			gpuShadeModel(GL_FLAT);
+			BKE_pbvh_draw(cddm->pbvh, partial_redraw_planes, face_nors, setMaterial, FALSE);
 		}
 
 		return;
 	}
 
 	if (GPU_buffer_legacy(dm)) {
+		uint32_t options = 0;
+
 		DEBUG_VBO("Using legacy code. cdDM_drawFacesSolid\n");
 		gpuImmediateFormat_N3_V3();
 		gpuBegin(glmode = GL_QUADS);
@@ -588,7 +589,12 @@
 
 				drawCurrentMat = setMaterial(matnr = new_matnr, NULL);
 
-				gpuShadeModel(shademodel = new_shademodel);
+				if (shademodel != -1)
+					gpuAspectEnd(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options));
+
+				shademodel = new_shademodel;
+				options    = shademodel == GL_SMOOTH ? 0 : GPU_SHADER_FLAT_SHADED;
+				gpuAspectBegin(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options));
 				gpuBegin(glmode = new_glmode);
 			}
 			
@@ -620,6 +626,10 @@
 
 			if (nors) nors += 3;
 		}
+
+		if (dm->numTessFaceData > 0)
+			gpuAspectEnd(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options));
+
 		gpuEnd();
 		gpuImmediateUnformat();
 	}
@@ -627,19 +637,20 @@
 		GPU_vertex_setup(dm);
 		GPU_normal_setup(dm);
 		if (!GPU_buffer_legacy(dm)) {
-			gpuShadeModel(GL_SMOOTH);
+			uint32_t options = 0;
+			gpuAspectBegin(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options)); // gpuShadeModel(GL_SMOOTH);
 			for (a = 0; a < dm->drawObject->totmaterial; a++) {
 				if (setMaterial(dm->drawObject->materials[a].mat_nr + 1, NULL)) {
 					glDrawArrays(GL_TRIANGLES, dm->drawObject->materials[a].start,
 					             dm->drawObject->materials[a].totpoint);
 				}
 			}
+			gpuAspectEnd(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options)); // gpuShadeModel(GL_FLAT);
 		}
 		GPU_buffer_unbind();
 	}
 
 #undef PASSVERT
-	gpuShadeModel(GL_FLAT);
 }
 
 static void cdDM_drawFacesTex_common(DerivedMesh *dm,
@@ -656,6 +667,7 @@
 	MCol *mcol;
 	int i, orig;
 	int colType, startFace = 0;
+	uint32_t options;
 
 	/* double lookup */
 	const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
@@ -693,7 +705,8 @@
 
 	cdDM_update_normals_from_pbvh(dm);
 
-	gpuAspectBegin(GPU_ASPECT_TEXTURE, NULL);
+	options = GPU_SHADER_TEXTURE_2D|GPU_SHADER_FLAT_SHADED; // XXX jwilkins: not sure if in this context thingsa re suppose dto be flat shaded or not.
+	gpuAspectBegin(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options));
 
 	if (GPU_buffer_legacy(dm)) {
 		DEBUG_VBO("Using legacy code. cdDM_drawFacesTex_common\n");
@@ -801,7 +814,10 @@
 			int tottri = dm->drawObject->tot_triangle_point / 3;
 			int next_actualFace = dm->drawObject->triangle_to_mface[0];
 
-			gpuShadeModel(GL_SMOOTH);
+			gpuAspectEnd(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options)); // gpuShadeModel(GL_FLAT);
+			options = GPU_SHADER_TEXTURE_2D;
+			gpuAspectBegin(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options)); // gpuShadeModel(GL_SMOOTH);
+
 			/* lastFlag = 0; */ /* UNUSED */
 			for (i = 0; i < tottri; i++) {
 				int actualFace = next_actualFace;
@@ -851,7 +867,7 @@
 							GPU_color_switch(1);
 						else
 							GPU_color_switch(0);
-						gpuMatrixCommit();
+						GPU_commit_matrixes();
 						glDrawArrays(GL_TRIANGLES, first, count);
 					}
 
@@ -860,10 +876,9 @@
 			}
 		}
 
-		gpuAspectEnd(GPU_ASPECT_TEXTURE, NULL);
+		gpuAspectEnd(GPU_ASPECT_TEXTURE, SET_UINT_IN_POINTER(options));
 
 		GPU_buffer_unbind();
-		gpuShadeModel(GL_FLAT);
 	}
 }
 

Modified: branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/editderivedmesh.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/editderivedmesh.c	2013-08-01 18:33:35 UTC (rev 58810)
+++ branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/editderivedmesh.c	2013-08-01 22:18:01 UTC (rev 58811)
@@ -58,6 +58,7 @@
 
 #include "GPU_extensions.h"
 #include "GPU_compatibility.h"
+#include "GPU_simple_shader.h"
 
 extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
 
@@ -321,7 +322,7 @@
 	const int lasttri = tottri - 1; /* compare agasint this a lot */
 	DMDrawOption draw_option;
 	int i, flush;
-	const int useNormals = (flag & DM_DRAW_USE_NORMALS) && !gpuIsLightingEnabled(); /* could be passed as an arg */
+	const int useNormals = (flag & DM_DRAW_USE_NORMALS) && GPU_simple_shader_needs_normals(); /* could be passed as an arg */
 
 	MLoopCol *lcol[3] = {NULL} /* , dummylcol = {0} */;
 	unsigned char(*color_vert_array)[4] = em->derivedVertColor;

Modified: branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/subsurf_ccg.c	2013-08-01 18:33:35 UTC (rev 58810)
+++ branches/soc-2013-viewport_fx/source/blender/blenkernel/intern/subsurf_ccg.c	2013-08-01 22:18:01 UTC (rev 58811)
@@ -77,6 +77,7 @@
 #include "GPU_draw.h"
 #include "GPU_extensions.h"
 #include "GPU_material.h"
+#include "GPU_simple_shader.h"
 
 #include "CCGSubSurf.h"
 
@@ -1749,9 +1750,7 @@
 
 	if (ccgdm->pbvh && ccgdm->multires.mmd && !fast) {
 		if (dm->numTessFaceData) {
-			BKE_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL,
-			              setMaterial, FALSE);
-			//gpuShadeModel(GL_FLAT); // XXX jwilkins: pbvh draw should probably return ShadeModel to FLAT, but this function doesn't even do that for itself in other cases.
+			BKE_pbvh_draw(ccgdm->pbvh, partial_redraw_planes, NULL, setMaterial, FALSE);
 		}
 
 		return;
@@ -1765,6 +1764,7 @@
 		int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f);
 		int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
 		int new_matnr, new_shademodel;
+		uint32_t options = 0;
 
 		if (faceFlags) {
 			new_shademodel = (faceFlags[index].flag & ME_SMOOTH) ? GL_SMOOTH : GL_FLAT;
@@ -1776,10 +1776,14 @@
 		}
 		
 		if (shademodel != new_shademodel) {
+			if (shademodel != -1)
+				gpuAspectEnd(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options));
+
 			shademodel = new_shademodel;
-			gpuShadeModel(shademodel);
+			options    = shademodel == GL_FLAT ? GPU_SHADER_FLAT_SHADED : 0;
+			gpuAspectBegin(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options));
 		}
-		
+
 		if (matnr != new_matnr) {
 			matnr = new_matnr;
 			drawcurrent = setMaterial(matnr + 1, NULL);
@@ -1789,7 +1793,7 @@
 			continue;
 
 		for (S = 0; S < numVerts; S++) {
-			CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
+			CCGElem *faceGridData = (CCGElem*)ccgSubSurf_getFaceGridDataArray(ss, f, S);
 
 			if (shademodel == GL_SMOOTH) {
 				for (y = 0; y < gridSize - 1; y += step) {
@@ -1828,6 +1832,9 @@
 				}
 			}
 		}
+
+		if (numVerts > 0)
+			gpuAspectEnd(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options));
 	}
 
 	gpuEnd();
@@ -1944,7 +1951,8 @@
 		int S, x, y, drawSmooth;
 		int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
 		int origIndex = ccgDM_getFaceMapIndex(ss, f);
-		
+		uint32_t options;
+
 		numVerts = ccgSubSurf_getFaceNumVerts(f);
 
 		if (faceFlags) {
@@ -1971,9 +1979,11 @@
 			continue;
 		}
 
-		gpuShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
+		options = drawSmooth ? 0 : GPU_SHADER_FLAT_SHADED;
+		gpuAspectBegin(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options)); //gpuShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT);
+
 		for (S = 0; S < numVerts; S++) {
-			CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
+			CCGElem *faceGridData = (CCGElem*)ccgSubSurf_getFaceGridDataArray(ss, f, S);
 			CCGElem *vda, *vdb;
 
 			if (drawSmooth) {
@@ -2038,6 +2048,8 @@
 			}
 		}
 
+		gpuAspectEnd(GPU_ASPECT_SIMPLE_SHADER, SET_UINT_IN_POINTER(options));
+
 		ccg_unformat_attrib_vertex();
 	}
 
@@ -2104,7 +2116,8 @@
 		int S, x, y, drawSmooth;
 		int index = GET_INT_FROM_POINTER(ccgSubSurf_getFaceFaceHandle(f));
 		int origIndex = ccgDM_getFaceMapIndex(ss, f);
-		
+		uint32_t options;
+
 		numVerts = ccgSubSurf_getFaceNumVerts(f);
 
 		/* get flags */
@@ -2130,9 +2143,12 @@
 		}
 
 		/* draw face*/

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list