[Bf-blender-cvs] [42beba3] soc-2014-viewport_fx: (Showing My Work) Expanded GPU Module to Support Modern OpenGL

Jason Wilkins noreply at git.blender.org
Sat Jun 28 11:03:09 CEST 2014


Commit: 42beba3f739663857be068975f67149ef4d53d8c
Author: Jason Wilkins
Date:   Fri Jun 27 05:20:31 2014 -0500
https://developer.blender.org/rB42beba3f739663857be068975f67149ef4d53d8c

(Showing My Work) Expanded GPU Module to Support Modern OpenGL

I am updating the GPU module so that it contains code needed for Blender to support a programmable shader based pipeline.

In an effort to make sure things always compile I've excluded most of the changes from 2013 that were made to gpu_codegen, gpu_draw, gpu_extensions, and gpu_material.

This new functionality is not used anywhere in Blender yet.  That will come gradually.

This is a bit rough because I wanted something in the repository before evaluations.  I wanted to break this into smaller more manageable pieces for code review, but that would take too much time.  However, this might still work for review purposes.

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

M	source/blender/gpu/CMakeLists.txt
A	source/blender/gpu/GPU_aspect.h
A	source/blender/gpu/GPU_basic.h
A	source/blender/gpu/GPU_blender_aspect.h
M	source/blender/gpu/GPU_buffers.h
A	source/blender/gpu/GPU_clipping.h
A	source/blender/gpu/GPU_colors.h
A	source/blender/gpu/GPU_common.h
A	source/blender/gpu/GPU_deprecated.h
M	source/blender/gpu/GPU_draw.h
M	source/blender/gpu/GPU_extensions.h
A	source/blender/gpu/GPU_font.h
M	source/blender/gpu/GPU_glew.h
A	source/blender/gpu/GPU_immediate.h
A	source/blender/gpu/GPU_init_exit.h
A	source/blender/gpu/GPU_lighting.h
M	source/blender/gpu/GPU_material.h
A	source/blender/gpu/GPU_matrix.h
A	source/blender/gpu/GPU_pixels.h
A	source/blender/gpu/GPU_primitives.h
A	source/blender/gpu/GPU_raster.h
A	source/blender/gpu/GPU_safety.h
A	source/blender/gpu/GPU_select.h
D	source/blender/gpu/GPU_simple_shader.h
A	source/blender/gpu/GPU_sprite.h
A	source/blender/gpu/GPU_state_latch.h
A	source/blender/gpu/GPU_utility.h
A	source/blender/gpu/intern/gpu_aspect.c
A	source/blender/gpu/intern/gpu_aspect_intern.h
A	source/blender/gpu/intern/gpu_basic.c
A	source/blender/gpu/intern/gpu_basic_intern.h
A	source/blender/gpu/intern/gpu_blender_aspect.c
A	source/blender/gpu/intern/gpu_blender_aspect_intern.h
A	source/blender/gpu/intern/gpu_buffers - Copy.c
A	source/blender/gpu/intern/gpu_clipping.c
A	source/blender/gpu/intern/gpu_clipping_intern.h
M	source/blender/gpu/intern/gpu_codegen.c
M	source/blender/gpu/intern/gpu_codegen.h
A	source/blender/gpu/intern/gpu_common.c
A	source/blender/gpu/intern/gpu_common_intern.h
A	source/blender/gpu/intern/gpu_debug.c
A	source/blender/gpu/intern/gpu_draw - Copy.c
M	source/blender/gpu/intern/gpu_draw.c
A	source/blender/gpu/intern/gpu_extensions - Copy.c
M	source/blender/gpu/intern/gpu_extensions.c
A	source/blender/gpu/intern/gpu_extensions_intern.h
A	source/blender/gpu/intern/gpu_font.c
A	source/blender/gpu/intern/gpu_font_intern.h
A	source/blender/gpu/intern/gpu_immediate.c
A	source/blender/gpu/intern/gpu_immediate_gl.c
A	source/blender/gpu/intern/gpu_immediate_intern.h
A	source/blender/gpu/intern/gpu_init_exit.c
A	source/blender/gpu/intern/gpu_lighting.c
A	source/blender/gpu/intern/gpu_lighting_intern.h
M	source/blender/gpu/intern/gpu_material.c
A	source/blender/gpu/intern/gpu_matrix.c
A	source/blender/gpu/intern/gpu_matrix_intern.h
A	source/blender/gpu/intern/gpu_pixels.c
A	source/blender/gpu/intern/gpu_pixels_intern.h
A	source/blender/gpu/intern/gpu_primitives.c
A	source/blender/gpu/intern/gpu_primitives_inline.h
A	source/blender/gpu/intern/gpu_profile.h
A	source/blender/gpu/intern/gpu_raster.c
A	source/blender/gpu/intern/gpu_raster_intern.h
A	source/blender/gpu/intern/gpu_safety.c
A	source/blender/gpu/intern/gpu_select.c
A	source/blender/gpu/intern/gpu_select_intern.h
D	source/blender/gpu/intern/gpu_simple_shader.c
A	source/blender/gpu/intern/gpu_sprite.c
A	source/blender/gpu/intern/gpu_sprite_intern.h
A	source/blender/gpu/intern/gpu_state_latch.c
A	source/blender/gpu/intern/gpu_state_latch_intern.h
A	source/blender/gpu/intern/gpu_utility.c
A	source/blender/gpu/shaders/gpu_shader_basic_frag.glsl
A	source/blender/gpu/shaders/gpu_shader_basic_vert.glsl
A	source/blender/gpu/shaders/gpu_shader_common_attribs.glsl
A	source/blender/gpu/shaders/gpu_shader_common_constants.glsl
A	source/blender/gpu/shaders/gpu_shader_common_uniforms.glsl
A	source/blender/gpu/shaders/gpu_shader_font_frag.glsl
A	source/blender/gpu/shaders/gpu_shader_font_vert.glsl
A	source/blender/gpu/shaders/gpu_shader_material - Copy.glsl
A	source/blender/gpu/shaders/gpu_shader_pixels_frag.glsl
A	source/blender/gpu/shaders/gpu_shader_pixels_uniforms.glsl
A	source/blender/gpu/shaders/gpu_shader_pixels_vert.glsl
A	source/blender/gpu/shaders/gpu_shader_raster_frag.glsl
A	source/blender/gpu/shaders/gpu_shader_raster_uniforms.glsl
A	source/blender/gpu/shaders/gpu_shader_raster_vert.glsl
D	source/blender/gpu/shaders/gpu_shader_simple_frag.glsl
D	source/blender/gpu/shaders/gpu_shader_simple_vert.glsl
A	source/blender/gpu/shaders/gpu_shader_vertex - Copy.glsl
M	source/blender/windowmanager/intern/wm_init_exit.c
A	source/blender/windowmanager/intern/wm_init_exit.c.0
A	source/blender/windowmanager/intern/wm_init_exit.c.orig
M	source/blender/windowmanager/intern/wm_window.c
A	source/blender/windowmanager/intern/wm_window.c.0
M	source/gameengine/GamePlayer/ghost/GPG_Application.cpp

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

diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 2035720..f59dd44 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -45,31 +45,125 @@ set(INC_SYS
 	${GLEW_INCLUDE_PATH}
 )
 
+set(INTERN_INC
+	intern/gpu_aspect_intern.h
+	intern/gpu_basic_intern.h
+	intern/gpu_blender_aspect_intern.h
+	intern/gpu_clipping_intern.h
+	intern/gpu_common_intern.h
+	intern/gpu_codegen.h
+	intern/gpu_extensions_intern.h
+	intern/gpu_immediate_intern.h
+	intern/gpu_lighting_intern.h
+	intern/gpu_pixels_intern.h
+	intern/gpu_primitives_inline.h
+	intern/gpu_profile.h
+	intern/gpu_raster_intern.h
+    intern/gpu_select_intern.h
+	intern/gpu_sprite_intern.h
+	intern/gpu_state_latch_intern.h
+)
+
+set(GLSL_SRC
+    shaders/gpu_shader_vertex.glsl
+    shaders/gpu_shader_material.glsl
+
+    shaders/gpu_shader_sep_gaussian_blur_frag.glsl
+    shaders/gpu_shader_sep_gaussian_blur_vert.glsl
+
+    shaders/gpu_shader_vsm_store_frag.glsl
+    shaders/gpu_shader_vsm_store_vert.glsl
+
+    shaders/gpu_shader_common_attribs.glsl
+    shaders/gpu_shader_common_constants.glsl
+    shaders/gpu_shader_common_uniforms.glsl
+
+    shaders/gpu_shader_font_frag.glsl
+    shaders/gpu_shader_font_vert.glsl
+
+    shaders/gpu_shader_pixels_uniforms.glsl
+    shaders/gpu_shader_pixels_frag.glsl
+    shaders/gpu_shader_pixels_vert.glsl
+
+    shaders/gpu_shader_basic_frag.glsl
+    shaders/gpu_shader_basic_vert.glsl
+
+    shaders/gpu_shader_raster_frag.glsl
+    shaders/gpu_shader_raster_uniforms.glsl
+    shaders/gpu_shader_raster_vert.glsl
+)
+
 set(SRC
+	intern/gpu_aspect.c
+	intern/gpu_basic.c
+	intern/gpu_blender_aspect.c
 	intern/gpu_buffers.c
+	intern/gpu_clipping.c
 	intern/gpu_codegen.c
+	intern/gpu_common.c
+	intern/gpu_debug.c
 	intern/gpu_draw.c
 	intern/gpu_extensions.c
+	intern/gpu_font.c
+	intern/gpu_immediate.c
+	intern/gpu_immediate_gl.c
+	intern/gpu_init_exit.c
+	intern/gpu_lighting.c
 	intern/gpu_material.c
-	intern/gpu_simple_shader.c
+	intern/gpu_matrix.c
+	intern/gpu_pixels.c
+	intern/gpu_primitives.c
+	intern/gpu_raster.c
+	intern/gpu_select.c
+	intern/gpu_sprite.c
+	intern/gpu_state_latch.c
+	intern/gpu_utility.c
 
+	GPU_aspect.h
+	GPU_basic.h
+	GPU_blender_aspect.h
 	GPU_buffers.h
+	GPU_clipping.h
+	GPU_colors.h
+	GPU_common.h
+	GPU_deprecated.h
 	GPU_draw.h
 	GPU_extensions.h
+	GPU_font.h
 	GPU_glew.h
+	GPU_init_exit.h
+	GPU_immediate.h
+	GPU_lighting.h
 	GPU_material.h
-	GPU_simple_shader.h
-	intern/gpu_codegen.h
+	GPU_matrix.h
+	GPU_pixels.h
+	GPU_primitives.h
+	GPU_raster.h
+	GPU_safety.h
+    GPU_select.h
+	GPU_sprite.h
+	GPU_state_latch.h
+	GPU_utility.h
+
+    ${INTERN_INC}
+    
+    ${GLSL_SRC}
 )
 
