Skip to content
Snippets Groups Projects
Commit 1665f478 authored by Pierre-Eric Pelloux-Prayer's avatar Pierre-Eric Pelloux-Prayer Committed by Dylan Baker
Browse files

nir/lower_tex: ignore texture_index if tex_instr has deref src


texture_index is meaningless when a tex_instr has deref src.
Use var->data.binding instead.

This fixes the incorrect lowering on radeonsi where the same
lowering steps was applied to all tex_instr based on the needs
of the first one (since texture_index is always 0).

CC: mesa-stable
Reviewed-by: Jesse Natalie's avatarJesse Natalie <jenatali@microsoft.com>
Acked-by: default avatarMarek Olšák <marek.olsak@amd.com>
Part-of: <mesa/mesa!9931>
(cherry picked from commit bc438c91)
parent 6a0f0a34
No related branches found
No related tags found
No related merge requests found
......@@ -148,7 +148,7 @@
"description": "nir/lower_tex: ignore texture_index if tex_instr has deref src",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": null
},
......@@ -287,16 +287,17 @@ static void
convert_yuv_to_rgb(nir_builder *b, nir_tex_instr *tex,
nir_ssa_def *y, nir_ssa_def *u, nir_ssa_def *v,
nir_ssa_def *a,
const nir_lower_tex_options *options)
const nir_lower_tex_options *options,
unsigned texture_index)
{
const float *offset_vals;
const nir_const_value_3_4 *m;
assert((options->bt709_external & options->bt2020_external) == 0);
if (options->bt709_external & (1 << tex->texture_index)) {
if (options->bt709_external & (1u << texture_index)) {
m = &bt709_csc_coeffs;
offset_vals = bt709_csc_offsets;
} else if (options->bt2020_external & (1 << tex->texture_index)) {
} else if (options->bt2020_external & (1u << texture_index)) {
m = &bt2020_csc_coeffs;
offset_vals = bt2020_csc_offsets;
} else {
......@@ -327,7 +328,8 @@ convert_yuv_to_rgb(nir_builder *b, nir_tex_instr *tex,
static void
lower_y_uv_external(nir_builder *b, nir_tex_instr *tex,
const nir_lower_tex_options *options)
const nir_lower_tex_options *options,
unsigned texture_index)
{
b->cursor = nir_after_instr(&tex->instr);
......@@ -339,12 +341,14 @@ lower_y_uv_external(nir_builder *b, nir_tex_instr *tex,
nir_channel(b, uv, 0),
nir_channel(b, uv, 1),
nir_imm_float(b, 1.0f),
options);
options,
texture_index);
}
static void
lower_y_u_v_external(nir_builder *b, nir_tex_instr *tex,
const nir_lower_tex_options *options)
const nir_lower_tex_options *options,
unsigned texture_index)
{
b->cursor = nir_after_instr(&tex->instr);
......@@ -357,12 +361,14 @@ lower_y_u_v_external(nir_builder *b, nir_tex_instr *tex,
nir_channel(b, u, 0),
nir_channel(b, v, 0),
nir_imm_float(b, 1.0f),
options);
options,
texture_index);
}
static void
lower_yx_xuxv_external(nir_builder *b, nir_tex_instr *tex,
const nir_lower_tex_options *options)
const nir_lower_tex_options *options,
unsigned texture_index)
{
b->cursor = nir_after_instr(&tex->instr);
......@@ -374,12 +380,14 @@ lower_yx_xuxv_external(nir_builder *b, nir_tex_instr *tex,
nir_channel(b, xuxv, 1),
nir_channel(b, xuxv, 3),
nir_imm_float(b, 1.0f),
options);
options,
texture_index);
}
static void
lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex,
const nir_lower_tex_options *options)
const nir_lower_tex_options *options,
unsigned texture_index)
{
b->cursor = nir_after_instr(&tex->instr);
......@@ -391,12 +399,14 @@ lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex,
nir_channel(b, uxvx, 0),
nir_channel(b, uxvx, 2),
nir_imm_float(b, 1.0f),
options);
options,
texture_index);
}
static void
lower_ayuv_external(nir_builder *b, nir_tex_instr *tex,
const nir_lower_tex_options *options)
const nir_lower_tex_options *options,
unsigned texture_index)
{
b->cursor = nir_after_instr(&tex->instr);
......@@ -407,12 +417,14 @@ lower_ayuv_external(nir_builder *b, nir_tex_instr *tex,
nir_channel(b, ayuv, 1),
nir_channel(b, ayuv, 0),
nir_channel(b, ayuv, 3),
options);
options,
texture_index);
}
static void
lower_xyuv_external(nir_builder *b, nir_tex_instr *tex,
const nir_lower_tex_options *options)
const nir_lower_tex_options *options,
unsigned texture_index)
{
b->cursor = nir_after_instr(&tex->instr);
......@@ -423,12 +435,14 @@ lower_xyuv_external(nir_builder *b, nir_tex_instr *tex,
nir_channel(b, xyuv, 1),
nir_channel(b, xyuv, 0),
nir_imm_float(b, 1.0f),
options);
options,
texture_index);
}
static void
lower_yuv_external(nir_builder *b, nir_tex_instr *tex,
const nir_lower_tex_options *options)
const nir_lower_tex_options *options,
unsigned texture_index)
{
b->cursor = nir_after_instr(&tex->instr);
......@@ -439,7 +453,8 @@ lower_yuv_external(nir_builder *b, nir_tex_instr *tex,
nir_channel(b, yuv, 1),
nir_channel(b, yuv, 2),
nir_imm_float(b, 1.0f),
options);
options,
texture_index);
}
/*
......@@ -1052,38 +1067,45 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
progress = true;
}
if ((1 << tex->texture_index) & options->lower_y_uv_external) {
lower_y_uv_external(b, tex, options);
unsigned texture_index = tex->texture_index;
int tex_index = nir_tex_instr_src_index(tex, nir_tex_src_texture_deref);
if (tex_index >= 0) {
nir_deref_instr *deref = nir_src_as_deref(tex->src[tex_index].src);
texture_index = nir_deref_instr_get_variable(deref)->data.binding;
}
if ((1u << texture_index) & options->lower_y_uv_external) {
lower_y_uv_external(b, tex, options, texture_index);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_y_u_v_external) {
lower_y_u_v_external(b, tex, options);
if ((1u << texture_index) & options->lower_y_u_v_external) {
lower_y_u_v_external(b, tex, options, texture_index);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_yx_xuxv_external) {
lower_yx_xuxv_external(b, tex, options);
if ((1u << texture_index) & options->lower_yx_xuxv_external) {
lower_yx_xuxv_external(b, tex, options, texture_index);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_xy_uxvx_external) {
lower_xy_uxvx_external(b, tex, options);
if ((1u << texture_index) & options->lower_xy_uxvx_external) {
lower_xy_uxvx_external(b, tex, options, texture_index);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_ayuv_external) {
lower_ayuv_external(b, tex, options);
if ((1u << texture_index) & options->lower_ayuv_external) {
lower_ayuv_external(b, tex, options, texture_index);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_xyuv_external) {
lower_xyuv_external(b, tex, options);
if ((1u << texture_index) & options->lower_xyuv_external) {
lower_xyuv_external(b, tex, options, texture_index);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_yuv_external) {
lower_yuv_external(b, tex, options);
lower_yuv_external(b, tex, options, texture_index);
progress = true;
}
......@@ -1097,7 +1119,7 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
progress = true;
}
if (((1 << tex->texture_index) & options->swizzle_result) &&
if (((1u << texture_index) & options->swizzle_result) &&
!nir_tex_instr_is_query(tex) &&
!(tex->is_shadow && tex->is_new_style_shadow)) {
swizzle_result(b, tex, options->swizzles[tex->texture_index]);
......@@ -1105,7 +1127,7 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
}
/* should be after swizzle so we know which channels are rgb: */
if (((1 << tex->texture_index) & options->lower_srgb) &&
if (((1u << texture_index) & options->lower_srgb) &&
!nir_tex_instr_is_query(tex) && !tex->is_shadow) {
linearize_srgb_result(b, tex);
progress = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment