Mesa (master): i965: Add brw_prog_key_set_id helper to set the program id on any stage

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 10 06:18:31 UTC 2018


Module: Mesa
Branch: master
Commit: 170d76de9fd29cfcfb75c4b5570f9d8271a8928e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=170d76de9fd29cfcfb75c4b5570f9d8271a8928e

Author: Jordan Justen <jordan.l.justen at intel.com>
Date:   Mon Mar  5 17:17:23 2018 -0800

i965: Add brw_prog_key_set_id helper to set the program id on any stage

For saving programs (shader cache; get program binary) it is useful to
set the id to 0, with the stage being a parameter.

For restoring programs it is useful to set the id to the id allocated
to the program at creation time.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>

---

 src/mesa/drivers/dri/i965/brw_program.c | 16 ++++++++++++++++
 src/mesa/drivers/dri/i965/brw_program.h |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 7a85678f86..7f0b7133f5 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -838,3 +838,19 @@ brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
    assert(next_binding_table_offset <= BRW_MAX_SURFACES);
    return next_binding_table_offset;
 }
+
+void
+brw_prog_key_set_id(union brw_any_prog_key *key, gl_shader_stage stage,
+                    unsigned id)
+{
+   static const unsigned stage_offsets[] = {
+      offsetof(struct brw_vs_prog_key, program_string_id),
+      offsetof(struct brw_tcs_prog_key, program_string_id),
+      offsetof(struct brw_tes_prog_key, program_string_id),
+      offsetof(struct brw_gs_prog_key, program_string_id),
+      offsetof(struct brw_wm_prog_key, program_string_id),
+      offsetof(struct brw_cs_prog_key, program_string_id),
+   };
+   assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_offsets));
+   *(unsigned*)((uint8_t*)key + stage_offsets[stage]) = id;
+}
diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
index a49bc81a2b..3cdb90264a 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -82,6 +82,9 @@ brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
                                         const struct gl_program *prog,
                                         struct brw_stage_prog_data *stage_prog_data,
                                         uint32_t next_binding_table_offset);
+void
+brw_prog_key_set_id(union brw_any_prog_key *key, gl_shader_stage stage,
+                    unsigned id);
 
 void
 brw_stage_prog_data_free(const void *prog_data);




More information about the mesa-commit mailing list