Path: blob/21.2-virgl/src/gallium/drivers/iris/iris_pipe.h
4565 views
/*1* Copyright © 2017 Intel Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*/22#ifndef IRIS_PIPE_H23#define IRIS_PIPE_H2425#include "pipe/p_defines.h"26#include "compiler/shader_enums.h"2728static inline gl_shader_stage29stage_from_pipe(enum pipe_shader_type pstage)30{31static const gl_shader_stage stages[PIPE_SHADER_TYPES] = {32[PIPE_SHADER_VERTEX] = MESA_SHADER_VERTEX,33[PIPE_SHADER_TESS_CTRL] = MESA_SHADER_TESS_CTRL,34[PIPE_SHADER_TESS_EVAL] = MESA_SHADER_TESS_EVAL,35[PIPE_SHADER_GEOMETRY] = MESA_SHADER_GEOMETRY,36[PIPE_SHADER_FRAGMENT] = MESA_SHADER_FRAGMENT,37[PIPE_SHADER_COMPUTE] = MESA_SHADER_COMPUTE,38};39return stages[pstage];40}4142static inline enum pipe_shader_type43stage_to_pipe(gl_shader_stage stage)44{45static const enum pipe_shader_type pstages[MESA_SHADER_STAGES] = {46[MESA_SHADER_VERTEX] = PIPE_SHADER_VERTEX,47[MESA_SHADER_TESS_CTRL] = PIPE_SHADER_TESS_CTRL,48[MESA_SHADER_TESS_EVAL] = PIPE_SHADER_TESS_EVAL,49[MESA_SHADER_GEOMETRY] = PIPE_SHADER_GEOMETRY,50[MESA_SHADER_FRAGMENT] = PIPE_SHADER_FRAGMENT,51[MESA_SHADER_COMPUTE] = PIPE_SHADER_COMPUTE,52};53return pstages[stage];54}5556/**57* Convert an swizzle enumeration (i.e. PIPE_SWIZZLE_X) to one of the HW's58* "Shader Channel Select" enumerations (i.e. SCS_RED). The mappings are59*60* SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_ZERO, SWIZZLE_ONE61* 0 1 2 3 4 562* 4 5 6 7 0 163* SCS_RED, SCS_GREEN, SCS_BLUE, SCS_ALPHA, SCS_ZERO, SCS_ONE64*65* which is simply adding 4 then modding by 8 (or anding with 7).66*/67static inline enum isl_channel_select68pipe_swizzle_to_isl_channel(enum pipe_swizzle swizzle)69{70return (swizzle + 4) & 7;71}7273#endif747576