diff --git a/src/asahi/compiler/agx_nir.h b/src/asahi/compiler/agx_nir.h index 651ea069ed4..c03715027e5 100644 --- a/src/asahi/compiler/agx_nir.h +++ b/src/asahi/compiler/agx_nir.h @@ -24,6 +24,6 @@ bool agx_nir_lower_subgroups(struct nir_shader *s); bool agx_nir_lower_fminmax(struct nir_shader *s); bool agx_nir_lower_texture_early(struct nir_shader *s, bool support_lod_bias); -bool agx_nir_lower_texture(struct nir_shader *s, bool support_rgb32); +bool agx_nir_lower_texture(struct nir_shader *s); bool agx_nir_lower_multisampled_image_store(struct nir_shader *s); bool agx_nir_needs_texture_crawl(struct nir_instr *instr); diff --git a/src/asahi/compiler/agx_nir_lower_texture.c b/src/asahi/compiler/agx_nir_lower_texture.c index ee680bf2707..bde9f06d5f5 100644 --- a/src/asahi/compiler/agx_nir_lower_texture.c +++ b/src/asahi/compiler/agx_nir_lower_texture.c @@ -131,7 +131,7 @@ coords_for_buffer_texture(nir_builder *b, nir_def *coord) * return txf(texture_as_2d, vec2(x % 1024, x / 1024)); */ static bool -lower_buffer_texture(nir_builder *b, nir_tex_instr *tex, bool support_rgb32) +lower_buffer_texture(nir_builder *b, nir_tex_instr *tex) { nir_def *coord = nir_steal_tex_src(tex, nir_tex_src_coord); nir_def *size = nir_get_texture_size(b, tex); @@ -151,19 +151,14 @@ lower_buffer_texture(nir_builder *b, nir_tex_instr *tex, bool support_rgb32) /* Lower RGB32 reads if the format requires. If we are out-of-bounds, we use * the hardware path so we get a zero texel. */ - nir_if *nif = NULL; - nir_def *rgb32 = NULL; - if (support_rgb32) { - nif = nir_push_if( - b, nir_iand(b, libagx_texture_is_rgb32(b, desc), nir_inot(b, oob))); + nir_if *nif = nir_push_if( + b, nir_iand(b, libagx_texture_is_rgb32(b, desc), nir_inot(b, oob))); - rgb32 = nir_trim_vector( - b, - libagx_texture_load_rgb32(b, desc, coord, nir_imm_bool(b, is_float)), - nir_tex_instr_dest_size(tex)); + nir_def *rgb32 = nir_trim_vector( + b, libagx_texture_load_rgb32(b, desc, coord, nir_imm_bool(b, is_float)), + nir_tex_instr_dest_size(tex)); - nir_push_else(b, nif); - } + nir_push_else(b, nif); /* Otherwise, lower the texture instruction to read from 2D */ assert(coord->num_components == 1 && "buffer textures are 1D"); @@ -175,19 +170,15 @@ lower_buffer_texture(nir_builder *b, nir_tex_instr *tex, bool support_rgb32) nir_tex_instr_add_src(tex, nir_tex_src_backend1, coord2d); nir_steal_tex_src(tex, nir_tex_src_sampler_handle); nir_steal_tex_src(tex, nir_tex_src_sampler_offset); + nir_block *else_block = nir_cursor_current_block(b->cursor); + nir_pop_if(b, nif); - if (support_rgb32) { - nir_block *else_block = nir_cursor_current_block(b->cursor); - nir_pop_if(b, nif); - - /* Put it together with a phi */ - nir_def *phi = nir_if_phi(b, rgb32, &tex->def); - nir_def_rewrite_uses(&tex->def, phi); - nir_phi_instr *phi_instr = nir_instr_as_phi(phi->parent_instr); - nir_phi_src *else_src = nir_phi_get_src_from_block(phi_instr, else_block); - nir_src_rewrite(&else_src->src, &tex->def); - } - + /* Put it together with a phi */ + nir_def *phi = nir_if_phi(b, rgb32, &tex->def); + nir_def_rewrite_uses(&tex->def, phi); + nir_phi_instr *phi_instr = nir_instr_as_phi(phi->parent_instr); + nir_phi_src *else_src = nir_phi_get_src_from_block(phi_instr, else_block); + nir_src_rewrite(&else_src->src, &tex->def); return true; } @@ -199,7 +190,6 @@ lower_buffer_texture(nir_builder *b, nir_tex_instr *tex, bool support_rgb32) static bool lower_regular_texture(nir_builder *b, nir_instr *instr, UNUSED void *data) { - bool *support_rgb32 = data; if (instr->type != nir_instr_type_tex) return false; @@ -210,7 +200,7 @@ lower_regular_texture(nir_builder *b, nir_instr *instr, UNUSED void *data) return false; if (tex->sampler_dim == GLSL_SAMPLER_DIM_BUF) - return lower_buffer_texture(b, tex, *support_rgb32); + return lower_buffer_texture(b, tex); /* Don't lower twice */ if (nir_tex_instr_src_index(tex, nir_tex_src_backend1) >= 0) @@ -756,7 +746,7 @@ agx_nir_lower_texture_early(nir_shader *s, bool support_lod_bias) } bool -agx_nir_lower_texture(nir_shader *s, bool support_rgb32) +agx_nir_lower_texture(nir_shader *s) { bool progress = false; @@ -793,7 +783,7 @@ agx_nir_lower_texture(nir_shader *s, bool support_rgb32) * generates txs for array textures). */ NIR_PASS(progress, s, nir_shader_instructions_pass, lower_regular_texture, - nir_metadata_none, &support_rgb32); + nir_metadata_none, NULL); NIR_PASS(progress, s, nir_shader_instructions_pass, lower_tex_crawl, nir_metadata_control_flow, NULL); diff --git a/src/asahi/lib/agx_bg_eot.c b/src/asahi/lib/agx_bg_eot.c index 6947829ac55..f3a52d52b56 100644 --- a/src/asahi/lib/agx_bg_eot.c +++ b/src/asahi/lib/agx_bg_eot.c @@ -32,14 +32,14 @@ agx_compile_bg_eot_shader(struct agx_bg_eot_cache *cache, nir_shader *shader, struct agx_shader_key *key, struct agx_tilebuffer_layout *tib) { - agx_nir_lower_texture(shader, false); + agx_nir_lower_texture(shader); agx_preprocess_nir(shader, cache->dev->libagx); if (tib) { unsigned bindless_base = 0; agx_nir_lower_tilebuffer(shader, tib, NULL, &bindless_base, NULL, NULL); agx_nir_lower_monolithic_msaa(shader, tib->nr_samples); agx_nir_lower_multisampled_image_store(shader); - agx_nir_lower_texture(shader, false); + agx_nir_lower_texture(shader); nir_shader_intrinsics_pass(shader, lower_tex_handle_to_u0, nir_metadata_control_flow, NULL); diff --git a/src/asahi/lib/agx_nir_prolog_epilog.c b/src/asahi/lib/agx_nir_prolog_epilog.c index 0db1f33648a..c2f18288971 100644 --- a/src/asahi/lib/agx_nir_prolog_epilog.c +++ b/src/asahi/lib/agx_nir_prolog_epilog.c @@ -436,7 +436,7 @@ agx_nir_fs_epilog(nir_builder *b, const void *key_) unsigned rt_spill = key->link.rt_spill_base; NIR_PASS(_, b->shader, agx_nir_lower_tilebuffer, &tib, colormasks, &rt_spill, write_samples, &force_translucent); - NIR_PASS(_, b->shader, agx_nir_lower_texture, false); + NIR_PASS(_, b->shader, agx_nir_lower_texture); NIR_PASS(_, b->shader, agx_nir_lower_multisampled_image_store); /* If the API shader runs once per sample, then the epilog runs once per diff --git a/src/asahi/vulkan/hk_buffer_view.c b/src/asahi/vulkan/hk_buffer_view.c index 60586288f6b..37344e672e1 100644 --- a/src/asahi/vulkan/hk_buffer_view.c +++ b/src/asahi/vulkan/hk_buffer_view.c @@ -36,13 +36,11 @@ hk_get_buffer_format_features(struct hk_physical_device *pdev, if (ail_pixel_format[p_format].texturable && !util_format_is_depth_or_stencil(p_format)) { - /* Only power-of-two supported by hardware. We have common RGB32 emulation - * code for GL, but we don't want to use it for VK as it has a performance - * cost on every buffer view load. - */ + features |= VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT; + + /* RGB32 specially supported for uniform texel buffers only. */ if (util_is_power_of_two_nonzero(util_format_get_blocksize(p_format))) { - features |= VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT | - VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT | + features |= VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT | VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT; } diff --git a/src/asahi/vulkan/hk_shader.c b/src/asahi/vulkan/hk_shader.c index d82493c7ac7..99647b993ae 100644 --- a/src/asahi/vulkan/hk_shader.c +++ b/src/asahi/vulkan/hk_shader.c @@ -724,7 +724,7 @@ hk_lower_nir(struct hk_device *dev, nir_shader *nir, nir_metadata_control_flow, NULL); } - NIR_PASS(_, nir, agx_nir_lower_texture, false); + NIR_PASS(_, nir, agx_nir_lower_texture); NIR_PASS(_, nir, agx_nir_lower_multisampled_image_store); agx_preprocess_nir(nir, dev->dev.libagx); diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index ba8077b421e..afa454c740a 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -1874,7 +1874,7 @@ agx_shader_initialize(struct agx_device *dev, struct agx_uncompiled_shader *so, .callback = agx_mem_vectorize_cb, }); - NIR_PASS(_, nir, agx_nir_lower_texture, true); + NIR_PASS(_, nir, agx_nir_lower_texture); NIR_PASS(_, nir, nir_lower_ssbo, NULL); agx_preprocess_nir(nir, dev->libagx); @@ -2643,7 +2643,7 @@ agx_build_meta_shader_internal(struct agx_context *ctx, nir_address_format_62bit_generic); agx_preprocess_nir(b.shader, NULL); - NIR_PASS(_, b.shader, agx_nir_lower_texture, true); + NIR_PASS(_, b.shader, agx_nir_lower_texture); NIR_PASS(_, b.shader, agx_nir_lower_multisampled_image_store); }