X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Fdraw%2Fdraw_llvm_sample.c;h=1845c0560a958b606577398e8cb3f31472a2e877;hb=3a26ef23e78f811abdfe657b52b9bc057b9ce5b6;hp=97b025565c3106c209bb6fbc5e626912af0404f9;hpb=894d4903e7325620fa2344ce1640658346b3e75f;p=mesa.git diff --git a/src/gallium/auxiliary/draw/draw_llvm_sample.c b/src/gallium/auxiliary/draw/draw_llvm_sample.c index 97b025565c3..1845c0560a9 100644 --- a/src/gallium/auxiliary/draw/draw_llvm_sample.c +++ b/src/gallium/auxiliary/draw/draw_llvm_sample.c @@ -59,8 +59,6 @@ struct draw_llvm_sampler_dynamic_state struct lp_sampler_dynamic_state base; const struct draw_sampler_static_state *static_state; - - LLVMValueRef context_ptr; }; @@ -86,14 +84,13 @@ struct draw_llvm_sampler_soa static LLVMValueRef draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base, struct gallivm_state *gallivm, + LLVMValueRef context_ptr, unsigned texture_unit, unsigned member_index, const char *member_name, boolean emit_load) { LLVMBuilderRef builder = gallivm->builder; - struct draw_llvm_sampler_dynamic_state *state = - (struct draw_llvm_sampler_dynamic_state *)base; LLVMValueRef indices[4]; LLVMValueRef ptr; LLVMValueRef res; @@ -109,7 +106,7 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base, /* context[0].textures[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); - ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); + ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), ""); if (emit_load) res = LLVMBuildLoad(builder, ptr, ""); @@ -133,14 +130,13 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base, static LLVMValueRef draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, struct gallivm_state *gallivm, + LLVMValueRef context_ptr, unsigned sampler_unit, unsigned member_index, const char *member_name, boolean emit_load) { LLVMBuilderRef builder = gallivm->builder; - struct draw_llvm_sampler_dynamic_state *state = - (struct draw_llvm_sampler_dynamic_state *)base; LLVMValueRef indices[4]; LLVMValueRef ptr; LLVMValueRef res; @@ -156,7 +152,7 @@ draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, /* context[0].samplers[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); - ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); + ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), ""); if (emit_load) res = LLVMBuildLoad(builder, ptr, ""); @@ -182,9 +178,11 @@ draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base, static LLVMValueRef \ draw_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \ struct gallivm_state *gallivm, \ + LLVMValueRef context_ptr, \ unsigned texture_unit) \ { \ - return draw_llvm_texture_member(base, gallivm, texture_unit, _index, #_name, _emit_load ); \ + return draw_llvm_texture_member(base, gallivm, context_ptr, \ + texture_unit, _index, #_name, _emit_load ); \ } @@ -203,9 +201,11 @@ DRAW_LLVM_TEXTURE_MEMBER(mip_offsets, DRAW_JIT_TEXTURE_MIP_OFFSETS, FALSE) static LLVMValueRef \ draw_llvm_sampler_##_name( const struct lp_sampler_dynamic_state *base, \ struct gallivm_state *gallivm, \ + LLVMValueRef context_ptr, \ unsigned sampler_unit) \ { \ - return draw_llvm_sampler_member(base, gallivm, sampler_unit, _index, #_name, _emit_load ); \ + return draw_llvm_sampler_member(base, gallivm, context_ptr, \ + sampler_unit, _index, #_name, _emit_load ); \ } @@ -229,36 +229,19 @@ draw_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler) static void draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, struct gallivm_state *gallivm, - struct lp_type type, - boolean is_fetch, - unsigned texture_index, - unsigned sampler_index, - const LLVMValueRef *coords, - const LLVMValueRef *offsets, - const struct lp_derivatives *derivs, - LLVMValueRef lod_bias, /* optional */ - LLVMValueRef explicit_lod, /* optional */ - boolean scalar_lod, - LLVMValueRef *texel) + const struct lp_sampler_params *params) { struct draw_llvm_sampler_soa *sampler = (struct draw_llvm_sampler_soa *)base; + unsigned texture_index = params->texture_index; + unsigned sampler_index = params->sampler_index; assert(texture_index < PIPE_MAX_SHADER_SAMPLER_VIEWS); assert(sampler_index < PIPE_MAX_SAMPLERS); - lp_build_sample_soa(gallivm, - &sampler->dynamic_state.static_state[texture_index].texture_state, + lp_build_sample_soa(&sampler->dynamic_state.static_state[texture_index].texture_state, &sampler->dynamic_state.static_state[sampler_index].sampler_state, &sampler->dynamic_state.base, - type, - is_fetch, - texture_index, - sampler_index, - coords, - offsets, - derivs, - lod_bias, explicit_lod, scalar_lod, - texel); + gallivm, params); } @@ -268,42 +251,29 @@ draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base, static void draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base, struct gallivm_state *gallivm, - struct lp_type type, - unsigned texture_unit, - unsigned target, - boolean is_sviewinfo, - boolean scalar_lod, - LLVMValueRef explicit_lod, /* optional */ - LLVMValueRef *sizes_out) + const struct lp_sampler_size_query_params *params) { struct draw_llvm_sampler_soa *sampler = (struct draw_llvm_sampler_soa *)base; - assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS); + assert(params->texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS); lp_build_size_query_soa(gallivm, - &sampler->dynamic_state.static_state[texture_unit].texture_state, + &sampler->dynamic_state.static_state[params->texture_unit].texture_state, &sampler->dynamic_state.base, - type, - texture_unit, - target, - is_sviewinfo, - scalar_lod, - explicit_lod, - sizes_out); + params); } struct lp_build_sampler_soa * -draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state, - LLVMValueRef context_ptr) +draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state) { struct draw_llvm_sampler_soa *sampler; sampler = CALLOC_STRUCT(draw_llvm_sampler_soa); - if(!sampler) + if (!sampler) return NULL; sampler->base.destroy = draw_llvm_sampler_soa_destroy; - sampler->base.emit_fetch_texel = draw_llvm_sampler_soa_emit_fetch_texel; + sampler->base.emit_tex_sample = draw_llvm_sampler_soa_emit_fetch_texel; sampler->base.emit_size_query = draw_llvm_sampler_soa_emit_size_query; sampler->dynamic_state.base.width = draw_llvm_texture_width; sampler->dynamic_state.base.height = draw_llvm_texture_height; @@ -319,7 +289,6 @@ draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_stat sampler->dynamic_state.base.lod_bias = draw_llvm_sampler_lod_bias; sampler->dynamic_state.base.border_color = draw_llvm_sampler_border_color; sampler->dynamic_state.static_state = static_state; - sampler->dynamic_state.context_ptr = context_ptr; return &sampler->base; }