Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2017-03-02 23:07:14 +0300
committerMike Erwin <significant.bit@gmail.com>2017-03-02 23:07:14 +0300
commit33758c7cb86f6b19183f12464f0256c5a37a2b8b (patch)
tree725dbde6a18b63e3ce3c5c9ec6c311dfc5d617d3 /source
parenta99495d2914088174ce0900b9360660a41d74c42 (diff)
Gawain: move PRIM types to new file, classify by geometry
PrimitiveClass will help match shaders to draw calls & detect usage errors. For example a point sprite shader only makes sense with PRIM_POINTS. Updated other files to include new primitive.h
Diffstat (limited to 'source')
-rw-r--r--source/blender/gpu/CMakeLists.txt2
-rw-r--r--source/blender/gpu/gawain/common.h17
-rw-r--r--source/blender/gpu/gawain/element.h2
-rw-r--r--source/blender/gpu/gawain/immediate.h1
-rw-r--r--source/blender/gpu/gawain/primitive.c41
-rw-r--r--source/blender/gpu/gawain/primitive.h43
6 files changed, 88 insertions, 18 deletions
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index b6ec702403a..148fb4fcb2f 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -81,6 +81,8 @@ set(SRC
gawain/immediate.h
gawain/imm_util.c
gawain/imm_util.h
+ gawain/primitive.h
+ gawain/primitive.c
gawain/vertex_buffer.c
gawain/vertex_buffer.h
gawain/vertex_format.c
diff --git a/source/blender/gpu/gawain/common.h b/source/blender/gpu/gawain/common.h
index 90340b94e4d..9c16101a0be 100644
--- a/source/blender/gpu/gawain/common.h
+++ b/source/blender/gpu/gawain/common.h
@@ -39,20 +39,3 @@
#undef glBindVertexArray
#define glBindVertexArray glBindVertexArrayAPPLE
#endif
-
-typedef enum {
- PRIM_POINTS = GL_POINTS,
- PRIM_LINES = GL_LINES,
- PRIM_TRIANGLES = GL_TRIANGLES,
-
-#ifdef WITH_GL_PROFILE_COMPAT
- PRIM_QUADS = GL_QUADS, // legacy GL has this, modern GL & Vulkan do not
-#endif
-
- PRIM_LINE_STRIP = GL_LINE_STRIP,
- PRIM_LINE_LOOP = GL_LINE_LOOP, // GL has this, Vulkan does not
- PRIM_TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
- PRIM_TRIANGLE_FAN = GL_TRIANGLE_FAN,
-
- PRIM_NONE = 0xF
-} PrimitiveType;
diff --git a/source/blender/gpu/gawain/element.h b/source/blender/gpu/gawain/element.h
index 4e0d5fb0649..f22d7c0ffda 100644
--- a/source/blender/gpu/gawain/element.h
+++ b/source/blender/gpu/gawain/element.h
@@ -11,7 +11,7 @@
#pragma once
-#include "common.h"
+#include "primitive.h"
#define TRACK_INDEX_RANGE 1
diff --git a/source/blender/gpu/gawain/immediate.h b/source/blender/gpu/gawain/immediate.h
index 1e5729e5cce..6a039542065 100644
--- a/source/blender/gpu/gawain/immediate.h
+++ b/source/blender/gpu/gawain/immediate.h
@@ -12,6 +12,7 @@
#pragma once
#include "vertex_format.h"
+#include "primitive.h"
#define IMM_BATCH_COMBO 1
diff --git a/source/blender/gpu/gawain/primitive.c b/source/blender/gpu/gawain/primitive.c
new file mode 100644
index 00000000000..95472c289e8
--- /dev/null
+++ b/source/blender/gpu/gawain/primitive.c
@@ -0,0 +1,41 @@
+
+// Gawain geometric primitives
+//
+// This code is part of the Gawain library, with modifications
+// specific to integration with Blender.
+//
+// Copyright 2017 Mike Erwin
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
+// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+#include "primitive.h"
+
+PrimitiveClass prim_class_of_type(PrimitiveType prim_type)
+ {
+ static const PrimitiveClass classes[] =
+ {
+ [PRIM_NONE] = PRIM_CLASS_NONE,
+ [PRIM_POINTS] = PRIM_CLASS_POINT,
+ [PRIM_LINES] = PRIM_CLASS_LINE,
+ [PRIM_LINE_STRIP] = PRIM_CLASS_LINE,
+ [PRIM_LINE_LOOP] = PRIM_CLASS_LINE,
+ [PRIM_TRIANGLES] = PRIM_CLASS_SURFACE,
+ [PRIM_TRIANGLE_STRIP] = PRIM_CLASS_SURFACE,
+ [PRIM_TRIANGLE_FAN] = PRIM_CLASS_SURFACE,
+
+#ifdef WITH_GL_PROFILE_COMPAT
+ [PRIM_QUADS] = PRIM_CLASS_SURFACE,
+#endif
+ };
+
+ return classes[prim_type];
+ }
+
+bool prim_type_belongs_to_class(PrimitiveType prim_type, PrimitiveClass prim_class)
+ {
+ if (prim_class == PRIM_CLASS_NONE && prim_type == PRIM_NONE)
+ return true;
+
+ return prim_class & prim_class_of_type(prim_type);
+ }
diff --git a/source/blender/gpu/gawain/primitive.h b/source/blender/gpu/gawain/primitive.h
new file mode 100644
index 00000000000..d1b8f5b3ec7
--- /dev/null
+++ b/source/blender/gpu/gawain/primitive.h
@@ -0,0 +1,43 @@
+
+// Gawain geometric primitives
+//
+// This code is part of the Gawain library, with modifications
+// specific to integration with Blender.
+//
+// Copyright 2017 Mike Erwin
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
+// the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+#pragma once
+
+#include "common.h"
+
+typedef enum {
+ PRIM_POINTS = GL_POINTS,
+ PRIM_LINES = GL_LINES,
+ PRIM_TRIANGLES = GL_TRIANGLES,
+
+#ifdef WITH_GL_PROFILE_COMPAT
+ PRIM_QUADS = GL_QUADS, // legacy GL has this, modern GL & Vulkan do not
+#endif
+
+ PRIM_LINE_STRIP = GL_LINE_STRIP,
+ PRIM_LINE_LOOP = GL_LINE_LOOP, // GL has this, Vulkan does not
+ PRIM_TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
+ PRIM_TRIANGLE_FAN = GL_TRIANGLE_FAN,
+
+ PRIM_NONE = 0xF
+} PrimitiveType;
+
+// what types of primitives does each shader expect?
+typedef enum {
+ PRIM_CLASS_NONE = 0,
+ PRIM_CLASS_POINT = (1 << 0),
+ PRIM_CLASS_LINE = (1 << 1),
+ PRIM_CLASS_SURFACE = (1 << 2),
+ PRIM_CLASS_ANY = PRIM_CLASS_POINT | PRIM_CLASS_LINE | PRIM_CLASS_SURFACE
+} PrimitiveClass;
+
+PrimitiveClass prim_class_of_type(PrimitiveType);
+bool prim_type_belongs_to_class(PrimitiveType, PrimitiveClass);