-data_to_c_simple(shaders/gpu_shader_material.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_sep_gaussian_blur_frag.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_sep_gaussian_blur_vert.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_simple_frag.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_simple_vert.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_vertex.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_vsm_store_frag.glsl SRC)
-data_to_c_simple(shaders/gpu_shader_vsm_store_vert.glsl SRC)
+if(WITH_GPU_SAFETY)
+	list(APPEND SRC
+		intern/gpu_safety.c
+	)
+endif()
+
+foreach(GLSL_FILE ${GLSL_SRC})
+    data_to_c_simple(${GLSL_FILE} SRC)
+    list(APPEND GEN_SRC "${CMAKE_CURRENT_BINARY_DIR}/${GLSL_FILE}.c")
+endforeach()
+
+source_group("Internal Header Files" FILES ${INTERN_INC})
+source_group("Generated Files"       FILES ${GEN_SRC})
+source_group("Shader Files"          FILES ${GLSL_SRC})
 
 if(WITH_GAMEENGINE)
 	add_definitions(-DWITH_GAMEENGINE)
@@ -79,8 +173,6 @@ if(WITH_MOD_SMOKE)
 	add_definitions(-DWITH_SMOKE)
 endif()
 
-add_definitions(-DGLEW_STATIC)
-
 if(WITH_IMAGE_DDS)
 	add_definitions(-DWITH_DDS)
 endif()
