iris/query: enable amd performance monitors
[mesa.git] / src / gallium / drivers / iris / iris_pipe.h
index 06ff938372e0bef4dd5da1f27aabc499d8a37237..b859e650ffbe374514ab87ab9e09f0750e09dbda 100644 (file)
@@ -26,7 +26,7 @@
 #include "pipe/p_defines.h"
 #include "compiler/shader_enums.h"
 
-static gl_shader_stage
+static inline gl_shader_stage
 stage_from_pipe(enum pipe_shader_type pstage)
 {
    static const gl_shader_stage stages[PIPE_SHADER_TYPES] = {
@@ -40,4 +40,35 @@ stage_from_pipe(enum pipe_shader_type pstage)
    return stages[pstage];
 }
 
+static inline enum pipe_shader_type
+stage_to_pipe(gl_shader_stage stage)
+{
+   static const enum pipe_shader_type pstages[MESA_SHADER_STAGES] = {
+      [MESA_SHADER_VERTEX] = PIPE_SHADER_VERTEX,
+      [MESA_SHADER_TESS_CTRL] = PIPE_SHADER_TESS_CTRL,
+      [MESA_SHADER_TESS_EVAL] = PIPE_SHADER_TESS_EVAL,
+      [MESA_SHADER_GEOMETRY] = PIPE_SHADER_GEOMETRY,
+      [MESA_SHADER_FRAGMENT] = PIPE_SHADER_FRAGMENT,
+      [MESA_SHADER_COMPUTE] = PIPE_SHADER_COMPUTE,
+   };
+   return pstages[stage];
+}
+
+/**
+ * Convert an swizzle enumeration (i.e. PIPE_SWIZZLE_X) to one of the HW's
+ * "Shader Channel Select" enumerations (i.e. SCS_RED).  The mappings are
+ *
+ * SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_ZERO, SWIZZLE_ONE
+ *         0          1          2          3             4            5
+ *         4          5          6          7             0            1
+ *   SCS_RED, SCS_GREEN,  SCS_BLUE, SCS_ALPHA,     SCS_ZERO,     SCS_ONE
+ *
+ * which is simply adding 4 then modding by 8 (or anding with 7).
+ */
+static inline enum isl_channel_select
+pipe_swizzle_to_isl_channel(enum pipe_swizzle swizzle)
+{
+   return (swizzle + 4) & 7;
+}
+
 #endif