tgsi_from_mesa: add pipe_shader_type_from_mesa
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 17 May 2017 16:09:03 +0000 (18:09 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 5 Jul 2017 10:27:11 +0000 (12:27 +0200)
So... the pipe_ prefix doesn't really fit into a TGSI header; on the
other hand, the return type has the pipe_ prefix.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/tgsi/tgsi_from_mesa.h

index 4c708f4e59fc5645a60ec70ad7f57f39dcbaacf2..d0f211e31e0d4c4205204ef68bea37907c6d52f6 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <stdbool.h>
 
+#include "pipe/p_compiler.h"
+#include "pipe/p_defines.h"
 #include "pipe/p_shader_tokens.h"
 
 #include "compiler/shader_enums.h"
@@ -40,4 +42,25 @@ unsigned
 tgsi_get_generic_gl_varying_index(gl_varying_slot attr,
                                   bool needs_texcoord_semantic);
 
+static inline enum pipe_shader_type
+pipe_shader_type_from_mesa(gl_shader_stage stage)
+{
+   switch (stage) {
+   case MESA_SHADER_VERTEX:
+      return PIPE_SHADER_VERTEX;
+   case MESA_SHADER_TESS_CTRL:
+      return PIPE_SHADER_TESS_CTRL;
+   case MESA_SHADER_TESS_EVAL:
+      return PIPE_SHADER_TESS_EVAL;
+   case MESA_SHADER_GEOMETRY:
+      return PIPE_SHADER_GEOMETRY;
+   case MESA_SHADER_FRAGMENT:
+      return PIPE_SHADER_FRAGMENT;
+   case MESA_SHADER_COMPUTE:
+      return PIPE_SHADER_COMPUTE;
+   default:
+      unreachable("bad shader stage");
+   }
+}
+
 #endif /* TGSI_FROM_MESA_H */