pan/bi: Expose the packed TextureOperationDescriptor in bifrost_texture_operation

Rather than adding memcpy()s to a local u32 variable, add a union
to bifrost_texture_operation so we can directly access the packed
value.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29521>
This commit is contained in:
Boris Brezillon 2024-10-30 13:43:25 +01:00 committed by Marge Bot
parent 93d434362b
commit 9199c25e5e
2 changed files with 42 additions and 40 deletions

View file

@ -517,47 +517,53 @@ enum bifrost_texture_fetch {
};
struct bifrost_texture_operation {
/* If immediate_indices is set:
* - immediate sampler index
* - index used as texture index
* Otherwise:
* - bifrost_single_index in lower 2 bits
* - 0x3 in upper 2 bits (single-texturing)
*/
unsigned sampler_index_or_mode : 4;
unsigned index : 7;
bool immediate_indices : 1;
enum bifrost_tex_op op : 3;
union {
struct {
/* If immediate_indices is set:
* - immediate sampler index
* - index used as texture index
* Otherwise:
* - bifrost_single_index in lower 2 bits
* - 0x3 in upper 2 bits (single-texturing)
*/
unsigned sampler_index_or_mode : 4;
unsigned index : 7;
bool immediate_indices : 1;
enum bifrost_tex_op op : 3;
/* If set for TEX/FETCH, loads texel offsets and multisample index from
* a staging register containing offset_x:offset_y:offset_z:ms_index
* packed 8:8:8:8. Offsets must be in [-31, +31]. If set for
* GRDESC(_DER), disable LOD bias. */
bool offset_or_bias_disable : 1;
/* If set for TEX/FETCH, loads texel offsets and multisample index from
* a staging register containing offset_x:offset_y:offset_z:ms_index
* packed 8:8:8:8. Offsets must be in [-31, +31]. If set for
* GRDESC(_DER), disable LOD bias. */
bool offset_or_bias_disable : 1;
/* If set for TEX/FETCH, loads fp32 shadow comparison value from a
* staging register. Implies fetch_component = gather4_r. If set for
* GRDESC(_DER), disables LOD clamping. */
bool shadow_or_clamp_disable : 1;
/* If set for TEX/FETCH, loads fp32 shadow comparison value from a
* staging register. Implies fetch_component = gather4_r. If set for
* GRDESC(_DER), disables LOD clamping. */
bool shadow_or_clamp_disable : 1;
/* If set, loads an uint32 array index from a staging register. */
bool array : 1;
/* If set, loads an uint32 array index from a staging register. */
bool array : 1;
/* Texture dimension, or 0 for a cubemap */
unsigned dimension : 2;
/* Texture dimension, or 0 for a cubemap */
unsigned dimension : 2;
/* Method to compute LOD value or for a FETCH, the
* bifrost_texture_fetch component specification */
enum bifrost_lod_mode lod_or_fetch : 3;
/* Method to compute LOD value or for a FETCH, the
* bifrost_texture_fetch component specification */
enum bifrost_lod_mode lod_or_fetch : 3;
/* Reserved */
unsigned zero : 1;
/* Reserved */
unsigned zero : 1;
/* Register format for the result */
enum bifrost_texture_format_full format : 4;
/* Register format for the result */
enum bifrost_texture_format_full format : 4;
/* Write mask for the result */
unsigned mask : 4;
/* Write mask for the result */
unsigned mask : 4;
};
uint32_t packed;
};
} __attribute__((packed));
struct bifrost_dual_texture_operation {

View file

@ -3667,10 +3667,8 @@ bi_emit_texc(bi_builder *b, nir_tex_instr *instr)
desc.shadow_or_clamp_disable = i != 0;
bi_index grdesc = bi_temp(b->shader);
uint32_t desc_u = 0;
memcpy(&desc_u, &desc, sizeof(desc_u));
bi_instr *I = bi_texc_to(b, grdesc, sr, cx, cy, bi_imm_u32(desc_u),
false, sr_count, 0);
bi_instr *I = bi_texc_to(b, grdesc, sr, cx, cy,
bi_imm_u32(desc.packed), false, sr_count, 0);
I->register_format = BI_REGISTER_FORMAT_U32;
bi_emit_cached_split_i32(b, grdesc, 4);
@ -3691,10 +3689,8 @@ bi_emit_texc(bi_builder *b, nir_tex_instr *instr)
bi_index dst = bi_temp(b->shader);
uint32_t desc_u = 0;
memcpy(&desc_u, &desc, sizeof(desc_u));
bi_instr *I =
bi_texc_to(b, dst, sr, cx, cy, bi_imm_u32(desc_u),
bi_texc_to(b, dst, sr, cx, cy, bi_imm_u32(desc.packed),
!nir_tex_instr_has_implicit_derivative(instr), sr_count, 0);
I->register_format = bi_reg_fmt_for_nir(instr->dest_type);