Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2016-09-15 19:41:28 +0300
committerMike Erwin <significant.bit@gmail.com>2016-09-15 19:41:28 +0300
commit5eddb8051382aa4406f6fb33b3eb0f748c6d1911 (patch)
tree186c1783c89e23d7f6cf4d42055ecd8c34c169fb /source
parent39f7a8117692da3a6645ccb7ae2080077f9e5980 (diff)
Extend Gawain to use Blender's built-in shaders
Was already done for immediate mode, but rearranged code to make a clean separation. Cleaned up #includes for code that uses this feature. Added same for batched rendering.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_draw.c1
-rw-r--r--source/blender/editors/interface/interface_widgets.c1
-rw-r--r--source/blender/editors/screen/area.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c1
-rw-r--r--source/blender/gpu/CMakeLists.txt2
-rw-r--r--source/blender/gpu/GPU_batch.h4
-rw-r--r--source/blender/gpu/GPU_immediate.h5
-rw-r--r--source/blender/gpu/GPU_shader.h4
-rw-r--r--source/blender/gpu/intern/gpu_batch.c35
-rw-r--r--source/blender/gpu/intern/gpu_immediate.c35
-rw-r--r--source/blender/gpu/intern/gpu_shader.c23
-rw-r--r--source/blender/gpu/intern/gpu_shader_private.h40
12 files changed, 122 insertions, 30 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index c6f7224fbf0..5ee05a46ada 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -57,7 +57,6 @@
#include "GPU_draw.h"
#include "GPU_basic_shader.h"
-#include "GPU_shader.h"
#include "GPU_immediate.h"
#include "UI_interface.h"
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index f3c0b7225dd..0ae4c7eed50 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -58,7 +58,6 @@
#include "interface_intern.h"
#include "GPU_basic_shader.h"
-#include "GPU_shader.h"
#include "GPU_immediate.h"
#ifdef WITH_INPUT_IME
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 0924f02c8ed..574f8871e53 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -57,7 +57,6 @@
#include "ED_screen_types.h"
#include "ED_space_api.h"
-#include "GPU_shader.h"
#include "GPU_immediate.h"
#include "BIF_gl.h"
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index e3b32ebdbb2..77f19d353e9 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -100,7 +100,6 @@
#include "GPU_material.h"
#include "GPU_compositing.h"
#include "GPU_extensions.h"
-#include "GPU_shader.h"
#include "GPU_immediate.h"
#include "view3d_intern.h" /* own include */
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 63ae58dad59..6d3052b1190 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -47,6 +47,7 @@ set(INC_SYS
set(SRC
intern/gpu_basic_shader.c
+ intern/gpu_batch.c
intern/gpu_buffers.c
intern/gpu_codegen.c
intern/gpu_compositing.c
@@ -54,6 +55,7 @@ set(SRC
intern/gpu_draw.c
intern/gpu_extensions.c
intern/gpu_framebuffer.c
+ intern/gpu_immediate.c
intern/gpu_init_exit.c
intern/gpu_material.c
intern/gpu_select.c
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 10b00c3375f..bc3017e2784 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -31,3 +31,7 @@
#pragma once
#include "gawain/batch.h"
+#include "GPU_shader.h"
+
+/* Extend Batch_set_program to use Blender’s library of built-in shader programs. */
+void Batch_set_builtin_program(Batch*, GPUBuiltinShader);
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index 8b882751aca..7c4b1614f37 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -31,3 +31,8 @@
#pragma once
#include "gawain/immediate.h"
+#include "GPU_shader.h"
+
+/* Extend immBindProgram to use Blender’s library of built-in shader programs.
+ * Use immUnbindProgram() when done. */
+void immBindBuiltinProgram(GPUBuiltinShader);
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index 2a1c5e0e748..196b0ec71f8 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -106,10 +106,6 @@ GPUShader *GPU_shader_get_builtin_fx_shader(int effects, bool persp);
void GPU_shader_free_builtin_shaders(void);
-/* Extend Gawain’s immBindProgram to use Blender’s library of built-in shader programs.
- * Use immUnbindProgram() when done. */
-void immBindBuiltinProgram(GPUBuiltinShader);
-
/* Vertex attributes for shaders */
#define GPU_MAX_ATTRIB 32
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
new file mode 100644
index 00000000000..23f9f68f1aa
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -0,0 +1,35 @@
+/*
+ * ***** 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) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Mike Erwin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "GPU_batch.h"
+#include "gpu_shader_private.h"
+
+void Batch_set_builtin_program(Batch* batch, GPUBuiltinShader shader_id)
+{
+ GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
+ Batch_set_program(batch, shader->program);
+}
diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c
new file mode 100644
index 00000000000..0fc42533475
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_immediate.c
@@ -0,0 +1,35 @@
+/*
+ * ***** 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) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Mike Erwin
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "GPU_immediate.h"
+#include "gpu_shader_private.h"
+
+void immBindBuiltinProgram(GPUBuiltinShader shader_id)
+{
+ GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
+ immBindProgram(shader->program);
+}
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c
index 9fe3c3a6afb..e9a5732950a 100644
--- a/source/blender/gpu/intern/gpu_shader.c
+++ b/source/blender/gpu/intern/gpu_shader.c
@@ -36,10 +36,9 @@
#include "GPU_compositing.h"
#include "GPU_debug.h"
#include "GPU_extensions.h"
-#include "GPU_glew.h"
#include "GPU_shader.h"
+#include "GPU_shader_private.h"
#include "GPU_texture.h"
-#include "GPU_immediate.h"
/* TODO(sergey): Find better default values for this constants. */
#define MAX_DEFINE_LENGTH 1024
@@ -95,20 +94,6 @@ static struct GPUShadersGlobal {
} shaders;
} GG = {{NULL}};
-/* GPUShader */
-
-struct GPUShader {
- GLuint program; /* handle for full program (links shader stages below) */
-
- GLuint vertex; /* handle for vertex shader */
- GLuint geometry; /* handle for geometry shader */
- GLuint fragment; /* handle for fragment shader */
-
- int totattrib; /* total number of attributes */
- int uniforms; /* required uniforms */
-
- void *uniform_interface; /* cached uniform interface for shader. Data depends on shader */
-};
static void shader_print_errors(const char *task, const char *log, const char **code, int totcode)
{
@@ -828,9 +813,3 @@ void GPU_shader_free_builtin_shaders(void)
}
}
}
-
-void immBindBuiltinProgram(GPUBuiltinShader shader_id)
-{
- GPUShader *shader = GPU_shader_get_builtin_shader(shader_id);
- immBindProgram(shader->program);
-}
diff --git a/source/blender/gpu/intern/gpu_shader_private.h b/source/blender/gpu/intern/gpu_shader_private.h
new file mode 100644
index 00000000000..d5193e09aa4
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_shader_private.h
@@ -0,0 +1,40 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file gpu_shader_private.h
+ * \ingroup gpu
+ */
+
+#pragma once
+
+#include "GPU_glew.h"
+
+struct GPUShader {
+ GLuint program; /* handle for full program (links shader stages below) */
+
+ GLuint vertex; /* handle for vertex shader */
+ GLuint geometry; /* handle for geometry shader */
+ GLuint fragment; /* handle for fragment shader */
+
+ int totattrib; /* total number of attributes */
+ int uniforms; /* required uniforms */
+
+ void *uniform_interface; /* cached uniform interface for shader. Data depends on shader */
+};