blob: f93e862d89dd85daef655d90f25aca7d3c3d8b3b [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
Yuly Novikove3352f92016-08-12 20:40:14 -040010#include <export.h>
Martin Radev4c4c8e72016-08-04 12:25:34 +030011#include <GLES3/gl31.h>
Geoff Lang49be2ad2014-02-28 13:05:51 -050012#include <GLES3/gl3.h>
Geoff Lang49be2ad2014-02-28 13:05:51 -050013#include <GLES2/gl2.h>
14#include <GLES2/gl2ext.h>
15#include <EGL/egl.h>
16#include <EGL/eglext.h>
17
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
109} // namespace vs
110
111namespace fs
112{
113
114// A shader that fills with 100% opaque red.
115ANGLE_EXPORT const char *Red();
116
117} // namespace fs
118} // namespace essl3_shaders
119
120namespace essl31_shaders
121{
122
123ANGLE_EXPORT const char *PositionAttrib();
124
125namespace vs
126{
127
128// A shader that sets gl_Position to zero.
129ANGLE_EXPORT const char *Zero();
130
131// A shader that sets gl_Position to attribute a_position.
132ANGLE_EXPORT const char *Simple();
133
Olli Etuahodff32a02018-08-28 14:35:50 +0300134// A shader that simply passes through attribute a_position, setting it to gl_Position and varying
135// v_position.
136ANGLE_EXPORT const char *Passthrough();
137
Olli Etuaho5804dc82018-04-13 14:11:46 +0300138} // namespace vs
139
140namespace fs
141{
142
143// A shader that fills with 100% opaque red.
144ANGLE_EXPORT const char *Red();
145
146} // namespace fs
147} // namespace essl31_shaders
148} // namespace angle
149
Geoff Lang49be2ad2014-02-28 13:05:51 -0500150#endif // SAMPLE_UTIL_SHADER_UTILS_H