[Mesa-dev] [PATCH 49/70] mesa: use gl_program for CurrentProgram rather than gl_shader_program
Timothy Arceri
timothy.arceri at collabora.com
Tue Dec 20 10:37:59 UTC 2016
This makes much more sense and should be more performant in some
critical paths such as SSO validation which is called at draw time.
Previously the CurrentProgram array could have contained multiple
pointers to the same struct which was confusing and we would often
need to fish out the information we were really after from the
gl_program anyway.
Also it was error prone to depend on the _LinkedShader array for
programs in current use because a failed linking attempt will lose
the infomation about the current program in use which is still
valid.
---
src/mesa/drivers/common/meta.c | 11 ++--
src/mesa/drivers/common/meta.h | 2 +-
src/mesa/drivers/dri/i965/brw_context.c | 10 ++--
src/mesa/drivers/dri/i965/brw_ff_gs.c | 4 +-
src/mesa/drivers/dri/i965/brw_gs_surface_state.c | 8 +--
src/mesa/drivers/dri/i965/brw_tcs_surface_state.c | 8 +--
src/mesa/drivers/dri/i965/brw_tes_surface_state.c | 8 +--
src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 9 +---
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 10 ++--
src/mesa/drivers/dri/i965/gen6_sol.c | 24 ++++-----
src/mesa/drivers/dri/i965/gen7_l3_state.c | 6 +--
src/mesa/main/api_validate.c | 57 ++++++++------------
src/mesa/main/ff_fragment_shader.cpp | 6 +--
src/mesa/main/mtypes.h | 2 +-
src/mesa/main/pipelineobj.c | 52 +++++++++----------
src/mesa/main/shader_query.cpp | 36 ++++++-------
src/mesa/main/shaderapi.c | 63 ++++++-----------------
src/mesa/main/state.c | 50 +++++++-----------
src/mesa/main/texstate.c | 5 +-
src/mesa/main/transformfeedback.c | 2 +-
src/mesa/main/uniform_query.cpp | 21 +++-----
src/mesa/state_tracker/st_atom_atomicbuf.c | 20 +++----
src/mesa/state_tracker/st_atom_constbuf.c | 43 +++++-----------
src/mesa/state_tracker/st_atom_image.c | 42 +++++----------
src/mesa/state_tracker/st_atom_storagebuf.c | 48 +++++------------
src/mesa/state_tracker/st_cb_compute.c | 4 +-
26 files changed, 197 insertions(+), 354 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 0d5661b..15d28b2 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -594,8 +594,8 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
* that we don't have to worry about the current pipeline state.
*/
for (i = 0; i < MESA_SHADER_STAGES; i++) {
- _mesa_reference_shader_program(ctx, &save->Shader[i],
- ctx->Shader.CurrentProgram[i]);
+ _mesa_reference_program(ctx, &save->Program[i],
+ ctx->Shader.CurrentProgram[i]);
}
_mesa_reference_shader_program(ctx, &save->ActiveShader,
ctx->Shader.ActiveProgram);
@@ -972,16 +972,15 @@ _mesa_meta_end(struct gl_context *ctx)
* program object must be NULL. _mesa_use_shader_program is a no-op
* in that case.
*/
- _mesa_use_shader_program(ctx, targets[i],
- save->Shader[i],
+ _mesa_use_shader_program(ctx, targets[i], save->Program[i],
&ctx->Shader);
/* Do this *before* killing the reference. :)
*/
- if (save->Shader[i] != NULL)
+ if (save->Program[i] != NULL)
any_shader = true;
- _mesa_reference_shader_program(ctx, &save->Shader[i], NULL);
+ _mesa_reference_program(ctx, &save->Program[i], NULL);
}
_mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram,
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index 0a913e9..1b5cf42 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -125,7 +125,7 @@ struct save_state
GLboolean FragmentProgramEnabled;
struct gl_program *FragmentProgram;
GLboolean ATIFragmentShaderEnabled;
- struct gl_shader_program *Shader[MESA_SHADER_STAGES];
+ struct gl_program *Program[MESA_SHADER_STAGES];
struct gl_shader_program *ActiveShader;
struct gl_pipeline_object *Pipeline;
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index e53aefd..63cb12c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -274,14 +274,12 @@ intel_update_state(struct gl_context * ctx, GLuint new_state)
/* Resolve color for each active shader image. */
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- const struct gl_linked_shader *shader =
- ctx->_Shader->CurrentProgram[i] ?
- ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i] : NULL;
+ const struct gl_program *prog = ctx->_Shader->CurrentProgram[i];
- if (unlikely(shader && shader->Program->info.num_images)) {
- for (unsigned j = 0; j < shader->Program->info.num_images; j++) {
+ if (unlikely(prog && prog->info.num_images)) {
+ for (unsigned j = 0; j < prog->info.num_images; j++) {
struct gl_image_unit *u =
- &ctx->ImageUnits[shader->Program->sh.ImageUnits[j]];
+ &ctx->ImageUnits[prog->sh.ImageUnits[j]];
tex_obj = intel_texture_object(u->TexObj);
if (tex_obj && tex_obj->mt) {
diff --git a/src/mesa/drivers/dri/i965/brw_ff_gs.c b/src/mesa/drivers/dri/i965/brw_ff_gs.c
index 4934af3..0316d0f 100644
--- a/src/mesa/drivers/dri/i965/brw_ff_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_ff_gs.c
@@ -195,10 +195,10 @@ brw_ff_gs_populate_key(struct brw_context *brw,
/* On Gen6, GS is used for transform feedback. */
/* BRW_NEW_TRANSFORM_FEEDBACK */
if (_mesa_is_xfb_active_and_unpaused(ctx)) {
- const struct gl_shader_program *shaderprog =
+ const struct gl_program *prog =
ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
const struct gl_transform_feedback_info *linked_xfb_info =
- shaderprog->xfb_program->sh.LinkedTransformFeedback;
+ prog->sh.LinkedTransformFeedback;
int i;
/* Make sure that the VUE slots won't overflow the unsigned chars in
diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
index dc06462..d5a106d 100644
--- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
@@ -72,17 +72,13 @@ brw_upload_gs_ubo_surfaces(struct brw_context *brw)
struct gl_context *ctx = &brw->ctx;
/* _NEW_PROGRAM */
- struct gl_shader_program *prog =
+ struct gl_program *prog =
ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
- if (!prog || !prog->_LinkedShaders[MESA_SHADER_GEOMETRY])
- return;
-
/* BRW_NEW_GS_PROG_DATA */
struct brw_stage_prog_data *prog_data = brw->gs.base.prog_data;
- brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program,
- &brw->gs.base, prog_data);
+ brw_upload_ubo_surfaces(brw, prog, &brw->gs.base, prog_data);
}
const struct brw_tracked_state brw_gs_ubo_surfaces = {
diff --git a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
index 083058b..ede7ae9 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
@@ -72,17 +72,13 @@ brw_upload_tcs_ubo_surfaces(struct brw_context *brw)
struct gl_context *ctx = &brw->ctx;
/* _NEW_PROGRAM */
- struct gl_shader_program *prog =
+ struct gl_program *prog =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
- if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_CTRL])
- return;
-
/* BRW_NEW_TCS_PROG_DATA */
struct brw_stage_prog_data *prog_data = brw->tcs.base.prog_data;
- brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program,
- &brw->tcs.base, prog_data);
+ brw_upload_ubo_surfaces(brw, prog, &brw->tcs.base, prog_data);
}
const struct brw_tracked_state brw_tcs_ubo_surfaces = {
diff --git a/src/mesa/drivers/dri/i965/brw_tes_surface_state.c b/src/mesa/drivers/dri/i965/brw_tes_surface_state.c
index 03b301e..1982955 100644
--- a/src/mesa/drivers/dri/i965/brw_tes_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_tes_surface_state.c
@@ -72,17 +72,13 @@ brw_upload_tes_ubo_surfaces(struct brw_context *brw)
struct gl_context *ctx = &brw->ctx;
/* _NEW_PROGRAM */
- struct gl_shader_program *prog =
+ struct gl_program *prog =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- if (!prog || !prog->_LinkedShaders[MESA_SHADER_TESS_EVAL])
- return;
-
/* BRW_NEW_TES_PROG_DATA */
struct brw_stage_prog_data *prog_data = brw->tes.base.prog_data;
- brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program,
- &brw->tes.base, prog_data);
+ brw_upload_ubo_surfaces(brw, prog, &brw->tes.base, prog_data);
}
const struct brw_tracked_state brw_tes_ubo_surfaces = {
diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
index 5665735..29359d4 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
@@ -140,15 +140,10 @@ brw_upload_vs_ubo_surfaces(struct brw_context *brw)
{
struct gl_context *ctx = &brw->ctx;
/* _NEW_PROGRAM */
- struct gl_shader_program *prog =
- ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
-
- if (!prog || !prog->_LinkedShaders[MESA_SHADER_VERTEX])
- return;
+ struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
/* BRW_NEW_VS_PROG_DATA */
- brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program,
- &brw->vs.base, brw->vs.base.prog_data);
+ brw_upload_ubo_surfaces(brw, prog, &brw->vs.base, brw->vs.base.prog_data);
}
const struct brw_tracked_state brw_vs_ubo_surfaces = {
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 4566696..e3d444c 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1460,15 +1460,11 @@ brw_upload_cs_ubo_surfaces(struct brw_context *brw)
{
struct gl_context *ctx = &brw->ctx;
/* _NEW_PROGRAM */
- struct gl_shader_program *prog =
+ struct gl_program *prog =
ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (!prog || !prog->_LinkedShaders[MESA_SHADER_COMPUTE])
- return;
-
/* BRW_NEW_CS_PROG_DATA */
- brw_upload_ubo_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_COMPUTE]->Program,
- &brw->cs.base, brw->cs.base.prog_data);
+ brw_upload_ubo_surfaces(brw, prog, &brw->cs.base, brw->cs.base.prog_data);
}
const struct brw_tracked_state brw_cs_ubo_surfaces = {
@@ -1843,7 +1839,7 @@ brw_upload_cs_work_groups_surface(struct brw_context *brw)
{
struct gl_context *ctx = &brw->ctx;
/* _NEW_PROGRAM */
- struct gl_shader_program *prog =
+ struct gl_program *prog =
ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
/* BRW_NEW_CS_PROG_DATA */
const struct brw_cs_prog_data *cs_prog_data =
diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c
index a683848..6815e20 100644
--- a/src/mesa/drivers/dri/i965/gen6_sol.c
+++ b/src/mesa/drivers/dri/i965/gen6_sol.c
@@ -100,7 +100,7 @@ brw_gs_upload_binding_table(struct brw_context *brw)
{
uint32_t *bind;
struct gl_context *ctx = &brw->ctx;
- const struct gl_shader_program *shaderprog;
+ const struct gl_program *prog;
bool need_binding_table = false;
/* We have two scenarios here:
@@ -114,11 +114,11 @@ brw_gs_upload_binding_table(struct brw_context *brw)
if (!brw->geometry_program) {
/* BRW_NEW_VERTEX_PROGRAM */
- shaderprog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
- if (shaderprog) {
+ prog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
+ if (prog) {
/* Skip making a binding table if we don't have anything to put in it */
const struct gl_transform_feedback_info *linked_xfb_info =
- shaderprog->xfb_program->sh.LinkedTransformFeedback;
+ prog->sh.LinkedTransformFeedback;
need_binding_table = linked_xfb_info->NumOutputs > 0;
}
if (!need_binding_table) {
@@ -142,12 +142,12 @@ brw_gs_upload_binding_table(struct brw_context *brw)
BRW_MAX_SOL_BINDINGS * sizeof(uint32_t));
} else {
/* BRW_NEW_GEOMETRY_PROGRAM */
- shaderprog = ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
- if (shaderprog) {
+ prog = ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
+ if (prog) {
/* Skip making a binding table if we don't have anything to put in it */
struct brw_stage_prog_data *prog_data = brw->gs.base.prog_data;
const struct gl_transform_feedback_info *linked_xfb_info =
- shaderprog->xfb_program->sh.LinkedTransformFeedback;
+ prog->sh.LinkedTransformFeedback;
need_binding_table = linked_xfb_info->NumOutputs > 0 ||
prog_data->binding_table.size_bytes > 0;
}
@@ -227,7 +227,7 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
struct gl_transform_feedback_object *obj)
{
struct brw_context *brw = brw_context(ctx);
- const struct gl_shader_program *shaderprog;
+ const struct gl_program *prog;
const struct gl_transform_feedback_info *linked_xfb_info;
struct gl_transform_feedback_object *xfb_obj =
ctx->TransformFeedback.CurrentObject;
@@ -236,14 +236,12 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) {
/* BRW_NEW_GEOMETRY_PROGRAM */
- shaderprog =
- ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
+ prog = ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
} else {
/* BRW_NEW_VERTEX_PROGRAM */
- shaderprog =
- ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
+ prog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
}
- linked_xfb_info = shaderprog->xfb_program->sh.LinkedTransformFeedback;
+ linked_xfb_info = prog->sh.LinkedTransformFeedback;
/* Compute the maximum number of vertices that we can write without
* overflowing any of the buffers currently being used for feedback.
diff --git a/src/mesa/drivers/dri/i965/gen7_l3_state.c b/src/mesa/drivers/dri/i965/gen7_l3_state.c
index e746b99..c7b9a3c 100644
--- a/src/mesa/drivers/dri/i965/gen7_l3_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_l3_state.c
@@ -49,12 +49,12 @@ get_pipeline_state_l3_weights(const struct brw_context *brw)
bool needs_dc = false, needs_slm = false;
for (unsigned i = 0; i < ARRAY_SIZE(stage_states); i++) {
- const struct gl_shader_program *prog =
+ const struct gl_program *prog =
brw->ctx._Shader->CurrentProgram[stage_states[i]->stage];
const struct brw_stage_prog_data *prog_data = stage_states[i]->prog_data;
- needs_dc |= (prog && (prog->data->NumAtomicBuffers ||
- prog->data->NumShaderStorageBlocks)) ||
+ needs_dc |= (prog && (prog->sh.data->NumAtomicBuffers ||
+ prog->sh.data->NumShaderStorageBlocks)) ||
(prog_data && (prog_data->total_scratch || prog_data->nr_image_params));
needs_slm |= prog_data && prog_data->total_shared;
}
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 5f051db..78fc7f8 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -191,12 +191,10 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
#ifdef DEBUG
if (ctx->_Shader->Flags & GLSL_LOG) {
- struct gl_shader_program **shProg = ctx->_Shader->CurrentProgram;
- gl_shader_stage i;
+ struct gl_program **prog = ctx->_Shader->CurrentProgram;
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
- if (shProg[i] == NULL || shProg[i]->_LinkedShaders[i] == NULL ||
- shProg[i]->_LinkedShaders[i]->Program->_Used)
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ if (prog[i] == NULL || prog[i]->_Used)
continue;
/* This is the first time this shader is being used.
@@ -208,12 +206,12 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
* program isn't also bound to the fragment shader target we don't
* want to log its fragment data.
*/
- _mesa_append_uniforms_to_file(shProg[i]->_LinkedShaders[i]->Program);
+ _mesa_append_uniforms_to_file(prog[i]);
}
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
- if (shProg[i] != NULL && shProg[i]->_LinkedShaders[i] != NULL)
- shProg[i]->_LinkedShaders[i]->Program->_Used = GL_TRUE;
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ if (prog[i] != NULL)
+ prog[i]->_Used = GL_TRUE;
}
}
#endif
@@ -394,17 +392,15 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) {
const GLenum geom_mode =
ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->
- _LinkedShaders[MESA_SHADER_GEOMETRY]->info.Geom.InputType;
- struct gl_shader_program *tes =
+ info.gs.input_primitive;
+ struct gl_program *tes =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
GLenum mode_before_gs = mode;
if (tes) {
- struct gl_linked_shader *tes_sh =
- tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
- if (tes_sh->info.TessEval.PointMode)
+ if (tes->info.tes.point_mode)
mode_before_gs = GL_POINTS;
- else if (tes_sh->info.TessEval.PrimitiveMode == GL_ISOLINES)
+ else if (tes->info.tes.primitive_mode == GL_ISOLINES)
mode_before_gs = GL_LINES;
else
/* the GL_QUADS mode generates triangles too */
@@ -501,8 +497,7 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
if(ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) {
switch (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->
- _LinkedShaders[MESA_SHADER_GEOMETRY]->
- info.Geom.OutputType) {
+ info.gs.output_primitive) {
case GL_POINTS:
pass = ctx->TransformFeedback.Mode == GL_POINTS;
break;
@@ -517,13 +512,11 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
}
}
else if (ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]) {
- struct gl_shader_program *tes =
+ struct gl_program *tes =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- struct gl_linked_shader *tes_sh =
- tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
- if (tes_sh->info.TessEval.PointMode)
+ if (tes->info.tes.point_mode)
pass = ctx->TransformFeedback.Mode == GL_POINTS;
- else if (tes_sh->info.TessEval.PrimitiveMode == GL_ISOLINES)
+ else if (tes->info.tes.primitive_mode == GL_ISOLINES)
pass = ctx->TransformFeedback.Mode == GL_LINES;
else
pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
@@ -1296,8 +1289,6 @@ _mesa_validate_MultiDrawElementsIndirectCount(struct gl_context *ctx,
static bool
check_valid_to_compute(struct gl_context *ctx, const char *function)
{
- struct gl_shader_program *prog;
-
if (!_mesa_has_compute_shaders(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"unsupported function (%s) called",
@@ -1310,8 +1301,7 @@ check_valid_to_compute(struct gl_context *ctx, const char *function)
* "An INVALID_OPERATION error is generated if there is no active program
* for the compute shader stage."
*/
- prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (prog == NULL || prog->_LinkedShaders[MESA_SHADER_COMPUTE] == NULL) {
+ if (ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE] == NULL) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(no active compute shader)",
function);
@@ -1325,7 +1315,6 @@ GLboolean
_mesa_validate_DispatchCompute(struct gl_context *ctx,
const GLuint *num_groups)
{
- struct gl_shader_program *prog;
int i;
FLUSH_CURRENT(ctx, 0);
@@ -1363,8 +1352,8 @@ _mesa_validate_DispatchCompute(struct gl_context *ctx,
* "An INVALID_OPERATION error is generated by DispatchCompute if the active
* program for the compute shader stage has a variable work group size."
*/
- prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (prog->Comp.LocalSizeVariable) {
+ struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
+ if (prog->info.cs.local_size_variable) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDispatchCompute(variable work group size forbidden)");
return GL_FALSE;
@@ -1378,7 +1367,6 @@ _mesa_validate_DispatchComputeGroupSizeARB(struct gl_context *ctx,
const GLuint *num_groups,
const GLuint *group_size)
{
- struct gl_shader_program *prog;
GLuint total_invocations = 1;
int i;
@@ -1393,8 +1381,8 @@ _mesa_validate_DispatchComputeGroupSizeARB(struct gl_context *ctx,
* DispatchComputeGroupSizeARB if the active program for the compute
* shader stage has a fixed work group size."
*/
- prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (!prog->Comp.LocalSizeVariable) {
+ struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
+ if (!prog->info.cs.local_size_variable) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glDispatchComputeGroupSizeARB(fixed work group size "
"forbidden)");
@@ -1462,7 +1450,6 @@ valid_dispatch_indirect(struct gl_context *ctx,
GLsizei size, const char *name)
{
const uint64_t end = (uint64_t) indirect + size;
- struct gl_shader_program *prog;
if (!check_valid_to_compute(ctx, name))
return GL_FALSE;
@@ -1513,8 +1500,8 @@ valid_dispatch_indirect(struct gl_context *ctx,
* "An INVALID_OPERATION error is generated if the active program for the
* compute shader stage has a variable work group size."
*/
- prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (prog->Comp.LocalSizeVariable) {
+ struct gl_program *prog = ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
+ if (prog->info.cs.local_size_variable) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(variable work group size forbidden)", name);
return GL_FALSE;
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index fd2c71f..d9d5458 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -300,9 +300,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
{
/* _NEW_PROGRAM */
const GLboolean vertexShader =
- (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] &&
- ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->data->LinkStatus &&
- ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]);
+ ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] != NULL;
const GLboolean vertexProgram = ctx->VertexProgram._Enabled;
GLbitfield fp_inputs = 0x0;
@@ -366,7 +364,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
* validation (see additional comments in state.c).
*/
if (vertexShader)
- vprog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
+ vprog = ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
else
vprog = ctx->VertexProgram.Current;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 176e0b8..d503a53 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2900,7 +2900,7 @@ struct gl_pipeline_object
*
* There is a separate program set for each shader stage.
*/
- struct gl_shader_program *CurrentProgram[MESA_SHADER_STAGES];
+ struct gl_program *CurrentProgram[MESA_SHADER_STAGES];
struct gl_program *_CurrentFragmentProgram;
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index bce7a82..f4b3a50 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -61,7 +61,7 @@ _mesa_delete_pipeline_object(struct gl_context *ctx,
_mesa_reference_program(ctx, &obj->_CurrentFragmentProgram, NULL);
for (i = 0; i < MESA_SHADER_STAGES; i++)
- _mesa_reference_shader_program(ctx, &obj->CurrentProgram[i], NULL);
+ _mesa_reference_program(ctx, &obj->CurrentProgram[i], NULL);
_mesa_reference_shader_program(ctx, &obj->ActiveProgram, NULL);
mtx_destroy(&obj->Mutex);
@@ -469,11 +469,9 @@ _mesa_bind_pipeline(struct gl_context *ctx,
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
for (i = 0; i < MESA_SHADER_STAGES; i++) {
- if (ctx->_Shader->CurrentProgram[i]) {
- struct gl_linked_shader *sh =
- ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i];
- if (sh)
- _mesa_shader_program_init_subroutine_defaults(ctx, sh->Program);
+ struct gl_program *prog = ctx->_Shader->CurrentProgram[i];
+ if (prog) {
+ _mesa_shader_program_init_subroutine_defaults(ctx, prog);
}
}
}
@@ -659,35 +657,35 @@ _mesa_GetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params)
return;
case GL_VERTEX_SHADER:
*params = pipe->CurrentProgram[MESA_SHADER_VERTEX]
- ? pipe->CurrentProgram[MESA_SHADER_VERTEX]->Name : 0;
+ ? pipe->CurrentProgram[MESA_SHADER_VERTEX]->Id : 0;
return;
case GL_TESS_EVALUATION_SHADER:
if (!has_tess)
break;
*params = pipe->CurrentProgram[MESA_SHADER_TESS_EVAL]
- ? pipe->CurrentProgram[MESA_SHADER_TESS_EVAL]->Name : 0;
+ ? pipe->CurrentProgram[MESA_SHADER_TESS_EVAL]->Id : 0;
return;
case GL_TESS_CONTROL_SHADER:
if (!has_tess)
break;
*params = pipe->CurrentProgram[MESA_SHADER_TESS_CTRL]
- ? pipe->CurrentProgram[MESA_SHADER_TESS_CTRL]->Name : 0;
+ ? pipe->CurrentProgram[MESA_SHADER_TESS_CTRL]->Id : 0;
return;
case GL_GEOMETRY_SHADER:
if (!has_gs)
break;
*params = pipe->CurrentProgram[MESA_SHADER_GEOMETRY]
- ? pipe->CurrentProgram[MESA_SHADER_GEOMETRY]->Name : 0;
+ ? pipe->CurrentProgram[MESA_SHADER_GEOMETRY]->Id : 0;
return;
case GL_FRAGMENT_SHADER:
*params = pipe->CurrentProgram[MESA_SHADER_FRAGMENT]
- ? pipe->CurrentProgram[MESA_SHADER_FRAGMENT]->Name : 0;
+ ? pipe->CurrentProgram[MESA_SHADER_FRAGMENT]->Id : 0;
return;
case GL_COMPUTE_SHADER:
if (!_mesa_has_compute_shaders(ctx))
break;
*params = pipe->CurrentProgram[MESA_SHADER_COMPUTE]
- ? pipe->CurrentProgram[MESA_SHADER_COMPUTE]->Name : 0;
+ ? pipe->CurrentProgram[MESA_SHADER_COMPUTE]->Id : 0;
return;
default:
break;
@@ -703,23 +701,22 @@ _mesa_GetProgramPipelineiv(GLuint pipeline, GLenum pname, GLint *params)
*/
static bool
program_stages_all_active(struct gl_pipeline_object *pipe,
- const struct gl_shader_program *prog)
+ const struct gl_program *prog)
{
- unsigned i;
bool status = true;
if (!prog)
return true;
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
- if (prog->_LinkedShaders[i]) {
- if (pipe->CurrentProgram[i]) {
- if (prog->Name != pipe->CurrentProgram[i]->Name) {
- status = false;
- }
- } else {
+ unsigned mask = prog->sh.data->linked_stages;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ if (pipe->CurrentProgram[i]) {
+ if (prog->Id != pipe->CurrentProgram[i]->Id) {
status = false;
}
+ } else {
+ status = false;
}
}
@@ -727,7 +724,7 @@ program_stages_all_active(struct gl_pipeline_object *pipe,
pipe->InfoLog = ralloc_asprintf(pipe,
"Program %d is not active for all "
"shaders that was linked",
- prog->Name);
+ prog->Id);
}
return status;
@@ -742,7 +739,7 @@ program_stages_interleaved_illegally(const struct gl_pipeline_object *pipe)
* sequence of unrelated programs or empty stages.
*/
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader_program *cur = pipe->CurrentProgram[i];
+ struct gl_program *cur = pipe->CurrentProgram[i];
/* Empty stages anywhere in the pipe are OK. Also we can be confident
* that if the linked_stages mask matches we are looking at the same
@@ -751,7 +748,7 @@ program_stages_interleaved_illegally(const struct gl_pipeline_object *pipe)
* programs with the sames stages linked are not active for all linked
* stages.
*/
- if (!cur || cur->data->linked_stages == prev_linked_stages)
+ if (!cur || cur->sh.data->linked_stages == prev_linked_stages)
continue;
if (prev_linked_stages) {
@@ -762,7 +759,7 @@ program_stages_interleaved_illegally(const struct gl_pipeline_object *pipe)
return true;
}
- prev_linked_stages = cur->data->linked_stages;
+ prev_linked_stages = cur->sh.data->linked_stages;
}
return false;
@@ -861,11 +858,12 @@ _mesa_validate_program_pipeline(struct gl_context* ctx,
* PROGRAM_SEPARABLE parameter set to FALSE.
*/
for (i = 0; i < MESA_SHADER_STAGES; i++) {
- if (pipe->CurrentProgram[i] && !pipe->CurrentProgram[i]->SeparateShader) {
+ if (pipe->CurrentProgram[i] &&
+ !pipe->CurrentProgram[i]->info.separate_shader) {
pipe->InfoLog = ralloc_asprintf(pipe,
"Program %d was relinked without "
"PROGRAM_SEPARABLE state",
- pipe->CurrentProgram[i]->Name);
+ pipe->CurrentProgram[i]->Id);
return GL_FALSE;
}
}
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 4010737..8635089 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -1373,24 +1373,21 @@ _mesa_get_program_resourceiv(struct gl_shader_program *shProg,
}
static bool
-validate_io(struct gl_shader_program *producer,
- struct gl_shader_program *consumer,
- gl_shader_stage producer_stage,
- gl_shader_stage consumer_stage)
+validate_io(struct gl_program *producer, struct gl_program *consumer)
{
if (producer == consumer)
return true;
const bool nonarray_stage_to_array_stage =
- producer_stage != MESA_SHADER_TESS_CTRL &&
- (consumer_stage == MESA_SHADER_GEOMETRY ||
- consumer_stage == MESA_SHADER_TESS_CTRL ||
- consumer_stage == MESA_SHADER_TESS_EVAL);
+ producer->info.stage != MESA_SHADER_TESS_CTRL &&
+ (consumer->info.stage == MESA_SHADER_GEOMETRY ||
+ consumer->info.stage == MESA_SHADER_TESS_CTRL ||
+ consumer->info.stage == MESA_SHADER_TESS_EVAL);
bool valid = true;
gl_shader_variable const **outputs =
- (gl_shader_variable const **) calloc(producer->data->NumProgramResourceList,
+ (gl_shader_variable const **) calloc(producer->sh.data->NumProgramResourceList,
sizeof(gl_shader_variable *));
if (outputs == NULL)
return false;
@@ -1413,9 +1410,9 @@ validate_io(struct gl_shader_program *producer,
* some output that did not have an input.
*/
unsigned num_outputs = 0;
- for (unsigned i = 0; i < producer->data->NumProgramResourceList; i++) {
+ for (unsigned i = 0; i < producer->sh.data->NumProgramResourceList; i++) {
struct gl_program_resource *res =
- &producer->data->ProgramResourceList[i];
+ &producer->sh.data->ProgramResourceList[i];
if (res->Type != GL_PROGRAM_OUTPUT)
continue;
@@ -1434,9 +1431,9 @@ validate_io(struct gl_shader_program *producer,
}
unsigned match_index = 0;
- for (unsigned i = 0; i < consumer->data->NumProgramResourceList; i++) {
+ for (unsigned i = 0; i < consumer->sh.data->NumProgramResourceList; i++) {
struct gl_program_resource *res =
- &consumer->data->ProgramResourceList[i];
+ &consumer->sh.data->ProgramResourceList[i];
if (res->Type != GL_PROGRAM_INPUT)
continue;
@@ -1592,30 +1589,27 @@ validate_io(struct gl_shader_program *producer,
extern "C" bool
_mesa_validate_pipeline_io(struct gl_pipeline_object *pipeline)
{
- struct gl_shader_program **shProg =
- (struct gl_shader_program **) pipeline->CurrentProgram;
+ struct gl_program **prog = (struct gl_program **) pipeline->CurrentProgram;
/* Find first active stage in pipeline. */
unsigned idx, prev = 0;
for (idx = 0; idx < ARRAY_SIZE(pipeline->CurrentProgram); idx++) {
- if (shProg[idx]) {
+ if (prog[idx]) {
prev = idx;
break;
}
}
for (idx = prev + 1; idx < ARRAY_SIZE(pipeline->CurrentProgram); idx++) {
- if (shProg[idx]) {
+ if (prog[idx]) {
/* Pipeline might include both non-compute and a compute program, do
* not attempt to validate varyings between non-compute and compute
* stage.
*/
- if (shProg[idx]->_LinkedShaders[idx]->Stage == MESA_SHADER_COMPUTE)
+ if (prog[idx]->info.stage == MESA_SHADER_COMPUTE)
break;
- if (!validate_io(shProg[prev], shProg[idx],
- shProg[prev]->_LinkedShaders[prev]->Stage,
- shProg[idx]->_LinkedShaders[idx]->Stage))
+ if (!validate_io(prog[prev], prog[idx]))
return false;
prev = idx;
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index fd6aae3..dde4fcc 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -156,10 +156,8 @@ _mesa_init_shader_state(struct gl_context *ctx)
void
_mesa_free_shader_state(struct gl_context *ctx)
{
- int i;
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
- _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram[i],
- NULL);
+ for (int i = 0; i < MESA_SHADER_STAGES; i++) {
+ _mesa_reference_program(ctx, &ctx->Shader.CurrentProgram[i], NULL);
}
_mesa_reference_program(ctx, &ctx->Shader._CurrentFragmentProgram, NULL);
_mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL);
@@ -1221,23 +1219,18 @@ use_shader_program(struct gl_context *ctx, gl_shader_stage stage,
struct gl_shader_program *shProg,
struct gl_pipeline_object *shTarget)
{
- struct gl_shader_program **target;
+ struct gl_program **target;
+ struct gl_program *new_prog = NULL;
target = &shTarget->CurrentProgram[stage];
- if ((shProg != NULL) && (shProg->_LinkedShaders[stage] == NULL))
- shProg = NULL;
+ if ((shProg != NULL) && (shProg->_LinkedShaders[stage] != NULL))
+ new_prog = shProg->_LinkedShaders[stage]->Program;
- if (shProg) {
- for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
- if (!sh)
- continue;
-
- _mesa_shader_program_init_subroutine_defaults(ctx, sh->Program);
- }
+ if (new_prog) {
+ _mesa_shader_program_init_subroutine_defaults(ctx, new_prog);
}
- if (*target != shProg) {
+ if (*target != new_prog) {
/* Program is current, flush it */
if (shTarget == ctx->_Shader) {
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
@@ -1256,10 +1249,7 @@ use_shader_program(struct gl_context *ctx, gl_shader_stage stage,
/* Empty for now. */
break;
case MESA_SHADER_FRAGMENT:
- if (*target != NULL &&
- ((*target)->_LinkedShaders[MESA_SHADER_FRAGMENT] &&
- (*target)->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program ==
- ctx->_Shader->_CurrentFragmentProgram)) {
+ if (*target == ctx->_Shader->_CurrentFragmentProgram) {
_mesa_reference_program(ctx,
&ctx->_Shader->_CurrentFragmentProgram,
NULL);
@@ -1267,7 +1257,7 @@ use_shader_program(struct gl_context *ctx, gl_shader_stage stage,
break;
}
- _mesa_reference_shader_program(ctx, target, shProg);
+ _mesa_reference_program(ctx, target, new_prog);
return;
}
}
@@ -2605,8 +2595,6 @@ _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
{
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glUniformSubroutinesuiv";
- struct gl_shader_program *shProg;
- struct gl_linked_shader *sh;
gl_shader_stage stage;
int i;
@@ -2621,19 +2609,12 @@ _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
}
stage = _mesa_shader_enum_to_shader_stage(shadertype);
- shProg = ctx->_Shader->CurrentProgram[stage];
- if (!shProg) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name);
- return;
- }
-
- sh = shProg->_LinkedShaders[stage];
- if (!sh) {
+ struct gl_program *p = ctx->_Shader->CurrentProgram[stage];
+ if (!p) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name);
return;
}
- struct gl_program *p = shProg->_LinkedShaders[stage]->Program;
if (count != p->sh.NumSubroutineUniformRemapTable) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s", api_name);
return;
@@ -2690,8 +2671,6 @@ _mesa_GetUniformSubroutineuiv(GLenum shadertype, GLint location,
{
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glGetUniformSubroutineuiv";
- struct gl_shader_program *shProg;
- struct gl_linked_shader *sh;
gl_shader_stage stage;
if (!_mesa_has_ARB_shader_subroutine(ctx)) {
@@ -2705,19 +2684,12 @@ _mesa_GetUniformSubroutineuiv(GLenum shadertype, GLint location,
}
stage = _mesa_shader_enum_to_shader_stage(shadertype);
- shProg = ctx->_Shader->CurrentProgram[stage];
- if (!shProg) {
+ struct gl_program *p = ctx->_Shader->CurrentProgram[stage];
+ if (!p) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name);
return;
}
- sh = shProg->_LinkedShaders[stage];
- if (!sh) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name);
- return;
- }
-
- struct gl_program *p = sh->Program;
if (location >= p->sh.NumSubroutineUniformRemapTable) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s", api_name);
return;
@@ -2883,10 +2855,9 @@ void
_mesa_shader_write_subroutine_indices(struct gl_context *ctx,
gl_shader_stage stage)
{
- if (ctx->_Shader->CurrentProgram[stage] &&
- ctx->_Shader->CurrentProgram[stage]->_LinkedShaders[stage])
+ if (ctx->_Shader->CurrentProgram[stage])
_mesa_shader_write_subroutine_index(ctx,
- ctx->_Shader->CurrentProgram[stage]->_LinkedShaders[stage]->Program);
+ ctx->_Shader->CurrentProgram[stage]);
}
void
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 2a926a1..5cb58a4 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -95,17 +95,17 @@ update_program_enables(struct gl_context *ctx)
static GLbitfield
update_program(struct gl_context *ctx)
{
- const struct gl_shader_program *vsProg =
+ struct gl_program *vsProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
- const struct gl_shader_program *tcsProg =
+ struct gl_program *tcsProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
- const struct gl_shader_program *tesProg =
+ struct gl_program *tesProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- const struct gl_shader_program *gsProg =
+ struct gl_program *gsProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
- struct gl_shader_program *fsProg =
+ struct gl_program *fsProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
- const struct gl_shader_program *csProg =
+ struct gl_program *csProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
const struct gl_program *prevVP = ctx->VertexProgram._Current;
const struct gl_program *prevFP = ctx->FragmentProgram._Current;
@@ -132,13 +132,11 @@ update_program(struct gl_context *ctx)
* come up, or matter.
*/
- if (fsProg && fsProg->data->LinkStatus
- && fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]) {
+ if (fsProg) {
/* Use GLSL fragment shader */
_mesa_reference_program(ctx, &ctx->_Shader->_CurrentFragmentProgram,
- fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
- _mesa_reference_program(ctx, &ctx->FragmentProgram._Current,
- fsProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program);
+ fsProg);
+ _mesa_reference_program(ctx, &ctx->FragmentProgram._Current, fsProg);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
NULL);
}
@@ -179,32 +177,26 @@ update_program(struct gl_context *ctx)
NULL);
}
- if (gsProg && gsProg->data->LinkStatus
- && gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
+ if (gsProg) {
/* Use GLSL geometry shader */
- _mesa_reference_program(ctx, &ctx->GeometryProgram._Current,
- gsProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program);
+ _mesa_reference_program(ctx, &ctx->GeometryProgram._Current, gsProg);
} else {
/* No geometry program */
_mesa_reference_program(ctx, &ctx->GeometryProgram._Current, NULL);
}
- if (tesProg && tesProg->data->LinkStatus
- && tesProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]) {
+ if (tesProg) {
/* Use GLSL tessellation evaluation shader */
- _mesa_reference_program(ctx, &ctx->TessEvalProgram._Current,
- tesProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program);
+ _mesa_reference_program(ctx, &ctx->TessEvalProgram._Current, tesProg);
}
else {
/* No tessellation evaluation program */
_mesa_reference_program(ctx, &ctx->TessEvalProgram._Current, NULL);
}
- if (tcsProg && tcsProg->data->LinkStatus
- && tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]) {
+ if (tcsProg) {
/* Use GLSL tessellation control shader */
- _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current,
- tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program);
+ _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, tcsProg);
}
else {
/* No tessellation control program */
@@ -215,11 +207,9 @@ update_program(struct gl_context *ctx)
* _mesa_get_fixed_func_vertex_program() needs to know active
* fragprog inputs.
*/
- if (vsProg && vsProg->data->LinkStatus
- && vsProg->_LinkedShaders[MESA_SHADER_VERTEX]) {
+ if (vsProg) {
/* Use GLSL vertex shader */
- _mesa_reference_program(ctx, &ctx->VertexProgram._Current,
- vsProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program);
+ _mesa_reference_program(ctx, &ctx->VertexProgram._Current, vsProg);
}
else if (ctx->VertexProgram._Enabled) {
/* Use user-defined vertex program */
@@ -238,11 +228,9 @@ update_program(struct gl_context *ctx)
_mesa_reference_program(ctx, &ctx->VertexProgram._Current, NULL);
}
- if (csProg && csProg->data->LinkStatus
- && csProg->_LinkedShaders[MESA_SHADER_COMPUTE]) {
+ if (csProg) {
/* Use GLSL compute shader */
- _mesa_reference_program(ctx, &ctx->ComputeProgram._Current,
- csProg->_LinkedShaders[MESA_SHADER_COMPUTE]->Program);
+ _mesa_reference_program(ctx, &ctx->ComputeProgram._Current, csProg);
} else {
/* no compute program */
_mesa_reference_program(ctx, &ctx->ComputeProgram._Current, NULL);
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 4676d4a..be73fc3 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -700,9 +700,8 @@ update_texture_state( struct gl_context *ctx )
BITSET_DECLARE(enabled_texture_units, MAX_COMBINED_TEXTURE_IMAGE_UNITS);
for (i = 0; i < MESA_SHADER_STAGES; i++) {
- if (ctx->_Shader->CurrentProgram[i] &&
- ctx->_Shader->CurrentProgram[i]->data->LinkStatus) {
- prog[i] = ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i]->Program;
+ if (ctx->_Shader->CurrentProgram[i]) {
+ prog[i] = ctx->_Shader->CurrentProgram[i];
} else {
if (i == MESA_SHADER_FRAGMENT && ctx->FragmentProgram._Enabled)
prog[i] = ctx->FragmentProgram.Current;
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index 771223a..06fa56a 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -390,7 +390,7 @@ get_xfb_source(struct gl_context *ctx)
int i;
for (i = MESA_SHADER_GEOMETRY; i >= MESA_SHADER_VERTEX; i--) {
if (ctx->_Shader->CurrentProgram[i] != NULL)
- return ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i]->Program;
+ return ctx->_Shader->CurrentProgram[i];
}
return NULL;
}
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 145eff0..03e6775 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -1087,27 +1087,22 @@ _mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *pipeline)
GLbitfield mask;
GLbitfield TexturesUsed[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
- struct gl_linked_shader *shader;
unsigned active_samplers = 0;
- const struct gl_shader_program **shProg =
- (const struct gl_shader_program **) pipeline->CurrentProgram;
+ const struct gl_program **prog =
+ (const struct gl_program **) pipeline->CurrentProgram;
memset(TexturesUsed, 0, sizeof(TexturesUsed));
for (unsigned idx = 0; idx < ARRAY_SIZE(pipeline->CurrentProgram); idx++) {
- if (!shProg[idx])
+ if (!prog[idx])
continue;
- shader = shProg[idx]->_LinkedShaders[idx];
- if (!shader || !shader->Program)
- continue;
-
- mask = shader->Program->SamplersUsed;
+ mask = prog[idx]->SamplersUsed;
while (mask) {
const int s = u_bit_scan(&mask);
- GLuint unit = shader->Program->SamplerUnits[s];
- GLuint tgt = shader->Program->sh.SamplerTargets[s];
+ GLuint unit = prog[idx]->SamplerUnits[s];
+ GLuint tgt = prog[idx]->sh.SamplerTargets[s];
/* FIXME: Samplers are initialized to 0 and Mesa doesn't do a
* great job of eliminating unused uniforms currently so for now
@@ -1121,14 +1116,14 @@ _mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *pipeline)
ralloc_asprintf(pipeline,
"Program %d: "
"Texture unit %d is accessed with 2 different types",
- shProg[idx]->Name, unit);
+ prog[idx]->Id, unit);
return false;
}
TexturesUsed[unit] |= (1 << tgt);
}
- active_samplers += shader->Program->info.num_textures;
+ active_samplers += prog[idx]->info.num_textures;
}
if (active_samplers > MAX_COMBINED_TEXTURE_IMAGE_UNITS) {
diff --git a/src/mesa/state_tracker/st_atom_atomicbuf.c b/src/mesa/state_tracker/st_atom_atomicbuf.c
index 93538b5..11fb84f 100644
--- a/src/mesa/state_tracker/st_atom_atomicbuf.c
+++ b/src/mesa/state_tracker/st_atom_atomicbuf.c
@@ -41,8 +41,7 @@
#include "st_program.h"
static void
-st_bind_atomics(struct st_context *st,
- struct gl_shader_program *prog,
+st_bind_atomics(struct st_context *st, struct gl_program *prog,
enum pipe_shader_type shader_type)
{
unsigned i;
@@ -50,8 +49,9 @@ st_bind_atomics(struct st_context *st,
if (!prog || !st->pipe->set_shader_buffers)
return;
- for (i = 0; i < prog->data->NumAtomicBuffers; i++) {
- struct gl_active_atomic_buffer *atomic = &prog->data->AtomicBuffers[i];
+ for (i = 0; i < prog->sh.data->NumAtomicBuffers; i++) {
+ struct gl_active_atomic_buffer *atomic =
+ &prog->sh.data->AtomicBuffers[i];
struct gl_atomic_buffer_binding *binding =
&st->ctx->AtomicBufferBindings[atomic->Binding];
struct st_buffer_object *st_obj =
@@ -72,7 +72,7 @@ st_bind_atomics(struct st_context *st,
static void
bind_vs_atomics(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
st_bind_atomics(st, prog, PIPE_SHADER_VERTEX);
@@ -85,7 +85,7 @@ const struct st_tracked_state st_bind_vs_atomics = {
static void
bind_fs_atomics(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
st_bind_atomics(st, prog, PIPE_SHADER_FRAGMENT);
@@ -98,7 +98,7 @@ const struct st_tracked_state st_bind_fs_atomics = {
static void
bind_gs_atomics(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
st_bind_atomics(st, prog, PIPE_SHADER_GEOMETRY);
@@ -111,7 +111,7 @@ const struct st_tracked_state st_bind_gs_atomics = {
static void
bind_tcs_atomics(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
st_bind_atomics(st, prog, PIPE_SHADER_TESS_CTRL);
@@ -124,7 +124,7 @@ const struct st_tracked_state st_bind_tcs_atomics = {
static void
bind_tes_atomics(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
st_bind_atomics(st, prog, PIPE_SHADER_TESS_EVAL);
@@ -137,7 +137,7 @@ const struct st_tracked_state st_bind_tes_atomics = {
static void
bind_cs_atomics(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
st_bind_atomics(st, prog, PIPE_SHADER_COMPUTE);
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index ef1a6f2..6ab4ca9 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -278,13 +278,10 @@ static void st_bind_ubos(struct st_context *st, struct gl_program *prog,
static void bind_vs_ubos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
- if (!prog)
- return;
-
- st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program, PIPE_SHADER_VERTEX);
+ st_bind_ubos(st, prog, PIPE_SHADER_VERTEX);
}
const struct st_tracked_state st_bind_vs_ubos = {
@@ -293,13 +290,10 @@ const struct st_tracked_state st_bind_vs_ubos = {
static void bind_fs_ubos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
- if (!prog)
- return;
-
- st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program, PIPE_SHADER_FRAGMENT);
+ st_bind_ubos(st, prog, PIPE_SHADER_FRAGMENT);
}
const struct st_tracked_state st_bind_fs_ubos = {
@@ -308,13 +302,10 @@ const struct st_tracked_state st_bind_fs_ubos = {
static void bind_gs_ubos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
- if (!prog)
- return;
-
- st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program, PIPE_SHADER_GEOMETRY);
+ st_bind_ubos(st, prog, PIPE_SHADER_GEOMETRY);
}
const struct st_tracked_state st_bind_gs_ubos = {
@@ -323,13 +314,10 @@ const struct st_tracked_state st_bind_gs_ubos = {
static void bind_tcs_ubos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
- if (!prog)
- return;
-
- st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program, PIPE_SHADER_TESS_CTRL);
+ st_bind_ubos(st, prog, PIPE_SHADER_TESS_CTRL);
}
const struct st_tracked_state st_bind_tcs_ubos = {
@@ -338,13 +326,10 @@ const struct st_tracked_state st_bind_tcs_ubos = {
static void bind_tes_ubos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- if (!prog)
- return;
-
- st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program, PIPE_SHADER_TESS_EVAL);
+ st_bind_ubos(st, prog, PIPE_SHADER_TESS_EVAL);
}
const struct st_tracked_state st_bind_tes_ubos = {
@@ -353,14 +338,10 @@ const struct st_tracked_state st_bind_tes_ubos = {
static void bind_cs_ubos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (!prog)
- return;
-
- st_bind_ubos(st, prog->_LinkedShaders[MESA_SHADER_COMPUTE]->Program,
- PIPE_SHADER_COMPUTE);
+ st_bind_ubos(st, prog, PIPE_SHADER_COMPUTE);
}
const struct st_tracked_state st_bind_cs_ubos = {
diff --git a/src/mesa/state_tracker/st_atom_image.c b/src/mesa/state_tracker/st_atom_image.c
index 4a6e8c1..5dd2cd6 100644
--- a/src/mesa/state_tracker/st_atom_image.c
+++ b/src/mesa/state_tracker/st_atom_image.c
@@ -129,13 +129,10 @@ st_bind_images(struct st_context *st, struct gl_program *prog,
static void bind_vs_images(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
- if (!prog)
- return;
-
- st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program, PIPE_SHADER_VERTEX);
+ st_bind_images(st, prog, PIPE_SHADER_VERTEX);
}
const struct st_tracked_state st_bind_vs_images = {
@@ -144,13 +141,10 @@ const struct st_tracked_state st_bind_vs_images = {
static void bind_fs_images(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
- if (!prog)
- return;
-
- st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program, PIPE_SHADER_FRAGMENT);
+ st_bind_images(st, prog, PIPE_SHADER_FRAGMENT);
}
const struct st_tracked_state st_bind_fs_images = {
@@ -159,13 +153,10 @@ const struct st_tracked_state st_bind_fs_images = {
static void bind_gs_images(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
- if (!prog)
- return;
-
- st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program, PIPE_SHADER_GEOMETRY);
+ st_bind_images(st, prog, PIPE_SHADER_GEOMETRY);
}
const struct st_tracked_state st_bind_gs_images = {
@@ -174,13 +165,10 @@ const struct st_tracked_state st_bind_gs_images = {
static void bind_tcs_images(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
- if (!prog)
- return;
-
- st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program, PIPE_SHADER_TESS_CTRL);
+ st_bind_images(st, prog, PIPE_SHADER_TESS_CTRL);
}
const struct st_tracked_state st_bind_tcs_images = {
@@ -189,13 +177,10 @@ const struct st_tracked_state st_bind_tcs_images = {
static void bind_tes_images(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- if (!prog)
- return;
-
- st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program, PIPE_SHADER_TESS_EVAL);
+ st_bind_images(st, prog, PIPE_SHADER_TESS_EVAL);
}
const struct st_tracked_state st_bind_tes_images = {
@@ -204,13 +189,10 @@ const struct st_tracked_state st_bind_tes_images = {
static void bind_cs_images(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (!prog)
- return;
-
- st_bind_images(st, prog->_LinkedShaders[MESA_SHADER_COMPUTE]->Program, PIPE_SHADER_COMPUTE);
+ st_bind_images(st, prog, PIPE_SHADER_COMPUTE);
}
const struct st_tracked_state st_bind_cs_images = {
diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c b/src/mesa/state_tracker/st_atom_storagebuf.c
index bf87037..ec89f16 100644
--- a/src/mesa/state_tracker/st_atom_storagebuf.c
+++ b/src/mesa/state_tracker/st_atom_storagebuf.c
@@ -92,14 +92,10 @@ st_bind_ssbos(struct st_context *st, struct gl_program *prog,
static void bind_vs_ssbos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
- if (!prog)
- return;
-
- st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program,
- PIPE_SHADER_VERTEX);
+ st_bind_ssbos(st, prog, PIPE_SHADER_VERTEX);
}
const struct st_tracked_state st_bind_vs_ssbos = {
@@ -108,14 +104,10 @@ const struct st_tracked_state st_bind_vs_ssbos = {
static void bind_fs_ssbos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
- if (!prog)
- return;
-
- st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program,
- PIPE_SHADER_FRAGMENT);
+ st_bind_ssbos(st, prog, PIPE_SHADER_FRAGMENT);
}
const struct st_tracked_state st_bind_fs_ssbos = {
@@ -124,14 +116,10 @@ const struct st_tracked_state st_bind_fs_ssbos = {
static void bind_gs_ssbos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
- if (!prog)
- return;
-
- st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program,
- PIPE_SHADER_GEOMETRY);
+ st_bind_ssbos(st, prog, PIPE_SHADER_GEOMETRY);
}
const struct st_tracked_state st_bind_gs_ssbos = {
@@ -140,14 +128,10 @@ const struct st_tracked_state st_bind_gs_ssbos = {
static void bind_tcs_ssbos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
- if (!prog)
- return;
-
- st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program,
- PIPE_SHADER_TESS_CTRL);
+ st_bind_ssbos(st, prog, PIPE_SHADER_TESS_CTRL);
}
const struct st_tracked_state st_bind_tcs_ssbos = {
@@ -156,14 +140,10 @@ const struct st_tracked_state st_bind_tcs_ssbos = {
static void bind_tes_ssbos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- if (!prog)
- return;
-
- st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program,
- PIPE_SHADER_TESS_EVAL);
+ st_bind_ssbos(st, prog, PIPE_SHADER_TESS_EVAL);
}
const struct st_tracked_state st_bind_tes_ssbos = {
@@ -172,14 +152,10 @@ const struct st_tracked_state st_bind_tes_ssbos = {
static void bind_cs_ssbos(struct st_context *st)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
- if (!prog)
- return;
-
- st_bind_ssbos(st, prog->_LinkedShaders[MESA_SHADER_COMPUTE]->Program,
- PIPE_SHADER_COMPUTE);
+ st_bind_ssbos(st, prog, PIPE_SHADER_COMPUTE);
}
const struct st_tracked_state st_bind_cs_ssbos = {
diff --git a/src/mesa/state_tracker/st_cb_compute.c b/src/mesa/state_tracker/st_cb_compute.c
index ccc5dc2..f91df4b 100644
--- a/src/mesa/state_tracker/st_cb_compute.c
+++ b/src/mesa/state_tracker/st_cb_compute.c
@@ -40,7 +40,7 @@ static void st_dispatch_compute_common(struct gl_context *ctx,
struct pipe_resource *indirect,
GLintptr indirect_offset)
{
- struct gl_shader_program *prog =
+ struct gl_program *prog =
ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
@@ -57,7 +57,7 @@ static void st_dispatch_compute_common(struct gl_context *ctx,
st_validate_state(st, ST_PIPELINE_COMPUTE);
for (unsigned i = 0; i < 3; i++) {
- info.block[i] = group_size ? group_size[i] : prog->Comp.LocalSize[i];
+ info.block[i] = group_size ? group_size[i] : prog->info.cs.local_size[i];
info.grid[i] = num_groups ? num_groups[i] : 0;
}
--
2.9.3
More information about the mesa-dev
mailing list