[Bf-blender-cvs] [09431033e9e] blender2.8: Cleanup: split GPU_batch

Campbell Barton noreply at git.blender.org
Sun Jul 15 10:52:29 CEST 2018


Commit: 09431033e9e2defcea42ffe056632b4bf4fd7a2a
Author: Campbell Barton
Date:   Sun Jul 15 10:34:31 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB09431033e9e2defcea42ffe056632b4bf4fd7a2a

Cleanup: split GPU_batch

Split out presets and utilities for creating batches.
These functions are quite specialized and not related to typical usage.

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

M	source/blender/draw/intern/draw_cache.c
M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/gpu/CMakeLists.txt
M	source/blender/gpu/GPU_batch.h
A	source/blender/gpu/GPU_batch_presets.h
A	source/blender/gpu/GPU_batch_utils.h
M	source/blender/gpu/intern/gpu_batch.c
M	source/blender/gpu/intern/gpu_batch_presets.c
A	source/blender/gpu/intern/gpu_batch_utils.c
M	source/blender/windowmanager/intern/wm_window.c

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

diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 2251285be74..1bf40673239 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -39,6 +39,8 @@
 #include "BLI_math.h"
 
 #include "GPU_batch.h"
+#include "GPU_batch_presets.h"
+#include "GPU_batch_utils.h"
 
 #include "draw_cache.h"
 #include "draw_cache_impl.h"
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index ce72a5ffc9f..90f9b2e0569 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -50,6 +50,7 @@
 #include "BIF_gl.h"
 
 #include "GPU_batch.h"
+#include "GPU_batch_presets.h"
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
index 33639dd7ec7..ede070f0bed 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
@@ -45,6 +45,7 @@
 #include "GPU_matrix.h"
 #include "GPU_select.h"
 #include "GPU_batch.h"
+#include "GPU_batch_utils.h"
 #include "GPU_state.h"
 
 #include "RNA_access.h"
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 0a8a6d1f832..51f2c7e8ece 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -55,6 +55,7 @@
 #include "BLF_api.h"
 
 #include "GPU_batch.h"
+#include "GPU_batch_presets.h"
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 03ff6593c59..fea88388be7 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -55,6 +55,7 @@
 
 #include "GPU_basic_shader.h"
 #include "GPU_batch.h"
+#include "GPU_batch_presets.h"
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 33515ebc645..97b112ebbd1 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -54,6 +54,7 @@
 
 #include "GPU_draw.h"
 #include "GPU_batch.h"
+#include "GPU_batch_presets.h"
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
 #include "GPU_state.h"
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 3b86e574a1a..be79cef182d 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -74,6 +74,7 @@
 #include "DEG_depsgraph_query.h"
 
 #include "GPU_batch.h"
+#include "GPU_batch_presets.h"
 #include "GPU_draw.h"
 #include "GPU_matrix.h"
 #include "GPU_immediate.h"
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 27977c16b51..716e00164ce 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -61,6 +61,7 @@ set(SRC
 	intern/gpu_basic_shader.c
 	intern/gpu_batch.c
 	intern/gpu_batch_presets.c
+	intern/gpu_batch_utils.c
 	intern/gpu_buffers.c
 	intern/gpu_codegen.c
 	intern/gpu_debug.c
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index b706bdbf189..f73968eda54 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -34,8 +34,6 @@
 #include "../../../intern/gawain/gawain/gwn_batch.h"
 #include "../../../intern/gawain/gawain/gwn_batch_private.h"
 
-struct rctf;
-
 // TODO: CMake magic to do this:
 // #include "gawain/batch.h"
 
@@ -44,31 +42,10 @@ struct rctf;
 
 #include "GPU_shader.h"
 
-/* Extend GWN_batch_program_set to use Blender’s library of built-in shader programs. */
-
 /* gpu_batch.c */
 void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id) ATTR_NONNULL(1);
 
-Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded(
-        const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
-        ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
-Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded(
-        const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
-        ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
-
 void gpu_batch_init(void);
 void gpu_batch_exit(void);
 
-/* gpu_batch_presets.c */
-/* Only use by draw manager. Use the presets function instead for interface. */
-Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT;
-/* Replacement for gluSphere */
-Gwn_Batch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT;
-Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT;
-
-void gpu_batch_presets_init(void);
-void gpu_batch_presets_register(Gwn_Batch *preset_batch);
-void gpu_batch_presets_reset(void);
-void gpu_batch_presets_exit(void);
-
 #endif  /* __GPU_BATCH_H__ */
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch_presets.h
similarity index 51%
copy from source/blender/gpu/GPU_batch.h
copy to source/blender/gpu/GPU_batch_presets.h
index b706bdbf189..2450a1760c3 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch_presets.h
@@ -28,47 +28,25 @@
  * This file contains any additions or modifications specific to Blender.
  */
 
-#ifndef __GPU_BATCH_H__
-#define __GPU_BATCH_H__
-
-#include "../../../intern/gawain/gawain/gwn_batch.h"
-#include "../../../intern/gawain/gawain/gwn_batch_private.h"
+#ifndef __GPU_BATCH_PRESETS_H__
+#define __GPU_BATCH_PRESETS_H__
 
 struct rctf;
-
-// TODO: CMake magic to do this:
-// #include "gawain/batch.h"
+struct Gwn_VertFormat;
 
 #include "BLI_compiler_attrs.h"
 #include "BLI_sys_types.h"
 
-#include "GPU_shader.h"
-
-/* Extend GWN_batch_program_set to use Blender’s library of built-in shader programs. */
-
-/* gpu_batch.c */
-void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id) ATTR_NONNULL(1);
-
-Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded(
-        const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
-        ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
-Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded(
-        const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
-        ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
-
-void gpu_batch_init(void);
-void gpu_batch_exit(void);
-
 /* gpu_batch_presets.c */
-/* Only use by draw manager. Use the presets function instead for interface. */
-Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT;
+struct Gwn_VertFormat *GPU_batch_preset_format_3d(void);
+
 /* Replacement for gluSphere */
-Gwn_Batch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT;
-Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT;
+struct Gwn_Batch *GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT;
+struct Gwn_Batch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT;
 
 void gpu_batch_presets_init(void);
-void gpu_batch_presets_register(Gwn_Batch *preset_batch);
+void gpu_batch_presets_register(struct Gwn_Batch *preset_batch);
 void gpu_batch_presets_reset(void);
 void gpu_batch_presets_exit(void);
 
-#endif  /* __GPU_BATCH_H__ */
+#endif  /* __GPU_BATCH_PRESETS_H__ */
diff --git a/source/blender/gpu/GPU_batch_utils.h b/source/blender/gpu/GPU_batch_utils.h
new file mode 100644
index 00000000000..b23b7723dc0
--- /dev/null
+++ b/source/blender/gpu/GPU_batch_utils.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 *****
+ */
+
+#ifndef __GPU_BATCH_UTILS_H__
+#define __GPU_BATCH_UTILS_H__
+
+struct rctf;
+
+#include "BLI_compiler_attrs.h"
+#include "BLI_sys_types.h"
+
+/* gpu_batch_utils.c */
+struct Gwn_Batch *GPU_batch_tris_from_poly_2d_encoded(
+        const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
+        ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+struct Gwn_Batch *GPU_batch_wire_from_poly_2d_encoded(
+        const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect
+        ) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+
+/* Only use by draw manager. Use the presets function instead for interface. */
+struct Gwn_Batch *gpu_batch_sphere(int lat_res, int lon_res) ATTR_WARN_UNUSED_RESULT;
+
+#endif  /* __GPU_BATCH_UTILS_H__ */
diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c
index 391a3812073..5bfd20e3c8b 100644
--- a/source/blender/gpu/intern/gpu_batch.c
+++ b/source/blender/gpu/intern/gpu_batch.c
@@ -37,8 +37,8 @@
 #include "BLI_polyfill_2d.h"
 #include "BLI_sort_utils.h"
 
-
 #include "GPU_batch.h"  /* own include */
+#include "GPU_batch_presets.h"
 #include "gpu_shader_private.h"
 
 /* -------------------------------------------------------------------- */
@@ -53,216 +53,6 @@ void GWN_batch_program_set_builtin(Gwn_Batch *batch, GPUBuiltinShader shader_id)
 
 /** \} */
 
-
-
-/* -------------------------------------------------------------------- */
-/** \name Batch Creation
- * \{ */
-
-/**
- * Creates triangles from a byte-array of polygons.
- *
- * See 'make_shape_2d_from_blend.py' utility to create data to pass to this fun

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list