[Bf-blender-cvs] [d88af2c8110] temp-gpu-compute-shaders: Added missing function body.

Jeroen Bakker noreply at git.blender.org
Thu Apr 8 18:56:49 CEST 2021


Commit: d88af2c8110a0088e2e32e0ab1702fe466653fb9
Author: Jeroen Bakker
Date:   Thu Apr 8 08:57:30 2021 +0200
Branches: temp-gpu-compute-shaders
https://developer.blender.org/rBd88af2c8110a0088e2e32e0ab1702fe466653fb9

Added missing function body.

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

M	source/blender/gpu/intern/gpu_compute.cc
M	source/blender/gpu/opengl/gl_shader.cc
M	source/blender/gpu/tests/gpu_shader_test.cc

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

diff --git a/source/blender/gpu/intern/gpu_compute.cc b/source/blender/gpu/intern/gpu_compute.cc
index f6f70be5efb..4befa1c62ee 100644
--- a/source/blender/gpu/intern/gpu_compute.cc
+++ b/source/blender/gpu/intern/gpu_compute.cc
@@ -19,7 +19,7 @@
  */
 
 #include "GPU_compute.h"
-#include "GPU_context.h"
+#include "gpu_backend.hh"
 
 #ifdef __cplusplus
 extern "C" {
@@ -27,7 +27,8 @@ extern "C" {
 
 void GPU_compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len)
 {
-  GPUContext &gpu_context = *GPU_context_active_get();
+  blender::gpu::GPUBackend &gpu_backend = *blender::gpu::GPUBackend::get();
+  gpu_backend.compute_dispatch(groups_x_len, groups_y_len, groups_z_len);
 }
 
 #ifdef __cplusplus
diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc
index 675098ee1c7..0e1da0907e5 100644
--- a/source/blender/gpu/opengl/gl_shader.cc
+++ b/source/blender/gpu/opengl/gl_shader.cc
@@ -123,7 +123,8 @@ static char *glsl_patch_compute_get()
   size_t slen = 0;
   /* Version need to go first. */
   STR_CONCAT(patch, slen, "#version 430\n");
-
+  STR_CONCAT(patch, slen, "#extension GL_ARB_compute_shader :enable\n");
+  // STR_CONCAT(patch, slen, "#extension GL_ARB_shader_storage_buffer_object : enable\n");
   BLI_assert(slen < sizeof(patch));
   return patch;
 }
diff --git a/source/blender/gpu/tests/gpu_shader_test.cc b/source/blender/gpu/tests/gpu_shader_test.cc
index c693d985370..2dc5a4485f3 100644
--- a/source/blender/gpu/tests/gpu_shader_test.cc
+++ b/source/blender/gpu/tests/gpu_shader_test.cc
@@ -2,6 +2,8 @@
 
 #include "testing/testing.h"
 
+#include <math.h>
+
 #include "GPU_capabilities.h"
 #include "GPU_compute.h"
 #include "GPU_shader.h"
@@ -56,6 +58,21 @@ void main() {
   float *data = static_cast<float *>(GPU_texture_read(texture, GPU_DATA_FLOAT, 0));
   EXPECT_NE(data, nullptr);
 
+  int index = 0;
+  for (int x = 0; x < WIDTH; x++) {
+    for (int y = 0; y < HEIGHT; y++) {
+      float value = data[index++];
+      float local_x = (x - 8) / 8.0f;
+      float local_y = (y - 8) / 8.0f;
+      float local_coef = sqrtf(local_x * local_x + local_y * local_y);
+
+      float global_coef = 0.0f;
+
+      float expected_value = 0.0f;
+      EXPECT_FLOAT_EQ(value, expected_value);
+    }
+  }
+
   for (int index = 0; index < WIDTH * HEIGHT; index++) {
     printf("%d: %f\n", index, data[index]);
   }



More information about the Bf-blender-cvs mailing list