diff --git a/source/blender/gpu/GPU_aspect.h b/source/blender/gpu/GPU_aspect.h
new file mode 100644
index 0000000..5132797
--- /dev/null
+++ b/source/blender/gpu/GPU_aspect.h
@@ -0,0 +1,73 @@
+#ifndef _GPU_ASPECT_H_
+#define _GPU_ASPECT_H_
+
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Jason Wilkins.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_aspect.h
+  *  \ingroup gpu
+  */
+
+#include "BLI_sys_types.h"
+
+#include <string.h> /* for size_t */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GPU_gen_aspects   (size_t count,       uint32_t* aspects);
+void GPU_delete_aspects(size_t count, const uint32_t* aspects);
+
+typedef struct GPUaspectimpl {
+	bool  (*render_begin )(const void* object, void* param);
+	bool  (*render_end   )(const void* object, void* param);
+	bool  (*render_commit)(const void* object);
+	bool  (*select_begin )(const void* object, void* param);
+	bool  (*select_end   )(const void* object, void* param);
+	bool  (*select_commit)(const void* object);
+	void  (*enable       )(const void* object, uint32_t options);
+	void  (*disable      )(const void* object, uint32_t options);
+	void* object;
+	void* current_param; /* not a part of the interface */
+} GPUaspectimpl;
+
+void GPU_aspect_impl(uint32_t aspect, GPUaspectimpl* aspectImpl);
+
+bool GPU_aspect_begin(uint32_t aspect, void* param);
+bool GPU_aspect_end  (void);
+
+void GPU_aspect_enable (uint32_t aspect, uint32_t options);
+void GPU_aspect_disable(uint32_t aspect, uint32_t options);
+
+bool GPU_commit_aspect(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GPU_ASPECT_H_ */
diff --git a/source/blender/gpu/GPU_basic.h b/source/blender/gpu/GPU_basic.h
new file mode 100644
index 0000000..161ad6b
--- /dev/null
+++ b/source/blender/gpu/GPU_basic.h
@@ -0,0 +1,70 @@
+#ifndef _GPU_BASIC_H_
+#define _GPU_BASIC_H_
+
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Brecht Van Lommel, Jason Wilkins.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file source/blender/gpu/GPU_basic.h
+ *  \ingroup gpu
+ */
+
+#include "BLI_sys_types.h" /* for bool */
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+typedef enum GPUBasicOption {
+	GPU_BASIC_LIGHTING       = (1<<0), /* do lighting computations                */
+	GPU_BASIC_TWO_SIDE       = (1<<1), /* flip back-facing normals towards viewer */
+	GPU_BASIC_TEXTURE_2D     = (1<<2), /* use 2D texture to replace diffuse color */
+	GPU_BASIC_LOCAL_VIEWER   = (1<<3), /* use for orthographic projection         */
+	GPU_BASIC_SMOOTH         = (1<<4), /* use smooth shading                      */
+	GPU_BASIC_ALPHATEST      = (1<<5), /* use alpha test                          */
+	GPU_BASIC_CLIPPING       = (1<<6), /* use clipping                            */
+
+	GPU_BASIC_FAST_LIGHTING  = (1<<7), /* use faster lighting (set automatically) */
+
+	GPU_BASIC_OPTIONS_NUM         = 8,
+	GPU_BASIC_OPTION_COMBINATIONS = (1<<GPU_BASIC_OPTIONS_NUM)
+} GPUBasicOption;
+
+
+
+bool GPU_basic_needs_normals(void);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GPU_BASIC_H_ */
diff --git a/source/blender/gpu/GPU_blender_aspect.h b/source/blender/gpu/GPU_blender_aspect.h
new file mode 100644
index 0000000..41b5e68
--- /dev/null
+++ b/source/blender/gpu/GPU_blender_aspect.h
@@ -0,0 +1,55 @@
+#ifndef _GPU_BLENDER_ASPECT_H_
+#define _GPU_BLENDER_ASPECT_H_
+
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Jason Wilkins.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/gpu/GPU_blender_aspect.h
+ *  \ingroup gpu
+ */
+
+#include "GPU_aspect.h"
+
+
+
+extern uint32_t GPU_ASPECT_BASIC;
+extern uint32_t GPU_ASPECT_CODEGEN;
+extern uint32_t GPU_ASPECT_FONT;
+extern uint32_t GPU_ASPECT_PIX

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list