From f1b752f6502b890a25ebe4c3b95a5c86e22f320a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 7 Jun 2023 14:33:34 +1000 Subject: [PATCH] draw: rename jit to vs_jit in lots of places. we should have done this when geom shaders got added, do it now, will make it easier to consolidate some code in macros Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/draw/draw_llvm.c | 44 +++++++++++----------- src/gallium/auxiliary/draw/draw_llvm.h | 22 +++++------ .../draw/draw_pt_fetch_shade_pipeline_llvm.c | 26 ++++++------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 0b25bda..ef5e8f4 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -148,23 +148,23 @@ create_jit_dvbuffer_type(struct gallivm_state *gallivm, * Create LLVM type for struct draw_jit_context */ static LLVMTypeRef -create_jit_context_type(struct gallivm_state *gallivm, const char *struct_name) +create_vs_jit_context_type(struct gallivm_state *gallivm, const char *struct_name) { LLVMTargetDataRef target = gallivm->target; LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context); - LLVMTypeRef elem_types[DRAW_JIT_CTX_NUM_FIELDS]; + LLVMTypeRef elem_types[DRAW_VS_JIT_CTX_NUM_FIELDS]; - elem_types[DRAW_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES), 0); - elem_types[DRAW_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0); + elem_types[DRAW_VS_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES), 0); + elem_types[DRAW_VS_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0); LLVMTypeRef context_type = LLVMStructTypeInContext(gallivm->context, elem_types, ARRAY_SIZE(elem_types), 0); (void) target; /* silence unused var warning for non-debug build */ - LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, planes, - target, context_type, DRAW_JIT_CTX_PLANES); - LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, viewports, - target, context_type, DRAW_JIT_CTX_VIEWPORT); - LP_CHECK_STRUCT_SIZE(struct draw_jit_context, + LP_CHECK_MEMBER_OFFSET(struct draw_vs_jit_context, planes, + target, context_type, DRAW_VS_JIT_CTX_PLANES); + LP_CHECK_MEMBER_OFFSET(struct draw_vs_jit_context, viewports, + target, context_type, DRAW_VS_JIT_CTX_VIEWPORT); + LP_CHECK_STRUCT_SIZE(struct draw_vs_jit_context, target, context_type); return context_type; @@ -329,11 +329,11 @@ create_tes_jit_input_deref_type(struct gallivm_state *gallivm) * Create LLVM types for various structures. */ static void -create_jit_types(struct draw_llvm_variant *variant) +create_vs_jit_types(struct draw_llvm_variant *variant) { struct gallivm_state *gallivm = variant->gallivm; - variant->context_type = create_jit_context_type(gallivm, "draw_jit_context"); + variant->context_type = create_vs_jit_context_type(gallivm, "draw_vs_jit_context"); variant->context_ptr_type = LLVMPointerType(variant->context_type, 0); variant->resources_type = lp_build_jit_resources_type(gallivm); @@ -351,7 +351,7 @@ static LLVMTypeRef get_context_ptr_type(struct draw_llvm_variant *variant) { if (!variant->context_ptr_type) - create_jit_types(variant); + create_vs_jit_types(variant); return variant->context_ptr_type; } @@ -360,7 +360,7 @@ static LLVMTypeRef get_buffer_ptr_type(struct draw_llvm_variant *variant) { if (!variant->buffer_ptr_type) - create_jit_types(variant); + create_vs_jit_types(variant); return variant->buffer_ptr_type; } @@ -369,7 +369,7 @@ static LLVMTypeRef get_vb_ptr_type(struct draw_llvm_variant *variant) { if (!variant->vb_ptr_type) - create_jit_types(variant); + create_vs_jit_types(variant); return variant->vb_ptr_type; } @@ -515,7 +515,7 @@ draw_llvm_create_variant(struct draw_llvm *llvm, } variant->gallivm = gallivm_create(module_name, llvm->context, &cached); - create_jit_types(variant); + create_vs_jit_types(variant); if (gallivm_debug & (GALLIVM_DEBUG_TGSI | GALLIVM_DEBUG_IR)) { if (llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_TGSI) @@ -1086,7 +1086,7 @@ generate_viewport(struct draw_llvm_variant *variant, LLVMTypeRef vs_type_llvm = lp_build_vec_type(gallivm, vs_type); LLVMValueRef out3 = LLVMBuildLoad2(builder, vs_type_llvm, outputs[pos][3], ""); /*w0 w1 .. wn*/ LLVMValueRef const1 = lp_build_const_vec(gallivm, f32_type, 1.0); /*1.0 1.0 1.0 1.0*/ - LLVMValueRef vp_ptr = draw_jit_context_viewports(variant, context_ptr); + LLVMValueRef vp_ptr = draw_vs_jit_context_viewports(variant, context_ptr); /* We treat pipe_viewport_state as a float array */ const int scale_index_offset = offsetof(struct pipe_viewport_state, scale) / sizeof(float); @@ -1258,7 +1258,7 @@ generate_clipmask(struct draw_llvm *llvm, } if (clip_user) { - LLVMValueRef planes_ptr = draw_jit_context_planes(gallivm, context_type, context_ptr); + LLVMValueRef planes_ptr = draw_vs_jit_context_planes(gallivm, context_type, context_ptr); LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context); LLVMTypeRef planes_type = LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES); LLVMValueRef indices[3]; @@ -2158,8 +2158,8 @@ draw_llvm_set_mapped_texture(struct draw_context *draw, switch (shader_stage) { case PIPE_SHADER_VERTEX: - assert(sview_idx < ARRAY_SIZE(draw->llvm->jit_resources.textures)); - jit_tex = &draw->llvm->jit_resources.textures[sview_idx]; + assert(sview_idx < ARRAY_SIZE(draw->llvm->vs_jit_resources.textures)); + jit_tex = &draw->llvm->vs_jit_resources.textures[sview_idx]; break; case PIPE_SHADER_GEOMETRY: assert(sview_idx < ARRAY_SIZE(draw->llvm->gs_jit_resources.textures)); @@ -2210,8 +2210,8 @@ draw_llvm_set_mapped_image(struct draw_context *draw, switch (shader_stage) { case PIPE_SHADER_VERTEX: - assert(idx < ARRAY_SIZE(draw->llvm->jit_resources.images)); - jit_image = &draw->llvm->jit_resources.images[idx]; + assert(idx < ARRAY_SIZE(draw->llvm->vs_jit_resources.images)); + jit_image = &draw->llvm->vs_jit_resources.images[idx]; break; case PIPE_SHADER_GEOMETRY: assert(idx < ARRAY_SIZE(draw->llvm->gs_jit_resources.images)); @@ -2249,7 +2249,7 @@ draw_llvm_set_sampler_state(struct draw_context *draw, switch (shader_type) { case PIPE_SHADER_VERTEX: for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_VERTEX]; i++) { - struct lp_jit_sampler *jit_sam = &draw->llvm->jit_resources.samplers[i]; + struct lp_jit_sampler *jit_sam = &draw->llvm->vs_jit_resources.samplers[i]; if (draw->samplers[PIPE_SHADER_VERTEX][i]) { const struct pipe_sampler_state *s diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index 976dfcb..d10debc 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -60,23 +60,23 @@ struct llvm_tess_eval_shader; * Only use types with a clear size and padding here, in particular prefer the * stdint.h types to the basic integer types. */ -struct draw_jit_context +struct draw_vs_jit_context { float (*planes) [DRAW_TOTAL_CLIP_PLANES][4]; struct pipe_viewport_state *viewports; }; enum { - DRAW_JIT_CTX_PLANES = 0, - DRAW_JIT_CTX_VIEWPORT = 1, - DRAW_JIT_CTX_NUM_FIELDS + DRAW_VS_JIT_CTX_PLANES = 0, + DRAW_VS_JIT_CTX_VIEWPORT = 1, + DRAW_VS_JIT_CTX_NUM_FIELDS }; -#define draw_jit_context_planes(_gallivm, _type, _ptr) \ - lp_build_struct_get2(_gallivm, _type, _ptr, DRAW_JIT_CTX_PLANES, "planes") +#define draw_vs_jit_context_planes(_gallivm, _type, _ptr) \ + lp_build_struct_get2(_gallivm, _type, _ptr, DRAW_VS_JIT_CTX_PLANES, "planes") -#define draw_jit_context_viewports(_variant, _ptr) \ - lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_VIEWPORT, "viewports") +#define draw_vs_jit_context_viewports(_variant, _ptr) \ + lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_VS_JIT_CTX_VIEWPORT, "viewports") #define draw_jit_vbuffer_stride(_gallivm, _type, _ptr) \ @@ -145,7 +145,7 @@ enum { typedef boolean -(*draw_jit_vert_func)(struct draw_jit_context *context, +(*draw_jit_vert_func)(struct draw_vs_jit_context *context, const struct lp_jit_resources *resources, struct vertex_header *io, const struct draw_vertex_buffer vbuffers[PIPE_MAX_ATTRIBS], @@ -544,10 +544,10 @@ struct draw_llvm { LLVMContextRef context; boolean context_owned; - struct draw_jit_context jit_context; + struct draw_vs_jit_context vs_jit_context; struct draw_gs_jit_context gs_jit_context; - struct lp_jit_resources jit_resources; + struct lp_jit_resources vs_jit_resources; struct lp_jit_resources gs_jit_resources; struct lp_jit_resources tcs_jit_resources; struct lp_jit_resources tes_jit_resources; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index 3672755..b3c8ab3 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -432,25 +432,25 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle) struct draw_llvm *llvm = fpme->llvm; unsigned i; - for (i = 0; i < ARRAY_SIZE(llvm->jit_resources.constants); ++i) { + for (i = 0; i < ARRAY_SIZE(llvm->vs_jit_resources.constants); ++i) { /* * There could be a potential issue with rounding this up, as the * shader expects 16-byte allocations, the fix is likely to move * to LOAD intrinsic in the future and remove the vec4 constraint. */ int num_consts = get_num_consts_robust(draw, draw->pt.user.vs_constants_size, i); - llvm->jit_resources.constants[i].f = draw->pt.user.vs_constants[i]; - llvm->jit_resources.constants[i].num_elements = num_consts; + llvm->vs_jit_resources.constants[i].f = draw->pt.user.vs_constants[i]; + llvm->vs_jit_resources.constants[i].num_elements = num_consts; if (num_consts == 0) { - llvm->jit_resources.constants[i].f = fake_const_buf; + llvm->vs_jit_resources.constants[i].f = fake_const_buf; } } - for (i = 0; i < ARRAY_SIZE(llvm->jit_resources.ssbos); ++i) { + for (i = 0; i < ARRAY_SIZE(llvm->vs_jit_resources.ssbos); ++i) { int num_ssbos = draw->pt.user.vs_ssbos_size[i]; - llvm->jit_resources.ssbos[i].u = draw->pt.user.vs_ssbos[i]; - llvm->jit_resources.ssbos[i].num_elements = num_ssbos; + llvm->vs_jit_resources.ssbos[i].u = draw->pt.user.vs_ssbos[i]; + llvm->vs_jit_resources.ssbos[i].num_elements = num_ssbos; if (num_ssbos == 0) { - llvm->jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf; + llvm->vs_jit_resources.ssbos[i].u = (const uint32_t *)fake_const_buf; } } @@ -505,15 +505,15 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle) } } - llvm->jit_context.planes = + llvm->vs_jit_context.planes = (float (*)[DRAW_TOTAL_CLIP_PLANES][4]) draw->pt.user.planes[0]; llvm->gs_jit_context.planes = (float (*)[DRAW_TOTAL_CLIP_PLANES][4]) draw->pt.user.planes[0]; - llvm->jit_context.viewports = draw->viewports; + llvm->vs_jit_context.viewports = draw->viewports; llvm->gs_jit_context.viewports = draw->viewports; - llvm->jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table(); + llvm->vs_jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table(); llvm->gs_jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table(); llvm->tcs_jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table(); llvm->tes_jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table(); @@ -608,8 +608,8 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle, elts = fetch_info->elts; } /* Run vertex fetch shader */ - clipped = fpme->current_variant->jit_func(&fpme->llvm->jit_context, - &fpme->llvm->jit_resources, + clipped = fpme->current_variant->jit_func(&fpme->llvm->vs_jit_context, + &fpme->llvm->vs_jit_resources, llvm_vert_info.verts, draw->pt.user.vbuffer, fetch_info->count, -- 2.7.4