[Mesa-dev] [PATCH 20/27] i965: add support for caching clip planes
Jordan Justen
jordan.l.justen at intel.com
Sat Aug 19 07:44:36 UTC 2017
From: Timothy Arceri <timothy.arceri at collabora.com>
---
src/mesa/drivers/dri/i965/brw_disk_cache.c | 45 ++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 0385856409..e8b4f2f5a9 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -113,10 +113,20 @@ fallback_to_full_recompile(struct brw_context *brw,
static void
load_program_data(struct gl_program *glprog, 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 };
+ const 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);
@@ -152,15 +162,27 @@ load_program_data(struct gl_program *glprog, 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 = glprog->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);
+ } else {
+ eye_offset = clip_offset = 0;
+ }
+
if (p_offset >= 0 && p_offset < 4 * param_list->NumParameters) {
prog_data->param[i] =
((gl_constant_value *) param_list->ParameterValues) + p_offset;
@@ -170,6 +192,15 @@ load_program_data(struct gl_program *glprog, 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;
}
@@ -342,7 +373,7 @@ read_and_upload(struct brw_context *brw, struct disk_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);
if (binary->current != binary->end || binary->overrun) {
/* Something very bad has gone wrong discard the item from the cache and
@@ -451,6 +482,14 @@ write_program_data(struct brw_context *brw, struct gl_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.14.0
More information about the mesa-dev
mailing list