mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
pco: add remaining texture buffer support
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com> Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36412>
This commit is contained in:
parent
0962eec985
commit
58e437781b
3 changed files with 79 additions and 6 deletions
|
|
@ -50,8 +50,10 @@ static inline nir_def *get_src_def(nir_tex_instr *tex,
|
|||
* \param[in] tex_state Texture state words.
|
||||
* \return The replacement/lowered def.
|
||||
*/
|
||||
static nir_def *
|
||||
lower_tex_query_basic(nir_builder *b, nir_tex_instr *tex, nir_def *tex_state)
|
||||
static nir_def *lower_tex_query_basic(nir_builder *b,
|
||||
nir_tex_instr *tex,
|
||||
nir_def *tex_state,
|
||||
nir_def *tex_meta)
|
||||
{
|
||||
nir_def *tex_state_word[] = {
|
||||
[0] = nir_channel(b, tex_state, 0),
|
||||
|
|
@ -68,6 +70,13 @@ lower_tex_query_basic(nir_builder *b, nir_tex_instr *tex, nir_def *tex_state)
|
|||
return STATE_UNPACK_SHIFT(b, tex_state_word, 1, 30, 2, 1);
|
||||
|
||||
case nir_texop_txs: {
|
||||
if (tex->sampler_dim == GLSL_SAMPLER_DIM_BUF) {
|
||||
assert(tex->def.num_components == 1);
|
||||
assert(!tex->is_array);
|
||||
|
||||
return nir_channel(b, tex_meta, PCO_IMAGE_META_BUFFER_ELEMS);
|
||||
}
|
||||
|
||||
unsigned num_comps = tex->def.num_components;
|
||||
if (tex->is_array)
|
||||
--num_comps;
|
||||
|
|
@ -499,8 +508,14 @@ lower_tex(nir_builder *b, nir_instr *instr, UNUSED void *cb_data)
|
|||
.desc_set = tex_desc_set,
|
||||
.binding = tex_binding);
|
||||
|
||||
nir_def *tex_meta = nir_load_tex_meta_pco(b,
|
||||
PCO_IMAGE_META_COUNT,
|
||||
tex_elem,
|
||||
.desc_set = tex_desc_set,
|
||||
.binding = tex_binding);
|
||||
|
||||
if (nir_tex_instr_is_query(tex) && tex->op != nir_texop_lod)
|
||||
return lower_tex_query_basic(b, tex, tex_state);
|
||||
return lower_tex_query_basic(b, tex, tex_state, tex_meta);
|
||||
|
||||
nir_def *smp_state =
|
||||
nir_load_smp_state_pco(b,
|
||||
|
|
@ -516,6 +531,19 @@ lower_tex(nir_builder *b, nir_instr *instr, UNUSED void *cb_data)
|
|||
bool is_cube_array = tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE &&
|
||||
tex->is_array;
|
||||
|
||||
/* Special case, override buffers to be 2D. */
|
||||
if ((tex->op == nir_texop_txf || tex->op == nir_texop_txf_ms) &&
|
||||
tex->sampler_dim == GLSL_SAMPLER_DIM_BUF) {
|
||||
assert(!tex_src_is_float(tex, nir_tex_src_coord));
|
||||
|
||||
tex->sampler_dim = GLSL_SAMPLER_DIM_2D;
|
||||
params.sampler_dim = tex->sampler_dim;
|
||||
tex_srcs[nir_tex_src_coord] =
|
||||
nir_vec2(b,
|
||||
nir_umod_imm(b, tex_srcs[nir_tex_src_coord], 8192),
|
||||
nir_udiv_imm(b, tex_srcs[nir_tex_src_coord], 8192));
|
||||
}
|
||||
|
||||
nir_def *float_coords;
|
||||
nir_def *int_coords;
|
||||
nir_def *float_array_index;
|
||||
|
|
|
|||
|
|
@ -77,6 +77,17 @@ static nir_def *array_elem_from_deref(nir_builder *b, nir_deref_instr *deref)
|
|||
return nir_imm_int(b, array_elem);
|
||||
}
|
||||
|
||||
static inline bool is_comb_img_smp(unsigned desc_set,
|
||||
unsigned binding,
|
||||
const pco_common_data *common)
|
||||
{
|
||||
const pco_descriptor_set_data *desc_set_data = &common->desc_sets[desc_set];
|
||||
assert(desc_set_data->bindings && binding < desc_set_data->binding_count);
|
||||
|
||||
const pco_binding_data *binding_data = &desc_set_data->bindings[binding];
|
||||
return binding_data->is_img_smp;
|
||||
}
|
||||
|
||||
static void lower_tex_deref_to_binding(nir_builder *b,
|
||||
nir_tex_instr *tex,
|
||||
unsigned deref_index,
|
||||
|
|
@ -108,6 +119,31 @@ static void lower_tex_deref_to_binding(nir_builder *b,
|
|||
nir_src_rewrite(&deref_src->src, elem);
|
||||
}
|
||||
|
||||
static void
|
||||
add_txf_sampler(nir_builder *b, nir_tex_instr *tex, pco_common_data *common)
|
||||
{
|
||||
int deref_index = nir_tex_instr_src_index(tex, nir_tex_src_backend1);
|
||||
assert(deref_index >= 0);
|
||||
nir_tex_src *deref_src = &tex->src[deref_index];
|
||||
|
||||
unsigned desc_set;
|
||||
unsigned binding;
|
||||
pco_unpack_desc(tex->texture_index, &desc_set, &binding);
|
||||
nir_def *elem = deref_src->src.ssa;
|
||||
|
||||
/* If it's not a combined image/sampler, use the point sampler. */
|
||||
if (!is_comb_img_smp(desc_set, binding, common)) {
|
||||
desc_set = PCO_POINT_SAMPLER;
|
||||
binding = PCO_POINT_SAMPLER;
|
||||
elem = nir_imm_int(b, 0);
|
||||
|
||||
common->uses.point_sampler = true;
|
||||
}
|
||||
|
||||
tex->sampler_index = pco_pack_desc(desc_set, binding);
|
||||
nir_tex_instr_add_src(tex, nir_tex_src_backend2, elem);
|
||||
}
|
||||
|
||||
static inline void
|
||||
lower_tex_derefs(nir_builder *b, nir_tex_instr *tex, pco_common_data *common)
|
||||
{
|
||||
|
|
@ -120,6 +156,8 @@ lower_tex_derefs(nir_builder *b, nir_tex_instr *tex, pco_common_data *common)
|
|||
deref_index = nir_tex_instr_src_index(tex, nir_tex_src_sampler_deref);
|
||||
if (deref_index >= 0)
|
||||
lower_tex_deref_to_binding(b, tex, deref_index, common);
|
||||
else if (tex->op == nir_texop_txf || tex->op == nir_texop_txf_ms)
|
||||
add_txf_sampler(b, tex, common);
|
||||
}
|
||||
|
||||
static nir_def *
|
||||
|
|
|
|||
|
|
@ -2087,6 +2087,16 @@ static void pvr_init_descriptors(pco_data *data,
|
|||
rzalloc_array_size(NULL,
|
||||
sizeof(*desc_set_data->bindings),
|
||||
set_layout->binding_count);
|
||||
|
||||
for (unsigned binding = 0; binding < set_layout->binding_count;
|
||||
++binding) {
|
||||
const struct pvr_descriptor_set_layout_binding *layout_binding =
|
||||
&set_layout->bindings[binding];
|
||||
pco_binding_data *binding_data = &desc_set_data->bindings[binding];
|
||||
|
||||
binding_data->is_img_smp = layout_binding->type ==
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2126,9 +2136,6 @@ static void pvr_setup_descriptors(pco_data *data,
|
|||
&set_layout->bindings[binding];
|
||||
pco_binding_data *binding_data = &desc_set_data->bindings[binding];
|
||||
|
||||
binding_data->is_img_smp = layout_binding->type ==
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
|
||||
binding_data->range = (pco_range){
|
||||
.start = desc_set_range->start +
|
||||
(layout_binding->offset / sizeof(uint32_t)),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue