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