[Mesa-dev] [RFC PATCH 33/40] i965/fs: Include ubo registers when assigning push_constant locations
Abdiel Janulgue
abdiel.janulgue at linux.intel.com
Sun Jan 4 06:04:47 PST 2015
When assigning a block of register to normal uniforms, pack the ubo
uniform registers next to it.
Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
src/mesa/drivers/dri/i965/brw_fs.cpp | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index d62050e..9a73691 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1670,7 +1670,7 @@ fs_visitor::assign_curb_setup()
if (inst->src[i].file == UNIFORM) {
int uniform_nr = inst->src[i].reg + inst->src[i].reg_offset;
int constant_nr;
- if (uniform_nr >= 0 && uniform_nr < (int) uniforms) {
+ if (uniform_nr >= 0 && uniform_nr < (int) (uniforms + ubo_uniforms)) {
constant_nr = push_constant_loc[uniform_nr];
} else {
/* Section 5.11 of the OpenGL 4.1 spec says:
@@ -2105,8 +2105,9 @@ fs_visitor::move_uniform_array_access_to_pull_constants()
if (dispatch_width != 8)
return;
- pull_constant_loc = ralloc_array(mem_ctx, int, uniforms);
- memset(pull_constant_loc, -1, sizeof(pull_constant_loc[0]) * uniforms);
+ unsigned int total_uniforms = uniforms + ubo_uniforms;
+ pull_constant_loc = ralloc_array(mem_ctx, int, total_uniforms);
+ memset(pull_constant_loc, -1, sizeof(pull_constant_loc[0]) * total_uniforms);
/* Walk through and find array access of uniforms. Put a copy of that
* uniform in the pull constant buffer.
@@ -2156,9 +2157,10 @@ fs_visitor::assign_constant_locations()
if (dispatch_width != 8)
return;
+ unsigned int total_uniforms = uniforms + ubo_uniforms;
/* Find which UNIFORM registers are still in use. */
- bool is_live[uniforms];
- for (unsigned int i = 0; i < uniforms; i++) {
+ bool is_live[total_uniforms];
+ for (unsigned int i = 0; i < total_uniforms; i++) {
is_live[i] = false;
}
@@ -2168,7 +2170,7 @@ fs_visitor::assign_constant_locations()
continue;
int constant_nr = inst->src[i].reg + inst->src[i].reg_offset;
- if (constant_nr >= 0 && constant_nr < (int) uniforms)
+ if (constant_nr >= 0 && constant_nr < (int) total_uniforms)
is_live[constant_nr] = true;
}
}
@@ -2184,9 +2186,9 @@ fs_visitor::assign_constant_locations()
unsigned int max_push_components = 16 * 8;
unsigned int num_push_constants = 0;
- push_constant_loc = ralloc_array(mem_ctx, int, uniforms);
+ push_constant_loc = ralloc_array(mem_ctx, int, total_uniforms);
- for (unsigned int i = 0; i < uniforms; i++) {
+ for (unsigned int i = 0; i < total_uniforms; i++) {
if (!is_live[i] || pull_constant_loc[i] != -1) {
/* This UNIFORM register is either dead, or has already been demoted
* to a pull const. Mark it as no longer living in the param[] array.
@@ -2210,7 +2212,8 @@ fs_visitor::assign_constant_locations()
}
}
- stage_prog_data->nr_params = num_push_constants;
+ stage_prog_data->nr_params = 0;
+ stage_prog_data->nr_ubo_params = ubo_uniforms;
/* Up until now, the param[] array has been indexed by reg + reg_offset
* of UNIFORM registers. Condense it to only contain the uniforms we
@@ -2224,6 +2227,7 @@ fs_visitor::assign_constant_locations()
assert(remapped <= (int)i);
stage_prog_data->param[remapped] = stage_prog_data->param[i];
+ stage_prog_data->nr_params++;
}
}
--
1.9.1
More information about the mesa-dev
mailing list