[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48934] branches/soc-2012-swiss_cheese/ source: GPU_matrix and gpu_funcions fixup
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sun Jul 15 08:14:36 CEST 2012
Revision: 48934
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48934
Author: jwilkins
Date: 2012-07-15 06:14:35 +0000 (Sun, 15 Jul 2012)
Log Message:
-----------
GPU_matrix and gpu_funcions fixup
Replaced GPU_MODELVIEW and friends with GL_MODELVIEW (If we need the bit fields we can create GPU_MODELVIEW_BIT, but having GPU_MODELVIEW is potentially very problematic for spotting bugs.)
Changed some macros to be enabled by WITH_GPU_SAFETY.
Prefer to use BLI_assert because it obeys WITH_ASSERT_ABORT option.
Fixed up CHECKMAT to work on MSVC.
Fixed up some functions to use GLAPIENTRY.
Quieted warning about slight differences between glBindAttribLocation and glBindAttribLocationARB.
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c
branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_functions.h
branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_matrix.h
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_functions.c
branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c
branches/soc-2012-swiss_cheese/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_Canvas.cpp
branches/soc-2012-swiss_cheese/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/BL_Texture.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_Dome.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp
Modified: branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c 2012-07-15 03:11:07 UTC (rev 48933)
+++ branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c 2012-07-15 06:14:35 UTC (rev 48934)
@@ -561,11 +561,11 @@
gpuMatrixLock();
- gpuMatrixMode(GPU_TEXTURE);
+ gpuMatrixMode(GL_TEXTURE);
gpuPushMatrix();
gpuLoadIdentity();
- gpuMatrixMode(GPU_MODELVIEW);
+ gpuMatrixMode(GL_MODELVIEW);
gpuPushMatrix();
@@ -596,10 +596,10 @@
{
draw_unlock(font);
- gpuMatrixMode(GPU_TEXTURE);
+ gpuMatrixMode(GL_TEXTURE);
gpuPopMatrix();
- gpuMatrixMode(GPU_MODELVIEW);
+ gpuMatrixMode(GL_MODELVIEW);
gpuPopMatrix();
gpuMatrixUnlock();
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_functions.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_functions.h 2012-07-15 03:11:07 UTC (rev 48933)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_functions.h 2012-07-15 06:14:35 UTC (rev 48934)
@@ -224,7 +224,7 @@
GPUFUNC void (GLAPIENTRY* gpuUniformMatrix4fv)(GLint location, GLint count, GLboolean transpose, const GLfloat * value);
GPUFUNC GLint (GLAPIENTRY* gpuGetAttribLocation)(GLuint program, const GLchar *name);
-GPUFUNC GLint (GLAPIENTRY* gpuBindAttribLocation)(GLuint program, GLuint index, const GLchar * name);
+GPUFUNC void (GLAPIENTRY* gpuBindAttribLocation)(GLuint program, GLuint index, const GLchar * name);
GPUFUNC GLint (GLAPIENTRY* gpuGetUniformLocation)(GLuint program, const GLchar * name);
@@ -248,6 +248,8 @@
#endif
+#ifndef GIVE_ME_APIENTRY
+
/***** BEGIN:THIS CODE WAS COPIED DIRECTLY FROM glew.h *****/
#ifdef GLEW_APIENTRY_DEFINED
@@ -272,4 +274,6 @@
/***** END:THIS CODE WAS COPIED DIRECTLY FROM glew.h *****/
+#endif
+
#endif /* GPU_FUNCTIONS_H */
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_matrix.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_matrix.h 2012-07-15 03:11:07 UTC (rev 48933)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/GPU_matrix.h 2012-07-15 06:14:35 UTC (rev 48934)
@@ -1,4 +1,5 @@
-#include "GPU_material.h"
+#include <GL/glew.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -6,10 +7,6 @@
#ifndef GPU_MATRIX
#define GPU_MATRIX
-#define GPU_MODELVIEW 1<<0
-#define GPU_PROJECTION 1<<1
-#define GPU_TEXTURE 1<<2
-
void GPU_matrix_forced_update(void);
void GPU_ms_init(void);
@@ -23,35 +20,35 @@
void gpuPushMatrix(void);
void gpuPopMatrix(void);
-void gpuMatrixMode(int mode);
+void gpuMatrixMode(GLenum mode);
-void gpuLoadMatrix(const float * m);
-float * gpuGetMatrix(float * m);
+void gpuLoadMatrix(const GLfloat * m);
+GLfloat * gpuGetMatrix(GLfloat * m);
void gpuLoadIdentity(void);
-void gpuMultMatrix(const float *m);
+void gpuMultMatrix(const GLfloat *m);
void gpuMultMatrixd(const double *m);
-void gpuTranslate(float x, float y, float z);
-void gpuScale(float x, float y, float z);
-void gpuRotateAxis(float angle, char axis);
+void gpuTranslate(GLfloat x, GLfloat y, GLfloat z);
+void gpuScale(GLfloat x, GLfloat y, GLfloat z);
+void gpuRotateAxis(GLfloat angle, char axis);
-void gpuOrtho(float left, float right, float bottom, float top, float nearVal, float farVal);
-void gpuFrustum(float left, float right, float bottom, float top, float nearVal, float farVal);
+void gpuOrtho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
+void gpuFrustum(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
-void gpuLoadOrtho(float left, float right, float bottom, float top, float nearVal, float farVal);
-void gpuLoadFrustum(float left, float right, float bottom, float top, float nearVal, float farVal);
+void gpuLoadOrtho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
+void gpuLoadFrustum(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
-void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ);
+void gpuLookAt(GLfloat eyeX, GLfloat eyeY, GLfloat eyeZ, GLfloat centerX, GLfloat centerY, GLfloat centerZ, GLfloat upX, GLfloat upY, GLfloat upZ);
#ifndef GPU_MAT_CAST_ANY
#define GPU_MAT_CAST_ANY
-#define gpuLoadMatrix(m) gpuLoadMatrix((const float *) m);
-#define gpuGetMatrix(m) gpuGetMatrix((float *) m);
-#define gpuMultMatrix(m) gpuMultMatrix((const float *) m);
+#define gpuLoadMatrix(m) gpuLoadMatrix((const GLfloat *) m);
+#define gpuGetMatrix(m) gpuGetMatrix((GLfloat *) m);
+#define gpuMultMatrix(m) gpuMultMatrix((const GLfloat *) m);
#define gpuMultMatrixd(m) gpuMultMatrixd((const double *) m);
#endif
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_functions.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_functions.c 2012-07-15 03:11:07 UTC (rev 48933)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_functions.c 2012-07-15 06:14:35 UTC (rev 48934)
@@ -34,6 +34,7 @@
#endif
#define GPU_FUNC_INTERN
+#define GIVE_ME_APIENTRY
#include "GPU_functions.h"
#include REAL_GL_MODE
@@ -54,14 +55,14 @@
#ifndef GLES
-static void check_glGetObjectParameterivARB(GLuint shader, GLuint pname, GLint *params)
+static void GLAPIENTRY check_glGetObjectParameterivARB(GLuint shader, GLuint pname, GLint *params)
{
GPU_CHECK_INVALID_PNAME(GL_SHADER_TYPE);
glGetObjectParameterivARB(shader, pname, params);
}
-static void check_glGetProgramivARB(GLuint shader, GLuint pname, GLint *params)
+static void GLAPIENTRY check_glGetProgramivARB(GLuint shader, GLuint pname, GLint *params)
{
GPU_CHECK_INVALID_PNAME(GL_ACTIVE_ATTRIBUTES);
GPU_CHECK_INVALID_PNAME(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH);
@@ -100,7 +101,7 @@
gpuUniformMatrix4fv = glUniformMatrix4fvARB;
gpuGetAttribLocation = glGetAttribLocationARB;
- gpuBindAttribLocation = glBindAttribLocationARB;
+ gpuBindAttribLocation = (void (GLAPIENTRY*)(GLuint,GLuint,const GLchar*))glBindAttribLocationARB;
gpuGetUniformLocation = glGetUniformLocationARB;
gpuUseProgram = glUseProgramObjectARB;
Modified: branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c 2012-07-15 03:11:07 UTC (rev 48933)
+++ branches/soc-2012-swiss_cheese/source/blender/gpu/intern/gpu_matrix.c 2012-07-15 06:14:35 UTC (rev 48934)
@@ -1,3 +1,5 @@
+#include "gpu_immediate.h"
+
#include <assert.h>
#include "MEM_guardedalloc.h"
@@ -17,16 +19,19 @@
#include <GL/glew.h>
#endif
-#define GLU_STACK_DEBUG
-int glslneedupdate = 1;
+#if WITH_GPU_SAFETY
+#define GPU_STACK_DEBUG
+#endif
-typedef float GPU_matrix[4][4];
+GLint glslneedupdate = 1;
+typedef GLfloat GPU_matrix[4][4];
+
typedef struct GPU_matrix_stack
{
- int size;
- int pos;
- int changed;
+ GLint size;
+ GLint pos;
+ GLint changed;
GPU_matrix * dynstack;
@@ -51,24 +56,26 @@
/* Check if we have a good matrix */
-#if 0
-static void checkmat(float *m)
+#if WITH_GPU_SAFETY
+static void checkmat(GLfloat *m)
{
- int i;
- for(i=0;i<16;i++){
- if(isinf(m[i]))
- {assert(0);};};
-
-
+ GLint i;
+ for(i=0;i<16;i++) {
+#if _MSC_VER
+ BLI_assert(_finite(m[i]));
+#else
+ BLI_assert(!isinf(m[i]));
+#endif
+ }
}
-#define CHECKMAT checkmat((float*)CURMATRIX);
+#define CHECKMAT checkmat((GLfloat*)CURMATRIX);
#else
#define CHECKMAT
#endif
-static void ms_init(GPU_matrix_stack * ms, int initsize)
+static void ms_init(GPU_matrix_stack * ms, GLint initsize)
{
if(initsize == 0)
initsize = 32;
@@ -88,8 +95,8 @@
}
-static int glstackpos[3] = {0};
-static int glstackmode;
+static GLint glstackpos[3] = {0};
+static GLint glstackmode;
void GPU_ms_init(void)
{
@@ -126,17 +133,17 @@
glGetIntegerv(GL_TEXTURE_STACK_DEPTH, glstackpos+2);
glGetIntegerv(GL_MATRIX_MODE, &glstackmode);
- glGetFloatv(GL_MODELVIEW_MATRIX, (float*)tm);
- gpuMatrixMode(GPU_MODELVIEW);
- gpuLoadMatrix((float*)tm);
+ glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*)tm);
+ gpuMatrixMode(GL_MODELVIEW);
+ gpuLoadMatrix((GLfloat*)tm);
- glGetFloatv(GL_PROJECTION_MATRIX, (float*)tm);
- gpuMatrixMode(GPU_PROJECTION);
- gpuLoadMatrix((float*)tm);
+ glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat*)tm);
+ gpuMatrixMode(GL_PROJECTION);
+ gpuLoadMatrix((GLfloat*)tm);
- glGetFloatv(GL_TEXTURE_MATRIX, (float*)tm);
- gpuMatrixMode(GPU_TEXTURE);
- gpuLoadMatrix((float*)tm);
+ glGetFloatv(GL_TEXTURE_MATRIX, (GLfloat*)tm);
+ gpuMatrixMode(GL_TEXTURE);
+ gpuLoadMatrix((GLfloat*)tm);
@@ -152,13 +159,13 @@
switch(glstackmode)
{
case GL_MODELVIEW:
- gpuMatrixMode(GPU_MODELVIEW);
+ gpuMatrixMode(GL_MODELVIEW);
break;
case GL_TEXTURE:
- gpuMatrixMode(GPU_TEXTURE);
+ gpuMatrixMode(GL_TEXTURE);
break;
case GL_PROJECTION:
- gpuMatrixMode(GPU_PROJECTION);
+ gpuMatrixMode(GL_PROJECTION);
break;
}
@@ -173,7 +180,7 @@
{
#ifndef GLES
- int curval;
+ GLint curval;
glMatrixMode(GL_TEXTURE);
@@ -207,19 +214,19 @@
{
ms_modelview.changed = 0;
glMatrixMode(GL_MODELVIEW);
- glLoadMatrixf((float*)ms_modelview.dynstack[ms_modelview.pos]);
+ glLoadMatrixf((GLfloat*)ms_modelview.dynstack[ms_modelview.pos]);
}
if(ms_projection.changed)
{
ms_projection.changed = 0;
glMatrixMode(GL_PROJECTION);
- glLoadMatrixf((float*)ms_projection.dynstack[ms_projection.pos]);
+ glLoadMatrixf((GLfloat*)ms_projection.dynstack[ms_projection.pos]);
}
if(ms_texture.changed)
{
ms_texture.changed = 0;
glMatrixMode(GL_TEXTURE);
- glLoadMatrixf((float*)ms_texture.dynstack[ms_texture.pos]);
+ glLoadMatrixf((GLfloat*)ms_texture.dynstack[ms_texture.pos]);
}
#else
@@ -229,7 +236,7 @@
if(ms_modelview.changed || glslneedupdate)
{
- float t[3][3] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
+ GLfloat t[3][3] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
copy_m3_m4(t, ms_modelview.dynstack[ms_modelview.pos]);
if(curglslesi->viewmatloc!=-1)
glUniformMatrix4fv(curglslesi->viewmatloc, 1, 0, ms_modelview.dynstack[ms_modelview.pos]);
@@ -270,7 +277,7 @@
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list