[Mesa-dev] [PATCH 50/68] i965: add shader cache support for pull param pointers
Timothy Arceri
timothy.arceri at collabora.com
Wed Jun 1 06:23:31 UTC 2016
---
src/mesa/drivers/dri/i965/brw_shader_cache.c | 52 ++++++++++++++++++++++++++--
1 file changed, 49 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 850e1e8..d1336d7 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -59,6 +59,7 @@ upload_cached_program(struct brw_context *brw)
intptr_t uniform_data_slots_base;
intptr_t image_params_base;
uint32_t nr_params, nr_pull_params, nr_image_params;
+ static const gl_constant_value zero = { 0 };
cache = brw->ctx.Cache;
if (cache == NULL)
@@ -180,10 +181,32 @@ upload_cached_program(struct brw_context *brw)
prog_data->pull_param = rzalloc_array(NULL, const gl_constant_value *,
nr_pull_params);
-
for (i = 0; i < nr_pull_params; i++) {
intptr_t pull_param = blob_read_intptr(&binary);
- /* FIXME: We need to fixup pull_params pointers here. */
+ struct gl_program_parameter_list *param_list =
+ prog->_LinkedShaders[MESA_SHADER_VERTEX] ?
+ prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Parameters :
+ NULL;
+
+ ptrdiff_t u_offset =
+ (pull_param - uniform_data_slots_base) / sizeof(gl_constant_value);
+ ptrdiff_t i_offset =
+ (pull_param - image_params_base) / sizeof(gl_constant_value);
+ ptrdiff_t p_offset =
+ (pull_param - parameter_values_base) / sizeof(gl_constant_value);
+
+ if (param_list && p_offset >= 0 &&
+ p_offset < 4 * param_list->NumParameters) {
+ prog_data->pull_param[i] =
+ ((gl_constant_value *) param_list->ParameterValues) + p_offset;
+ } else if (u_offset >= 0 && u_offset < prog->NumUniformDataSlots) {
+ prog_data->pull_param[i] = prog->UniformDataSlots + u_offset;
+ } else if (i_offset >= 0 && i_offset < image_upper_boundary) {
+ prog_data->pull_param[i] =
+ ((gl_constant_value *) prog_data->image_param) + i_offset;
+ } else {
+ prog_data->pull_param[i] = &zero;
+ }
}
struct brw_vertex_program *vp =
@@ -262,7 +285,30 @@ upload_cached_program(struct brw_context *brw)
for (i = 0; i < nr_pull_params; i++) {
intptr_t pull_param = blob_read_intptr(&binary);
- /* FIXME: We need to fixup pull_params pointers here. */
+ struct gl_program_parameter_list *param_list =
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT] ?
+ prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->Parameters :
+ NULL;
+
+ ptrdiff_t u_offset =
+ (pull_param - uniform_data_slots_base) / sizeof(gl_constant_value);
+ ptrdiff_t i_offset =
+ (pull_param - image_params_base) / sizeof(gl_constant_value);
+ ptrdiff_t p_offset =
+ (pull_param - parameter_values_base) / sizeof(gl_constant_value);
+
+ if (param_list && p_offset >= 0 &&
+ p_offset < 4 * param_list->NumParameters) {
+ prog_data->pull_param[i] =
+ ((gl_constant_value *) param_list->ParameterValues) + p_offset;
+ } else if (u_offset >= 0 && u_offset < prog->NumUniformDataSlots) {
+ prog_data->pull_param[i] = prog->UniformDataSlots + u_offset;
+ } else if (i_offset >= 0 && i_offset < image_upper_boundary) {
+ prog_data->pull_param[i] =
+ ((gl_constant_value *) prog_data->image_param) + i_offset;
+ } else {
+ prog_data->pull_param[i] = &zero;
+ }
}
struct brw_fragment_program *wp =
--
2.5.5
More information about the mesa-dev
mailing list