nir: add support for gather offsets

Values inside the offsets parameter of textureGatherOffsets are required to be
constants in the range of [GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET,
GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET].

As this range is never outside [-32, 31] for all existing drivers inside mesa,
we can simply store the offsets as a int8_t[4][2] array inside nir_tex_instr.

Right now only Nvidia hardware supports this in hardware, so we can turn this
on inside Nouveau for the NIR path as it is already enabled with the TGSI one.

v2: use memcpy instead of for loops
    add missing bits to nir_instr_set
    don't show offsets if they are all 0
v3: default offsets aren't all 0
v4: rename offsets -> tg4_offsets
    rename nir_tex_instr_has_explicit_offsets -> nir_tex_instr_has_explicit_tg4_offsets

Signed-off-by: Karol Herbst <kherbst@redhat.com>
This commit is contained in:
Karol Herbst
2019-03-18 21:23:59 +01:00
committed by Karol Herbst
parent b95b33a5c7
commit 71c66c254b
8 changed files with 66 additions and 7 deletions

View File

@@ -1482,6 +1482,9 @@ typedef struct {
/* gather component selector */
unsigned component : 2;
/* gather offsets */
int8_t tg4_offsets[4][2];
/** The texture index
*
* If this texture instruction has a nir_tex_src_texture_offset source,
@@ -1699,6 +1702,8 @@ void nir_tex_instr_add_src(nir_tex_instr *tex,
void nir_tex_instr_remove_src(nir_tex_instr *tex, unsigned src_idx);
bool nir_tex_instr_has_explicit_tg4_offsets(nir_tex_instr *tex);
typedef struct {
nir_instr instr;