mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 10:18:05 +02:00
v3d: fix texture packing lowering
For texture instructions that don't have sampler state we have been incorrectly using sampler index to retrive texture packing information. This is incorrect for two reasons: 1. These instructions don't have a defined sampler index by definition. 2. The driver was not setting it either, so effectively, we have always been using whatever we had set for the first texture, which is obviously bogus. Fix this by running a lowering pass that sets the index to use in backend_flags, which is what the compiler expects, based on the texture index, which is what we want in GL since we make this decision based on the texture format. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24537>
This commit is contained in:
parent
d28e5960e5
commit
6ae2844c52
1 changed files with 28 additions and 0 deletions
|
|
@ -306,6 +306,24 @@ lower_uniform_offset_to_bytes_cb(nir_builder *b, nir_instr *instr, void *_state)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
lower_textures_cb(nir_builder *b, nir_instr *instr, void *_state)
|
||||
{
|
||||
if (instr->type != nir_instr_type_tex)
|
||||
return false;
|
||||
|
||||
nir_tex_instr *tex = nir_instr_as_tex(instr);
|
||||
if (nir_tex_instr_need_sampler(tex))
|
||||
return false;
|
||||
|
||||
/* Use the texture index as sampler index for the purposes of
|
||||
* lower_tex_packing, since in GL we currently make packing
|
||||
* decisions based on texture format.
|
||||
*/
|
||||
tex->backend_flags = tex->texture_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
v3d_nir_lower_uniform_offset_to_bytes(nir_shader *s)
|
||||
{
|
||||
|
|
@ -314,6 +332,14 @@ v3d_nir_lower_uniform_offset_to_bytes(nir_shader *s)
|
|||
nir_metadata_dominance, NULL);
|
||||
}
|
||||
|
||||
static bool
|
||||
v3d_nir_lower_textures(nir_shader *s)
|
||||
{
|
||||
return nir_shader_instructions_pass(s, lower_textures_cb,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance, NULL);
|
||||
}
|
||||
|
||||
static void *
|
||||
v3d_uncompiled_shader_create(struct pipe_context *pctx,
|
||||
enum pipe_shader_ir type, void *ir)
|
||||
|
|
@ -372,6 +398,8 @@ v3d_uncompiled_shader_create(struct pipe_context *pctx,
|
|||
*/
|
||||
NIR_PASS(_, s, v3d_nir_lower_uniform_offset_to_bytes);
|
||||
|
||||
NIR_PASS(_, s, v3d_nir_lower_textures);
|
||||
|
||||
/* Garbage collect dead instructions */
|
||||
nir_sweep(s);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue