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