summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-12-16 14:06:23 +1100
committerTimothy Arceri <[email protected]>2018-01-30 09:08:47 +1100
commitf63e05ae9ea0be38a8fb2dd0ae8f391b8699e757 (patch)
treea8560935b10101db258f692e50dff41efb996367
parentf6cc15dccd54ff70be987457af790cac1c8fe5bb (diff)
compiler: tidy up double_inputs_read uses
First we move double_inputs_read into a vs struct in the union, double_inputs_read is only used for vs inputs so this will save space and also allows us to add a new double_inputs field. We add the new field because c2acf97fcc9b changed the behaviour of double_inputs_read, and while it's no longer used to track actual reads in i965 we do still want to track this for gallium drivers. Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r--src/compiler/glsl/glsl_to_nir.cpp9
-rw-r--r--src/compiler/glsl/ir_set_program_inouts.cpp2
-rw-r--r--src/compiler/nir/nir_gather_info.c8
-rw-r--r--src/compiler/shader_info.h10
-rw-r--r--src/intel/compiler/brw_vec4.cpp2
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp2
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp2
-rw-r--r--src/mesa/state_tracker/st_program.c2
8 files changed, 24 insertions, 13 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index c4ef4f5ce14..29e32cde53c 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -133,13 +133,13 @@ static void
nir_remap_attributes(nir_shader *shader)
{
nir_foreach_variable(var, &shader->inputs) {
- var->data.location += _mesa_bitcount_64(shader->info.double_inputs_read &
+ var->data.location += _mesa_bitcount_64(shader->info.vs.double_inputs &
BITFIELD64_MASK(var->data.location));
}
/* Once the remap is done, reset double_inputs_read, so later it will have
* which location/slots are doubles */
- shader->info.double_inputs_read = 0;
+ shader->info.vs.double_inputs = 0;
}
nir_shader *
@@ -363,10 +363,11 @@ nir_visitor::visit(ir_variable *ir)
}
/* Mark all the locations that require two slots */
- if (glsl_type_is_dual_slot(glsl_without_array(var->type))) {
+ if (shader->info.stage == MESA_SHADER_VERTEX &&
+ glsl_type_is_dual_slot(glsl_without_array(var->type))) {
for (uint i = 0; i < glsl_count_attribute_slots(var->type, true); i++) {
uint64_t bitfield = BITFIELD64_BIT(var->data.location + i);
- shader->info.double_inputs_read |= bitfield;
+ shader->info.vs.double_inputs |= bitfield;
}
}
break;
diff --git a/src/compiler/glsl/ir_set_program_inouts.cpp b/src/compiler/glsl/ir_set_program_inouts.cpp
index 90b06b9f417..1b6c8d750b9 100644
--- a/src/compiler/glsl/ir_set_program_inouts.cpp
+++ b/src/compiler/glsl/ir_set_program_inouts.cpp
@@ -118,7 +118,7 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
/* double inputs read is only for vertex inputs */
if (stage == MESA_SHADER_VERTEX &&
var->type->without_array()->is_dual_slot())
- prog->info.double_inputs_read |= bitfield;
+ prog->info.vs.double_inputs_read |= bitfield;
if (stage == MESA_SHADER_FRAGMENT) {
prog->info.fs.uses_sample_qualifier |= var->data.sample;
diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index 946939657ec..e98129b22c8 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -234,7 +234,8 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader)
glsl_type_is_dual_slot(glsl_without_array(var->type))) {
for (uint i = 0; i < glsl_count_attribute_slots(var->type, false); i++) {
int idx = var->data.location + i;
- shader->info.double_inputs_read |= BITFIELD64_BIT(idx);
+ shader->info.vs.double_inputs |= BITFIELD64_BIT(idx);
+ shader->info.vs.double_inputs_read |= BITFIELD64_BIT(idx);
}
}
}
@@ -356,10 +357,13 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
shader->info.outputs_written = 0;
shader->info.outputs_read = 0;
shader->info.patch_outputs_read = 0;
- shader->info.double_inputs_read = 0;
shader->info.patch_inputs_read = 0;
shader->info.patch_outputs_written = 0;
shader->info.system_values_read = 0;
+ if (shader->info.stage == MESA_SHADER_VERTEX) {
+ shader->info.vs.double_inputs = 0;
+ shader->info.vs.double_inputs_read = 0;
+ }
if (shader->info.stage == MESA_SHADER_FRAGMENT) {
shader->info.fs.uses_sample_qualifier = false;
}
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 4492cad0e8d..f6dedb8d624 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -67,8 +67,6 @@ typedef struct shader_info {
/* Which inputs are actually read */
uint64_t inputs_read;
- /* Which inputs are actually read and are double */
- uint64_t double_inputs_read;
/* Which outputs are actually written */
uint64_t outputs_written;
/* Which outputs are actually read */
@@ -110,6 +108,14 @@ typedef struct shader_info {
union {
struct {
+ /* Which inputs are doubles */
+ uint64_t double_inputs;
+
+ /* Which inputs are actually read and are double */
+ uint64_t double_inputs_read;
+ } vs;
+
+ struct {
/** The number of vertices recieves per input primitive */
unsigned vertices_in;
diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp
index ad6d8f9d6bc..e95886349d8 100644
--- a/src/intel/compiler/brw_vec4.cpp
+++ b/src/intel/compiler/brw_vec4.cpp
@@ -2769,7 +2769,7 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
}
prog_data->inputs_read = shader->info.inputs_read;
- prog_data->double_inputs_read = shader->info.double_inputs_read;
+ prog_data->double_inputs_read = shader->info.vs.double_inputs;
brw_nir_lower_vs_inputs(shader, key->gl_attrib_wa_flags);
brw_nir_lower_vue_outputs(shader, is_scalar);
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 4cf150ea1ef..2de767625af 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -88,7 +88,7 @@ st_nir_assign_vs_in_locations(struct gl_program *prog, nir_shader *nir)
if ((prog->info.inputs_read & BITFIELD64_BIT(attr)) != 0) {
input_to_index[attr] = num_inputs;
num_inputs++;
- if ((prog->info.double_inputs_read & BITFIELD64_BIT(attr)) != 0) {
+ if ((prog->info.vs.double_inputs_read & BITFIELD64_BIT(attr)) != 0) {
/* add placeholder for second part of a double attribute */
num_inputs++;
}
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 094c79ade9e..84ed614927b 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6783,7 +6783,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
_mesa_copy_linked_program_data(shader_program, shader);
shrink_array_declarations(v->inputs, v->num_inputs,
&prog->info.inputs_read,
- prog->info.double_inputs_read,
+ prog->info.vs.double_inputs_read,
&prog->info.patch_inputs_read);
shrink_array_declarations(v->outputs, v->num_outputs,
&prog->info.outputs_written, 0ULL,
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 883813d6c02..1116b5afbc8 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -406,7 +406,7 @@ st_translate_vertex_program(struct st_context *st,
input_to_index[attr] = stvp->num_inputs;
stvp->index_to_input[stvp->num_inputs] = attr;
stvp->num_inputs++;
- if ((stvp->Base.info.double_inputs_read &
+ if ((stvp->Base.info.vs.double_inputs_read &
BITFIELD64_BIT(attr)) != 0) {
/* add placeholder for second part of a double attribute */
stvp->index_to_input[stvp->num_inputs] = ST_DOUBLE_ATTRIB_PLACEHOLDER;