mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 17:50:11 +01:00
panfrost: Add a panfrost_compile_shader() helper
This deduplicates the
if (pan_is_bifrost())
return bifrost_compile_shader_nir();
else
return midgard_compile_shader_nir();
pattern.
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8808>
This commit is contained in:
parent
89cfa4180b
commit
834bb5e54c
7 changed files with 67 additions and 29 deletions
|
|
@ -28,13 +28,12 @@
|
|||
#include <string.h>
|
||||
#include "pan_bo.h"
|
||||
#include "pan_context.h"
|
||||
#include "pan_shader.h"
|
||||
#include "pan_util.h"
|
||||
#include "panfrost-quirks.h"
|
||||
|
||||
#include "compiler/nir/nir.h"
|
||||
#include "nir/tgsi_to_nir.h"
|
||||
#include "midgard/midgard_compile.h"
|
||||
#include "bifrost/bifrost_compile.h"
|
||||
#include "util/u_dynarray.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
|
||||
|
|
@ -274,10 +273,7 @@ panfrost_shader_compile(struct panfrost_context *ctx,
|
|||
|
||||
panfrost_program *program;
|
||||
|
||||
if (pan_is_bifrost(dev))
|
||||
program = bifrost_compile_shader_nir(NULL, s, &inputs);
|
||||
else
|
||||
program = midgard_compile_shader_nir(NULL, s, &inputs);
|
||||
program = panfrost_compile_shader(dev, NULL, s, &inputs);
|
||||
|
||||
/* Prepare the compiled binary for upload */
|
||||
mali_ptr shader = 0;
|
||||
|
|
|
|||
|
|
@ -25,10 +25,9 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include "pan_blend_shaders.h"
|
||||
#include "pan_shader.h"
|
||||
#include "pan_util.h"
|
||||
#include "panfrost-quirks.h"
|
||||
#include "midgard/midgard_compile.h"
|
||||
#include "bifrost/bifrost_compile.h"
|
||||
#include "compiler/nir/nir_builder.h"
|
||||
#include "nir/nir_lower_blend.h"
|
||||
#include "panfrost/util/pan_lower_framebuffer.h"
|
||||
|
|
@ -301,11 +300,10 @@ panfrost_compile_blend_shader(struct panfrost_blend_shader *shader,
|
|||
if (pan_is_bifrost(dev)) {
|
||||
inputs.blend.bifrost_blend_desc =
|
||||
bifrost_get_blend_desc(dev, shader->key.format, shader->key.rt);
|
||||
program = bifrost_compile_shader_nir(NULL, shader->nir, &inputs);
|
||||
} else {
|
||||
program = midgard_compile_shader_nir(NULL, shader->nir, &inputs);
|
||||
}
|
||||
|
||||
program = panfrost_compile_shader(dev, NULL, shader->nir, &inputs);
|
||||
|
||||
/* Allow us to patch later */
|
||||
shader->first_tag = program->first_tag;
|
||||
shader->size = program->compiled.size;
|
||||
|
|
|
|||
|
|
@ -30,10 +30,9 @@
|
|||
#include "pan_cmdstream.h"
|
||||
#include "panfrost-quirks.h"
|
||||
#include "pan_bo.h"
|
||||
#include "pan_shader.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "nir_serialize.h"
|
||||
#include "midgard/midgard_compile.h"
|
||||
#include "bifrost/bifrost_compile.h"
|
||||
|
||||
/* Compute CSOs are tracked like graphics shader CSOs, but are
|
||||
* considerably simpler. We do not implement multiple
|
||||
|
|
@ -65,8 +64,7 @@ panfrost_create_compute_state(
|
|||
blob_reader_init(&reader, hdr->blob, hdr->num_bytes);
|
||||
|
||||
const struct nir_shader_compiler_options *options =
|
||||
pan_is_bifrost(dev) ?
|
||||
&bifrost_nir_options : &midgard_nir_options;
|
||||
panfrost_get_shader_options(dev);
|
||||
|
||||
so->cbase.prog = nir_deserialize(NULL, options, &reader);
|
||||
so->cbase.ir_type = PIPE_SHADER_IR_NIR;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include "drm-uapi/panfrost_drm.h"
|
||||
|
||||
#include "pan_bo.h"
|
||||
#include "pan_shader.h"
|
||||
#include "pan_screen.h"
|
||||
#include "pan_resource.h"
|
||||
#include "pan_public.h"
|
||||
|
|
@ -51,8 +52,6 @@
|
|||
#include "decode.h"
|
||||
|
||||
#include "pan_context.h"
|
||||
#include "midgard/midgard_compile.h"
|
||||
#include "bifrost/bifrost_compile.h"
|
||||
#include "panfrost-quirks.h"
|
||||
|
||||
static const struct debug_named_value panfrost_debug_options[] = {
|
||||
|
|
@ -764,10 +763,7 @@ panfrost_screen_get_compiler_options(struct pipe_screen *pscreen,
|
|||
enum pipe_shader_ir ir,
|
||||
enum pipe_shader_type shader)
|
||||
{
|
||||
if (pan_is_bifrost(pan_device(pscreen)))
|
||||
return &bifrost_nir_options;
|
||||
else
|
||||
return &midgard_nir_options;
|
||||
return panfrost_get_shader_options(pan_device(pscreen));
|
||||
}
|
||||
|
||||
struct pipe_screen *
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ lib_FILES := \
|
|||
lib/pan_pool.h \
|
||||
lib/pan_props.c \
|
||||
lib/pan_sampler.c \
|
||||
lib/pan_shader.h \
|
||||
lib/pan_scoreboard.c \
|
||||
lib/pan_scoreboard.h \
|
||||
lib/pan_tiler.c \
|
||||
|
|
|
|||
|
|
@ -28,11 +28,10 @@
|
|||
#include <stdio.h>
|
||||
#include "pan_encoder.h"
|
||||
#include "pan_pool.h"
|
||||
#include "pan_shader.h"
|
||||
#include "pan_scoreboard.h"
|
||||
#include "pan_texture.h"
|
||||
#include "panfrost-quirks.h"
|
||||
#include "../midgard/midgard_compile.h"
|
||||
#include "../bifrost/bifrost_compile.h"
|
||||
#include "compiler/nir/nir_builder.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
|
|
@ -107,12 +106,8 @@ panfrost_build_blit_shader(struct panfrost_device *dev,
|
|||
.gpu_id = dev->gpu_id,
|
||||
};
|
||||
|
||||
panfrost_program *program;
|
||||
|
||||
if (pan_is_bifrost(dev))
|
||||
program = bifrost_compile_shader_nir(NULL, shader, &inputs);
|
||||
else
|
||||
program = midgard_compile_shader_nir(NULL, shader, &inputs);
|
||||
panfrost_program *program =
|
||||
panfrost_compile_shader(dev, NULL, shader, &inputs);
|
||||
|
||||
ralloc_free(shader);
|
||||
return program;
|
||||
|
|
|
|||
54
src/panfrost/lib/pan_shader.h
Normal file
54
src/panfrost/lib/pan_shader.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PAN_SHADER_H__
|
||||
#define __PAN_SHADER_H__
|
||||
|
||||
#include "pan_device.h"
|
||||
#include "pan_shader.h"
|
||||
|
||||
#include "panfrost/midgard/midgard_compile.h"
|
||||
#include "panfrost/bifrost/bifrost_compile.h"
|
||||
|
||||
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;
|
||||
|
||||
return &midgard_nir_options;
|
||||
}
|
||||
|
||||
static inline 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);
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue