740613118a6546c3cab25714634539922ed17973
[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 0
42
43 ///////////////////////////////////////////////////////////////////////////////
44 // Architecture validation
45 ///////////////////////////////////////////////////////////////////////////////
46 #if !defined(KNOB_ARCH)
47 #define KNOB_ARCH KNOB_ARCH_AVX
48 #endif
49
50 #if (KNOB_ARCH == KNOB_ARCH_AVX)
51 #define KNOB_ARCH_ISA AVX
52 #define KNOB_ARCH_STR "AVX"
53 #define KNOB_SIMD_WIDTH 8
54 #define KNOB_SIMD_BYTES 32
55 #elif (KNOB_ARCH == KNOB_ARCH_AVX2)
56 #define KNOB_ARCH_ISA AVX2
57 #define KNOB_ARCH_STR "AVX2"
58 #define KNOB_SIMD_WIDTH 8
59 #define KNOB_SIMD_BYTES 32
60 #elif (KNOB_ARCH == KNOB_ARCH_AVX512)
61 #if 0
62 // not ready to enable this globally, enabled on the side (below)
63 #define KNOB_ARCH_ISA AVX512F
64 #define KNOB_ARCH_STR "AVX512"
65 #define KNOB_SIMD_WIDTH 16
66 #define KNOB_SIMD_BYTES 64
67 #else
68 #define KNOB_ARCH_ISA AVX2
69 #define KNOB_ARCH_STR "AVX2"
70 #define KNOB_SIMD_WIDTH 8
71 #define KNOB_SIMD_BYTES 32
72 #endif
73 #else
74 #error "Unknown architecture"
75 #endif
76
77 #if ENABLE_AVX512_SIMD16
78
79 #define KNOB_SIMD16_WIDTH 16
80 #define KNOB_SIMD16_BYTES 64
81
82 #if (KNOB_ARCH == KNOB_ARCH_AVX512)
83 #define ENABLE_AVX512_EMULATION 0
84 #else
85 #define ENABLE_AVX512_EMULATION 1
86 #endif
87
88 #endif
89
90 #define MAX_KNOB_ARCH_STR_LEN sizeof("AVX512_PLUS_PADDING")
91
92 ///////////////////////////////////////////////////////////////////////////////
93 // Configuration knobs
94 ///////////////////////////////////////////////////////////////////////////////
95 #define KNOB_MAX_NUM_THREADS 256 // Supports up to dual-HSW-Xeon.
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 #elif KNOB_SIMD_WIDTH==16 && KNOB_TILE_X_DIM < 4
146 #error "incompatible width/tile dimensions"
147 #endif
148
149 #if ENABLE_AVX512_SIMD16
150 #if KNOB_SIMD16_WIDTH==16 && KNOB_TILE_X_DIM < 4
151 #error "incompatible width/tile dimensions"
152 #endif
153 #endif
154
155 #if KNOB_SIMD_WIDTH == 8
156 #define SIMD_TILE_X_DIM 4
157 #define SIMD_TILE_Y_DIM 2
158 #elif KNOB_SIMD_WIDTH == 16
159 #define SIMD_TILE_X_DIM 4
160 #define SIMD_TILE_Y_DIM 4
161 #else
162 #error "Invalid simd width"
163 #endif
164
165 #if ENABLE_AVX512_SIMD16
166 #if KNOB_SIMD16_WIDTH == 16
167 #define SIMD16_TILE_X_DIM 4
168 #define SIMD16_TILE_Y_DIM 4
169 #else
170 #error "Invalid simd width"
171 #endif
172 #endif
173
174 ///////////////////////////////////////////////////////////////////////////////
175 // Optimization knobs
176 ///////////////////////////////////////////////////////////////////////////////
177 #define KNOB_USE_FAST_SRGB TRUE
178
179 // enables cut-aware primitive assembler
180 #define KNOB_ENABLE_CUT_AWARE_PA TRUE
181
182 ///////////////////////////////////////////////////////////////////////////////
183 // Debug knobs
184 ///////////////////////////////////////////////////////////////////////////////
185 //#define KNOB_ENABLE_RDTSC
186
187 // Set to 1 to use the dynamic KNOB_TOSS_XXXX knobs.
188 #if !defined(KNOB_ENABLE_TOSS_POINTS)
189 #define KNOB_ENABLE_TOSS_POINTS 0
190 #endif
191