diff options
author | marha <marha@users.sourceforge.net> | 2011-03-12 14:57:48 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-03-12 14:57:48 +0000 |
commit | 77ec02adbc8f9657e7749b307d3cc86ccbd163ea (patch) | |
tree | 8b11e4e5002a05a69a7b7dfe5ce79162448f2aa2 /mesalib/src/mesa/program/ir_to_mesa.cpp | |
parent | f81bb3160c5f39d8f7ad329e99865af88f02b96a (diff) | |
download | vcxsrv-77ec02adbc8f9657e7749b307d3cc86ccbd163ea.tar.gz vcxsrv-77ec02adbc8f9657e7749b307d3cc86ccbd163ea.tar.bz2 vcxsrv-77ec02adbc8f9657e7749b307d3cc86ccbd163ea.zip |
libX11 pixman mesa git update 12 Mar 2011
Diffstat (limited to 'mesalib/src/mesa/program/ir_to_mesa.cpp')
-rw-r--r-- | mesalib/src/mesa/program/ir_to_mesa.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index 0255b576c..a7bafb50b 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -2406,6 +2406,11 @@ print_program(struct prog_instruction *mesa_instructions, }
}
+
+/**
+ * Count resources used by the given gpu program (number of texture
+ * samplers, etc).
+ */
static void
count_resources(struct gl_program *prog)
{
@@ -2429,6 +2434,57 @@ count_resources(struct gl_program *prog) _mesa_update_shader_textures_used(prog);
}
+
+/**
+ * Check if the given vertex/fragment/shader program is within the
+ * resource limits of the context (number of texture units, etc).
+ * If any of those checks fail, record a linker error.
+ *
+ * XXX more checks are needed...
+ */
+static void
+check_resources(const struct gl_context *ctx,
+ struct gl_shader_program *shader_program,
+ struct gl_program *prog)
+{
+ switch (prog->Target) {
+ case GL_VERTEX_PROGRAM_ARB:
+ if (_mesa_bitcount(prog->SamplersUsed) >
+ ctx->Const.MaxVertexTextureImageUnits) {
+ fail_link(shader_program, "Too many vertex shader texture samplers");
+ }
+ if (prog->Parameters->NumParameters >
+ ctx->Const.VertexProgram.MaxUniformComponents / 4) {
+ fail_link(shader_program, "Too many vertex shader constants");
+ }
+ break;
+ case MESA_GEOMETRY_PROGRAM:
+ if (_mesa_bitcount(prog->SamplersUsed) >
+ ctx->Const.MaxGeometryTextureImageUnits) {
+ fail_link(shader_program, "Too many geometry shader texture samplers");
+ }
+ if (prog->Parameters->NumParameters >
+ ctx->Const.GeometryProgram.MaxUniformComponents / 4) {
+ fail_link(shader_program, "Too many geometry shader constants");
+ }
+ break;
+ case GL_FRAGMENT_PROGRAM_ARB:
+ if (_mesa_bitcount(prog->SamplersUsed) >
+ ctx->Const.MaxTextureImageUnits) {
+ fail_link(shader_program, "Too many fragment shader texture samplers");
+ }
+ if (prog->Parameters->NumParameters >
+ ctx->Const.FragmentProgram.MaxUniformComponents / 4) {
+ fail_link(shader_program, "Too many fragment shader constants");
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "unexpected program type in check_resources()");
+ }
+}
+
+
+
struct uniform_sort {
struct gl_uniform *u;
int pos;
@@ -3026,6 +3082,8 @@ get_mesa_program(struct gl_context *ctx, do_set_program_inouts(shader->ir, prog);
count_resources(prog);
+ check_resources(ctx, shader_program, prog);
+
_mesa_reference_program(ctx, &shader->Program, prog);
if ((ctx->Shader.Flags & GLSL_NO_OPT) == 0) {
|