Cleanup: GPU: Remove unused attr_binding and primitive code
This commit is contained in:
parent
1804eb57fd
commit
a1df2fc443
|
@ -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. */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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.
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
|
@ -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
|
|
@ -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;
|
||||
|
|
|
@ -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_);
|
||||
|
|
Loading…
Reference in New Issue