Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 1 | // |
| 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 Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 10 | #include <export.h> |
Martin Radev | 4c4c8e7 | 2016-08-04 12:25:34 +0300 | [diff] [blame] | 11 | #include <GLES3/gl31.h> |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 12 | #include <GLES3/gl3.h> |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 13 | #include <GLES2/gl2.h> |
| 14 | #include <GLES2/gl2ext.h> |
| 15 | #include <EGL/egl.h> |
| 16 | #include <EGL/eglext.h> |
| 17 | |
| 18 | #include <string> |
Jamie Madill | ca03b35 | 2015-09-02 12:38:13 -0400 | [diff] [blame] | 19 | #include <vector> |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 20 | |
Yuly Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 21 | ANGLE_EXPORT GLuint CompileShader(GLenum type, const std::string &source); |
| 22 | ANGLE_EXPORT GLuint CompileShaderFromFile(GLenum type, const std::string &sourcePath); |
Geoff Lang | 712e3f4 | 2014-03-03 11:14:15 -0500 | [diff] [blame] | 23 | |
Yuly Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 24 | ANGLE_EXPORT GLuint |
| 25 | CompileProgramWithTransformFeedback(const std::string &vsSource, |
| 26 | const std::string &fsSource, |
| 27 | const std::vector<std::string> &transformFeedbackVaryings, |
| 28 | GLenum bufferMode); |
Jiawei Shao | 4ed05da | 2018-02-02 14:26:15 +0800 | [diff] [blame] | 29 | ANGLE_EXPORT GLuint |
| 30 | CompileProgramWithGSAndTransformFeedback(const std::string &vsSource, |
| 31 | const std::string &gsSource, |
| 32 | const std::string &fsSource, |
| 33 | const std::vector<std::string> &transformFeedbackVaryings, |
| 34 | GLenum bufferMode); |
Yuly Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 35 | ANGLE_EXPORT GLuint CompileProgram(const std::string &vsSource, const std::string &fsSource); |
Jiawei Shao | 4ed05da | 2018-02-02 14:26:15 +0800 | [diff] [blame] | 36 | ANGLE_EXPORT GLuint CompileProgramWithGS(const std::string &vsSource, |
| 37 | const std::string &gsSource, |
| 38 | const std::string &fsSource); |
Yuly Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 39 | ANGLE_EXPORT GLuint CompileProgramFromFiles(const std::string &vsPath, const std::string &fsPath); |
| 40 | ANGLE_EXPORT GLuint CompileComputeProgram(const std::string &csSource, |
| 41 | bool outputErrorMessages = true); |
Jamie Madill | 401345e | 2017-08-21 10:52:40 -0400 | [diff] [blame] | 42 | ANGLE_EXPORT bool LinkAttachedProgram(GLuint program); |
Yuly Novikov | e3352f9 | 2016-08-12 20:40:14 -0400 | [diff] [blame] | 43 | |
Jamie Madill | a7d12dc | 2016-12-13 15:08:19 -0500 | [diff] [blame] | 44 | ANGLE_EXPORT GLuint LoadBinaryProgramOES(const std::vector<uint8_t> &binary, GLenum binaryFormat); |
| 45 | ANGLE_EXPORT GLuint LoadBinaryProgramES3(const std::vector<uint8_t> &binary, GLenum binaryFormat); |
| 46 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame^] | 47 | namespace angle |
| 48 | { |
| 49 | |
| 50 | namespace essl1_shaders |
| 51 | { |
| 52 | |
| 53 | ANGLE_EXPORT const char *PositionAttrib(); |
| 54 | ANGLE_EXPORT const char *ColorUniform(); |
| 55 | |
| 56 | namespace vs |
| 57 | { |
| 58 | |
| 59 | // A shader that sets gl_Position to zero. |
| 60 | ANGLE_EXPORT const char *Zero(); |
| 61 | |
| 62 | // A shader that sets gl_Position to attribute a_position. |
| 63 | ANGLE_EXPORT const char *Simple(); |
| 64 | |
| 65 | // A shader that passes through attribute a_position, setting it to gl_Position and varying |
| 66 | // v_position. |
| 67 | ANGLE_EXPORT const char *Passthrough(); |
| 68 | |
| 69 | } // namespace vs |
| 70 | |
| 71 | namespace fs |
| 72 | { |
| 73 | |
| 74 | // A shader that renders a simple checker pattern of red and green. X axis and y axis separate the |
| 75 | // different colors. Needs varying v_position. |
| 76 | ANGLE_EXPORT const char *Checkered(); |
| 77 | |
| 78 | // A shader that fills with color taken from uniform named "color". |
| 79 | ANGLE_EXPORT const char *UniformColor(); |
| 80 | |
| 81 | // A shader that fills with 100% opaque red. |
| 82 | ANGLE_EXPORT const char *Red(); |
| 83 | |
| 84 | // A shader that fills with 100% opaque blue. |
| 85 | ANGLE_EXPORT const char *Blue(); |
| 86 | |
| 87 | } // namespace fs |
| 88 | } // namespace essl1_shaders |
| 89 | |
| 90 | namespace essl3_shaders |
| 91 | { |
| 92 | |
| 93 | ANGLE_EXPORT const char *PositionAttrib(); |
| 94 | |
| 95 | namespace vs |
| 96 | { |
| 97 | |
| 98 | // A shader that sets gl_Position to zero. |
| 99 | ANGLE_EXPORT const char *Zero(); |
| 100 | |
| 101 | // A shader that sets gl_Position to attribute a_position. |
| 102 | ANGLE_EXPORT const char *Simple(); |
| 103 | |
| 104 | } // namespace vs |
| 105 | |
| 106 | namespace fs |
| 107 | { |
| 108 | |
| 109 | // A shader that fills with 100% opaque red. |
| 110 | ANGLE_EXPORT const char *Red(); |
| 111 | |
| 112 | } // namespace fs |
| 113 | } // namespace essl3_shaders |
| 114 | |
| 115 | namespace essl31_shaders |
| 116 | { |
| 117 | |
| 118 | ANGLE_EXPORT const char *PositionAttrib(); |
| 119 | |
| 120 | namespace vs |
| 121 | { |
| 122 | |
| 123 | // A shader that sets gl_Position to zero. |
| 124 | ANGLE_EXPORT const char *Zero(); |
| 125 | |
| 126 | // A shader that sets gl_Position to attribute a_position. |
| 127 | ANGLE_EXPORT const char *Simple(); |
| 128 | |
| 129 | } // namespace vs |
| 130 | |
| 131 | namespace fs |
| 132 | { |
| 133 | |
| 134 | // A shader that fills with 100% opaque red. |
| 135 | ANGLE_EXPORT const char *Red(); |
| 136 | |
| 137 | } // namespace fs |
| 138 | } // namespace essl31_shaders |
| 139 | } // namespace angle |
| 140 | |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 141 | #endif // SAMPLE_UTIL_SHADER_UTILS_H |