swr: [rasterizer core] Enable 8x2 backend
[mesa.git] / src / gallium / drivers / swr / rasterizer / core / knobs.h
1 /****************************************************************************
2 * Copyright (C) 2014-2015 Intel Corporation. All Rights Reserved.
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * 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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * @file knobs.h
24 *
25 * @brief Static (Compile-Time) Knobs for Core.
26 *
27 ******************************************************************************/
28 #pragma once
29
30 #include <stdint.h>
31 #include <gen_knobs.h>
32
33 #define KNOB_ARCH_AVX 0
34 #define KNOB_ARCH_AVX2 1
35 #define KNOB_ARCH_AVX512 2
36
37 ///////////////////////////////////////////////////////////////////////////////
38 // AVX512 Support
39 ///////////////////////////////////////////////////////////////////////////////
40
41 #define ENABLE_AVX512_SIMD16 1
42 #define USE_8x2_TILE_BACKEND 1
43 #define USE_SIMD16_FRONTEND 0
44
45 ///////////////////////////////////////////////////////////////////////////////
46 // Architecture validation
47 ///////////////////////////////////////////////////////////////////////////////
48 #if !defined(KNOB_ARCH)
49 #define KNOB_ARCH KNOB_ARCH_AVX
50 #endif
51
52 #if (KNOB_ARCH == KNOB_ARCH_AVX)
53 #define KNOB_ARCH_ISA AVX
54 #define KNOB_ARCH_STR "AVX"
55 #define KNOB_SIMD_WIDTH 8
56 #define KNOB_SIMD_BYTES 32
57 #elif (KNOB_ARCH == KNOB_ARCH_AVX2)
58 #define KNOB_ARCH_ISA AVX2
59 #define KNOB_ARCH_STR "AVX2"
60 #define KNOB_SIMD_WIDTH 8
61 #define KNOB_SIMD_BYTES 32
62 #elif (KNOB_ARCH == KNOB_ARCH_AVX512)
63 #if 0
64 // not ready to enable this globally, enabled on the side (below)
65 #define KNOB_ARCH_ISA AVX512F
66 #define KNOB_ARCH_STR "AVX512"
67 #define KNOB_SIMD_WIDTH 16
68 #define KNOB_SIMD_BYTES 64
69 #else
70 #define KNOB_ARCH_ISA AVX2
71 #define KNOB_ARCH_STR "AVX2"
72 #define KNOB_SIMD_WIDTH 8
73 #define KNOB_SIMD_BYTES 32
74 #endif
75 #else
76 #error "Unknown architecture"
77 #endif
78
79 #if ENABLE_AVX512_SIMD16
80
81 #define KNOB_SIMD16_WIDTH 16
82 #define KNOB_SIMD16_BYTES 64
83
84 #if (KNOB_ARCH == KNOB_ARCH_AVX512)
85 #define ENABLE_AVX512_EMULATION 0
86 #else
87 #define ENABLE_AVX512_EMULATION 1
88 #endif
89
90 #endif
91
92 #define MAX_KNOB_ARCH_STR_LEN sizeof("AVX512_PLUS_PADDING")
93
94 ///////////////////////////////////////////////////////////////////////////////
95 // Configuration knobs
96 ///////////////////////////////////////////////////////////////////////////////
97 // Maximum supported number of active vertex buffer streams
98 #define KNOB_NUM_STREAMS 32
99
100 // Maximum supported number of attributes per vertex
101 #define KNOB_NUM_ATTRIBUTES 39
102
103 // Maximum supported active viewports and scissors
104 #define KNOB_NUM_VIEWPORTS_SCISSORS 16
105
106 // Guardband range used by the clipper
107 #define KNOB_GUARDBAND_WIDTH 32768.0f
108 #define KNOB_GUARDBAND_HEIGHT 32768.0f
109
110 ///////////////////////////////
111 // Macro tile configuration
112 ///////////////////////////////
113
114 // raster tile dimensions
115 #define KNOB_TILE_X_DIM 8
116 #define KNOB_TILE_X_DIM_SHIFT 3
117 #define KNOB_TILE_Y_DIM 8
118 #define KNOB_TILE_Y_DIM_SHIFT 3
119
120 // fixed macrotile pixel dimension for now, eventually will be
121 // dynamically set based on tile format and pixel size
122 #define KNOB_MACROTILE_X_DIM 32
123 #define KNOB_MACROTILE_Y_DIM 32
124 #define KNOB_MACROTILE_X_DIM_FIXED_SHIFT 13
125 #define KNOB_MACROTILE_Y_DIM_FIXED_SHIFT 13
126 #define KNOB_MACROTILE_X_DIM_FIXED (KNOB_MACROTILE_X_DIM << 8)
127 #define KNOB_MACROTILE_Y_DIM_FIXED (KNOB_MACROTILE_Y_DIM << 8)
128 #define KNOB_MACROTILE_X_DIM_IN_TILES (KNOB_MACROTILE_X_DIM >> KNOB_TILE_X_DIM_SHIFT)
129 #define KNOB_MACROTILE_Y_DIM_IN_TILES (KNOB_MACROTILE_Y_DIM >> KNOB_TILE_Y_DIM_SHIFT)
130
131 // total # of hot tiles available. This should be enough to
132 // fully render a 16kx16k 128bpp render target
133 #define KNOB_NUM_HOT_TILES_X 256
134 #define KNOB_NUM_HOT_TILES_Y 256
135 #define KNOB_COLOR_HOT_TILE_FORMAT R32G32B32A32_FLOAT
136 #define KNOB_DEPTH_HOT_TILE_FORMAT R32_FLOAT
137 #define KNOB_STENCIL_HOT_TILE_FORMAT R8_UINT
138
139 // Max scissor rectangle
140 #define KNOB_MAX_SCISSOR_X KNOB_NUM_HOT_TILES_X * KNOB_MACROTILE_X_DIM
141 #define KNOB_MAX_SCISSOR_Y KNOB_NUM_HOT_TILES_Y * KNOB_MACROTILE_Y_DIM
142
143 #if KNOB_SIMD_WIDTH==8 && KNOB_TILE_X_DIM < 4
144 #error "incompatible width/tile dimensions"
145 #endif
146
147 #if ENABLE_AVX512_SIMD16
148 #if KNOB_SIMD16_WIDTH == 16 && KNOB_TILE_X_DIM < 8
149 #error "incompatible width/tile dimensions"
150 #endif
151 #endif
152
153 #if KNOB_SIMD_WIDTH == 8
154 #define SIMD_TILE_X_DIM 4
155 #define SIMD_TILE_Y_DIM 2
156 #else
157 #error "Invalid simd width"
158 #endif
159
160 #if ENABLE_AVX512_SIMD16
161 #if KNOB_SIMD16_WIDTH == 16
162 #define SIMD16_TILE_X_DIM 8
163 #define SIMD16_TILE_Y_DIM 2
164 #else
165 #error "Invalid simd width"
166 #endif
167 #endif
168
169 ///////////////////////////////////////////////////////////////////////////////
170 // Optimization knobs
171 ///////////////////////////////////////////////////////////////////////////////
172 #define KNOB_USE_FAST_SRGB TRUE
173
174 // enables cut-aware primitive assembler
175 #define KNOB_ENABLE_CUT_AWARE_PA TRUE
176
177 ///////////////////////////////////////////////////////////////////////////////
178 // Debug knobs
179 ///////////////////////////////////////////////////////////////////////////////
180 //#define KNOB_ENABLE_RDTSC
181
182 // Set to 1 to use the dynamic KNOB_TOSS_XXXX knobs.
183 #if !defined(KNOB_ENABLE_TOSS_POINTS)
184 #define KNOB_ENABLE_TOSS_POINTS 0
185 #endif
186