author | Ethan Lee <flibitijibibo@flibitijibibo.com> |
Sun, 30 Aug 2020 21:35:31 -0400 | |
changeset 1303 | 7a43f238f28a |
parent 1200 | eb1e5280a5a9 |
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 |
#define __MOJOSHADER_INTERNAL__ 1 |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
11 |
#include "mojoshader_profile.h" |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
12 |
|
1200
eb1e5280a5a9
Move the visibility pragmas below the includes.
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents:
1199
diff
changeset
|
13 |
#pragma GCC visibility push(hidden) |
eb1e5280a5a9
Move the visibility pragmas below the includes.
Ethan Lee <flibitijibibo@flibitijibibo.com>
parents:
1199
diff
changeset
|
14 |
|
1199
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
15 |
#if SUPPORT_PROFILE_ARB1 |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
16 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
17 |
static inline const char *get_ARB1_register_string(Context *ctx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
18 |
const RegisterType regtype, const int regnum, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
19 |
char *regnum_str, const size_t regnum_size) |
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 |
// turns out these are identical at the moment. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
22 |
return get_D3D_register_string(ctx,regtype,regnum,regnum_str,regnum_size); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
23 |
} // get_ARB1_register_string |
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 |
int allocate_scratch_register(Context *ctx) |
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 |
const int retval = ctx->scratch_registers++; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
28 |
if (retval >= ctx->max_scratch_registers) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
29 |
ctx->max_scratch_registers = retval + 1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
30 |
return retval; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
31 |
} // allocate_scratch_register |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
32 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
33 |
int allocate_branch_label(Context *ctx) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
34 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
35 |
return ctx->assigned_branch_labels++; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
36 |
} // allocate_branch_label |
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 |
const char *allocate_ARB1_scratch_reg_name(Context *ctx, char *buf, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
39 |
const size_t buflen) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
40 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
41 |
const int scratch = allocate_scratch_register(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
42 |
snprintf(buf, buflen, "scratch%d", scratch); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
43 |
return buf; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
44 |
} // allocate_ARB1_scratch_reg_name |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
45 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
46 |
static inline const char *get_ARB1_branch_label_name(Context *ctx, const int id, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
47 |
char *buf, const size_t buflen) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
48 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
49 |
snprintf(buf, buflen, "branch_label%d", id); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
50 |
return buf; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
51 |
} // get_ARB1_branch_label_name |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
52 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
53 |
const char *get_ARB1_varname_in_buf(Context *ctx, const RegisterType rt, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
54 |
const int regnum, char *buf, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
55 |
const size_t buflen) |
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 |
// turns out these are identical at the moment. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
58 |
return get_D3D_varname_in_buf(ctx, rt, regnum, buf, buflen); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
59 |
} // get_ARB1_varname_in_buf |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
60 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
61 |
const char *get_ARB1_varname(Context *ctx, const RegisterType rt, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
62 |
const int regnum) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
63 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
64 |
// turns out these are identical at the moment. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
65 |
return get_D3D_varname(ctx, rt, regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
66 |
} // get_ARB1_varname |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
67 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
68 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
69 |
static inline const char *get_ARB1_const_array_varname_in_buf(Context *ctx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
70 |
const int base, const int size, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
71 |
char *buf, const size_t buflen) |
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 |
snprintf(buf, buflen, "c_array_%d_%d", base, size); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
74 |
return buf; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
75 |
} // get_ARB1_const_array_varname_in_buf |
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 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
78 |
const char *get_ARB1_const_array_varname(Context *ctx, int base, int size) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
79 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
80 |
char buf[64]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
81 |
get_ARB1_const_array_varname_in_buf(ctx, base, size, buf, sizeof (buf)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
82 |
return StrDup(ctx, buf); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
83 |
} // get_ARB1_const_array_varname |
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 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
86 |
const char *make_ARB1_srcarg_string_in_buf(Context *ctx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
87 |
const SourceArgInfo *arg, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
88 |
char *buf, size_t buflen) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
89 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
90 |
// !!! FIXME: this can hit pathological cases where we look like this... |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
91 |
// |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
92 |
// dp3 r1.xyz, t0_bx2, t0_bx2 |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
93 |
// mad r1.xyz, t0_bias, 1-r1, t0_bx2 |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
94 |
// |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
95 |
// ...which do a lot of duplicate work in arb1... |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
96 |
// |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
97 |
// SUB scratch0, t0, { 0.5, 0.5, 0.5, 0.5 }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
98 |
// MUL scratch0, scratch0, { 2.0, 2.0, 2.0, 2.0 }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
99 |
// SUB scratch1, t0, { 0.5, 0.5, 0.5, 0.5 }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
100 |
// MUL scratch1, scratch1, { 2.0, 2.0, 2.0, 2.0 }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
101 |
// DP3 r1.xyz, scratch0, scratch1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
102 |
// SUB scratch0, t0, { 0.5, 0.5, 0.5, 0.5 }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
103 |
// SUB scratch1, { 1.0, 1.0, 1.0, 1.0 }, r1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
104 |
// SUB scratch2, t0, { 0.5, 0.5, 0.5, 0.5 }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
105 |
// MUL scratch2, scratch2, { 2.0, 2.0, 2.0, 2.0 }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
106 |
// MAD r1.xyz, scratch0, scratch1, scratch2; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
107 |
// |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
108 |
// ...notice that the dp3 calculates the same value into two scratch |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
109 |
// registers. This case is easier to handle; just see if multiple |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
110 |
// source args are identical, build it up once, and use the same |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
111 |
// scratch register for multiple arguments in that opcode. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
112 |
// Even better still, only calculate things once across instructions, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
113 |
// and be smart about letting it linger in a scratch register until we |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
114 |
// definitely don't need the calculation anymore. That's harder to |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
115 |
// write, though. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
116 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
117 |
char regnum_str[16] = { '\0' }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
118 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
119 |
// !!! FIXME: use get_ARB1_varname_in_buf() instead? |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
120 |
const char *regtype_str = NULL; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
121 |
if (!arg->relative) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
122 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
123 |
regtype_str = get_ARB1_register_string(ctx, arg->regtype, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
124 |
arg->regnum, regnum_str, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
125 |
sizeof (regnum_str)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
126 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
127 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
128 |
const char *rel_lbracket = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
129 |
char rel_offset[32] = { '\0' }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
130 |
const char *rel_rbracket = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
131 |
char rel_swizzle[4] = { '\0' }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
132 |
const char *rel_regtype_str = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
133 |
if (arg->relative) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
134 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
135 |
rel_regtype_str = get_ARB1_varname_in_buf(ctx, arg->relative_regtype, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
136 |
arg->relative_regnum, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
137 |
(char *) alloca(64), 64); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
138 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
139 |
rel_swizzle[0] = '.'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
140 |
rel_swizzle[1] = swizzle_channels[arg->relative_component]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
141 |
rel_swizzle[2] = '\0'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
142 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
143 |
if (!support_nv2(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
144 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
145 |
// The address register in ARB1 only allows the '.x' component, so |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
146 |
// we need to load the component we need from a temp vector |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
147 |
// register into .x as needed. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
148 |
assert(arg->relative_regtype == REG_TYPE_ADDRESS); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
149 |
assert(arg->relative_regnum == 0); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
150 |
if (ctx->last_address_reg_component != arg->relative_component) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
151 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
152 |
output_line(ctx, "ARL %s.x, addr%d.%c;", rel_regtype_str, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
153 |
arg->relative_regnum, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
154 |
swizzle_channels[arg->relative_component]); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
155 |
ctx->last_address_reg_component = arg->relative_component; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
156 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
157 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
158 |
rel_swizzle[1] = 'x'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
159 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
160 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
161 |
if (arg->regtype == REG_TYPE_INPUT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
162 |
regtype_str = "vertex.attrib"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
163 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
164 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
165 |
assert(arg->regtype == REG_TYPE_CONST); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
166 |
const int arrayidx = arg->relative_array->index; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
167 |
const int arraysize = arg->relative_array->count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
168 |
const int offset = arg->regnum - arrayidx; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
169 |
assert(offset >= 0); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
170 |
regtype_str = get_ARB1_const_array_varname_in_buf(ctx, arrayidx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
171 |
arraysize, (char *) alloca(64), 64); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
172 |
if (offset != 0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
173 |
snprintf(rel_offset, sizeof (rel_offset), " + %d", offset); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
174 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
175 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
176 |
rel_lbracket = "["; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
177 |
rel_rbracket = "]"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
178 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
179 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
180 |
// This is the source register with everything but swizzle and source mods. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
181 |
snprintf(buf, buflen, "%s%s%s%s%s%s%s", regtype_str, regnum_str, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
182 |
rel_lbracket, rel_regtype_str, rel_swizzle, rel_offset, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
183 |
rel_rbracket); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
184 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
185 |
// Some of the source mods need to generate instructions to a temp |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
186 |
// register, in which case we'll replace the register name. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
187 |
const SourceMod mod = arg->src_mod; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
188 |
const int inplace = ( (mod == SRCMOD_NONE) || (mod == SRCMOD_NEGATE) || |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
189 |
((mod == SRCMOD_ABS) && support_nv2(ctx)) ); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
190 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
191 |
if (!inplace) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
192 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
193 |
const size_t len = 64; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
194 |
char *stackbuf = (char *) alloca(len); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
195 |
regtype_str = allocate_ARB1_scratch_reg_name(ctx, stackbuf, len); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
196 |
regnum_str[0] = '\0'; // move value to scratch register. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
197 |
rel_lbracket = ""; // scratch register won't use array. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
198 |
rel_rbracket = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
199 |
rel_offset[0] = '\0'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
200 |
rel_swizzle[0] = '\0'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
201 |
rel_regtype_str = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
202 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
203 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
204 |
const char *premod_str = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
205 |
const char *postmod_str = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
206 |
switch (mod) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
207 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
208 |
case SRCMOD_NEGATE: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
209 |
premod_str = "-"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
210 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
211 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
212 |
case SRCMOD_BIASNEGATE: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
213 |
premod_str = "-"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
214 |
// fall through. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
215 |
case SRCMOD_BIAS: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
216 |
output_line(ctx, "SUB %s, %s, { 0.5, 0.5, 0.5, 0.5 };", |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
217 |
regtype_str, buf); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
218 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
219 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
220 |
case SRCMOD_SIGNNEGATE: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
221 |
premod_str = "-"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
222 |
// fall through. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
223 |
case SRCMOD_SIGN: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
224 |
output_line(ctx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
225 |
"MAD %s, %s, { 2.0, 2.0, 2.0, 2.0 }, { -1.0, -1.0, -1.0, -1.0 };", |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
226 |
regtype_str, buf); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
227 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
228 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
229 |
case SRCMOD_COMPLEMENT: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
230 |
output_line(ctx, "SUB %s, { 1.0, 1.0, 1.0, 1.0 }, %s;", |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
231 |
regtype_str, buf); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
232 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
233 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
234 |
case SRCMOD_X2NEGATE: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
235 |
premod_str = "-"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
236 |
// fall through. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
237 |
case SRCMOD_X2: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
238 |
output_line(ctx, "MUL %s, %s, { 2.0, 2.0, 2.0, 2.0 };", |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
239 |
regtype_str, buf); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
240 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
241 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
242 |
case SRCMOD_DZ: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
243 |
fail(ctx, "SRCMOD_DZ currently unsupported in arb1"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
244 |
postmod_str = "_dz"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
245 |
break; |
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 |
case SRCMOD_DW: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
248 |
fail(ctx, "SRCMOD_DW currently unsupported in arb1"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
249 |
postmod_str = "_dw"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
250 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
251 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
252 |
case SRCMOD_ABSNEGATE: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
253 |
premod_str = "-"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
254 |
// fall through. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
255 |
case SRCMOD_ABS: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
256 |
if (!support_nv2(ctx)) // GL_NV_vertex_program2_option adds this. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
257 |
output_line(ctx, "ABS %s, %s;", regtype_str, buf); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
258 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
259 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
260 |
premod_str = (mod == SRCMOD_ABSNEGATE) ? "-|" : "|"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
261 |
postmod_str = "|"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
262 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
263 |
break; |
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 |
case SRCMOD_NOT: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
266 |
fail(ctx, "SRCMOD_NOT currently unsupported in arb1"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
267 |
premod_str = "!"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
268 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
269 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
270 |
case SRCMOD_NONE: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
271 |
case SRCMOD_TOTAL: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
272 |
break; // stop compiler whining. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
273 |
} // switch |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
274 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
275 |
char swizzle_str[6]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
276 |
size_t i = 0; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
277 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
278 |
if (support_nv4(ctx)) // vFace must be output as "vFace.x" in nv4. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
279 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
280 |
if (arg->regtype == REG_TYPE_MISCTYPE) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
281 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
282 |
if ( ((const MiscTypeType) arg->regnum) == MISCTYPE_TYPE_FACE ) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
283 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
284 |
swizzle_str[i++] = '.'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
285 |
swizzle_str[i++] = 'x'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
286 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
287 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
288 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
289 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
290 |
const int scalar = isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
291 |
if (!scalar && !no_swizzle(arg->swizzle)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
292 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
293 |
swizzle_str[i++] = '.'; |
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 |
// .xxxx is the same as .x, but .xx is illegal...scalar or full! |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
296 |
if (replicate_swizzle(arg->swizzle)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
297 |
swizzle_str[i++] = swizzle_channels[arg->swizzle_x]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
298 |
else |
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 |
swizzle_str[i++] = swizzle_channels[arg->swizzle_x]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
301 |
swizzle_str[i++] = swizzle_channels[arg->swizzle_y]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
302 |
swizzle_str[i++] = swizzle_channels[arg->swizzle_z]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
303 |
swizzle_str[i++] = swizzle_channels[arg->swizzle_w]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
304 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
305 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
306 |
swizzle_str[i] = '\0'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
307 |
assert(i < sizeof (swizzle_str)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
308 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
309 |
snprintf(buf, buflen, "%s%s%s%s%s%s%s%s%s%s", premod_str, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
310 |
regtype_str, regnum_str, rel_lbracket, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
311 |
rel_regtype_str, rel_swizzle, rel_offset, rel_rbracket, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
312 |
swizzle_str, postmod_str); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
313 |
// !!! FIXME: make sure the scratch buffer was large enough. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
314 |
return buf; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
315 |
} // make_ARB1_srcarg_string_in_buf |
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 |
const char *get_ARB1_destarg_varname(Context *ctx, char *buf, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
318 |
const size_t buflen) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
319 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
320 |
const DestArgInfo *arg = &ctx->dest_arg; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
321 |
return get_ARB1_varname_in_buf(ctx, arg->regtype, arg->regnum, buf, buflen); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
322 |
} // get_ARB1_destarg_varname |
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 |
const char *get_ARB1_srcarg_varname(Context *ctx, const size_t idx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
325 |
char *buf, const size_t buflen) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
326 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
327 |
if (idx >= STATICARRAYLEN(ctx->source_args)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
328 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
329 |
fail(ctx, "Too many source args"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
330 |
*buf = '\0'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
331 |
return buf; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
332 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
333 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
334 |
const SourceArgInfo *arg = &ctx->source_args[idx]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
335 |
return get_ARB1_varname_in_buf(ctx, arg->regtype, arg->regnum, buf, buflen); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
336 |
} // get_ARB1_srcarg_varname |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
337 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
338 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
339 |
const char *make_ARB1_destarg_string(Context *ctx, char *buf, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
340 |
const size_t buflen) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
341 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
342 |
const DestArgInfo *arg = &ctx->dest_arg; |
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 |
*buf = '\0'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
345 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
346 |
const char *sat_str = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
347 |
if (arg->result_mod & MOD_SATURATE) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
348 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
349 |
// nv4 can use ".SAT" in all program types. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
350 |
// For less than nv4, the "_SAT" modifier is only available in |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
351 |
// fragment shaders. Every thing else will fake it later in |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
352 |
// emit_ARB1_dest_modifiers() ... |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
353 |
if (support_nv4(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
354 |
sat_str = ".SAT"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
355 |
else if (shader_is_pixel(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
356 |
sat_str = "_SAT"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
357 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
358 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
359 |
const char *pp_str = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
360 |
if (arg->result_mod & MOD_PP) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
361 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
362 |
// Most ARB1 profiles can't do partial precision (MOD_PP), but that's |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
363 |
// okay. The spec says lots of Direct3D implementations ignore the |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
364 |
// flag anyhow. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
365 |
if (support_nv4(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
366 |
pp_str = "H"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
367 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
368 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
369 |
// CENTROID only allowed in DCL opcodes, which shouldn't come through here. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
370 |
assert((arg->result_mod & MOD_CENTROID) == 0); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
371 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
372 |
char regnum_str[16]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
373 |
const char *regtype_str = get_ARB1_register_string(ctx, arg->regtype, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
374 |
arg->regnum, regnum_str, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
375 |
sizeof (regnum_str)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
376 |
if (regtype_str == NULL) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
377 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
378 |
fail(ctx, "Unknown destination register type."); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
379 |
return buf; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
380 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
381 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
382 |
char writemask_str[6]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
383 |
size_t i = 0; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
384 |
const int scalar = isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
385 |
if (!scalar && !writemask_xyzw(arg->writemask)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
386 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
387 |
writemask_str[i++] = '.'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
388 |
if (arg->writemask0) writemask_str[i++] = 'x'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
389 |
if (arg->writemask1) writemask_str[i++] = 'y'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
390 |
if (arg->writemask2) writemask_str[i++] = 'z'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
391 |
if (arg->writemask3) writemask_str[i++] = 'w'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
392 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
393 |
writemask_str[i] = '\0'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
394 |
assert(i < sizeof (writemask_str)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
395 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
396 |
//const char *pred_left = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
397 |
//const char *pred_right = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
398 |
char pred[32] = { '\0' }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
399 |
if (ctx->predicated) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
400 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
401 |
fail(ctx, "dest register predication currently unsupported in arb1"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
402 |
return buf; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
403 |
//pred_left = "("; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
404 |
//pred_right = ") "; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
405 |
make_ARB1_srcarg_string_in_buf(ctx, &ctx->predicate_arg, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
406 |
pred, sizeof (pred)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
407 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
408 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
409 |
snprintf(buf, buflen, "%s%s %s%s%s", pp_str, sat_str, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
410 |
regtype_str, regnum_str, writemask_str); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
411 |
// !!! FIXME: make sure the scratch buffer was large enough. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
412 |
return buf; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
413 |
} // make_ARB1_destarg_string |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
414 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
415 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
416 |
void emit_ARB1_dest_modifiers(Context *ctx) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
417 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
418 |
const DestArgInfo *arg = &ctx->dest_arg; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
419 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
420 |
if (arg->result_shift != 0x0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
421 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
422 |
char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
423 |
const char *multiplier = NULL; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
424 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
425 |
switch (arg->result_shift) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
426 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
427 |
case 0x1: multiplier = "2.0"; break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
428 |
case 0x2: multiplier = "4.0"; break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
429 |
case 0x3: multiplier = "8.0"; break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
430 |
case 0xD: multiplier = "0.125"; break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
431 |
case 0xE: multiplier = "0.25"; break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
432 |
case 0xF: multiplier = "0.5"; break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
433 |
} // switch |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
434 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
435 |
if (multiplier != NULL) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
436 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
437 |
char var[64]; get_ARB1_destarg_varname(ctx, var, sizeof (var)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
438 |
output_line(ctx, "MUL%s, %s, %s;", dst, var, multiplier); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
439 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
440 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
441 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
442 |
if (arg->result_mod & MOD_SATURATE) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
443 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
444 |
// nv4 and/or pixel shaders just used the "SAT" modifier, instead. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
445 |
if ( (!support_nv4(ctx)) && (!shader_is_pixel(ctx)) ) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
446 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
447 |
char var[64]; get_ARB1_destarg_varname(ctx, var, sizeof (var)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
448 |
char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
449 |
output_line(ctx, "MIN%s, %s, 1.0;", dst, var); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
450 |
output_line(ctx, "MAX%s, %s, 0.0;", dst, var); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
451 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
452 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
453 |
} // emit_ARB1_dest_modifiers |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
454 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
455 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
456 |
const char *make_ARB1_srcarg_string(Context *ctx, const size_t idx, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
457 |
char *buf, const size_t buflen) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
458 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
459 |
if (idx >= STATICARRAYLEN(ctx->source_args)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
460 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
461 |
fail(ctx, "Too many source args"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
462 |
*buf = '\0'; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
463 |
return buf; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
464 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
465 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
466 |
const SourceArgInfo *arg = &ctx->source_args[idx]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
467 |
return make_ARB1_srcarg_string_in_buf(ctx, arg, buf, buflen); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
468 |
} // make_ARB1_srcarg_string |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
469 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
470 |
void emit_ARB1_opcode_ds(Context *ctx, const char *opcode) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
471 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
472 |
char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
473 |
char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
474 |
output_line(ctx, "%s%s, %s;", opcode, dst, src0); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
475 |
emit_ARB1_dest_modifiers(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
476 |
} // emit_ARB1_opcode_ds |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
477 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
478 |
void emit_ARB1_opcode_dss(Context *ctx, const char *opcode) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
479 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
480 |
char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
481 |
char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
482 |
char src1[64]; make_ARB1_srcarg_string(ctx, 1, src1, sizeof (src1)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
483 |
output_line(ctx, "%s%s, %s, %s;", opcode, dst, src0, src1); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
484 |
emit_ARB1_dest_modifiers(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
485 |
} // emit_ARB1_opcode_dss |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
486 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
487 |
void emit_ARB1_opcode_dsss(Context *ctx, const char *opcode) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
488 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
489 |
char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
490 |
char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
491 |
char src1[64]; make_ARB1_srcarg_string(ctx, 1, src1, sizeof (src1)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
492 |
char src2[64]; make_ARB1_srcarg_string(ctx, 2, src2, sizeof (src2)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
493 |
output_line(ctx, "%s%s, %s, %s, %s;", opcode, dst, src0, src1, src2); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
494 |
emit_ARB1_dest_modifiers(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
495 |
} // emit_ARB1_opcode_dsss |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
496 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
497 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
498 |
#define EMIT_ARB1_OPCODE_FUNC(op) \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
499 |
void emit_ARB1_##op(Context *ctx) { \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
500 |
emit_ARB1_opcode(ctx, #op); \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
501 |
} |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
502 |
#define EMIT_ARB1_OPCODE_D_FUNC(op) \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
503 |
void emit_ARB1_##op(Context *ctx) { \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
504 |
emit_ARB1_opcode_d(ctx, #op); \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
505 |
} |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
506 |
#define EMIT_ARB1_OPCODE_S_FUNC(op) \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
507 |
void emit_ARB1_##op(Context *ctx) { \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
508 |
emit_ARB1_opcode_s(ctx, #op); \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
509 |
} |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
510 |
#define EMIT_ARB1_OPCODE_SS_FUNC(op) \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
511 |
void emit_ARB1_##op(Context *ctx) { \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
512 |
emit_ARB1_opcode_ss(ctx, #op); \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
513 |
} |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
514 |
#define EMIT_ARB1_OPCODE_DS_FUNC(op) \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
515 |
void emit_ARB1_##op(Context *ctx) { \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
516 |
emit_ARB1_opcode_ds(ctx, #op); \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
517 |
} |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
518 |
#define EMIT_ARB1_OPCODE_DSS_FUNC(op) \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
519 |
void emit_ARB1_##op(Context *ctx) { \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
520 |
emit_ARB1_opcode_dss(ctx, #op); \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
521 |
} |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
522 |
#define EMIT_ARB1_OPCODE_DSSS_FUNC(op) \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
523 |
void emit_ARB1_##op(Context *ctx) { \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
524 |
emit_ARB1_opcode_dsss(ctx, #op); \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
525 |
} |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
526 |
#define EMIT_ARB1_OPCODE_DSSSS_FUNC(op) \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
527 |
void emit_ARB1_##op(Context *ctx) { \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
528 |
emit_ARB1_opcode_dssss(ctx, #op); \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
529 |
} |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
530 |
#define EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(op) \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
531 |
void emit_ARB1_##op(Context *ctx) { \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
532 |
failf(ctx, #op " unimplemented in %s profile", ctx->profile->name); \ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
533 |
} |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
534 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
535 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
536 |
void emit_ARB1_start(Context *ctx, const char *profilestr) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
537 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
538 |
const char *shader_str = NULL; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
539 |
const char *shader_full_str = NULL; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
540 |
if (shader_is_vertex(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
541 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
542 |
shader_str = "vp"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
543 |
shader_full_str = "vertex"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
544 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
545 |
else if (shader_is_pixel(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
546 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
547 |
shader_str = "fp"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
548 |
shader_full_str = "fragment"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
549 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
550 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
551 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
552 |
failf(ctx, "Shader type %u unsupported in this profile.", |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
553 |
(uint) ctx->shader_type); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
554 |
return; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
555 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
556 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
557 |
set_output(ctx, &ctx->preflight); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
558 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
559 |
if (strcmp(profilestr, MOJOSHADER_PROFILE_ARB1) == 0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
560 |
output_line(ctx, "!!ARB%s1.0", shader_str); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
561 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
562 |
#if SUPPORT_PROFILE_ARB1_NV |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
563 |
else if (strcmp(profilestr, MOJOSHADER_PROFILE_NV2) == 0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
564 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
565 |
ctx->profile_supports_nv2 = 1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
566 |
output_line(ctx, "!!ARB%s1.0", shader_str); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
567 |
output_line(ctx, "OPTION NV_%s_program2;", shader_full_str); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
568 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
569 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
570 |
else if (strcmp(profilestr, MOJOSHADER_PROFILE_NV3) == 0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
571 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
572 |
// there's no NV_fragment_program3, so just use 2. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
573 |
const int ver = shader_is_pixel(ctx) ? 2 : 3; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
574 |
ctx->profile_supports_nv2 = 1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
575 |
ctx->profile_supports_nv3 = 1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
576 |
output_line(ctx, "!!ARB%s1.0", shader_str); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
577 |
output_line(ctx, "OPTION NV_%s_program%d;", shader_full_str, ver); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
578 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
579 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
580 |
else if (strcmp(profilestr, MOJOSHADER_PROFILE_NV4) == 0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
581 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
582 |
ctx->profile_supports_nv2 = 1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
583 |
ctx->profile_supports_nv3 = 1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
584 |
ctx->profile_supports_nv4 = 1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
585 |
output_line(ctx, "!!NV%s4.0", shader_str); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
586 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
587 |
#endif |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
588 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
589 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
590 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
591 |
failf(ctx, "Profile '%s' unsupported or unknown.", profilestr); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
592 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
593 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
594 |
set_output(ctx, &ctx->mainline); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
595 |
} // emit_ARB1_start |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
596 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
597 |
void emit_ARB1_end(Context *ctx) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
598 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
599 |
// ps_1_* writes color to r0 instead oC0. We move it to the right place. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
600 |
// We don't have to worry about a RET opcode messing this up, since |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
601 |
// RET isn't available before ps_2_0. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
602 |
if (shader_is_pixel(ctx) && !shader_version_atleast(ctx, 2, 0)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
603 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
604 |
set_used_register(ctx, REG_TYPE_COLOROUT, 0, 1); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
605 |
output_line(ctx, "MOV oC0, r0;"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
606 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
607 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
608 |
output_line(ctx, "END"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
609 |
} // emit_ARB1_end |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
610 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
611 |
void emit_ARB1_phase(Context *ctx) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
612 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
613 |
// no-op in arb1. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
614 |
} // emit_ARB1_phase |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
615 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
616 |
static inline const char *arb1_float_temp(const Context *ctx) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
617 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
618 |
// nv4 lets you specify data type. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
619 |
return (support_nv4(ctx)) ? "FLOAT TEMP" : "TEMP"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
620 |
} // arb1_float_temp |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
621 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
622 |
void emit_ARB1_finalize(Context *ctx) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
623 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
624 |
push_output(ctx, &ctx->preflight); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
625 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
626 |
if (shader_is_vertex(ctx) && !ctx->arb1_wrote_position) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
627 |
output_line(ctx, "OPTION ARB_position_invariant;"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
628 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
629 |
if (shader_is_pixel(ctx) && ctx->have_multi_color_outputs) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
630 |
output_line(ctx, "OPTION ARB_draw_buffers;"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
631 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
632 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
633 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
634 |
const char *tmpstr = arb1_float_temp(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
635 |
int i; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
636 |
push_output(ctx, &ctx->globals); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
637 |
for (i = 0; i < ctx->max_scratch_registers; i++) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
638 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
639 |
char buf[64]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
640 |
allocate_ARB1_scratch_reg_name(ctx, buf, sizeof (buf)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
641 |
output_line(ctx, "%s %s;", tmpstr, buf); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
642 |
} // for |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
643 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
644 |
// nv2 fragment programs (and anything nv4) have a real REP/ENDREP. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
645 |
if ( (support_nv2(ctx)) && (!shader_is_pixel(ctx)) && (!support_nv4(ctx)) ) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
646 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
647 |
// set up temps for nv2 REP/ENDREP emulation through branching. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
648 |
for (i = 0; i < ctx->max_reps; i++) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
649 |
output_line(ctx, "TEMP rep%d;", i); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
650 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
651 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
652 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
653 |
assert(ctx->scratch_registers == ctx->max_scratch_registers); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
654 |
} // emit_ARB1_finalize |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
655 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
656 |
void emit_ARB1_global(Context *ctx, RegisterType regtype, int regnum) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
657 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
658 |
// !!! FIXME: dependency on ARB1 profile. // !!! FIXME about FIXME: huh? |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
659 |
char varname[64]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
660 |
get_ARB1_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
661 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
662 |
push_output(ctx, &ctx->globals); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
663 |
switch (regtype) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
664 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
665 |
case REG_TYPE_ADDRESS: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
666 |
if (shader_is_pixel(ctx)) // actually REG_TYPE_TEXTURE. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
667 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
668 |
// We have to map texture registers to temps for ps_1_1, since |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
669 |
// they work like temps, initialize with tex coords, and the |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
670 |
// ps_1_1 TEX opcode expects to overwrite it. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
671 |
if (!shader_version_atleast(ctx, 1, 4)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
672 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
673 |
output_line(ctx, "%s %s;", arb1_float_temp(ctx), varname); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
674 |
push_output(ctx, &ctx->mainline_top); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
675 |
output_line(ctx, "MOV %s, fragment.texcoord[%d];", |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
676 |
varname, regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
677 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
678 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
679 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
680 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
681 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
682 |
// nv4 replaced address registers with generic int registers. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
683 |
if (support_nv4(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
684 |
output_line(ctx, "INT TEMP %s;", varname); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
685 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
686 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
687 |
// nv2 has four-component address already, but stock arb1 has |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
688 |
// to emulate it in a temporary, and move components to the |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
689 |
// scalar ADDRESS register on demand. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
690 |
output_line(ctx, "ADDRESS %s;", varname); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
691 |
if (!support_nv2(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
692 |
output_line(ctx, "TEMP addr%d;", regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
693 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
694 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
695 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
696 |
//case REG_TYPE_PREDICATE: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
697 |
// output_line(ctx, "bvec4 %s;", varname); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
698 |
// break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
699 |
case REG_TYPE_TEMP: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
700 |
output_line(ctx, "%s %s;", arb1_float_temp(ctx), varname); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
701 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
702 |
//case REG_TYPE_LOOP: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
703 |
// break; // no-op. We declare these in for loops at the moment. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
704 |
//case REG_TYPE_LABEL: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
705 |
// break; // no-op. If we see it here, it means we optimized it out. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
706 |
default: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
707 |
fail(ctx, "BUG: we used a register we don't know how to define."); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
708 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
709 |
} // switch |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
710 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
711 |
} // emit_ARB1_global |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
712 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
713 |
void emit_ARB1_array(Context *ctx, VariableList *var) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
714 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
715 |
// All uniforms are now packed tightly into the program.local array, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
716 |
// instead of trying to map them to the d3d registers. So this needs to |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
717 |
// map to the next piece of the array we haven't used yet. Thankfully, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
718 |
// arb1 lets you make a PARAM array that maps to a subset of another |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
719 |
// array; we don't need to do offsets, since myarray[0] can map to |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
720 |
// program.local[5] without any extra math from us. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
721 |
const int base = var->index; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
722 |
const int size = var->count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
723 |
const int arb1base = ctx->uniform_float4_count + |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
724 |
ctx->uniform_int4_count + |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
725 |
ctx->uniform_bool_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
726 |
char varname[64]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
727 |
get_ARB1_const_array_varname_in_buf(ctx, base, size, varname, sizeof (varname)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
728 |
push_output(ctx, &ctx->globals); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
729 |
output_line(ctx, "PARAM %s[%d] = { program.local[%d..%d] };", varname, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
730 |
size, arb1base, (arb1base + size) - 1); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
731 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
732 |
var->emit_position = arb1base; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
733 |
} // emit_ARB1_array |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
734 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
735 |
void emit_ARB1_const_array(Context *ctx, const ConstantsList *clist, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
736 |
int base, int size) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
737 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
738 |
char varname[64]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
739 |
get_ARB1_const_array_varname_in_buf(ctx, base, size, varname, sizeof (varname)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
740 |
int i; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
741 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
742 |
push_output(ctx, &ctx->globals); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
743 |
output_line(ctx, "PARAM %s[%d] = {", varname, size); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
744 |
ctx->indent++; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
745 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
746 |
for (i = 0; i < size; i++) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
747 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
748 |
while (clist->constant.type != MOJOSHADER_UNIFORM_FLOAT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
749 |
clist = clist->next; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
750 |
assert(clist->constant.index == (base + i)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
751 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
752 |
char val0[32]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
753 |
char val1[32]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
754 |
char val2[32]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
755 |
char val3[32]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
756 |
floatstr(ctx, val0, sizeof (val0), clist->constant.value.f[0], 1); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
757 |
floatstr(ctx, val1, sizeof (val1), clist->constant.value.f[1], 1); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
758 |
floatstr(ctx, val2, sizeof (val2), clist->constant.value.f[2], 1); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
759 |
floatstr(ctx, val3, sizeof (val3), clist->constant.value.f[3], 1); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
760 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
761 |
output_line(ctx, "{ %s, %s, %s, %s }%s", val0, val1, val2, val3, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
762 |
(i < (size-1)) ? "," : ""); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
763 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
764 |
clist = clist->next; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
765 |
} // for |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
766 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
767 |
ctx->indent--; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
768 |
output_line(ctx, "};"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
769 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
770 |
} // emit_ARB1_const_array |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
771 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
772 |
void emit_ARB1_uniform(Context *ctx, RegisterType regtype, int regnum, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
773 |
const VariableList *var) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
774 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
775 |
// We pack these down into the program.local array, so if we only use |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
776 |
// register c439, it'll actually map to program.local[0]. This will |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
777 |
// prevent overflows when we actually have enough resources to run. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
778 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
779 |
const char *arrayname = "program.local"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
780 |
int index = 0; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
781 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
782 |
char varname[64]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
783 |
get_ARB1_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
784 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
785 |
push_output(ctx, &ctx->globals); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
786 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
787 |
if (var == NULL) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
788 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
789 |
// all types share one array (rather, all types convert to float4). |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
790 |
index = ctx->uniform_float4_count + ctx->uniform_int4_count + |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
791 |
ctx->uniform_bool_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
792 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
793 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
794 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
795 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
796 |
const int arraybase = var->index; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
797 |
if (var->constant) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
798 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
799 |
const int arraysize = var->count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
800 |
arrayname = get_ARB1_const_array_varname_in_buf(ctx, arraybase, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
801 |
arraysize, (char *) alloca(64), 64); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
802 |
index = (regnum - arraybase); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
803 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
804 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
805 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
806 |
assert(var->emit_position != -1); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
807 |
index = (regnum - arraybase) + var->emit_position; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
808 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
809 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
810 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
811 |
output_line(ctx, "PARAM %s = %s[%d];", varname, arrayname, index); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
812 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
813 |
} // emit_ARB1_uniform |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
814 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
815 |
void emit_ARB1_sampler(Context *ctx,int stage,TextureType ttype,int tb) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
816 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
817 |
// this is mostly a no-op...you don't predeclare samplers in arb1. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
818 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
819 |
if (tb) // This sampler used a ps_1_1 TEXBEM opcode? |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
820 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
821 |
const int index = ctx->uniform_float4_count + ctx->uniform_int4_count + |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
822 |
ctx->uniform_bool_count; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
823 |
char var[64]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
824 |
get_ARB1_varname_in_buf(ctx, REG_TYPE_SAMPLER, stage, var, sizeof(var)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
825 |
push_output(ctx, &ctx->globals); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
826 |
output_line(ctx, "PARAM %s_texbem = program.local[%d];", var, index); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
827 |
output_line(ctx, "PARAM %s_texbeml = program.local[%d];", var, index+1); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
828 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
829 |
ctx->uniform_float4_count += 2; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
830 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
831 |
} // emit_ARB1_sampler |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
832 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
833 |
// !!! FIXME: a lot of cut-and-paste here from emit_GLSL_attribute(). |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
834 |
void emit_ARB1_attribute(Context *ctx, RegisterType regtype, int regnum, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
835 |
MOJOSHADER_usage usage, int index, int wmask, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
836 |
int flags) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
837 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
838 |
// !!! FIXME: this function doesn't deal with write masks at all yet! |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
839 |
const char *usage_str = NULL; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
840 |
const char *arrayleft = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
841 |
const char *arrayright = ""; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
842 |
char index_str[16] = { '\0' }; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
843 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
844 |
char varname[64]; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
845 |
get_ARB1_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
846 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
847 |
//assert((flags & MOD_PP) == 0); // !!! FIXME: is PP allowed? |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
848 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
849 |
if (index != 0) // !!! FIXME: a lot of these MUST be zero. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
850 |
snprintf(index_str, sizeof (index_str), "%u", (uint) index); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
851 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
852 |
if (shader_is_vertex(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
853 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
854 |
// pre-vs3 output registers. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
855 |
// these don't ever happen in DCL opcodes, I think. Map to vs_3_* |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
856 |
// output registers. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
857 |
if (!shader_version_atleast(ctx, 3, 0)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
858 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
859 |
if (regtype == REG_TYPE_RASTOUT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
860 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
861 |
regtype = REG_TYPE_OUTPUT; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
862 |
index = regnum; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
863 |
switch ((const RastOutType) regnum) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
864 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
865 |
case RASTOUT_TYPE_POSITION: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
866 |
usage = MOJOSHADER_USAGE_POSITION; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
867 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
868 |
case RASTOUT_TYPE_FOG: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
869 |
usage = MOJOSHADER_USAGE_FOG; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
870 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
871 |
case RASTOUT_TYPE_POINT_SIZE: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
872 |
usage = MOJOSHADER_USAGE_POINTSIZE; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
873 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
874 |
} // switch |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
875 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
876 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
877 |
else if (regtype == REG_TYPE_ATTROUT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
878 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
879 |
regtype = REG_TYPE_OUTPUT; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
880 |
usage = MOJOSHADER_USAGE_COLOR; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
881 |
index = regnum; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
882 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
883 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
884 |
else if (regtype == REG_TYPE_TEXCRDOUT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
885 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
886 |
regtype = REG_TYPE_OUTPUT; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
887 |
usage = MOJOSHADER_USAGE_TEXCOORD; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
888 |
index = regnum; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
889 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
890 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
891 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
892 |
// to avoid limitations of various GL entry points for input |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
893 |
// attributes (glSecondaryColorPointer() can only take 3 component |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
894 |
// items, glVertexPointer() can't do GL_UNSIGNED_BYTE, many other |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
895 |
// issues), we set up all inputs as generic vertex attributes, so we |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
896 |
// can pass data in just about any form, and ignore the built-in GLSL |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
897 |
// attributes like gl_SecondaryColor. Output needs to use the the |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
898 |
// built-ins, though, but we don't have to worry about the GL entry |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
899 |
// point limitations there. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
900 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
901 |
if (regtype == REG_TYPE_INPUT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
902 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
903 |
const int attr = ctx->assigned_vertex_attributes++; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
904 |
push_output(ctx, &ctx->globals); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
905 |
output_line(ctx, "ATTRIB %s = vertex.attrib[%d];", varname, attr); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
906 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
907 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
908 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
909 |
else if (regtype == REG_TYPE_OUTPUT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
910 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
911 |
switch (usage) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
912 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
913 |
case MOJOSHADER_USAGE_POSITION: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
914 |
ctx->arb1_wrote_position = 1; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
915 |
usage_str = "result.position"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
916 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
917 |
case MOJOSHADER_USAGE_POINTSIZE: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
918 |
usage_str = "result.pointsize"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
919 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
920 |
case MOJOSHADER_USAGE_COLOR: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
921 |
index_str[0] = '\0'; // no explicit number. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
922 |
if (index == 0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
923 |
usage_str = "result.color.primary"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
924 |
else if (index == 1) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
925 |
usage_str = "result.color.secondary"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
926 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
927 |
case MOJOSHADER_USAGE_FOG: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
928 |
usage_str = "result.fogcoord"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
929 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
930 |
case MOJOSHADER_USAGE_TEXCOORD: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
931 |
snprintf(index_str, sizeof (index_str), "%u", (uint) index); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
932 |
usage_str = "result.texcoord"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
933 |
arrayleft = "["; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
934 |
arrayright = "]"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
935 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
936 |
default: |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
937 |
// !!! FIXME: we need to deal with some more built-in varyings here. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
938 |
break; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
939 |
} // switch |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
940 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
941 |
// !!! FIXME: the #define is a little hacky, but it means we don't |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
942 |
// !!! FIXME: have to track these separately if this works. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
943 |
push_output(ctx, &ctx->globals); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
944 |
// no mapping to built-in var? Just make it a regular global, pray. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
945 |
if (usage_str == NULL) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
946 |
output_line(ctx, "%s %s;", arb1_float_temp(ctx), varname); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
947 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
948 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
949 |
output_line(ctx, "OUTPUT %s = %s%s%s%s;", varname, usage_str, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
950 |
arrayleft, index_str, arrayright); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
951 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
952 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
953 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
954 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
955 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
956 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
957 |
fail(ctx, "unknown vertex shader attribute register"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
958 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
959 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
960 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
961 |
else if (shader_is_pixel(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
962 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
963 |
const char *paramtype_str = "ATTRIB"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
964 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
965 |
// samplers DCLs get handled in emit_ARB1_sampler(). |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
966 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
967 |
if (flags & MOD_CENTROID) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
968 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
969 |
if (!support_nv4(ctx)) // GL_NV_fragment_program4 adds centroid. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
970 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
971 |
// !!! FIXME: should we just wing it without centroid here? |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
972 |
failf(ctx, "centroid unsupported in %s profile", |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
973 |
ctx->profile->name); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
974 |
return; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
975 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
976 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
977 |
paramtype_str = "CENTROID ATTRIB"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
978 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
979 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
980 |
if (regtype == REG_TYPE_COLOROUT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
981 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
982 |
paramtype_str = "OUTPUT"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
983 |
usage_str = "result.color"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
984 |
if (ctx->have_multi_color_outputs) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
985 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
986 |
// We have to gamble that you have GL_ARB_draw_buffers. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
987 |
// You probably do at this point if you have a sane setup. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
988 |
snprintf(index_str, sizeof (index_str), "%u", (uint) regnum); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
989 |
arrayleft = "["; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
990 |
arrayright = "]"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
991 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
992 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
993 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
994 |
else if (regtype == REG_TYPE_DEPTHOUT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
995 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
996 |
paramtype_str = "OUTPUT"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
997 |
usage_str = "result.depth"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
998 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
999 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1000 |
// !!! FIXME: can you actualy have a texture register with COLOR usage? |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1001 |
else if ((regtype == REG_TYPE_TEXTURE) || (regtype == REG_TYPE_INPUT)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1002 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1003 |
if (usage == MOJOSHADER_USAGE_TEXCOORD) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1004 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1005 |
// ps_1_1 does a different hack for this attribute. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1006 |
// Refer to emit_ARB1_global()'s REG_TYPE_TEXTURE code. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1007 |
if (shader_version_atleast(ctx, 1, 4)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1008 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1009 |
snprintf(index_str, sizeof (index_str), "%u", (uint) index); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1010 |
usage_str = "fragment.texcoord"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1011 |
arrayleft = "["; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1012 |
arrayright = "]"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1013 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1014 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1015 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1016 |
else if (usage == MOJOSHADER_USAGE_COLOR) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1017 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1018 |
index_str[0] = '\0'; // no explicit number. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1019 |
if (index == 0) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1020 |
usage_str = "fragment.color.primary"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1021 |
else if (index == 1) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1022 |
usage_str = "fragment.color.secondary"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1023 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1024 |
fail(ctx, "unsupported color index"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1025 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1026 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1027 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1028 |
else if (regtype == REG_TYPE_MISCTYPE) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1029 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1030 |
const MiscTypeType mt = (MiscTypeType) regnum; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1031 |
if (mt == MISCTYPE_TYPE_FACE) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1032 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1033 |
if (support_nv4(ctx)) // FINALLY, a vFace equivalent in nv4! |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1034 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1035 |
index_str[0] = '\0'; // no explicit number. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1036 |
usage_str = "fragment.facing"; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1037 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1038 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1039 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1040 |
failf(ctx, "vFace unsupported in %s profile", |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1041 |
ctx->profile->name); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1042 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1043 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1044 |
else if (mt == MISCTYPE_TYPE_POSITION) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1045 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1046 |
index_str[0] = '\0'; // no explicit number. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1047 |
usage_str = "fragment.position"; // !!! FIXME: is this the same coord space as D3D? |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1048 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1049 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1050 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1051 |
fail(ctx, "BUG: unhandled misc register"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1052 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1053 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1054 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1055 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1056 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1057 |
fail(ctx, "unknown pixel shader attribute register"); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1058 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1059 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1060 |
if (usage_str != NULL) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1061 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1062 |
push_output(ctx, &ctx->globals); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1063 |
output_line(ctx, "%s %s = %s%s%s%s;", paramtype_str, varname, |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1064 |
usage_str, arrayleft, index_str, arrayright); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1065 |
pop_output(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1066 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1067 |
} // else if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1068 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1069 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1070 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1071 |
fail(ctx, "Unknown shader type"); // state machine should catch this. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1072 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1073 |
} // emit_ARB1_attribute |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1074 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1075 |
void emit_ARB1_RESERVED(Context *ctx) { /* no-op. */ } |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1076 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1077 |
void emit_ARB1_NOP(Context *ctx) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1078 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1079 |
// There is no NOP in arb1. Just don't output anything here. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1080 |
} // emit_ARB1_NOP |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1081 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1082 |
EMIT_ARB1_OPCODE_DS_FUNC(MOV) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1083 |
EMIT_ARB1_OPCODE_DSS_FUNC(ADD) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1084 |
EMIT_ARB1_OPCODE_DSS_FUNC(SUB) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1085 |
EMIT_ARB1_OPCODE_DSSS_FUNC(MAD) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1086 |
EMIT_ARB1_OPCODE_DSS_FUNC(MUL) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1087 |
EMIT_ARB1_OPCODE_DS_FUNC(RCP) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1088 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1089 |
void emit_ARB1_RSQ(Context *ctx) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1090 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1091 |
// nv4 doesn't force abs() on this, so negative values will generate NaN. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1092 |
// The spec says you should force the abs() yourself. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1093 |
if (!support_nv4(ctx)) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1094 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1095 |
emit_ARB1_opcode_ds(ctx, "RSQ"); // pre-nv4 implies ABS. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1096 |
return; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1097 |
} // if |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1098 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1099 |
// we can optimize this to use nv2's |abs| construct in some cases. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1100 |
if ( (ctx->source_args[0].src_mod == SRCMOD_NONE) || |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1101 |
(ctx->source_args[0].src_mod == SRCMOD_NEGATE) || |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1102 |
(ctx->source_args[0].src_mod == SRCMOD_ABSNEGATE) ) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1103 |
ctx->source_args[0].src_mod = SRCMOD_ABS; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1104 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1105 |
char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1106 |
char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1107 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1108 |
if (ctx->source_args[0].src_mod == SRCMOD_ABS) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1109 |
output_line(ctx, "RSQ%s, %s;", dst, src0); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1110 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1111 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1112 |
char buf[64]; allocate_ARB1_scratch_reg_name(ctx, buf, sizeof (buf)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1113 |
output_line(ctx, "ABS %s, %s;", buf, src0); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1114 |
output_line(ctx, "RSQ%s, %s.x;", dst, buf); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1115 |
} // else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1116 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1117 |
emit_ARB1_dest_modifiers(ctx); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1118 |
} // emit_ARB1_RSQ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1119 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1120 |
EMIT_ARB1_OPCODE_DSS_FUNC(DP3) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1121 |
EMIT_ARB1_OPCODE_DSS_FUNC(DP4) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1122 |
EMIT_ARB1_OPCODE_DSS_FUNC(MIN) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1123 |
EMIT_ARB1_OPCODE_DSS_FUNC(MAX) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1124 |
EMIT_ARB1_OPCODE_DSS_FUNC(SLT) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1125 |
EMIT_ARB1_OPCODE_DSS_FUNC(SGE) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1126 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1127 |
void emit_ARB1_EXP(Context *ctx) { emit_ARB1_opcode_ds(ctx, "EX2"); } |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1128 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1129 |
static void arb1_log(Context *ctx, const char *opcode) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1130 |
{ |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1131 |
// !!! FIXME: SRCMOD_NEGATE can be made into SRCMOD_ABS here, too |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1132 |
// we can optimize this to use nv2's |abs| construct in some cases. |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1133 |
if ( (ctx->source_args[0].src_mod == SRCMOD_NONE) || |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1134 |
(ctx->source_args[0].src_mod == SRCMOD_ABSNEGATE) ) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1135 |
ctx->source_args[0].src_mod = SRCMOD_ABS; |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1136 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1137 |
char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1138 |
char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1139 |
|
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1140 |
if (ctx->source_args[0].src_mod == SRCMOD_ABS) |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1141 |
output_line(ctx, "%s%s, %s;", opcode, dst, src0); |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook.com>
parents:
diff
changeset
|
1142 |
else |
b8ece252a201
Reorganize profiles into their own files
Caleb Cornett <caleb.cornett@outlook. |