From: Boris Brezillon Date: Thu, 23 Sep 2021 16:02:41 +0000 (+0200) Subject: panvk: Add a dummy sampler for NIR tex operations that don't take one X-Git-Tag: upstream/22.3.5~11741 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9dc8382de8be8f8f899276d0d9f466335483f403;p=platform%2Fupstream%2Fmesa.git panvk: Add a dummy sampler for NIR tex operations that don't take one In the NIR domain, some texture operations don't require a sampler, but Bifrost/Midgard always want one. Let's add a dummy sampler to handle that case. Signed-off-by: Boris Brezillon Reviewed-by: Jason Ekstrand Part-of: --- diff --git a/src/panfrost/vulkan/panvk_descriptor_set.c b/src/panfrost/vulkan/panvk_descriptor_set.c index 7240dd1..cdf9874 100644 --- a/src/panfrost/vulkan/panvk_descriptor_set.c +++ b/src/panfrost/vulkan/panvk_descriptor_set.c @@ -340,6 +340,15 @@ panvk_CreatePipelineLayout(VkDevice _device, layout->num_dyn_ssbos = dyn_ssbo_idx; layout->num_imgs = img_idx; + /* Some NIR texture operations don't require a sampler, but Bifrost/Midgard + * ones always expect one. Add a dummy sampler to deal with this limitation. + */ + if (layout->num_textures) { + layout->num_samplers++; + for (unsigned set = 0; set < pCreateInfo->setLayoutCount; set++) + layout->sets[set].sampler_offset++; + } + _mesa_sha1_final(&ctx, layout->sha1); *pPipelineLayout = panvk_pipeline_layout_to_handle(layout); diff --git a/src/panfrost/vulkan/panvk_vX_cmd_buffer.c b/src/panfrost/vulkan/panvk_vX_cmd_buffer.c index fbfe088..869d84a 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_buffer.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_buffer.c @@ -492,6 +492,18 @@ panvk_cmd_prepare_samplers(struct panvk_cmd_buffer *cmdbuf, void *sampler = samplers.cpu; + /* Prepare the dummy sampler */ + pan_pack(sampler, SAMPLER, cfg) { +#if PAN_ARCH >= 6 + cfg.seamless_cube_map = false; +#endif + cfg.magnify_nearest = true; + cfg.minify_nearest = true; + cfg.normalized_coordinates = false; + } + + sampler += pan_size(SAMPLER); + for (unsigned i = 0; i < ARRAY_SIZE(desc_state->sets); i++) { if (!desc_state->sets[i]) continue;