summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-11-04 20:02:21 +1100
committerTimothy Arceri <[email protected]>2017-01-06 11:21:40 +1100
commita1da57c19c27505b9eab4792355f2f1b5c774a0a (patch)
treeacb5353c05fee5e416c4b2bdd993975818af7687 /src/mesa/drivers/dri
parent3d2485f011c4f1c7de35871ca359a84415bfcc06 (diff)
st/mesa/glsl/i965: move ImageUnits and ImageAccess fields to gl_program
Having it here rather than in gl_linked_shader allows us to simplify the code. Also it is error prone to depend on the gl_linked_shader for programs in current use because a failed linking attempt will free infomation about the current program. In i965 we could be trying to recompile a shader variant but may have lost some required fields. We drop the memset on ImageUnits because gl_program is already created using rzalloc(). Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs_surface_state.c9
-rw-r--r--src/mesa/drivers/dri/i965/brw_tcs_surface_state.c9
-rw-r--r--src/mesa/drivers/dri/i965/brw_tes_surface_state.c9
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_surface_state.c9
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c24
7 files changed, 23 insertions, 41 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 032b5ec16aa..0b9d2a05bf6 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -280,7 +280,8 @@ intel_update_state(struct gl_context * ctx, GLuint new_state)
if (unlikely(shader && shader->Program->info.num_images)) {
for (unsigned j = 0; j < shader->Program->info.num_images; j++) {
- struct gl_image_unit *u = &ctx->ImageUnits[shader->ImageUnits[j]];
+ struct gl_image_unit *u =
+ &ctx->ImageUnits[shader->Program->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_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 113974badc8..628840e7cf3 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1465,7 +1465,6 @@ void brw_upload_abo_surfaces(struct brw_context *brw,
struct brw_stage_state *stage_state,
struct brw_stage_prog_data *prog_data);
void brw_upload_image_surfaces(struct brw_context *brw,
- struct gl_linked_shader *shader,
const struct gl_program *prog,
struct brw_stage_state *stage_state,
struct brw_stage_prog_data *prog_data);
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 cf56acfd99a..e2ef222b08c 100644
--- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
@@ -122,16 +122,13 @@ const struct brw_tracked_state brw_gs_abo_surfaces = {
static void
brw_upload_gs_image_surfaces(struct brw_context *brw)
{
- struct gl_context *ctx = &brw->ctx;
/* BRW_NEW_GEOMETRY_PROGRAM */
- struct gl_shader_program *prog =
- ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
const struct gl_program *gp = brw->geometry_program;
- if (gp && prog) {
+ if (gp) {
/* BRW_NEW_GS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */
- brw_upload_image_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_GEOMETRY],
- gp, &brw->gs.base, brw->gs.base.prog_data);
+ brw_upload_image_surfaces(brw, gp, &brw->gs.base,
+ brw->gs.base.prog_data);
}
}
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 b2d075fe6bf..16f0bd2f96e 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c
@@ -123,16 +123,13 @@ const struct brw_tracked_state brw_tcs_abo_surfaces = {
static void
brw_upload_tcs_image_surfaces(struct brw_context *brw)
{
- struct gl_context *ctx = &brw->ctx;
/* BRW_NEW_TESS_PROGRAMS */
- struct gl_shader_program *prog =
- ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
const struct gl_program *tcp = brw->tess_ctrl_program;
- if (tcp && prog) {
+ if (tcp) {
/* BRW_NEW_TCS_PROG_DATA, BRW_NEW_IMAGE_UNITS */
- brw_upload_image_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_CTRL],
- tcp, &brw->tcs.base, brw->tcs.base.prog_data);
+ brw_upload_image_surfaces(brw, tcp, &brw->tcs.base,
+ brw->tcs.base.prog_data);
}
}
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 a3516834ce4..f74d86961e2 100644
--- a/src/mesa/drivers/dri/i965/brw_tes_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_tes_surface_state.c
@@ -123,16 +123,13 @@ const struct brw_tracked_state brw_tes_abo_surfaces = {
static void
brw_upload_tes_image_surfaces(struct brw_context *brw)
{
- struct gl_context *ctx = &brw->ctx;
/* BRW_NEW_TESS_PROGRAMS */
- struct gl_shader_program *prog =
- ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
const struct gl_program *tep = brw->tess_eval_program;
- if (tep && prog) {
+ if (tep) {
/* BRW_NEW_TES_PROG_DATA, BRW_NEW_IMAGE_UNITS */
- brw_upload_image_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_TESS_EVAL],
- tep, &brw->tes.base, brw->tes.base.prog_data);
+ brw_upload_image_surfaces(brw, tep, &brw->tes.base,
+ brw->tes.base.prog_data);
}
}
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 7bc7b77e9cf..6c349f400ec 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
@@ -188,16 +188,13 @@ const struct brw_tracked_state brw_vs_abo_surfaces = {
static void
brw_upload_vs_image_surfaces(struct brw_context *brw)
{
- struct gl_context *ctx = &brw->ctx;
/* BRW_NEW_VERTEX_PROGRAM */
- struct gl_shader_program *prog =
- ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
const struct gl_program *vp = brw->vertex_program;
- if (vp && prog) {
+ if (vp) {
/* BRW_NEW_VS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */
- brw_upload_image_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_VERTEX],
- vp, &brw->vs.base, brw->vs.base.prog_data);
+ brw_upload_image_surfaces(brw, vp, &brw->vs.base,
+ brw->vs.base.prog_data);
}
}
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 6c44381be13..34fec7e7d94 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -1564,16 +1564,13 @@ const struct brw_tracked_state brw_cs_abo_surfaces = {
static void
brw_upload_cs_image_surfaces(struct brw_context *brw)
{
- struct gl_context *ctx = &brw->ctx;
/* _NEW_PROGRAM */
- struct gl_shader_program *prog =
- ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
const struct gl_program *cp = brw->compute_program;
- if (cp && prog) {
+ if (cp) {
/* BRW_NEW_CS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */
- brw_upload_image_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_COMPUTE],
- cp, &brw->cs.base, brw->cs.base.prog_data);
+ brw_upload_image_surfaces(brw, cp, &brw->cs.base,
+ brw->cs.base.prog_data);
}
}
@@ -1780,7 +1777,6 @@ update_image_surface(struct brw_context *brw,
void
brw_upload_image_surfaces(struct brw_context *brw,
- struct gl_linked_shader *shader,
const struct gl_program *prog,
struct brw_stage_state *stage_state,
struct brw_stage_prog_data *prog_data)
@@ -1788,12 +1784,12 @@ brw_upload_image_surfaces(struct brw_context *brw,
assert(prog);
struct gl_context *ctx = &brw->ctx;
- if (prog->info.num_images && shader) {
+ if (prog->info.num_images) {
for (unsigned i = 0; i < prog->info.num_images; i++) {
- struct gl_image_unit *u = &ctx->ImageUnits[shader->ImageUnits[i]];
+ struct gl_image_unit *u = &ctx->ImageUnits[prog->sh.ImageUnits[i]];
const unsigned surf_idx = prog_data->binding_table.image_start + i;
- update_image_surface(brw, u, shader->ImageAccess[i],
+ update_image_surface(brw, u, prog->sh.ImageAccess[i],
surf_idx,
&stage_state->surf_offset[surf_idx],
&prog_data->image_param[i]);
@@ -1811,15 +1807,13 @@ brw_upload_image_surfaces(struct brw_context *brw,
static void
brw_upload_wm_image_surfaces(struct brw_context *brw)
{
- struct gl_context *ctx = &brw->ctx;
/* BRW_NEW_FRAGMENT_PROGRAM */
- struct gl_shader_program *prog = ctx->_Shader->_CurrentFragmentProgram;
const struct gl_program *wm = brw->fragment_program;
- if (wm && prog) {
+ if (wm) {
/* BRW_NEW_FS_PROG_DATA, BRW_NEW_IMAGE_UNITS, _NEW_TEXTURE */
- brw_upload_image_surfaces(brw, prog->_LinkedShaders[MESA_SHADER_FRAGMENT],
- wm, &brw->wm.base, brw->wm.base.prog_data);
+ brw_upload_image_surfaces(brw, wm, &brw->wm.base,
+ brw->wm.base.prog_data);
}
}