intel/compiler: Use a struct for brw_compile_bs parameters

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14139>
This commit is contained in:
Caio Oliveira 2021-03-23 21:21:40 -07:00 committed by Marge Bot
parent 58c4a95320
commit 2ad11b39bd
3 changed files with 58 additions and 30 deletions

View file

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

View file

@ -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, &params->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,
&params->error_str);
if (simd_size == 0)
return NULL;

View file

@ -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, &params);
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, &params);
device->rt_trivial_return =
anv_device_upload_kernel(device, &device->default_pipeline_cache,