add Shader_interface
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 22 Sep 2017 04:41:20 +0000 (21:41 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Fri, 22 Sep 2017 04:41:20 +0000 (21:41 -0700)
src/spirv_to_llvm/spirv_to_llvm.h

index d24fbb58f67ff87def8e40656d5f19385f60b11d..f2a791512f592ce994aa125b334b3f2e9df376d1 100644 (file)
@@ -36,6 +36,7 @@
 #include "util/string_view.h"
 #include "vulkan/vulkan.h"
 #include "vulkan/remove_xlib_macros.h"
+#include "util/bitset.h"
 
 namespace kazan
 {
@@ -55,6 +56,51 @@ struct LLVM_type_and_alignment
     }
 };
 
+struct Shader_interface
+{
+    /** uses a single type for both signed and unsigned integer variants */
+    enum class Location_type
+    {
+        Int32,
+        Float32,
+    };
+    enum class Interpolation_kind
+    {
+        Perspective,
+        Linear,
+        Flat,
+    };
+    struct Location_descriptor
+    {
+        Location_type type;
+        util::bitset<4> used_components;
+        Interpolation_kind interpolation_kind;
+        constexpr Location_descriptor() noexcept : type(), used_components(), interpolation_kind()
+        {
+        }
+        constexpr Location_descriptor(Location_type type,
+                                      util::bitset<4> used_components,
+                                      Interpolation_kind interpolation_kind) noexcept
+            : type(type),
+              used_components(used_components),
+              interpolation_kind(interpolation_kind)
+        {
+        }
+        constexpr explicit operator bool() const noexcept
+        {
+            return used_components.any();
+        }
+    };
+    std::vector<Location_descriptor> locations;
+    Shader_interface() noexcept : locations()
+    {
+    }
+    explicit Shader_interface(std::vector<Location_descriptor> locations) noexcept
+        : locations(std::move(locations))
+    {
+    }
+};
+
 class Simple_type_descriptor;
 class Vector_type_descriptor;
 class Matrix_type_descriptor;