1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2017 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub 8bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom 9bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci#ifndef CROCUS_PIPE_H 24bf215546Sopenharmony_ci#define CROCUS_PIPE_H 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#include "pipe/p_defines.h" 27bf215546Sopenharmony_ci#include "compiler/shader_enums.h" 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_cistatic inline gl_shader_stage 30bf215546Sopenharmony_cistage_from_pipe(enum pipe_shader_type pstage) 31bf215546Sopenharmony_ci{ 32bf215546Sopenharmony_ci static const gl_shader_stage stages[PIPE_SHADER_TYPES] = { 33bf215546Sopenharmony_ci [PIPE_SHADER_VERTEX] = MESA_SHADER_VERTEX, 34bf215546Sopenharmony_ci [PIPE_SHADER_TESS_CTRL] = MESA_SHADER_TESS_CTRL, 35bf215546Sopenharmony_ci [PIPE_SHADER_TESS_EVAL] = MESA_SHADER_TESS_EVAL, 36bf215546Sopenharmony_ci [PIPE_SHADER_GEOMETRY] = MESA_SHADER_GEOMETRY, 37bf215546Sopenharmony_ci [PIPE_SHADER_FRAGMENT] = MESA_SHADER_FRAGMENT, 38bf215546Sopenharmony_ci [PIPE_SHADER_COMPUTE] = MESA_SHADER_COMPUTE, 39bf215546Sopenharmony_ci }; 40bf215546Sopenharmony_ci return stages[pstage]; 41bf215546Sopenharmony_ci} 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_cistatic inline enum pipe_shader_type 44bf215546Sopenharmony_cistage_to_pipe(gl_shader_stage stage) 45bf215546Sopenharmony_ci{ 46bf215546Sopenharmony_ci static const enum pipe_shader_type pstages[MESA_SHADER_STAGES] = { 47bf215546Sopenharmony_ci [MESA_SHADER_VERTEX] = PIPE_SHADER_VERTEX, 48bf215546Sopenharmony_ci [MESA_SHADER_TESS_CTRL] = PIPE_SHADER_TESS_CTRL, 49bf215546Sopenharmony_ci [MESA_SHADER_TESS_EVAL] = PIPE_SHADER_TESS_EVAL, 50bf215546Sopenharmony_ci [MESA_SHADER_GEOMETRY] = PIPE_SHADER_GEOMETRY, 51bf215546Sopenharmony_ci [MESA_SHADER_FRAGMENT] = PIPE_SHADER_FRAGMENT, 52bf215546Sopenharmony_ci [MESA_SHADER_COMPUTE] = PIPE_SHADER_COMPUTE, 53bf215546Sopenharmony_ci }; 54bf215546Sopenharmony_ci return pstages[stage]; 55bf215546Sopenharmony_ci} 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci/** 58bf215546Sopenharmony_ci * Convert an swizzle enumeration (i.e. PIPE_SWIZZLE_X) to one of the HW's 59bf215546Sopenharmony_ci * "Shader Channel Select" enumerations (i.e. SCS_RED). The mappings are 60bf215546Sopenharmony_ci * 61bf215546Sopenharmony_ci * SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_ZERO, SWIZZLE_ONE 62bf215546Sopenharmony_ci * 0 1 2 3 4 5 63bf215546Sopenharmony_ci * 4 5 6 7 0 1 64bf215546Sopenharmony_ci * SCS_RED, SCS_GREEN, SCS_BLUE, SCS_ALPHA, SCS_ZERO, SCS_ONE 65bf215546Sopenharmony_ci * 66bf215546Sopenharmony_ci * which is simply adding 4 then modding by 8 (or anding with 7). 67bf215546Sopenharmony_ci */ 68bf215546Sopenharmony_cistatic inline enum isl_channel_select 69bf215546Sopenharmony_cipipe_swizzle_to_isl_channel(enum pipe_swizzle swizzle) 70bf215546Sopenharmony_ci{ 71bf215546Sopenharmony_ci return (swizzle + 4) & 7; 72bf215546Sopenharmony_ci} 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci#endif 75