From 10d9c4e5746c0cdacd86da10ac503393fab116fe Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 12 Feb 2021 16:54:17 +0100 Subject: [PATCH] panfrost: Hide backend compiler internals Move panfrost_compile_shader() and panfrost_get_shader_options() to pan_shader.c and drop the {bifrost,midgard}_compile.h include so backend compiler internals are not directly exposed to the gallium driver. Signed-off-by: Boris Brezillon Acked-by: Alyssa Rosenzweig Part-of: --- src/panfrost/Makefile.sources | 1 + src/panfrost/lib/meson.build | 1 + src/panfrost/lib/pan_shader.c | 49 +++++++++++++++++++++++++++++++++++ src/panfrost/lib/pan_shader.h | 27 +++++-------------- 4 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 src/panfrost/lib/pan_shader.c diff --git a/src/panfrost/Makefile.sources b/src/panfrost/Makefile.sources index ba1e258b842..71fc9b5e9ff 100644 --- a/src/panfrost/Makefile.sources +++ b/src/panfrost/Makefile.sources @@ -41,6 +41,7 @@ lib_FILES := \ lib/pan_props.c \ lib/pan_sampler.c \ lib/pan_samples.c \ + lib/pan_shader.c \ lib/pan_shader.h \ lib/pan_scoreboard.c \ lib/pan_scoreboard.h \ diff --git a/src/panfrost/lib/meson.build b/src/panfrost/lib/meson.build index 3a4235db2b0..a32b7de28da 100644 --- a/src/panfrost/lib/meson.build +++ b/src/panfrost/lib/meson.build @@ -32,6 +32,7 @@ libpanfrost_lib_files = files( 'pan_samples.c', 'pan_tiler.c', 'pan_texture.c', + 'pan_shader.c', 'pan_scoreboard.c', 'pan_scratch.c', 'pan_pool.c', diff --git a/src/panfrost/lib/pan_shader.c b/src/panfrost/lib/pan_shader.c new file mode 100644 index 00000000000..19d6be83e45 --- /dev/null +++ b/src/panfrost/lib/pan_shader.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2018 Alyssa Rosenzweig + * Copyright (C) 2019-2021 Collabora, Ltd. + * + * 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. + */ + +#include "pan_device.h" +#include "pan_shader.h" + +#include "panfrost/midgard/midgard_compile.h" +#include "panfrost/bifrost/bifrost_compile.h" + +const nir_shader_compiler_options * +panfrost_get_shader_options(const struct panfrost_device *dev) +{ + if (pan_is_bifrost(dev)) + return &bifrost_nir_options; + + return &midgard_nir_options; +} + +panfrost_program * +panfrost_compile_shader(const struct panfrost_device *dev, + void *mem_ctx, nir_shader *nir, + const struct panfrost_compile_inputs *inputs) +{ + if (pan_is_bifrost(dev)) + return bifrost_compile_shader_nir(mem_ctx, nir, inputs); + + return midgard_compile_shader_nir(mem_ctx, nir, inputs); +} diff --git a/src/panfrost/lib/pan_shader.h b/src/panfrost/lib/pan_shader.h index bf22f6e0a95..111c92ef5dd 100644 --- a/src/panfrost/lib/pan_shader.h +++ b/src/panfrost/lib/pan_shader.h @@ -25,30 +25,17 @@ #ifndef __PAN_SHADER_H__ #define __PAN_SHADER_H__ -#include "pan_device.h" -#include "pan_shader.h" +#include "compiler/nir/nir.h" +#include "panfrost/util/pan_ir.h" -#include "panfrost/midgard/midgard_compile.h" -#include "panfrost/bifrost/bifrost_compile.h" +struct panfrost_device; -static inline const nir_shader_compiler_options * -panfrost_get_shader_options(const struct panfrost_device *dev) -{ - if (pan_is_bifrost(dev)) - return &bifrost_nir_options; +const nir_shader_compiler_options * +panfrost_get_shader_options(const struct panfrost_device *dev); - return &midgard_nir_options; -} - -static inline panfrost_program * +panfrost_program * panfrost_compile_shader(const struct panfrost_device *dev, void *mem_ctx, nir_shader *nir, - const struct panfrost_compile_inputs *inputs) -{ - if (pan_is_bifrost(dev)) - return bifrost_compile_shader_nir(mem_ctx, nir, inputs); - - return midgard_compile_shader_nir(mem_ctx, nir, inputs); -} + const struct panfrost_compile_inputs *inputs); #endif