Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/panfrost/bifrost/bifrost.h
4564 views
1
/*
2
* Copyright (C) 2019 Connor Abbott <[email protected]>
3
* Copyright (C) 2019 Lyude Paul <[email protected]>
4
* Copyright (C) 2019 Ryan Houdek <[email protected]>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a
7
* copy of this software and associated documentation files (the "Software"),
8
* to deal in the Software without restriction, including without limitation
9
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
* and/or sell copies of the Software, and to permit persons to whom the
11
* Software is furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice (including the next
14
* paragraph) shall be included in all copies or substantial portions of the
15
* Software.
16
*
17
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
* SOFTWARE.
24
*/
25
26
#ifndef __bifrost_h__
27
#define __bifrost_h__
28
29
#include <stdint.h>
30
#include <stdbool.h>
31
#include <assert.h>
32
33
#define BIFROST_DBG_MSGS 0x0001
34
#define BIFROST_DBG_SHADERS 0x0002
35
#define BIFROST_DBG_SHADERDB 0x0004
36
#define BIFROST_DBG_VERBOSE 0x0008
37
#define BIFROST_DBG_INTERNAL 0x0010
38
#define BIFROST_DBG_NOSCHED 0x0020
39
#define BIFROST_DBG_INORDER 0x0040
40
41
extern int bifrost_debug;
42
43
enum bifrost_message_type {
44
BIFROST_MESSAGE_NONE = 0,
45
BIFROST_MESSAGE_VARYING = 1,
46
BIFROST_MESSAGE_ATTRIBUTE = 2,
47
BIFROST_MESSAGE_TEX = 3,
48
BIFROST_MESSAGE_VARTEX = 4,
49
BIFROST_MESSAGE_LOAD = 5,
50
BIFROST_MESSAGE_STORE = 6,
51
BIFROST_MESSAGE_ATOMIC = 7,
52
BIFROST_MESSAGE_BARRIER = 8,
53
BIFROST_MESSAGE_BLEND = 9,
54
BIFROST_MESSAGE_TILE = 10,
55
/* type 11 reserved */
56
BIFROST_MESSAGE_Z_STENCIL = 12,
57
BIFROST_MESSAGE_ATEST = 13,
58
BIFROST_MESSAGE_JOB = 14,
59
BIFROST_MESSAGE_64BIT = 15
60
};
61
62
enum bifrost_ftz {
63
BIFROST_FTZ_DISABLE = 0,
64
BIFROST_FTZ_DX11 = 1,
65
BIFROST_FTZ_ALWAYS = 2,
66
BIFROST_FTZ_ABRUPT = 3
67
};
68
69
enum bifrost_exceptions {
70
BIFROST_EXCEPTIONS_ENABLED = 0,
71
BIFROST_EXCEPTIONS_DISABLED = 1,
72
BIFROST_EXCEPTIONS_PRECISE_DIVISION = 2,
73
BIFROST_EXCEPTIONS_PRECISE_SQRT = 3,
74
};
75
76
/* Describes clause flow control, with respect to control flow and branch
77
* reconvergence.
78
*
79
* Control flow may be considered back-to-back (execute clauses back-to-back),
80
* non-back-to-back (switch warps after clause before the next clause), write
81
* elision (back-to-back and elide register slot #3 write from the clause), or
82
* end of shader.
83
*
84
* Branch reconvergence may be disabled, enabled unconditionally, or enabled
85
* based on the program counter. A clause requires reconvergence if it has a
86
* successor that can be executed without first executing the clause itself.
87
* Separate iterations of a loop are treated separately here, so it is also the
88
* case for a loop exit where the iteration count is not warp-invariant.
89
*
90
*/
91
92
enum bifrost_flow {
93
/* End-of-shader */
94
BIFROST_FLOW_END = 0,
95
96
/* Non back-to-back, PC-encoded reconvergence */
97
BIFROST_FLOW_NBTB_PC = 1,
98
99
/* Non back-to-back, unconditional reconvergence */
100
BIFROST_FLOW_NBTB_UNCONDITIONAL = 2,
101
102
/* Non back-to-back, no reconvergence */
103
BIFROST_FLOW_NBTB = 3,
104
105
/* Back-to-back, unconditional reconvergence */
106
BIFROST_FLOW_BTB_UNCONDITIONAL = 4,
107
108
/* Back-to-back, no reconvergence */
109
BIFROST_FLOW_BTB_NONE = 5,
110
111
/* Write elision, unconditional reconvergence */
112
BIFROST_FLOW_WE_UNCONDITIONAL = 6,
113
114
/* Write elision, no reconvergence */
115
BIFROST_FLOW_WE = 7,
116
};
117
118
enum bifrost_slot {
119
/* 0-5 are general purpose */
120
BIFROST_SLOT_ELDEST_DEPTH = 6,
121
BIFROST_SLOT_ELDEST_COLOUR = 7,
122
};
123
124
struct bifrost_header {
125
/* Reserved */
126
unsigned zero1 : 5;
127
128
/* Flush-to-zero mode, leave zero for GL */
129
enum bifrost_ftz flush_to_zero : 2;
130
131
/* Convert any infinite result of any floating-point operation to the
132
* biggest representable number */
133
unsigned suppress_inf: 1;
134
135
/* Convert NaN to +0.0 */
136
unsigned suppress_nan : 1;
137
138
/* Floating-point excception handling mode */
139
enum bifrost_exceptions float_exceptions : 2;
140
141
/* Enum describing the flow control, which matters for handling
142
* divergence and reconvergence efficiently */
143
enum bifrost_flow flow_control : 3;
144
145
/* Reserved */
146
unsigned zero2 : 1;
147
148
/* Terminate discarded threads, rather than continuing execution. Set
149
* for fragment shaders for standard GL behaviour of DISCARD. Also in a
150
* fragment shader, this disables helper invocations, so cannot be used
151
* in a shader that requires derivatives or texture LOD computation */
152
unsigned terminate_discarded_threads : 1;
153
154
/* If set, the hardware may prefetch the next clause. If false, the
155
* hardware may not. Clear for unconditional branches. */
156
unsigned next_clause_prefetch : 1;
157
158
/* If set, a barrier will be inserted after the clause waiting for all
159
* message passing instructions to read their staging registers, such
160
* that it is safe for the next clause to write them. */
161
unsigned staging_barrier: 1;
162
unsigned staging_register : 6;
163
164
/* Slots to wait on and slot to be used for message passing
165
* instructions respectively */
166
unsigned dependency_wait : 8;
167
unsigned dependency_slot : 3;
168
169
enum bifrost_message_type message_type : 5;
170
enum bifrost_message_type next_message_type : 5;
171
} __attribute__((packed));
172
173
enum bifrost_packed_src {
174
BIFROST_SRC_PORT0 = 0,
175
BIFROST_SRC_PORT1 = 1,
176
BIFROST_SRC_PORT2 = 2,
177
BIFROST_SRC_STAGE = 3,
178
BIFROST_SRC_FAU_LO = 4,
179
BIFROST_SRC_FAU_HI = 5,
180
BIFROST_SRC_PASS_FMA = 6,
181
BIFROST_SRC_PASS_ADD = 7,
182
};
183
184
struct bifrost_fma_inst {
185
unsigned src0 : 3;
186
unsigned op : 20;
187
} __attribute__((packed));
188
189
struct bifrost_add_inst {
190
unsigned src0 : 3;
191
unsigned op : 17;
192
} __attribute__((packed));
193
194
enum branch_bit_size {
195
BR_SIZE_32 = 0,
196
BR_SIZE_16XX = 1,
197
BR_SIZE_16YY = 2,
198
// For the above combinations of bitsize and location, an extra bit is
199
// encoded via comparing the sources. The only possible source of ambiguity
200
// would be if the sources were the same, but then the branch condition
201
// would be always true or always false anyways, so we can ignore it. But
202
// this no longer works when comparing the y component to the x component,
203
// since it's valid to compare the y component of a source against its own
204
// x component. Instead, the extra bit is encoded via an extra bitsize.
205
BR_SIZE_16YX0 = 3,
206
BR_SIZE_16YX1 = 4,
207
BR_SIZE_32_AND_16X = 5,
208
BR_SIZE_32_AND_16Y = 6,
209
// Used for comparisons with zero and always-true, see below. I think this
210
// only works for integer comparisons.
211
BR_SIZE_ZERO = 7,
212
};
213
214
struct bifrost_regs {
215
unsigned fau_idx : 8;
216
unsigned reg3 : 6;
217
unsigned reg2 : 6;
218
unsigned reg0 : 5;
219
unsigned reg1 : 6;
220
unsigned ctrl : 4;
221
} __attribute__((packed));
222
223
#define BIFROST_FMTC_CONSTANTS 0b0011
224
#define BIFROST_FMTC_FINAL 0b0111
225
226
struct bifrost_fmt_constant {
227
unsigned pos : 4;
228
unsigned tag : 4;
229
uint64_t imm_1 : 60;
230
uint64_t imm_2 : 60;
231
} __attribute__((packed));
232
233
/* Clause formats, encoded in a table */
234
235
enum bi_clause_subword {
236
/* Literal 3-bit values */
237
BI_CLAUSE_SUBWORD_LITERAL_0 = 0,
238
/* etc */
239
BI_CLAUSE_SUBWORD_LITERAL_7 = 7,
240
241
/* The value of the corresponding tuple in the corresponding bits */
242
BI_CLAUSE_SUBWORD_TUPLE_0 = 8,
243
/* etc */
244
BI_CLAUSE_SUBWORD_TUPLE_7 = 15,
245
246
/* Clause header */
247
BI_CLAUSE_SUBWORD_HEADER = 16,
248
249
/* Leave zero, but semantically distinct from literal 0 */
250
BI_CLAUSE_SUBWORD_RESERVED = 17,
251
252
/* Embedded constant 0 */
253
BI_CLAUSE_SUBWORD_CONSTANT = 18,
254
255
/* M bits controlling modifier for the constant */
256
BI_CLAUSE_SUBWORD_M = 19,
257
258
/* Z bit: 1 to begin encoding constants, 0 to terminate the clause */
259
BI_CLAUSE_SUBWORD_Z = 20,
260
261
/* Upper 3-bits of a given tuple and zero extended */
262
BI_CLAUSE_SUBWORD_UPPER_0 = 32,
263
/* etc */
264
BI_CLAUSE_SUBWORD_UPPER_7 = BI_CLAUSE_SUBWORD_UPPER_0 + 7,
265
266
/* Upper 3-bits of two tuples, concatenated and zero-extended */
267
BI_CLAUSE_SUBWORD_UPPER_23 = BI_CLAUSE_SUBWORD_UPPER_0 + 23,
268
BI_CLAUSE_SUBWORD_UPPER_56 = BI_CLAUSE_SUBWORD_UPPER_0 + 56,
269
};
270
271
#define L(x) (BI_CLAUSE_SUBWORD_LITERAL_0 + x)
272
#define U(x) (BI_CLAUSE_SUBWORD_UPPER_0 + x)
273
#define T(x) (BI_CLAUSE_SUBWORD_TUPLE_0 + x)
274
#define EC BI_CLAUSE_SUBWORD_CONSTANT
275
#define M BI_CLAUSE_SUBWORD_M
276
#define Z BI_CLAUSE_SUBWORD_Z
277
#define H BI_CLAUSE_SUBWORD_HEADER
278
#define R BI_CLAUSE_SUBWORD_RESERVED
279
280
struct bi_clause_format {
281
unsigned format; /* format number */
282
unsigned pos; /* index in the clause */
283
enum bi_clause_subword tag_1; /* 2-bits */
284
enum bi_clause_subword tag_2; /* 3-bits */
285
enum bi_clause_subword tag_3; /* 3-bits */
286
enum bi_clause_subword s0_s3; /* 60 bits */
287
enum bi_clause_subword s4; /* 15 bits */
288
enum bi_clause_subword s5_s6; /* 30 bits */
289
enum bi_clause_subword s7; /* 15 bits */
290
};
291
292
static const struct bi_clause_format bi_clause_formats[] = {
293
{ 0, 0, L(0), L(5), U(0), T(0), T(0), H, H },
294
{ 0, 0, Z, L(1), U(0), T(0), T(0), H, H },
295
{ 1, 1, Z, L(0), L(3), T(1), T(1), R, U(1) },
296
{ 2, 1, L(0), L(4), U(1), T(1), T(1), T(2), T(2) },
297
{ 3, 2, Z, L(0), L(4), EC, M, T(2), U(2) },
298
{ 4, 2, L(0), L(0), L(1), T(3), T(3), T(2), U(23) },
299
{ 4, 2, Z, L(0), L(5), T(3), T(3), T(2), U(23) },
300
{ 5, 2, L(2), U(3), U(2), T(3), T(3), T(2), EC },
301
{ 6, 3, Z, L(2), U(4), T(4), T(4), EC, EC },
302
{ 7, 3, L(1), L(4), U(4), T(4), T(4), T(5), T(5) },
303
{ 8, 4, Z, L(0), L(6), EC, M, T(5), U(5) },
304
{ 9, 4, Z, L(0), L(7), T(6), T(6), T(5), U(56) },
305
{ 10, 4, L(3), U(6), U(5), T(6), T(6), T(5), EC },
306
{ 11, 5, Z, L(3), U(7), T(7), T(7), EC, EC },
307
};
308
309
#undef L
310
#undef U
311
#undef T
312
#undef EC
313
#undef M
314
#undef Z
315
#undef H
316
#undef R
317
318
/* 32-bit modes for slots 2/3, as encoded in the register block. Other values
319
* are reserved. First part specifies behaviour of slot 2 (Idle, Read, Write
320
* Full, Write Low, Write High), second part behaviour of slot 3, and the last
321
* part specifies the source for the write (FMA, ADD, or MIX for FMA/ADD).
322
*
323
* IDLE is a special mode disabling both slots, except for the first
324
* instruction in the clause which uses IDLE_1 for the same purpose.
325
*
326
* All fields 0 used as sentinel for reserved encoding, so IDLE(_1) have FMA
327
* set (and ignored) as a placeholder to differentiate from reserved.
328
*/
329
enum bifrost_reg_mode {
330
BIFROST_R_WL_FMA = 1,
331
BIFROST_R_WH_FMA = 2,
332
BIFROST_R_W_FMA = 3,
333
BIFROST_R_WL_ADD = 4,
334
BIFROST_R_WH_ADD = 5,
335
BIFROST_R_W_ADD = 6,
336
BIFROST_WL_WL_ADD = 7,
337
BIFROST_WL_WH_ADD = 8,
338
BIFROST_WL_W_ADD = 9,
339
BIFROST_WH_WL_ADD = 10,
340
BIFROST_WH_WH_ADD = 11,
341
BIFROST_WH_W_ADD = 12,
342
BIFROST_W_WL_ADD = 13,
343
BIFROST_W_WH_ADD = 14,
344
BIFROST_W_W_ADD = 15,
345
BIFROST_IDLE_1 = 16,
346
BIFROST_I_W_FMA = 17,
347
BIFROST_I_WL_FMA = 18,
348
BIFROST_I_WH_FMA = 19,
349
BIFROST_R_I = 20,
350
BIFROST_I_W_ADD = 21,
351
BIFROST_I_WL_ADD = 22,
352
BIFROST_I_WH_ADD = 23,
353
BIFROST_WL_WH_MIX = 24,
354
BIFROST_WH_WL_MIX = 26,
355
BIFROST_IDLE = 27,
356
};
357
358
enum bifrost_reg_op {
359
BIFROST_OP_IDLE = 0,
360
BIFROST_OP_READ = 1,
361
BIFROST_OP_WRITE = 2,
362
BIFROST_OP_WRITE_LO = 3,
363
BIFROST_OP_WRITE_HI = 4,
364
};
365
366
struct bifrost_reg_ctrl_23 {
367
enum bifrost_reg_op slot2;
368
enum bifrost_reg_op slot3;
369
bool slot3_fma;
370
};
371
372
static const struct bifrost_reg_ctrl_23 bifrost_reg_ctrl_lut[32] = {
373
[BIFROST_R_WL_FMA] = { BIFROST_OP_READ, BIFROST_OP_WRITE_LO, true },
374
[BIFROST_R_WH_FMA] = { BIFROST_OP_READ, BIFROST_OP_WRITE_HI, true },
375
[BIFROST_R_W_FMA] = { BIFROST_OP_READ, BIFROST_OP_WRITE, true },
376
[BIFROST_R_WL_ADD] = { BIFROST_OP_READ, BIFROST_OP_WRITE_LO, false },
377
[BIFROST_R_WH_ADD] = { BIFROST_OP_READ, BIFROST_OP_WRITE_HI, false },
378
[BIFROST_R_W_ADD] = { BIFROST_OP_READ, BIFROST_OP_WRITE, false },
379
[BIFROST_WL_WL_ADD] = { BIFROST_OP_WRITE_LO, BIFROST_OP_WRITE_LO, false },
380
[BIFROST_WL_WH_ADD] = { BIFROST_OP_WRITE_LO, BIFROST_OP_WRITE_HI, false },
381
[BIFROST_WL_W_ADD] = { BIFROST_OP_WRITE_LO, BIFROST_OP_WRITE, false },
382
[BIFROST_WH_WL_ADD] = { BIFROST_OP_WRITE_HI, BIFROST_OP_WRITE_LO, false },
383
[BIFROST_WH_WH_ADD] = { BIFROST_OP_WRITE_HI, BIFROST_OP_WRITE_HI, false },
384
[BIFROST_WH_W_ADD] = { BIFROST_OP_WRITE_HI, BIFROST_OP_WRITE, false },
385
[BIFROST_W_WL_ADD] = { BIFROST_OP_WRITE, BIFROST_OP_WRITE_LO, false },
386
[BIFROST_W_WH_ADD] = { BIFROST_OP_WRITE, BIFROST_OP_WRITE_HI, false },
387
[BIFROST_W_W_ADD] = { BIFROST_OP_WRITE, BIFROST_OP_WRITE, false },
388
[BIFROST_IDLE_1] = { BIFROST_OP_IDLE, BIFROST_OP_IDLE, true },
389
[BIFROST_I_W_FMA] = { BIFROST_OP_IDLE, BIFROST_OP_WRITE, true },
390
[BIFROST_I_WL_FMA] = { BIFROST_OP_IDLE, BIFROST_OP_WRITE_LO, true },
391
[BIFROST_I_WH_FMA] = { BIFROST_OP_IDLE, BIFROST_OP_WRITE_HI, true },
392
[BIFROST_R_I] = { BIFROST_OP_READ, BIFROST_OP_IDLE, false },
393
[BIFROST_I_W_ADD] = { BIFROST_OP_IDLE, BIFROST_OP_WRITE, false },
394
[BIFROST_I_WL_ADD] = { BIFROST_OP_IDLE, BIFROST_OP_WRITE_LO, false },
395
[BIFROST_I_WH_ADD] = { BIFROST_OP_IDLE, BIFROST_OP_WRITE_HI, false },
396
[BIFROST_WL_WH_MIX] = { BIFROST_OP_WRITE_LO, BIFROST_OP_WRITE_HI, false },
397
[BIFROST_WH_WL_MIX] = { BIFROST_OP_WRITE_HI, BIFROST_OP_WRITE_LO, false },
398
[BIFROST_IDLE] = { BIFROST_OP_IDLE, BIFROST_OP_IDLE, true },
399
};
400
401
/* Texture operator descriptors in various states. Usually packed in the
402
* compiler and stored as a constant */
403
404
enum bifrost_index {
405
/* Both texture/sampler index immediate */
406
BIFROST_INDEX_IMMEDIATE_SHARED = 0,
407
408
/* Sampler index immediate, texture index from staging */
409
BIFROST_INDEX_IMMEDIATE_SAMPLER = 1,
410
411
/* Texture index immediate, sampler index from staging */
412
BIFROST_INDEX_IMMEDIATE_TEXTURE = 2,
413
414
/* Both indices from (separate) staging registers */
415
BIFROST_INDEX_REGISTER = 3,
416
};
417
418
enum bifrost_tex_op {
419
/* Given explicit derivatives, compute a gradient descriptor */
420
BIFROST_TEX_OP_GRDESC_DER = 4,
421
422
/* Given implicit derivatives (texture coordinates in a fragment
423
* shader), compute a gradient descriptor */
424
BIFROST_TEX_OP_GRDESC = 5,
425
426
/* Fetch a texel. Takes a staging register with LOD level / face index
427
* packed 16:16 */
428
BIFROST_TEX_OP_FETCH = 6,
429
430
/* Filtered texture */
431
BIFROST_TEX_OP_TEX = 7,
432
};
433
434
enum bifrost_lod_mode {
435
/* Takes two staging registers forming a 64-bit gradient descriptor
436
* (computed by a previous GRDESC or GRDESC_DER operation) */
437
BIFROST_LOD_MODE_GRDESC = 3,
438
439
/* Take a staging register with 8:8 fixed-point in bottom 16-bits
440
* specifying an explicit LOD */
441
BIFROST_LOD_MODE_EXPLICIT = 4,
442
443
/* Takes a staging register with bottom 16-bits as 8:8 fixed-point LOD
444
* bias and top 16-bit as 8:8 fixed-point lower bound (generally left
445
* zero), added and clamped to a computed LOD */
446
BIFROST_LOD_MODE_BIAS = 5,
447
448
/* Set LOD to zero */
449
BIFROST_LOD_MODE_ZERO = 6,
450
451
/* Compute LOD */
452
BIFROST_LOD_MODE_COMPUTE = 7,
453
};
454
455
enum bifrost_texture_format {
456
/* 16-bit floating point, with optional clamping */
457
BIFROST_TEXTURE_FORMAT_F16 = 0,
458
BIFROST_TEXTURE_FORMAT_F16_POS = 1,
459
BIFROST_TEXTURE_FORMAT_F16_PM1 = 2,
460
BIFROST_TEXTURE_FORMAT_F16_1 = 3,
461
462
/* 32-bit floating point, with optional clamping */
463
BIFROST_TEXTURE_FORMAT_F32 = 4,
464
BIFROST_TEXTURE_FORMAT_F32_POS = 5,
465
BIFROST_TEXTURE_FORMAT_F32_PM1 = 6,
466
BIFROST_TEXTURE_FORMAT_F32_1 = 7,
467
};
468
469
enum bifrost_texture_format_full {
470
/* Transclude bifrost_texture_format from above */
471
472
/* Integers, unclamped */
473
BIFROST_TEXTURE_FORMAT_U16 = 12,
474
BIFROST_TEXTURE_FORMAT_S16 = 13,
475
BIFROST_TEXTURE_FORMAT_U32 = 14,
476
BIFROST_TEXTURE_FORMAT_S32 = 15,
477
};
478
479
enum bifrost_texture_fetch {
480
/* Default texelFetch */
481
BIFROST_TEXTURE_FETCH_TEXEL = 1,
482
483
/* Deprecated, fetches 4x U32 of a U8 x 4 texture. Do not use. */
484
BIFROST_TEXTURE_FETCH_GATHER4_RGBA = 3,
485
486
/* Gathers */
487
BIFROST_TEXTURE_FETCH_GATHER4_R = 4,
488
BIFROST_TEXTURE_FETCH_GATHER4_G = 5,
489
BIFROST_TEXTURE_FETCH_GATHER4_B = 6,
490
BIFROST_TEXTURE_FETCH_GATHER4_A = 7
491
};
492
493
struct bifrost_texture_operation {
494
/* If immediate_indices is set:
495
* - immediate sampler index
496
* - index used as texture index
497
* Otherwise:
498
* - bifrost_single_index in lower 2 bits
499
* - 0x3 in upper 2 bits (single-texturing)
500
*/
501
unsigned sampler_index_or_mode : 4;
502
unsigned index : 7;
503
bool immediate_indices : 1;
504
enum bifrost_tex_op op : 3;
505
506
/* If set for TEX/FETCH, loads texel offsets and multisample index from
507
* a staging register containing offset_x:offset_y:offset_z:ms_index
508
* packed 8:8:8:8. Offsets must be in [-31, +31]. If set for
509
* GRDESC(_DER), disable LOD bias. */
510
bool offset_or_bias_disable : 1;
511
512
/* If set for TEX/FETCH, loads fp32 shadow comparison value from a
513
* staging register. Implies fetch_component = gather4_r. If set for
514
* GRDESC(_DER), disables LOD clamping. */
515
bool shadow_or_clamp_disable : 1;
516
517
/* If set, loads an uint32 array index from a staging register. */
518
bool array : 1;
519
520
/* Texture dimension, or 0 for a cubemap */
521
unsigned dimension : 2;
522
523
/* Method to compute LOD value or for a FETCH, the
524
* bifrost_texture_fetch component specification */
525
enum bifrost_lod_mode lod_or_fetch : 3;
526
527
/* Reserved */
528
unsigned zero : 1;
529
530
/* Register format for the result */
531
enum bifrost_texture_format_full format : 4;
532
533
/* Write mask for the result */
534
unsigned mask : 4;
535
} __attribute__((packed));
536
537
#define BIFROST_MEGA_SAMPLE 128
538
#define BIFROST_ALL_SAMPLES 255
539
#define BIFROST_CURRENT_PIXEL 255
540
541
struct bifrost_pixel_indices {
542
unsigned sample : 8;
543
unsigned rt : 8;
544
unsigned x : 8;
545
unsigned y : 8;
546
} __attribute__((packed));
547
548
enum bi_constmod {
549
BI_CONSTMOD_NONE,
550
BI_CONSTMOD_PC_LO,
551
BI_CONSTMOD_PC_HI,
552
BI_CONSTMOD_PC_LO_HI
553
};
554
555
struct bi_constants {
556
/* Raw constant values */
557
uint64_t raw[6];
558
559
/* Associated modifier derived from M values */
560
enum bi_constmod mods[6];
561
};
562
563
/* FAU selectors for constants are out-of-order, construct the top bits
564
* here given a embedded constant index in a clause */
565
566
static inline unsigned
567
bi_constant_field(unsigned idx)
568
{
569
const unsigned values[] = {
570
4, 5, 6, 7, 2, 3
571
};
572
573
assert(idx <= 5);
574
return values[idx] << 4;
575
}
576
577
#endif
578
579