19f464c52Smaya/* 29f464c52Smaya * Copyright © 2017 Intel Corporation 39f464c52Smaya * 49f464c52Smaya * Permission is hereby granted, free of charge, to any person obtaining a 59f464c52Smaya * copy of this software and associated documentation files (the "Software"), 69f464c52Smaya * to deal in the Software without restriction, including without limitation 79f464c52Smaya * on the rights to use, copy, modify, merge, publish, distribute, sub 89f464c52Smaya * license, and/or sell copies of the Software, and to permit persons to whom 99f464c52Smaya * the Software is furnished to do so, subject to the following conditions: 109f464c52Smaya * 119f464c52Smaya * The above copyright notice and this permission notice (including the next 129f464c52Smaya * paragraph) shall be included in all copies or substantial portions of the 139f464c52Smaya * Software. 149f464c52Smaya * 159f464c52Smaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 169f464c52Smaya * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 179f464c52Smaya * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 189f464c52Smaya * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 199f464c52Smaya * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 209f464c52Smaya * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 219f464c52Smaya * USE OR OTHER DEALINGS IN THE SOFTWARE. 229f464c52Smaya */ 239f464c52Smaya#ifndef IRIS_PIPE_H 249f464c52Smaya#define IRIS_PIPE_H 259f464c52Smaya 269f464c52Smaya#include "pipe/p_defines.h" 279f464c52Smaya#include "compiler/shader_enums.h" 289f464c52Smaya 299f464c52Smayastatic inline gl_shader_stage 309f464c52Smayastage_from_pipe(enum pipe_shader_type pstage) 319f464c52Smaya{ 329f464c52Smaya static const gl_shader_stage stages[PIPE_SHADER_TYPES] = { 339f464c52Smaya [PIPE_SHADER_VERTEX] = MESA_SHADER_VERTEX, 349f464c52Smaya [PIPE_SHADER_TESS_CTRL] = MESA_SHADER_TESS_CTRL, 359f464c52Smaya [PIPE_SHADER_TESS_EVAL] = MESA_SHADER_TESS_EVAL, 369f464c52Smaya [PIPE_SHADER_GEOMETRY] = MESA_SHADER_GEOMETRY, 379f464c52Smaya [PIPE_SHADER_FRAGMENT] = MESA_SHADER_FRAGMENT, 389f464c52Smaya [PIPE_SHADER_COMPUTE] = MESA_SHADER_COMPUTE, 399f464c52Smaya }; 409f464c52Smaya return stages[pstage]; 419f464c52Smaya} 429f464c52Smaya 439f464c52Smayastatic inline enum pipe_shader_type 449f464c52Smayastage_to_pipe(gl_shader_stage stage) 459f464c52Smaya{ 469f464c52Smaya static const enum pipe_shader_type pstages[MESA_SHADER_STAGES] = { 479f464c52Smaya [MESA_SHADER_VERTEX] = PIPE_SHADER_VERTEX, 489f464c52Smaya [MESA_SHADER_TESS_CTRL] = PIPE_SHADER_TESS_CTRL, 499f464c52Smaya [MESA_SHADER_TESS_EVAL] = PIPE_SHADER_TESS_EVAL, 509f464c52Smaya [MESA_SHADER_GEOMETRY] = PIPE_SHADER_GEOMETRY, 519f464c52Smaya [MESA_SHADER_FRAGMENT] = PIPE_SHADER_FRAGMENT, 529f464c52Smaya [MESA_SHADER_COMPUTE] = PIPE_SHADER_COMPUTE, 539f464c52Smaya }; 549f464c52Smaya return pstages[stage]; 559f464c52Smaya} 569f464c52Smaya 579f464c52Smaya/** 589f464c52Smaya * Convert an swizzle enumeration (i.e. PIPE_SWIZZLE_X) to one of the HW's 599f464c52Smaya * "Shader Channel Select" enumerations (i.e. SCS_RED). The mappings are 609f464c52Smaya * 619f464c52Smaya * SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_ZERO, SWIZZLE_ONE 629f464c52Smaya * 0 1 2 3 4 5 639f464c52Smaya * 4 5 6 7 0 1 649f464c52Smaya * SCS_RED, SCS_GREEN, SCS_BLUE, SCS_ALPHA, SCS_ZERO, SCS_ONE 659f464c52Smaya * 669f464c52Smaya * which is simply adding 4 then modding by 8 (or anding with 7). 679f464c52Smaya */ 689f464c52Smayastatic inline enum isl_channel_select 699f464c52Smayapipe_swizzle_to_isl_channel(enum pipe_swizzle swizzle) 709f464c52Smaya{ 719f464c52Smaya return (swizzle + 4) & 7; 729f464c52Smaya} 739f464c52Smaya 749f464c52Smaya#endif 75