[Bf-blender-cvs] [18753e3167e] temp-gpu-compute-shaders: Revert "Use GPUBatch to handle compute pipeline."
Jeroen Bakker
noreply at git.blender.org
Fri Apr 23 10:26:21 CEST 2021
Commit: 18753e3167ee7cde146c84a59fafd0db47b5d507
Author: Jeroen Bakker
Date: Fri Apr 9 10:34:06 2021 +0200
Branches: temp-gpu-compute-shaders
https://developer.blender.org/rB18753e3167ee7cde146c84a59fafd0db47b5d507
Revert "Use GPUBatch to handle compute pipeline."
This reverts commit 982e8ef6fdd811cda953cb2f20e7f4e565126f80.
===================================================================
M source/blender/gpu/CMakeLists.txt
M source/blender/gpu/GPU_batch.h
M source/blender/gpu/intern/gpu_backend.hh
M source/blender/gpu/intern/gpu_batch.cc
M source/blender/gpu/intern/gpu_batch_private.hh
A source/blender/gpu/intern/gpu_compute.cc
M source/blender/gpu/opengl/gl_backend.hh
M source/blender/gpu/opengl/gl_batch.cc
M source/blender/gpu/opengl/gl_batch.hh
A source/blender/gpu/opengl/gl_compute.cc
A source/blender/gpu/opengl/gl_compute.hh
M source/blender/gpu/tests/gpu_shader_test.cc
===================================================================
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 867483b0285..fda31441d2b 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -62,6 +62,7 @@ set(SRC
intern/gpu_buffers.c
intern/gpu_capabilities.cc
intern/gpu_codegen.c
+ intern/gpu_compute.cc
intern/gpu_context.cc
intern/gpu_debug.cc
intern/gpu_drawlist.cc
@@ -91,6 +92,7 @@ set(SRC
opengl/gl_backend.cc
opengl/gl_batch.cc
+ opengl/gl_compute.cc
opengl/gl_context.cc
opengl/gl_debug.cc
opengl/gl_debug_layer.cc
@@ -113,6 +115,7 @@ set(SRC
GPU_buffers.h
GPU_capabilities.h
GPU_common.h
+ GPU_compute.h
GPU_context.h
GPU_debug.h
GPU_drawlist.h
@@ -163,6 +166,7 @@ set(SRC
opengl/gl_backend.hh
opengl/gl_batch.hh
+ opengl/gl_compute.hh
opengl/gl_context.hh
opengl/gl_debug.hh
opengl/gl_drawlist.hh
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index da4214481d9..018e192bf37 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -105,8 +105,6 @@ void GPU_batch_init_ex(GPUBatch *batch,
void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch *batch_src);
#define GPU_batch_create(prim, verts, elem) GPU_batch_create_ex(prim, verts, elem, 0)
-#define GPU_batch_compute_create() \
- GPU_batch_create_ex(GPU_PRIM_NONE, NULL, NULL, GPU_BATCH_OWNS_NONE)
#define GPU_batch_init(batch, prim, verts, elem) GPU_batch_init_ex(batch, prim, verts, elem, 0)
/* Same as discard but does not free. (does not call free callback). */
@@ -150,15 +148,11 @@ void GPU_batch_program_set_builtin_with_config(GPUBatch *batch,
GPU_shader_uniform_mat4((batch)->shader, name, val);
#define GPU_batch_texture_bind(batch, name, tex) \
GPU_texture_bind(tex, GPU_shader_get_texture_binding((batch)->shader, name));
-#define GPU_batch_texture_image_bind(batch, name, tex) \
- GPU_texture_image_bind(tex, GPU_shader_get_texture_binding((batch)->shader, name));
void GPU_batch_draw(GPUBatch *batch);
void GPU_batch_draw_range(GPUBatch *batch, int v_first, int v_count);
void GPU_batch_draw_instanced(GPUBatch *batch, int i_count);
-void GPU_batch_compute(GPUBatch *batch, uint group_x_len, uint group_y_len, uint group_z_len);
-
/* This does not bind/unbind shader and does not call GPU_matrix_bind() */
void GPU_batch_draw_advanced(GPUBatch *, int v_first, int v_count, int i_first, int i_count);
diff --git a/source/blender/gpu/intern/gpu_backend.hh b/source/blender/gpu/intern/gpu_backend.hh
index 04ec82a9213..73792215569 100644
--- a/source/blender/gpu/intern/gpu_backend.hh
+++ b/source/blender/gpu/intern/gpu_backend.hh
@@ -47,6 +47,7 @@ class GPUBackend {
static GPUBackend *get(void);
virtual void samplers_update(void) = 0;
+ virtual void compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len) = 0;
virtual Context *context_alloc(void *ghost_window) = 0;
diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc
index f0bcca7b07b..9dc24c59e22 100644
--- a/source/blender/gpu/intern/gpu_batch.cc
+++ b/source/blender/gpu/intern/gpu_batch.cc
@@ -73,7 +73,7 @@ void GPU_batch_init_ex(GPUBatch *batch,
GPUIndexBuf *elem,
eGPUBatchFlag owns_flag)
{
- BLI_assert(verts != nullptr || prim_type == GPU_PRIM_NONE);
+ BLI_assert(verts != nullptr);
/* Do not pass any other flag */
BLI_assert((owns_flag & ~(GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX)) == 0);
@@ -284,24 +284,6 @@ void GPU_batch_draw_advanced(
/** \} */
-/* -------------------------------------------------------------------- */
-/** \name Drawing / Drawcall functions
- * \{ */
-
-void GPU_batch_compute(GPUBatch *gpu_batch, uint group_x_len, uint group_y_len, uint group_z_len)
-{
- BLI_assert(gpu_batch);
- Batch *batch = static_cast<Batch *>(gpu_batch);
-
- BLI_assert(batch->prim_type == GPU_PRIM_NONE);
- BLI_assert(Context::get()->shader != nullptr);
-
- GPU_shader_bind(batch->shader);
- batch->compute(group_x_len, group_y_len, group_z_len);
-}
-
-/** \} */
-
/* -------------------------------------------------------------------- */
/** \name Utilities
* \{ */
diff --git a/source/blender/gpu/intern/gpu_batch_private.hh b/source/blender/gpu/intern/gpu_batch_private.hh
index 4b02477ee37..d0fbd1432b3 100644
--- a/source/blender/gpu/intern/gpu_batch_private.hh
+++ b/source/blender/gpu/intern/gpu_batch_private.hh
@@ -46,7 +46,6 @@ class Batch : public GPUBatch {
virtual ~Batch(){};
virtual void draw(int v_first, int v_count, int i_first, int i_count) = 0;
- virtual void compute(uint group_x_len, uint group_y_len, uint group_z_len) = 0;
/* Convenience casts. */
IndexBuf *elem_(void) const
diff --git a/source/blender/gpu/intern/gpu_compute.cc b/source/blender/gpu/intern/gpu_compute.cc
new file mode 100644
index 00000000000..e07a17d14a4
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_compute.cc
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup gpu
+ */
+
+#include "GPU_compute.h"
+
+#include "gpu_backend.hh"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GPU_compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len)
+{
+ blender::gpu::GPUBackend &gpu_backend = *blender::gpu::GPUBackend::get();
+ gpu_backend.compute_dispatch(groups_x_len, groups_y_len, groups_z_len);
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/gpu/opengl/gl_backend.hh b/source/blender/gpu/opengl/gl_backend.hh
index 231e5811b45..7a11a11dd8f 100644
--- a/source/blender/gpu/opengl/gl_backend.hh
+++ b/source/blender/gpu/opengl/gl_backend.hh
@@ -28,6 +28,7 @@
#include "BLI_vector.hh"
#include "gl_batch.hh"
+#include "gl_compute.hh"
#include "gl_context.hh"
#include "gl_drawlist.hh"
#include "gl_framebuffer.hh"
@@ -126,6 +127,11 @@ class GLBackend : public GPUBackend {
return shared_orphan_list_;
};
+ void compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len) override
+ {
+ GLCompute::dispatch(groups_x_len, groups_y_len, groups_z_len);
+ }
+
private:
static void platform_init(void);
static void platform_exit(void);
diff --git a/source/blender/gpu/opengl/gl_batch.cc b/source/blender/gpu/opengl/gl_batch.cc
index ae2172c3630..321d9552828 100644
--- a/source/blender/gpu/opengl/gl_batch.cc
+++ b/source/blender/gpu/opengl/gl_batch.cc
@@ -363,16 +363,3 @@ void GLBatch::draw(int v_first, int v_count, int i_first, int i_count)
}
/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Compute
- * \{ */
-
-void GLBatch::compute(uint group_x_len, uint group_y_len, uint group_z_len)
-{
- GLContext::get()->state_manager->apply_state();
- glDispatchCompute(group_x_len, group_y_len, group_z_len);
- debug::check_gl_error("Dispatch Compute");
-}
-
-/** \} */
diff --git a/source/blender/gpu/opengl/gl_batch.hh b/source/blender/gpu/opengl/gl_batch.hh
index 557fa5b53d4..218b9ffe4b7 100644
--- a/source/blender/gpu/opengl/gl_batch.hh
+++ b/source/blender/gpu/opengl/gl_batch.hh
@@ -100,7 +100,6 @@ class GLBatch : public Batch {
~GLBatch();
void draw(int v_first, int v_count, int i_first, int i_count) override;
- void compute(uint group_x_len, uint group_y_len, uint group_z_len) override;
void bind(int i_first);
/* Convenience getters. */
diff --git a/source/blender/gpu/opengl/gl_compute.cc b/source/blender/gpu/opengl/gl_compute.cc
new file mode 100644
index 00000000000..fa8317dde4a
--- /dev/null
+++ b/source/blender/gpu/opengl/gl_compute.cc
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup gpu
+ */
+
+#include "gl_compute.hh"
+
+#include "gl_debug.hh"
+
+#include "glew-mx.h"
+
+namespace blender::gpu {
+
+void GLCompute::dispatch(int group_x_len, int group_y_len, int group_z_len)
+{
+ glDispatchCompute(group_x_len, group_y_len, group_z_len);
+ debug::check_gl_error("Dispatch Compute");
+}
+
+} // namespace blender::gpu
diff --git a/source/blender/gpu/opengl/gl_compute.hh b/source/blender/gpu/opengl/gl_compute.hh
new file mode 100644
index 00000000000..2fd918ddd10
--- /dev/null
+++ b/source/blender/gpu/opengl/gl_compute.hh
@@ -0,0 +1,30 @@
+/*
+ * 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
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list