summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-11-09 23:38:46 +1100
committerTimothy Arceri <[email protected]>2017-01-06 11:21:42 +1100
commitf584f3821426955b94f36c77191edcfe1b1cc7d5 (patch)
tree043484b6571b8ab26fde0f128b98e245d67cec49
parent2784128398e405405f0263d318ebe4121d1baf4c (diff)
st/mesa/glsl: add new is_arb_asm flag in gl_program
Set the flag via the _mesa_init_gl_program() and NewProgram() helpers. In i965 we currently check for the existance of gl_shader_program to decide if this is an ARB assembly style program or not. Adding a flag makes the code clearer and will help removes a dependency on gl_shader_program in the i965 codegen functions. Also this will allow use to skip initialising sampler units for linked shaders, we currently memset it to zero again during linking. Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r--src/compiler/glsl/linker.cpp2
-rw-r--r--src/compiler/glsl/standalone.cpp7
-rw-r--r--src/mesa/drivers/dri/i915/i915_fragprog.c10
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.c9
-rw-r--r--src/mesa/drivers/dri/r200/r200_vertprog.c7
-rw-r--r--src/mesa/main/arbprogram.c2
-rw-r--r--src/mesa/main/dd.h2
-rw-r--r--src/mesa/main/ffvertex_prog.c2
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/shared.c4
-rw-r--r--src/mesa/program/program.c9
-rw-r--r--src/mesa/program/program.h6
-rw-r--r--src/mesa/state_tracker/st_cb_program.c17
13 files changed, 45 insertions, 34 deletions
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 38cbbfa680f..327b7be8006 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -2202,7 +2202,7 @@ link_intrastage_shaders(void *mem_ctx,
struct gl_program *gl_prog =
ctx->Driver.NewProgram(ctx,
_mesa_shader_stage_to_program(shader_list[0]->Stage),
- prog->Name);
+ prog->Name, false);
if (!gl_prog) {
prog->data->LinkStatus = false;
_mesa_delete_linked_shader(ctx, linked);
diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index 69d86c705fc..e93e9afcbfa 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -100,12 +100,13 @@ private:
};
void
-init_gl_program(struct gl_program *prog, GLenum target)
+init_gl_program(struct gl_program *prog, GLenum target, bool is_arb_asm)
{
mtx_init(&prog->Mutex, mtx_plain);
prog->RefCount = 1;
prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
+ prog->is_arb_asm = is_arb_asm;
/* default mapping from samplers to texture units */
for (int i = 0; i < MAX_SAMPLERS; i++)
@@ -113,7 +114,7 @@ init_gl_program(struct gl_program *prog, GLenum target)
}
struct gl_program *
-new_program(struct gl_context *ctx, GLenum target, GLuint id)
+new_program(struct gl_context *ctx, GLenum target, GLuint id, bool is_arb_asm)
{
switch (target) {
case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
@@ -123,7 +124,7 @@ new_program(struct gl_context *ctx, GLenum target, GLuint id)
case GL_FRAGMENT_PROGRAM_ARB:
case GL_COMPUTE_PROGRAM_NV: {
struct gl_program *prog = rzalloc(NULL, struct gl_program);
- init_gl_program(prog, target);
+ init_gl_program(prog, target, is_arb_asm);
return prog;
}
default:
diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c
index c5a8ac5532d..fce649d44e3 100644
--- a/src/mesa/drivers/dri/i915/i915_fragprog.c
+++ b/src/mesa/drivers/dri/i915/i915_fragprog.c
@@ -1144,12 +1144,13 @@ i915BindProgram(struct gl_context * ctx, GLenum target, struct gl_program *prog)
}
static struct gl_program *
-i915NewProgram(struct gl_context * ctx, GLenum target, GLuint id)
+i915NewProgram(struct gl_context * ctx, GLenum target, GLuint id,
+ bool is_arb_asm)
{
switch (target) {
case GL_VERTEX_PROGRAM_ARB: {
struct gl_program *prog = rzalloc(NULL, struct gl_program);
- return _mesa_init_gl_program(prog, target, id);
+ return _mesa_init_gl_program(prog, target, id, is_arb_asm);
}
case GL_FRAGMENT_PROGRAM_ARB:{
@@ -1158,7 +1159,8 @@ i915NewProgram(struct gl_context * ctx, GLenum target, GLuint id)
if (prog) {
i915_init_program(I915_CONTEXT(ctx), prog);
- return _mesa_init_gl_program(&prog->FragProg, target, id);
+ return _mesa_init_gl_program(&prog->FragProg, target, id,
+ is_arb_asm);
}
else
return NULL;
@@ -1167,7 +1169,7 @@ i915NewProgram(struct gl_context * ctx, GLenum target, GLuint id)
default:
/* Just fallback:
*/
- return _mesa_new_program(ctx, target, id);
+ return _mesa_new_program(ctx, target, id, is_arb_asm);
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 80a87211020..93b29749b28 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -136,9 +136,8 @@ get_new_program_id(struct intel_screen *screen)
return id;
}
-static struct gl_program *brwNewProgram( struct gl_context *ctx,
- GLenum target,
- GLuint id )
+static struct gl_program *brwNewProgram(struct gl_context *ctx, GLenum target,
+ GLuint id, bool is_arb_asm)
{
struct brw_context *brw = brw_context(ctx);
@@ -152,7 +151,7 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx,
if (prog) {
prog->id = get_new_program_id(brw->screen);
- return _mesa_init_gl_program(&prog->program, target, id);
+ return _mesa_init_gl_program(&prog->program, target, id, is_arb_asm);
}
else
return NULL;
@@ -171,7 +170,7 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx,
if (prog) {
prog->id = get_new_program_id(brw->screen);
- return _mesa_init_gl_program(&prog->program, target, id);
+ return _mesa_init_gl_program(&prog->program, target, id, is_arb_asm);
}
else
return NULL;
diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c
index ded8e2af244..0a3e98428c6 100644
--- a/src/mesa/drivers/dri/r200/r200_vertprog.c
+++ b/src/mesa/drivers/dri/r200/r200_vertprog.c
@@ -1199,17 +1199,18 @@ r200BindProgram(struct gl_context *ctx, GLenum target, struct gl_program *prog)
}
static struct gl_program *
-r200NewProgram(struct gl_context *ctx, GLenum target, GLuint id)
+r200NewProgram(struct gl_context *ctx, GLenum target, GLuint id,
+ bool is_arb_asm)
{
switch(target){
case GL_VERTEX_PROGRAM_ARB: {
struct r200_vertex_program *vp = rzalloc(NULL,
struct r200_vertex_program);
- return _mesa_init_gl_program(&vp->mesa_program, target, id);
+ return _mesa_init_gl_program(&vp->mesa_program, target, id, is_arb_asm);
}
case GL_FRAGMENT_PROGRAM_ARB: {
struct gl_program *prog = rzalloc(NULL, struct gl_program);
- return _mesa_init_gl_program(prog, target, id);
+ return _mesa_init_gl_program(prog, target, id, is_arb_asm);
}
default:
_mesa_problem(ctx, "Bad target in r200NewProgram");
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c
index 70b40b3c490..2c6031096ac 100644
--- a/src/mesa/main/arbprogram.c
+++ b/src/mesa/main/arbprogram.c
@@ -83,7 +83,7 @@ _mesa_BindProgramARB(GLenum target, GLuint id)
newProg = _mesa_lookup_program(ctx, id);
if (!newProg || newProg == &_mesa_DummyProgram) {
/* allocate a new program now */
- newProg = ctx->Driver.NewProgram(ctx, target, id);
+ newProg = ctx->Driver.NewProgram(ctx, target, id, true);
if (!newProg) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindProgramARB");
return;
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 21e8260fc78..7ebd084ca31 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -474,7 +474,7 @@ struct dd_function_table {
struct gl_program *prog);
/** Allocate a new program */
struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum target,
- GLuint id);
+ GLuint id, bool is_arb_asm);
/** Delete a program */
void (*DeleteProgram)(struct gl_context *ctx, struct gl_program *prog);
/**
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index c917b41e9dc..85f8f24d830 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -1671,7 +1671,7 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
if (0)
printf("Build new TNL program\n");
- prog = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
+ prog = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0, true);
if (!prog)
return NULL;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 0301eb57f8f..40a240c961c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1925,6 +1925,8 @@ struct gl_program
struct nir_shader *nir;
+ bool is_arb_asm; /** Is this an ARB assembly-style program */
+
GLbitfield64 SecondaryOutputsWritten; /**< Subset of OutputsWritten outputs written with non-zero index. */
GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */
GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index 04e54439a84..53448127389 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -70,9 +70,9 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
shared->Programs = _mesa_NewHashTable();
shared->DefaultVertexProgram =
- ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
+ ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0, true);
shared->DefaultFragmentProgram =
- ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+ ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0, true);
shared->ATIShaders = _mesa_NewHashTable();
shared->DefaultFragmentShader = _mesa_new_ati_fragment_shader(ctx, 0);
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index b728d862e54..3edeec81730 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -178,7 +178,8 @@ _mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string)
* Initialize a new gl_program object.
*/
struct gl_program *
-_mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id)
+_mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id,
+ bool is_arb_asm)
{
GLuint i;
@@ -192,6 +193,7 @@ _mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id)
prog->RefCount = 1;
prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
prog->info.stage = _mesa_program_enum_to_shader_stage(target);
+ prog->is_arb_asm = is_arb_asm;
/* default mapping from samplers to texture units */
for (i = 0; i < MAX_SAMPLERS; i++)
@@ -214,7 +216,8 @@ _mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id)
* \return pointer to new program object
*/
struct gl_program *
-_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id)
+_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id,
+ bool is_arb_asm)
{
switch (target) {
case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
@@ -224,7 +227,7 @@ _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id)
case GL_FRAGMENT_PROGRAM_ARB:
case GL_COMPUTE_PROGRAM_NV: {
struct gl_program *prog = rzalloc(NULL, struct gl_program);
- return _mesa_init_gl_program(prog, target, id);
+ return _mesa_init_gl_program(prog, target, id, is_arb_asm);
}
default:
_mesa_problem(ctx, "bad target in _mesa_new_program");
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 18122f75b74..296fa40fbc1 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -64,10 +64,12 @@ extern void
_mesa_set_program_error(struct gl_context *ctx, GLint pos, const char *string);
extern struct gl_program *
-_mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id);
+_mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id,
+ bool is_arb_asm);
extern struct gl_program *
-_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id);
+_mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id,
+ bool is_arb_asm);
extern void
_mesa_delete_program(struct gl_context *ctx, struct gl_program *prog);
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 77b7a263796..b104649b036 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -54,38 +54,39 @@
* fragment program.
*/
static struct gl_program *
-st_new_program(struct gl_context *ctx, GLenum target, GLuint id)
+st_new_program(struct gl_context *ctx, GLenum target, GLuint id,
+ bool is_arb_asm)
{
switch (target) {
case GL_VERTEX_PROGRAM_ARB: {
struct st_vertex_program *prog = rzalloc(NULL,
struct st_vertex_program);
- return _mesa_init_gl_program(&prog->Base, target, id);
+ return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
}
case GL_FRAGMENT_PROGRAM_ARB: {
struct st_fragment_program *prog = rzalloc(NULL,
struct st_fragment_program);
- return _mesa_init_gl_program(&prog->Base, target, id);
+ return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
}
case GL_GEOMETRY_PROGRAM_NV: {
struct st_geometry_program *prog = rzalloc(NULL,
struct st_geometry_program);
- return _mesa_init_gl_program(&prog->Base, target, id);
+ return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
}
case GL_TESS_CONTROL_PROGRAM_NV: {
struct st_tessctrl_program *prog = rzalloc(NULL,
struct st_tessctrl_program);
- return _mesa_init_gl_program(&prog->Base, target, id);
+ return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
}
case GL_TESS_EVALUATION_PROGRAM_NV: {
struct st_tesseval_program *prog = rzalloc(NULL,
struct st_tesseval_program);
- return _mesa_init_gl_program(&prog->Base, target, id);
+ return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
}
case GL_COMPUTE_PROGRAM_NV: {
struct st_compute_program *prog = rzalloc(NULL,
struct st_compute_program);
- return _mesa_init_gl_program(&prog->Base, target, id);
+ return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
}
default:
assert(0);
@@ -290,7 +291,7 @@ static struct gl_program *
st_new_ati_fs(struct gl_context *ctx, struct ati_fragment_shader *curProg)
{
struct gl_program *prog = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
- curProg->Id);
+ curProg->Id, true);
struct st_fragment_program *stfp = (struct st_fragment_program *)prog;
stfp->ati_fs = curProg;
return prog;