blob: e0dc3e5d182de81890a55269fdd2a4be999181aa [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
18#include <string>
Jamie Madillca03b352015-09-02 12:38:13 -040019#include <vector>
Geoff Lang49be2ad2014-02-28 13:05:51 -050020
Luc Ferron94ae6602018-04-23 13:58:59 -040021ANGLE_EXPORT GLuint CheckLinkStatusAndReturnProgram(GLuint program, bool outputErrorMessages);
Yuly Novikove3352f92016-08-12 20:40:14 -040022ANGLE_EXPORT GLuint CompileShader(GLenum type, const std::string &source);
23ANGLE_EXPORT GLuint CompileShaderFromFile(GLenum type, const std::string &sourcePath);
Geoff Lang712e3f42014-03-03 11:14:15 -050024
Yuly Novikove3352f92016-08-12 20:40:14 -040025ANGLE_EXPORT GLuint
26CompileProgramWithTransformFeedback(const std::string &vsSource,
27 const std::string &fsSource,
28 const std::vector<std::string> &transformFeedbackVaryings,
29 GLenum bufferMode);
Jiawei Shao4ed05da2018-02-02 14:26:15 +080030ANGLE_EXPORT GLuint
31CompileProgramWithGSAndTransformFeedback(const std::string &vsSource,
32 const std::string &gsSource,
33 const std::string &fsSource,
34 const std::vector<std::string> &transformFeedbackVaryings,
35 GLenum bufferMode);
Yuly Novikove3352f92016-08-12 20:40:14 -040036ANGLE_EXPORT GLuint CompileProgram(const std::string &vsSource, const std::string &fsSource);
Jiawei Shao4ed05da2018-02-02 14:26:15 +080037ANGLE_EXPORT GLuint CompileProgramWithGS(const std::string &vsSource,
38 const std::string &gsSource,
39 const std::string &fsSource);
Yuly Novikove3352f92016-08-12 20:40:14 -040040ANGLE_EXPORT GLuint CompileProgramFromFiles(const std::string &vsPath, const std::string &fsPath);
41ANGLE_EXPORT GLuint CompileComputeProgram(const std::string &csSource,
42 bool outputErrorMessages = true);
Jamie Madill401345e2017-08-21 10:52:40 -040043ANGLE_EXPORT bool LinkAttachedProgram(GLuint program);
Yuly Novikove3352f92016-08-12 20:40:14 -040044
Jamie Madilla7d12dc2016-12-13 15:08:19 -050045ANGLE_EXPORT GLuint LoadBinaryProgramOES(const std::vector<uint8_t> &binary, GLenum binaryFormat);
46ANGLE_EXPORT GLuint LoadBinaryProgramES3(const std::vector<uint8_t> &binary, GLenum binaryFormat);
47
Olli Etuaho5804dc82018-04-13 14:11:46 +030048namespace angle
49{
50
51namespace essl1_shaders
52{
53
54ANGLE_EXPORT const char *PositionAttrib();
55ANGLE_EXPORT const char *ColorUniform();
56
57namespace vs
58{
59
60// A shader that sets gl_Position to zero.
61ANGLE_EXPORT const char *Zero();
62
63// A shader that sets gl_Position to attribute a_position.
64ANGLE_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_EXPORT const char *Passthrough();
69
70} // namespace vs
71
72namespace fs
73{
74
75// A shader that renders a simple checker pattern of red and green. X axis and y axis separate the
76// different colors. Needs varying v_position.
77ANGLE_EXPORT const char *Checkered();
78
79// A shader that fills with color taken from uniform named "color".
80ANGLE_EXPORT const char *UniformColor();
81
82// A shader that fills with 100% opaque red.
83ANGLE_EXPORT const char *Red();
84
85// A shader that fills with 100% opaque blue.
86ANGLE_EXPORT const char *Blue();
87
88} // namespace fs
89} // namespace essl1_shaders
90
91namespace essl3_shaders
92{
93
94ANGLE_EXPORT const char *PositionAttrib();
95
96namespace vs
97{
98
99// A shader that sets gl_Position to zero.
100ANGLE_EXPORT const char *Zero();
101
102// A shader that sets gl_Position to attribute a_position.
103ANGLE_EXPORT const char *Simple();
104
105} // namespace vs
106
107namespace fs
108{
109
110// A shader that fills with 100% opaque red.
111ANGLE_EXPORT const char *Red();
112
113} // namespace fs
114} // namespace essl3_shaders
115
116namespace essl31_shaders
117{
118
119ANGLE_EXPORT const char *PositionAttrib();
120
121namespace vs
122{
123
124// A shader that sets gl_Position to zero.
125ANGLE_EXPORT const char *Zero();
126
127// A shader that sets gl_Position to attribute a_position.
128ANGLE_EXPORT const char *Simple();
129
130} // namespace vs
131
132namespace fs
133{
134
135// A shader that fills with 100% opaque red.
136ANGLE_EXPORT const char *Red();
137
138} // namespace fs
139} // namespace essl31_shaders
140} // namespace angle
141
Geoff Lang49be2ad2014-02-28 13:05:51 -0500142#endif // SAMPLE_UTIL_SHADER_UTILS_H