diff options
author | Dave Airlie <[email protected]> | 2019-06-29 07:34:18 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2019-08-27 12:29:21 +1000 |
commit | a8ef6b5755c49118dc77dea6bb4b1087ef74ccc2 (patch) | |
tree | 9057689c016430edb0994a64eaddc61623c16458 /src/gallium/drivers/llvmpipe/lp_jit.c | |
parent | 1eda49cc3de22e97a70944367d17d5afe611f3cc (diff) |
llvmpipe: refactor jit type creation
This just cleans the code up so the texture/sampler type
creation can be reused.
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_jit.c')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_jit.c | 163 |
1 files changed, 87 insertions, 76 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index d5527e30d9b..de21abf212a 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -40,6 +40,91 @@ #include "lp_context.h" #include "lp_jit.h" +static LLVMTypeRef +create_jit_texture_type(struct gallivm_state *gallivm) +{ + LLVMContextRef lc = gallivm->context; + LLVMTypeRef texture_type; + LLVMTypeRef elem_types[LP_JIT_TEXTURE_NUM_FIELDS]; + + /* struct lp_jit_texture */ + elem_types[LP_JIT_TEXTURE_WIDTH] = + elem_types[LP_JIT_TEXTURE_HEIGHT] = + elem_types[LP_JIT_TEXTURE_DEPTH] = + elem_types[LP_JIT_TEXTURE_FIRST_LEVEL] = + elem_types[LP_JIT_TEXTURE_LAST_LEVEL] = LLVMInt32TypeInContext(lc); + elem_types[LP_JIT_TEXTURE_BASE] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0); + elem_types[LP_JIT_TEXTURE_ROW_STRIDE] = + elem_types[LP_JIT_TEXTURE_IMG_STRIDE] = + elem_types[LP_JIT_TEXTURE_MIP_OFFSETS] = + LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TEXTURE_LEVELS); + + texture_type = LLVMStructTypeInContext(lc, elem_types, + ARRAY_SIZE(elem_types), 0); + + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, width, + gallivm->target, texture_type, + LP_JIT_TEXTURE_WIDTH); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, height, + gallivm->target, texture_type, + LP_JIT_TEXTURE_HEIGHT); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, depth, + gallivm->target, texture_type, + LP_JIT_TEXTURE_DEPTH); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, first_level, + gallivm->target, texture_type, + LP_JIT_TEXTURE_FIRST_LEVEL); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, last_level, + gallivm->target, texture_type, + LP_JIT_TEXTURE_LAST_LEVEL); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, base, + gallivm->target, texture_type, + LP_JIT_TEXTURE_BASE); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, row_stride, + gallivm->target, texture_type, + LP_JIT_TEXTURE_ROW_STRIDE); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, img_stride, + gallivm->target, texture_type, + LP_JIT_TEXTURE_IMG_STRIDE); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, mip_offsets, + gallivm->target, texture_type, + LP_JIT_TEXTURE_MIP_OFFSETS); + LP_CHECK_STRUCT_SIZE(struct lp_jit_texture, + gallivm->target, texture_type); + return texture_type; +} + +static LLVMTypeRef +create_jit_sampler_type(struct gallivm_state *gallivm) +{ + LLVMContextRef lc = gallivm->context; + LLVMTypeRef sampler_type; + LLVMTypeRef elem_types[LP_JIT_SAMPLER_NUM_FIELDS]; + elem_types[LP_JIT_SAMPLER_MIN_LOD] = + elem_types[LP_JIT_SAMPLER_MAX_LOD] = + elem_types[LP_JIT_SAMPLER_LOD_BIAS] = LLVMFloatTypeInContext(lc); + elem_types[LP_JIT_SAMPLER_BORDER_COLOR] = + LLVMArrayType(LLVMFloatTypeInContext(lc), 4); + + sampler_type = LLVMStructTypeInContext(lc, elem_types, + ARRAY_SIZE(elem_types), 0); + + LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, min_lod, + gallivm->target, sampler_type, + LP_JIT_SAMPLER_MIN_LOD); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, max_lod, + gallivm->target, sampler_type, + LP_JIT_SAMPLER_MAX_LOD); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, lod_bias, + gallivm->target, sampler_type, + LP_JIT_SAMPLER_LOD_BIAS); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, border_color, + gallivm->target, sampler_type, + LP_JIT_SAMPLER_BORDER_COLOR); + LP_CHECK_STRUCT_SIZE(struct lp_jit_sampler, + gallivm->target, sampler_type); + return sampler_type; +} static void lp_jit_create_types(struct lp_fragment_shader_variant *lp) @@ -68,82 +153,8 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) gallivm->target, viewport_type); } - /* struct lp_jit_texture */ - { - LLVMTypeRef elem_types[LP_JIT_TEXTURE_NUM_FIELDS]; - - elem_types[LP_JIT_TEXTURE_WIDTH] = - elem_types[LP_JIT_TEXTURE_HEIGHT] = - elem_types[LP_JIT_TEXTURE_DEPTH] = - elem_types[LP_JIT_TEXTURE_FIRST_LEVEL] = - elem_types[LP_JIT_TEXTURE_LAST_LEVEL] = LLVMInt32TypeInContext(lc); - elem_types[LP_JIT_TEXTURE_BASE] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0); - elem_types[LP_JIT_TEXTURE_ROW_STRIDE] = - elem_types[LP_JIT_TEXTURE_IMG_STRIDE] = - elem_types[LP_JIT_TEXTURE_MIP_OFFSETS] = - LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TEXTURE_LEVELS); - - texture_type = LLVMStructTypeInContext(lc, elem_types, - ARRAY_SIZE(elem_types), 0); - - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, width, - gallivm->target, texture_type, - LP_JIT_TEXTURE_WIDTH); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, height, - gallivm->target, texture_type, - LP_JIT_TEXTURE_HEIGHT); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, depth, - gallivm->target, texture_type, - LP_JIT_TEXTURE_DEPTH); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, first_level, - gallivm->target, texture_type, - LP_JIT_TEXTURE_FIRST_LEVEL); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, last_level, - gallivm->target, texture_type, - LP_JIT_TEXTURE_LAST_LEVEL); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, base, - gallivm->target, texture_type, - LP_JIT_TEXTURE_BASE); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, row_stride, - gallivm->target, texture_type, - LP_JIT_TEXTURE_ROW_STRIDE); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, img_stride, - gallivm->target, texture_type, - LP_JIT_TEXTURE_IMG_STRIDE); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, mip_offsets, - gallivm->target, texture_type, - LP_JIT_TEXTURE_MIP_OFFSETS); - LP_CHECK_STRUCT_SIZE(struct lp_jit_texture, - gallivm->target, texture_type); - } - - /* struct lp_jit_sampler */ - { - LLVMTypeRef elem_types[LP_JIT_SAMPLER_NUM_FIELDS]; - elem_types[LP_JIT_SAMPLER_MIN_LOD] = - elem_types[LP_JIT_SAMPLER_MAX_LOD] = - elem_types[LP_JIT_SAMPLER_LOD_BIAS] = LLVMFloatTypeInContext(lc); - elem_types[LP_JIT_SAMPLER_BORDER_COLOR] = - LLVMArrayType(LLVMFloatTypeInContext(lc), 4); - - sampler_type = LLVMStructTypeInContext(lc, elem_types, - ARRAY_SIZE(elem_types), 0); - - LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, min_lod, - gallivm->target, sampler_type, - LP_JIT_SAMPLER_MIN_LOD); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, max_lod, - gallivm->target, sampler_type, - LP_JIT_SAMPLER_MAX_LOD); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, lod_bias, - gallivm->target, sampler_type, - LP_JIT_SAMPLER_LOD_BIAS); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, border_color, - gallivm->target, sampler_type, - LP_JIT_SAMPLER_BORDER_COLOR); - LP_CHECK_STRUCT_SIZE(struct lp_jit_sampler, - gallivm->target, sampler_type); - } + texture_type = create_jit_texture_type(gallivm); + sampler_type = create_jit_sampler_type(gallivm); /* struct lp_jit_context */ { |