Mesa (main): intel/compiler: Use a struct for brw_compile_bs parameters
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Dec 13 01:29:01 UTC 2021
Module: Mesa
Branch: main
Commit: 2ad11b39bdb192bba105327a5448de9050c4eae4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ad11b39bdb192bba105327a5448de9050c4eae4
Author: Caio Oliveira <caio.oliveira at intel.com>
Date: Tue Mar 23 21:21:40 2021 -0700
intel/compiler: Use a struct for brw_compile_bs parameters
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14139>
---
src/intel/compiler/brw_compiler.h | 35 +++++++++++++++++++++++++----------
src/intel/compiler/brw_fs.cpp | 26 +++++++++++++-------------
src/intel/vulkan/anv_pipeline.c | 27 ++++++++++++++++++++-------
3 files changed, 58 insertions(+), 30 deletions(-)
diff --git a/src/intel/compiler/brw_compiler.h b/src/intel/compiler/brw_compiler.h
index b2e49a7d1cf..ac102553935 100644
--- a/src/intel/compiler/brw_compiler.h
+++ b/src/intel/compiler/brw_compiler.h
@@ -1787,20 +1787,35 @@ brw_compile_cs(const struct brw_compiler *compiler,
struct brw_compile_cs_params *params);
/**
- * Compile a Ray Tracing shader.
+ * Parameters for compiling a Bindless shader.
*
- * Returns the final assembly and the program's size.
+ * Some of these will be modified during the shader compilation.
+ */
+struct brw_compile_bs_params {
+ nir_shader *nir;
+
+ const struct brw_bs_prog_key *key;
+ struct brw_bs_prog_data *prog_data;
+
+ unsigned num_resume_shaders;
+ struct nir_shader **resume_shaders;
+
+ struct brw_compile_stats *stats;
+
+ void *log_data;
+
+ char *error_str;
+};
+
+/**
+ * Compile a Bindless shader.
+ *
+ * Returns the final assembly and updates the parameters structure.
*/
const unsigned *
-brw_compile_bs(const struct brw_compiler *compiler, void *log_data,
+brw_compile_bs(const struct brw_compiler *compiler,
void *mem_ctx,
- const struct brw_bs_prog_key *key,
- struct brw_bs_prog_data *prog_data,
- struct nir_shader *shader,
- unsigned num_resume_shaders,
- struct nir_shader **resume_shaders,
- struct brw_compile_stats *stats,
- char **error_str);
+ struct brw_compile_bs_params *params);
/**
* Compile a fixed function geometry shader.
diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp
index b5ab29095d3..41449b7a536 100644
--- a/src/intel/compiler/brw_fs.cpp
+++ b/src/intel/compiler/brw_fs.cpp
@@ -10163,22 +10163,20 @@ brw_bsr(const struct intel_device_info *devinfo,
}
const unsigned *
-brw_compile_bs(const struct brw_compiler *compiler, void *log_data,
+brw_compile_bs(const struct brw_compiler *compiler,
void *mem_ctx,
- const struct brw_bs_prog_key *key,
- struct brw_bs_prog_data *prog_data,
- nir_shader *shader,
- unsigned num_resume_shaders,
- struct nir_shader **resume_shaders,
- struct brw_compile_stats *stats,
- char **error_str)
+ struct brw_compile_bs_params *params)
{
+ nir_shader *shader = params->nir;
+ struct brw_bs_prog_data *prog_data = params->prog_data;
+ unsigned num_resume_shaders = params->num_resume_shaders;
+ nir_shader **resume_shaders = params->resume_shaders;
const bool debug_enabled = INTEL_DEBUG(DEBUG_RT);
prog_data->base.stage = shader->info.stage;
prog_data->max_stack_size = 0;
- fs_generator g(compiler, log_data, mem_ctx, &prog_data->base,
+ fs_generator g(compiler, params->log_data, mem_ctx, &prog_data->base,
false, shader->info.stage);
if (unlikely(debug_enabled)) {
char *name = ralloc_asprintf(mem_ctx, "%s %s shader %s",
@@ -10190,8 +10188,9 @@ brw_compile_bs(const struct brw_compiler *compiler, void *log_data,
}
prog_data->simd_size =
- compile_single_bs(compiler, log_data, mem_ctx, key, prog_data,
- shader, &g, stats, NULL, error_str);
+ compile_single_bs(compiler, params->log_data, mem_ctx,
+ params->key, prog_data,
+ shader, &g, params->stats, NULL, ¶ms->error_str);
if (prog_data->simd_size == 0)
return NULL;
@@ -10209,8 +10208,9 @@ brw_compile_bs(const struct brw_compiler *compiler, void *log_data,
/* TODO: Figure out shader stats etc. for resume shaders */
int offset = 0;
uint8_t simd_size =
- compile_single_bs(compiler, log_data, mem_ctx, key, prog_data,
- resume_shaders[i], &g, NULL, &offset, error_str);
+ compile_single_bs(compiler, params->log_data, mem_ctx, params->key,
+ prog_data, resume_shaders[i], &g, NULL, &offset,
+ ¶ms->error_str);
if (simd_size == 0)
return NULL;
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index dd57a31a906..08b4a495c62 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -2564,10 +2564,18 @@ compile_upload_rt_shader(struct anv_ray_tracing_pipeline *pipeline,
NIR_PASS_V(resume_shaders[i], brw_nir_lower_rt_intrinsics, devinfo);
}
- stage->code =
- brw_compile_bs(compiler, pipeline->base.device, mem_ctx,
- &stage->key.bs, &stage->prog_data.bs, nir,
- num_resume_shaders, resume_shaders, stage->stats, NULL);
+ struct brw_compile_bs_params params = {
+ .nir = nir,
+ .key = &stage->key.bs,
+ .prog_data = &stage->prog_data.bs,
+ .num_resume_shaders = num_resume_shaders,
+ .resume_shaders = resume_shaders,
+
+ .stats = stage->stats,
+ .log_data = pipeline->base.device,
+ };
+
+ stage->code = brw_compile_bs(compiler, mem_ctx, ¶ms);
if (stage->code == NULL)
return vk_error(pipeline, VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -3069,10 +3077,15 @@ anv_device_init_rt_shaders(struct anv_device *device)
.sampler_count = 0,
};
struct brw_bs_prog_data return_prog_data = { 0, };
+ struct brw_compile_bs_params params = {
+ .nir = trivial_return_nir,
+ .key = &return_key.key,
+ .prog_data = &return_prog_data,
+
+ .log_data = device,
+ };
const unsigned *return_data =
- brw_compile_bs(device->physical->compiler, device, tmp_ctx,
- &return_key.key, &return_prog_data, trivial_return_nir,
- 0, 0, NULL, NULL);
+ brw_compile_bs(device->physical->compiler, tmp_ctx, ¶ms);
device->rt_trivial_return =
anv_device_upload_kernel(device, &device->default_pipeline_cache,
More information about the mesa-commit
mailing list