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