blob: b93a010600ecd0e1b51bf94961493de194090abf [file] [log] [blame]
David Ghandeharib1536522017-05-24 00:01:15 -07001//
Kaido Kert612c0202020-01-22 10:28:42 -08002// Copyright 2014 The ANGLE Project Authors. All rights reserved.
David Ghandeharib1536522017-05-24 00:01:15 -07003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7#ifndef SAMPLE_UTIL_SHADER_UTILS_H
8#define SAMPLE_UTIL_SHADER_UTILS_H
9
Kaido Kert612c0202020-01-22 10:28:42 -080010#include <functional>
David Ghandeharib1536522017-05-24 00:01:15 -070011#include <string>
12#include <vector>
13
Kaido Kert612c0202020-01-22 10:28:42 -080014#include "util/util_export.h"
15#include "util/util_gl.h"
David Ghandeharib1536522017-05-24 00:01:15 -070016
Kaido Kert612c0202020-01-22 10:28:42 -080017ANGLE_UTIL_EXPORT GLuint CheckLinkStatusAndReturnProgram(GLuint program, bool outputErrorMessages);
18ANGLE_UTIL_EXPORT GLuint CompileShader(GLenum type, const char *source);
19ANGLE_UTIL_EXPORT GLuint CompileShaderFromFile(GLenum type, const std::string &sourcePath);
David Ghandeharib1536522017-05-24 00:01:15 -070020
Kaido Kert612c0202020-01-22 10:28:42 -080021ANGLE_UTIL_EXPORT GLuint
22CompileProgramWithTransformFeedback(const char *vsSource,
23 const char *fsSource,
David Ghandeharib1536522017-05-24 00:01:15 -070024 const std::vector<std::string> &transformFeedbackVaryings,
25 GLenum bufferMode);
David Ghandeharib1536522017-05-24 00:01:15 -070026
Kaido Kert612c0202020-01-22 10:28:42 -080027ANGLE_UTIL_EXPORT GLuint CompileProgram(const char *vsSource, const char *fsSource);
David Ghandeharib1536522017-05-24 00:01:15 -070028
Kaido Kert612c0202020-01-22 10:28:42 -080029ANGLE_UTIL_EXPORT GLuint CompileProgram(const char *vsSource,
30 const char *fsSource,
31 const std::function<void(GLuint)> &preLinkCallback);
32
33ANGLE_UTIL_EXPORT GLuint CompileProgramWithGS(const char *vsSource,
34 const char *gsSource,
35 const char *fsSource);
36ANGLE_UTIL_EXPORT GLuint CompileProgramFromFiles(const std::string &vsPath,
37 const std::string &fsPath);
38ANGLE_UTIL_EXPORT GLuint CompileComputeProgram(const char *csSource,
39 bool outputErrorMessages = true);
40ANGLE_UTIL_EXPORT bool LinkAttachedProgram(GLuint program);
41
42ANGLE_UTIL_EXPORT GLuint LoadBinaryProgramOES(const std::vector<uint8_t> &binary,
43 GLenum binaryFormat);
44ANGLE_UTIL_EXPORT GLuint LoadBinaryProgramES3(const std::vector<uint8_t> &binary,
45 GLenum binaryFormat);
46
47namespace angle
48{
49
50namespace essl1_shaders
51{
52
53ANGLE_UTIL_EXPORT const char *PositionAttrib();
54ANGLE_UTIL_EXPORT const char *ColorUniform();
55ANGLE_UTIL_EXPORT const char *Texture2DUniform();
56
57namespace vs
58{
59
60// A shader that sets gl_Position to zero.
61ANGLE_UTIL_EXPORT const char *Zero();
62
63// A shader that sets gl_Position to attribute a_position.
64ANGLE_UTIL_EXPORT const char *Simple();
65
66// A shader that passes through attribute a_position, setting it to gl_Position and varying
67// v_position.
68ANGLE_UTIL_EXPORT const char *Passthrough();
69
70// A shader that simply passes through attribute a_position, setting it to gl_Position and varying
71// texcoord.
72ANGLE_UTIL_EXPORT const char *Texture2D();
73
74} // namespace vs
75
76namespace fs
77{
78
79// A shader that renders a simple checker pattern of red and green. X axis and y axis separate the
80// different colors. Needs varying v_position.
81ANGLE_UTIL_EXPORT const char *Checkered();
82
83// A shader that fills with color taken from uniform named "color".
84ANGLE_UTIL_EXPORT const char *UniformColor();
85
86// A shader that fills with 100% opaque red.
87ANGLE_UTIL_EXPORT const char *Red();
88
89// A shader that fills with 100% opaque green.
90ANGLE_UTIL_EXPORT const char *Green();
91
92// A shader that fills with 100% opaque blue.
93ANGLE_UTIL_EXPORT const char *Blue();
94
95// A shader that samples the texture
96ANGLE_UTIL_EXPORT const char *Texture2D();
97
98} // namespace fs
99} // namespace essl1_shaders
100
101namespace essl3_shaders
102{
103
104ANGLE_UTIL_EXPORT const char *PositionAttrib();
105
106namespace vs
107{
108
109// A shader that sets gl_Position to zero.
110ANGLE_UTIL_EXPORT const char *Zero();
111
112// A shader that sets gl_Position to attribute a_position.
113ANGLE_UTIL_EXPORT const char *Simple();
114
115// A shader that simply passes through attribute a_position, setting it to gl_Position and varying
116// v_position.
117ANGLE_UTIL_EXPORT const char *Passthrough();
118
119} // namespace vs
120
121namespace fs
122{
123
124// A shader that fills with 100% opaque red.
125ANGLE_UTIL_EXPORT const char *Red();
126
127// A shader that fills with 100% opaque green.
128ANGLE_UTIL_EXPORT const char *Green();
129
130// A shader that fills with 100% opaque blue.
131ANGLE_UTIL_EXPORT const char *Blue();
132
133} // namespace fs
134} // namespace essl3_shaders
135
136namespace essl31_shaders
137{
138
139ANGLE_UTIL_EXPORT const char *PositionAttrib();
140
141namespace vs
142{
143
144// A shader that sets gl_Position to zero.
145ANGLE_UTIL_EXPORT const char *Zero();
146
147// A shader that sets gl_Position to attribute a_position.
148ANGLE_UTIL_EXPORT const char *Simple();
149
150// A shader that simply passes through attribute a_position, setting it to gl_Position and varying
151// v_position.
152ANGLE_UTIL_EXPORT const char *Passthrough();
153
154} // namespace vs
155
156namespace fs
157{
158
159// A shader that fills with 100% opaque red.
160ANGLE_UTIL_EXPORT const char *Red();
161
162} // namespace fs
163} // namespace essl31_shaders
164} // namespace angle
165
166#endif // SAMPLE_UTIL_SHADER_UTILS_H