summaryrefslogtreecommitdiffstats
path: root/src/glsl/main.cpp
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-09-09 14:07:15 -0500
committerIan Romanick <[email protected]>2013-10-07 09:59:23 -0700
commit3646d65f6a70ddaf8d1e0dafde11cf21db836223 (patch)
tree82b4092e96acf7d4bef19f307928d33efdff1576 /src/glsl/main.cpp
parent257db619c63a0474ea87749ed3e3fd681b3e58ea (diff)
glsl_compiler: Set max GLSL version on the command line
Infer whether or not to use ES based on the GLSL version (100 or 300 are for ES). This replaces the --glsl-es command line option. Set various compiler limits based on the minimums required for the specified GLSL version. Signed-off-by: Ian Romanick <[email protected]> Acked-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/main.cpp')
-rw-r--r--src/glsl/main.cpp185
1 files changed, 173 insertions, 12 deletions
diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index bc158356e9b..58e940a34b0 100644
--- a/src/glsl/main.cpp
+++ b/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", no_argument, &glsl_es, 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)