Home | History | Annotate | Download | only in main

Lines Matching refs:ctx

98 _mesa_init_shader_state(struct gl_context *ctx)
114 memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options));
116 ctx->Shader.Flags = get_shader_flags();
124 _mesa_free_shader_state(struct gl_context *ctx)
126 _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentVertexProgram, NULL);
127 _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentGeometryProgram,
129 _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentFragmentProgram,
131 _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
133 _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL);
163 * \param ctx Current GL context
168 validate_shader_target(const struct gl_context *ctx, GLenum type)
173 return ctx->Extensions.ARB_fragment_shader;
177 return ctx->Extensions.ARB_vertex_shader;
181 return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_geometry_shader4;
190 is_program(struct gl_context *ctx, GLuint name)
192 struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, name);
198 is_shader(struct gl_context *ctx, GLuint name)
200 struct gl_shader *shader = _mesa_lookup_shader(ctx, name);
209 attach_shader(struct gl_context *ctx, GLuint program, GLuint shader)
215 shProg = _mesa_lookup_shader_program_err(ctx, program, "glAttachShader");
219 sh = _mesa_lookup_shader_err(ctx, shader, "glAttachShader");
233 _mesa_error(ctx, GL_INVALID_OPERATION, "glAttachShader");
244 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glAttachShader");
250 _mesa_reference_shader(ctx, &shProg->Shaders[n], sh);
256 create_shader(struct gl_context *ctx, GLenum type)
261 if (!validate_shader_target(ctx, type)) {
262 _mesa_error(ctx, GL_INVALID_ENUM, "CreateShader(type)");
266 name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1);
267 sh = ctx->Driver.NewShader(ctx, name, type);
268 _mesa_HashInsert(ctx->Shared->ShaderObjects, name, sh);
275 create_shader_program(struct gl_context *ctx)
280 name = _mesa_HashFindFreeKeyBlock(ctx->Shared->ShaderObjects, 1);
282 shProg = ctx->Driver.NewShaderProgram(ctx, name);
284 _mesa_HashInsert(ctx->Shared->ShaderObjects, name, shProg);
297 delete_shader_program(struct gl_context *ctx, GLuint name)
309 shProg = _mesa_lookup_shader_program_err(ctx, name, "glDeleteProgram");
317 _mesa_reference_shader_program(ctx, &shProg, NULL);
323 delete_shader(struct gl_context *ctx, GLuint shader)
327 sh = _mesa_lookup_shader_err(ctx, shader, "glDeleteShader");
335 _mesa_reference_shader(ctx, &sh, NULL);
341 detach_shader(struct gl_context *ctx, GLuint program, GLuint shader)
347 shProg = _mesa_lookup_shader_program_err(ctx, program, "glDetachShader");
359 _mesa_reference_shader(ctx, &shProg->Shaders[i], NULL);
365 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDetachShader");
396 if (is_shader(ctx, shader))
398 else if (is_program(ctx, shader))
402 _mesa_error(ctx, err, "glDetachProgram(shader)");
412 get_attached_shaders(struct gl_context *ctx, GLuint program, GLsizei maxCount,
416 _mesa_lookup_shader_program_err(ctx, program, "glGetAttachedShaders");
432 get_handle(struct gl_context *ctx, GLenum pname)
435 if (ctx->Shader.ActiveProgram)
436 return ctx->Shader.ActiveProgram->Name;
441 _mesa_error(ctx, GL_INVALID_ENUM, "glGetHandleARB");
453 get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *params)
456 = _mesa_lookup_shader_program(ctx, program);
462 (ctx->API == API_OPENGL && ctx->Extensions.EXT_transform_feedback)
463 || ctx->API == API_OPENGL_CORE
464 || _mesa_is_gles3(ctx);
471 _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_geometry_shader4;
477 (ctx->API == API_OPENGL && ctx->Extensions.ARB_uniform_buffer_object)
478 || ctx->API == API_OPENGL_CORE
479 || _mesa_is_gles3(ctx);
482 _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)");
603 _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname=%s)",
612 get_shaderiv(struct gl_context *ctx, GLuint name, GLenum pname, GLint *params)
615 _mesa_lookup_shader_err(ctx, name, "glGetShaderiv");
638 _mesa_error(ctx, GL_INVALID_ENUM, "glGetShaderiv(pname)");
645 get_program_info_log(struct gl_context *ctx, GLuint program, GLsizei bufSize,
649 = _mesa_lookup_shader_program(ctx, program);
651 _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)");
659 get_shader_info_log(struct gl_context *ctx, GLuint shader, GLsizei bufSize,
662 struct gl_shader *sh = _mesa_lookup_shader(ctx, shader);
664 _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)");
675 get_shader_source(struct gl_context *ctx, GLuint shader, GLsizei maxLength,
679 sh = _mesa_lookup_shader_err(ctx, shader, "glGetShaderSource");
692 shader_source(struct gl_context *ctx, GLuint shader, const GLchar *source)
696 sh = _mesa_lookup_shader_err(ctx, shader, "glShaderSource");
716 compile_shader(struct gl_context *ctx, GLuint shaderObj)
721 sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader");
725 options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)];
733 _mesa_glsl_compile_shader(ctx, sh);
736 (ctx->Shader.Flags & GLSL_REPORT_ERRORS)) {
737 _mesa_debug(ctx, "Error compiling shader %u:\n%s\n",
747 link_program(struct gl_context *ctx, GLuint program)
751 ctx->TransformFeedback.CurrentObject;
753 shProg = _mesa_lookup_shader_program_err(ctx, program, "glLinkProgram");
758 && (shProg == ctx->Shader.CurrentVertexProgram
759 || shProg == ctx->Shader.CurrentGeometryProgram
760 || shProg == ctx->Shader.CurrentFragmentProgram)) {
761 _mesa_error(ctx, GL_INVALID_OPERATION,
766 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
768 _mesa_glsl_link_shader(ctx, shProg);
771 (ctx->Shader.Flags & GLSL_REPORT_ERRORS)) {
772 _mesa_debug(ctx, "Error linking program %u:\n%s\n",
837 _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg,
841 _mesa_error(ctx, GL_INVALID_OPERATION,
846 if (ctx->Shader.ActiveProgram != shProg) {
847 _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, shProg);
854 use_shader_program(struct gl_context *ctx, GLenum type,
862 target = &ctx->Shader.CurrentVertexProgram;
871 target = &ctx->Shader.CurrentGeometryProgram;
880 target = &ctx->Shader.CurrentFragmentProgram;
892 FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
911 if (*target == ctx->Shader._CurrentFragmentProgram) {
912 _mesa_reference_shader_program(ctx,
913 &ctx->Shader._CurrentFragmentProgram,
920 _mesa_reference_shader_program(ctx, target, shProg);
931 _mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg)
933 use_shader_program(ctx, GL_VERTEX_SHADER, shProg);
934 use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg);
935 use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg);
936 _mesa_active_program(ctx, shProg, "glUseProgram");
938 if (ctx->Driver.UseProgram)
939 ctx->Driver.UseProgram(ctx, shProg);
987 validate_program(struct gl_context *ctx, GLuint program)
992 shProg = _mesa_lookup_shader_program_err(ctx, program, "glValidateProgram");
1012 GET_CURRENT_CONTEXT(ctx);
1013 attach_shader(ctx, program, shader);
1020 GET_CURRENT_CONTEXT(ctx);
1021 attach_shader(ctx, program, shader);
1028 GET_CURRENT_CONTEXT(ctx);
1030 _mesa_debug(ctx, "glCompileShader %u\n", shaderObj);
1031 compile_shader(ctx, shaderObj);
1038 GET_CURRENT_CONTEXT(ctx);
1040 _mesa_debug(ctx, "glCreateShader %s\n", _mesa_lookup_enum_by_nr(type));
1041 return create_shader(ctx, type);
1048 GET_CURRENT_CONTEXT(ctx);
1049 return create_shader(ctx, type);
1056 GET_CURRENT_CONTEXT(ctx);
1058 _mesa_debug(ctx, "glCreateProgram\n");
1059 return create_shader_program(ctx);
1066 GET_CURRENT_CONTEXT(ctx);
1067 return create_shader_program(ctx);
1075 GET_CURRENT_CONTEXT(ctx);
1076 _mesa_debug(ctx, "glDeleteObjectARB(%u)\n", obj);
1080 GET_CURRENT_CONTEXT(ctx);
1081 FLUSH_VERTICES(ctx, 0);
1082 if (is_program(ctx, obj)) {
1083 delete_shader_program(ctx, obj);
1085 else if (is_shader(ctx, obj)) {
1086 delete_shader(ctx, obj);
1099 GET_CURRENT_CONTEXT(ctx);
1100 FLUSH_VERTICES(ctx, 0);
1101 delete_shader_program(ctx, name);
1110 GET_CURRENT_CONTEXT(ctx);
1111 FLUSH_VERTICES(ctx, 0);
1112 delete_shader(ctx, name);
1120 GET_CURRENT_CONTEXT(ctx);
1121 detach_shader(ctx, program, shader);
1128 GET_CURRENT_CONTEXT(ctx);
1129 detach_shader(ctx, program, shader);
1137 GET_CURRENT_CONTEXT(ctx);
1138 get_attached_shaders(ctx, container, maxCount, count, obj);
1146 GET_CURRENT_CONTEXT(ctx);
1147 get_attached_shaders(ctx, program, maxCount, count, obj);
1155 GET_CURRENT_CONTEXT(ctx);
1156 if (is_program(ctx, object)) {
1157 get_program_info_log(ctx, object, maxLength, length, infoLog);
1159 else if (is_shader(ctx, object)) {
1160 get_shader_info_log(ctx, object, maxLength, length, infoLog);
1163 _mesa_error(ctx, GL_INVALID_OPERATION, "glGetInfoLogARB");
1171 GET_CURRENT_CONTEXT(ctx);
1173 if (is_program(ctx, object)) {
1178 get_programiv(ctx, object, pname, params);
1181 else if (is_shader(ctx, object)) {
1186 get_shaderiv(ctx, object, pname, params);
1190 _mesa_error(ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB");
1208 GET_CURRENT_CONTEXT(ctx);
1209 get_programiv(ctx, program, pname, params);
1216 GET_CURRENT_CONTEXT(ctx);
1217 get_shaderiv(ctx, shader, pname, params);
1225 GET_CURRENT_CONTEXT(ctx);
1226 get_program_info_log(ctx, program, bufSize, length, infoLog);
1234 GET_CURRENT_CONTEXT(ctx);
1235 get_shader_info_log(ctx, shader, bufSize, length, infoLog);
1243 GET_CURRENT_CONTEXT(ctx);
1244 get_shader_source(ctx, shader, maxLength, length, sourceOut);
1251 GET_CURRENT_CONTEXT(ctx);
1252 return get_handle(ctx, pname);
1259 GET_CURRENT_CONTEXT(ctx);
1260 return is_program(ctx, name);
1267 GET_CURRENT_CONTEXT(ctx);
1268 return is_shader(ctx, name);
1275 GET_CURRENT_CONTEXT(ctx);
1276 link_program(ctx, programObj);
1319 GET_CURRENT_CONTEXT(ctx);
1326 _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB");
1336 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
1343 _mesa_error(ctx, GL_INVALID_OPERATION,
1364 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
1397 shader_source(ctx, shaderObj, source);
1400 struct gl_shader *sh = _mesa_lookup_shader(ctx, shaderObj);
1412 GET_CURRENT_CONTEXT(ctx);
1415 ctx->TransformFeedback.CurrentObject;
1417 ASSERT_OUTSIDE_BEGIN_END(ctx);
1420 _mesa_error(ctx, GL_INVALID_OPERATION,
1426 shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram");
1431 _mesa_error(ctx, GL_INVALID_OPERATION,
1437 if (ctx->Shader.Flags & GLSL_USE_PROG) {
1445 _mesa_use_program(ctx, shProg);
1452 GET_CURRENT_CONTEXT(ctx);
1453 validate_program(ctx, program);
1464 GET_CURRENT_CONTEXT(ctx);
1468 limits = &ctx->Const.VertexProgram;
1471 limits = &ctx->Const.FragmentProgram;
1474 _mesa_error(ctx, GL_INVALID_ENUM,
1499 _mesa_error(ctx, GL_INVALID_ENUM,
1521 GET_CURRENT_CONTEXT(ctx);
1527 _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__);
1539 GET_CURRENT_CONTEXT(ctx);
1541 ASSERT_OUTSIDE_BEGIN_END(ctx);
1543 shProg = _mesa_lookup_shader_program_err(ctx, program,
1551 (unsigned) value > ctx->Const.MaxGeometryOutputVertices) {
1552 _mesa_error(ctx, GL_INVALID_VALUE,
1569 _mesa_error(ctx, GL_INVALID_VALUE,
1583 _mesa_error(ctx, GL_INVALID_VALUE,
1590 _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameteriARB(pname=%s)",
1599 _mesa_use_shader_program(struct gl_context *ctx, GLenum type,
1602 use_shader_program(ctx, type, shProg);
1604 if (ctx->Driver.UseProgram)
1605 ctx->Driver.UseProgram(ctx, shProg);
1615 GET_CURRENT_CONTEXT(ctx);
1618 ASSERT_OUTSIDE_BEGIN_END(ctx);
1620 if (!validate_shader_target(ctx, type)) {
1621 _mesa_error(ctx, GL_INVALID_ENUM, "glUseShaderProgramEXT(type)");
1625 if (ctx->TransformFeedback.CurrentObject->Active &&
1626 !ctx->TransformFeedback.CurrentObject->Paused) {
1627 _mesa_error(ctx, GL_INVALID_OPERATION,
1633 shProg = _mesa_lookup_shader_program_err(ctx, program,
1639 _mesa_error(ctx, GL_INVALID_OPERATION,
1645 _mesa_use_shader_program(ctx, type, shProg);
1655 GET_CURRENT_CONTEXT(ctx);
1657 ? _mesa_lookup_shader_program_err(ctx, program, "glActiveProgramEXT")
1660 _mesa_active_program(ctx, shProg, "glActiveProgramEXT");
1671 GET_CURRENT_CONTEXT(ctx);
1672 const GLuint shader = create_shader(ctx, type);
1676 shader_source(ctx, shader, _mesa_strdup(string));
1677 compile_shader(ctx, shader);
1679 program = create_shader_program(ctx);
1685 shProg = _mesa_lookup_shader_program(ctx, program);
1686 sh = _mesa_lookup_shader(ctx, shader);
1688 get_shaderiv(ctx, shader, GL_COMPILE_STATUS, &compiled);
1690 attach_shader(ctx, program, shader);
1691 link_program(ctx, program);
1692 detach_shader(ctx, program, shader);
1706 delete_shader(ctx, shader);
1716 _mesa_init_shader_dispatch(const struct gl_context *ctx,
1721 if (ctx->API != API_OPENGLES2) {
1762 if (ctx->API != API_OPENGLES2) {
1773 if (ctx->API != API_OPENGLES2) {
1776 if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
1785 if (ctx->API != API_OPENGLES2) {