mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-20 23:00:36 +02:00
intel/blorp: Set nir_shader::options up-front before building
Previously, we left it NULL until later in the compile. However, some builder helpers are starting to check the options and they blow up when options == NULL. Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27617>
This commit is contained in:
parent
073e69c7dc
commit
4a84725ebb
6 changed files with 35 additions and 17 deletions
|
|
@ -1195,7 +1195,7 @@ blorp_build_nir_shader(struct blorp_context *blorp,
|
|||
key->base.shader_pipeline == BLORP_SHADER_PIPELINE_COMPUTE;
|
||||
gl_shader_stage stage =
|
||||
compute ? MESA_SHADER_COMPUTE : MESA_SHADER_FRAGMENT;
|
||||
blorp_nir_init_shader(&b, mem_ctx, stage, NULL);
|
||||
blorp_nir_init_shader(&b, blorp, mem_ctx, stage, NULL);
|
||||
|
||||
struct blorp_blit_vars v;
|
||||
blorp_blit_vars_init(&b, &v, key);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,14 @@
|
|||
#include "compiler/brw_nir.h"
|
||||
#include "dev/intel_debug.h"
|
||||
|
||||
static const nir_shader_compiler_options *
|
||||
blorp_nir_options_brw(struct blorp_context *blorp,
|
||||
gl_shader_stage stage)
|
||||
{
|
||||
const struct brw_compiler *compiler = blorp->compiler->brw;
|
||||
return compiler->nir_options[stage];
|
||||
}
|
||||
|
||||
static struct blorp_program
|
||||
blorp_compile_fs_brw(struct blorp_context *blorp, void *mem_ctx,
|
||||
struct nir_shader *nir,
|
||||
|
|
@ -16,7 +24,6 @@ blorp_compile_fs_brw(struct blorp_context *blorp, void *mem_ctx,
|
|||
bool use_repclear)
|
||||
{
|
||||
const struct brw_compiler *compiler = blorp->compiler->brw;
|
||||
nir->options = compiler->nir_options[MESA_SHADER_FRAGMENT];
|
||||
|
||||
struct brw_wm_prog_data *wm_prog_data = rzalloc(mem_ctx, struct brw_wm_prog_data);
|
||||
wm_prog_data->base.nr_params = 0;
|
||||
|
|
@ -61,8 +68,6 @@ blorp_compile_vs_brw(struct blorp_context *blorp, void *mem_ctx,
|
|||
{
|
||||
const struct brw_compiler *compiler = blorp->compiler->brw;
|
||||
|
||||
nir->options = compiler->nir_options[MESA_SHADER_VERTEX];
|
||||
|
||||
struct brw_nir_compiler_opts opts = {};
|
||||
brw_preprocess_nir(compiler, nir, &opts);
|
||||
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
|
||||
|
|
@ -116,8 +121,6 @@ blorp_compile_cs_brw(struct blorp_context *blorp, void *mem_ctx,
|
|||
{
|
||||
const struct brw_compiler *compiler = blorp->compiler->brw;
|
||||
|
||||
nir->options = compiler->nir_options[MESA_SHADER_COMPUTE];
|
||||
|
||||
struct brw_nir_compiler_opts opts = {};
|
||||
brw_preprocess_nir(compiler, nir, &opts);
|
||||
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
|
||||
|
|
@ -200,7 +203,7 @@ blorp_params_get_layer_offset_vs_brw(struct blorp_batch *batch,
|
|||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
nir_builder b;
|
||||
blorp_nir_init_shader(&b, mem_ctx, MESA_SHADER_VERTEX,
|
||||
blorp_nir_init_shader(&b, blorp, mem_ctx, MESA_SHADER_VERTEX,
|
||||
blorp_shader_type_to_name(blorp_key.base.shader_type));
|
||||
|
||||
const struct glsl_type *uvec4_type = glsl_vector_type(GLSL_TYPE_UINT, 4);
|
||||
|
|
@ -267,6 +270,7 @@ blorp_init_brw(struct blorp_context *blorp, void *driver_ctx,
|
|||
assert(brw);
|
||||
|
||||
blorp->compiler->brw = brw;
|
||||
blorp->compiler->nir_options = blorp_nir_options_brw;
|
||||
blorp->compiler->compile_fs = blorp_compile_fs_brw;
|
||||
blorp->compiler->compile_vs = blorp_compile_vs_brw;
|
||||
blorp->compiler->compile_cs = blorp_compile_cs_brw;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ blorp_params_get_clear_kernel_fs(struct blorp_batch *batch,
|
|||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
nir_builder b;
|
||||
blorp_nir_init_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT,
|
||||
blorp_nir_init_shader(&b, blorp, mem_ctx, MESA_SHADER_FRAGMENT,
|
||||
blorp_shader_type_to_name(blorp_key.base.shader_type));
|
||||
|
||||
nir_variable *v_color =
|
||||
|
|
@ -133,7 +133,8 @@ blorp_params_get_clear_kernel_cs(struct blorp_batch *batch,
|
|||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
nir_builder b;
|
||||
blorp_nir_init_shader(&b, mem_ctx, MESA_SHADER_COMPUTE, "BLORP-gpgpu-clear");
|
||||
blorp_nir_init_shader(&b, blorp, mem_ctx, MESA_SHADER_COMPUTE,
|
||||
"BLORP-gpgpu-clear");
|
||||
blorp_set_cs_dims(b.shader, blorp_key.local_y);
|
||||
|
||||
nir_def *dst_pos = nir_load_global_invocation_id(&b, 32);
|
||||
|
|
@ -1296,7 +1297,7 @@ blorp_params_get_mcs_partial_resolve_kernel(struct blorp_batch *batch,
|
|||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
nir_builder b;
|
||||
blorp_nir_init_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT,
|
||||
blorp_nir_init_shader(&b, blorp, mem_ctx, MESA_SHADER_FRAGMENT,
|
||||
blorp_shader_type_to_name(blorp_key.base.shader_type));
|
||||
|
||||
nir_variable *v_color =
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@
|
|||
#include "compiler/intel_nir.h"
|
||||
#include "dev/intel_debug.h"
|
||||
|
||||
static const nir_shader_compiler_options *
|
||||
blorp_nir_options_elk(struct blorp_context *blorp,
|
||||
gl_shader_stage stage)
|
||||
{
|
||||
const struct elk_compiler *compiler = blorp->compiler->elk;
|
||||
return compiler->nir_options[stage];
|
||||
}
|
||||
|
||||
static struct blorp_program
|
||||
blorp_compile_fs_elk(struct blorp_context *blorp, void *mem_ctx,
|
||||
struct nir_shader *nir,
|
||||
|
|
@ -17,7 +25,6 @@ blorp_compile_fs_elk(struct blorp_context *blorp, void *mem_ctx,
|
|||
bool use_repclear)
|
||||
{
|
||||
const struct elk_compiler *compiler = blorp->compiler->elk;
|
||||
nir->options = compiler->nir_options[MESA_SHADER_FRAGMENT];
|
||||
|
||||
struct elk_wm_prog_data *wm_prog_data = rzalloc(mem_ctx, struct elk_wm_prog_data);
|
||||
wm_prog_data->base.nr_params = 0;
|
||||
|
|
@ -69,8 +76,6 @@ blorp_compile_vs_elk(struct blorp_context *blorp, void *mem_ctx,
|
|||
{
|
||||
const struct elk_compiler *compiler = blorp->compiler->elk;
|
||||
|
||||
nir->options = compiler->nir_options[MESA_SHADER_VERTEX];
|
||||
|
||||
struct elk_nir_compiler_opts opts = {};
|
||||
elk_preprocess_nir(compiler, nir, &opts);
|
||||
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
|
||||
|
|
@ -124,8 +129,6 @@ blorp_compile_cs_elk(struct blorp_context *blorp, void *mem_ctx,
|
|||
{
|
||||
const struct elk_compiler *compiler = blorp->compiler->elk;
|
||||
|
||||
nir->options = compiler->nir_options[MESA_SHADER_COMPUTE];
|
||||
|
||||
struct elk_nir_compiler_opts opts = {};
|
||||
elk_preprocess_nir(compiler, nir, &opts);
|
||||
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
|
||||
|
|
@ -272,7 +275,7 @@ blorp_params_get_layer_offset_vs_elk(struct blorp_batch *batch,
|
|||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
nir_builder b;
|
||||
blorp_nir_init_shader(&b, mem_ctx, MESA_SHADER_VERTEX,
|
||||
blorp_nir_init_shader(&b, blorp, mem_ctx, MESA_SHADER_VERTEX,
|
||||
blorp_shader_type_to_name(blorp_key.base.shader_type));
|
||||
|
||||
const struct glsl_type *uvec4_type = glsl_vector_type(GLSL_TYPE_UINT, 4);
|
||||
|
|
@ -339,6 +342,7 @@ blorp_init_elk(struct blorp_context *blorp, void *driver_ctx,
|
|||
assert(elk);
|
||||
|
||||
blorp->compiler->elk = elk;
|
||||
blorp->compiler->nir_options = blorp_nir_options_elk;
|
||||
blorp->compiler->compile_fs = blorp_compile_fs_elk;
|
||||
blorp->compiler->compile_vs = blorp_compile_vs_elk;
|
||||
blorp->compiler->compile_cs = blorp_compile_cs_elk;
|
||||
|
|
|
|||
|
|
@ -22,14 +22,20 @@
|
|||
*/
|
||||
|
||||
#include "compiler/nir/nir_builder.h"
|
||||
#include "blorp_priv.h"
|
||||
|
||||
static inline void
|
||||
blorp_nir_init_shader(nir_builder *b,
|
||||
struct blorp_context *blorp,
|
||||
void *mem_ctx,
|
||||
gl_shader_stage stage,
|
||||
const char *name)
|
||||
{
|
||||
*b = nir_builder_init_simple_shader(stage, NULL, "%s", name ? name : "");
|
||||
const nir_shader_compiler_options *nir_options =
|
||||
blorp->compiler->nir_options(blorp, stage);
|
||||
|
||||
*b = nir_builder_init_simple_shader(stage, nir_options,
|
||||
"%s", name ? name : "");
|
||||
ralloc_steal(mem_ctx, b->shader);
|
||||
if (stage == MESA_SHADER_FRAGMENT)
|
||||
b->shader->info.fs.origin_upper_left = true;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ struct blorp_compiler {
|
|||
const struct brw_compiler *brw;
|
||||
const struct elk_compiler *elk;
|
||||
|
||||
const nir_shader_compiler_options *(*nir_options)(struct blorp_context *blorp,
|
||||
gl_shader_stage stage);
|
||||
|
||||
struct blorp_program (*compile_fs)(struct blorp_context *blorp, void *mem_ctx,
|
||||
struct nir_shader *nir,
|
||||
bool multisample_fbo,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue