mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
v3dv: make nir helpers receive nir compiler options from caller
We are about to make a change that will make compiler options depend on v3d version, so helpers would usually need additional parameters to retrieve them. Isntead of doing this, we will make the callers get the options instead and provide them to the helpers. Reviewed-by: Juan A. Suarez <jasuarez@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30086>
This commit is contained in:
parent
d3a684803d
commit
5b1e88760a
5 changed files with 71 additions and 50 deletions
|
|
@ -27,9 +27,8 @@
|
|||
#include "vk_common_entrypoints.h"
|
||||
|
||||
static nir_shader *
|
||||
get_set_event_cs()
|
||||
get_set_event_cs(const nir_shader_compiler_options *options)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, options,
|
||||
"set event cs");
|
||||
|
||||
|
|
@ -52,9 +51,8 @@ get_set_event_cs()
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_wait_event_cs()
|
||||
get_wait_event_cs(const nir_shader_compiler_options *options)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, options,
|
||||
"wait event cs");
|
||||
|
||||
|
|
@ -137,8 +135,11 @@ create_event_pipelines(struct v3dv_device *device)
|
|||
|
||||
VkPipeline pipeline;
|
||||
|
||||
const nir_shader_compiler_options *options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
|
||||
if (!device->events.set_event_pipeline) {
|
||||
nir_shader *set_event_cs_nir = get_set_event_cs();
|
||||
nir_shader *set_event_cs_nir = get_set_event_cs(options);
|
||||
result = v3dv_create_compute_pipeline_from_nir(device,
|
||||
set_event_cs_nir,
|
||||
device->events.pipeline_layout,
|
||||
|
|
@ -151,7 +152,7 @@ create_event_pipelines(struct v3dv_device *device)
|
|||
}
|
||||
|
||||
if (!device->events.wait_event_pipeline) {
|
||||
nir_shader *wait_event_cs_nir = get_wait_event_cs();
|
||||
nir_shader *wait_event_cs_nir = get_wait_event_cs(options);
|
||||
result = v3dv_create_compute_pipeline_from_nir(device,
|
||||
wait_event_cs_nir,
|
||||
device->events.pipeline_layout,
|
||||
|
|
|
|||
|
|
@ -323,9 +323,8 @@ v3dv_meta_clear_finish(struct v3dv_device *device)
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_clear_rect_vs()
|
||||
get_clear_rect_vs(const nir_shader_compiler_options *options)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_VERTEX, options,
|
||||
"meta clear vs");
|
||||
|
||||
|
|
@ -341,7 +340,8 @@ get_clear_rect_vs()
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_clear_rect_gs(uint32_t push_constant_layer_base)
|
||||
get_clear_rect_gs(const nir_shader_compiler_options *options,
|
||||
uint32_t push_constant_layer_base)
|
||||
{
|
||||
/* FIXME: this creates a geometry shader that takes the index of a single
|
||||
* layer to clear from push constants, so we need to emit a draw call for
|
||||
|
|
@ -350,7 +350,6 @@ get_clear_rect_gs(uint32_t push_constant_layer_base)
|
|||
* however, if we were to do this we would need to be careful not to exceed
|
||||
* the maximum number of output vertices allowed in a geometry shader.
|
||||
*/
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_GEOMETRY, options,
|
||||
"meta clear gs");
|
||||
nir_shader *nir = b.shader;
|
||||
|
|
@ -405,9 +404,9 @@ get_clear_rect_gs(uint32_t push_constant_layer_base)
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_color_clear_rect_fs(uint32_t rt_idx, VkFormat format)
|
||||
get_color_clear_rect_fs(const nir_shader_compiler_options *options,
|
||||
uint32_t rt_idx, VkFormat format)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_FRAGMENT, options,
|
||||
"meta clear fs");
|
||||
|
||||
|
|
@ -426,9 +425,8 @@ get_color_clear_rect_fs(uint32_t rt_idx, VkFormat format)
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_depth_clear_rect_fs()
|
||||
get_depth_clear_rect_fs(const nir_shader_compiler_options *options)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_FRAGMENT, options,
|
||||
"meta depth clear fs");
|
||||
|
||||
|
|
@ -583,9 +581,12 @@ create_color_clear_pipeline(struct v3dv_device *device,
|
|||
VkPipelineLayout pipeline_layout,
|
||||
VkPipeline *pipeline)
|
||||
{
|
||||
nir_shader *vs_nir = get_clear_rect_vs();
|
||||
nir_shader *fs_nir = get_color_clear_rect_fs(rt_idx, format);
|
||||
nir_shader *gs_nir = is_layered ? get_clear_rect_gs(16) : NULL;
|
||||
const nir_shader_compiler_options *options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
|
||||
nir_shader *vs_nir = get_clear_rect_vs(options);
|
||||
nir_shader *fs_nir = get_color_clear_rect_fs(options, rt_idx, format);
|
||||
nir_shader *gs_nir = is_layered ? get_clear_rect_gs(options, 16) : NULL;
|
||||
|
||||
const VkPipelineVertexInputStateCreateInfo vi_state = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||
|
|
@ -645,9 +646,12 @@ create_depth_clear_pipeline(struct v3dv_device *device,
|
|||
const bool has_stencil = aspects & VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
assert(has_depth || has_stencil);
|
||||
|
||||
nir_shader *vs_nir = get_clear_rect_vs();
|
||||
nir_shader *fs_nir = has_depth ? get_depth_clear_rect_fs() : NULL;
|
||||
nir_shader *gs_nir = is_layered ? get_clear_rect_gs(4) : NULL;
|
||||
const nir_shader_compiler_options *options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
|
||||
nir_shader *vs_nir = get_clear_rect_vs(options);
|
||||
nir_shader *fs_nir = has_depth ? get_depth_clear_rect_fs(options) : NULL;
|
||||
nir_shader *gs_nir = is_layered ? get_clear_rect_gs(options, 4) : NULL;
|
||||
|
||||
const VkPipelineVertexInputStateCreateInfo vi_state = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||
|
|
|
|||
|
|
@ -2210,9 +2210,8 @@ create_pipeline(struct v3dv_device *device,
|
|||
VkPipeline *pipeline);
|
||||
|
||||
static nir_shader *
|
||||
get_texel_buffer_copy_vs()
|
||||
get_texel_buffer_copy_vs(const nir_shader_compiler_options *options)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_VERTEX, options,
|
||||
"meta texel buffer copy vs");
|
||||
nir_variable *vs_out_pos =
|
||||
|
|
@ -2227,7 +2226,7 @@ get_texel_buffer_copy_vs()
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_texel_buffer_copy_gs()
|
||||
get_texel_buffer_copy_gs(const nir_shader_compiler_options *options)
|
||||
{
|
||||
/* FIXME: this creates a geometry shader that takes the index of a single
|
||||
* layer to clear from push constants, so we need to emit a draw call for
|
||||
|
|
@ -2236,7 +2235,6 @@ get_texel_buffer_copy_gs()
|
|||
* be careful not to exceed the maximum number of output vertices allowed in
|
||||
* a geometry shader.
|
||||
*/
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_GEOMETRY, options,
|
||||
"meta texel buffer copy gs");
|
||||
nir_shader *nir = b.shader;
|
||||
|
|
@ -2325,10 +2323,9 @@ component_swizzle_to_nir_swizzle(VkComponentSwizzle comp, VkComponentSwizzle swz
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_texel_buffer_copy_fs(struct v3dv_device *device, VkFormat format,
|
||||
VkComponentMapping *cswizzle)
|
||||
get_texel_buffer_copy_fs(const nir_shader_compiler_options *options,
|
||||
VkFormat format, VkComponentMapping *cswizzle)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_FRAGMENT, options,
|
||||
"meta texel buffer copy fs");
|
||||
|
||||
|
|
@ -2433,9 +2430,12 @@ create_texel_buffer_copy_pipeline(struct v3dv_device *device,
|
|||
|
||||
assert(vk_format_is_color(format));
|
||||
|
||||
nir_shader *vs_nir = get_texel_buffer_copy_vs();
|
||||
nir_shader *fs_nir = get_texel_buffer_copy_fs(device, format, cswizzle);
|
||||
nir_shader *gs_nir = is_layered ? get_texel_buffer_copy_gs() : NULL;
|
||||
const nir_shader_compiler_options *options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
|
||||
nir_shader *vs_nir = get_texel_buffer_copy_vs(options);
|
||||
nir_shader *fs_nir = get_texel_buffer_copy_fs(options, format, cswizzle);
|
||||
nir_shader *gs_nir = is_layered ? get_texel_buffer_copy_gs(options) : NULL;
|
||||
|
||||
const VkPipelineVertexInputStateCreateInfo vi_state = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
|
||||
|
|
@ -3809,9 +3809,8 @@ build_nir_tex_op(struct nir_builder *b,
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_blit_vs()
|
||||
get_blit_vs(const nir_shader_compiler_options *options)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_VERTEX, options,
|
||||
"meta blit vs");
|
||||
|
||||
|
|
@ -3849,14 +3848,14 @@ get_channel_mask_for_sampler_dim(enum glsl_sampler_dim sampler_dim)
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_color_blit_fs(struct v3dv_device *device,
|
||||
get_color_blit_fs(const nir_shader_compiler_options *options,
|
||||
struct v3dv_device *device,
|
||||
VkFormat dst_format,
|
||||
VkFormat src_format,
|
||||
VkSampleCountFlagBits dst_samples,
|
||||
VkSampleCountFlagBits src_samples,
|
||||
enum glsl_sampler_dim sampler_dim)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_FRAGMENT, options,
|
||||
"meta blit fs");
|
||||
|
||||
|
|
@ -4094,12 +4093,15 @@ create_blit_pipeline(struct v3dv_device *device,
|
|||
assert(vk_format_is_color(dst_format));
|
||||
assert(vk_format_is_color(src_format));
|
||||
|
||||
const nir_shader_compiler_options *options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
|
||||
const enum glsl_sampler_dim sampler_dim =
|
||||
get_sampler_dim(src_type, src_samples);
|
||||
|
||||
nir_shader *vs_nir = get_blit_vs();
|
||||
nir_shader *vs_nir = get_blit_vs(options);
|
||||
nir_shader *fs_nir =
|
||||
get_color_blit_fs(device, dst_format, src_format,
|
||||
get_color_blit_fs(options, device, dst_format, src_format,
|
||||
dst_samples, src_samples, sampler_dim);
|
||||
|
||||
const VkPipelineVertexInputStateCreateInfo vi_state = {
|
||||
|
|
|
|||
|
|
@ -339,7 +339,9 @@ shader_module_compile_to_nir(struct v3dv_device *device,
|
|||
assert(stage->module || stage->module_info);
|
||||
|
||||
nir_shader *nir;
|
||||
const nir_shader_compiler_options *nir_options = &v3dv_nir_options;
|
||||
const nir_shader_compiler_options *nir_options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
|
||||
gl_shader_stage gl_stage = broadcom_shader_stage_to_gl(stage->stage);
|
||||
|
||||
if (V3D_DBG(DUMP_SPIRV)) {
|
||||
|
|
@ -1827,9 +1829,11 @@ pipeline_stage_get_nir(struct v3dv_pipeline_stage *p_stage,
|
|||
int64_t stage_start = os_time_get_nano();
|
||||
|
||||
nir_shader *nir = NULL;
|
||||
const nir_shader_compiler_options *nir_options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
|
||||
nir = v3dv_pipeline_cache_search_for_nir(pipeline, cache,
|
||||
&v3dv_nir_options,
|
||||
nir_options,
|
||||
p_stage->shader_sha1);
|
||||
|
||||
if (nir) {
|
||||
|
|
@ -2234,7 +2238,8 @@ pipeline_add_multiview_gs(struct v3dv_pipeline *pipeline,
|
|||
p_stage_vs->nir = pipeline_stage_get_nir(p_stage_vs, pipeline, cache);
|
||||
nir_shader *vs_nir = p_stage_vs->nir;
|
||||
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
const nir_shader_compiler_options *options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_GEOMETRY, options,
|
||||
"multiview broadcast gs");
|
||||
nir_shader *nir = b.shader;
|
||||
|
|
@ -2442,8 +2447,10 @@ pipeline_compile_graphics(struct v3dv_pipeline *pipeline,
|
|||
|
||||
/* Add a no-op fragment shader if needed */
|
||||
if (!pipeline->stages[BROADCOM_SHADER_FRAGMENT]) {
|
||||
const nir_shader_compiler_options *compiler_options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_FRAGMENT,
|
||||
&v3dv_nir_options,
|
||||
compiler_options,
|
||||
"noop_fs");
|
||||
|
||||
struct v3dv_pipeline_stage *p_stage =
|
||||
|
|
|
|||
|
|
@ -1078,7 +1078,8 @@ copy_pipeline_index_from_flags(VkQueryResultFlags flags)
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_copy_query_results_cs(VkQueryResultFlags flags);
|
||||
get_copy_query_results_cs(const nir_shader_compiler_options *compiler_options,
|
||||
VkQueryResultFlags flags);
|
||||
|
||||
static void
|
||||
cmd_buffer_emit_copy_query_pool_results(struct v3dv_cmd_buffer *cmd_buffer,
|
||||
|
|
@ -1095,7 +1096,10 @@ cmd_buffer_emit_copy_query_pool_results(struct v3dv_cmd_buffer *cmd_buffer,
|
|||
/* Create the required copy pipeline if not yet created */
|
||||
uint32_t pipeline_idx = copy_pipeline_index_from_flags(flags);
|
||||
if (!device->queries.copy_pipeline[pipeline_idx]) {
|
||||
nir_shader *copy_query_results_cs_nir = get_copy_query_results_cs(flags);
|
||||
const nir_shader_compiler_options *compiler_options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
nir_shader *copy_query_results_cs_nir =
|
||||
get_copy_query_results_cs(compiler_options, flags);
|
||||
VkResult result =
|
||||
v3dv_create_compute_pipeline_from_nir(
|
||||
device, copy_query_results_cs_nir,
|
||||
|
|
@ -1405,9 +1409,8 @@ nir_get_query_availability(nir_builder *b,
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_set_query_availability_cs()
|
||||
get_set_query_availability_cs(const nir_shader_compiler_options *options)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, options,
|
||||
"set query availability cs");
|
||||
|
||||
|
|
@ -1469,9 +1472,8 @@ nir_read_occlusion_counter(nir_builder *b,
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_reset_occlusion_query_cs()
|
||||
get_reset_occlusion_query_cs(const nir_shader_compiler_options *options)
|
||||
{
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, options,
|
||||
"reset occlusion query cs");
|
||||
|
||||
|
|
@ -1523,13 +1525,13 @@ write_query_buffer(nir_builder *b,
|
|||
}
|
||||
|
||||
static nir_shader *
|
||||
get_copy_query_results_cs(VkQueryResultFlags flags)
|
||||
get_copy_query_results_cs(const nir_shader_compiler_options *options,
|
||||
VkQueryResultFlags flags)
|
||||
{
|
||||
bool flag_64bit = flags & VK_QUERY_RESULT_64_BIT;
|
||||
bool flag_avail = flags & VK_QUERY_RESULT_WITH_AVAILABILITY_BIT;
|
||||
bool flag_partial = flags & VK_QUERY_RESULT_PARTIAL_BIT;
|
||||
|
||||
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
|
||||
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, options,
|
||||
"copy query results cs");
|
||||
|
||||
|
|
@ -1650,8 +1652,12 @@ create_query_pipelines(struct v3dv_device *device)
|
|||
return false;
|
||||
}
|
||||
|
||||
const nir_shader_compiler_options *compiler_options =
|
||||
v3dv_pipeline_get_nir_options();
|
||||
|
||||
if (!device->queries.avail_pipeline) {
|
||||
nir_shader *set_query_availability_cs_nir = get_set_query_availability_cs();
|
||||
nir_shader *set_query_availability_cs_nir =
|
||||
get_set_query_availability_cs(compiler_options);
|
||||
result = v3dv_create_compute_pipeline_from_nir(device,
|
||||
set_query_availability_cs_nir,
|
||||
device->queries.avail_pipeline_layout,
|
||||
|
|
@ -1692,7 +1698,8 @@ create_query_pipelines(struct v3dv_device *device)
|
|||
}
|
||||
|
||||
if (!device->queries.reset_occlusion_pipeline) {
|
||||
nir_shader *reset_occlusion_query_cs_nir = get_reset_occlusion_query_cs();
|
||||
nir_shader *reset_occlusion_query_cs_nir =
|
||||
get_reset_occlusion_query_cs(compiler_options);
|
||||
result = v3dv_create_compute_pipeline_from_nir(
|
||||
device,
|
||||
reset_occlusion_query_cs_nir,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue