Mesa (master): mesa: use _mesa_validate_shader_target() more frequently.
Paul Berry
stereotype441 at kemper.freedesktop.org
Wed Jan 22 04:58:56 UTC 2014
Module: Mesa
Branch: master
Commit: 4a91675b262c8150c1542991e1018e924c72f337
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a91675b262c8150c1542991e1018e924c72f337
Author: Paul Berry <stereotype441 at gmail.com>
Date: Tue Jan 7 15:19:07 2014 -0800
mesa: use _mesa_validate_shader_target() more frequently.
This patch replaces code in _mesa_new_shader() and delete_shader_cb()
that checks the type of a shader with calls to
_mesa_validate_shader_target(). This has two advantages: it allows
for a more thorough check (since _mesa_validate_shader_target()
doesn't permit shader targets that aren't supported by the back-end),
and it reduces the amount of code that will need to be modified when
adding new shader stages.
Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>
Reviewed-by: Brian Paul <brianp at vmware.com>
---
src/mesa/main/shaderobj.c | 4 ++--
src/mesa/main/shared.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index dc81bbc..4f4bb69 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -34,6 +34,7 @@
#include "main/context.h"
#include "main/hash.h"
#include "main/mtypes.h"
+#include "main/shaderapi.h"
#include "main/shaderobj.h"
#include "main/uniforms.h"
#include "program/program.h"
@@ -105,8 +106,7 @@ struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
{
struct gl_shader *shader;
- assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER ||
- type == GL_GEOMETRY_SHADER_ARB);
+ assert(_mesa_validate_shader_target(ctx, type));
shader = rzalloc(NULL, struct gl_shader);
if (shader) {
shader->Type = type;
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index 2f73cf3..c11c7f9 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -38,6 +38,7 @@
#include "dlist.h"
#include "samplerobj.h"
#include "set.h"
+#include "shaderapi.h"
#include "shaderobj.h"
#include "syncobj.h"
@@ -218,8 +219,7 @@ delete_shader_cb(GLuint id, void *data, void *userData)
{
struct gl_context *ctx = (struct gl_context *) userData;
struct gl_shader *sh = (struct gl_shader *) data;
- if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER ||
- sh->Type == GL_GEOMETRY_SHADER) {
+ if (_mesa_validate_shader_target(ctx, sh->Type)) {
ctx->Driver.DeleteShader(ctx, sh);
}
else {
More information about the mesa-commit
mailing list