[Bf-blender-cvs] [f40ffb7] GPU_data_request: More compilation fixes - add new files for cmake, make files conform to old C (no declarations, use #ifdef instead or #if).
Antony Riakiotakis
noreply at git.blender.org
Fri Apr 3 12:13:34 CEST 2015
Commit: f40ffb79d481c002ff0ca225e2c3ed66bb8d738e
Author: Antony Riakiotakis
Date: Fri Apr 3 12:13:28 2015 +0200
Branches: GPU_data_request
https://developer.blender.org/rBf40ffb79d481c002ff0ca225e2c3ed66bb8d738e
More compilation fixes - add new files for cmake, make files conform to
old C (no declarations, use #ifdef instead or #if).
===================================================================
M source/blender/gpu/CMakeLists.txt
M source/blender/gpu/GPUx_vbo.h
D source/blender/gpu/intern/GPUx_element_private.h
M source/blender/gpu/intern/gpux_draw.c
M source/blender/gpu/intern/gpux_element.c
A source/blender/gpu/intern/gpux_element_private.h
M source/blender/gpu/intern/gpux_state.c
M source/blender/gpu/intern/gpux_vbo.c
M source/blender/nodes/CMakeLists.txt
===================================================================
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 97b0e7e..58fe387 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -56,6 +56,10 @@ set(SRC
intern/gpu_select.c
intern/gpu_compositing.c
intern/gpu_debug.c
+ intern/gpux_element.c
+ intern/gpux_draw.c
+ intern/gpux_vbo.c
+ intern/gpux_state.c
shaders/gpu_shader_fx_lib.glsl
shaders/gpu_shader_fx_ssao_frag.glsl
@@ -87,6 +91,7 @@ set(SRC
GPU_compositing.h
intern/gpu_codegen.h
intern/gpu_private.h
+ intern/gpux_element_private.h
)
data_to_c_simple(shaders/gpu_shader_material.glsl SRC)
diff --git a/source/blender/gpu/GPUx_vbo.h b/source/blender/gpu/GPUx_vbo.h
index 0e9b62c..a455d09 100644
--- a/source/blender/gpu/GPUx_vbo.h
+++ b/source/blender/gpu/GPUx_vbo.h
@@ -8,9 +8,9 @@
/* ^-- for GLenum (and if you're including this file, you're probably calling OpenGL anyway) */
#include <stdbool.h>
-#define GENERIC_ATTRIB false
-#define TRUST_NO_ONE true
-#define PRINT false
+//#define GENERIC_ATTRIB
+#define TRUST_NO_ONE
+//#define PRINT
struct VertexBuffer; /* forward declaration */
typedef struct VertexBuffer VertexBuffer;
@@ -27,12 +27,12 @@ void vertex_buffer_discard(VertexBuffer*);
unsigned vertex_ct(const VertexBuffer*);
-#if PRINT
+#ifdef PRINT
void attrib_print(const VertexBuffer*, unsigned attrib_num);
#endif /* PRINT */
void specify_attrib(VertexBuffer*, unsigned attrib_num,
-#if GENERIC_ATTRIB
+#ifdef GENERIC_ATTRIB
const char *name, /* use any legal GLSL identifier */
#else
GLenum attrib_array, /* use GL_VERTEX_ARRAY, GL_NORMAL_ARRAY, etc. */
diff --git a/source/blender/gpu/intern/gpux_draw.c b/source/blender/gpu/intern/gpux_draw.c
index ff9f861..475c0fd 100644
--- a/source/blender/gpu/intern/gpux_draw.c
+++ b/source/blender/gpu/intern/gpux_draw.c
@@ -1,12 +1,12 @@
#include "GPUx_draw.h"
-#include "GPUx_element_private.h"
+#include "gpux_element_private.h"
-#if TRUST_NO_ONE
+#ifdef TRUST_NO_ONE
#include <assert.h>
#endif /* TRUST_NO_ONE */
-#define REALLY_DRAW true
+#define REALLY_DRAW
/* generally useful utility function */
static unsigned chop_to_multiple(unsigned x, unsigned m)
@@ -19,14 +19,14 @@ void draw_points(const CommonDrawState *common_state, const PointDrawState *poin
set_common_state(common_state);
set_point_state(point_state);
-#if TRUST_NO_ONE
+#ifdef TRUST_NO_ONE
if (el) {
assert(el->prim_type == GL_POINTS);
assert(el->max_allowed_index < vertex_ct(vbo));
}
#endif /* TRUST_NO_ONE */
-#if REALLY_DRAW
+#ifdef REALLY_DRAW
vertex_buffer_use_primed(vbo);
if (el)
@@ -43,14 +43,14 @@ void draw_lines(const CommonDrawState *common_state, const LineDrawState *line_s
set_common_state(common_state);
set_line_state(line_state);
-#if TRUST_NO_ONE
+#ifdef TRUST_NO_ONE
if (el) {
assert(el->prim_type == GL_LINES);
assert(el->max_allowed_index < vertex_ct(vbo));
}
#endif /* TRUST_NO_ONE */
-#if REALLY_DRAW
+#ifdef REALLY_DRAW
vertex_buffer_use_primed(vbo);
if (el)
@@ -67,14 +67,14 @@ void draw_triangles(const CommonDrawState *common_state, const PolygonDrawState
set_common_state(common_state);
set_polygon_state(polygon_state);
-#if TRUST_NO_ONE
+#ifdef TRUST_NO_ONE
if (el) {
assert(el->prim_type == GL_TRIANGLES);
assert(el->max_allowed_index < vertex_ct(vbo));
}
#endif /* TRUST_NO_ONE */
-#if REALLY_DRAW
+#ifdef REALLY_DRAW
vertex_buffer_use_primed(vbo);
if (el)
@@ -88,12 +88,12 @@ void draw_triangles(const CommonDrawState *common_state, const PolygonDrawState
void draw_primitives(const CommonDrawState *common_state, const void *primitive_state, const VertexBuffer *vbo, const ElementList *el)
{
-#if TRUST_NO_ONE
+ int vert_per_prim = 0;
+
+#ifdef TRUST_NO_ONE
assert(el->max_allowed_index < vertex_ct(vbo));
#endif /* TRUST_NO_ONE */
- int vert_per_prim = 0;
-
switch (el->prim_type) {
case GL_POINTS:
set_point_state((const PointDrawState*)primitive_state);
@@ -108,7 +108,7 @@ void draw_primitives(const CommonDrawState *common_state, const void *primitive_
vert_per_prim = 3;
break;
default:
-#if TRUST_NO_ONE
+#ifdef TRUST_NO_ONE
assert(false);
#else
return;
@@ -117,7 +117,7 @@ void draw_primitives(const CommonDrawState *common_state, const void *primitive_
set_common_state(common_state);
-#if REALLY_DRAW
+#ifdef REALLY_DRAW
vertex_buffer_use_primed(vbo);
glDrawRangeElements(el->prim_type, min_index(el), max_index(el), el->prim_ct * vert_per_prim, el->index_type, el->indices);
diff --git a/source/blender/gpu/intern/gpux_element.c b/source/blender/gpu/intern/gpux_element.c
index 1109e44..906d1d8 100644
--- a/source/blender/gpu/intern/gpux_element.c
+++ b/source/blender/gpu/intern/gpux_element.c
@@ -1,9 +1,9 @@
-#include "GPUx_element_private.h"
+#include "gpux_element_private.h"
#include <stdlib.h>
#if TRACK_INDEX_RANGE
-void track_index_range(ElementList *el, unsigned v)
+static void track_index_range(ElementList *el, unsigned v)
{
if (v < el->min_observed_index)
el->min_observed_index = v;
@@ -42,7 +42,7 @@ ElementList *element_list_create(GLenum prim_type, unsigned prim_ct, unsigned ma
else if (prim_type == GL_TRIANGLES)
prim_vertex_ct = 3;
else {
-#if TRUST_NO_ONE
+#ifdef TRUST_NO_ONE
assert(false);
#endif /* TRUST_NO_ONE */
return NULL;
diff --git a/source/blender/gpu/intern/GPUx_element_private.h b/source/blender/gpu/intern/gpux_element_private.h
similarity index 100%
rename from source/blender/gpu/intern/GPUx_element_private.h
rename to source/blender/gpu/intern/gpux_element_private.h
diff --git a/source/blender/gpu/intern/gpux_state.c b/source/blender/gpu/intern/gpux_state.c
index 1f6fd23..0e980b6 100644
--- a/source/blender/gpu/intern/gpux_state.c
+++ b/source/blender/gpu/intern/gpux_state.c
@@ -4,7 +4,7 @@
#include <string.h> /* memset */
-#if TRUST_NO_ONE
+#ifdef TRUST_NO_ONE
#include <assert.h>
#endif /* TRUST_NO_ONE */
@@ -96,9 +96,9 @@ void set_line_state(const LineDrawState *state)
if (state->stipple != current.line.stipple) {
if (state->stipple) {
+ const GLushort pattern = 0x4E72; /* or 0xAAAA */
glEnable(GL_LINE_STIPPLE);
/* line stipple is 16-bit pattern */
- const GLushort pattern = 0x4E72; /* or 0xAAAA */
glLineStipple(state->stipple, pattern);
}
else
@@ -161,6 +161,7 @@ void set_polygon_state(const PolygonDrawState *state)
void force_state_update()
{
+ const GLenum cull = faces_to_cull(¤t.polygon);
/* TODO: factor some of this stuff out, share with set_*_state functions? */
/* common state */
@@ -201,16 +202,15 @@ void force_state_update()
glLineWidth(current.line.width);
if (current.line.stipple) {
+ const GLushort pattern = 0x4E72; /* or 0xAAAA */
glEnable(GL_LINE_STIPPLE);
/* line stipple is 16-bit pattern */
- const GLushort pattern = 0x4E72; /* or 0xAAAA */
glLineStipple(current.line.stipple, pattern);
}
else
glDisable(GL_LINE_STIPPLE);
/* polygon state */
- const GLenum cull = faces_to_cull(¤t.polygon);
if (cull == GL_NONE)
glDisable(GL_CULL_FACE);
else {
@@ -221,9 +221,9 @@ void force_state_update()
/* TODO: whatever needed to make material active */
if (current.polygon.stipple) {
+ GLubyte pattern[128];
glEnable(GL_POLYGON_STIPPLE);
/* polygon stipple is 32x32-bit pattern */
- GLubyte pattern[128];
memset(pattern, 0xAA, sizeof(pattern));
glPolygonStipple(pattern);
polygon_stipple_pattern_set = true;
diff --git a/source/blender/gpu/intern/gpux_vbo.c b/source/blender/gpu/intern/gpux_vbo.c
index 4d1afbe..1a2f703 100644
--- a/source/blender/gpu/intern/gpux_vbo.c
+++ b/source/blender/gpu/intern/gpux_vbo.c
@@ -5,19 +5,21 @@
/* VBOs are guaranteed for any GL >= 1.5
* They can be turned off here (mostly for comparison). */
-#define USE_VBO true
+#define USE_VBO
/* VAOs are part of GL 3.0, and optionally available in 2.1 as an extension:
* APPLE_vertex_array_object or ARB_vertex_array_object
* the ARB version of VAOs *must* use VBOs for vertex data
* so we should follow that restriction on all platforms. */
-#define USE_VAO (USE_VBO && true)
+#ifdef USE_VBO
+#define USE_VAO
+#endif
-#if TRUST_NO_ONE
+#ifdef TRUST_NO_ONE
#include <assert.h>
#endif /* TRUST_NO_ONE */
-#if PRINT
+#ifdef PRINT
#include <stdio.h>
#endif /* PRINT */
@@ -29,7 +31,7 @@ typedef struct {
unsigned sz; /* size in bytes, 1 to 16 */
unsigned stride; /* natural stride in bytes, 1 to 16 */
VertexFetchMode fetch_mode;
-#if GENERIC_ATTRIB
+#ifdef GENERIC_ATTRIB
char *name;
#else
GLenum array;
@@ -39,7 +41,7 @@ typedef struct {
* - single VBO for all attribs (sequential)
* - single VBO, attribs interleaved
* - distinguish between static & dynamic attribs, w/ separate storage */
-#if USE_VBO
+#ifdef USE_VBO
GLuint vbo_id;
#endif /* USE_VBO */
} Attrib;
@@ -47,7 +49,7 @@ typedef struct {
static unsigned comp_sz(GLenum type)
{
const GLubyte sizes[] = {1,1,2,2,4,4,4}; /* uint32 might result in smaller code? */
-#if TRUST_NO_ONE
+#ifdef TRUST_NO_ONE
assert(type >= GL_BYTE && type <= GL_FLOAT);
#endif /* TRUST_NO_ONE */
return sizes[type - GL_BYTE];
@@ -73,24 +75,21 @@ struct VertexBuffer
unsigned attrib_ct; /* 1 to 16 */
unsigned vertex_ct;
Attrib *attribs;
-#if USE_VAO
+#ifdef USE_VAO
GLuint vao_id;
#endif /* USE_VAO */
};
-#if PRINT
+#ifdef PRINT
void attrib_print(const VertexBuffer *buff, unsigned attrib_num)
{
+ unsigned int comp_size, v;
Attrib *a = buff->attribs + attrib_num;
-#if TRUST_NO_ONE
- assert(attrib_num < buff->attrib_ct);
- assert(a->comp_type >= GL_BYTE && a->comp_type <= GL_FLOAT);
- assert(a->data != NULL); /* attribute must be specified */
-#endif /* TRUST_NO_ONE */
+ unsigned type_idx = a->comp_type - GL_BYTE;
/* use GLSL names when they exist, or type_count for the others */
const char *singular[] = {"byte","ubyte","short","ushort","int","uint","float"};
const char *plural[] = {"byte_","ubyte_","short_","ushort_","ivec","uint_","vec"};
-#if GENERIC_ATTRIB
+#ifdef GENERIC_ATTRIB
const char *var_name = a->name ? a->name : "foo";
#else
const char* var_name = "foo";
@@ -111,16 +1
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list