diff options
author | Roland Scheidegger <[email protected]> | 2015-03-29 23:21:56 +0200 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2015-03-31 17:23:51 +0200 |
commit | 73c6914195bd3cc81f52192d4ec8e23fc6239c41 (patch) | |
tree | a4508fa2c171bf6723858ff7c0a28198096f6704 /src/gallium | |
parent | 1863ed21ffbb3ab7fd9875dc25e32ececea79d50 (diff) |
gallivm: add gather support to sampler interface
Luckily thanks to the revamped interface this is a lot less work now...
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_sample.h | 18 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 31 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 6 |
3 files changed, 34 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index b95ee6fb56f..640b7e0d7e0 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -76,13 +76,21 @@ enum lp_sampler_lod_control { }; +enum lp_sampler_op_type { + LP_SAMPLER_OP_TEXTURE, + LP_SAMPLER_OP_FETCH, + LP_SAMPLER_OP_GATHER +}; + + #define LP_SAMPLER_SHADOW (1 << 0) #define LP_SAMPLER_OFFSETS (1 << 1) -#define LP_SAMPLER_FETCH (1 << 2) -#define LP_SAMPLER_LOD_CONTROL_SHIFT 3 -#define LP_SAMPLER_LOD_CONTROL_MASK (3 << 3) -#define LP_SAMPLER_LOD_PROPERTY_SHIFT 5 -#define LP_SAMPLER_LOD_PROPERTY_MASK (3 << 5) +#define LP_SAMPLER_OP_TYPE_SHIFT 2 +#define LP_SAMPLER_OP_TYPE_MASK (3 << 2) +#define LP_SAMPLER_LOD_CONTROL_SHIFT 4 +#define LP_SAMPLER_LOD_CONTROL_MASK (3 << 4) +#define LP_SAMPLER_LOD_PROPERTY_SHIFT 6 +#define LP_SAMPLER_LOD_PROPERTY_MASK (3 << 6) struct lp_sampler_params { diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 82ef359ed30..962f478f568 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -2391,9 +2391,10 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, LLVMValueRef tex_width, newcoords[5]; enum lp_sampler_lod_property lod_property; enum lp_sampler_lod_control lod_control; + enum lp_sampler_op_type op_type; LLVMValueRef lod_bias = NULL; LLVMValueRef explicit_lod = NULL; - boolean is_fetch = !!(sample_key & LP_SAMPLER_FETCH); + boolean op_is_tex; if (0) { enum pipe_format fmt = static_texture_state->format; @@ -2404,6 +2405,10 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, LP_SAMPLER_LOD_PROPERTY_SHIFT; lod_control = (sample_key & LP_SAMPLER_LOD_CONTROL_MASK) >> LP_SAMPLER_LOD_CONTROL_SHIFT; + op_type = (sample_key & LP_SAMPLER_OP_TYPE_MASK) >> + LP_SAMPLER_OP_TYPE_SHIFT; + + op_is_tex = op_type == LP_SAMPLER_OP_TEXTURE; if (lod_control == LP_SAMPLER_LOD_BIAS) { lod_bias = lod; @@ -2534,7 +2539,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, (gallivm_debug & GALLIVM_DEBUG_NO_RHO_APPROX) && (static_texture_state->target == PIPE_TEXTURE_CUBE || static_texture_state->target == PIPE_TEXTURE_CUBE_ARRAY) && - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { /* * special case for using per-pixel lod even for implicit lod, * which is generally never required (ok by APIs) except to please @@ -2548,23 +2553,23 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, } else if (lod_property == LP_SAMPLER_LOD_PER_ELEMENT || (explicit_lod || lod_bias || derivs)) { - if ((is_fetch && target != PIPE_BUFFER) || - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + if ((!op_is_tex && target != PIPE_BUFFER) || + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { bld.num_mips = type.length; bld.num_lods = type.length; } - else if (!is_fetch && min_img_filter != mag_img_filter) { + else if (op_is_tex && min_img_filter != mag_img_filter) { bld.num_mips = 1; bld.num_lods = type.length; } } /* TODO: for true scalar_lod should only use 1 lod value */ - else if ((is_fetch && explicit_lod && target != PIPE_BUFFER) || - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + else if ((!op_is_tex && explicit_lod && target != PIPE_BUFFER) || + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { bld.num_mips = num_quads; bld.num_lods = num_quads; } - else if (!is_fetch && min_img_filter != mag_img_filter) { + else if (op_is_tex && min_img_filter != mag_img_filter) { bld.num_mips = 1; bld.num_lods = num_quads; } @@ -2658,7 +2663,7 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, texel_out); } - else if (is_fetch) { + else if (op_type == LP_SAMPLER_OP_FETCH) { lp_build_fetch_texel(&bld, texture_index, newcoords, lod, offsets, texel_out); @@ -2786,18 +2791,18 @@ lp_build_sample_soa_code(struct gallivm_state *gallivm, (gallivm_debug & GALLIVM_DEBUG_NO_RHO_APPROX) && (static_texture_state->target == PIPE_TEXTURE_CUBE || static_texture_state->target == PIPE_TEXTURE_CUBE_ARRAY) && - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { bld4.num_mips = type4.length; bld4.num_lods = type4.length; } if (lod_property == LP_SAMPLER_LOD_PER_ELEMENT && (explicit_lod || lod_bias || derivs)) { - if ((is_fetch && target != PIPE_BUFFER) || - (!is_fetch && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { + if ((!op_is_tex && target != PIPE_BUFFER) || + (op_is_tex && mip_filter != PIPE_TEX_MIPFILTER_NONE)) { bld4.num_mips = type4.length; bld4.num_lods = type4.length; } - else if (!is_fetch && min_img_filter != mag_img_filter) { + else if (op_is_tex && min_img_filter != mag_img_filter) { bld4.num_mips = 1; bld4.num_lods = type4.length; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 6a71da68acd..ae527b24130 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1974,7 +1974,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld, unsigned num_derivs, num_offsets, i; unsigned shadow_coord = 0; unsigned layer_coord = 0; - unsigned sample_key = 0; + unsigned sample_key = LP_SAMPLER_OP_TEXTURE << LP_SAMPLER_OP_TYPE_SHIFT; memset(¶ms, 0, sizeof(params)); @@ -2179,7 +2179,7 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, unsigned num_offsets, num_derivs, i; unsigned layer_coord = 0; - unsigned sample_key = 0; + unsigned sample_key = LP_SAMPLER_OP_TEXTURE << LP_SAMPLER_OP_TYPE_SHIFT; memset(¶ms, 0, sizeof(params)); @@ -2356,7 +2356,7 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld, enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; unsigned dims, i; unsigned layer_coord = 0; - unsigned sample_key = LP_SAMPLER_FETCH; + unsigned sample_key = LP_SAMPLER_OP_FETCH << LP_SAMPLER_OP_TYPE_SHIFT; memset(¶ms, 0, sizeof(params)); |