8cccbf416afcdac34f81e8536fc85db9fe47cc1b
[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_SIMD16_FRONTEND 1
43 #define USE_SIMD16_SHADERS 1 // requires USE_SIMD16_FRONTEND
44 #define USE_SIMD16_VS 1 // requires USE_SIMD16_SHADERS
45
46 ///////////////////////////////////////////////////////////////////////////////
47 // Architecture validation
48 ///////////////////////////////////////////////////////////////////////////////
49 #if !defined(KNOB_ARCH)
50 #define KNOB_ARCH KNOB_ARCH_AVX
51 #endif
52
53 #if (KNOB_ARCH == KNOB_ARCH_AVX)
54 #define KNOB_ARCH_ISA AVX
55 #define KNOB_ARCH_STR "AVX"
56 #define KNOB_SIMD_WIDTH 8
57 #define KNOB_SIMD_BYTES 32
58 #elif (KNOB_ARCH == KNOB_ARCH_AVX2)
59 #define KNOB_ARCH_ISA AVX2
60 #define KNOB_ARCH_STR "AVX2"
61 #define KNOB_SIMD_WIDTH 8
62 #define KNOB_SIMD_BYTES 32
63 #elif (KNOB_ARCH == KNOB_ARCH_AVX512)
64 #define KNOB_ARCH_ISA AVX512F
65 #define KNOB_ARCH_STR "AVX512"
66 #define KNOB_SIMD_WIDTH 8
67 #define KNOB_SIMD_BYTES 32
68 #else
69 #error "Unknown architecture"
70 #endif
71
72 #if ENABLE_AVX512_SIMD16
73
74 #define KNOB_SIMD16_WIDTH 16
75 #define KNOB_SIMD16_BYTES 64
76
77 #if (KNOB_ARCH == KNOB_ARCH_AVX512)
78 #define ENABLE_AVX512_EMULATION 0
79 #else
80 #define ENABLE_AVX512_EMULATION 1
81 #endif
82
83 #endif
84
85 #define MAX_KNOB_ARCH_STR_LEN sizeof("AVX512_PLUS_PADDING")
86
87 ///////////////////////////////////////////////////////////////////////////////
88 // Configuration knobs
89 ///////////////////////////////////////////////////////////////////////////////
90 // Maximum supported number of active vertex buffer streams
91 #define KNOB_NUM_STREAMS 32
92
93 // Maximum supported active viewports and scissors
94 #define KNOB_NUM_VIEWPORTS_SCISSORS 16
95
96 // Guardband range used by the clipper
97 #define KNOB_GUARDBAND_WIDTH 32768.0f
98 #define KNOB_GUARDBAND_HEIGHT 32768.0f
99
100 ///////////////////////////////
101 // Macro tile configuration
102 ///////////////////////////////
103
104 // raster tile dimensions
105 #define KNOB_TILE_X_DIM 8
106 #define KNOB_TILE_X_DIM_SHIFT 3
107 #define KNOB_TILE_Y_DIM 8
108 #define KNOB_TILE_Y_DIM_SHIFT 3
109
110 // fixed macrotile pixel dimension for now, eventually will be
111 // dynamically set based on tile format and pixel size
112 #define KNOB_MACROTILE_X_DIM 32
113 #define KNOB_MACROTILE_Y_DIM 32
114 #define KNOB_MACROTILE_X_DIM_FIXED_SHIFT 13
115 #define KNOB_MACROTILE_Y_DIM_FIXED_SHIFT 13
116 #define KNOB_MACROTILE_X_DIM_FIXED (KNOB_MACROTILE_X_DIM << 8)
117 #define KNOB_MACROTILE_Y_DIM_FIXED (KNOB_MACROTILE_Y_DIM << 8)
118 #define KNOB_MACROTILE_X_DIM_IN_TILES (KNOB_MACROTILE_X_DIM >> KNOB_TILE_X_DIM_SHIFT)
119 #define KNOB_MACROTILE_Y_DIM_IN_TILES (KNOB_MACROTILE_Y_DIM >> KNOB_TILE_Y_DIM_SHIFT)
120
121 // total # of hot tiles available. This should be enough to
122 // fully render a 16kx16k 128bpp render target
123 #define KNOB_NUM_HOT_TILES_X 256
124 #define KNOB_NUM_HOT_TILES_Y 256
125 #define KNOB_COLOR_HOT_TILE_FORMAT R32G32B32A32_FLOAT
126 #define KNOB_DEPTH_HOT_TILE_FORMAT R32_FLOAT
127 #define KNOB_STENCIL_HOT_TILE_FORMAT R8_UINT
128
129 // Max scissor rectangle
130 #define KNOB_MAX_SCISSOR_X KNOB_NUM_HOT_TILES_X* KNOB_MACROTILE_X_DIM
131 #define KNOB_MAX_SCISSOR_Y KNOB_NUM_HOT_TILES_Y* KNOB_MACROTILE_Y_DIM
132
133 #if KNOB_SIMD_WIDTH == 8 && KNOB_TILE_X_DIM < 4
134 #error "incompatible width/tile dimensions"
135 #endif
136
137 #if ENABLE_AVX512_SIMD16
138 #if KNOB_SIMD16_WIDTH == 16 && KNOB_TILE_X_DIM < 8
139 #error "incompatible width/tile dimensions"
140 #endif
141 #endif
142
143 #if KNOB_SIMD_WIDTH == 8
144 #define SIMD_TILE_X_DIM 4
145 #define SIMD_TILE_Y_DIM 2
146 #else
147 #error "Invalid simd width"
148 #endif
149
150 #if ENABLE_AVX512_SIMD16
151 #if KNOB_SIMD16_WIDTH == 16
152 #define SIMD16_TILE_X_DIM 8
153 #define SIMD16_TILE_Y_DIM 2
154 #else
155 #error "Invalid simd width"
156 #endif
157 #endif
158
159 ///////////////////////////////////////////////////////////////////////////////
160 // Optimization knobs
161 ///////////////////////////////////////////////////////////////////////////////
162 #define KNOB_USE_FAST_SRGB TRUE
163
164 // enables cut-aware primitive assembler
165 #define KNOB_ENABLE_CUT_AWARE_PA TRUE
166
167 // enables early rasterization (useful for small triangles)
168 #if !defined(KNOB_ENABLE_EARLY_RAST)
169 #define KNOB_ENABLE_EARLY_RAST 1
170 #endif
171
172 #if KNOB_ENABLE_EARLY_RAST
173 #define ER_SIMD_TILE_X_SHIFT 2
174 #define ER_SIMD_TILE_Y_SHIFT 2
175 #endif
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