summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2014-01-06 20:06:05 -0800
committerPaul Berry <[email protected]>2014-02-05 09:00:34 -0800
commitc61ec8d8e34e9bf30b3c4c84afa08f0a5b66b932 (patch)
treef660a11f655b3f456e40e0374c7048f105718197 /src/mesa
parent28e526d5580739e8b4098cd08c644b9157fdc94c (diff)
mesa/cs: Add a MESA_SHADER_COMPUTE stage and update switch statements.
This patch adds MESA_SHADER_COMPUTE to the gl_shader_stage enum. Also, where it is trivial to do so, it adds a compute shader case to switch statements that switch based on the type of shader. This avoids "unhandled switch case" compiler warnings. Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/context.c8
-rw-r--r--src/mesa/main/mtypes.h3
-rw-r--r--src/mesa/main/shaderapi.c5
-rw-r--r--src/mesa/main/shaderobj.h2
-rw-r--r--src/mesa/program/prog_print.c3
-rw-r--r--src/mesa/program/program.h4
6 files changed, 24 insertions, 1 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index d0a14493ab5..69835a59eaf 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -498,6 +498,14 @@ init_program_limits(struct gl_context *ctx, gl_shader_stage stage,
prog->MaxInputComponents = 16 * 4; /* old limit not to break tnl and swrast */
prog->MaxOutputComponents = 16 * 4; /* old limit not to break tnl and swrast */
break;
+ case MESA_SHADER_COMPUTE:
+ prog->MaxParameters = 0; /* not meaningful for compute shaders */
+ prog->MaxAttribs = 0; /* not meaningful for compute shaders */
+ prog->MaxAddressRegs = 0; /* not meaningful for compute shaders */
+ prog->MaxUniformComponents = 4 * MAX_UNIFORMS;
+ prog->MaxInputComponents = 0; /* not meaningful for compute shaders */
+ prog->MaxOutputComponents = 0; /* not meaningful for compute shaders */
+ break;
default:
assert(0 && "Bad shader stage in init_program_limits()");
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index f591033231d..b793227f076 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -406,9 +406,10 @@ typedef enum
MESA_SHADER_VERTEX = 0,
MESA_SHADER_GEOMETRY = 1,
MESA_SHADER_FRAGMENT = 2,
+ MESA_SHADER_COMPUTE = 3,
} gl_shader_stage;
-#define MESA_SHADER_STAGES (MESA_SHADER_FRAGMENT + 1)
+#define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
/**
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 61ac0e35ac7..519b2001981 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -188,6 +188,8 @@ _mesa_validate_shader_target(const struct gl_context *ctx, GLenum type)
return ctx == NULL || ctx->Extensions.ARB_vertex_shader;
case GL_GEOMETRY_SHADER_ARB:
return ctx == NULL || _mesa_has_geometry_shaders(ctx);
+ case GL_COMPUTE_SHADER:
+ return ctx == NULL || ctx->Extensions.ARB_compute_shader;
default:
return false;
}
@@ -966,6 +968,9 @@ use_shader_program(struct gl_context *ctx, GLenum type,
case GL_GEOMETRY_SHADER_ARB:
/* Empty for now. */
break;
+ case GL_COMPUTE_SHADER:
+ /* Empty for now. */
+ break;
case GL_FRAGMENT_SHADER:
if (*target == ctx->Shader._CurrentFragmentProgram) {
_mesa_reference_shader_program(ctx,
diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index 517557088b8..fae8be827c5 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -111,6 +111,8 @@ _mesa_shader_enum_to_shader_stage(GLenum v)
return MESA_SHADER_FRAGMENT;
case GL_GEOMETRY_SHADER:
return MESA_SHADER_GEOMETRY;
+ case GL_COMPUTE_SHADER:
+ return MESA_SHADER_COMPUTE;
default:
ASSERT(0 && "bad value in _mesa_shader_enum_to_shader_stage()");
return MESA_SHADER_VERTEX;
diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index 02ba01eca7b..4a5c1c1fb11 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -1021,6 +1021,9 @@ _mesa_write_shader_to_file(const struct gl_shader *shader)
case MESA_SHADER_GEOMETRY:
type = "geom";
break;
+ case MESA_SHADER_COMPUTE:
+ type = "comp";
+ break;
}
_mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type);
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 71b0a4af26d..4351e05331a 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -202,6 +202,8 @@ _mesa_program_enum_to_shader_stage(GLenum v)
return MESA_SHADER_FRAGMENT;
case GL_GEOMETRY_PROGRAM_NV:
return MESA_SHADER_GEOMETRY;
+ case GL_COMPUTE_PROGRAM_NV:
+ return MESA_SHADER_COMPUTE;
default:
ASSERT(0);
return ~0;
@@ -219,6 +221,8 @@ _mesa_shader_stage_to_program(unsigned stage)
return GL_FRAGMENT_PROGRAM_ARB;
case MESA_SHADER_GEOMETRY:
return GL_GEOMETRY_PROGRAM_NV;
+ case MESA_SHADER_COMPUTE:
+ return GL_COMPUTE_PROGRAM_NV;
}
assert(!"Unexpected shader stage in _mesa_shader_stage_to_program");