summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-07-20 11:24:10 +0200
committerSamuel Pitoiset <[email protected]>2017-08-02 12:54:31 +0200
commit29f84556ca5fef7b752edf1eaa161a7d35f3fcf6 (patch)
treeae365667ea9aadcaf14338ae08e865829b3146d0
parentbece5a7dddb149aaf09785332d0e7760ef166709 (diff)
mesa: add shader_source() helper
Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
-rw-r--r--src/mesa/main/shaderapi.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index ae5647b4c0d..941419b6f17 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1814,23 +1814,26 @@ read_shader(const gl_shader_stage stage, const char *source)
* Basically, concatenate the source code strings into one long string
* and pass it to _mesa_shader_source().
*/
-void GLAPIENTRY
-_mesa_ShaderSource(GLuint shaderObj, GLsizei count,
- const GLchar * const * string, const GLint * length)
+static ALWAYS_INLINE void
+shader_source(struct gl_context *ctx, GLuint shaderObj, GLsizei count,
+ const GLchar *const *string, const GLint *length, bool no_error)
{
- GET_CURRENT_CONTEXT(ctx);
GLint *offsets;
GLsizei i, totalLength;
GLcharARB *source;
struct gl_shader *sh;
- sh = _mesa_lookup_shader_err(ctx, shaderObj, "glShaderSourceARB");
- if (!sh)
- return;
+ if (!no_error) {
+ sh = _mesa_lookup_shader_err(ctx, shaderObj, "glShaderSourceARB");
+ if (!sh)
+ return;
- if (string == NULL) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB");
- return;
+ if (string == NULL) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB");
+ return;
+ }
+ } else {
+ sh = _mesa_lookup_shader(ctx, shaderObj);
}
/*
@@ -1844,7 +1847,7 @@ _mesa_ShaderSource(GLuint shaderObj, GLsizei count,
}
for (i = 0; i < count; i++) {
- if (string[i] == NULL) {
+ if (!no_error && string[i] == NULL) {
free((GLvoid *) offsets);
_mesa_error(ctx, GL_INVALID_OPERATION,
"glShaderSourceARB(null string)");
@@ -1900,6 +1903,15 @@ _mesa_ShaderSource(GLuint shaderObj, GLsizei count,
}
+void GLAPIENTRY
+_mesa_ShaderSource(GLuint shaderObj, GLsizei count,
+ const GLchar *const *string, const GLint *length)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ shader_source(ctx, shaderObj, count, string, length, false);
+}
+
+
static ALWAYS_INLINE void
use_program(GLuint program, bool no_error)
{