blob: b401f4455f8ad961c7aae10ba2f723ffe8ceb6e6 [file] [log] [blame]
Geoff Lang49be2ad2014-02-28 13:05:51 -05001//
2// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
3// 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
Geoff Lang49be2ad2014-02-28 13:05:51 -050010#include <EGL/egl.h>
11#include <EGL/eglext.h>
Yizhou Jiang7818a852018-09-06 15:02:04 +080012#include <GLES2/gl2.h>
13#include <GLES2/gl2ext.h>
14#include <GLES3/gl3.h>
15#include <GLES3/gl31.h>
16#include <export.h>
Geoff Lang49be2ad2014-02-28 13:05:51 -050017
Olli Etuaho624fbdc2018-10-01 11:54:05 +030018#include <functional>
Geoff Lang49be2ad2014-02-28 13:05:51 -050019#include <string>
Jamie Madillca03b352015-09-02 12:38:13 -040020#include <vector>
Geoff Lang49be2ad2014-02-28 13:05:51 -050021
Luc Ferron94ae6602018-04-23 13:58:59 -040022ANGLE_EXPORT GLuint CheckLinkStatusAndReturnProgram(GLuint program, bool outputErrorMessages);
Yuly Novikove3352f92016-08-12 20:40:14 -040023ANGLE_EXPORT GLuint CompileShader(GLenum type, const std::string &source);
24ANGLE_EXPORT GLuint CompileShaderFromFile(GLenum type, const std::string &sourcePath);
Geoff Lang712e3f42014-03-03 11:14:15 -050025
Yuly Novikove3352f92016-08-12 20:40:14 -040026ANGLE_EXPORT GLuint
27CompileProgramWithTransformFeedback(const std::string &vsSource,
28 const std::string &fsSource,
29 const std::vector<std::string> &transformFeedbackVaryings,
30 GLenum bufferMode);
Olli Etuaho624fbdc2018-10-01 11:54:05 +030031
Yuly Novikove3352f92016-08-12 20:40:14 -040032ANGLE_EXPORT GLuint CompileProgram(const std::string &vsSource, const std::string &fsSource);
jchen107ae70d82018-07-06 13:47:01 +080033
Olli Etuaho624fbdc2018-10-01 11:54:05 +030034ANGLE_EXPORT GLuint CompileProgram(const std::string &vsSource,
35 const std::string &fsSource,
36 const std::function<void(GLuint)> &preLinkCallback);
37
Jiawei Shao4ed05da2018-02-02 14:26:15 +080038ANGLE_EXPORT GLuint CompileProgramWithGS(const std::string &vsSource,
39 const std::string &gsSource,
40 const std::string &fsSource);
Yuly Novikove3352f92016-08-12 20:40:14 -040041ANGLE_EXPORT GLuint CompileProgramFromFiles(const std::string &vsPath, const std::string &fsPath);
42ANGLE_EXPORT GLuint CompileComputeProgram(const std::string &csSource,
43 bool outputErrorMessages = true);
Jamie Madill401345e2017-08-21 10:52:40 -040044ANGLE_EXPORT bool LinkAttachedProgram(GLuint program);
Yuly Novikove3352f92016-08-12 20:40:14 -040045
Jamie Madilla7d12dc2016-12-13 15:08:19 -050046ANGLE_EXPORT GLuint LoadBinaryProgramOES(const std::vector<uint8_t> &binary, GLenum binaryFormat);
47ANGLE_EXPORT GLuint LoadBinaryProgramES3(const std::vector<uint8_t> &binary, GLenum binaryFormat);
48
Olli Etuaho5804dc82018-04-13 14:11:46 +030049namespace angle
50{
51
52namespace essl1_shaders
53{
54
55ANGLE_EXPORT const char *PositionAttrib();
56ANGLE_EXPORT const char *ColorUniform();
57
58namespace vs
59{
60
61// A shader that sets gl_Position to zero.
62ANGLE_EXPORT const char *Zero();
63
64// A shader that sets gl_Position to attribute a_position.
65ANGLE_EXPORT const char *Simple();
66
67// A shader that passes through attribute a_position, setting it to gl_Position and varying
68// v_position.
69ANGLE_EXPORT const char *Passthrough();
70
71} // namespace vs
72
73namespace fs
74{
75
76// A shader that renders a simple checker pattern of red and green. X axis and y axis separate the
77// different colors. Needs varying v_position.
78ANGLE_EXPORT const char *Checkered();
79
80// A shader that fills with color taken from uniform named "color".
81ANGLE_EXPORT const char *UniformColor();
82
83// A shader that fills with 100% opaque red.
84ANGLE_EXPORT const char *Red();
85
Jamie Madillb36a4812018-09-25 10:15:11 -040086// A shader that fills with 100% opaque green.
87ANGLE_EXPORT const char *Green();
88
Olli Etuaho5804dc82018-04-13 14:11:46 +030089// A shader that fills with 100% opaque blue.
90ANGLE_EXPORT const char *Blue();
91
92} // namespace fs
93} // namespace essl1_shaders
94
95namespace essl3_shaders
96{
97
98ANGLE_EXPORT const char *PositionAttrib();
99
100namespace vs
101{
102
103// A shader that sets gl_Position to zero.
104ANGLE_EXPORT const char *Zero();
105
106// A shader that sets gl_Position to attribute a_position.
107ANGLE_EXPORT const char *Simple();
108
Yizhou Jiang7818a852018-09-06 15:02:04 +0800109// A shader that simply passes through attribute a_position, setting it to gl_Position and varying
110// v_position.
111ANGLE_EXPORT const char *Passthrough();
112
Olli Etuaho5804dc82018-04-13 14:11:46 +0300113} // namespace vs
114
115namespace fs
116{
117
118// A shader that fills with 100% opaque red.
119ANGLE_EXPORT const char *Red();
120
121} // namespace fs
122} // namespace essl3_shaders
123
124namespace essl31_shaders
125{
126
127ANGLE_EXPORT const char *PositionAttrib();
128
129namespace vs
130{
131
132// A shader that sets gl_Position to zero.
133ANGLE_EXPORT const char *Zero();
134
135// A shader that sets gl_Position to attribute a_position.
136ANGLE_EXPORT const char *Simple();
137
Olli Etuahodff32a02018-08-28 14:35:50 +0300138// A shader that simply passes through attribute a_position, setting it to gl_Position and varying
139// v_position.
140ANGLE_EXPORT const char *Passthrough();
141
Olli Etuaho5804dc82018-04-13 14:11:46 +0300142} // namespace vs
143
144namespace fs
145{
146
147// A shader that fills with 100% opaque red.
148ANGLE_EXPORT const char *Red();
149
150} // namespace fs
151} // namespace essl31_shaders
152} // namespace angle
153
Yizhou Jiang7818a852018-09-06 15:02:04 +0800154#endif // SAMPLE_UTIL_SHADER_UTILS_H