From 66b3879618d54e4c752b5807bf4df3ad9cf8c03a Mon Sep 17 00:00:00 2001 From: Konstantin Seurer Date: Tue, 5 Nov 2024 16:19:47 +0100 Subject: [PATCH] lavapipe: Move nir passes to a new directory The number of lavapipe nir passes keeps growing so it's a good idea to add some separation before it becomes a mess. Reviewed-by: Mike Blumenkrantz Part-of: --- .../lavapipe/lvp_lower_vulkan_resource.h | 36 ------------------- src/gallium/frontends/lavapipe/lvp_pipeline.c | 2 +- src/gallium/frontends/lavapipe/lvp_private.h | 8 +---- .../lavapipe/lvp_ray_tracing_pipeline.c | 5 +-- src/gallium/frontends/lavapipe/meson.build | 14 ++++---- .../{lvp_nir_ray_tracing.h => nir/lvp_nir.h} | 16 +++++++++ .../lvp_nir_lower_exec_graph.c} | 4 +-- .../lvp_nir_lower_input_attachments.c} | 4 +-- .../lvp_nir_lower_pipeline_layout.c} | 4 +-- .../{ => nir}/lvp_nir_lower_ray_queries.c | 5 +-- .../lvp_nir_lower_sparse_residency.c | 2 +- .../lavapipe/{ => nir}/lvp_nir_ray_tracing.c | 2 +- 12 files changed, 31 insertions(+), 71 deletions(-) delete mode 100644 src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.h rename src/gallium/frontends/lavapipe/{lvp_nir_ray_tracing.h => nir/lvp_nir.h} (85%) rename src/gallium/frontends/lavapipe/{lvp_lower_exec_graph.c => nir/lvp_nir_lower_exec_graph.c} (99%) rename src/gallium/frontends/lavapipe/{lvp_lower_input_attachments.c => nir/lvp_nir_lower_input_attachments.c} (97%) rename src/gallium/frontends/lavapipe/{lvp_lower_vulkan_resource.c => nir/lvp_nir_lower_pipeline_layout.c} (99%) rename src/gallium/frontends/lavapipe/{ => nir}/lvp_nir_lower_ray_queries.c (99%) rename src/gallium/frontends/lavapipe/{ => nir}/lvp_nir_lower_sparse_residency.c (96%) rename src/gallium/frontends/lavapipe/{ => nir}/lvp_nir_ray_tracing.c (99%) diff --git a/src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.h b/src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.h deleted file mode 100644 index af3aab72eec..00000000000 --- a/src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2019 Red Hat. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef LVP_LOWER_VULKAN_RESOURCE_H -#define LVP_LOWER_VULKAN_RESOURCE_H - -struct lvp_pipeline_layout; -struct lvp_device; -void lvp_lower_pipeline_layout(const struct lvp_device *device, - struct lvp_pipeline_layout *layout, - nir_shader *shader); - -bool -lvp_lower_input_attachments(nir_shader *shader, bool use_fragcoord_sysval); - -#endif diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c b/src/gallium/frontends/lavapipe/lvp_pipeline.c index 36f5278089c..47f5c4cd7c1 100644 --- a/src/gallium/frontends/lavapipe/lvp_pipeline.c +++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c @@ -31,7 +31,7 @@ #include "spirv/nir_spirv.h" #include "nir/nir_builder.h" #include "nir/nir_serialize.h" -#include "lvp_lower_vulkan_resource.h" +#include "nir/lvp_nir.h" #include "pipe/p_state.h" #include "pipe/p_context.h" #include "nir/nir_xfb_info.h" diff --git a/src/gallium/frontends/lavapipe/lvp_private.h b/src/gallium/frontends/lavapipe/lvp_private.h index d8307646810..d637c273e01 100644 --- a/src/gallium/frontends/lavapipe/lvp_private.h +++ b/src/gallium/frontends/lavapipe/lvp_private.h @@ -577,9 +577,6 @@ struct lvp_exec_graph_internal_data { struct lvp_exec_graph_shader_output outputs[LVP_MAX_EXEC_GRAPH_PAYLOADS]; }; -bool -lvp_lower_exec_graph(struct lvp_pipeline *pipeline, nir_shader *nir); - void lvp_pipeline_shaders_compile(struct lvp_pipeline *pipeline, bool locked); @@ -821,10 +818,7 @@ void lvp_inline_uniforms(nir_shader *nir, const struct lvp_shader *shader, const uint32_t *uniform_values, uint32_t ubo); void * lvp_shader_compile(struct lvp_device *device, struct lvp_shader *shader, nir_shader *nir, bool locked); -bool -lvp_nir_lower_ray_queries(struct nir_shader *shader); -bool -lvp_nir_lower_sparse_residency(struct nir_shader *shader); + enum vk_cmd_type lvp_nv_dgc_token_to_cmd_type(const VkIndirectCommandsLayoutTokenNV *token); diff --git a/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c b/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c index b395cc5017a..fb576ba5f86 100644 --- a/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c +++ b/src/gallium/frontends/lavapipe/lvp_ray_tracing_pipeline.c @@ -6,13 +6,10 @@ #include "lvp_private.h" #include "lvp_acceleration_structure.h" -#include "lvp_nir_ray_tracing.h" +#include "nir/lvp_nir.h" #include "vk_pipeline.h" -#include "nir.h" -#include "nir_builder.h" - #include "spirv/spirv.h" #include "util/mesa-sha1.h" diff --git a/src/gallium/frontends/lavapipe/meson.build b/src/gallium/frontends/lavapipe/meson.build index 06adc5aa8ca..e6b8fe32bdc 100644 --- a/src/gallium/frontends/lavapipe/meson.build +++ b/src/gallium/frontends/lavapipe/meson.build @@ -12,6 +12,12 @@ lvp_entrypoints = custom_target( ) liblvp_files = files( + 'nir/lvp_nir_lower_exec_graph.c', + 'nir/lvp_nir_lower_input_attachments.c', + 'nir/lvp_nir_lower_pipeline_layout.c', + 'nir/lvp_nir_lower_ray_queries.c', + 'nir/lvp_nir_lower_sparse_residency.c', + 'nir/lvp_nir_ray_tracing.c', 'lvp_acceleration_structure.c', 'lvp_device.c', 'lvp_device_generated_commands.c', @@ -22,14 +28,6 @@ liblvp_files = files( 'lvp_image.c', 'lvp_formats.c', 'lvp_inline_uniforms.c', - 'lvp_lower_exec_graph.c', - 'lvp_lower_vulkan_resource.c', - 'lvp_lower_vulkan_resource.h', - 'lvp_lower_input_attachments.c', - 'lvp_nir_lower_ray_queries.c', - 'lvp_nir_lower_sparse_residency.c', - 'lvp_nir_ray_tracing.c', - 'lvp_nir_ray_tracing.h', 'lvp_pipe_sync.c', 'lvp_pipeline.c', 'lvp_pipeline_cache.c', diff --git a/src/gallium/frontends/lavapipe/lvp_nir_ray_tracing.h b/src/gallium/frontends/lavapipe/nir/lvp_nir.h similarity index 85% rename from src/gallium/frontends/lavapipe/lvp_nir_ray_tracing.h rename to src/gallium/frontends/lavapipe/nir/lvp_nir.h index 18a9acfd6f1..a1d899dc2cc 100644 --- a/src/gallium/frontends/lavapipe/lvp_nir_ray_tracing.h +++ b/src/gallium/frontends/lavapipe/nir/lvp_nir.h @@ -102,4 +102,20 @@ struct lvp_ray_traversal_args { */ nir_def *lvp_build_ray_traversal(nir_builder *b, const struct lvp_ray_traversal_args *args); +struct lvp_device; +struct lvp_pipeline; +struct lvp_pipeline_layout; + +bool lvp_lower_exec_graph(struct lvp_pipeline *pipeline, nir_shader *nir); + +bool lvp_lower_input_attachments(nir_shader *shader, bool use_fragcoord_sysval); + +void lvp_lower_pipeline_layout(const struct lvp_device *device, + struct lvp_pipeline_layout *layout, + nir_shader *shader); + +bool lvp_nir_lower_ray_queries(struct nir_shader *shader); + +bool lvp_nir_lower_sparse_residency(struct nir_shader *shader); + #endif diff --git a/src/gallium/frontends/lavapipe/lvp_lower_exec_graph.c b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_exec_graph.c similarity index 99% rename from src/gallium/frontends/lavapipe/lvp_lower_exec_graph.c rename to src/gallium/frontends/lavapipe/nir/lvp_nir_lower_exec_graph.c index 5195121f21f..a6288ef2ae9 100644 --- a/src/gallium/frontends/lavapipe/lvp_lower_exec_graph.c +++ b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_exec_graph.c @@ -5,9 +5,7 @@ */ #include "lvp_private.h" - -#include "nir.h" -#include "nir_builder.h" +#include "lvp_nir.h" #define lvp_load_internal_field(b, bit_size, field) \ nir_load_ssbo(b, 1, bit_size, nir_imm_int(b, 0), \ diff --git a/src/gallium/frontends/lavapipe/lvp_lower_input_attachments.c b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_input_attachments.c similarity index 97% rename from src/gallium/frontends/lavapipe/lvp_lower_input_attachments.c rename to src/gallium/frontends/lavapipe/nir/lvp_nir_lower_input_attachments.c index 0788f9e7bbe..1c6d448e3e8 100644 --- a/src/gallium/frontends/lavapipe/lvp_lower_input_attachments.c +++ b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_input_attachments.c @@ -21,9 +21,7 @@ * IN THE SOFTWARE. */ -#include "nir.h" -#include "nir_builder.h" -#include "lvp_lower_vulkan_resource.h" +#include "lvp_nir.h" static nir_def * load_frag_coord(nir_builder *b) diff --git a/src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.c b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_pipeline_layout.c similarity index 99% rename from src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.c rename to src/gallium/frontends/lavapipe/nir/lvp_nir_lower_pipeline_layout.c index c70af17b62a..5769b2334fe 100644 --- a/src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.c +++ b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_pipeline_layout.c @@ -22,9 +22,7 @@ */ #include "lvp_private.h" -#include "nir.h" -#include "nir_builder.h" -#include "lvp_lower_vulkan_resource.h" +#include "lvp_nir.h" static bool lower_vulkan_resource_index(const nir_instr *instr, const void *data_cb) diff --git a/src/gallium/frontends/lavapipe/lvp_nir_lower_ray_queries.c b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_ray_queries.c similarity index 99% rename from src/gallium/frontends/lavapipe/lvp_nir_lower_ray_queries.c rename to src/gallium/frontends/lavapipe/nir/lvp_nir_lower_ray_queries.c index 1ae12238ddb..b956e2dce25 100644 --- a/src/gallium/frontends/lavapipe/lvp_nir_lower_ray_queries.c +++ b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_ray_queries.c @@ -3,10 +3,7 @@ * SPDX-License-Identifier: MIT */ -#include "nir/nir.h" -#include "nir/nir_builder.h" - -#include "lvp_nir_ray_tracing.h" +#include "lvp_nir.h" #include "lvp_acceleration_structure.h" #include "lvp_private.h" diff --git a/src/gallium/frontends/lavapipe/lvp_nir_lower_sparse_residency.c b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_sparse_residency.c similarity index 96% rename from src/gallium/frontends/lavapipe/lvp_nir_lower_sparse_residency.c rename to src/gallium/frontends/lavapipe/nir/lvp_nir_lower_sparse_residency.c index df611a7e39d..2608ab72410 100644 --- a/src/gallium/frontends/lavapipe/lvp_nir_lower_sparse_residency.c +++ b/src/gallium/frontends/lavapipe/nir/lvp_nir_lower_sparse_residency.c @@ -3,7 +3,7 @@ * SPDX-License-Identifier: MIT */ -#include "lvp_private.h" +#include "lvp_nir.h" #include "nir.h" #include "nir_builder.h" diff --git a/src/gallium/frontends/lavapipe/lvp_nir_ray_tracing.c b/src/gallium/frontends/lavapipe/nir/lvp_nir_ray_tracing.c similarity index 99% rename from src/gallium/frontends/lavapipe/lvp_nir_ray_tracing.c rename to src/gallium/frontends/lavapipe/nir/lvp_nir_ray_tracing.c index 635b8e31b67..3118674e36c 100644 --- a/src/gallium/frontends/lavapipe/lvp_nir_ray_tracing.c +++ b/src/gallium/frontends/lavapipe/nir/lvp_nir_ray_tracing.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -#include "lvp_nir_ray_tracing.h" +#include "lvp_nir.h" #include "lvp_acceleration_structure.h" #include "lvp_private.h"