aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl/main.cpp')
-rw-r--r--mesalib/src/glsl/main.cpp197
1 files changed, 180 insertions, 17 deletions
diff --git a/mesalib/src/glsl/main.cpp b/mesalib/src/glsl/main.cpp
index 57bec44be..aa188b1f1 100644
--- a/mesalib/src/glsl/main.cpp
+++ b/mesalib/src/glsl/main.cpp
@@ -38,6 +38,8 @@
#include "loop_analysis.h"
#include "standalone_scaffolding.h"
+static int glsl_version = 330;
+
static void
initialize_context(struct gl_context *ctx, gl_api api)
{
@@ -46,16 +48,150 @@ initialize_context(struct gl_context *ctx, gl_api api)
/* The standalone compiler needs to claim support for almost
* everything in order to compile the built-in functions.
*/
- ctx->Const.GLSLVersion = 330;
+ ctx->Const.GLSLVersion = glsl_version;
ctx->Extensions.ARB_ES3_compatibility = true;
- ctx->Const.MaxClipPlanes = 8;
- ctx->Const.MaxDrawBuffers = 2;
-
- /* More than the 1.10 minimum to appease parser tests taken from
- * apps that (hopefully) already checked the number of coords.
- */
- ctx->Const.MaxTextureCoordUnits = 4;
+ switch (ctx->Const.GLSLVersion) {
+ case 100:
+ ctx->Const.MaxClipPlanes = 0;
+ ctx->Const.MaxCombinedTextureImageUnits = 8;
+ ctx->Const.MaxDrawBuffers = 2;
+ ctx->Const.MinProgramTexelOffset = 0;
+ ctx->Const.MaxProgramTexelOffset = 0;
+ ctx->Const.MaxLights = 0;
+ ctx->Const.MaxTextureCoordUnits = 0;
+ ctx->Const.MaxTextureUnits = 8;
+
+ ctx->Const.VertexProgram.MaxAttribs = 8;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 0;
+ ctx->Const.VertexProgram.MaxUniformComponents = 128 * 4;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 32;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits =
+ ctx->Const.MaxCombinedTextureImageUnits;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 16 * 4;
+ ctx->Const.FragmentProgram.MaxInputComponents =
+ ctx->Const.VertexProgram.MaxOutputComponents;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxVarying = ctx->Const.VertexProgram.MaxOutputComponents / 4;
+ break;
+ case 110:
+ case 120:
+ ctx->Const.MaxClipPlanes = 6;
+ ctx->Const.MaxCombinedTextureImageUnits = 2;
+ ctx->Const.MaxDrawBuffers = 1;
+ ctx->Const.MinProgramTexelOffset = 0;
+ ctx->Const.MaxProgramTexelOffset = 0;
+ ctx->Const.MaxLights = 8;
+ ctx->Const.MaxTextureCoordUnits = 2;
+ ctx->Const.MaxTextureUnits = 2;
+
+ ctx->Const.VertexProgram.MaxAttribs = 16;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 0;
+ ctx->Const.VertexProgram.MaxUniformComponents = 512;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 32;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits =
+ ctx->Const.MaxCombinedTextureImageUnits;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 64;
+ ctx->Const.FragmentProgram.MaxInputComponents =
+ ctx->Const.VertexProgram.MaxOutputComponents;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxVarying = ctx->Const.VertexProgram.MaxOutputComponents / 4;
+ break;
+ case 130:
+ case 140:
+ ctx->Const.MaxClipPlanes = 8;
+ ctx->Const.MaxCombinedTextureImageUnits = 16;
+ ctx->Const.MaxDrawBuffers = 8;
+ ctx->Const.MinProgramTexelOffset = -8;
+ ctx->Const.MaxProgramTexelOffset = 7;
+ ctx->Const.MaxLights = 8;
+ ctx->Const.MaxTextureCoordUnits = 8;
+ ctx->Const.MaxTextureUnits = 2;
+
+ ctx->Const.VertexProgram.MaxAttribs = 16;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 16;
+ ctx->Const.VertexProgram.MaxUniformComponents = 1024;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 64;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits = 16;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 1024;
+ ctx->Const.FragmentProgram.MaxInputComponents =
+ ctx->Const.VertexProgram.MaxOutputComponents;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxVarying = ctx->Const.VertexProgram.MaxOutputComponents / 4;
+ break;
+ case 150:
+ case 330:
+ ctx->Const.MaxClipPlanes = 8;
+ ctx->Const.MaxDrawBuffers = 8;
+ ctx->Const.MinProgramTexelOffset = -8;
+ ctx->Const.MaxProgramTexelOffset = 7;
+ ctx->Const.MaxLights = 8;
+ ctx->Const.MaxTextureCoordUnits = 8;
+ ctx->Const.MaxTextureUnits = 2;
+
+ ctx->Const.VertexProgram.MaxAttribs = 16;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 16;
+ ctx->Const.VertexProgram.MaxUniformComponents = 1024;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 64;
+
+ ctx->Const.GeometryProgram.MaxTextureImageUnits = 16;
+ ctx->Const.GeometryProgram.MaxUniformComponents = 1024;
+ ctx->Const.GeometryProgram.MaxInputComponents =
+ ctx->Const.VertexProgram.MaxOutputComponents;
+ ctx->Const.GeometryProgram.MaxOutputComponents = 128;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits = 16;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 1024;
+ ctx->Const.FragmentProgram.MaxInputComponents =
+ ctx->Const.GeometryProgram.MaxOutputComponents;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxCombinedTextureImageUnits =
+ ctx->Const.VertexProgram.MaxTextureImageUnits
+ + ctx->Const.GeometryProgram.MaxTextureImageUnits
+ + ctx->Const.FragmentProgram.MaxTextureImageUnits;
+
+ ctx->Const.MaxGeometryOutputVertices = 256;
+ ctx->Const.MaxGeometryTotalOutputComponents = 1024;
+
+// ctx->Const.MaxGeometryVaryingComponents = 64;
+
+ ctx->Const.MaxVarying = 60 / 4;
+ break;
+ case 300:
+ ctx->Const.MaxClipPlanes = 8;
+ ctx->Const.MaxCombinedTextureImageUnits = 32;
+ ctx->Const.MaxDrawBuffers = 4;
+ ctx->Const.MinProgramTexelOffset = -8;
+ ctx->Const.MaxProgramTexelOffset = 7;
+ ctx->Const.MaxLights = 0;
+ ctx->Const.MaxTextureCoordUnits = 0;
+ ctx->Const.MaxTextureUnits = 0;
+
+ ctx->Const.VertexProgram.MaxAttribs = 16;
+ ctx->Const.VertexProgram.MaxTextureImageUnits = 16;
+ ctx->Const.VertexProgram.MaxUniformComponents = 1024;
+ ctx->Const.VertexProgram.MaxInputComponents = 0; /* not used */
+ ctx->Const.VertexProgram.MaxOutputComponents = 16 * 4;
+
+ ctx->Const.FragmentProgram.MaxTextureImageUnits = 16;
+ ctx->Const.FragmentProgram.MaxUniformComponents = 224;
+ ctx->Const.FragmentProgram.MaxInputComponents = 15 * 4;
+ ctx->Const.FragmentProgram.MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxVarying = ctx->Const.FragmentProgram.MaxInputComponents / 4;
+ break;
+ }
ctx->Driver.NewShader = _mesa_new_shader;
}
@@ -103,18 +239,17 @@ load_text_file(void *ctx, const char *file_name)
return text;
}
-int glsl_es = 0;
int dump_ast = 0;
int dump_hir = 0;
int dump_lir = 0;
int do_link = 0;
const struct option compiler_opts[] = {
- { "glsl-es", 0, &glsl_es, 1 },
- { "dump-ast", 0, &dump_ast, 1 },
- { "dump-hir", 0, &dump_hir, 1 },
- { "dump-lir", 0, &dump_lir, 1 },
- { "link", 0, &do_link, 1 },
+ { "dump-ast", no_argument, &dump_ast, 1 },
+ { "dump-hir", no_argument, &dump_hir, 1 },
+ { "dump-lir", no_argument, &dump_lir, 1 },
+ { "link", no_argument, &do_link, 1 },
+ { "version", required_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
@@ -159,11 +294,37 @@ main(int argc, char **argv)
int status = EXIT_SUCCESS;
struct gl_context local_ctx;
struct gl_context *ctx = &local_ctx;
+ bool glsl_es = false;
int c;
int idx = 0;
- while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1)
- /* empty */ ;
+ while ((c = getopt_long(argc, argv, "", compiler_opts, &idx)) != -1) {
+ switch (c) {
+ case 'v':
+ glsl_version = strtol(optarg, NULL, 10);
+ switch (glsl_version) {
+ case 100:
+ case 300:
+ glsl_es = true;
+ break;
+ case 110:
+ case 120:
+ case 130:
+ case 140:
+ case 150:
+ case 330:
+ glsl_es = false;
+ break;
+ default:
+ fprintf(stderr, "Unrecognized GLSL version `%s'\n", optarg);
+ usage_fail(argv[0]);
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
if (argc <= optind)
@@ -210,8 +371,10 @@ main(int argc, char **argv)
compile_shader(ctx, shader);
- if (!shader->CompileStatus) {
+ if (strlen(shader->InfoLog) > 0)
printf("Info log for %s:\n%s\n", argv[optind], shader->InfoLog);
+
+ if (!shader->CompileStatus) {
status = EXIT_FAILURE;
break;
}