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 <boris.brezillon@collabora.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8963>
This commit is contained in:
Boris Brezillon 2021-02-12 16:54:17 +01:00 committed by Marge Bot
parent 678f44447b
commit 10d9c4e574
4 changed files with 58 additions and 20 deletions

View File

@ -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 \

View File

@ -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',

View File

@ -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);
}

View File

@ -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