author | Ryan C. Gordon <icculus@icculus.org> |
Wed, 10 Oct 2012 21:35:16 -0400 | |
changeset 1117 | f6712bf72c19 |
parent 1112 | ef76d5efedcc |
child 1143 | e4027cbe2116 |
permissions | -rw-r--r-- |
7 | 1 |
/** |
35 | 2 |
* MojoShader; generate shader programs from bytecode of compiled |
3 |
* Direct3D shaders. |
|
7 | 4 |
* |
5 |
* Please see the file LICENSE.txt in the source's root directory. |
|
6 |
* |
|
7 |
* This file written by Ryan C. Gordon. |
|
8 |
*/ |
|
9 |
||
592
ef8b7cc469da
Removed an underscore.
Ryan C. Gordon <icculus@icculus.org>
parents:
579
diff
changeset
|
10 |
#ifndef _INCL_MOJOSHADER_H_ |
ef8b7cc469da
Removed an underscore.
Ryan C. Gordon <icculus@icculus.org>
parents:
579
diff
changeset
|
11 |
#define _INCL_MOJOSHADER_H_ |
7 | 12 |
|
13 |
#ifdef __cplusplus |
|
14 |
extern "C" { |
|
15 |
#endif |
|
16 |
||
455
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
17 |
/* You can define this if you aren't generating mojoshader_version.h */ |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
18 |
#ifndef MOJOSHADER_NO_VERSION_INCLUDE |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
19 |
#include "mojoshader_version.h" |
461
892b408b5779
Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents:
458
diff
changeset
|
20 |
#endif |
892b408b5779
Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents:
458
diff
changeset
|
21 |
|
892b408b5779
Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents:
458
diff
changeset
|
22 |
#ifndef MOJOSHADER_VERSION |
455
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
23 |
#define MOJOSHADER_VERSION -1 |
461
892b408b5779
Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents:
458
diff
changeset
|
24 |
#endif |
892b408b5779
Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents:
458
diff
changeset
|
25 |
|
892b408b5779
Only define MOJOSHADER_VERSION and MOJOSHADER_CHANGESET if required.
Ryan C. Gordon <icculus@icculus.org>
parents:
458
diff
changeset
|
26 |
#ifndef MOJOSHADER_CHANGESET |
455
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
27 |
#define MOJOSHADER_CHANGESET "???" |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
28 |
#endif |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
29 |
|
20
bb2e8f285acc
[svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents:
18
diff
changeset
|
30 |
/* |
46 | 31 |
* For determining the version of MojoShader you are using: |
32 |
* const int compiled_against = MOJOSHADER_VERSION; |
|
33 |
* const int linked_against = MOJOSHADER_version(); |
|
34 |
* |
|
35 |
* The version is a single integer that increments, not a major/minor value. |
|
20
bb2e8f285acc
[svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents:
18
diff
changeset
|
36 |
*/ |
35 | 37 |
int MOJOSHADER_version(void); |
20
bb2e8f285acc
[svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents:
18
diff
changeset
|
38 |
|
bb2e8f285acc
[svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents:
18
diff
changeset
|
39 |
/* |
552 | 40 |
* For determining the revision control changeset of MojoShader you are using: |
1017
5034d40d718a
Fixed typo in documentation.
Ryan C. Gordon <icculus@icculus.org>
parents:
1014
diff
changeset
|
41 |
* const char *compiled_against = MOJOSHADER_CHANGESET; |
455
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
42 |
* const char *linked_against = MOJOSHADER_changeset(); |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
43 |
* |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
44 |
* The version is an arbitrary, null-terminated ASCII string. It is probably |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
45 |
* a hash that represents a revision control changeset, and can't be |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
46 |
* compared to any other string to determine chronology. |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
47 |
* |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
48 |
* Do not attempt to free this string; it's statically allocated. |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
49 |
*/ |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
50 |
const char *MOJOSHADER_changeset(void); |
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
51 |
|
d99f47386d51
Generate MOJOSHADER_VERSION, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
454
diff
changeset
|
52 |
/* |
20
bb2e8f285acc
[svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents:
18
diff
changeset
|
53 |
* These allocators work just like the C runtime's malloc() and free() |
46 | 54 |
* (in fact, they probably use malloc() and free() internally if you don't |
55 |
* specify your own allocator, but don't rely on that behaviour). |
|
97
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
56 |
* (data) is the pointer you supplied when specifying these allocator |
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
57 |
* callbacks, in case you need instance-specific data...it is passed through |
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
58 |
* to your allocator unmolested, and can be NULL if you like. |
20
bb2e8f285acc
[svn] Bunch More Work...higher level parses dest/src tokens before it goes to the
icculus
parents:
18
diff
changeset
|
59 |
*/ |
97
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
60 |
typedef void *(*MOJOSHADER_malloc)(int bytes, void *data); |
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
61 |
typedef void (*MOJOSHADER_free)(void *ptr, void *data); |
18
0dbdb2be8bf8
[svn] Bunch More Work. Cleanups, added app-supplied allocators, flexible output, etc.
icculus
parents:
14
diff
changeset
|
62 |
|
46 | 63 |
|
64 |
/* |
|
65 |
* These are enum values, but they also can be used in bitmasks, so we can |
|
66 |
* test if an opcode is acceptable: if (op->shader_types & ourtype) {} ... |
|
67 |
*/ |
|
68 |
typedef enum |
|
69 |
{ |
|
70 |
MOJOSHADER_TYPE_UNKNOWN = 0, |
|
71 |
MOJOSHADER_TYPE_PIXEL = (1 << 0), |
|
72 |
MOJOSHADER_TYPE_VERTEX = (1 << 1), |
|
73 |
MOJOSHADER_TYPE_GEOMETRY = (1 << 2), /* (not supported yet.) */ |
|
74 |
MOJOSHADER_TYPE_ANY = 0xFFFFFFFF /* used for bitmasks */ |
|
75 |
} MOJOSHADER_shaderType; |
|
76 |
||
94
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
77 |
/* |
196
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
78 |
* Data types for vertex attribute streams. |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
79 |
*/ |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
80 |
typedef enum |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
81 |
{ |
240
a945af028366
Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents:
239
diff
changeset
|
82 |
MOJOSHADER_ATTRIBUTE_UNKNOWN = -1, /* housekeeping; not returned. */ |
196
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
83 |
MOJOSHADER_ATTRIBUTE_BYTE, |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
84 |
MOJOSHADER_ATTRIBUTE_UBYTE, |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
85 |
MOJOSHADER_ATTRIBUTE_SHORT, |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
86 |
MOJOSHADER_ATTRIBUTE_USHORT, |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
87 |
MOJOSHADER_ATTRIBUTE_INT, |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
88 |
MOJOSHADER_ATTRIBUTE_UINT, |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
89 |
MOJOSHADER_ATTRIBUTE_FLOAT, |
236
8e2fc535b210
Support for half-float attribute arrays.
Ryan C. Gordon <icculus@icculus.org>
parents:
219
diff
changeset
|
90 |
MOJOSHADER_ATTRIBUTE_DOUBLE, |
8e2fc535b210
Support for half-float attribute arrays.
Ryan C. Gordon <icculus@icculus.org>
parents:
219
diff
changeset
|
91 |
MOJOSHADER_ATTRIBUTE_HALF_FLOAT, /* MAYBE available in your OpenGL! */ |
196
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
92 |
} MOJOSHADER_attributeType; |
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
93 |
|
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
94 |
/* |
94
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
95 |
* Data types for uniforms. See MOJOSHADER_uniform for more information. |
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
96 |
*/ |
92
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
97 |
typedef enum |
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
98 |
{ |
240
a945af028366
Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents:
239
diff
changeset
|
99 |
MOJOSHADER_UNIFORM_UNKNOWN = -1, /* housekeeping value; never returned. */ |
147
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
100 |
MOJOSHADER_UNIFORM_FLOAT, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
101 |
MOJOSHADER_UNIFORM_INT, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
102 |
MOJOSHADER_UNIFORM_BOOL, |
94
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
103 |
} MOJOSHADER_uniformType; |
92
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
104 |
|
94
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
105 |
/* |
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
106 |
* These are the uniforms to be set for a shader. "Uniforms" are what Direct3D |
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
107 |
* calls "Constants" ... IDirect3DDevice::SetVertexShaderConstantF() would |
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
108 |
* need this data, for example. These integers are register indexes. So if |
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
109 |
* index==6 and type==MOJOSHADER_UNIFORM_FLOAT, that means we'd expect a |
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
110 |
* 4-float vector to be specified for what would be register "c6" in D3D |
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
111 |
* assembly language, before drawing with the shader. |
280
61b2abd9c927
Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
278
diff
changeset
|
112 |
* (array_count) means this is an array of uniforms...this happens in some |
61b2abd9c927
Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
278
diff
changeset
|
113 |
* profiles when we see a relative address ("c0[a0.x]", not the usual "c0"). |
61b2abd9c927
Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
278
diff
changeset
|
114 |
* In those cases, the shader was built to set some range of constant |
61b2abd9c927
Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
278
diff
changeset
|
115 |
* registers as an array. You should set this array with (array_count) |
61b2abd9c927
Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
278
diff
changeset
|
116 |
* elements from the constant register file, starting at (index) instead of |
61b2abd9c927
Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
278
diff
changeset
|
117 |
* just a single uniform. To be extra difficult, you'll need to fill in the |
61b2abd9c927
Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
278
diff
changeset
|
118 |
* correct values from the MOJOSHADER_constant data into the appropriate |
61b2abd9c927
Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
278
diff
changeset
|
119 |
* parts of the array, overriding the constant register file. Fun! |
438
73492129c1af
Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents:
431
diff
changeset
|
120 |
* (constant) says whether this is a constant array; these need to be loaded |
73492129c1af
Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents:
431
diff
changeset
|
121 |
* once at creation time, from the constant list and not ever updated from |
73492129c1af
Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents:
431
diff
changeset
|
122 |
* the constant register file. This is a workaround for limitations in some |
73492129c1af
Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents:
431
diff
changeset
|
123 |
* profiles. |
190
2a2fb0f656cf
Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents:
187
diff
changeset
|
124 |
* (name) is a profile-specific variable name; it may be NULL if it isn't |
2a2fb0f656cf
Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents:
187
diff
changeset
|
125 |
* applicable to the requested profile. |
94
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
126 |
*/ |
462
af8c1ff58453
Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
461
diff
changeset
|
127 |
typedef struct MOJOSHADER_uniform |
92
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
128 |
{ |
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
129 |
MOJOSHADER_uniformType type; |
92
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
130 |
int index; |
280
61b2abd9c927
Relative addressing fixes.
Ryan C. Gordon <icculus@icculus.org>
parents:
278
diff
changeset
|
131 |
int array_count; |
438
73492129c1af
Expose true constant arrays in parseData, load them at link time for GLSL.
Ryan C. Gordon <icculus@icculus.org>
parents:
431
diff
changeset
|
132 |
int constant; |
190
2a2fb0f656cf
Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents:
187
diff
changeset
|
133 |
const char *name; |
92
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
134 |
} MOJOSHADER_uniform; |
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
135 |
|
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
136 |
/* |
278
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
137 |
* These are the constants defined in a shader. These are data values |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
138 |
* hardcoded in a shader (with the DEF, DEFI, DEFB instructions), which |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
139 |
* override your Uniforms. This data is largely for informational purposes, |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
140 |
* since they are compiled in and can't be changed, like Uniforms can be. |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
141 |
* These integers are register indexes. So if index==6 and |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
142 |
* type==MOJOSHADER_UNIFORM_FLOAT, that means we'd expect a 4-float vector |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
143 |
* to be specified for what would be register "c6" in D3D assembly language, |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
144 |
* before drawing with the shader. |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
145 |
* (value) is the value of the constant, unioned by type. |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
146 |
*/ |
462
af8c1ff58453
Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
461
diff
changeset
|
147 |
typedef struct MOJOSHADER_constant |
278
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
148 |
{ |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
149 |
MOJOSHADER_uniformType type; |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
150 |
int index; |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
151 |
union |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
152 |
{ |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
153 |
float f[4]; /* if type==MOJOSHADER_UNIFORM_FLOAT */ |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
154 |
int i[4]; /* if type==MOJOSHADER_UNIFORM_INT */ |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
155 |
int b; /* if type==MOJOSHADER_UNIFORM_BOOL */ |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
156 |
} value; |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
157 |
} MOJOSHADER_constant; |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
158 |
|
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
159 |
/* |
148
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
160 |
* Data types for samplers. See MOJOSHADER_sampler for more information. |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
161 |
*/ |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
162 |
typedef enum |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
163 |
{ |
240
a945af028366
Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents:
239
diff
changeset
|
164 |
MOJOSHADER_SAMPLER_UNKNOWN = -1, /* housekeeping value; never returned. */ |
148
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
165 |
MOJOSHADER_SAMPLER_2D, |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
166 |
MOJOSHADER_SAMPLER_CUBE, |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
167 |
MOJOSHADER_SAMPLER_VOLUME, |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
168 |
} MOJOSHADER_samplerType; |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
169 |
|
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
170 |
/* |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
171 |
* These are the samplers to be set for a shader. ... |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
172 |
* IDirect3DDevice::SetTexture() would need this data, for example. |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
173 |
* These integers are the sampler "stage". So if index==6 and |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
174 |
* type==MOJOSHADER_SAMPLER_2D, that means we'd expect a regular 2D texture |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
175 |
* to be specified for what would be register "s6" in D3D assembly language, |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
176 |
* before drawing with the shader. |
190
2a2fb0f656cf
Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents:
187
diff
changeset
|
177 |
* (name) is a profile-specific variable name; it may be NULL if it isn't |
2a2fb0f656cf
Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents:
187
diff
changeset
|
178 |
* applicable to the requested profile. |
1090
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1068
diff
changeset
|
179 |
* (texbem) will be non-zero if a TEXBEM opcode references this sampler. This |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1068
diff
changeset
|
180 |
* is only used in legacy shaders (ps_1_1 through ps_1_3), but it needs some |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1068
diff
changeset
|
181 |
* special support to work, as we have to load a magic uniform behind the |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1068
diff
changeset
|
182 |
* scenes to support it. Most code can ignore this field in general, and no |
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1068
diff
changeset
|
183 |
* one has to touch it unless they really know what they're doing. |
148
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
184 |
*/ |
462
af8c1ff58453
Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
461
diff
changeset
|
185 |
typedef struct MOJOSHADER_sampler |
148
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
186 |
{ |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
187 |
MOJOSHADER_samplerType type; |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
188 |
int index; |
190
2a2fb0f656cf
Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents:
187
diff
changeset
|
189 |
const char *name; |
1090
636ffcd3f14a
First shot at GLSL/ARB1 support for TEXBEM and TEXBEML opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1068
diff
changeset
|
190 |
int texbem; |
148
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
191 |
} MOJOSHADER_sampler; |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
192 |
|
1104
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
193 |
|
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
194 |
/* |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
195 |
* This struct is used if you have to force a sampler to a specific type. |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
196 |
* Generally, you can ignore this, but if you have, say, a ps_1_1 |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
197 |
* shader, you might need to specify what the samplers are meant to be |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
198 |
* to get correct results, as Shader Model 1 samples textures according |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
199 |
* to what is bound to a sampler at the moment instead of what the shader |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
200 |
* is hardcoded to expect. |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
201 |
*/ |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
202 |
typedef struct MOJOSHADER_samplerMap |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
203 |
{ |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
204 |
int index; |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
205 |
MOJOSHADER_samplerType type; |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
206 |
} MOJOSHADER_samplerMap; |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
207 |
|
148
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
208 |
/* |
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
209 |
* Data types for attributes. See MOJOSHADER_attribute for more information. |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
210 |
*/ |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
211 |
typedef enum |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
212 |
{ |
240
a945af028366
Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents:
239
diff
changeset
|
213 |
MOJOSHADER_USAGE_UNKNOWN = -1, /* housekeeping value; never returned. */ |
147
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
214 |
MOJOSHADER_USAGE_POSITION, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
215 |
MOJOSHADER_USAGE_BLENDWEIGHT, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
216 |
MOJOSHADER_USAGE_BLENDINDICES, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
217 |
MOJOSHADER_USAGE_NORMAL, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
218 |
MOJOSHADER_USAGE_POINTSIZE, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
219 |
MOJOSHADER_USAGE_TEXCOORD, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
220 |
MOJOSHADER_USAGE_TANGENT, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
221 |
MOJOSHADER_USAGE_BINORMAL, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
222 |
MOJOSHADER_USAGE_TESSFACTOR, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
223 |
MOJOSHADER_USAGE_POSITIONT, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
224 |
MOJOSHADER_USAGE_COLOR, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
225 |
MOJOSHADER_USAGE_FOG, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
226 |
MOJOSHADER_USAGE_DEPTH, |
98043daf5027
Removed explicit numbers on enums in mojoshader.h.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
227 |
MOJOSHADER_USAGE_SAMPLE, |
240
a945af028366
Added UNKNOWN value to the enums in the public API.
Ryan C. Gordon <icculus@icculus.org>
parents:
239
diff
changeset
|
228 |
MOJOSHADER_USAGE_TOTAL, /* housekeeping value; never returned. */ |
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
229 |
} MOJOSHADER_usage; |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
230 |
|
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
231 |
/* |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
232 |
* These are the attributes to be set for a shader. "Attributes" are what |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
233 |
* Direct3D calls "Vertex Declarations Usages" ... |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
234 |
* IDirect3DDevice::CreateVertexDeclaration() would need this data, for |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
235 |
* example. Each attribute is associated with an array of data that uses one |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
236 |
* element per-vertex. So if usage==MOJOSHADER_USAGE_COLOR and index==1, that |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
237 |
* means we'd expect a secondary color array to be bound to this shader |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
238 |
* before drawing. |
190
2a2fb0f656cf
Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents:
187
diff
changeset
|
239 |
* (name) is a profile-specific variable name; it may be NULL if it isn't |
2a2fb0f656cf
Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents:
187
diff
changeset
|
240 |
* applicable to the requested profile. |
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
241 |
*/ |
462
af8c1ff58453
Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
461
diff
changeset
|
242 |
typedef struct MOJOSHADER_attribute |
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
243 |
{ |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
244 |
MOJOSHADER_usage usage; |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
245 |
int index; |
190
2a2fb0f656cf
Added profile-specific variable names to returned parse data.
Ryan C. Gordon <icculus@icculus.org>
parents:
187
diff
changeset
|
246 |
const char *name; |
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
247 |
} MOJOSHADER_attribute; |
46 | 248 |
|
249 |
/* |
|
450
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
250 |
* Use this if you want to specify newly-parsed code to swizzle incoming |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
251 |
* data. This can be useful if you know, at parse time, that a shader |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
252 |
* will be processing data on COLOR0 that should be RGBA, but you'll |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
253 |
* be passing it a vertex array full of ARGB instead. |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
254 |
*/ |
462
af8c1ff58453
Make the C struct definitions more C++ friendly.
Ryan C. Gordon <icculus@icculus.org>
parents:
461
diff
changeset
|
255 |
typedef struct MOJOSHADER_swizzle |
450
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
256 |
{ |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
257 |
MOJOSHADER_usage usage; |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
258 |
unsigned int index; |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
259 |
unsigned char swizzles[4]; /* {0,1,2,3} == .xyzw, {2,2,2,2} == .zzzz */ |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
260 |
} MOJOSHADER_swizzle; |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
261 |
|
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
262 |
|
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
263 |
/* |
524
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
264 |
* MOJOSHADER_symbol data. |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
265 |
* |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
266 |
* These are used to expose high-level information in shader bytecode. |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
267 |
* They associate HLSL variables with registers. This data is used for both |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
268 |
* debugging and optimization. |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
269 |
*/ |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
270 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
271 |
typedef enum |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
272 |
{ |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
273 |
MOJOSHADER_SYMREGSET_BOOL, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
274 |
MOJOSHADER_SYMREGSET_INT4, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
275 |
MOJOSHADER_SYMREGSET_FLOAT4, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
276 |
MOJOSHADER_SYMREGSET_SAMPLER, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
277 |
} MOJOSHADER_symbolRegisterSet; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
278 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
279 |
typedef enum |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
280 |
{ |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
281 |
MOJOSHADER_SYMCLASS_SCALAR, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
282 |
MOJOSHADER_SYMCLASS_VECTOR, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
283 |
MOJOSHADER_SYMCLASS_MATRIX_ROWS, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
284 |
MOJOSHADER_SYMCLASS_MATRIX_COLUMNS, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
285 |
MOJOSHADER_SYMCLASS_OBJECT, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
286 |
MOJOSHADER_SYMCLASS_STRUCT, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
287 |
} MOJOSHADER_symbolClass; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
288 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
289 |
typedef enum |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
290 |
{ |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
291 |
MOJOSHADER_SYMTYPE_VOID, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
292 |
MOJOSHADER_SYMTYPE_BOOL, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
293 |
MOJOSHADER_SYMTYPE_INT, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
294 |
MOJOSHADER_SYMTYPE_FLOAT, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
295 |
MOJOSHADER_SYMTYPE_STRING, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
296 |
MOJOSHADER_SYMTYPE_TEXTURE, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
297 |
MOJOSHADER_SYMTYPE_TEXTURE1D, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
298 |
MOJOSHADER_SYMTYPE_TEXTURE2D, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
299 |
MOJOSHADER_SYMTYPE_TEXTURE3D, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
300 |
MOJOSHADER_SYMTYPE_TEXTURECUBE, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
301 |
MOJOSHADER_SYMTYPE_SAMPLER, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
302 |
MOJOSHADER_SYMTYPE_SAMPLER1D, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
303 |
MOJOSHADER_SYMTYPE_SAMPLER2D, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
304 |
MOJOSHADER_SYMTYPE_SAMPLER3D, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
305 |
MOJOSHADER_SYMTYPE_SAMPLERCUBE, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
306 |
MOJOSHADER_SYMTYPE_PIXELSHADER, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
307 |
MOJOSHADER_SYMTYPE_VERTEXSHADER, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
308 |
MOJOSHADER_SYMTYPE_PIXELFRAGMENT, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
309 |
MOJOSHADER_SYMTYPE_VERTEXFRAGMENT, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
310 |
MOJOSHADER_SYMTYPE_UNSUPPORTED, |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
311 |
} MOJOSHADER_symbolType; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
312 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
313 |
typedef struct MOJOSHADER_symbolStructMember MOJOSHADER_symbolStructMember; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
314 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
315 |
typedef struct MOJOSHADER_symbolTypeInfo |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
316 |
{ |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
317 |
MOJOSHADER_symbolClass parameter_class; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
318 |
MOJOSHADER_symbolType parameter_type; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
319 |
unsigned int rows; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
320 |
unsigned int columns; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
321 |
unsigned int elements; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
322 |
unsigned int member_count; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
323 |
MOJOSHADER_symbolStructMember *members; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
324 |
} MOJOSHADER_symbolTypeInfo; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
325 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
326 |
struct MOJOSHADER_symbolStructMember |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
327 |
{ |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
328 |
const char *name; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
329 |
MOJOSHADER_symbolTypeInfo info; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
330 |
}; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
331 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
332 |
typedef struct MOJOSHADER_symbol |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
333 |
{ |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
334 |
const char *name; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
335 |
MOJOSHADER_symbolRegisterSet register_set; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
336 |
unsigned int register_index; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
337 |
unsigned int register_count; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
338 |
MOJOSHADER_symbolTypeInfo info; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
339 |
} MOJOSHADER_symbol; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
340 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
341 |
|
947
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
342 |
/* |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
343 |
* These are used with MOJOSHADER_error as special case positions. |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
344 |
*/ |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
345 |
#define MOJOSHADER_POSITION_NONE (-3) |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
346 |
#define MOJOSHADER_POSITION_BEFORE (-2) |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
347 |
#define MOJOSHADER_POSITION_AFTER (-1) |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
348 |
|
536
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
349 |
typedef struct MOJOSHADER_error |
46 | 350 |
{ |
351 |
/* |
|
352 |
* Human-readable error, if there is one. Will be NULL if there was no |
|
353 |
* error. The string will be UTF-8 encoded, and English only. Most of |
|
354 |
* these shouldn't be shown to the end-user anyhow. |
|
355 |
*/ |
|
356 |
const char *error; |
|
357 |
||
523
699696afd731
Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents:
515
diff
changeset
|
358 |
/* |
578
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
359 |
* Filename where error happened. This can be NULL if the information |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
360 |
* isn't available. |
536
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
361 |
*/ |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
362 |
const char *filename; |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
363 |
|
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
364 |
/* |
947
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
365 |
* Position of error, if there is one. Will be MOJOSHADER_POSITION_NONE if |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
366 |
* there was no error, MOJOSHADER_POSITION_BEFORE if there was an error |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
367 |
* before processing started, and MOJOSHADER_POSITION_AFTER if there was |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
368 |
* an error during final processing. If >= 0, MOJOSHADER_parse() sets |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
369 |
* this to the byte offset (starting at zero) into the bytecode you |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
370 |
* supplied, and MOJOSHADER_assemble(), MOJOSHADER_parseAst(), and |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
371 |
* MOJOSHADER_compile() sets this to a a line number in the source code |
16af6e2b2ada
Cleaned up error position reporting.
Ryan C. Gordon <icculus@icculus.org>
parents:
939
diff
changeset
|
372 |
* you supplied (starting at one). |
475
ea119c8ce5cd
Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
470
diff
changeset
|
373 |
*/ |
ea119c8ce5cd
Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
470
diff
changeset
|
374 |
int error_position; |
536
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
375 |
} MOJOSHADER_error; |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
376 |
|
1030
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
377 |
|
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
378 |
/* !!! FIXME: document me. */ |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
379 |
typedef enum MOJOSHADER_preshaderOpcode |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
380 |
{ |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
381 |
MOJOSHADER_PRESHADEROP_NOP, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
382 |
MOJOSHADER_PRESHADEROP_MOV, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
383 |
MOJOSHADER_PRESHADEROP_NEG, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
384 |
MOJOSHADER_PRESHADEROP_RCP, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
385 |
MOJOSHADER_PRESHADEROP_FRC, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
386 |
MOJOSHADER_PRESHADEROP_EXP, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
387 |
MOJOSHADER_PRESHADEROP_LOG, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
388 |
MOJOSHADER_PRESHADEROP_RSQ, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
389 |
MOJOSHADER_PRESHADEROP_SIN, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
390 |
MOJOSHADER_PRESHADEROP_COS, |
1032
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
391 |
MOJOSHADER_PRESHADEROP_ASIN, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
392 |
MOJOSHADER_PRESHADEROP_ACOS, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
393 |
MOJOSHADER_PRESHADEROP_ATAN, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
394 |
MOJOSHADER_PRESHADEROP_MIN, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
395 |
MOJOSHADER_PRESHADEROP_MAX, |
1035
5855d767e4b2
Changed CMPLT and CMPGE to LT and GE, to match what fxc spits out.
Ryan C. Gordon <icculus@icculus.org>
parents:
1034
diff
changeset
|
396 |
MOJOSHADER_PRESHADEROP_LT, |
5855d767e4b2
Changed CMPLT and CMPGE to LT and GE, to match what fxc spits out.
Ryan C. Gordon <icculus@icculus.org>
parents:
1034
diff
changeset
|
397 |
MOJOSHADER_PRESHADEROP_GE, |
1032
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
398 |
MOJOSHADER_PRESHADEROP_ADD, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
399 |
MOJOSHADER_PRESHADEROP_MUL, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
400 |
MOJOSHADER_PRESHADEROP_ATAN2, |
1033
b72073c4820e
Added DIV preshader opcode.
Ryan C. Gordon <icculus@icculus.org>
parents:
1032
diff
changeset
|
401 |
MOJOSHADER_PRESHADEROP_DIV, |
1032
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
402 |
MOJOSHADER_PRESHADEROP_CMP, |
1034
549f160533fa
Found, I think, the final preshader opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1033
diff
changeset
|
403 |
MOJOSHADER_PRESHADEROP_MOVC, |
1032
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
404 |
MOJOSHADER_PRESHADEROP_DOT, |
1034
549f160533fa
Found, I think, the final preshader opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1033
diff
changeset
|
405 |
MOJOSHADER_PRESHADEROP_NOISE, |
1032
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
406 |
MOJOSHADER_PRESHADEROP_SCALAR_OPS, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
407 |
MOJOSHADER_PRESHADEROP_MIN_SCALAR = MOJOSHADER_PRESHADEROP_SCALAR_OPS, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
408 |
MOJOSHADER_PRESHADEROP_MAX_SCALAR, |
1035
5855d767e4b2
Changed CMPLT and CMPGE to LT and GE, to match what fxc spits out.
Ryan C. Gordon <icculus@icculus.org>
parents:
1034
diff
changeset
|
409 |
MOJOSHADER_PRESHADEROP_LT_SCALAR, |
5855d767e4b2
Changed CMPLT and CMPGE to LT and GE, to match what fxc spits out.
Ryan C. Gordon <icculus@icculus.org>
parents:
1034
diff
changeset
|
410 |
MOJOSHADER_PRESHADEROP_GE_SCALAR, |
1032
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
411 |
MOJOSHADER_PRESHADEROP_ADD_SCALAR, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
412 |
MOJOSHADER_PRESHADEROP_MUL_SCALAR, |
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
413 |
MOJOSHADER_PRESHADEROP_ATAN2_SCALAR, |
1033
b72073c4820e
Added DIV preshader opcode.
Ryan C. Gordon <icculus@icculus.org>
parents:
1032
diff
changeset
|
414 |
MOJOSHADER_PRESHADEROP_DIV_SCALAR, |
1032
464f38a2fb70
Added some more preshader opcodes, cleaned up opcode handling elsewhere.
Ryan C. Gordon <icculus@icculus.org>
parents:
1030
diff
changeset
|
415 |
MOJOSHADER_PRESHADEROP_DOT_SCALAR, |
1034
549f160533fa
Found, I think, the final preshader opcodes.
Ryan C. Gordon <icculus@icculus.org>
parents:
1033
diff
changeset
|
416 |
MOJOSHADER_PRESHADEROP_NOISE_SCALAR, |
1030
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
417 |
} MOJOSHADER_preshaderOpcode; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
418 |
|
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
419 |
typedef enum MOJOSHADER_preshaderOperandType |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
420 |
{ |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
421 |
MOJOSHADER_PRESHADEROPERAND_INPUT, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
422 |
MOJOSHADER_PRESHADEROPERAND_OUTPUT, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
423 |
MOJOSHADER_PRESHADEROPERAND_LITERAL, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
424 |
MOJOSHADER_PRESHADEROPERAND_TEMP, |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
425 |
} MOJOSHADER_preshaderOperandType; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
426 |
|
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
427 |
typedef struct MOJOSHADER_preshaderOperand |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
428 |
{ |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
429 |
MOJOSHADER_preshaderOperandType type; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
430 |
unsigned int index; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
431 |
} MOJOSHADER_preshaderOperand; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
432 |
|
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
433 |
typedef struct MOJOSHADER_preshaderInstruction |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
434 |
{ |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
435 |
MOJOSHADER_preshaderOpcode opcode; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
436 |
unsigned int element_count; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
437 |
unsigned int operand_count; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
438 |
MOJOSHADER_preshaderOperand operands[3]; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
439 |
} MOJOSHADER_preshaderInstruction; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
440 |
|
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
441 |
typedef struct MOJOSHADER_preshader |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
442 |
{ |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
443 |
unsigned int literal_count; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
444 |
double *literals; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
445 |
unsigned int temp_count; /* scalar, not vector! */ |
1042
cb6659f80bb9
Export symbol information for preshaders.
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
446 |
unsigned int symbol_count; |
cb6659f80bb9
Export symbol information for preshaders.
Ryan C. Gordon <icculus@icculus.org>
parents:
1040
diff
changeset
|
447 |
MOJOSHADER_symbol *symbols; |
1030
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
448 |
unsigned int instruction_count; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
449 |
MOJOSHADER_preshaderInstruction *instructions; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
450 |
} MOJOSHADER_preshader; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
451 |
|
536
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
452 |
/* |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
453 |
* Structure used to return data from parsing of a shader... |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
454 |
*/ |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
455 |
/* !!! FIXME: most of these ints should be unsigned. */ |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
456 |
typedef struct MOJOSHADER_parseData |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
457 |
{ |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
458 |
/* |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
459 |
* The number of elements pointed to by (errors). |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
460 |
*/ |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
461 |
int error_count; |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
462 |
|
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
463 |
/* |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
464 |
* (error_count) elements of data that specify errors that were generated |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
465 |
* by parsing this shader. |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
466 |
* This can be NULL if there were no errors or if (error_count) is zero. |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
467 |
*/ |
5af65fe6e917
Allow multiple errors from parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
524
diff
changeset
|
468 |
MOJOSHADER_error *errors; |
475
ea119c8ce5cd
Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
470
diff
changeset
|
469 |
|
ea119c8ce5cd
Added error position information to MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
470
diff
changeset
|
470 |
/* |
187
1c709f65cf1b
Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
148
diff
changeset
|
471 |
* The name of the profile used to parse the shader. Will be NULL on error. |
1c709f65cf1b
Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
148
diff
changeset
|
472 |
*/ |
1c709f65cf1b
Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
148
diff
changeset
|
473 |
const char *profile; |
1c709f65cf1b
Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
148
diff
changeset
|
474 |
|
1c709f65cf1b
Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
148
diff
changeset
|
475 |
/* |
46 | 476 |
* Bytes of output from parsing. Most profiles produce a string of source |
477 |
* code, but profiles that do binary output may not be text at all. |
|
478 |
* Will be NULL on error. |
|
479 |
*/ |
|
480 |
const char *output; |
|
481 |
||
482 |
/* |
|
483 |
* Byte count for output, not counting any null terminator. Most profiles |
|
113
8ebf445c5305
Print output in testparse.c byte-by-byte instead of as an ASCIZ string.
Ryan C. Gordon <icculus@icculus.org>
parents:
109
diff
changeset
|
484 |
* produce an ASCII string of source code (which will be null-terminated |
8ebf445c5305
Print output in testparse.c byte-by-byte instead of as an ASCIZ string.
Ryan C. Gordon <icculus@icculus.org>
parents:
109
diff
changeset
|
485 |
* even though that null char isn't included in output_len), but profiles |
8ebf445c5305
Print output in testparse.c byte-by-byte instead of as an ASCIZ string.
Ryan C. Gordon <icculus@icculus.org>
parents:
109
diff
changeset
|
486 |
* that do binary output may not be text at all. Will be 0 on error. |
46 | 487 |
*/ |
488 |
int output_len; |
|
489 |
||
490 |
/* |
|
356
8e23d7eb90d9
Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents:
354
diff
changeset
|
491 |
* Count of Direct3D instruction slots used. This is meaningless in terms |
46 | 492 |
* of the actual output, as the profile will probably grow or reduce |
493 |
* the count (or for high-level languages, not have that information at |
|
356
8e23d7eb90d9
Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents:
354
diff
changeset
|
494 |
* all). Also, as with Microsoft's own assembler, this value is just a |
8e23d7eb90d9
Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents:
354
diff
changeset
|
495 |
* rough estimate, as unpredicable real-world factors make the actual |
8e23d7eb90d9
Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents:
354
diff
changeset
|
496 |
* value vary at least a little from this count. Still, it can give you |
8e23d7eb90d9
Better attempt at instruction counts, with official numbers from msdn.
Ryan C. Gordon <icculus@icculus.org>
parents:
354
diff
changeset
|
497 |
* a rough idea of the size of your shader. Will be zero on error. |
46 | 498 |
*/ |
499 |
int instruction_count; |
|
500 |
||
501 |
/* |
|
502 |
* The type of shader we parsed. Will be MOJOSHADER_TYPE_UNKNOWN on error. |
|
503 |
*/ |
|
504 |
MOJOSHADER_shaderType shader_type; |
|
505 |
||
506 |
/* |
|
507 |
* The shader's major version. If this was a "vs_3_0", this would be 3. |
|
508 |
*/ |
|
509 |
int major_ver; |
|
510 |
||
511 |
/* |
|
512 |
* The shader's minor version. If this was a "ps_1_4", this would be 4. |
|
513 |
* Two notes: for "vs_2_x", this is 1, and for "vs_3_sw", this is 255. |
|
514 |
*/ |
|
515 |
int minor_ver; |
|
516 |
||
517 |
/* |
|
92
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
518 |
* The number of elements pointed to by (uniforms). |
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
519 |
*/ |
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
520 |
int uniform_count; |
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
521 |
|
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
522 |
/* |
94
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
523 |
* (uniform_count) elements of data that specify Uniforms to be set for |
57adfb4769a0
Simplifed public uniform information.
Ryan C. Gordon <icculus@icculus.org>
parents:
92
diff
changeset
|
524 |
* this shader. See discussion on MOJOSHADER_uniform for details. |
145
5325c8d6077c
Don't create unnecessary attributes.
Ryan C. Gordon <icculus@icculus.org>
parents:
113
diff
changeset
|
525 |
* This can be NULL on error or if (uniform_count) is zero. |
92
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
526 |
*/ |
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
527 |
MOJOSHADER_uniform *uniforms; |
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
528 |
|
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
529 |
/* |
278
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
530 |
* The number of elements pointed to by (constants). |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
531 |
*/ |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
532 |
int constant_count; |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
533 |
|
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
534 |
/* |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
535 |
* (constant_count) elements of data that specify constants used in |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
536 |
* this shader. See discussion on MOJOSHADER_constant for details. |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
537 |
* This can be NULL on error or if (constant_count) is zero. |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
538 |
* This is largely informational: constants are hardcoded into a shader. |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
539 |
* The constants that you can set like parameters are in the "uniforms" |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
540 |
* list. |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
541 |
*/ |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
542 |
MOJOSHADER_constant *constants; |
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
543 |
|
5c432d216078
Report hardcoded constants in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
276
diff
changeset
|
544 |
/* |
148
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
545 |
* The number of elements pointed to by (samplers). |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
546 |
*/ |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
547 |
int sampler_count; |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
548 |
|
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
549 |
/* |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
550 |
* (sampler_count) elements of data that specify Samplers to be set for |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
551 |
* this shader. See discussion on MOJOSHADER_sampler for details. |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
552 |
* This can be NULL on error or if (sampler_count) is zero. |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
553 |
*/ |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
554 |
MOJOSHADER_sampler *samplers; |
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
555 |
|
1055
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
556 |
/* !!! FIXME: this should probably be "input" and not "attribute" */ |
148
645003ec6623
Hopefully sorted out the reported uniform/attribute mess.
Ryan C. Gordon <icculus@icculus.org>
parents:
147
diff
changeset
|
557 |
/* |
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
558 |
* The number of elements pointed to by (attributes). |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
559 |
*/ |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
560 |
int attribute_count; |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
561 |
|
1055
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
562 |
/* !!! FIXME: this should probably be "input" and not "attribute" */ |
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
563 |
/* |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
564 |
* (attribute_count) elements of data that specify Attributes to be set |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
565 |
* for this shader. See discussion on MOJOSHADER_attribute for details. |
145
5325c8d6077c
Don't create unnecessary attributes.
Ryan C. Gordon <icculus@icculus.org>
parents:
113
diff
changeset
|
566 |
* This can be NULL on error or if (attribute_count) is zero. |
100
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
567 |
*/ |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
568 |
MOJOSHADER_attribute *attributes; |
2b88649b6f98
First shot at attributes reporting API.
Ryan C. Gordon <icculus@icculus.org>
parents:
97
diff
changeset
|
569 |
|
92
bc1bb138e855
Implemented foundation for reporting uniforms to calling app.
Ryan C. Gordon <icculus@icculus.org>
parents:
46
diff
changeset
|
570 |
/* |
1055
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
571 |
* The number of elements pointed to by (outputs). |
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
572 |
*/ |
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
573 |
int output_count; |
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
574 |
|
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
575 |
/* |
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
576 |
* (output_count) elements of data that specify outputs this shader |
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
577 |
* writes to. See discussion on MOJOSHADER_attribute for details. |
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
578 |
* This can be NULL on error or if (output_count) is zero. |
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
579 |
*/ |
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
580 |
MOJOSHADER_attribute *outputs; |
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
581 |
|
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
582 |
/* |
450
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
583 |
* The number of elements pointed to by (swizzles). |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
584 |
*/ |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
585 |
int swizzle_count; |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
586 |
|
1055
3295380ce6fc
Report shader outputs in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
1043
diff
changeset
|
587 |
/* !!! FIXME: this should probably be "input" and not "attribute" */ |
450
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
588 |
/* |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
589 |
* (swizzle_count) elements of data that specify swizzles the shader will |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
590 |
* apply to incoming attributes. This is a copy of what was passed to |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
591 |
* MOJOSHADER_parseData(). |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
592 |
* This can be NULL on error or if (swizzle_count) is zero. |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
593 |
*/ |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
594 |
MOJOSHADER_swizzle *swizzles; |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
595 |
|
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
596 |
/* |
524
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
597 |
* The number of elements pointed to by (symbols). |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
598 |
*/ |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
599 |
int symbol_count; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
600 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
601 |
/* |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
602 |
* (symbol_count) elements of data that specify high-level symbol data |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
603 |
* for the shader. This will be parsed from the CTAB section |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
604 |
* in bytecode, and will be a copy of what you provide to |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
605 |
* MOJOSHADER_assemble(). This data is optional. |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
606 |
* This can be NULL on error or if (symbol_count) is zero. |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
607 |
*/ |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
608 |
MOJOSHADER_symbol *symbols; |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
609 |
|
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
610 |
/* |
1030
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
611 |
* !!! FIXME: document me. |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
612 |
* This can be NULL on error or if no preshader was available. |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
613 |
*/ |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
614 |
MOJOSHADER_preshader *preshader; |
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
615 |
|
a407c516e325
Initial work on preshader support.
Ryan C. Gordon <icculus@icculus.org>
parents:
1028
diff
changeset
|
616 |
/* |
46 | 617 |
* This is the malloc implementation you passed to MOJOSHADER_parse(). |
618 |
*/ |
|
619 |
MOJOSHADER_malloc malloc; |
|
620 |
||
621 |
/* |
|
622 |
* This is the free implementation you passed to MOJOSHADER_parse(). |
|
623 |
*/ |
|
624 |
MOJOSHADER_free free; |
|
97
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
625 |
|
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
626 |
/* |
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
627 |
* This is the pointer you passed as opaque data for your allocator. |
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
628 |
*/ |
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
629 |
void *malloc_data; |
46 | 630 |
} MOJOSHADER_parseData; |
631 |
||
632 |
||
633 |
/* |
|
634 |
* Profile string for Direct3D assembly language output. |
|
635 |
*/ |
|
636 |
#define MOJOSHADER_PROFILE_D3D "d3d" |
|
637 |
||
638 |
/* |
|
109
48e95cf41505
Added "passthrough" profile, which just sends the bytecode through unchanged;
Ryan C. Gordon <icculus@icculus.org>
parents:
101
diff
changeset
|
639 |
* Profile string for passthrough of the original bytecode, unchanged. |
48e95cf41505
Added "passthrough" profile, which just sends the bytecode through unchanged;
Ryan C. Gordon <icculus@icculus.org>
parents:
101
diff
changeset
|
640 |
*/ |
469
b8cfaae6c4af
Renamed "passthrough" profile to "bytecode"
Ryan C. Gordon <icculus@icculus.org>
parents:
465
diff
changeset
|
641 |
#define MOJOSHADER_PROFILE_BYTECODE "bytecode" |
109
48e95cf41505
Added "passthrough" profile, which just sends the bytecode through unchanged;
Ryan C. Gordon <icculus@icculus.org>
parents:
101
diff
changeset
|
642 |
|
48e95cf41505
Added "passthrough" profile, which just sends the bytecode through unchanged;
Ryan C. Gordon <icculus@icculus.org>
parents:
101
diff
changeset
|
643 |
/* |
46 | 644 |
* Profile string for GLSL: OpenGL high-level shader language output. |
645 |
*/ |
|
646 |
#define MOJOSHADER_PROFILE_GLSL "glsl" |
|
647 |
||
323
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
284
diff
changeset
|
648 |
/* |
407
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
361
diff
changeset
|
649 |
* Profile string for GLSL 1.20: minor improvements to base GLSL spec. |
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
361
diff
changeset
|
650 |
*/ |
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
361
diff
changeset
|
651 |
#define MOJOSHADER_PROFILE_GLSL120 "glsl120" |
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
361
diff
changeset
|
652 |
|
620d48c5d13a
Added framework for GLSL 1.20 support.
Ryan C. Gordon <icculus@icculus.org>
parents:
361
diff
changeset
|
653 |
/* |
323
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
284
diff
changeset
|
654 |
* Profile string for OpenGL ARB 1.0 shaders: GL_ARB_(vertex|fragment)_program. |
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
284
diff
changeset
|
655 |
*/ |
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
284
diff
changeset
|
656 |
#define MOJOSHADER_PROFILE_ARB1 "arb1" |
b60c88ec8182
Initial work on ARB1 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
284
diff
changeset
|
657 |
|
361
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
658 |
/* |
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
659 |
* Profile string for OpenGL ARB 1.0 shaders with Nvidia 2.0 extensions: |
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
660 |
* GL_NV_vertex_program2_option and GL_NV_fragment_program2 |
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
661 |
*/ |
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
662 |
#define MOJOSHADER_PROFILE_NV2 "nv2" |
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
663 |
|
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
664 |
/* |
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
665 |
* Profile string for OpenGL ARB 1.0 shaders with Nvidia 3.0 extensions: |
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
666 |
* GL_NV_vertex_program3 and GL_NV_fragment_program2 |
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
667 |
*/ |
421
bfd3d95273ec
First piece of work on nv3 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
407
diff
changeset
|
668 |
#define MOJOSHADER_PROFILE_NV3 "nv3" |
361
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
669 |
|
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
670 |
/* |
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
671 |
* Profile string for OpenGL ARB 1.0 shaders with Nvidia 4.0 extensions: |
454
70c9818840eb
Happy September. Minor comment tweak.
Ryan C. Gordon <icculus@icculus.org>
parents:
450
diff
changeset
|
672 |
* GL_NV_gpu_program4 |
361
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
673 |
*/ |
431
0d0cbe10db02
First shot at nv4 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
422
diff
changeset
|
674 |
#define MOJOSHADER_PROFILE_NV4 "nv4" |
361
9fa6652cacbd
First (untested) work on nv2 profile.
Ryan C. Gordon <icculus@icculus.org>
parents:
356
diff
changeset
|
675 |
|
458
b91904879798
Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents:
455
diff
changeset
|
676 |
/* |
b91904879798
Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents:
455
diff
changeset
|
677 |
* Determine the highest supported Shader Model for a profile. |
b91904879798
Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents:
455
diff
changeset
|
678 |
*/ |
b91904879798
Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents:
455
diff
changeset
|
679 |
int MOJOSHADER_maxShaderModel(const char *profile); |
b91904879798
Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents:
455
diff
changeset
|
680 |
|
97
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
681 |
|
46 | 682 |
/* |
683 |
* Parse a compiled Direct3D shader's bytecode. |
|
684 |
* |
|
685 |
* This is your primary entry point into MojoShader. You need to pass it |
|
686 |
* a compiled D3D shader and tell it which "profile" you want to use to |
|
687 |
* convert it into useful data. |
|
688 |
* |
|
689 |
* The available profiles are the set of MOJOSHADER_PROFILE_* defines. |
|
690 |
* Note that MojoShader may be built without support for all listed |
|
691 |
* profiles (in which case using one here will return with an error). |
|
692 |
* |
|
693 |
* As parsing requires some memory to be allocated, you may provide a custom |
|
694 |
* allocator to this function, which will be used to allocate/free memory. |
|
695 |
* They function just like malloc() and free(). We do not use realloc(). |
|
97
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
696 |
* If you don't care, pass NULL in for the allocator functions. If your |
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
697 |
* allocator needs instance-specific data, you may supply it with the |
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
698 |
* (d) parameter. This pointer is passed as-is to your (m) and (f) functions. |
46 | 699 |
* |
97
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
700 |
* This function returns a MOJOSHADER_parseData. |
46 | 701 |
* |
702 |
* This function will never return NULL, even if the system is completely |
|
703 |
* out of memory upon entry (in which case, this function returns a static |
|
704 |
* MOJOSHADER_parseData object, which is still safe to pass to |
|
705 |
* MOJOSHADER_freeParseData()). |
|
706 |
* |
|
450
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
707 |
* You can tell the generated program to swizzle certain inputs. If you know |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
708 |
* that COLOR0 should be RGBA but you're passing in ARGB, you can specify |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
709 |
* a swizzle of { MOJOSHADER_USAGE_COLOR, 0, {1,2,3,0} } to (swiz). If the |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
710 |
* input register in the code would produce reg.ywzx, that swizzle would |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
711 |
* change it to reg.wzxy ... (swiz) can be NULL. |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
712 |
* |
1104
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
713 |
* You can force the shader to expect samplers of certain types. Generally |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
714 |
* you don't need this, as Shader Model 2 and later always specify what they |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
715 |
* expect samplers to be (2D, cubemap, etc). Shader Model 1, however, just |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
716 |
* uses whatever is bound to a given sampler at draw time, but this doesn't |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
717 |
* work in OpenGL, etc. In these cases, MojoShader will default to |
1106
2bef26cc20f9
More work on sampler remapping...3D should probably default to cubemaps, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
1104
diff
changeset
|
718 |
* 2D texture sampling (or cubemap sampling, in cases where it makes sense, |
2bef26cc20f9
More work on sampler remapping...3D should probably default to cubemaps, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
1104
diff
changeset
|
719 |
* like the TEXM3X3TEX opcode), which works 75% of the time, but if you |
2bef26cc20f9
More work on sampler remapping...3D should probably default to cubemaps, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
1104
diff
changeset
|
720 |
* really needed something else, you'll need to specify it here. This can |
2bef26cc20f9
More work on sampler remapping...3D should probably default to cubemaps, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
1104
diff
changeset
|
721 |
* also be used, at your own risk, to override DCL opcodes in shaders: if |
2bef26cc20f9
More work on sampler remapping...3D should probably default to cubemaps, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
1104
diff
changeset
|
722 |
* the shader explicit says 2D, but you want Cubemap, for example, you can |
2bef26cc20f9
More work on sampler remapping...3D should probably default to cubemaps, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
1104
diff
changeset
|
723 |
* use this to override. If you aren't sure about any of this stuff, you can |
2bef26cc20f9
More work on sampler remapping...3D should probably default to cubemaps, etc.
Ryan C. Gordon <icculus@icculus.org>
parents:
1104
diff
changeset
|
724 |
* (and should) almost certainly ignore it: (smap) can be NULL. |
1104
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
725 |
* |
187
1c709f65cf1b
Store profile string in MOJOSHADER_parseData.
Ryan C. Gordon <icculus@icculus.org>
parents:
148
diff
changeset
|
726 |
* This function is thread safe, so long as (m) and (f) are too, and that |
46 | 727 |
* (tokenbuf) remains intact for the duration of the call. This allows you |
728 |
* to parse several shaders on separate CPU cores at the same time. |
|
729 |
*/ |
|
730 |
const MOJOSHADER_parseData *MOJOSHADER_parse(const char *profile, |
|
731 |
const unsigned char *tokenbuf, |
|
732 |
const unsigned int bufsize, |
|
450
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
733 |
const MOJOSHADER_swizzle *swiz, |
6a9faf398c1d
Allow overriding of swizzle on vertex attributes during bytecode parsing.
Ryan C. Gordon <icculus@icculus.org>
parents:
438
diff
changeset
|
734 |
const unsigned int swizcount, |
1104
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
735 |
const MOJOSHADER_samplerMap *smap, |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
736 |
const unsigned int smapcount, |
46 | 737 |
MOJOSHADER_malloc m, |
97
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
738 |
MOJOSHADER_free f, |
4a41e3d17297
Allow instance data to be passed to the allocator.
Ryan C. Gordon <icculus@icculus.org>
parents:
94
diff
changeset
|
739 |
void *d); |
46 | 740 |
|
741 |
/* |
|
742 |
* Call this to dispose of parsing results when you are done with them. |
|
743 |
* This will call the MOJOSHADER_free function you provided to |
|
744 |
* MOJOSHADER_parse multiple times, if you provided one. |
|
745 |
* Passing a NULL here is a safe no-op. |
|
746 |
* |
|
747 |
* This function is thread safe, so long as any allocator you passed into |
|
748 |
* MOJOSHADER_parse() is, too. |
|
749 |
*/ |
|
750 |
void MOJOSHADER_freeParseData(const MOJOSHADER_parseData *data); |
|
7 | 751 |
|
196
5715754e5549
Initial API proposal for OpenGL glue.
Ryan C. Gordon <icculus@icculus.org>
parents:
190
diff
changeset
|
752 |
|
1019
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
753 |
/* Effects interface... */ /* !!! FIXME: THIS API IS NOT STABLE YET! */ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
754 |
|
1037
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
755 |
typedef struct MOJOSHADER_effectParam |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
756 |
{ |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
757 |
const char *name; |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
758 |
const char *semantic; |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
759 |
} MOJOSHADER_effectParam; |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
760 |
|
1019
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
761 |
typedef struct MOJOSHADER_effectState |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
762 |
{ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
763 |
unsigned int type; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
764 |
} MOJOSHADER_effectState; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
765 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
766 |
typedef struct MOJOSHADER_effectPass |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
767 |
{ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
768 |
const char *name; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
769 |
unsigned int state_count; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
770 |
MOJOSHADER_effectState *states; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
771 |
} MOJOSHADER_effectPass; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
772 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
773 |
typedef struct MOJOSHADER_effectTechnique |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
774 |
{ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
775 |
const char *name; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
776 |
unsigned int pass_count; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
777 |
MOJOSHADER_effectPass *passes; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
778 |
} MOJOSHADER_effectTechnique; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
779 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
780 |
typedef struct MOJOSHADER_effectTexture |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
781 |
{ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
782 |
unsigned int param; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
783 |
const char *name; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
784 |
} MOJOSHADER_effectTexture; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
785 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
786 |
typedef struct MOJOSHADER_effectShader |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
787 |
{ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
788 |
unsigned int technique; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
789 |
unsigned int pass; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
790 |
const MOJOSHADER_parseData *shader; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
791 |
} MOJOSHADER_effectShader; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
792 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
793 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
794 |
* Structure used to return data from parsing of an effect file... |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
795 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
796 |
/* !!! FIXME: most of these ints should be unsigned. */ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
797 |
typedef struct MOJOSHADER_effect |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
798 |
{ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
799 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
800 |
* The number of elements pointed to by (errors). |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
801 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
802 |
int error_count; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
803 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
804 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
805 |
* (error_count) elements of data that specify errors that were generated |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
806 |
* by parsing this shader. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
807 |
* This can be NULL if there were no errors or if (error_count) is zero. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
808 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
809 |
MOJOSHADER_error *errors; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
810 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
811 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
812 |
* The name of the profile used to parse the shader. Will be NULL on error. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
813 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
814 |
const char *profile; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
815 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
816 |
/* |
1037
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
817 |
* The number of params pointed to by (params). |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
818 |
*/ |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
819 |
int param_count; |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
820 |
|
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
821 |
/* |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
822 |
* (param_count) elements of data that specify parameter bind points for |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
823 |
* this effect. |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
824 |
* This can be NULL on error or if (param_count) is zero. |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
825 |
*/ |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
826 |
MOJOSHADER_effectParam *params; |
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
827 |
|
b102a563d9cb
Filled in and fixed some stuff in the Effect parser.
Ryan C. Gordon <icculus@icculus.org>
parents:
1035
diff
changeset
|
828 |
/* |
1019
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
829 |
* The number of elements pointed to by (techniques). |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
830 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
831 |
int technique_count; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
832 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
833 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
834 |
* (technique_count) elements of data that specify techniques used in |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
835 |
* this effect. Each technique contains a series of passes, and each pass |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
836 |
* specifies state and shaders that affect rendering. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
837 |
* This can be NULL on error or if (technique_count) is zero. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
838 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
839 |
MOJOSHADER_effectTechnique *techniques; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
840 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
841 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
842 |
* The number of elements pointed to by (textures). |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
843 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
844 |
int texture_count; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
845 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
846 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
847 |
* (texture_count) elements of data that specify textures used in |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
848 |
* this effect. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
849 |
* This can be NULL on error or if (texture_count) is zero. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
850 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
851 |
MOJOSHADER_effectTexture *textures; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
852 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
853 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
854 |
* The number of elements pointed to by (shaders). |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
855 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
856 |
int shader_count; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
857 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
858 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
859 |
* (shader_count) elements of data that specify shaders used in |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
860 |
* this effect. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
861 |
* This can be NULL on error or if (shader_count) is zero. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
862 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
863 |
MOJOSHADER_effectShader *shaders; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
864 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
865 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
866 |
* This is the malloc implementation you passed to MOJOSHADER_parseEffect(). |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
867 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
868 |
MOJOSHADER_malloc malloc; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
869 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
870 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
871 |
* This is the free implementation you passed to MOJOSHADER_parseEffect(). |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
872 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
873 |
MOJOSHADER_free free; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
874 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
875 |
/* |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
876 |
* This is the pointer you passed as opaque data for your allocator. |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
877 |
*/ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
878 |
void *malloc_data; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
879 |
} MOJOSHADER_effect; |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
880 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
881 |
/* !!! FIXME: document me. */ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
882 |
const MOJOSHADER_effect *MOJOSHADER_parseEffect(const char *profile, |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
883 |
const unsigned char *buf, |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
884 |
const unsigned int _len, |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
885 |
const MOJOSHADER_swizzle *swiz, |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
886 |
const unsigned int swizcount, |
1104
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
887 |
const MOJOSHADER_samplerMap *smap, |
9147482e1ec7
Allow sampler type remapping.
Ryan C. Gordon <icculus@icculus.org>
parents:
1090
diff
changeset
|
888 |
const unsigned int smapcount, |
1019
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
889 |
MOJOSHADER_malloc m, |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
890 |
MOJOSHADER_free f, |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
891 |
void *d); |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
892 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
893 |
|
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
894 |
/* !!! FIXME: document me. */ |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
895 |
void MOJOSHADER_freeEffect(const MOJOSHADER_effect *effect); |
e8988ca01c6d
Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
1017
diff
changeset
|
896 |
|
218 | 897 |
|
555
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
898 |
/* Preprocessor interface... */ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
899 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
900 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
901 |
* Structure used to pass predefined macros. Maps to D3DXMACRO. |
675 | 902 |
* You can have macro arguments: set identifier to "a(b, c)" or whatever. |
555
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
903 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
904 |
typedef struct MOJOSHADER_preprocessorDefine |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
905 |
{ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
906 |
const char *identifier; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
907 |
const char *definition; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
908 |
} MOJOSHADER_preprocessorDefine; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
909 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
910 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
911 |
* Used with the MOJOSHADER_includeOpen callback. Maps to D3DXINCLUDE_TYPE. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
912 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
913 |
typedef enum |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
914 |
{ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
915 |
MOJOSHADER_INCLUDETYPE_LOCAL, /* local header: #include "blah.h" */ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
916 |
MOJOSHADER_INCLUDETYPE_SYSTEM /* system header: #include <blah.h> */ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
917 |
} MOJOSHADER_includeType; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
918 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
919 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
920 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
921 |
* Structure used to return data from preprocessing of a shader... |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
922 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
923 |
/* !!! FIXME: most of these ints should be unsigned. */ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
924 |
typedef struct MOJOSHADER_preprocessData |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
925 |
{ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
926 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
927 |
* The number of elements pointed to by (errors). |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
928 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
929 |
int error_count; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
930 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
931 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
932 |
* (error_count) elements of data that specify errors that were generated |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
933 |
* by parsing this shader. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
934 |
* This can be NULL if there were no errors or if (error_count) is zero. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
935 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
936 |
MOJOSHADER_error *errors; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
937 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
938 |
/* |
579
e408bfc631f5
Replaced some "ASCII" comments with "UTF-8".
Ryan C. Gordon <icculus@icculus.org>
parents:
578
diff
changeset
|
939 |
* Bytes of output from preprocessing. This is a UTF-8 string. We |
555
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
940 |
* guarantee it to be NULL-terminated. Will be NULL on error. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
941 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
942 |
const char *output; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
943 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
944 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
945 |
* Byte count for output, not counting any null terminator. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
946 |
* Will be 0 on error. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
947 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
948 |
int output_len; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
949 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
950 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
951 |
* This is the malloc implementation you passed to MOJOSHADER_parse(). |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
952 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
953 |
MOJOSHADER_malloc malloc; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
954 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
955 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
956 |
* This is the free implementation you passed to MOJOSHADER_parse(). |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
957 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
958 |
MOJOSHADER_free free; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
959 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
960 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
961 |
* This is the pointer you passed as opaque data for your allocator. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
962 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
963 |
void *malloc_data; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
964 |
} MOJOSHADER_preprocessData; |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
965 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
966 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
967 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
968 |
* This callback allows an app to handle #include statements for the |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
969 |
* preprocessor. When the preprocessor sees an #include, it will call this |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
970 |
* function to obtain the contents of the requested file. This is optional; |
728 | 971 |
* the preprocessor will open files directly if no callback is supplied, but |
555
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
972 |
* this allows an app to retrieve data from something other than the |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
973 |
* traditional filesystem (for example, headers packed in a .zip file or |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
974 |
* headers generated on-the-fly). |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
975 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
976 |
* This function maps to ID3DXInclude::Open() |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
977 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
978 |
* (inctype) specifies the type of header we wish to include. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
979 |
* (fname) specifies the name of the file specified on the #include line. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
980 |
* (parent) is a string of the entire source file containing the include, in |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
981 |
* its original, not-yet-preprocessed state. Note that this is just the |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
982 |
* contents of the specific file, not all source code that the preprocessor |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
983 |
* has seen through other includes, etc. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
984 |
* (outdata) will be set by the callback to a pointer to the included file's |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
985 |
* contents. The callback is responsible for allocating this however they |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
986 |
* see fit (we provide allocator functions, but you may ignore them). This |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
987 |
* pointer must remain valid until the includeClose callback runs. This |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
988 |
* string does not need to be NULL-terminated. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
989 |
* (outbytes) will be set by the callback to the number of bytes pointed to |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
990 |
* by (outdata). |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
991 |
* (m),(f), and (d) are the allocator details that the application passed to |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
992 |
* MojoShader. If these were NULL, MojoShader may have replaced them with its |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
993 |
* own internal allocators. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
994 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
995 |
* The callback returns zero on error, non-zero on success. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
996 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
997 |
* If you supply an includeOpen callback, you must supply includeClose, too. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
998 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
999 |
typedef int (*MOJOSHADER_includeOpen)(MOJOSHADER_includeType inctype, |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1000 |
const char *fname, const char *parent, |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1001 |
const char **outdata, unsigned int *outbytes, |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1002 |
MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1003 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1004 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1005 |
* This callback allows an app to clean up the results of a previous |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1006 |
* includeOpen callback. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1007 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1008 |
* This function maps to ID3DXInclude::Close() |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1009 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1010 |
* (data) is the data that was returned from a previous call to includeOpen. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1011 |
* It is now safe to deallocate this data. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1012 |
* (m),(f), and (d) are the same allocator details that were passed to your |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1013 |
* includeOpen callback. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1014 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1015 |
* If you supply an includeClose callback, you must supply includeOpen, too. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1016 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1017 |
typedef void (*MOJOSHADER_includeClose)(const char *data, |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1018 |
MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1019 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1020 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1021 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1022 |
* This function is optional. Even if you are dealing with shader source |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1023 |
* code, you don't need to explicitly use the preprocessor, as the compiler |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1024 |
* and assembler will use it behind the scenes. In fact, you probably never |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1025 |
* need this function unless you are debugging a custom tool (or debugging |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1026 |
* MojoShader itself). |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1027 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1028 |
* Preprocessing roughly follows the syntax of an ANSI C preprocessor, as |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1029 |
* Microsoft's Direct3D assembler and HLSL compiler use this syntax. Please |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1030 |
* note that we try to match the output you'd get from Direct3D's |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1031 |
* preprocessor, which has some quirks if you're expecting output that matches |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1032 |
* a generic C preprocessor. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1033 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1034 |
* This function maps to D3DXPreprocessShader(). |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1035 |
* |
578
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1036 |
* (filename) is a NULL-terminated UTF-8 filename. It can be NULL. We do not |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1037 |
* actually access this file, as we obtain our data from (source). This |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1038 |
* string is copied when we need to report errors while processing (source), |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1039 |
* as opposed to errors in a file referenced via the #include directive in |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1040 |
* (source). If this is NULL, then errors will report the filename as NULL, |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1041 |
* too. |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1042 |
* |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1043 |
* (source) is an string of UTF-8 text to preprocess. It does not need to be |
555
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1044 |
* NULL-terminated. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1045 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1046 |
* (sourcelen) is the length of the string pointed to by (source), in bytes. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1047 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1048 |
* (defines) points to (define_count) preprocessor definitions, and can be |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1049 |
* NULL. These are treated by the preprocessor as if the source code started |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1050 |
* with one #define for each entry you pass in here. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1051 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1052 |
* (include_open) and (include_close) let the app control the preprocessor's |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1053 |
* behaviour for #include statements. Both are optional and can be NULL, but |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1054 |
* both must be specified if either is specified. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1055 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1056 |
* This will return a MOJOSHADER_preprocessorData. You should pass this |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1057 |
* return value to MOJOSHADER_freePreprocessData() when you are done with |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1058 |
* it. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1059 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1060 |
* This function will never return NULL, even if the system is completely |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1061 |
* out of memory upon entry (in which case, this function returns a static |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1062 |
* MOJOSHADER_preprocessData object, which is still safe to pass to |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1063 |
* MOJOSHADER_freePreprocessData()). |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1064 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1065 |
* As preprocessing requires some memory to be allocated, you may provide a |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1066 |
* custom allocator to this function, which will be used to allocate/free |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1067 |
* memory. They function just like malloc() and free(). We do not use |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1068 |
* realloc(). If you don't care, pass NULL in for the allocator functions. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1069 |
* If your allocator needs instance-specific data, you may supply it with the |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1070 |
* (d) parameter. This pointer is passed as-is to your (m) and (f) functions. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1071 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1072 |
* This function is thread safe, so long as the various callback functions |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1073 |
* are, too, and that the parameters remains intact for the duration of the |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1074 |
* call. This allows you to preprocess several shaders on separate CPU cores |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1075 |
* at the same time. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1076 |
*/ |
578
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1077 |
const MOJOSHADER_preprocessData *MOJOSHADER_preprocess(const char *filename, |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1078 |
const char *source, unsigned int sourcelen, |
658
22695d3d6b98
Should be an array of structs, not an array of pointers to structs.
Ryan C. Gordon <icculus@icculus.org>
parents:
592
diff
changeset
|
1079 |
const MOJOSHADER_preprocessorDefine *defines, |
555
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1080 |
unsigned int define_count, |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1081 |
MOJOSHADER_includeOpen include_open, |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1082 |
MOJOSHADER_includeClose include_close, |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1083 |
MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1084 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1085 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1086 |
/* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1087 |
* Call this to dispose of preprocessing results when you are done with them. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1088 |
* This will call the MOJOSHADER_free function you provided to |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1089 |
* MOJOSHADER_preprocess() multiple times, if you provided one. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1090 |
* Passing a NULL here is a safe no-op. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1091 |
* |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1092 |
* This function is thread safe, so long as any allocator you passed into |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1093 |
* MOJOSHADER_preprocess() is, too. |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1094 |
*/ |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1095 |
void MOJOSHADER_freePreprocessData(const MOJOSHADER_preprocessData *data); |
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1096 |
|
940821555fda
Initial work on preprocessor. Not yet complete!
Ryan C. Gordon <icculus@icculus.org>
parents:
552
diff
changeset
|
1097 |
|
465
0a75f98f785b
Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents:
462
diff
changeset
|
1098 |
/* Assembler interface... */ |
0a75f98f785b
Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents:
462
diff
changeset
|
1099 |
|
0a75f98f785b
Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents:
462
diff
changeset
|
1100 |
/* |
0a75f98f785b
Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents:
462
diff
changeset
|
1101 |
* This function is optional. Use this to convert Direct3D shader assembly |
0a75f98f785b
Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents:
462
diff
changeset
|
1102 |
* language into bytecode, which can be handled by MOJOSHADER_parse(). |
0a75f98f785b
Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents:
462
diff
changeset
|
1103 |
* |
578
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1104 |
* (filename) is a NULL-terminated UTF-8 filename. It can be NULL. We do not |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1105 |
* actually access this file, as we obtain our data from (source). This |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1106 |
* string is copied when we need to report errors while processing (source), |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1107 |
* as opposed to errors in a file referenced via the #include directive in |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1108 |
* (source). If this is NULL, then errors will report the filename as NULL, |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1109 |
* too. |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1110 |
* |
6c8f73c845e7
Allow app to specify a base filename for error messages.
Ryan C. Gordon <icculus@icculus.org>
parents:
562
diff
changeset
|
1111 |
* (source) is an UTF-8 string of valid Direct3D shader assembly source code. |
562
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1112 |
* It does not need to be NULL-terminated. |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1113 |
* |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1114 |
* (sourcelen) is the length of the string pointed to by (source), in bytes. |
465
0a75f98f785b
Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents:
462
diff
changeset
|
1115 |
* |
579
e408bfc631f5
Replaced some "ASCII" comments with "UTF-8".
Ryan C. Gordon <icculus@icculus.org>
parents:
578
diff
changeset
|
1116 |
* (comments) points to (comment_count) NULL-terminated UTF-8 strings, and |
524
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1117 |
* can be NULL. These strings are inserted as comments in the bytecode. |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1118 |
* |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1119 |
* (symbols) points to (symbol_count) symbol structs, and can be NULL. These |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1120 |
* become a CTAB field in the bytecode. This is optional, but |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1121 |
* MOJOSHADER_parse() needs CTAB data for all arrays used in a program, or |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1122 |
* relative addressing will not be permitted, so you'll want to at least |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1123 |
* provide symbol information for those. The symbol data is 100% trusted |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1124 |
* at this time; it will not be checked to see if it matches what was |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1125 |
* assembled in any way whatsoever. |
03eea2f0762c
First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents:
523
diff
changeset
|
1126 |
* |
562
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1127 |
* (defines) points to (define_count) preprocessor definitions, and can be |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1128 |
* NULL. These are treated by the preprocessor as if the source code started |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1129 |
* with one #define for each entry you pass in here. |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1130 |
* |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1131 |
* (include_open) and (include_close) let the app control the preprocessor's |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1132 |
* behaviour for #include statements. Both are optional and can be NULL, but |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1133 |
* both must be specified if either is specified. |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1134 |
* |
c9a2bc5129c9
First shot at reworking assembly parser to use preprocessor/lexer.
Ryan C. Gordon <icculus@icculus.org>
parents:
555
diff
changeset
|
1135 |
* This will return a MOJOSHADER_parseData, like MOJOSHADER_parse() would, |
470
7d84d3452125
Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents:
469
diff
changeset
|
1136 |
* except the profile will be MOJOSHADER_PROFILE_BYTECODE and the output |
7d84d3452125
Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents:
469
diff
changeset
|
1137 |
* will be the assembled bytecode instead of some other language. This output |
7d84d3452125
Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents:
469
diff
changeset
|
1138 |
* can be pushed back through MOJOSHADER_parseData() with a different profile. |
7d84d3452125
Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents:
469
diff
changeset
|
1139 |
* |
7d84d3452125
Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents:
469
diff
changeset
|
1140 |
* This function will never return NULL, even if the system is completely |
7d84d3452125
Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents:
469
diff
changeset
|
1141 |
* out of memory upon entry (in which case, this function returns a static |
7d84d3452125
Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents:
469
diff
changeset
|
1142 |
* MOJOSHADER_parseData object, which is still safe to pass to |
7d84d3452125
Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents:
469
diff
changeset
|
1143 |
* MOJOSHADER_freeParseData()). |
7d84d3452125
Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents:
469
diff
changeset
|
1144 |
* |
465
0a75f98f785b
Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents:
462
diff
changeset
|
1145 |
* As assembling requires some memory to be allocated, you may provide a |
0a75f98f785b
Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents:
462
diff
changeset
|
1146 |
* custom allocator to this function, which will be used to allocate/free |
0a75f98f785b
Initial work on assembler. Not |