[Bf-blender-cvs] [501d064ee92] lanpr-under-gp: Cleanup: GPU: Remove unused attr_binding and primitive code

Clément Foucault noreply at git.blender.org
Mon Aug 31 16:23:58 CEST 2020


Commit: 501d064ee92225b6ca1bc69f474d7a7ff28773b1
Author: Clément Foucault
Date:   Mon Aug 31 15:09:15 2020 +0200
Branches: lanpr-under-gp
https://developer.blender.org/rB501d064ee92225b6ca1bc69f474d7a7ff28773b1

Cleanup: GPU: Remove unused attr_binding and primitive code

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

M	source/blender/draw/intern/draw_instance_data.c
M	source/blender/gpu/CMakeLists.txt
D	source/blender/gpu/GPU_attr_binding.h
M	source/blender/gpu/GPU_primitive.h
D	source/blender/gpu/intern/gpu_attr_binding.cc
D	source/blender/gpu/intern/gpu_attr_binding_private.h
M	source/blender/gpu/intern/gpu_batch.cc
M	source/blender/gpu/intern/gpu_immediate.cc
D	source/blender/gpu/intern/gpu_primitive.c
D	source/blender/gpu/intern/gpu_primitive_private.h
M	source/blender/gpu/opengl/gl_batch.cc
M	source/blender/gpu/opengl/gl_drawlist.cc

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

diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 4e08e6e5129..9d0727555b6 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -38,8 +38,6 @@
 #include "BLI_utildefines.h"
 #include "MEM_guardedalloc.h"
 
