From a1df2fc44388a92ba539f764203170902dd2a663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 31 Aug 2020 15:09:15 +0200 Subject: Cleanup: GPU: Remove unused attr_binding and primitive code --- source/blender/gpu/intern/gpu_attr_binding.cc | 80 ---------------------- .../blender/gpu/intern/gpu_attr_binding_private.h | 43 ------------ source/blender/gpu/intern/gpu_batch.cc | 5 +- source/blender/gpu/intern/gpu_immediate.cc | 3 - source/blender/gpu/intern/gpu_primitive.c | 49 ------------- source/blender/gpu/intern/gpu_primitive_private.h | 37 ---------- 6 files changed, 3 insertions(+), 214 deletions(-) delete mode 100644 source/blender/gpu/intern/gpu_attr_binding.cc delete mode 100644 source/blender/gpu/intern/gpu_attr_binding_private.h delete mode 100644 source/blender/gpu/intern/gpu_primitive.c delete mode 100644 source/blender/gpu/intern/gpu_primitive_private.h (limited to 'source/blender/gpu/intern') 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 -#include - -#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 #include #include @@ -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 -- cgit v1.2.3