wut  1.0.0-beta8
Wii U Toolchain
shaders.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include "enum.h"
4 #include "sampler.h"
5 #include "gx2r/buffer.h"
6 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 typedef struct GX2AttribVar GX2AttribVar;
21 typedef struct GX2LoopVar GX2LoopVar;
28 
30 {
32 
33  struct
34  {
35  uint32_t sq_pgm_resources_fs;
36  } regs;
37 
38  uint32_t size;
39  void *program;
40  uint32_t attribCount;
41  uint32_t numDivisors;
42  uint32_t divisors[2];
43 };
44 WUT_CHECK_OFFSET(GX2FetchShader, 0x0, type);
45 WUT_CHECK_OFFSET(GX2FetchShader, 0x4, regs.sq_pgm_resources_fs);
46 WUT_CHECK_OFFSET(GX2FetchShader, 0x8, size);
47 WUT_CHECK_OFFSET(GX2FetchShader, 0xc, program);
48 WUT_CHECK_OFFSET(GX2FetchShader, 0x10, attribCount);
49 WUT_CHECK_OFFSET(GX2FetchShader, 0x14, numDivisors);
50 WUT_CHECK_OFFSET(GX2FetchShader, 0x18, divisors);
51 WUT_CHECK_SIZE(GX2FetchShader, 0x20);
52 
54 {
55  const char *name;
56  uint32_t offset;
57  uint32_t size;
58 };
59 WUT_CHECK_OFFSET(GX2UniformBlock, 0x00, name);
60 WUT_CHECK_OFFSET(GX2UniformBlock, 0x04, offset);
61 WUT_CHECK_OFFSET(GX2UniformBlock, 0x08, size);
62 WUT_CHECK_SIZE(GX2UniformBlock, 0x0C);
63 
65 {
66  const char *name;
68  uint32_t count;
69  uint32_t offset;
70  int32_t block;
71 };
72 WUT_CHECK_OFFSET(GX2UniformVar, 0x00, name);
73 WUT_CHECK_OFFSET(GX2UniformVar, 0x04, type);
74 WUT_CHECK_OFFSET(GX2UniformVar, 0x08, count);
75 WUT_CHECK_OFFSET(GX2UniformVar, 0x0C, offset);
76 WUT_CHECK_OFFSET(GX2UniformVar, 0x10, block);
77 WUT_CHECK_SIZE(GX2UniformVar, 0x14);
78 
80 {
81  float value[4];
82  uint32_t offset;
83 };
84 WUT_CHECK_OFFSET(GX2UniformInitialValue, 0x00, value);
85 WUT_CHECK_OFFSET(GX2UniformInitialValue, 0x10, offset);
86 WUT_CHECK_SIZE(GX2UniformInitialValue, 0x14);
87 
88 struct GX2LoopVar
89 {
90  uint32_t offset;
91  uint32_t value;
92 };
93 WUT_CHECK_OFFSET(GX2LoopVar, 0x00, offset);
94 WUT_CHECK_OFFSET(GX2LoopVar, 0x04, value);
95 WUT_CHECK_SIZE(GX2LoopVar, 0x08);
96 
98 {
99  const char *name;
101  uint32_t location;
102 };
103 WUT_CHECK_OFFSET(GX2SamplerVar, 0x00, name);
104 WUT_CHECK_OFFSET(GX2SamplerVar, 0x04, type);
105 WUT_CHECK_OFFSET(GX2SamplerVar, 0x08, location);
106 WUT_CHECK_SIZE(GX2SamplerVar, 0x0C);
107 
109 {
110  const char *name;
112  uint32_t count;
113  uint32_t location;
114 };
115 WUT_CHECK_OFFSET(GX2AttribVar, 0x00, name);
116 WUT_CHECK_OFFSET(GX2AttribVar, 0x04, type);
117 WUT_CHECK_OFFSET(GX2AttribVar, 0x08, count);
118 WUT_CHECK_OFFSET(GX2AttribVar, 0x0C, location);
119 WUT_CHECK_SIZE(GX2AttribVar, 0x10);
120 
122 {
123  struct
124  {
125  uint32_t sq_pgm_resources_vs;
126  uint32_t vgt_primitiveid_en;
127  uint32_t spi_vs_out_config;
128  uint32_t num_spi_vs_out_id;
129  uint32_t spi_vs_out_id[10];
130  uint32_t pa_cl_vs_out_cntl;
131  uint32_t sq_vtx_semantic_clear;
132  uint32_t num_sq_vtx_semantic;
133  uint32_t sq_vtx_semantic[32];
134  uint32_t vgt_strmout_buffer_en;
135  uint32_t vgt_vertex_reuse_block_cntl;
136  uint32_t vgt_hos_reuse_depth;
137  } regs;
138 
139  uint32_t size;
140  void *program;
142 
145 
146  uint32_t uniformVarCount;
148 
151 
152  uint32_t loopVarCount;
154 
155  uint32_t samplerVarCount;
157 
158  uint32_t attribVarCount;
160 
161  uint32_t ringItemsize;
162 
164  uint32_t streamOutStride[4];
165 
167 };
168 WUT_CHECK_OFFSET(GX2VertexShader, 0x00, regs.sq_pgm_resources_vs);
169 WUT_CHECK_OFFSET(GX2VertexShader, 0x04, regs.vgt_primitiveid_en);
170 WUT_CHECK_OFFSET(GX2VertexShader, 0x08, regs.spi_vs_out_config);
171 WUT_CHECK_OFFSET(GX2VertexShader, 0x0C, regs.num_spi_vs_out_id);
172 WUT_CHECK_OFFSET(GX2VertexShader, 0x10, regs.spi_vs_out_id);
173 WUT_CHECK_OFFSET(GX2VertexShader, 0x38, regs.pa_cl_vs_out_cntl);
174 WUT_CHECK_OFFSET(GX2VertexShader, 0x3C, regs.sq_vtx_semantic_clear);
175 WUT_CHECK_OFFSET(GX2VertexShader, 0x40, regs.num_sq_vtx_semantic);
176 WUT_CHECK_OFFSET(GX2VertexShader, 0x44, regs.sq_vtx_semantic);
177 WUT_CHECK_OFFSET(GX2VertexShader, 0xC4, regs.vgt_strmout_buffer_en);
178 WUT_CHECK_OFFSET(GX2VertexShader, 0xC8, regs.vgt_vertex_reuse_block_cntl);
179 WUT_CHECK_OFFSET(GX2VertexShader, 0xCC, regs.vgt_hos_reuse_depth);
180 WUT_CHECK_OFFSET(GX2VertexShader, 0xD0, size);
181 WUT_CHECK_OFFSET(GX2VertexShader, 0xD4, program);
182 WUT_CHECK_OFFSET(GX2VertexShader, 0xD8, mode);
183 WUT_CHECK_OFFSET(GX2VertexShader, 0xDc, uniformBlockCount);
184 WUT_CHECK_OFFSET(GX2VertexShader, 0xE0, uniformBlocks);
185 WUT_CHECK_OFFSET(GX2VertexShader, 0xE4, uniformVarCount);
186 WUT_CHECK_OFFSET(GX2VertexShader, 0xE8, uniformVars);
187 WUT_CHECK_OFFSET(GX2VertexShader, 0xEc, initialValueCount);
188 WUT_CHECK_OFFSET(GX2VertexShader, 0xF0, initialValues);
189 WUT_CHECK_OFFSET(GX2VertexShader, 0xF4, loopVarCount);
190 WUT_CHECK_OFFSET(GX2VertexShader, 0xF8, loopVars);
191 WUT_CHECK_OFFSET(GX2VertexShader, 0xFc, samplerVarCount);
192 WUT_CHECK_OFFSET(GX2VertexShader, 0x100, samplerVars);
193 WUT_CHECK_OFFSET(GX2VertexShader, 0x104, attribVarCount);
194 WUT_CHECK_OFFSET(GX2VertexShader, 0x108, attribVars);
195 WUT_CHECK_OFFSET(GX2VertexShader, 0x10c, ringItemsize);
196 WUT_CHECK_OFFSET(GX2VertexShader, 0x110, hasStreamOut);
197 WUT_CHECK_OFFSET(GX2VertexShader, 0x114, streamOutStride);
198 WUT_CHECK_OFFSET(GX2VertexShader, 0x124, gx2rBuffer);
199 WUT_CHECK_SIZE(GX2VertexShader, 0x134);
200 
202 {
203  struct
204  {
205  uint32_t sq_pgm_resources_ps;
206  uint32_t sq_pgm_exports_ps;
207  uint32_t spi_ps_in_control_0;
208  uint32_t spi_ps_in_control_1;
209  uint32_t num_spi_ps_input_cntl;
210  uint32_t spi_ps_input_cntls[32];
211  uint32_t cb_shader_mask;
212  uint32_t cb_shader_control;
213  uint32_t db_shader_control;
214  uint32_t spi_input_z;
215  } regs;
216 
217  uint32_t size;
218  void *program;
220 
223 
224  uint32_t uniformVarCount;
226 
229 
230  uint32_t loopVarCount;
232 
233  uint32_t samplerVarCount;
235 
237 };
238 WUT_CHECK_OFFSET(GX2PixelShader, 0x00, regs.sq_pgm_resources_ps);
239 WUT_CHECK_OFFSET(GX2PixelShader, 0x04, regs.sq_pgm_exports_ps);
240 WUT_CHECK_OFFSET(GX2PixelShader, 0x08, regs.spi_ps_in_control_0);
241 WUT_CHECK_OFFSET(GX2PixelShader, 0x0C, regs.spi_ps_in_control_1);
242 WUT_CHECK_OFFSET(GX2PixelShader, 0x10, regs.num_spi_ps_input_cntl);
243 WUT_CHECK_OFFSET(GX2PixelShader, 0x14, regs.spi_ps_input_cntls);
244 WUT_CHECK_OFFSET(GX2PixelShader, 0x94, regs.cb_shader_mask);
245 WUT_CHECK_OFFSET(GX2PixelShader, 0x98, regs.cb_shader_control);
246 WUT_CHECK_OFFSET(GX2PixelShader, 0x9C, regs.db_shader_control);
247 WUT_CHECK_OFFSET(GX2PixelShader, 0xA0, regs.spi_input_z);
248 WUT_CHECK_OFFSET(GX2PixelShader, 0xA4, size);
249 WUT_CHECK_OFFSET(GX2PixelShader, 0xA8, program);
250 WUT_CHECK_OFFSET(GX2PixelShader, 0xAC, mode);
251 WUT_CHECK_OFFSET(GX2PixelShader, 0xB0, uniformBlockCount);
252 WUT_CHECK_OFFSET(GX2PixelShader, 0xB4, uniformBlocks);
253 WUT_CHECK_OFFSET(GX2PixelShader, 0xB8, uniformVarCount);
254 WUT_CHECK_OFFSET(GX2PixelShader, 0xBC, uniformVars);
255 WUT_CHECK_OFFSET(GX2PixelShader, 0xC0, initialValueCount);
256 WUT_CHECK_OFFSET(GX2PixelShader, 0xC4, initialValues);
257 WUT_CHECK_OFFSET(GX2PixelShader, 0xC8, loopVarCount);
258 WUT_CHECK_OFFSET(GX2PixelShader, 0xCC, loopVars);
259 WUT_CHECK_OFFSET(GX2PixelShader, 0xD0, samplerVarCount);
260 WUT_CHECK_OFFSET(GX2PixelShader, 0xD4, samplerVars);
261 WUT_CHECK_OFFSET(GX2PixelShader, 0xD8, gx2rBuffer);
262 WUT_CHECK_SIZE(GX2PixelShader, 0xE8);
263 
265 {
266  struct
267  {
268  uint32_t sq_pgm_resources_gs;
269  uint32_t vgt_gs_out_prim_type;
270  uint32_t vgt_gs_mode;
271  uint32_t pa_cl_vs_out_cntl;
272  uint32_t sq_pgm_resources_vs;
273  uint32_t sq_gs_vert_itemsize;
274  uint32_t spi_vs_out_config;
275  uint32_t num_spi_vs_out_id;
276  uint32_t spi_vs_out_id[10];
277  uint32_t vgt_strmout_buffer_en;
278  } regs;
279 
280  uint32_t size;
281  void *program;
285 
288 
289  uint32_t uniformVarCount;
291 
294 
295  uint32_t loopVarCount;
297 
298  uint32_t samplerVarCount;
300 
301  uint32_t ringItemSize;
303  uint32_t streamOutStride[4];
304 
306 };
307 WUT_CHECK_OFFSET(GX2GeometryShader, 0x00, regs.sq_pgm_resources_gs);
308 WUT_CHECK_OFFSET(GX2GeometryShader, 0x04, regs.vgt_gs_out_prim_type);
309 WUT_CHECK_OFFSET(GX2GeometryShader, 0x08, regs.vgt_gs_mode);
310 WUT_CHECK_OFFSET(GX2GeometryShader, 0x0C, regs.pa_cl_vs_out_cntl);
311 WUT_CHECK_OFFSET(GX2GeometryShader, 0x10, regs.sq_pgm_resources_vs);
312 WUT_CHECK_OFFSET(GX2GeometryShader, 0x14, regs.sq_gs_vert_itemsize);
313 WUT_CHECK_OFFSET(GX2GeometryShader, 0x18, regs.spi_vs_out_config);
314 WUT_CHECK_OFFSET(GX2GeometryShader, 0x1C, regs.num_spi_vs_out_id);
315 WUT_CHECK_OFFSET(GX2GeometryShader, 0x20, regs.spi_vs_out_id);
316 WUT_CHECK_OFFSET(GX2GeometryShader, 0x48, regs.vgt_strmout_buffer_en);
317 WUT_CHECK_OFFSET(GX2GeometryShader, 0x4C, size);
318 WUT_CHECK_OFFSET(GX2GeometryShader, 0x50, program);
319 WUT_CHECK_OFFSET(GX2GeometryShader, 0x54, vertexProgramSize);
320 WUT_CHECK_OFFSET(GX2GeometryShader, 0x58, vertexProgram);
321 WUT_CHECK_OFFSET(GX2GeometryShader, 0x5C, mode);
322 WUT_CHECK_OFFSET(GX2GeometryShader, 0x60, uniformBlockCount);
323 WUT_CHECK_OFFSET(GX2GeometryShader, 0x64, uniformBlocks);
324 WUT_CHECK_OFFSET(GX2GeometryShader, 0x68, uniformVarCount);
325 WUT_CHECK_OFFSET(GX2GeometryShader, 0x6C, uniformVars);
326 WUT_CHECK_OFFSET(GX2GeometryShader, 0x70, initialValueCount);
327 WUT_CHECK_OFFSET(GX2GeometryShader, 0x74, initialValues);
328 WUT_CHECK_OFFSET(GX2GeometryShader, 0x78, loopVarCount);
329 WUT_CHECK_OFFSET(GX2GeometryShader, 0x7C, loopVars);
330 WUT_CHECK_OFFSET(GX2GeometryShader, 0x80, samplerVarCount);
331 WUT_CHECK_OFFSET(GX2GeometryShader, 0x84, samplerVars);
332 WUT_CHECK_OFFSET(GX2GeometryShader, 0x88, ringItemSize);
333 WUT_CHECK_OFFSET(GX2GeometryShader, 0x8C, hasStreamOut);
334 WUT_CHECK_OFFSET(GX2GeometryShader, 0x90, streamOutStride);
335 WUT_CHECK_OFFSET(GX2GeometryShader, 0xA0, gx2rBuffer);
336 WUT_CHECK_SIZE(GX2GeometryShader, 0xB0);
337 
339 {
340  uint32_t location;
341  uint32_t buffer;
342  uint32_t offset;
345  uint32_t aluDivisor;
346  uint32_t mask;
348 };
349 WUT_CHECK_OFFSET(GX2AttribStream, 0x0, location);
350 WUT_CHECK_OFFSET(GX2AttribStream, 0x4, buffer);
351 WUT_CHECK_OFFSET(GX2AttribStream, 0x8, offset);
352 WUT_CHECK_OFFSET(GX2AttribStream, 0xc, format);
353 WUT_CHECK_OFFSET(GX2AttribStream, 0x10, type);
354 WUT_CHECK_OFFSET(GX2AttribStream, 0x14, aluDivisor);
355 WUT_CHECK_OFFSET(GX2AttribStream, 0x18, mask);
356 WUT_CHECK_OFFSET(GX2AttribStream, 0x1c, endianSwap);
357 WUT_CHECK_SIZE(GX2AttribStream, 0x20);
358 
359 uint32_t
360 GX2CalcGeometryShaderInputRingBufferSize(uint32_t ringItemSize);
361 
362 uint32_t
363 GX2CalcGeometryShaderOutputRingBufferSize(uint32_t ringItemSize);
364 
365 uint32_t
366 GX2CalcFetchShaderSizeEx(uint32_t attribs,
367  GX2FetchShaderType fetchShaderType,
368  GX2TessellationMode tesellationMode);
369 
370 void
372  uint8_t *buffer,
373  uint32_t attribCount,
374  GX2AttribStream *attribs,
375  GX2FetchShaderType type,
376  GX2TessellationMode tessMode);
377 
378 void
380 
381 void
383 
384 void
386 
387 void
389 
390 void
392  uint32_t id);
393 
394 void
396  uint32_t id);
397 
398 void
400  uint32_t id);
401 
402 void
403 GX2SetVertexUniformReg(uint32_t offset,
404  uint32_t count,
405  uint32_t *data);
406 
407 void
408 GX2SetPixelUniformReg(uint32_t offset,
409  uint32_t count,
410  uint32_t *data);
411 
412 void
413 GX2SetVertexUniformBlock(uint32_t location,
414  uint32_t size,
415  const void *data);
416 
417 void
418 GX2SetPixelUniformBlock(uint32_t location,
419  uint32_t size,
420  const void *data);
421 
422 void
423 GX2SetGeometryUniformBlock(uint32_t location,
424  uint32_t size,
425  const void *data);
426 
427 void
429  uint32_t numVsGpr, uint32_t numVsStackEntries,
430  uint32_t numGsGpr, uint32_t numGsStackEntries,
431  uint32_t numPsGpr, uint32_t numPsStackEntries);
432 
433 void
435 
436 void
438  uint32_t size);
439 
440 void
442  uint32_t size);
443 
444 uint32_t
446 
447 uint32_t
449 
450 uint32_t
452 
453 uint32_t
455 
456 uint32_t
458 
459 uint32_t
461 
462 #ifdef __cplusplus
463 }
464 #endif
465 
uint32_t value
Definition: shaders.h:91
void GX2SetVertexShader(GX2VertexShader *shader)
GX2ShaderVarType
Definition: enum.h:297
void * vertexProgram
Definition: shaders.h:283
uint32_t GX2CalcGeometryShaderOutputRingBufferSize(uint32_t ringItemSize)
GX2ShaderMode mode
Definition: shaders.h:141
GX2UniformInitialValue * initialValues
Definition: shaders.h:150
uint32_t loopVarCount
Definition: shaders.h:152
GX2ShaderVarType type
Definition: shaders.h:67
GX2FetchShaderType
Definition: enum.h:172
uint32_t GX2CalcGeometryShaderInputRingBufferSize(uint32_t ringItemSize)
uint32_t aluDivisor
Definition: shaders.h:345
void GX2SetVertexUniformReg(uint32_t offset, uint32_t count, uint32_t *data)
uint32_t uniformVarCount
Definition: shaders.h:146
void GX2InitFetchShaderEx(GX2FetchShader *fetchShader, uint8_t *buffer, uint32_t attribCount, GX2AttribStream *attribs, GX2FetchShaderType type, GX2TessellationMode tessMode)
uint32_t streamOutStride[4]
Definition: shaders.h:164
uint32_t GX2CalcFetchShaderSizeEx(uint32_t attribs, GX2FetchShaderType fetchShaderType, GX2TessellationMode tesellationMode)
uint32_t attribCount
Definition: shaders.h:40
void * program
Definition: shaders.h:39
GX2UniformBlock * uniformBlocks
Definition: shaders.h:144
void GX2SetGeometrySampler(GX2Sampler *sampler, uint32_t id)
void GX2SetPixelShader(GX2PixelShader *shader)
uint32_t GX2GetVertexShaderStackEntries(GX2VertexShader *shader)
void GX2SetPixelUniformBlock(uint32_t location, uint32_t size, const void *data)
GX2SamplerVar * samplerVars
Definition: shaders.h:156
struct GX2PixelShader::@7 regs
GX2ShaderMode
Definition: enum.h:289
void GX2SetStreamOutEnable(BOOL enable)
void GX2SetGeometryShaderOutputRingBuffer(void *buffer, uint32_t size)
void GX2SetPixelSampler(GX2Sampler *sampler, uint32_t id)
GX2EndianSwapMode endianSwap
Definition: shaders.h:347
void GX2SetFetchShader(GX2FetchShader *shader)
GX2EndianSwapMode
Definition: enum.h:164
void GX2SetVertexSampler(GX2Sampler *sampler, uint32_t id)
uint32_t divisors[2]
Definition: shaders.h:42
uint32_t initialValueCount
Definition: shaders.h:149
void GX2SetShaderModeEx(GX2ShaderMode mode, uint32_t numVsGpr, uint32_t numVsStackEntries, uint32_t numGsGpr, uint32_t numGsStackEntries, uint32_t numPsGpr, uint32_t numPsStackEntries)
GX2AttribIndexType type
Definition: shaders.h:344
void GX2SetGeometryShader(GX2GeometryShader *shader)
GX2AttribFormat
Definition: enum.h:44
uint32_t offset
Definition: shaders.h:56
int32_t block
Definition: shaders.h:70
uint32_t numDivisors
Definition: shaders.h:41
void GX2SetPixelUniformReg(uint32_t offset, uint32_t count, uint32_t *data)
uint32_t count
Definition: shaders.h:68
struct GX2VertexShader::@6 regs
GX2AttribVar * attribVars
Definition: shaders.h:159
uint32_t mask
Definition: shaders.h:346
GX2SamplerVarType type
Definition: shaders.h:100
uint32_t ringItemsize
Definition: shaders.h:161
uint32_t vertexProgramSize
Definition: shaders.h:282
GX2AttribIndexType
Definition: enum.h:68
uint32_t samplerVarCount
Definition: shaders.h:155
void GX2SetGeometryShaderInputRingBuffer(void *buffer, uint32_t size)
GX2AttribFormat format
Definition: shaders.h:343
GX2UniformVar * uniformVars
Definition: shaders.h:147
uint32_t attribVarCount
Definition: shaders.h:158
GX2FetchShaderType type
Definition: shaders.h:31
uint32_t GX2GetVertexShaderGPRs(GX2VertexShader *shader)
uint32_t GX2GetPixelShaderGPRs(GX2PixelShader *shader)
uint32_t ringItemSize
Definition: shaders.h:301
GX2TessellationMode
Definition: enum.h:419
int32_t BOOL
Definition: wut_types.h:4
uint32_t size
Definition: shaders.h:38
BOOL hasStreamOut
Definition: shaders.h:163
struct GX2FetchShader::@5 regs
uint32_t GX2GetGeometryShaderStackEntries(GX2GeometryShader *shader)
uint32_t location
Definition: shaders.h:101
GX2RBuffer gx2rBuffer
Definition: shaders.h:166
GX2LoopVar * loopVars
Definition: shaders.h:153
const char * name
Definition: shaders.h:55
uint32_t GX2GetPixelShaderStackEntries(GX2PixelShader *shader)
uint32_t uniformBlockCount
Definition: shaders.h:143
void GX2SetGeometryUniformBlock(uint32_t location, uint32_t size, const void *data)
GX2SamplerVarType
Definition: enum.h:275
uint32_t GX2GetGeometryShaderGPRs(GX2GeometryShader *shader)
void GX2SetVertexUniformBlock(uint32_t location, uint32_t size, const void *data)
struct GX2GeometryShader::@8 regs
uint32_t buffer
Definition: shaders.h:341