1b8e80941Smrg/*
2b8e80941Smrg * Copyright (C) 2019 Connor Abbott <cwabbott0@gmail.com>
3b8e80941Smrg * Copyright (C) 2019 Lyude Paul <thatslyude@gmail.com>
4b8e80941Smrg * Copyright (C) 2019 Ryan Houdek <Sonicadvance1@gmail.com>
5b8e80941Smrg *
6b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
7b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
8b8e80941Smrg * to deal in the Software without restriction, including without limitation
9b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
11b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
12b8e80941Smrg *
13b8e80941Smrg * The above copyright notice and this permission notice (including the next
14b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the
15b8e80941Smrg * Software.
16b8e80941Smrg *
17b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22b8e80941Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23b8e80941Smrg * SOFTWARE.
24b8e80941Smrg */
25b8e80941Smrg
26b8e80941Smrg#ifndef __bifrost_h__
27b8e80941Smrg#define __bifrost_h__
28b8e80941Smrg
29b8e80941Smrg#include <stdint.h>
30b8e80941Smrg#include <stdbool.h>
31b8e80941Smrg
32b8e80941Smrgstruct bifrost_header {
33b8e80941Smrg        unsigned unk0 : 7;
34b8e80941Smrg        // If true, convert any infinite result of any floating-point operation to
35b8e80941Smrg        // the biggest representable number.
36b8e80941Smrg        unsigned suppress_inf: 1;
37b8e80941Smrg        // Convert any NaN results to 0.
38b8e80941Smrg        unsigned suppress_nan : 1;
39b8e80941Smrg        unsigned unk1 : 2;
40b8e80941Smrg        // true if the execution mask of the next clause is the same as the mask of
41b8e80941Smrg        // the current clause.
42b8e80941Smrg        unsigned back_to_back : 1;
43b8e80941Smrg        unsigned no_end_of_shader: 1;
44b8e80941Smrg        unsigned unk2 : 2;
45b8e80941Smrg        // Set to true for fragment shaders, to implement this bit of spec text
46b8e80941Smrg        // from section 7.1.5 of the GLSL ES spec:
47b8e80941Smrg        //
48b8e80941Smrg        // "Stores to image and buffer variables performed by helper invocations
49b8e80941Smrg        // have no effect on the underlying image or buffer memory."
50b8e80941Smrg        //
51b8e80941Smrg        // Helper invocations are threads (invocations) corresponding to pixels in
52b8e80941Smrg        // a quad that aren't actually part of the triangle, but are included to
53b8e80941Smrg        // make derivatives work correctly. They're usually turned on, but they
54b8e80941Smrg        // need to be masked off for GLSL-level stores. This bit seems to be the
55b8e80941Smrg        // only bit that's actually different between fragment shaders and other
56b8e80941Smrg        // shaders, so this is probably what it's doing.
57b8e80941Smrg        unsigned elide_writes : 1;
58b8e80941Smrg        // If backToBack is off:
59b8e80941Smrg        // - true for conditional branches and fallthrough
60b8e80941Smrg        // - false for unconditional branches
61b8e80941Smrg        // The blob seems to always set it to true if back-to-back is on.
62b8e80941Smrg        unsigned branch_cond : 1;
63b8e80941Smrg        // This bit is set when the next clause writes to the data register of some
64b8e80941Smrg        // previous clause.
65b8e80941Smrg        unsigned datareg_writebarrier: 1;
66b8e80941Smrg        unsigned datareg : 6;
67b8e80941Smrg        unsigned scoreboard_deps: 8;
68b8e80941Smrg        unsigned scoreboard_index: 3;
69b8e80941Smrg        unsigned clause_type: 4;
70b8e80941Smrg        unsigned unk3 : 1; // part of clauseType?
71b8e80941Smrg        unsigned next_clause_type: 4;
72b8e80941Smrg        unsigned unk4 : 1; // part of nextClauseType?
73b8e80941Smrg};
74b8e80941Smrg
75b8e80941Smrgstruct bifrost_fma_inst {
76b8e80941Smrg        unsigned src0 : 3;
77b8e80941Smrg        unsigned op   : 20;
78b8e80941Smrg};
79b8e80941Smrg
80b8e80941Smrgstruct bifrost_add_inst {
81b8e80941Smrg        unsigned src0 : 3;
82b8e80941Smrg        unsigned op   : 17;
83b8e80941Smrg};
84b8e80941Smrg
85b8e80941Smrg#endif
86