summaryrefslogtreecommitdiffstats
path: root/src/intel/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/intel/compiler')
-rw-r--r--src/intel/compiler/brw_compiler.h1
-rw-r--r--src/intel/compiler/brw_nir.c4
-rw-r--r--src/intel/compiler/brw_nir.h2
-rw-r--r--src/intel/compiler/brw_nir_attribute_workarounds.c29
-rw-r--r--src/intel/compiler/brw_vec4.cpp7
-rw-r--r--src/intel/compiler/brw_vec4_vs.h5
-rw-r--r--src/intel/compiler/brw_vec4_vs_visitor.cpp6
7 files changed, 13 insertions, 41 deletions
diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index 28aed833245..0060c381c0d 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -1123,7 +1123,6 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
const struct brw_vs_prog_key *key,
struct brw_vs_prog_data *prog_data,
const struct nir_shader *shader,
- bool use_legacy_snorm_formula,
int shader_time_index,
char **error_str);
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index 265c63efdda..dbddef0d04d 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -211,7 +211,6 @@ remap_patch_urb_offsets(nir_block *block, nir_builder *b,
void
brw_nir_lower_vs_inputs(nir_shader *nir,
- bool use_legacy_snorm_formula,
const uint8_t *vs_attrib_wa_flags)
{
/* Start with the location of the variable's base. */
@@ -230,8 +229,7 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
add_const_offset_to_base(nir, nir_var_shader_in);
- brw_nir_apply_attribute_workarounds(nir, use_legacy_snorm_formula,
- vs_attrib_wa_flags);
+ brw_nir_apply_attribute_workarounds(nir, vs_attrib_wa_flags);
/* The last step is to remap VERT_ATTRIB_* to actual registers */
diff --git a/src/intel/compiler/brw_nir.h b/src/intel/compiler/brw_nir.h
index e9cb6f89948..809d4c338dc 100644
--- a/src/intel/compiler/brw_nir.h
+++ b/src/intel/compiler/brw_nir.h
@@ -102,7 +102,6 @@ brw_nir_link_shaders(const struct brw_compiler *compiler,
bool brw_nir_lower_cs_intrinsics(nir_shader *nir,
unsigned dispatch_width);
void brw_nir_lower_vs_inputs(nir_shader *nir,
- bool use_legacy_snorm_formula,
const uint8_t *vs_attrib_wa_flags);
void brw_nir_lower_vue_inputs(nir_shader *nir,
const struct brw_vue_map *vue_map);
@@ -121,7 +120,6 @@ nir_shader *brw_postprocess_nir(nir_shader *nir,
bool is_scalar);
bool brw_nir_apply_attribute_workarounds(nir_shader *nir,
- bool use_legacy_snorm_formula,
const uint8_t *attrib_wa_flags);
bool brw_nir_apply_trig_workarounds(nir_shader *nir);
diff --git a/src/intel/compiler/brw_nir_attribute_workarounds.c b/src/intel/compiler/brw_nir_attribute_workarounds.c
index c719371ddf1..55a3b3e4546 100644
--- a/src/intel/compiler/brw_nir_attribute_workarounds.c
+++ b/src/intel/compiler/brw_nir_attribute_workarounds.c
@@ -33,7 +33,6 @@
struct attr_wa_state {
nir_builder builder;
bool impl_progress;
- bool use_legacy_snorm_formula;
const uint8_t *wa_flags;
};
@@ -88,12 +87,15 @@ apply_attr_wa_block(nir_block *block, struct attr_wa_state *state)
/* ES 3.0 has different rules for converting signed normalized
* fixed-point numbers than desktop GL.
*/
- if ((wa_flags & BRW_ATTRIB_WA_SIGN) &&
- !state->use_legacy_snorm_formula) {
+ if (wa_flags & BRW_ATTRIB_WA_SIGN) {
/* According to equation 2.2 of the ES 3.0 specification,
* signed normalization conversion is done by:
*
* f = c / (2^(b-1)-1)
+ *
+ * OpenGL 4.2+ uses this equation as well. Since most contexts
+ * promote to the new higher version, and this is what Haswell+
+ * hardware does anyway, we just always use this formula.
*/
nir_ssa_def *es3_normalize_factor =
nir_imm_vec4(b, 1.0f / ((1 << 9) - 1), 1.0f / ((1 << 9) - 1),
@@ -102,31 +104,16 @@ apply_attr_wa_block(nir_block *block, struct attr_wa_state *state)
nir_fmul(b, nir_i2f32(b, val), es3_normalize_factor),
nir_imm_float(b, -1.0f));
} else {
- /* The following equations are from the OpenGL 3.2 specification:
+ /* The following equation is from the OpenGL 3.2 specification:
*
* 2.1 unsigned normalization
* f = c/(2^n-1)
- *
- * 2.2 signed normalization
- * f = (2c+1)/(2^n-1)
- *
- * Both of these share a common divisor, which we handle by
- * multiplying by 1 / (2^b - 1) for b = <10, 10, 10, 2>.
*/
nir_ssa_def *normalize_factor =
nir_imm_vec4(b, 1.0f / ((1 << 10) - 1), 1.0f / ((1 << 10) - 1),
1.0f / ((1 << 10) - 1), 1.0f / ((1 << 2) - 1));
- if (wa_flags & BRW_ATTRIB_WA_SIGN) {
- /* For signed normalization, the numerator is 2c+1. */
- nir_ssa_def *two = nir_imm_float(b, 2.0f);
- nir_ssa_def *one = nir_imm_float(b, 1.0f);
- val = nir_fadd(b, nir_fmul(b, nir_i2f32(b, val), two), one);
- } else {
- /* For unsigned normalization, the numerator is just c. */
- val = nir_u2f32(b, val);
- }
- val = nir_fmul(b, val, normalize_factor);
+ val = nir_fmul(b, nir_u2f32(b, val), normalize_factor);
}
}
@@ -145,12 +132,10 @@ apply_attr_wa_block(nir_block *block, struct attr_wa_state *state)
bool
brw_nir_apply_attribute_workarounds(nir_shader *shader,
- bool use_legacy_snorm_formula,
const uint8_t *attrib_wa_flags)
{
bool progress = false;
struct attr_wa_state state = {
- .use_legacy_snorm_formula = use_legacy_snorm_formula,
.wa_flags = attrib_wa_flags,
};
diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp
index 3ddbe6c57fc..ad6d8f9d6bc 100644
--- a/src/intel/compiler/brw_vec4.cpp
+++ b/src/intel/compiler/brw_vec4.cpp
@@ -2744,7 +2744,6 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
const struct brw_vs_prog_key *key,
struct brw_vs_prog_data *prog_data,
const nir_shader *src_shader,
- bool use_legacy_snorm_formula,
int shader_time_index,
char **error_str)
{
@@ -2772,8 +2771,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;
- brw_nir_lower_vs_inputs(shader, use_legacy_snorm_formula,
- key->gl_attrib_wa_flags);
+ brw_nir_lower_vs_inputs(shader, key->gl_attrib_wa_flags);
brw_nir_lower_vue_outputs(shader, is_scalar);
shader = brw_postprocess_nir(shader, compiler, is_scalar);
@@ -2891,8 +2889,7 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
prog_data->base.dispatch_mode = DISPATCH_MODE_4X2_DUAL_OBJECT;
vec4_vs_visitor v(compiler, log_data, key, prog_data,
- shader, mem_ctx,
- shader_time_index, use_legacy_snorm_formula);
+ shader, mem_ctx, shader_time_index);
if (!v.run()) {
if (error_str)
*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
diff --git a/src/intel/compiler/brw_vec4_vs.h b/src/intel/compiler/brw_vec4_vs.h
index b2a862fdbde..b62e03aa8d9 100644
--- a/src/intel/compiler/brw_vec4_vs.h
+++ b/src/intel/compiler/brw_vec4_vs.h
@@ -37,8 +37,7 @@ public:
struct brw_vs_prog_data *vs_prog_data,
const nir_shader *shader,
void *mem_ctx,
- int shader_time_index,
- bool use_legacy_snorm_formula);
+ int shader_time_index);
protected:
virtual void setup_payload();
@@ -55,8 +54,6 @@ private:
const struct brw_vs_prog_key *const key;
struct brw_vs_prog_data * const vs_prog_data;
-
- bool use_legacy_snorm_formula;
};
} /* namespace brw */
diff --git a/src/intel/compiler/brw_vec4_vs_visitor.cpp b/src/intel/compiler/brw_vec4_vs_visitor.cpp
index 4d8ae23b0c7..8f15bc30a7c 100644
--- a/src/intel/compiler/brw_vec4_vs_visitor.cpp
+++ b/src/intel/compiler/brw_vec4_vs_visitor.cpp
@@ -172,13 +172,11 @@ vec4_vs_visitor::vec4_vs_visitor(const struct brw_compiler *compiler,
struct brw_vs_prog_data *vs_prog_data,
const nir_shader *shader,
void *mem_ctx,
- int shader_time_index,
- bool use_legacy_snorm_formula)
+ int shader_time_index)
: vec4_visitor(compiler, log_data, &key->tex, &vs_prog_data->base, shader,
mem_ctx, false /* no_spills */, shader_time_index),
key(key),
- vs_prog_data(vs_prog_data),
- use_legacy_snorm_formula(use_legacy_snorm_formula)
+ vs_prog_data(vs_prog_data)
{
}