pvr, pco: image size query 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:
committed by
Marge Bot
parent
7369f77590
commit
fe884e30f8
@@ -111,9 +111,9 @@ typedef struct _pco_cs_data {
|
||||
/** PCO image descriptor metadata. */
|
||||
enum pco_image_meta {
|
||||
PCO_IMAGE_META_LAYER_SIZE,
|
||||
PCO_IMAGE_META_BUFFER_ELEMS,
|
||||
PCO_IMAGE_META_RSVD0,
|
||||
PCO_IMAGE_META_RSVD1,
|
||||
PCO_IMAGE_META_RSVD2,
|
||||
|
||||
PCO_IMAGE_META_COUNT,
|
||||
};
|
||||
|
||||
@@ -724,6 +724,58 @@ static nir_def *lower_image(nir_builder *b, nir_instr *instr, void *cb_data)
|
||||
enum glsl_sampler_dim image_dim = nir_intrinsic_image_dim(intr);
|
||||
bool is_array = nir_intrinsic_image_array(intr);
|
||||
enum pipe_format format = nir_intrinsic_format(intr);
|
||||
unsigned desc_set = nir_src_comp_as_uint(intr->src[0], 0);
|
||||
unsigned binding = nir_src_comp_as_uint(intr->src[0], 1);
|
||||
nir_def *elem = nir_channel(b, intr->src[0].ssa, 2);
|
||||
|
||||
if (intr->intrinsic == nir_intrinsic_image_deref_size) {
|
||||
if (image_dim == GLSL_SAMPLER_DIM_BUF) {
|
||||
assert(intr->def.num_components == 1);
|
||||
nir_def *tex_meta = nir_load_tex_meta_pco(b,
|
||||
PCO_IMAGE_META_COUNT,
|
||||
elem,
|
||||
.desc_set = desc_set,
|
||||
.binding = binding);
|
||||
|
||||
return nir_channel(b, tex_meta, PCO_IMAGE_META_BUFFER_ELEMS);
|
||||
}
|
||||
|
||||
nir_def *tex_state = nir_load_tex_state_pco(b,
|
||||
ROGUE_NUM_TEXSTATE_DWORDS,
|
||||
elem,
|
||||
.desc_set = desc_set,
|
||||
.binding = binding);
|
||||
|
||||
nir_def *tex_state_word[] = {
|
||||
[0] = nir_channel(b, tex_state, 0),
|
||||
[1] = nir_channel(b, tex_state, 1),
|
||||
[2] = nir_channel(b, tex_state, 2),
|
||||
[3] = nir_channel(b, tex_state, 3),
|
||||
};
|
||||
|
||||
unsigned num_comps = intr->def.num_components;
|
||||
if (is_array)
|
||||
--num_comps;
|
||||
|
||||
nir_def *size_comps[] = {
|
||||
[0] = STATE_UNPACK_ADD(b, tex_state_word, 1, 2, 14, 1),
|
||||
[1] = STATE_UNPACK_ADD(b, tex_state_word, 1, 16, 14, 1),
|
||||
[2] = STATE_UNPACK_ADD(b, tex_state_word, 2, 4, 11, 1),
|
||||
};
|
||||
|
||||
nir_def *base_level = STATE_UNPACK(b, tex_state_word, 3, 28, 4);
|
||||
nir_def *lod = intr->src[0].ssa;
|
||||
lod = nir_iadd(b, lod, base_level);
|
||||
|
||||
for (unsigned c = 0; c < num_comps; ++c)
|
||||
size_comps[c] = nir_umax_imm(b, nir_ushr(b, size_comps[c], lod), 1);
|
||||
|
||||
if (image_dim == GLSL_SAMPLER_DIM_1D && is_array)
|
||||
size_comps[1] = size_comps[2];
|
||||
|
||||
return nir_vec(b, size_comps, intr->def.num_components);
|
||||
}
|
||||
|
||||
nir_alu_type type = intr->intrinsic == nir_intrinsic_image_deref_load
|
||||
? nir_intrinsic_dest_type(intr)
|
||||
: nir_intrinsic_src_type(intr);
|
||||
@@ -731,10 +783,6 @@ static nir_def *lower_image(nir_builder *b, nir_instr *instr, void *cb_data)
|
||||
bool msaa = image_dim == GLSL_SAMPLER_DIM_MS ||
|
||||
image_dim == GLSL_SAMPLER_DIM_SUBPASS_MS;
|
||||
|
||||
unsigned desc_set = nir_src_comp_as_uint(intr->src[0], 0);
|
||||
unsigned binding = nir_src_comp_as_uint(intr->src[0], 1);
|
||||
nir_def *elem = nir_channel(b, intr->src[0].ssa, 2);
|
||||
|
||||
nir_def *coords = intr->src[1].ssa;
|
||||
nir_def *sample_index = msaa ? intr->src[2].ssa : NULL;
|
||||
|
||||
@@ -881,6 +929,7 @@ static bool is_image(const nir_instr *instr, UNUSED const void *cb_data)
|
||||
switch (intr->intrinsic) {
|
||||
case nir_intrinsic_image_deref_load:
|
||||
case nir_intrinsic_image_deref_store:
|
||||
case nir_intrinsic_image_deref_size:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -197,6 +197,7 @@ static nir_def *lower_vk(nir_builder *b, nir_instr *instr, void *cb_data)
|
||||
|
||||
case nir_intrinsic_image_deref_load:
|
||||
case nir_intrinsic_image_deref_store:
|
||||
case nir_intrinsic_image_deref_size:
|
||||
return lower_image_derefs(b, intr, data);
|
||||
|
||||
default:
|
||||
@@ -235,6 +236,7 @@ static bool is_vk(const nir_instr *instr, UNUSED const void *cb_data)
|
||||
case nir_intrinsic_load_vulkan_descriptor:
|
||||
case nir_intrinsic_image_deref_load:
|
||||
case nir_intrinsic_image_deref_store:
|
||||
case nir_intrinsic_image_deref_size:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -463,6 +463,7 @@ VkResult pvr_CreateBufferView(VkDevice _device,
|
||||
info.format = bview->vk.format;
|
||||
info.flags = PVR_TEXFLAGS_INDEX_LOOKUP;
|
||||
info.aspect_mask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
info.buffer_elems = bview->vk.elements;
|
||||
|
||||
if (PVR_HAS_FEATURE(&device->pdevice->dev_info, tpu_array_textures))
|
||||
info.array_size = 1U;
|
||||
|
||||
@@ -246,9 +246,9 @@ VkResult pvr_pack_tex_state(struct pvr_device *device,
|
||||
}
|
||||
|
||||
state->meta[PCO_IMAGE_META_LAYER_SIZE] = info->layer_size;
|
||||
state->meta[PCO_IMAGE_META_BUFFER_ELEMS] = info->buffer_elems;
|
||||
state->meta[PCO_IMAGE_META_RSVD0] = 0;
|
||||
state->meta[PCO_IMAGE_META_RSVD1] = 0;
|
||||
state->meta[PCO_IMAGE_META_RSVD2] = 0;
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ struct pvr_texture_state_info {
|
||||
pvr_dev_addr_t addr;
|
||||
|
||||
uint32_t layer_size;
|
||||
uint32_t buffer_elems;
|
||||
};
|
||||
|
||||
VkResult pvr_pack_tex_state(struct pvr_device *device,
|
||||
|
||||
Reference in New Issue
Block a user