[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58973] branches/soc-2013-viewport_fx/ source/blender/gpu/intern: Tested the fixed function fallback mode for the basic shader.
Jason Wilkins
Jason.A.Wilkins at gmail.com
Tue Aug 6 22:31:21 CEST 2013
Revision: 58973
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58973
Author: jwilkins
Date: 2013-08-06 20:31:20 +0000 (Tue, 06 Aug 2013)
Log Message:
-----------
Tested the fixed function fallback mode for the basic shader.
Also tested what happens if there is no glsl support (need to make this a debug option)
Fixed memory leak that is detected when no glsl support (in the quad emulation code)
Modified Paths:
--------------
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_basic_shader.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extension_wrapper.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_extensions.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_font_shader.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_gl.c
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_immediate_gl.h
branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_matrix.c
Modified: branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_basic_shader.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_basic_shader.c 2013-08-06 19:50:25 UTC (rev 58972)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_basic_shader.c 2013-08-06 20:31:20 UTC (rev 58973)
@@ -234,69 +234,76 @@
void GPU_basic_shader_bind(void)
{
- if (GPU_glsl_support())
+ bool glsl_support = GPU_glsl_support();
+
+ GPU_CHECK_NO_ERROR();
+
+ if (glsl_support) {
basic_shader_bind();
+ }
#if defined(WITH_GL_PROFILE_COMPAT)
- /* Only change state if it is different than the Blender default */
+ if (!glsl_support) {
+ if (BASIC_SHADER.options & GPU_BASIC_LIGHTING)
+ glEnable(GL_LIGHTING);
+ else
+ glDisable(GL_LIGHTING);
- if (BASIC_SHADER.options & GPU_BASIC_LIGHTING)
- glEnable(GL_LIGHTING);
+ if (BASIC_SHADER.options & GPU_BASIC_TEXTURE_2D)
+ glEnable(GL_TEXTURE_2D);
+ else
+ glDisable(GL_TEXTURE_2D);
- if (BASIC_SHADER.options & GPU_BASIC_TEXTURE_2D)
- glEnable(GL_TEXTURE_2D);
+ if (BASIC_SHADER.options & GPU_BASIC_TWO_SIDE)
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
+ else
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
- if (BASIC_SHADER.options & GPU_BASIC_TWO_SIDE)
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
+ if (BASIC_SHADER.options & GPU_BASIC_LOCAL_VIEWER)
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
+ else
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
- if (BASIC_SHADER.options & GPU_BASIC_LOCAL_VIEWER)
- glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
-
- if (BASIC_SHADER.options & GPU_BASIC_SMOOTH)
- glShadeModel(GL_SMOOTH);
+ if (BASIC_SHADER.options & GPU_BASIC_SMOOTH)
+ glShadeModel(GL_SMOOTH);
+ else
+ glShadeModel(GL_FLAT);
+ }
#endif
if (BASIC_SHADER.options & GPU_BASIC_LIGHTING) {
-GPU_CHECK_NO_ERROR();
gpu_commit_light();
-GPU_CHECK_NO_ERROR();
gpu_commit_material();
-GPU_CHECK_NO_ERROR();
BASIC_SHADER.need_normals = true; // Temporary hack. Should be solved outside of this file.
}
else {
BASIC_SHADER.need_normals = false; // Temporary hack. Should be solved outside of this file.
}
+
+ GPU_CHECK_NO_ERROR();
}
void GPU_basic_shader_unbind(void)
{
+ GPU_CHECK_NO_ERROR();
+
if (GPU_glsl_support())
GPU_shader_unbind();
#if defined(WITH_GL_PROFILE_COMPAT)
- /* If GL state was switched from the Blender default then reset it. */
-
- if (BASIC_SHADER.options & GPU_BASIC_LIGHTING)
- glDisable(GL_LIGHTING);
-
- if (BASIC_SHADER.options & GPU_BASIC_TEXTURE_2D)
- glDisable(GL_TEXTURE_2D);
-
- if (BASIC_SHADER.options & GPU_BASIC_TWO_SIDED)
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
-
- if (BASIC_SHADER.options & GPU_BASIC_LOCAL_VIEWER)
- glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
-
- if (BASIC_SHADER.options & GPU_BASIC_SMOOTH)
- glShadeModel(GL_FLAT);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_TEXTURE_2D);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
+ glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE);
+ glShadeModel(GL_FLAT);
#endif
BASIC_SHADER.need_normals = false; // Temporary hack. Should be solved outside of this file.
+
+ GPU_CHECK_NO_ERROR();
}
Modified: branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.c
===================================================================
--- branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.c 2013-08-06 19:50:25 UTC (rev 58972)
+++ branches/soc-2013-viewport_fx/source/blender/gpu/intern/gpu_common.c 2013-08-06 20:31:20 UTC (rev 58973)
@@ -184,10 +184,12 @@
void gpu_enable_vertex_array (void)
{
- GLint vertex = current_common != NULL ? current_common->vertex : -1;
+ if (current_common != NULL) {
+ if (current_common->vertex != -1)
+ gpu_glEnableVertexAttribArray(current_common->vertex);
- if (gpu_glEnableVertexAttribArray != NULL && vertex != -1)
- gpu_glEnableVertexAttribArray(vertex);
+ return;
+ }
#if defined(WITH_GL_PROFILE_COMPAT)
glEnableClientState(GL_VERTEX_ARRAY);
@@ -198,10 +200,12 @@
void gpu_enable_normal_array (void)
{
- GLint normal = current_common != NULL ? current_common->normal : -1;
+ if (current_common != NULL) {
+ if (current_common->normal != -1)
+ gpu_glEnableVertexAttribArray(current_common->normal);
- if (gpu_glEnableVertexAttribArray != NULL && normal != -1)
- gpu_glEnableVertexAttribArray(normal);
+ return;
+ }
#if defined(WITH_GL_PROFILE_COMPAT)
glEnableClientState(GL_NORMAL_ARRAY);
@@ -212,10 +216,12 @@
void gpu_enable_color_array (void)
{
- GLint color = current_common != NULL ? current_common->color : -1;
+ if (current_common != NULL) {
+ if (current_common->color != -1)
+ gpu_glEnableVertexAttribArray(current_common->color);
- if (gpu_glEnableVertexAttribArray != NULL && color != -1)
- gpu_glEnableVertexAttribArray(color);
+ return;
+ }
#if defined(WITH_GL_PROFILE_COMPAT)
glEnableClientState(GL_COLOR_ARRAY);
@@ -226,13 +232,18 @@
void gpu_enable_texcoord_array (void)
{
- GLint multi_texcoord = current_common != NULL ? current_common->multi_texcoord[active_texture_num] : -1;
+ GPU_ASSERT(active_texture_num >= 0);
+ GPU_ASSERT(active_texture_num < GPU_MAX_COMMON_TEXCOORDS);
- if (gpu_glEnableVertexAttribArray != NULL && multi_texcoord != -1)
- gpu_glEnableVertexAttribArray(multi_texcoord);
+ if (current_common != NULL) {
+ if (current_common->multi_texcoord[active_texture_num] != -1)
+ gpu_glEnableVertexAttribArray(current_common->multi_texcoord[active_texture_num]);
+ return;
+ }
+
#if defined(WITH_GL_PROFILE_COMPAT)
- if (active_texture_num < GPU_max_textures()
+ if (active_texture_num < GPU_max_textures())
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
}
@@ -241,10 +252,12 @@
void gpu_disable_vertex_array (void)
{
- GLint vertex = current_common != NULL ? current_common->vertex : -1;
+ if (current_common != NULL) {
+ if (current_common->vertex != -1)
+ gpu_glDisableVertexAttribArray(current_common->vertex);
- if (gpu_glDisableVertexAttribArray != NULL && vertex != -1)
- gpu_glDisableVertexAttribArray(vertex);
+ return;
+ }
#if defined(WITH_GL_PROFILE_COMPAT)
glDisableClientState(GL_VERTEX_ARRAY);
@@ -255,10 +268,12 @@
void gpu_disable_normal_array (void)
{
- GLint normal = current_common != NULL ? current_common->normal : -1;
+ if (current_common != NULL) {
+ if (current_common->normal != -1)
+ gpu_glDisableVertexAttribArray(current_common->normal);
- if (gpu_glDisableVertexAttribArray != NULL && normal != -1)
- gpu_glDisableVertexAttribArray(normal);
+ return;
+ }
#if defined(WITH_GL_PROFILE_COMPAT)
glDisableClientState(GL_NORMAL_ARRAY);
@@ -269,10 +284,12 @@
void gpu_disable_color_array (void)
{
- GLint color = current_common != NULL ? current_common->color : -1;
+ if (current_common != NULL) {
+ if (current_common->color != -1)
+ gpu_glDisableVertexAttribArray(current_common->color);
- if (gpu_glDisableVertexAttribArray != NULL && color != -1)
- gpu_glDisableVertexAttribArray(color);
+ return;
+ }
#if defined(WITH_GL_PROFILE_COMPAT)
glDisableClientState(GL_COLOR_ARRAY);
@@ -283,11 +300,16 @@
void gpu_disable_texcoord_array(void)
{
- GLint multi_texcoord = current_common != NULL ? current_common->multi_texcoord[active_texture_num] : -1;
+ GPU_ASSERT(active_texture_num >= 0);
+ GPU_ASSERT(active_texture_num < GPU_MAX_COMMON_TEXCOORDS);
- if (gpu_glDisableVertexAttribArray != NULL && multi_texcoord != -1)
- gpu_glDisableVertexAttribArray(multi_texcoord);
+ if (current_common != NULL) {
+ if (current_common->multi_texcoord[active_texture_num] != -1)
+ gpu_glDisableVertexAttribArray(current_common->multi_texcoord[active_texture_num]);
+ return;
+ }
+
#if defined(WITH_GL_PROFILE_COMPAT)
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
@@ -297,10 +319,12 @@
void gpu_vertex_pointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
{
- GLint vertex = current_common != NULL ? current_common->vertex : -1;
+ if (current_common != NULL) {
+ if (current_common->vertex != -1)
+ gpu_glVertexAttribPointer(current_common->vertex, size, type, GL_FALSE, stride, pointer);
- if (gpu_glVertexAttribPointer != NULL && vertex != -1)
- gpu_glVertexAttribPointer(vertex, size, type, GL_FALSE, stride, pointer);
+ return;
+ }
#if defined(WITH_GL_PROFILE_COMPAT)
glVertexPointer(size, type, stride, pointer);
@@ -311,10 +335,12 @@
void gpu_normal_pointer(GLenum type, GLsizei stride, const GLvoid* pointer)
{
- GLint normal = current_common != NULL ? current_common->normal : -1;
+ if (current_common != NULL) {
+ if (current_common->normal != -1)
+ gpu_glVertexAttribPointer(current_common->normal, 3, type, GL_FALSE, stride, pointer);
- if (gpu_glVertexAttribPointer != NULL && normal != -1)
- gpu_glVertexAttribPointer(normal, 3, type, GL_FALSE, stride, pointer);
+ return;
+ }
#if defined(WITH_GL_PROFILE_COMPAT)
glNormalPointer(type, stride, pointer);
@@ -322,14 +348,18 @@
}
-// XXX jwilkins: either remove the type parameter or add a normalize parameter (this applies to all of the pointer functions, not just gpu_color_pointer)
+
void gpu_color_pointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
{
- GLint color = current_common != NULL ? current_common->color : -1;
+ GPU_ASSERT(type == GL_UNSIGNED_BYTE); // making assumptions about the type being a fixed point type
- if (gpu_glVertexAttribPointer != NULL && color != -1)
- gpu_glVertexAttribPointer(color, size, type, GL_TRUE, stride, pointer);
+ if (current_common != NULL) {
+ if (current_common->color != -1)
+ gpu_glVertexAttribPointer(current_common->color, size, type, GL_TRUE, stride, pointer);
+ return;
+ }
+
#if defined(WITH_GL_PROFILE_COMPAT)
glColorPointer(size, type, stride, pointer);
#endif
@@ -339,13 +369,18 @@
void gpu_texcoord_pointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer)
{
- GLuint multi_texcoord = current_common != NULL ? current_common->multi_texcoord[active_texture_num] : -1;
+ GPU_ASSERT(active_texture_num >= 0);
+ GPU_ASSERT(active_texture_num < GPU_MAX_COMMON_TEXCOORDS);
- if (gpu_glVertexAttribPointer != NULL && multi_texcoord != -1)
- gpu_glVertexAttribPointer(multi_texcoord, size, type, GL_FALSE, stride, pointer);
+ if (current_common != NULL) {
+ if (current_common->multi_texcoord[active_texture_num] != -1)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list