[Mesa-dev] [PATCH 54/77] i965: add support for caching clip planes
Timothy Arceri
timothy.arceri at collabora.com
Mon Oct 3 06:05:13 UTC 2016
---
src/mesa/drivers/dri/i965/brw_shader_cache.c | 43 ++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index d003c71..12b3db2 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -130,9 +130,18 @@ fallback_to_full_recompile(struct brw_context *brw,
static void
load_program_data(struct gl_shader_program *prog, struct blob_reader *binary,
struct brw_stage_prog_data *prog_data,
- gl_shader_stage stage, struct gl_context *ctx)
+ gl_shader_stage stage, struct gl_context *ctx,
+ const struct brw_vs_prog_key *vs_key)
{
static const gl_constant_value zero = { 0 };
+ bool is_vertex = stage == MESA_SHADER_VERTEX;
+
+ uint64_t eye_user_plane_base = 0;
+ uint64_t clip_user_plane_base = 0;
+ if (is_vertex) {
+ eye_user_plane_base = blob_read_uint64(binary);
+ clip_user_plane_base = blob_read_uint64(binary);
+ }
uint64_t parameter_values_base = blob_read_uint64(binary);
uint64_t uniform_data_slots_base = blob_read_uint64(binary);
@@ -169,15 +178,26 @@ load_program_data(struct gl_shader_program *prog, struct blob_reader *binary,
}
}
+ unsigned cp_upper_boundary =
+ is_vertex ? vs_key->nr_userclip_plane_consts * 4 : 0;
+
for (unsigned i = 0; i < nr_params; i++) {
uint64_t param = blob_read_uint64(binary);
- ptrdiff_t p_offset, u_offset, i_offset;
+ ptrdiff_t p_offset, u_offset, i_offset, eye_offset, clip_offset;
+
struct gl_program_parameter_list *param_list =
prog->_LinkedShaders[stage]->Program->Parameters;
p_offset = (param - parameter_values_base) / sizeof(gl_constant_value);
u_offset = (param - uniform_data_slots_base) / sizeof(gl_constant_value);
i_offset = (param - image_params_base) / sizeof(gl_constant_value);
+
+ if (is_vertex) {
+ eye_offset =
+ (param - eye_user_plane_base) / sizeof(gl_constant_value);
+ clip_offset =
+ (param - clip_user_plane_base) / sizeof(gl_constant_value);
+ }
if (p_offset >= 0 && p_offset < 4 * param_list->NumParameters) {
prog_data->param[i] =
@@ -187,6 +207,15 @@ load_program_data(struct gl_shader_program *prog, struct blob_reader *binary,
} else if (i_offset >= 0 && i_offset < image_upper_boundary) {
prog_data->param[i] =
((gl_constant_value *) prog_data->image_param) + i_offset;
+ } else if (is_vertex &&
+ eye_offset >= 0 && eye_offset < cp_upper_boundary) {
+ prog_data->param[i] =
+ ((gl_constant_value *) ctx->Transform.EyeUserPlane) + eye_offset;
+ } else if (is_vertex &&
+ clip_offset >= 0 && clip_offset < cp_upper_boundary) {
+ prog_data->param[i] =
+ ((gl_constant_value *) ctx->Transform._ClipUserPlane) +
+ clip_offset;
} else {
prog_data->param[i] = &zero;
}
@@ -329,7 +358,7 @@ read_and_upload(struct brw_context *brw, struct program_cache *cache,
unreachable("Unsupported stage!");
}
- load_program_data(prog, binary, prog_data, stage, &brw->ctx);
+ load_program_data(prog, binary, prog_data, stage, &brw->ctx, &vs_key);
brw_alloc_stage_scratch(brw, stage_state, prog_data->total_scratch,
max_threads);
@@ -414,6 +443,14 @@ write_program_data(struct brw_context *brw, struct gl_shader_program *prog,
blob_write_uint32(binary, prog_data_size);
blob_write_bytes(binary, prog_data, prog_data_size);
+ if (stage == MESA_SHADER_VERTEX) {
+ /* Cache clip plane pointers */
+ blob_write_uint64(binary,
+ ptr_to_uint64_t(brw->ctx.Transform.EyeUserPlane));
+ blob_write_uint64(binary,
+ ptr_to_uint64_t(brw->ctx.Transform._ClipUserPlane));
+ }
+
/* Include variable-length params from end of brw_stage_prog_data as well.
*
* Before writing either of the params or pull_params arrays, we first
--
2.7.4
More information about the mesa-dev
mailing list