nir_builder: Return a new builder from nir_builder_init_simple_shader().

It's a little inline function, so we can just RAII it for better
ergonomics.

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7323>
This commit is contained in:
Eric Anholt
2020-10-26 10:44:53 -07:00
parent 1aa1c1aec2
commit 4e9328e3b6
38 changed files with 87 additions and 150 deletions

View File

@@ -546,10 +546,9 @@ radv_meta_build_nir_vs_generate_vertices(void)
{ {
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b;
nir_variable *v_position; nir_variable *v_position;
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_vs_gen_verts"); b.shader->info.name = ralloc_strdup(b.shader, "meta_vs_gen_verts");
nir_ssa_def *outvec = radv_meta_gen_rect_vertices(&b); nir_ssa_def *outvec = radv_meta_gen_rect_vertices(&b);
@@ -566,9 +565,7 @@ radv_meta_build_nir_vs_generate_vertices(void)
nir_shader * nir_shader *
radv_meta_build_nir_fs_noop(void) radv_meta_build_nir_fs_noop(void)
{ {
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
b.shader->info.name = ralloc_asprintf(b.shader, b.shader->info.name = ralloc_asprintf(b.shader,
"meta_noop_fs"); "meta_noop_fs");

View File

@@ -42,9 +42,7 @@ static nir_shader *
build_nir_vertex_shader(void) build_nir_vertex_shader(void)
{ {
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_blit_vs"); b.shader->info.name = ralloc_strdup(b.shader, "meta_blit_vs");
nir_variable *pos_out = nir_variable_create(b.shader, nir_var_shader_out, nir_variable *pos_out = nir_variable_create(b.shader, nir_var_shader_out,
@@ -111,9 +109,7 @@ build_nir_copy_fragment_shader(enum glsl_sampler_dim tex_dim)
{ {
char shader_name[64]; char shader_name[64];
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
sprintf(shader_name, "meta_blit_fs.%d", tex_dim); sprintf(shader_name, "meta_blit_fs.%d", tex_dim);
b.shader->info.name = ralloc_strdup(b.shader, shader_name); b.shader->info.name = ralloc_strdup(b.shader, shader_name);
@@ -169,9 +165,7 @@ build_nir_copy_fragment_shader_depth(enum glsl_sampler_dim tex_dim)
{ {
char shader_name[64]; char shader_name[64];
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
sprintf(shader_name, "meta_blit_depth_fs.%d", tex_dim); sprintf(shader_name, "meta_blit_depth_fs.%d", tex_dim);
b.shader->info.name = ralloc_strdup(b.shader, shader_name); b.shader->info.name = ralloc_strdup(b.shader, shader_name);
@@ -227,9 +221,7 @@ build_nir_copy_fragment_shader_stencil(enum glsl_sampler_dim tex_dim)
{ {
char shader_name[64]; char shader_name[64];
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
sprintf(shader_name, "meta_blit_stencil_fs.%d", tex_dim); sprintf(shader_name, "meta_blit_stencil_fs.%d", tex_dim);
b.shader->info.name = ralloc_strdup(b.shader, shader_name); b.shader->info.name = ralloc_strdup(b.shader, shader_name);

View File

@@ -428,9 +428,7 @@ build_nir_vertex_shader(void)
{ {
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2); const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_blit2d_vs"); b.shader->info.name = ralloc_strdup(b.shader, "meta_blit2d_vs");
nir_variable *pos_out = nir_variable_create(b.shader, nir_var_shader_out, nir_variable *pos_out = nir_variable_create(b.shader, nir_var_shader_out,
@@ -603,9 +601,7 @@ build_nir_copy_fragment_shader(struct radv_device *device,
{ {
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2); const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
b.shader->info.name = ralloc_strdup(b.shader, name); b.shader->info.name = ralloc_strdup(b.shader, name);
nir_variable *tex_pos_in = nir_variable_create(b.shader, nir_var_shader_in, nir_variable *tex_pos_in = nir_variable_create(b.shader, nir_var_shader_in,
@@ -632,9 +628,7 @@ build_nir_copy_fragment_shader_depth(struct radv_device *device,
{ {
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2); const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
b.shader->info.name = ralloc_strdup(b.shader, name); b.shader->info.name = ralloc_strdup(b.shader, name);
nir_variable *tex_pos_in = nir_variable_create(b.shader, nir_var_shader_in, nir_variable *tex_pos_in = nir_variable_create(b.shader, nir_var_shader_in,
@@ -661,9 +655,7 @@ build_nir_copy_fragment_shader_stencil(struct radv_device *device,
{ {
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2); const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
b.shader->info.name = ralloc_strdup(b.shader, name); b.shader->info.name = ralloc_strdup(b.shader, name);
nir_variable *tex_pos_in = nir_variable_create(b.shader, nir_var_shader_in, nir_variable *tex_pos_in = nir_variable_create(b.shader, nir_var_shader_in,

View File

@@ -7,9 +7,7 @@
static nir_shader * static nir_shader *
build_buffer_fill_shader(struct radv_device *dev) build_buffer_fill_shader(struct radv_device *dev)
{ {
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_buffer_fill"); b.shader->info.name = ralloc_strdup(b.shader, "meta_buffer_fill");
b.shader->info.cs.local_size[0] = 64; b.shader->info.cs.local_size[0] = 64;
b.shader->info.cs.local_size[1] = 1; b.shader->info.cs.local_size[1] = 1;
@@ -55,9 +53,7 @@ build_buffer_fill_shader(struct radv_device *dev)
static nir_shader * static nir_shader *
build_buffer_copy_shader(struct radv_device *dev) build_buffer_copy_shader(struct radv_device *dev)
{ {
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_buffer_copy"); b.shader->info.name = ralloc_strdup(b.shader, "meta_buffer_copy");
b.shader->info.cs.local_size[0] = 64; b.shader->info.cs.local_size[0] = 64;
b.shader->info.cs.local_size[1] = 1; b.shader->info.cs.local_size[1] = 1;

View File

@@ -35,7 +35,6 @@
static nir_shader * static nir_shader *
build_nir_itob_compute_shader(struct radv_device *dev, bool is_3d) build_nir_itob_compute_shader(struct radv_device *dev, bool is_3d)
{ {
nir_builder b;
enum glsl_sampler_dim dim = is_3d ? GLSL_SAMPLER_DIM_3D : GLSL_SAMPLER_DIM_2D; enum glsl_sampler_dim dim = is_3d ? GLSL_SAMPLER_DIM_3D : GLSL_SAMPLER_DIM_2D;
const struct glsl_type *sampler_type = glsl_sampler_type(dim, const struct glsl_type *sampler_type = glsl_sampler_type(dim,
false, false,
@@ -44,7 +43,7 @@ build_nir_itob_compute_shader(struct radv_device *dev, bool is_3d)
const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_BUF, const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_BUF,
false, false,
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, is_3d ? "meta_itob_cs_3d" : "meta_itob_cs"); b.shader->info.name = ralloc_strdup(b.shader, is_3d ? "meta_itob_cs_3d" : "meta_itob_cs");
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;
@@ -264,7 +263,6 @@ radv_device_finish_meta_itob_state(struct radv_device *device)
static nir_shader * static nir_shader *
build_nir_btoi_compute_shader(struct radv_device *dev, bool is_3d) build_nir_btoi_compute_shader(struct radv_device *dev, bool is_3d)
{ {
nir_builder b;
enum glsl_sampler_dim dim = is_3d ? GLSL_SAMPLER_DIM_3D : GLSL_SAMPLER_DIM_2D; enum glsl_sampler_dim dim = is_3d ? GLSL_SAMPLER_DIM_3D : GLSL_SAMPLER_DIM_2D;
const struct glsl_type *buf_type = glsl_sampler_type(GLSL_SAMPLER_DIM_BUF, const struct glsl_type *buf_type = glsl_sampler_type(GLSL_SAMPLER_DIM_BUF,
false, false,
@@ -273,7 +271,7 @@ build_nir_btoi_compute_shader(struct radv_device *dev, bool is_3d)
const struct glsl_type *img_type = glsl_image_type(dim, const struct glsl_type *img_type = glsl_image_type(dim,
false, false,
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, is_3d ? "meta_btoi_cs_3d" : "meta_btoi_cs"); b.shader->info.name = ralloc_strdup(b.shader, is_3d ? "meta_btoi_cs_3d" : "meta_btoi_cs");
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;
@@ -487,7 +485,6 @@ radv_device_finish_meta_btoi_state(struct radv_device *device)
static nir_shader * static nir_shader *
build_nir_btoi_r32g32b32_compute_shader(struct radv_device *dev) build_nir_btoi_r32g32b32_compute_shader(struct radv_device *dev)
{ {
nir_builder b;
const struct glsl_type *buf_type = glsl_sampler_type(GLSL_SAMPLER_DIM_BUF, const struct glsl_type *buf_type = glsl_sampler_type(GLSL_SAMPLER_DIM_BUF,
false, false,
false, false,
@@ -495,7 +492,7 @@ build_nir_btoi_r32g32b32_compute_shader(struct radv_device *dev)
const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_BUF, const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_BUF,
false, false,
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_btoi_r32g32b32_cs"); b.shader->info.name = ralloc_strdup(b.shader, "meta_btoi_r32g32b32_cs");
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;
@@ -694,7 +691,6 @@ radv_device_finish_meta_btoi_r32g32b32_state(struct radv_device *device)
static nir_shader * static nir_shader *
build_nir_itoi_compute_shader(struct radv_device *dev, bool is_3d) build_nir_itoi_compute_shader(struct radv_device *dev, bool is_3d)
{ {
nir_builder b;
enum glsl_sampler_dim dim = is_3d ? GLSL_SAMPLER_DIM_3D : GLSL_SAMPLER_DIM_2D; enum glsl_sampler_dim dim = is_3d ? GLSL_SAMPLER_DIM_3D : GLSL_SAMPLER_DIM_2D;
const struct glsl_type *buf_type = glsl_sampler_type(dim, const struct glsl_type *buf_type = glsl_sampler_type(dim,
false, false,
@@ -703,7 +699,7 @@ build_nir_itoi_compute_shader(struct radv_device *dev, bool is_3d)
const struct glsl_type *img_type = glsl_image_type(dim, const struct glsl_type *img_type = glsl_image_type(dim,
false, false,
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, is_3d ? "meta_itoi_cs_3d" : "meta_itoi_cs"); b.shader->info.name = ralloc_strdup(b.shader, is_3d ? "meta_itoi_cs_3d" : "meta_itoi_cs");
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;
@@ -912,7 +908,6 @@ radv_device_finish_meta_itoi_state(struct radv_device *device)
static nir_shader * static nir_shader *
build_nir_itoi_r32g32b32_compute_shader(struct radv_device *dev) build_nir_itoi_r32g32b32_compute_shader(struct radv_device *dev)
{ {
nir_builder b;
const struct glsl_type *type = glsl_sampler_type(GLSL_SAMPLER_DIM_BUF, const struct glsl_type *type = glsl_sampler_type(GLSL_SAMPLER_DIM_BUF,
false, false,
false, false,
@@ -920,7 +915,7 @@ build_nir_itoi_r32g32b32_compute_shader(struct radv_device *dev)
const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_BUF, const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_BUF,
false, false,
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_itoi_r32g32b32_cs"); b.shader->info.name = ralloc_strdup(b.shader, "meta_itoi_r32g32b32_cs");
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;
@@ -1126,12 +1121,11 @@ radv_device_finish_meta_itoi_r32g32b32_state(struct radv_device *device)
static nir_shader * static nir_shader *
build_nir_cleari_compute_shader(struct radv_device *dev, bool is_3d) build_nir_cleari_compute_shader(struct radv_device *dev, bool is_3d)
{ {
nir_builder b;
enum glsl_sampler_dim dim = is_3d ? GLSL_SAMPLER_DIM_3D : GLSL_SAMPLER_DIM_2D; enum glsl_sampler_dim dim = is_3d ? GLSL_SAMPLER_DIM_3D : GLSL_SAMPLER_DIM_2D;
const struct glsl_type *img_type = glsl_image_type(dim, const struct glsl_type *img_type = glsl_image_type(dim,
false, false,
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, is_3d ? "meta_cleari_cs_3d" : "meta_cleari_cs"); b.shader->info.name = ralloc_strdup(b.shader, is_3d ? "meta_cleari_cs_3d" : "meta_cleari_cs");
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;
@@ -1319,11 +1313,10 @@ radv_device_finish_meta_cleari_state(struct radv_device *device)
static nir_shader * static nir_shader *
build_nir_cleari_r32g32b32_compute_shader(struct radv_device *dev) build_nir_cleari_r32g32b32_compute_shader(struct radv_device *dev)
{ {
nir_builder b;
const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_BUF, const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_BUF,
false, false,
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_cleari_r32g32b32_cs"); b.shader->info.name = ralloc_strdup(b.shader, "meta_cleari_r32g32b32_cs");
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;

View File

@@ -40,11 +40,8 @@ build_color_shaders(struct nir_shader **out_vs,
struct nir_shader **out_fs, struct nir_shader **out_fs,
uint32_t frag_output) uint32_t frag_output)
{ {
nir_builder vs_b; nir_builder vs_b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, NULL);
nir_builder fs_b; nir_builder fs_b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL);
nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL);
vs_b.shader->info.name = ralloc_strdup(vs_b.shader, "meta_clear_color_vs"); vs_b.shader->info.name = ralloc_strdup(vs_b.shader, "meta_clear_color_vs");
fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "meta_clear_color_fs"); fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "meta_clear_color_fs");
@@ -507,10 +504,8 @@ build_depthstencil_shader(struct nir_shader **out_vs,
struct nir_shader **out_fs, struct nir_shader **out_fs,
bool unrestricted) bool unrestricted)
{ {
nir_builder vs_b, fs_b; nir_builder vs_b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, NULL);
nir_builder fs_b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL);
nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL);
vs_b.shader->info.name = ralloc_strdup(vs_b.shader, vs_b.shader->info.name = ralloc_strdup(vs_b.shader,
unrestricted ? "meta_clear_depthstencil_unrestricted_vs" unrestricted ? "meta_clear_depthstencil_unrestricted_vs"
@@ -1166,9 +1161,7 @@ radv_fast_clear_depth(struct radv_cmd_buffer *cmd_buffer,
static nir_shader * static nir_shader *
build_clear_htile_mask_shader() build_clear_htile_mask_shader()
{ {
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_clear_htile_mask"); b.shader->info.name = ralloc_strdup(b.shader, "meta_clear_htile_mask");
b.shader->info.cs.local_size[0] = 64; b.shader->info.cs.local_size[0] = 64;
b.shader->info.cs.local_size[1] = 1; b.shader->info.cs.local_size[1] = 1;

View File

@@ -32,7 +32,6 @@
static nir_shader * static nir_shader *
build_dcc_decompress_compute_shader(struct radv_device *dev) build_dcc_decompress_compute_shader(struct radv_device *dev)
{ {
nir_builder b;
const struct glsl_type *buf_type = glsl_sampler_type(GLSL_SAMPLER_DIM_2D, const struct glsl_type *buf_type = glsl_sampler_type(GLSL_SAMPLER_DIM_2D,
false, false,
false, false,
@@ -40,7 +39,8 @@ build_dcc_decompress_compute_shader(struct radv_device *dev)
const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_2D, const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_2D,
false, false,
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "dcc_decompress_compute"); b.shader->info.name = ralloc_strdup(b.shader, "dcc_decompress_compute");
/* We need at least 16/16/1 to cover an entire DCC block in a single workgroup. */ /* We need at least 16/16/1 to cover an entire DCC block in a single workgroup. */

View File

@@ -29,7 +29,6 @@
static nir_shader * static nir_shader *
build_fmask_expand_compute_shader(struct radv_device *device, int samples) build_fmask_expand_compute_shader(struct radv_device *device, int samples)
{ {
nir_builder b;
char name[64]; char name[64];
const struct glsl_type *type = const struct glsl_type *type =
glsl_sampler_type(GLSL_SAMPLER_DIM_MS, false, false, glsl_sampler_type(GLSL_SAMPLER_DIM_MS, false, false,
@@ -40,7 +39,7 @@ build_fmask_expand_compute_shader(struct radv_device *device, int samples)
snprintf(name, 64, "meta_fmask_expand_cs-%d", samples); snprintf(name, 64, "meta_fmask_expand_cs-%d", samples);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, name); b.shader->info.name = ralloc_strdup(b.shader, name);
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;

View File

@@ -35,10 +35,9 @@ static nir_shader *
build_nir_fs(void) build_nir_fs(void)
{ {
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b;
nir_variable *f_color; /* vec4, fragment output color */ nir_variable *f_color; /* vec4, fragment output color */
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
b.shader->info.name = ralloc_asprintf(b.shader, b.shader->info.name = ralloc_asprintf(b.shader,
"meta_resolve_fs"); "meta_resolve_fs");

View File

@@ -67,7 +67,6 @@ static nir_ssa_def *radv_meta_build_resolve_srgb_conversion(nir_builder *b,
static nir_shader * static nir_shader *
build_resolve_compute_shader(struct radv_device *dev, bool is_integer, bool is_srgb, int samples) build_resolve_compute_shader(struct radv_device *dev, bool is_integer, bool is_srgb, int samples)
{ {
nir_builder b;
char name[64]; char name[64];
const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_MS, const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_MS,
false, false,
@@ -77,7 +76,7 @@ build_resolve_compute_shader(struct radv_device *dev, bool is_integer, bool is_s
false, false,
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
snprintf(name, 64, "meta_resolve_cs-%d-%s", samples, is_integer ? "int" : (is_srgb ? "srgb" : "float")); snprintf(name, 64, "meta_resolve_cs-%d-%s", samples, is_integer ? "int" : (is_srgb ? "srgb" : "float"));
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, name); b.shader->info.name = ralloc_strdup(b.shader, name);
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;
@@ -166,7 +165,6 @@ build_depth_stencil_resolve_compute_shader(struct radv_device *dev, int samples,
int index, int index,
VkResolveModeFlagBits resolve_mode) VkResolveModeFlagBits resolve_mode)
{ {
nir_builder b;
char name[64]; char name[64];
const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_MS, const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_MS,
false, false,
@@ -179,7 +177,7 @@ build_depth_stencil_resolve_compute_shader(struct radv_device *dev, int samples,
index == DEPTH_RESOLVE ? "depth" : "stencil", index == DEPTH_RESOLVE ? "depth" : "stencil",
get_resolve_mode_str(resolve_mode), samples); get_resolve_mode_str(resolve_mode), samples);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, name); b.shader->info.name = ralloc_strdup(b.shader, name);
b.shader->info.cs.local_size[0] = 16; b.shader->info.cs.local_size[0] = 16;
b.shader->info.cs.local_size[1] = 16; b.shader->info.cs.local_size[1] = 16;

View File

@@ -35,9 +35,7 @@ static nir_shader *
build_nir_vertex_shader(void) build_nir_vertex_shader(void)
{ {
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_resolve_vs"); b.shader->info.name = ralloc_strdup(b.shader, "meta_resolve_vs");
nir_variable *pos_out = nir_variable_create(b.shader, nir_var_shader_out, nir_variable *pos_out = nir_variable_create(b.shader, nir_var_shader_out,
@@ -53,7 +51,6 @@ build_nir_vertex_shader(void)
static nir_shader * static nir_shader *
build_resolve_fragment_shader(struct radv_device *dev, bool is_integer, int samples) build_resolve_fragment_shader(struct radv_device *dev, bool is_integer, int samples)
{ {
nir_builder b;
char name[64]; char name[64];
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_MS, const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_MS,
@@ -62,7 +59,7 @@ build_resolve_fragment_shader(struct radv_device *dev, bool is_integer, int samp
GLSL_TYPE_FLOAT); GLSL_TYPE_FLOAT);
snprintf(name, 64, "meta_resolve_fs-%d-%s", samples, is_integer ? "int" : "float"); snprintf(name, 64, "meta_resolve_fs-%d-%s", samples, is_integer ? "int" : "float");
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
b.shader->info.name = ralloc_strdup(b.shader, name); b.shader->info.name = ralloc_strdup(b.shader, name);
nir_variable *input_img = nir_variable_create(b.shader, nir_var_uniform, nir_variable *input_img = nir_variable_create(b.shader, nir_var_uniform,
@@ -359,7 +356,6 @@ build_depth_stencil_resolve_fragment_shader(struct radv_device *dev, int samples
int index, int index,
VkResolveModeFlagBits resolve_mode) VkResolveModeFlagBits resolve_mode)
{ {
nir_builder b;
char name[64]; char name[64];
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_2D, const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_2D,
@@ -371,7 +367,7 @@ build_depth_stencil_resolve_fragment_shader(struct radv_device *dev, int samples
index == DEPTH_RESOLVE ? "depth" : "stencil", index == DEPTH_RESOLVE ? "depth" : "stencil",
get_resolve_mode_str(resolve_mode), samples); get_resolve_mode_str(resolve_mode), samples);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
b.shader->info.name = ralloc_strdup(b.shader, name); b.shader->info.name = ralloc_strdup(b.shader, name);
nir_variable *input_img = nir_variable_create(b.shader, nir_var_uniform, nir_variable *input_img = nir_variable_create(b.shader, nir_var_uniform,

View File

@@ -3073,8 +3073,7 @@ VkResult radv_create_shaders(struct radv_pipeline *pipeline,
} }
if (!modules[MESA_SHADER_FRAGMENT] && !modules[MESA_SHADER_COMPUTE]) { if (!modules[MESA_SHADER_FRAGMENT] && !modules[MESA_SHADER_COMPUTE]) {
nir_builder fs_b; nir_builder fs_b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL);
fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "noop_fs"); fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "noop_fs");
fs_m.nir = fs_b.shader; fs_m.nir = fs_b.shader;
modules[MESA_SHADER_FRAGMENT] = &fs_m; modules[MESA_SHADER_FRAGMENT] = &fs_m;

View File

@@ -153,8 +153,7 @@ build_occlusion_query_shader(struct radv_device *device) {
* } * }
* } * }
*/ */
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "occlusion_query"); b.shader->info.name = ralloc_strdup(b.shader, "occlusion_query");
b.shader->info.cs.local_size[0] = 64; b.shader->info.cs.local_size[0] = 64;
b.shader->info.cs.local_size[1] = 1; b.shader->info.cs.local_size[1] = 1;
@@ -321,8 +320,7 @@ build_pipeline_statistics_query_shader(struct radv_device *device) {
* } * }
* } * }
*/ */
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "pipeline_statistics_query"); b.shader->info.name = ralloc_strdup(b.shader, "pipeline_statistics_query");
b.shader->info.cs.local_size[0] = 64; b.shader->info.cs.local_size[0] = 64;
b.shader->info.cs.local_size[1] = 1; b.shader->info.cs.local_size[1] = 1;
@@ -516,8 +514,7 @@ build_tfb_query_shader(struct radv_device *device)
* } * }
* } * }
*/ */
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "tfb_query"); b.shader->info.name = ralloc_strdup(b.shader, "tfb_query");
b.shader->info.cs.local_size[0] = 64; b.shader->info.cs.local_size[0] = 64;
b.shader->info.cs.local_size[1] = 1; b.shader->info.cs.local_size[1] = 1;
@@ -695,8 +692,7 @@ build_timestamp_query_shader(struct radv_device *device)
* } * }
* } * }
*/ */
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "timestamp_query"); b.shader->info.name = ralloc_strdup(b.shader, "timestamp_query");
b.shader->info.cs.local_size[0] = 64; b.shader->info.cs.local_size[0] = 64;
b.shader->info.cs.local_size[1] = 1; b.shader->info.cs.local_size[1] = 1;

View File

@@ -1403,8 +1403,7 @@ radv_create_trap_handler_shader(struct radv_device *device)
struct radv_shader_binary *binary = NULL; struct radv_shader_binary *binary = NULL;
struct radv_shader_info info = {0}; struct radv_shader_info info = {0};
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_COMPUTE, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "meta_trap_handler"); b.shader->info.name = ralloc_strdup(b.shader, "meta_trap_handler");
options.explicit_scratch_args = true; options.explicit_scratch_args = true;

View File

@@ -129,9 +129,8 @@ gen_rect_vertices(nir_builder *b)
static nir_shader * static nir_shader *
get_clear_rect_vs() get_clear_rect_vs()
{ {
nir_builder b;
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options(); const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, options); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, options);
b.shader->info.name = ralloc_strdup(b.shader, "meta clear vs"); b.shader->info.name = ralloc_strdup(b.shader, "meta clear vs");
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
@@ -148,9 +147,8 @@ get_clear_rect_vs()
static nir_shader * static nir_shader *
get_color_clear_rect_fs(uint32_t rt_idx, VkFormat format) get_color_clear_rect_fs(uint32_t rt_idx, VkFormat format)
{ {
nir_builder b;
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options(); const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, options); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, options);
b.shader->info.name = ralloc_strdup(b.shader, "meta clear fs"); b.shader->info.name = ralloc_strdup(b.shader, "meta clear fs");
enum pipe_format pformat = vk_format_to_pipe_format(format); enum pipe_format pformat = vk_format_to_pipe_format(format);
@@ -178,9 +176,8 @@ get_color_clear_rect_fs(uint32_t rt_idx, VkFormat format)
static nir_shader * static nir_shader *
get_depth_clear_rect_fs() get_depth_clear_rect_fs()
{ {
nir_builder b;
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options(); const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, options); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, options);
b.shader->info.name = ralloc_strdup(b.shader, "meta depth clear fs"); b.shader->info.name = ralloc_strdup(b.shader, "meta depth clear fs");
nir_variable *fs_out_depth = nir_variable *fs_out_depth =

View File

@@ -3492,9 +3492,8 @@ build_nir_tex_op(struct nir_builder *b,
static nir_shader * static nir_shader *
get_blit_vs() get_blit_vs()
{ {
nir_builder b;
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options(); const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, options); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, options);
b.shader->info.name = ralloc_strdup(b.shader, "meta blit vs"); b.shader->info.name = ralloc_strdup(b.shader, "meta blit vs");
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
@@ -3538,9 +3537,8 @@ get_color_blit_fs(struct v3dv_device *device,
VkSampleCountFlagBits src_samples, VkSampleCountFlagBits src_samples,
enum glsl_sampler_dim sampler_dim) enum glsl_sampler_dim sampler_dim)
{ {
nir_builder b;
const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options(); const nir_shader_compiler_options *options = v3dv_pipeline_get_nir_options();
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, options); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, options);
b.shader->info.name = ralloc_strdup(b.shader, "meta blit fs"); b.shader->info.name = ralloc_strdup(b.shader, "meta blit fs");
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();

View File

@@ -1995,9 +1995,8 @@ pipeline_compile_graphics(struct v3dv_pipeline *pipeline,
/* Add a no-op fragment shader if needed */ /* Add a no-op fragment shader if needed */
if (!pipeline->fs) { if (!pipeline->fs) {
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT,
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, &v3dv_nir_options);
&v3dv_nir_options);
b.shader->info.name = ralloc_strdup(b.shader, "noop_fs"); b.shader->info.name = ralloc_strdup(b.shader, "noop_fs");
struct v3dv_pipeline_stage *p_stage = struct v3dv_pipeline_stage *p_stage =

View File

@@ -53,18 +53,22 @@ nir_builder_init(nir_builder *build, nir_function_impl *impl)
build->shader = impl->function->shader; build->shader = impl->function->shader;
} }
static inline void static inline nir_builder MUST_CHECK
nir_builder_init_simple_shader(nir_builder *build, void *mem_ctx, nir_builder_init_simple_shader(void *mem_ctx,
gl_shader_stage stage, gl_shader_stage stage,
const nir_shader_compiler_options *options) const nir_shader_compiler_options *options)
{ {
memset(build, 0, sizeof(*build)); nir_builder b;
build->shader = nir_shader_create(mem_ctx, stage, options, NULL);
nir_function *func = nir_function_create(build->shader, "main"); memset(&b, 0, sizeof(b));
b.shader = nir_shader_create(mem_ctx, stage, options, NULL);
nir_function *func = nir_function_create(b.shader, "main");
func->is_entrypoint = true; func->is_entrypoint = true;
build->exact = false; b.exact = false;
build->impl = nir_function_impl_create(func); b.impl = nir_function_impl_create(func);
build->cursor = nir_after_cf_list(&build->impl->body); b.cursor = nir_after_cf_list(&b.impl->body);
return b;
} }
typedef bool (*nir_instr_pass_cb)(struct nir_builder *, nir_instr *, void *); typedef bool (*nir_instr_pass_cb)(struct nir_builder *, nir_instr *, void *);

View File

@@ -81,7 +81,7 @@ nir_builder_test::nir_builder_test()
lin_ctx = linear_alloc_parent(mem_ctx, 0); lin_ctx = linear_alloc_parent(mem_ctx, 0);
static const nir_shader_compiler_options options = { }; static const nir_shader_compiler_options options = { };
b = rzalloc(mem_ctx, nir_builder); b = rzalloc(mem_ctx, nir_builder);
nir_builder_init_simple_shader(b, mem_ctx, MESA_SHADER_COMPUTE, &options); *b = nir_builder_init_simple_shader(mem_ctx, MESA_SHADER_COMPUTE, &options);
} }
nir_builder_test::~nir_builder_test() nir_builder_test::~nir_builder_test()

View File

@@ -31,7 +31,7 @@ protected:
glsl_type_singleton_init_or_ref(); glsl_type_singleton_init_or_ref();
static const nir_shader_compiler_options options = { }; static const nir_shader_compiler_options options = { };
nir_builder_init_simple_shader(&bld, NULL, MESA_SHADER_VERTEX, &options); bld = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, &options);
v1 = nir_imm_vec4(&bld, -2.0, -1.0, 1.0, 2.0); v1 = nir_imm_vec4(&bld, -2.0, -1.0, 1.0, 2.0);
v2 = nir_imm_vec4(&bld, 2.0, 1.0, -1.0, -2.0); v2 = nir_imm_vec4(&bld, 2.0, 1.0, -1.0, -2.0);

View File

@@ -37,7 +37,7 @@ nir_cf_test::nir_cf_test()
glsl_type_singleton_init_or_ref(); glsl_type_singleton_init_or_ref();
static const nir_shader_compiler_options options = { }; static const nir_shader_compiler_options options = { };
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, &options); b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, &options);
} }
nir_cf_test::~nir_cf_test() nir_cf_test::~nir_cf_test()

View File

@@ -93,7 +93,7 @@ nir_load_store_vectorize_test::nir_load_store_vectorize_test()
mem_ctx = ralloc_context(NULL); mem_ctx = ralloc_context(NULL);
static const nir_shader_compiler_options options = { }; static const nir_shader_compiler_options options = { };
b = rzalloc(mem_ctx, nir_builder); b = rzalloc(mem_ctx, nir_builder);
nir_builder_init_simple_shader(b, mem_ctx, MESA_SHADER_COMPUTE, &options); *b = nir_builder_init_simple_shader(mem_ctx, MESA_SHADER_COMPUTE, &options);
} }
nir_load_store_vectorize_test::~nir_load_store_vectorize_test() nir_load_store_vectorize_test::~nir_load_store_vectorize_test()

View File

@@ -39,7 +39,7 @@ nir_opt_lower_returns_test::nir_opt_lower_returns_test()
glsl_type_singleton_init_or_ref(); glsl_type_singleton_init_or_ref();
static const nir_shader_compiler_options options = { }; static const nir_shader_compiler_options options = { };
nir_builder_init_simple_shader(&bld, NULL, MESA_SHADER_VERTEX, &options); bld = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, &options);
nir_variable *var = nir_variable_create(bld.shader, nir_var_shader_in, glsl_int_type(), "in"); nir_variable *var = nir_variable_create(bld.shader, nir_var_shader_in, glsl_int_type(), "in");
in_def = nir_load_var(&bld, var); in_def = nir_load_var(&bld, var);

View File

@@ -57,7 +57,7 @@ protected:
glsl_type_singleton_init_or_ref(); glsl_type_singleton_init_or_ref();
static const nir_shader_compiler_options options = { }; static const nir_shader_compiler_options options = { };
nir_builder_init_simple_shader(&bld, NULL, MESA_SHADER_VERTEX, &options); bld = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, &options);
memset(c1, 0, sizeof(c1)); memset(c1, 0, sizeof(c1));
memset(c2, 0, sizeof(c2)); memset(c2, 0, sizeof(c2));
} }

View File

@@ -40,7 +40,7 @@ nir_opt_if_test::nir_opt_if_test()
glsl_type_singleton_init_or_ref(); glsl_type_singleton_init_or_ref();
static const nir_shader_compiler_options options = { }; static const nir_shader_compiler_options options = { };
nir_builder_init_simple_shader(&bld, NULL, MESA_SHADER_VERTEX, &options); bld = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, &options);
nir_variable *var = nir_variable_create(bld.shader, nir_var_shader_in, glsl_int_type(), "in"); nir_variable *var = nir_variable_create(bld.shader, nir_var_shader_in, glsl_int_type(), "in");
in_def = nir_load_var(&bld, var); in_def = nir_load_var(&bld, var);

View File

@@ -52,7 +52,7 @@ nir_serialize_test::nir_serialize_test()
mem_ctx = ralloc_context(NULL); mem_ctx = ralloc_context(NULL);
b = rzalloc(mem_ctx, nir_builder); b = rzalloc(mem_ctx, nir_builder);
nir_builder_init_simple_shader(b, mem_ctx, MESA_SHADER_COMPUTE, &options); *b = nir_builder_init_simple_shader(mem_ctx, MESA_SHADER_COMPUTE, &options);
} }
nir_serialize_test::~nir_serialize_test() nir_serialize_test::~nir_serialize_test()

View File

@@ -106,7 +106,7 @@ nir_vars_test::nir_vars_test()
lin_ctx = linear_alloc_parent(mem_ctx, 0); lin_ctx = linear_alloc_parent(mem_ctx, 0);
static const nir_shader_compiler_options options = { }; static const nir_shader_compiler_options options = { };
b = rzalloc(mem_ctx, nir_builder); b = rzalloc(mem_ctx, nir_builder);
nir_builder_init_simple_shader(b, mem_ctx, MESA_SHADER_COMPUTE, &options); *b = nir_builder_init_simple_shader(mem_ctx, MESA_SHADER_COMPUTE, &options);
} }
nir_vars_test::~nir_vars_test() nir_vars_test::~nir_vars_test()

View File

@@ -2058,9 +2058,9 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder,
if (!nir[MESA_SHADER_FRAGMENT]) { if (!nir[MESA_SHADER_FRAGMENT]) {
const nir_shader_compiler_options *nir_options = const nir_shader_compiler_options *nir_options =
ir3_get_compiler_options(builder->device->compiler); ir3_get_compiler_options(builder->device->compiler);
nir_builder fs_b; nir_builder fs_b = nir_builder_init_simple_shader(NULL,
nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, MESA_SHADER_FRAGMENT,
nir_options); nir_options);
fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "noop_fs"); fs_b.shader->info.name = ralloc_strdup(fs_b.shader, "noop_fs");
nir[MESA_SHADER_FRAGMENT] = fs_b.shader; nir[MESA_SHADER_FRAGMENT] = fs_b.shader;
} }

View File

@@ -2299,9 +2299,9 @@ ttn_compile_init(const void *tgsi_tokens,
screen->get_compiler_options(screen, PIPE_SHADER_IR_NIR, scan.processor); screen->get_compiler_options(screen, PIPE_SHADER_IR_NIR, scan.processor);
} }
nir_builder_init_simple_shader(&c->build, NULL, c->build = nir_builder_init_simple_shader(NULL,
tgsi_processor_to_shader_stage(scan.processor), tgsi_processor_to_shader_stage(scan.processor),
options); options);
s = c->build.shader; s = c->build.shader;

View File

@@ -199,8 +199,7 @@ static void *vc4_get_yuv_vs(struct pipe_context *pctx)
PIPE_SHADER_IR_NIR, PIPE_SHADER_IR_NIR,
PIPE_SHADER_VERTEX); PIPE_SHADER_VERTEX);
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, options);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, options);
b.shader->info.name = ralloc_strdup(b.shader, "linear_blit_vs"); b.shader->info.name = ralloc_strdup(b.shader, "linear_blit_vs");
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
@@ -246,8 +245,8 @@ static void *vc4_get_yuv_fs(struct pipe_context *pctx, int cpp)
PIPE_SHADER_IR_NIR, PIPE_SHADER_IR_NIR,
PIPE_SHADER_FRAGMENT); PIPE_SHADER_FRAGMENT);
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT,
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, options); options);
b.shader->info.name = ralloc_strdup(b.shader, name); b.shader->info.name = ralloc_strdup(b.shader, name);
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();

View File

@@ -789,9 +789,7 @@ lvp_graphics_pipeline_init(struct lvp_pipeline *pipeline,
if (has_fragment_shader == false) { if (has_fragment_shader == false) {
/* create a dummy fragment shader for this pipeline. */ /* create a dummy fragment shader for this pipeline. */
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, NULL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "dummy_frag"); b.shader->info.name = ralloc_strdup(b.shader, "dummy_frag");
pipeline->pipeline_nir[MESA_SHADER_FRAGMENT] = b.shader; pipeline->pipeline_nir[MESA_SHADER_FRAGMENT] = b.shader;

View File

@@ -29,7 +29,7 @@ blorp_nir_init_shader(nir_builder *b,
gl_shader_stage stage, gl_shader_stage stage,
const char *name) const char *name)
{ {
nir_builder_init_simple_shader(b, mem_ctx, stage, NULL); *b = nir_builder_init_simple_shader(mem_ctx, stage, NULL);
if (name != NULL) if (name != NULL)
b->shader->info.name = ralloc_strdup(b->shader, name); b->shader->info.name = ralloc_strdup(b->shader, name);
if (stage == MESA_SHADER_FRAGMENT) if (stage == MESA_SHADER_FRAGMENT)

View File

@@ -1475,9 +1475,8 @@ brw_nir_create_passthrough_tcs(void *mem_ctx, const struct brw_compiler *compile
const nir_shader_compiler_options *options, const nir_shader_compiler_options *options,
const struct brw_tcs_prog_key *key) const struct brw_tcs_prog_key *key)
{ {
nir_builder b; nir_builder b = nir_builder_init_simple_shader(mem_ctx, MESA_SHADER_TESS_CTRL,
nir_builder_init_simple_shader(&b, mem_ctx, MESA_SHADER_TESS_CTRL, options);
options);
nir_shader *nir = b.shader; nir_shader *nir = b.shader;
nir_variable *var; nir_variable *var;
nir_intrinsic_instr *load; nir_intrinsic_instr *load;

View File

@@ -969,7 +969,7 @@ prog_to_nir(const struct gl_program *prog,
return NULL; return NULL;
c->prog = prog; c->prog = prog;
nir_builder_init_simple_shader(&c->build, NULL, stage, options); c->build = nir_builder_init_simple_shader(NULL, stage, options);
/* Copy the shader_info from the gl_program */ /* Copy the shader_info from the gl_program */
c->build.shader->info = prog->info; c->build.shader->info = prog->info;

View File

@@ -148,11 +148,10 @@ make_drawpix_z_stencil_program_nir(struct st_context *st,
bool write_depth, bool write_depth,
bool write_stencil) bool write_stencil)
{ {
struct nir_builder b;
const nir_shader_compiler_options *options = const nir_shader_compiler_options *options =
st_get_nir_compiler_options(st, MESA_SHADER_FRAGMENT); st_get_nir_compiler_options(st, MESA_SHADER_FRAGMENT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, options); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, options);
nir_variable *texcoord = nir_variable *texcoord =
nir_variable_create(b.shader, nir_var_shader_in, glsl_vec_type(2), nir_variable_create(b.shader, nir_var_shader_in, glsl_vec_type(2),
@@ -202,11 +201,10 @@ static void *
make_drawpix_zs_to_color_program_nir(struct st_context *st, make_drawpix_zs_to_color_program_nir(struct st_context *st,
bool rgba) bool rgba)
{ {
struct nir_builder b;
const nir_shader_compiler_options *options = const nir_shader_compiler_options *options =
st_get_nir_compiler_options(st, MESA_SHADER_FRAGMENT); st_get_nir_compiler_options(st, MESA_SHADER_FRAGMENT);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, options); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, options);
nir_variable *texcoord = nir_variable *texcoord =
nir_variable_create(b.shader, nir_var_shader_in, glsl_vec_type(2), nir_variable_create(b.shader, nir_var_shader_in, glsl_vec_type(2),

View File

@@ -113,12 +113,11 @@ st_nir_make_passthrough_shader(struct st_context *st,
unsigned *interpolation_modes, unsigned *interpolation_modes,
unsigned sysval_mask) unsigned sysval_mask)
{ {
struct nir_builder b;
const struct glsl_type *vec4 = glsl_vec4_type(); const struct glsl_type *vec4 = glsl_vec4_type();
const nir_shader_compiler_options *options = const nir_shader_compiler_options *options =
st_get_nir_compiler_options(st, stage); st_get_nir_compiler_options(st, stage);
nir_builder_init_simple_shader(&b, NULL, stage, options); nir_builder b = nir_builder_init_simple_shader(NULL, stage, options);
char var_name[15]; char var_name[15];

View File

@@ -296,8 +296,7 @@ st_pbo_create_vs(struct st_context *st)
const nir_shader_compiler_options *options = const nir_shader_compiler_options *options =
st_get_nir_compiler_options(st, MESA_SHADER_VERTEX); st_get_nir_compiler_options(st, MESA_SHADER_VERTEX);
nir_builder b; nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_VERTEX, options);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, options);
nir_variable *in_pos = nir_variable_create(b.shader, nir_var_shader_in, nir_variable *in_pos = nir_variable_create(b.shader, nir_var_shader_in,
vec4, "in_pos"); vec4, "in_pos");
@@ -406,13 +405,12 @@ create_fs(struct st_context *st, bool download,
enum st_pbo_conversion conversion) enum st_pbo_conversion conversion)
{ {
struct pipe_screen *screen = st->pipe->screen; struct pipe_screen *screen = st->pipe->screen;
struct nir_builder b;
const nir_shader_compiler_options *options = const nir_shader_compiler_options *options =
st_get_nir_compiler_options(st, MESA_SHADER_FRAGMENT); st_get_nir_compiler_options(st, MESA_SHADER_FRAGMENT);
bool pos_is_sysval = bool pos_is_sysval =
screen->get_param(screen, PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL); screen->get_param(screen, PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL);
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, options); nir_builder b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, options);
nir_ssa_def *zero = nir_imm_int(&b, 0); nir_ssa_def *zero = nir_imm_int(&b, 0);

View File

@@ -52,8 +52,7 @@ panfrost_build_blit_shader(struct panfrost_device *dev,
{ {
bool is_colour = loc >= FRAG_RESULT_DATA0; bool is_colour = loc >= FRAG_RESULT_DATA0;
nir_builder _b; nir_builder _b = nir_builder_init_simple_shader(NULL, MESA_SHADER_FRAGMENT, &midgard_nir_options);
nir_builder_init_simple_shader(&_b, NULL, MESA_SHADER_FRAGMENT, &midgard_nir_options);
nir_builder *b = &_b; nir_builder *b = &_b;
nir_shader *shader = b->shader; nir_shader *shader = b->shader;