diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-31 16:09:15 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-08-31 16:15:04 +0300 |
commit | a1df2fc44388a92ba539f764203170902dd2a663 (patch) | |
tree | 7e7c4f6467a024fb1abd0643f79ec6ec70a37822 /source | |
parent | 1804eb57fd27fceb0ed113e3ef2f4a55db0d03c8 (diff) |
Cleanup: GPU: Remove unused attr_binding and primitive code
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/draw_instance_data.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/CMakeLists.txt | 5 | ||||
-rw-r--r-- | source/blender/gpu/GPU_attr_binding.h | 43 | ||||
-rw-r--r-- | source/blender/gpu/GPU_primitive.h | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_attr_binding.cc | 80 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_attr_binding_private.h | 43 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_batch.cc | 5 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_immediate.cc | 3 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_primitive.c | 49 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_primitive_private.h | 37 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_batch.cc | 4 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_drawlist.cc | 4 |
12 files changed, 12 insertions, 270 deletions
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 - * 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 geometric primitives - */ - -#include "GPU_primitive.h" -#include "gpu_primitive_private.h" - -GLenum convert_prim_type_to_gl(GPUPrimType prim_type) -{ -#if TRUST_NO_ONE - assert(prim_type != GPU_PRIM_NONE); -#endif - static const GLenum table[] = { - [GPU_PRIM_POINTS] = GL_POINTS, - [GPU_PRIM_LINES] = GL_LINES, - [GPU_PRIM_LINE_STRIP] = GL_LINE_STRIP, - [GPU_PRIM_LINE_LOOP] = GL_LINE_LOOP, - [GPU_PRIM_TRIS] = GL_TRIANGLES, - [GPU_PRIM_TRI_STRIP] = GL_TRIANGLE_STRIP, - [GPU_PRIM_TRI_FAN] = GL_TRIANGLE_FAN, - - [GPU_PRIM_LINES_ADJ] = GL_LINES_ADJACENCY, - [GPU_PRIM_LINE_STRIP_ADJ] = GL_LINE_STRIP_ADJACENCY, - [GPU_PRIM_TRIS_ADJ] = GL_TRIANGLES_ADJACENCY, - }; - - return table[prim_type]; -} diff --git a/source/blender/gpu/intern/gpu_primitive_private.h b/source/blender/gpu/intern/gpu_primitive_private.h deleted file mode 100644 index e91eec18786..00000000000 --- a/source/blender/gpu/intern/gpu_primitive_private.h +++ /dev/null @@ -1,37 +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 geometric primitives - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -/* TODO(fclem) move to OGL backend */ -GLenum convert_prim_type_to_gl(GPUPrimType); - -#ifdef __cplusplus -} -#endif diff --git a/source/blender/gpu/opengl/gl_batch.cc b/source/blender/gpu/opengl/gl_batch.cc index 7d6270bca93..bc951736db3 100644 --- a/source/blender/gpu/opengl/gl_batch.cc +++ b/source/blender/gpu/opengl/gl_batch.cc @@ -32,11 +32,11 @@ #include "GPU_extensions.h" #include "gpu_batch_private.hh" -#include "gpu_primitive_private.h" #include "gpu_shader_private.hh" #include "gl_batch.hh" #include "gl_context.hh" +#include "gl_primitive.hh" #include "gl_vertex_array.hh" using namespace blender::gpu; @@ -335,7 +335,7 @@ void GLBatch::draw(int v_first, int v_count, int i_first, int i_count) BLI_assert(v_count > 0 && i_count > 0); - GLenum gl_type = convert_prim_type_to_gl(prim_type); + GLenum gl_type = to_gl(prim_type); if (elem) { const GPUIndexBuf *el = elem; diff --git a/source/blender/gpu/opengl/gl_drawlist.cc b/source/blender/gpu/opengl/gl_drawlist.cc index 16ea924d8dc..35fecc859b8 100644 --- a/source/blender/gpu/opengl/gl_drawlist.cc +++ b/source/blender/gpu/opengl/gl_drawlist.cc @@ -33,10 +33,10 @@ #include "gpu_context_private.hh" #include "gpu_drawlist_private.hh" -#include "gpu_primitive_private.h" #include "gl_backend.hh" #include "gl_drawlist.hh" +#include "gl_primitive.hh" #include <limits.h> @@ -199,7 +199,7 @@ void GLDrawList::submit(void) * case where only a few instances are needed to finish filling a call buffer. */ const bool is_finishing_a_buffer = (command_offset_ >= data_size_); if (command_len_ > 2 || is_finishing_a_buffer) { - GLenum prim = convert_prim_type_to_gl(batch_->prim_type); + GLenum prim = to_gl(batch_->prim_type); void *offset = (void *)data_offset_; glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer_id_); |