broadcom/compiler: separate texture/sampler info from v3d_key

So far the v3d compiler has them combined, as for OpenGL both are the
same. This change is intended to fit the v3d compiler better with
Vulkan, where they are separate concepts.

Note that NIR has them separate for a long time, both on nir_variable
and on some NIR lowerings.

v2: (from Iago feedback)
    * Use key->num_tex/sampler_used to iterate through the array
    * Fill up num_samplers_used on v3d, assert that is the same that
      num_tex_used if possible.

v3: (Iago)
    * Assert num_tex/samplers_used is smaller that tex/sampler array size.

v4: Update assert mentioned on v3 to use <= instead of < (detected by CI)

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>

squash! broadcom/compiler: separate texture/sampler info from v3d_key

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7545>
This commit is contained in:
Alejandro Piñeiro
2020-11-10 22:05:10 +01:00
committed by Marge Bot
parent 1fe52af61a
commit 429c336412
5 changed files with 40 additions and 22 deletions

View File

@@ -61,7 +61,9 @@ static const struct V3D41_TMU_CONFIG_PARAMETER_2 p2_unpacked_default = {
void
v3d40_vir_emit_tex(struct v3d_compile *c, nir_tex_instr *instr)
{
unsigned unit = instr->texture_index;
unsigned texture_idx = instr->texture_index;
unsigned sampler_idx = instr->sampler_index;
int tmu_writes = 0;
struct V3D41_TMU_CONFIG_PARAMETER_0 p0_unpacked = {
@@ -199,11 +201,11 @@ v3d40_vir_emit_tex(struct v3d_compile *c, nir_tex_instr *instr)
if (instr->op == nir_texop_lod)
p2_packed |= 1UL << 24;
/* Load unit number into the high bits of the texture address field,
/* Load texture_idx number into the high bits of the texture address field,
* which will be be used by the driver to decide which texture to put
* in the actual address field.
*/
p0_packed |= unit << 24;
p0_packed |= texture_idx << 24;
vir_WRTMUC(c, QUNIFORM_TMU_CONFIG_P0, p0_packed);
@@ -211,7 +213,7 @@ v3d40_vir_emit_tex(struct v3d_compile *c, nir_tex_instr *instr)
* itself, we still need to add the sampler configuration
* parameter if the output is 32 bit
*/
bool output_type_32_bit = (c->key->tex[unit].return_size == 32 &&
bool output_type_32_bit = (c->key->sampler[sampler_idx].return_size == 32 &&
!instr->is_shadow);
/*
@@ -248,12 +250,12 @@ v3d40_vir_emit_tex(struct v3d_compile *c, nir_tex_instr *instr)
&p1_unpacked);
if (nir_tex_instr_need_sampler(instr)) {
/* Load unit number into the high bits of the sampler
* address field, which will be be used by the driver
* to decide which sampler to put in the actual
/* Load sampler_idx number into the high bits of the
* sampler address field, which will be be used by the
* driver to decide which sampler to put in the actual
* address field.
*/
p1_packed |= unit << 24;
p1_packed |= sampler_idx << 24;
vir_WRTMUC(c, QUNIFORM_TMU_CONFIG_P1, p1_packed);
} else {