From 165de87f8ed50b1f36dabd51528813f18a1dee82 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Wed, 4 Jan 2023 12:51:25 -0800 Subject: [PATCH] freedreno/ir3: Let driver specify fb-read descriptor Let the driver control where the shader should look for fb-read descriptor. Signed-off-by: Rob Clark Part-of: --- src/freedreno/ir3/ir3_compiler.h | 6 ++++++ src/freedreno/ir3/ir3_compiler_nir.c | 19 +++++++++++++++---- src/freedreno/vulkan/tu_device.c | 2 ++ .../drivers/freedreno/ir3/ir3_gallium.c | 7 +++++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/freedreno/ir3/ir3_compiler.h b/src/freedreno/ir3/ir3_compiler.h index baa405f5d99..f0b6dfbf750 100644 --- a/src/freedreno/ir3/ir3_compiler.h +++ b/src/freedreno/ir3/ir3_compiler.h @@ -55,6 +55,12 @@ struct ir3_compiler_options { * caching. */ bool disable_cache; + + /* If >= 0, this specifies the bindless descriptor set + descriptor to use + * for txf_ms_fb + */ + int bindless_fb_read_descriptor; + int bindless_fb_read_slot; }; struct ir3_compiler { diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 86baf0874ca..62861448214 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -3161,10 +3161,21 @@ emit_tex(struct ir3_context *ctx, nir_tex_instr *tex) compile_assert(ctx, ctx->so->type == MESA_SHADER_FRAGMENT); ctx->so->fb_read = true; - info.samp_tex = ir3_collect( - b, create_immed_typed(ctx->block, ctx->so->num_samp, TYPE_U16), - create_immed_typed(ctx->block, ctx->so->num_samp, TYPE_U16)); - info.flags = IR3_INSTR_S2EN; + if (ctx->compiler->options.bindless_fb_read_descriptor >= 0) { + ctx->so->bindless_tex = true; + + info.flags = IR3_INSTR_B | IR3_INSTR_A1EN; + info.base = ctx->compiler->options.bindless_fb_read_descriptor; + info.a1_val = ctx->compiler->options.bindless_fb_read_slot << 3; + } else { + /* Otherwise append a sampler to be patched into the texture + * state: + */ + info.samp_tex = ir3_collect( + b, create_immed_typed(ctx->block, ctx->so->num_samp, TYPE_U16), + create_immed_typed(ctx->block, ctx->so->num_samp, TYPE_U16)); + info.flags = IR3_INSTR_S2EN; + } ctx->so->num_samp++; } else { diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 11ef2ff5a53..abe8515dfa8 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -2119,6 +2119,8 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice, .robust_buffer_access2 = robust_buffer_access2, .push_ubo_with_preamble = true, .disable_cache = true, + .bindless_fb_read_descriptor = -1, + .bindless_fb_read_slot = -1, }); if (!device->compiler) { result = vk_startup_errorf(physical_device->instance, diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index 7b406ac1338..f7814753194 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -547,8 +547,11 @@ ir3_screen_init(struct pipe_screen *pscreen) { struct fd_screen *screen = fd_screen(pscreen); - screen->compiler = ir3_compiler_create(screen->dev, screen->dev_id, - &(struct ir3_compiler_options) {}); + struct ir3_compiler_options options = { + .bindless_fb_read_descriptor = -1, + .bindless_fb_read_slot = -1, + }; + screen->compiler = ir3_compiler_create(screen->dev, screen->dev_id, &options); /* TODO do we want to limit things to # of fast cores, or just limit * based on total # of both big and little cores. The little cores