libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
FetchShader.h
1/****************************************************************************
2 * Platform Abstraction Layer (WUT driver)
3 * Daryl Borth 2026
4 * FetchShader.h
5 ***************************************************************************/
6#ifndef WUT_FETCH_SHADER_H_
7#define WUT_FETCH_SHADER_H_
8
9#include <malloc.h>
10#include "Shader.h"
11
16class FetchShader : public Shader
17{
18 public:
24 FetchShader(GX2AttribStream * attributes, uint32_t attrCount,
25 GX2FetchShaderType type = GX2_FETCH_SHADER_TESSELLATION_NONE,
26 GX2TessellationMode tess = GX2_TESSELLATION_MODE_DISCRETE)
27 : fetchShader(nullptr), fetchShaderProgram(nullptr)
28 {
29 uint32_t shaderSize = GX2CalcFetchShaderSizeEx(attrCount, type, tess);
30 fetchShaderProgram = memalign(GX2_SHADER_PROGRAM_ALIGNMENT, shaderSize);
32 {
33 fetchShader = new GX2FetchShader;
34 GX2InitFetchShaderEx(fetchShader, static_cast<uint8_t *>(fetchShaderProgram), attrCount, attributes, type, tess);
35 GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, fetchShaderProgram, shaderSize);
36 }
37 }
38
39 virtual ~FetchShader()
40 {
43 if(fetchShader)
44 delete fetchShader;
45 }
46
48 void setShader() const
49 {
50 GX2SetFetchShader(fetchShader);
51 }
52
53 protected:
54 GX2FetchShader * fetchShader;
56};
57
58#endif // WUT_FETCH_SHADER_H_
Owns the GX2 fetch shader program that binds vertex attribute streams to a vertex shader.
Definition FetchShader.h:17
GX2FetchShader * fetchShader
The GX2 fetch shader object (nullptr if allocation failed)
Definition FetchShader.h:54
void setShader() const
Binds this fetch shader for subsequent draws.
Definition FetchShader.h:48
void * fetchShaderProgram
Aligned program memory the fetch shader executes from.
Definition FetchShader.h:55
FetchShader(GX2AttribStream *attributes, uint32_t attrCount, GX2FetchShaderType type=GX2_FETCH_SHADER_TESSELLATION_NONE, GX2TessellationMode tess=GX2_TESSELLATION_MODE_DISCRETE)
Builds a fetch shader for the given vertex attribute streams.
Definition FetchShader.h:24