Lines Matching full:builder
212 get_draw_ctx_data(struct indirect_draw_shader_builder *builder, in get_draw_ctx_data() argument
215 nir_builder *b = &builder->b; in get_draw_ctx_data()
217 get_address_imm(b, builder->draw.draw_ctx, offset), in get_draw_ctx_data()
222 set_draw_ctx_data(struct indirect_draw_shader_builder *builder, in set_draw_ctx_data() argument
225 nir_builder *b = &builder->b; in set_draw_ctx_data()
227 get_address_imm(b, builder->draw.draw_ctx, offset), in set_draw_ctx_data()
231 #define get_draw_ctx_field(builder, name) \ argument
232 get_draw_ctx_data(builder, \
236 #define set_draw_ctx_field(builder, name, val) \ argument
237 set_draw_ctx_data(builder, \
243 get_min_max_ctx_data(struct indirect_draw_shader_builder *builder, in get_min_max_ctx_data() argument
246 nir_builder *b = &builder->b; in get_min_max_ctx_data()
248 get_address_imm(b, builder->draw.min_max_ctx, offset), in get_min_max_ctx_data()
252 #define get_min_max_ctx_field(builder, name) \ argument
253 get_min_max_ctx_data(builder, \
258 update_min(struct indirect_draw_shader_builder *builder, nir_ssa_def *val) in update_min() argument
260 nir_builder *b = &builder->b; in update_min()
263 builder->draw.min_max_ctx, in update_min()
269 update_max(struct indirect_draw_shader_builder *builder, nir_ssa_def *val) in update_max() argument
271 nir_builder *b = &builder->b; in update_max()
274 builder->draw.min_max_ctx, in update_max()
292 extract_inputs(struct indirect_draw_shader_builder *builder) in extract_inputs() argument
294 nir_builder *b = &builder->b; in extract_inputs()
296 builder->draw.draw_ctx = get_input_field(b, draw_ctx); in extract_inputs()
297 builder->draw.draw_buf = get_input_field(b, draw_buf); in extract_inputs()
298 builder->draw.draw_buf_stride = get_input_field(b, draw_buf_stride); in extract_inputs()
300 if (builder->index_size) { in extract_inputs()
301 builder->draw.index_buf = get_input_field(b, index_buf); in extract_inputs()
302 builder->draw.min_max_ctx = get_input_field(b, min_max_ctx); in extract_inputs()
303 if (builder->flags & PAN_INDIRECT_DRAW_PRIMITIVE_RESTART) { in extract_inputs()
304 builder->draw.restart_index = in extract_inputs()
309 if (builder->index_min_max_search) in extract_inputs()
312 builder->jobs.first_vertex_sysval = get_input_field(b, first_vertex_sysval); in extract_inputs()
313 builder->jobs.base_vertex_sysval = get_input_field(b, base_vertex_sysval); in extract_inputs()
314 builder->jobs.base_instance_sysval = get_input_field(b, base_instance_sysval); in extract_inputs()
315 builder->jobs.vertex_job = get_input_field(b, vertex_job); in extract_inputs()
316 builder->jobs.tiler_job = get_input_field(b, tiler_job); in extract_inputs()
317 builder->attribs.attrib_bufs = get_input_field(b, attrib_bufs); in extract_inputs()
318 builder->attribs.attribs = get_input_field(b, attribs); in extract_inputs()
319 builder->attribs.attrib_count = get_input_field(b, attrib_count); in extract_inputs()
320 builder->varyings.varying_bufs = get_input_field(b, varying_bufs); in extract_inputs()
321 builder->varyings.mem_ptr = in extract_inputs()
325 nir_store_var(b, builder->varyings.mem_ptr, in extract_inputs()
326 get_draw_ctx_field(builder, varying_mem), 3); in extract_inputs()
330 init_shader_builder(struct indirect_draw_shader_builder *builder, in init_shader_builder() argument
335 memset(builder, 0, sizeof(*builder)); in init_shader_builder()
336 builder->dev = dev; in init_shader_builder()
337 builder->flags = flags; in init_shader_builder()
338 builder->index_size = index_size; in init_shader_builder()
340 builder->index_min_max_search = index_min_max_search; in init_shader_builder()
343 builder->b = in init_shader_builder()
347 builder->index_size); in init_shader_builder()
349 builder->b = in init_shader_builder()
353 builder->index_size, in init_shader_builder()
364 extract_inputs(builder); in init_shader_builder()
368 update_dcd(struct indirect_draw_shader_builder *builder, in update_dcd() argument
372 nir_builder *b = &builder->b; in update_dcd()
380 nir_ult(b, builder->draw.instance_count, nir_imm_int(b, 2)), in update_dcd()
381 nir_imm_int(b, 0), builder->instance_size.packed); in update_dcd()
385 builder->jobs.offset_start); in update_dcd()
391 update_job(struct indirect_draw_shader_builder *builder, enum mali_job_type type) in update_job() argument
393 nir_builder *b = &builder->b; in update_job()
396 builder->jobs.vertex_job : builder->jobs.tiler_job; in update_job()
400 builder->jobs.invocation, 2); in update_job()
408 unsigned index_size = builder->index_size; in update_job()
414 builder->jobs.base_vertex_offset, 1); in update_job()
417 nir_iadd_imm(b, builder->draw.vertex_count, -1), 1); in update_job()
424 nir_imul_imm(b, builder->draw.vertex_start, index_size); in update_job()
431 if ((builder->flags & PAN_INDIRECT_DRAW_HAS_PSIZ) && in update_job()
432 (builder->flags & PAN_INDIRECT_DRAW_UPDATE_PRIM_SIZE)) { in update_job()
435 builder->varyings.psiz_ptr, 2); in update_job()
440 builder->varyings.pos_ptr, 2); in update_job()
443 update_dcd(builder, job_ptr, draw_offset); in update_job()
445 if (builder->flags & PAN_INDIRECT_DRAW_IDVS) { in update_job()
448 update_dcd(builder, job_ptr, in update_job()
473 update_vertex_attrib_buf(struct indirect_draw_shader_builder *builder, in update_vertex_attrib_buf() argument
479 nir_builder *b = &builder->b; in update_vertex_attrib_buf()
507 zero_attrib_buf_stride(struct indirect_draw_shader_builder *builder, in zero_attrib_buf_stride() argument
511 nir_builder *b = &builder->b; in zero_attrib_buf_stride()
517 adjust_attrib_offset(struct indirect_draw_shader_builder *builder, in adjust_attrib_offset() argument
521 nir_builder *b = &builder->b; in adjust_attrib_offset()
525 nir_iand(b, nir_ine(b, builder->jobs.offset_start, zero), in adjust_attrib_offset()
526 nir_uge(b, builder->draw.instance_count, two)); in adjust_attrib_offset()
529 nir_iand(b, nir_ine(b, builder->draw.start_instance, zero), in adjust_attrib_offset()
546 builder->draw.start_instance), in adjust_attrib_offset()
553 builder->jobs.offset_start)); in adjust_attrib_offset()
572 update_vertex_attribs(struct indirect_draw_shader_builder *builder) in update_vertex_attribs() argument
574 nir_builder *b = &builder->b; in update_vertex_attribs()
582 nir_ult(b, builder->draw.instance_count, nir_imm_int(b, 2)); in update_vertex_attribs()
587 IF (nir_uge(b, attrib_idx, builder->attribs.attrib_count)) in update_vertex_attribs()
592 get_address(b, builder->attribs.attrib_bufs, in update_vertex_attribs()
596 get_address(b, builder->attribs.attribs, in update_vertex_attribs()
607 builder->instance_size.packed); in update_vertex_attribs()
619 split_div(b, builder->instance_size.padded, in update_vertex_attribs()
624 builder->instance_size.padded, in update_vertex_attribs()
643 nir_ssa_def *div = nir_imul(b, instance_div, builder->instance_size.padded); in update_vertex_attribs()
646 nir_uge(b, builder->draw.instance_count, nir_imm_int(b, 2)); in update_vertex_attribs()
654 update_vertex_attrib_buf(builder, attrib_buf_ptr, in update_vertex_attribs()
659 update_vertex_attrib_buf(builder, attrib_buf_ptr, in update_vertex_attribs()
666 zero_attrib_buf_stride(builder, attrib_buf_ptr); in update_vertex_attribs()
669 adjust_attrib_offset(builder, attrib_ptr, attrib_buf_ptr, instance_div); in update_vertex_attribs()
671 update_vertex_attrib_buf(builder, attrib_buf_ptr, in update_vertex_attribs()
673 builder->instance_size.packed, NULL); in update_vertex_attribs()
681 update_varying_buf(struct indirect_draw_shader_builder *builder, in update_varying_buf() argument
685 nir_builder *b = &builder->b; in update_varying_buf()
693 nir_load_var(b, builder->varyings.mem_ptr); in update_varying_buf()
701 nir_store_var(b, builder->varyings.mem_ptr, in update_varying_buf()
710 update_varyings(struct indirect_draw_shader_builder *builder) in update_varyings() argument
712 nir_builder *b = &builder->b; in update_varyings()
714 nir_imul(b, builder->instance_size.padded, in update_varyings()
715 builder->draw.instance_count); in update_varyings()
717 get_address_imm(b, builder->varyings.varying_bufs, in update_varyings()
720 update_varying_buf(builder, buf_ptr, vertex_count); in update_varyings()
722 buf_ptr = get_address_imm(b, builder->varyings.varying_bufs, in update_varyings()
725 builder->varyings.pos_ptr = in update_varyings()
726 update_varying_buf(builder, buf_ptr, vertex_count); in update_varyings()
728 if (builder->flags & PAN_INDIRECT_DRAW_HAS_PSIZ) { in update_varyings()
729 buf_ptr = get_address_imm(b, builder->varyings.varying_bufs, in update_varyings()
732 builder->varyings.psiz_ptr = in update_varyings()
733 update_varying_buf(builder, buf_ptr, vertex_count); in update_varyings()
736 set_draw_ctx_field(builder, varying_mem, in update_varyings()
737 nir_load_var(b, builder->varyings.mem_ptr)); in update_varyings()
743 get_invocation(struct indirect_draw_shader_builder *builder) in get_invocation() argument
745 nir_builder *b = &builder->b; in get_invocation()
748 nir_usub_sat(b, builder->instance_size.raw, one); in get_invocation()
750 nir_usub_sat(b, builder->draw.instance_count, one); in get_invocation()
756 builder->jobs.invocation = in get_invocation()
803 update_jobs(struct indirect_draw_shader_builder *builder) in update_jobs() argument
805 get_invocation(builder); in update_jobs()
807 if (!(builder->flags & PAN_INDIRECT_DRAW_IDVS)) in update_jobs()
808 update_job(builder, MALI_JOB_TYPE_VERTEX); in update_jobs()
810 update_job(builder, MALI_JOB_TYPE_TILER); in update_jobs()
815 set_null_job(struct indirect_draw_shader_builder *builder, in set_null_job() argument
818 nir_builder *b = &builder->b; in set_null_job()
829 get_instance_size(struct indirect_draw_shader_builder *builder) in get_instance_size() argument
831 nir_builder *b = &builder->b; in get_instance_size()
833 if (!builder->index_size) { in get_instance_size()
834 builder->jobs.base_vertex_offset = nir_imm_int(b, 0); in get_instance_size()
835 builder->jobs.offset_start = builder->draw.vertex_start; in get_instance_size()
836 builder->instance_size.raw = builder->draw.vertex_count; in get_instance_size()
840 unsigned index_size = builder->index_size; in get_instance_size()
841 nir_ssa_def *min = get_min_max_ctx_field(builder, min); in get_instance_size()
842 nir_ssa_def *max = get_min_max_ctx_field(builder, max); in get_instance_size()
847 if (builder->index_size < 4) { in get_instance_size()
856 get_address(b, builder->draw.index_buf, in get_instance_size()
857 nir_imul_imm(b, builder->draw.vertex_start, index_size)); in get_instance_size()
861 nir_imul_imm(b, builder->draw.vertex_count, index_size)); in get_instance_size()
924 builder->jobs.base_vertex_offset = nir_ineg(b, min); in get_instance_size()
925 builder->jobs.offset_start = nir_iadd(b, min, builder->draw.index_bias); in get_instance_size()
926 builder->instance_size.raw = nir_iadd_imm(b, nir_usub_sat(b, max, min), 1); in get_instance_size()
932 patch(struct indirect_draw_shader_builder *builder) in patch() argument
934 unsigned index_size = builder->index_size; in patch()
935 nir_builder *b = &builder->b; in patch()
937 nir_ssa_def *draw_ptr = builder->draw.draw_buf; in patch()
940 builder->draw.vertex_count = get_indexed_draw_field(b, draw_ptr, count); in patch()
941 builder->draw.start_instance = get_indexed_draw_field(b, draw_ptr, start_instance); in patch()
942 builder->draw.instance_count = in patch()
944 builder->draw.vertex_start = get_indexed_draw_field(b, draw_ptr, start); in patch()
945 builder->draw.index_bias = get_indexed_draw_field(b, draw_ptr, index_bias); in patch()
947 builder->draw.vertex_count = get_draw_field(b, draw_ptr, count); in patch()
948 builder->draw.start_instance = get_draw_field(b, draw_ptr, start_instance); in patch()
949 builder->draw.instance_count = get_draw_field(b, draw_ptr, instance_count); in patch()
950 builder->draw.vertex_start = get_draw_field(b, draw_ptr, start); in patch()
953 assert(builder->draw.vertex_count->num_components); in patch()
956 nir_imul(b, builder->draw.vertex_count, builder->draw.instance_count); in patch()
962 if (!(builder->flags & PAN_INDIRECT_DRAW_IDVS)) in patch()
963 set_null_job(builder, builder->jobs.vertex_job); in patch()
965 set_null_job(builder, builder->jobs.tiler_job); in patch()
967 get_instance_size(builder); in patch()
969 nir_ssa_def *count = builder->instance_size.raw; in patch()
972 if (builder->flags & PAN_INDIRECT_DRAW_IDVS) in patch()
975 builder->instance_size.padded = in patch()
977 &builder->instance_size.packed); in patch()
979 update_varyings(builder); in patch()
980 update_jobs(builder); in patch()
981 update_vertex_attribs(builder); in patch()
983 IF (nir_ine(b, builder->jobs.first_vertex_sysval, nir_imm_int64(b, 0))) { in patch()
984 store_global(b, builder->jobs.first_vertex_sysval, in patch()
985 builder->jobs.offset_start, 1); in patch()
988 IF (nir_ine(b, builder->jobs.base_vertex_sysval, nir_imm_int64(b, 0))) { in patch()
989 store_global(b, builder->jobs.base_vertex_sysval, in patch()
991 builder->draw.index_bias : in patch()
996 IF (nir_ine(b, builder->jobs.base_instance_sysval, nir_imm_int64(b, 0))) { in patch()
997 store_global(b, builder->jobs.base_instance_sysval, in patch()
998 builder->draw.start_instance, 1); in patch()
1006 get_index_min_max(struct indirect_draw_shader_builder *builder) in get_index_min_max() argument
1008 nir_ssa_def *restart_index = builder->draw.restart_index; in get_index_min_max()
1009 unsigned index_size = builder->index_size; in get_index_min_max()
1010 nir_builder *b = &builder->b; in get_index_min_max()
1012 nir_ssa_def *draw_ptr = builder->draw.draw_buf; in get_index_min_max()
1014 builder->draw.vertex_count = get_draw_field(b, draw_ptr, count); in get_index_min_max()
1015 builder->draw.vertex_start = get_draw_field(b, draw_ptr, start); in get_index_min_max()
1026 get_address(b, builder->draw.index_buf, in get_index_min_max()
1027 nir_imul_imm(b, builder->draw.vertex_start, index_size)); in get_index_min_max()
1032 nir_iadd(b, start, nir_imul_imm(b, builder->draw.vertex_count, index_size)); in get_index_min_max()
1080 update_min(builder, nir_load_var(b, min_var)); in get_index_min_max()
1081 update_max(builder, nir_load_var(b, max_var)); in get_index_min_max()
1108 struct indirect_draw_shader_builder builder; in create_indirect_draw_shader() local
1109 init_shader_builder(&builder, dev, flags, index_size, index_min_max_search); in create_indirect_draw_shader()
1111 nir_builder *b = &builder.b; in create_indirect_draw_shader()
1114 get_index_min_max(&builder); in create_indirect_draw_shader()
1116 patch(&builder); in create_indirect_draw_shader()