author | Ryan C. Gordon <icculus@icculus.org> |
Thu, 23 Jul 2020 05:12:09 -0400 | |
changeset 1298 | b70ccc2c7a51 |
parent 1255 | 0135d797e287 |
permissions | -rw-r--r-- |
1199
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1 |
/** |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
2 |
* MojoShader; generate shader programs from bytecode of compiled |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
3 |
* Direct3D shaders. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
4 |
* |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
5 |
* Please see the file LICENSE.txt in the source's root directory. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
6 |
* |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
7 |
* This file written by Ryan C. Gordon. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
8 |
*/ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
9 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
10 |
#ifndef MOJOSHADER_PROFILE_H |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
11 |
#define MOJOSHADER_PROFILE_H |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
12 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
13 |
#include "../mojoshader_internal.h" |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
14 |
|
1224
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
15 |
#if SUPPORT_PROFILE_SPIRV |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
16 |
#include "mojoshader_profile_spirv.h" |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
17 |
#endif |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
18 |
|
1199
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
19 |
typedef struct ConstantsList |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
20 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
21 |
MOJOSHADER_constant constant; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
22 |
struct ConstantsList *next; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
23 |
} ConstantsList; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
24 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
25 |
typedef struct VariableList |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
26 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
27 |
MOJOSHADER_uniformType type; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
28 |
int index; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
29 |
int count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
30 |
ConstantsList *constant; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
31 |
int used; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
32 |
int emit_position; // used in some profiles. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
33 |
struct VariableList *next; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
34 |
} VariableList; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
35 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
36 |
typedef struct RegisterList |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
37 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
38 |
RegisterType regtype; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
39 |
int regnum; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
40 |
MOJOSHADER_usage usage; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
41 |
unsigned int index; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
42 |
int writemask; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
43 |
int misc; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
44 |
int written; |
1224
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
45 |
#if SUPPORT_PROFILE_SPIRV |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
46 |
struct { |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
47 |
uint32 iddecl; |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
48 |
int is_ssa; // FIXME(krolli): Is there an existing way to tell constants and uniforms apart? |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
49 |
} spirv; |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
50 |
#endif |
1199
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
51 |
const VariableList *array; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
52 |
struct RegisterList *next; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
53 |
} RegisterList; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
54 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
55 |
typedef struct |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
56 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
57 |
const uint32 *token; // this is the unmolested token in the stream. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
58 |
int regnum; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
59 |
int swizzle; // xyzw (all four, not split out). |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
60 |
int swizzle_x; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
61 |
int swizzle_y; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
62 |
int swizzle_z; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
63 |
int swizzle_w; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
64 |
SourceMod src_mod; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
65 |
RegisterType regtype; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
66 |
int relative; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
67 |
RegisterType relative_regtype; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
68 |
int relative_regnum; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
69 |
int relative_component; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
70 |
const VariableList *relative_array; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
71 |
} SourceArgInfo; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
72 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
73 |
struct Profile; // predeclare. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
74 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
75 |
typedef struct CtabData |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
76 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
77 |
int have_ctab; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
78 |
int symbol_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
79 |
MOJOSHADER_symbol *symbols; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
80 |
} CtabData; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
81 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
82 |
// Context...this is state that changes as we parse through a shader... |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
83 |
typedef struct Context |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
84 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
85 |
int isfail; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
86 |
int out_of_memory; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
87 |
MOJOSHADER_malloc malloc; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
88 |
MOJOSHADER_free free; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
89 |
void *malloc_data; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
90 |
int current_position; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
91 |
const uint32 *orig_tokens; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
92 |
const uint32 *tokens; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
93 |
uint32 tokencount; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
94 |
int know_shader_size; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
95 |
const MOJOSHADER_swizzle *swizzles; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
96 |
unsigned int swizzles_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
97 |
const MOJOSHADER_samplerMap *samplermap; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
98 |
unsigned int samplermap_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
99 |
Buffer *output; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
100 |
Buffer *preflight; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
101 |
Buffer *globals; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
102 |
Buffer *inputs; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
103 |
Buffer *outputs; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
104 |
Buffer *helpers; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
105 |
Buffer *subroutines; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
106 |
Buffer *mainline_intro; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
107 |
Buffer *mainline_arguments; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
108 |
Buffer *mainline_top; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
109 |
Buffer *mainline; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
110 |
Buffer *postflight; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
111 |
Buffer *ignore; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
112 |
Buffer *output_stack[3]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
113 |
int indent_stack[3]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
114 |
int output_stack_len; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
115 |
int indent; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
116 |
const char *shader_type_str; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
117 |
const char *endline; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
118 |
const char *mainfn; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
119 |
int endline_len; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
120 |
int profileid; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
121 |
const struct Profile *profile; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
122 |
MOJOSHADER_shaderType shader_type; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
123 |
uint8 major_ver; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
124 |
uint8 minor_ver; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
125 |
DestArgInfo dest_arg; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
126 |
SourceArgInfo source_args[5]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
127 |
SourceArgInfo predicate_arg; // for predicated instructions. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
128 |
uint32 dwords[4]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
129 |
uint32 version_token; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
130 |
int instruction_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
131 |
uint32 instruction_controls; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
132 |
uint32 previous_opcode; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
133 |
int coissue; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
134 |
int loops; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
135 |
int reps; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
136 |
int max_reps; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
137 |
int cmps; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
138 |
int scratch_registers; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
139 |
int max_scratch_registers; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
140 |
int branch_labels_stack_index; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
141 |
int branch_labels_stack[32]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
142 |
int assigned_branch_labels; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
143 |
int assigned_vertex_attributes; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
144 |
int last_address_reg_component; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
145 |
RegisterList used_registers; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
146 |
RegisterList defined_registers; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
147 |
ErrorList *errors; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
148 |
int constant_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
149 |
ConstantsList *constants; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
150 |
int uniform_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
151 |
int uniform_float4_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
152 |
int uniform_int4_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
153 |
int uniform_bool_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
154 |
RegisterList uniforms; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
155 |
int attribute_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
156 |
RegisterList attributes; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
157 |
int sampler_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
158 |
RegisterList samplers; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
159 |
VariableList *variables; // variables to register mapping. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
160 |
int centroid_allowed; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
161 |
CtabData ctab; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
162 |
int have_relative_input_registers; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
163 |
int have_multi_color_outputs; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
164 |
int determined_constants_arrays; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
165 |
int predicated; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
166 |
int uses_pointsize; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
167 |
int uses_fog; |
1255
0135d797e287
Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents:
1225
diff
changeset
|
168 |
int need_max_float; |
1199
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
169 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
170 |
// !!! FIXME: move these into SUPPORT_PROFILE sections. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
171 |
int glsl_generated_lit_helper; |
1212
124155bb9bed
GLSL: Implement texldl instruction
Katelyn Gadd <kg@luminance.org>
parents:
1199
diff
changeset
|
172 |
int glsl_generated_texlod_setup; |
1199
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
173 |
int glsl_generated_texm3x3spec_helper; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
174 |
int arb1_wrote_position; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
175 |
// !!! FIXME: move these into SUPPORT_PROFILE sections. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
176 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
177 |
int have_preshader; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
178 |
int ignores_ctab; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
179 |
int reset_texmpad; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
180 |
int texm3x2pad_dst0; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
181 |
int texm3x2pad_src0; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
182 |
int texm3x3pad_dst0; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
183 |
int texm3x3pad_src0; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
184 |
int texm3x3pad_dst1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
185 |
int texm3x3pad_src1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
186 |
MOJOSHADER_preshader *preshader; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
187 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
188 |
#if SUPPORT_PROFILE_ARB1_NV |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
189 |
int profile_supports_nv2; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
190 |
int profile_supports_nv3; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
191 |
int profile_supports_nv4; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
192 |
#endif |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
193 |
#if SUPPORT_PROFILE_GLSL120 |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
194 |
int profile_supports_glsl120; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
195 |
#endif |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
196 |
#if SUPPORT_PROFILE_GLSLES |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
197 |
int profile_supports_glsles; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
198 |
#endif |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
199 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
200 |
#if SUPPORT_PROFILE_METAL |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
201 |
int metal_need_header_common; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
202 |
int metal_need_header_math; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
203 |
int metal_need_header_relational; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
204 |
int metal_need_header_geometric; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
205 |
int metal_need_header_graphics; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
206 |
int metal_need_header_texture; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
207 |
#endif |
1224
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
208 |
|
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
209 |
#if SUPPORT_PROFILE_SPIRV |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
210 |
int branch_labels_patch_stack[32]; |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
211 |
SpirvContext spirv; |
21cd84f1aa0a
Add support for emitting SPIR-V shaders.
Martin Krošlák <kroslakma@gmail.com>
parents:
1221
diff
changeset
|
212 |
#endif |
1225
50b8dd7e0b1a
Add GLSPIRV profile, to allow for both GL- and VK-friendly SPIR-V output
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents:
1224
diff
changeset
|
213 |
#if SUPPORT_PROFILE_GLSPIRV |
50b8dd7e0b1a
Add GLSPIRV profile, to allow for both GL- and VK-friendly SPIR-V output
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents:
1224
diff
changeset
|
214 |
int profile_supports_glspirv; |
50b8dd7e0b1a
Add GLSPIRV profile, to allow for both GL- and VK-friendly SPIR-V output
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents:
1224
diff
changeset
|
215 |
#endif |
1255
0135d797e287
Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents:
1225
diff
changeset
|
216 |
|
0135d797e287
Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents:
1225
diff
changeset
|
217 |
#if SUPPORT_PROFILE_HLSL |
0135d797e287
Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents:
1225
diff
changeset
|
218 |
char hlsl_outpos_name[16]; |
0135d797e287
Implement HLSL emitter, MOJOSHADER_d3d11 API
Caleb Cornett <caleb.cornett@outlook.com>
parents:
1225
diff
changeset
|
219 |
#endif |
1199
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
220 |
} Context; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
221 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
222 |
// Use these macros so we can remove all bits of these profiles from the build. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
223 |
#if SUPPORT_PROFILE_ARB1_NV |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
224 |
#define support_nv2(ctx) ((ctx)->profile_supports_nv2) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
225 |
#define support_nv3(ctx) ((ctx)->profile_supports_nv3) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
226 |
#define support_nv4(ctx) ((ctx)->profile_supports_nv4) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
227 |
#else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
228 |
#define support_nv2(ctx) (0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
229 |
#define support_nv3(ctx) (0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
230 |
#define support_nv4(ctx) (0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
231 |
#endif |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
232 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
233 |
#if SUPPORT_PROFILE_GLSL120 |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
234 |
#define support_glsl120(ctx) ((ctx)->profile_supports_glsl120) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
235 |
#else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
236 |
#define support_glsl120(ctx) (0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
237 |
#endif |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
238 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
239 |
#if SUPPORT_PROFILE_GLSLES |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
240 |
#define support_glsles(ctx) ((ctx)->profile_supports_glsles) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
241 |
#else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
242 |
#define support_glsles(ctx) (0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
243 |
#endif |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
244 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
245 |
// Profile entry points... |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
246 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
247 |
// one emit function for each opcode in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
248 |
typedef void (*emit_function)(Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
249 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
250 |
// one emit function for starting output in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
251 |
typedef void (*emit_start)(Context *ctx, const char *profilestr); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
252 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
253 |
// one emit function for ending output in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
254 |
typedef void (*emit_end)(Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
255 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
256 |
// one emit function for phase opcode output in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
257 |
typedef void (*emit_phase)(Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
258 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
259 |
// one emit function for finalizing output in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
260 |
typedef void (*emit_finalize)(Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
261 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
262 |
// one emit function for global definitions in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
263 |
typedef void (*emit_global)(Context *ctx, RegisterType regtype, int regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
264 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
265 |
// one emit function for relative uniform arrays in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
266 |
typedef void (*emit_array)(Context *ctx, VariableList *var); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
267 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
268 |
// one emit function for relative constants arrays in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
269 |
typedef void (*emit_const_array)(Context *ctx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
270 |
const struct ConstantsList *constslist, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
271 |
int base, int size); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
272 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
273 |
// one emit function for uniforms in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
274 |
typedef void (*emit_uniform)(Context *ctx, RegisterType regtype, int regnum, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
275 |
const VariableList *var); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
276 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
277 |
// one emit function for samplers in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
278 |
typedef void (*emit_sampler)(Context *ctx, int stage, TextureType ttype, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
279 |
int texbem); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
280 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
281 |
// one emit function for attributes in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
282 |
typedef void (*emit_attribute)(Context *ctx, RegisterType regtype, int regnum, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
283 |
MOJOSHADER_usage usage, int index, int wmask, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
284 |
int flags); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
285 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
286 |
// one args function for each possible sequence of opcode arguments. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
287 |
typedef int (*args_function)(Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
288 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
289 |
// one state function for each opcode where we have state machine updates. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
290 |
typedef void (*state_function)(Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
291 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
292 |
// one function for varnames in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
293 |
typedef const char *(*varname_function)(Context *c, RegisterType t, int num); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
294 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
295 |
// one function for const var array in each profile. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
296 |
typedef const char *(*const_array_varname_function)(Context *c, int base, int size); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
297 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
298 |
typedef struct Profile |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
299 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
300 |
const char *name; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
301 |
emit_start start_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
302 |
emit_end end_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
303 |
emit_phase phase_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
304 |
emit_global global_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
305 |
emit_array array_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
306 |
emit_const_array const_array_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
307 |
emit_uniform uniform_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
308 |
emit_sampler sampler_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
309 |
emit_attribute attribute_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
310 |
emit_finalize finalize_emitter; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
311 |
varname_function get_varname; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
312 |
const_array_varname_function get_const_array_varname; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
313 |
} Profile; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
314 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
315 |
// Common utilities... |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
316 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
317 |
void out_of_memory(Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
318 |
void *Malloc(Context *ctx, const size_t len); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
319 |
char *StrDup(Context *ctx, const char *str); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
320 |
void Free(Context *ctx, void *ptr); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
321 |
void * MOJOSHADERCALL MallocBridge(int bytes, void *data); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
322 |
void MOJOSHADERCALL FreeBridge(void *ptr, void *data); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
323 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
324 |
int set_output(Context *ctx, Buffer **section); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
325 |
void push_output(Context *ctx, Buffer **section); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
326 |
void pop_output(Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
327 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
328 |
uint32 ver_ui32(const uint8 major, const uint8 minor); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
329 |
int shader_version_supported(const uint8 maj, const uint8 min); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
330 |
int shader_version_atleast(const Context *ctx, const uint8 maj, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
331 |
const uint8 min); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
332 |
int shader_version_exactly(const Context *ctx, const uint8 maj, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
333 |
const uint8 min); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
334 |
int shader_is_pixel(const Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
335 |
int shader_is_vertex(const Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
336 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
337 |
int isfail(const Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
338 |
void failf(Context *ctx, const char *fmt, ...); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
339 |
void fail(Context *ctx, const char *reason); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
340 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
341 |
void output_line(Context *ctx, const char *fmt, ...); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
342 |
void output_blank_line(Context *ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
343 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
344 |
void floatstr(Context *ctx, char *buf, size_t bufsize, float f, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
345 |
int leavedecimal); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
346 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
347 |
RegisterList *reglist_insert(Context *ctx, RegisterList *prev, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
348 |
const RegisterType regtype, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
349 |
const int regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
350 |
RegisterList *reglist_find(const RegisterList *prev, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
351 |
const RegisterType rtype, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
352 |
const int regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
353 |
RegisterList *set_used_register(Context *ctx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
354 |
const RegisterType regtype, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
355 |
const int regnum, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
356 |
const int written); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
357 |
void set_defined_register(Context *ctx, const RegisterType rtype, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
358 |
const int regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
359 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
360 |
int writemask_xyzw(const int writemask); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
361 |
int writemask_xyz(const int writemask); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
362 |
int writemask_xy(const int writemask); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
363 |
int writemask_x(const int writemask); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
364 |
int writemask_y(const int writemask); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
365 |
int replicate_swizzle(const int swizzle); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
366 |
int no_swizzle(const int swizzle); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
367 |
int vecsize_from_writemask(const int m); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
368 |
void set_dstarg_writemask(DestArgInfo *dst, const int mask); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
369 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
370 |
int isscalar(Context *ctx, const MOJOSHADER_shaderType shader_type, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
371 |
const RegisterType rtype, const int rnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
372 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
373 |
static const char swizzle_channels[] = { 'x', 'y', 'z', 'w' }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
374 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
375 |
const char *get_D3D_register_string(Context *ctx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
376 |
RegisterType regtype, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
377 |
int regnum, char *regnum_str, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
378 |
size_t regnum_size); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
379 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
380 |
// !!! FIXME: These should stay in the mojoshader_profile_d3d file |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
381 |
// !!! FIXME: but ARB1 relies on them, so we have to move them here. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
382 |
// !!! FIXME: If/when we kill off ARB1, we can move these back. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
383 |
const char *get_D3D_varname_in_buf(Context *ctx, RegisterType rt, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
384 |
int regnum, char *buf, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
385 |
const size_t len); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
386 |
const char *get_D3D_varname(Context *ctx, RegisterType rt, int regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
387 |
|
1212
124155bb9bed
GLSL: Implement texldl instruction
Katelyn Gadd <kg@luminance.org>
parents:
1199
diff
changeset
|
388 |
#endif |