diff options
author | Kenneth Graunke <[email protected]> | 2017-06-02 09:54:31 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2017-07-13 20:18:54 -0700 |
commit | c9ef27e77ba0884c3716a3c39640e987200ea46e (patch) | |
tree | 6b92b70fa641978da7911d466da3199004464478 | |
parent | 4f586cd8f19a598a0f61f361840a358a7f99eaa0 (diff) |
i965: Factor out push locations.
With UBOs, the answer of "have we decided to push this uniform" gets
a bit more complicated - for one, we have multiple surfaces. This
patch refactors things so we can add the new code in a single place.
Reviewed-by: Matt Turner <[email protected]>
-rw-r--r-- | src/intel/compiler/brw_fs.cpp | 39 | ||||
-rw-r--r-- | src/intel/compiler/brw_fs.h | 2 |
2 files changed, 25 insertions, 16 deletions
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index ba1fc66e138..d631bd01ecc 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -2096,6 +2096,25 @@ fs_visitor::assign_constant_locations() new_thread_local_id_index; } +bool +fs_visitor::get_pull_locs(const fs_reg &src, + unsigned *out_surf_index, + unsigned *out_pull_index) +{ + assert(src.file == UNIFORM); + + const unsigned location = src.nr + src.offset / 4; + + if (location < uniforms && pull_constant_loc[location] != -1) { + /* A regular uniform push constant */ + *out_surf_index = stage_prog_data->binding_table.pull_constants_start; + *out_pull_index = pull_constant_loc[location]; + return true; + } + + return false; +} + /** * Replace UNIFORM register file access with either UNIFORM_PULL_CONSTANT_LOAD * or VARYING_PULL_CONSTANT_LOAD instructions which load values into VGRFs. @@ -2103,7 +2122,7 @@ fs_visitor::assign_constant_locations() void fs_visitor::lower_constant_loads() { - const unsigned index = stage_prog_data->binding_table.pull_constants_start; + unsigned index, pull_index; foreach_block_and_inst_safe (block, fs_inst, inst, cfg) { /* Set up the annotation tracking for new generated instructions. */ @@ -2117,13 +2136,7 @@ fs_visitor::lower_constant_loads() if (inst->opcode == SHADER_OPCODE_MOV_INDIRECT && i == 0) continue; - unsigned location = inst->src[i].nr + inst->src[i].offset / 4; - if (location >= uniforms) - continue; /* Out of bounds access */ - - int pull_index = pull_constant_loc[location]; - - if (pull_index == -1) + if (!get_pull_locs(inst->src[i], &index, &pull_index)) continue; assert(inst->src[i].stride == 0); @@ -2148,14 +2161,8 @@ fs_visitor::lower_constant_loads() if (inst->opcode == SHADER_OPCODE_MOV_INDIRECT && inst->src[0].file == UNIFORM) { - unsigned location = inst->src[0].nr + inst->src[0].offset / 4; - if (location >= uniforms) - continue; /* Out of bounds access */ - - int pull_index = pull_constant_loc[location]; - - if (pull_index == -1) - continue; + if (!get_pull_locs(inst->src[0], &index, &pull_index)) + continue; VARYING_PULL_CONSTANT_LOAD(ibld, inst->dst, brw_imm_ud(index), diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h index 6c8c0275a76..beb0d971b4c 100644 --- a/src/intel/compiler/brw_fs.h +++ b/src/intel/compiler/brw_fs.h @@ -125,6 +125,8 @@ public: void split_virtual_grfs(); bool compact_virtual_grfs(); void assign_constant_locations(); + bool get_pull_locs(const fs_reg &src, unsigned *out_surf_index, + unsigned *out_pull_index); void lower_constant_loads(); void invalidate_live_intervals(); void calculate_live_intervals(); |