-#include "intern/gpu_primitive_private.h"
-
 struct DRWInstanceData {
   struct DRWInstanceData *next;
   bool used;        /* If this data is used or not. */
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 6dadde398b9..549a7585e1b 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -55,7 +55,6 @@ set(INC_SYS
 )
 
 set(SRC
-  intern/gpu_attr_binding.cc
   intern/gpu_batch.cc
   intern/gpu_batch_presets.c
   intern/gpu_batch_utils.c
@@ -75,7 +74,6 @@ set(SRC
   intern/gpu_matrix.cc
   intern/gpu_node_graph.c
   intern/gpu_platform.cc
-  intern/gpu_primitive.c
   intern/gpu_select.c
   intern/gpu_select_pick.c
   intern/gpu_select_sample_query.c
@@ -100,7 +98,6 @@ set(SRC
   opengl/gl_uniform_buffer.cc
   opengl/gl_vertex_array.cc
 
-  GPU_attr_binding.h
   GPU_batch.h
   GPU_batch_presets.h
   GPU_batch_utils.h
@@ -130,7 +127,6 @@ set(SRC
   GPU_vertex_format.h
   GPU_viewport.h
 
-  intern/gpu_attr_binding_private.h
   intern/gpu_backend.hh
   intern/gpu_batch_private.hh
   intern/gpu_codegen.h
@@ -141,7 +137,6 @@ set(SRC
   intern/gpu_material_library.h
   intern/gpu_matrix_private.h
   intern/gpu_node_graph.h
-  intern/gpu_primitive_private.h
   intern/gpu_private.h
   intern/gpu_select_private.h
   intern/gpu_shader_private.hh
diff --git a/source/blender/gpu/GPU_attr_binding.h b/source/blender/gpu/GPU_attr_binding.h
deleted file mode 100644
index e7c3dcbce05..00000000000
--- a/source/blender/gpu/GPU_attr_binding.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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 by Mike Erwin.
- * All rights reserved.
- */
-
-/** \file
- * \ingroup gpu
- *
- * GPU vertex attribute binding
- */
-
-#pragma once
-
-#include "GPU_common.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct GPUAttrBinding {
-  /** Store 4 bits for each of the 16 attributes. */
-  uint64_t loc_bits;
-  /** 1 bit for each attribute. */
-  uint16_t enabled_bits;
-} GPUAttrBinding;
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/source/blender/gpu/GPU_primitive.h b/source/blender/gpu/GPU_primitive.h
index e910e81fac1..781a10f3636 100644
--- a/source/blender/gpu/GPU_primitive.h
+++ b/source/blender/gpu/GPU_primitive.h
@@ -56,8 +56,11 @@ typedef enum {
   GPU_PRIM_CLASS_ANY = GPU_PRIM_CLASS_POINT | GPU_PRIM_CLASS_LINE | GPU_PRIM_CLASS_SURFACE,
 } GPUPrimClass;
 
-GPUPrimClass GPU_primtype_class(GPUPrimType);
-bool GPU_primtype_belongs_to_class(GPUPrimType, GPUPrimClass);
+/**
+ * TODO Improve error checking by validating that the shader is suited for this primitive type.
+ * GPUPrimClass GPU_primtype_class(GPUPrimType);
+ * bool GPU_primtype_belongs_to_class(GPUPrimType, GPUPrimClass);
+ **/
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/gpu/intern/gpu_attr_binding.cc b/source/blender/gpu/intern/gpu_attr_binding.cc
deleted file mode 100644
index 2a48107e190..00000000000
--- a/source/blender/gpu/intern/gpu_attr_binding.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 by Mike Erwin.
- * All rights reserved.
- */
-
-/** \file
- * \ingroup gpu
- *
- * GPU vertex attribute binding
- */
-
-#include "GPU_attr_binding.h"
-#include "gpu_attr_binding_private.h"
-#include <stddef.h>
-#include <stdlib.h>
-
-#if GPU_VERT_ATTR_MAX_LEN != 16
-#  error "attribute binding code assumes GPU_VERT_ATTR_MAX_LEN = 16"
-#endif
-
-void AttrBinding_clear(GPUAttrBinding *binding)
-{
-  binding->loc_bits = 0;
-  binding->enabled_bits = 0;
-}
-
-uint read_attr_location(const GPUAttrBinding *binding, uint a_idx)
-{
-#if TRUST_NO_ONE
-  assert(a_idx < GPU_VERT_ATTR_MAX_LEN);
-  assert(binding->enabled_bits & (1 << a_idx));
-#endif
-  return (binding->loc_bits >> (4 * a_idx)) & 0xF;
-}
-
-static void write_attr_location(GPUAttrBinding *binding, uint a_idx, uint location)
-{
-#if TRUST_NO_ONE
-  assert(a_idx < GPU_VERT_ATTR_MAX_LEN);
-  assert(location < GPU_VERT_ATTR_MAX_LEN);
-#endif
-  const uint shift = 4 * a_idx;
-  const uint64_t mask = ((uint64_t)0xF) << shift;
-  /* overwrite this attr's previous location */
-  binding->loc_bits = (binding->loc_bits & ~mask) | (location << shift);
-  /* mark this attr as enabled */
-  binding->enabled_bits |= 1 << a_idx;
-}
-
-void get_attr_locations(const GPUVertFormat *format, GPUAttrBinding *binding, GPUShader *shader)
-{
-  AttrBinding_clear(binding);
-
-  for (uint a_idx = 0; a_idx < format->attr_len; a_idx++) {
-    const GPUVertAttr *a = &format->attrs[a_idx];
-    for (uint n_idx = 0; n_idx < a->name_len; n_idx++) {
-      const char *name = GPU_vertformat_attr_name_get(format, a, n_idx);
-      int loc = GPU_shader_get_attribute(shader, name);
-      /* TODO: make this a recoverable runtime error?
-       * indicates mismatch between vertex format and program. */
-      BLI_assert(loc != -1);
-
-      write_attr_location(binding, a_idx, loc);
-    }
-  }
-}
diff --git a/source/blender/gpu/intern/gpu_attr_binding_private.h b/source/blender/gpu/intern/gpu_attr_binding_private.h
deleted file mode 100644
index cd67a51a822..00000000000
--- a/source/blender/gpu/intern/gpu_attr_binding_private.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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 by Mike Erwin.
- * All rights reserved.
- */
-
-/** \file
- * \ingroup gpu
- *
- * GPU vertex attribute binding
- */
-
-#pragma once
-
-#include "GPU_vertex_format.h"
-#include "gpu_shader_interface.hh"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* TODO(fclem) remove, use shaderface directly. */
-void AttrBinding_clear(GPUAttrBinding *binding);
-
-void get_attr_locations(const GPUVertFormat *format, GPUAttrBinding *binding, GPUShader *shader);
-uint read_attr_location(const GPUAttrBinding *binding, uint a_idx);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc
index 36f60c3dcc8..c3554d9abc8 100644
--- a/source/blender/gpu/intern/gpu_batch.cc
+++ b/source/blender/gpu/intern/gpu_batch.cc
@@ -38,10 +38,11 @@
 #include "gpu_backend.hh"
 #include "gpu_batch_private.hh"
 #include "gpu_context_private.hh"
-#include "gpu_primitive_private.h"
 #include "gpu_shader_private.hh"
 #include "gpu_vertex_format_private.h"
 
+#include "gl_primitive.hh" /* TODO remove */
+
 #include <limits.h>
 #include <stdlib.h>
 #include <string.h>
@@ -287,7 +288,7 @@ void GPU_draw_primitive(GPUPrimType prim_type, int v_count)
   /* we cannot draw without vao ... annoying ... */
   glBindVertexArray(GPU_vao_default());
 
-  GLenum type = convert_prim_type_to_gl(prim_type);
+  GLenum type = blender::gpu::to_gl(prim_type);
   glDrawArrays(type, 0, v_count);
 
   /* Performance hog if you are drawing with the same vao multiple time.
diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc
index 51843917f58..c5dd84ddbd0 100644
--- a/source/blender/gpu/intern/gpu_immediate.cc
+++ b/source/blender/gpu/intern/gpu_immediate.cc
@@ -27,15 +27,12 @@
 #  include "UI_resources.h"
 #endif
 
-#include "GPU_attr_binding.h"
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
 #include "GPU_texture.h"
 
-#include "gpu_attr_binding_private.h"
 #include "gpu_context_private.hh"
 #include "gpu_immediate_private.hh"
-#include "gpu_primitive_private.h"
 #include "gpu_shader_private.hh"
 #include "gpu_vertex_format_private.h"
 
diff --git a/source/blender/gpu/intern/gpu_primitive.c b/source/blender/gpu/intern/gpu_primitive.c
deleted file mode 100644
index 3b11b38db87..00000000000
--- a/source/blender/gpu/intern/gpu_primitive.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
-

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list