summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_format_soa.c')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_format_soa.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
index afaabc0..42aef83 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
@@ -346,6 +346,7 @@ lp_build_rgba8_to_fi32_soa(struct gallivm_state *gallivm,
* \param i, j the sub-block pixel coordinates. For non-compressed formats
* these will always be (0,0). For compressed formats, i will
* be in [0, block_width-1] and j will be in [0, block_height-1].
+ * \param cache optional value pointing to a lp_build_format_cache structure
*/
void
lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
@@ -355,6 +356,7 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
LLVMValueRef offset,
LLVMValueRef i,
LLVMValueRef j,
+ LLVMValueRef cache,
LLVMValueRef rgba_out[4])
{
LLVMBuilderRef builder = gallivm->builder;
@@ -473,7 +475,7 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
tmp_type.norm = TRUE;
tmp = lp_build_fetch_rgba_aos(gallivm, format_desc, tmp_type,
- TRUE, base_ptr, offset, i, j);
+ TRUE, base_ptr, offset, i, j, cache);
lp_build_rgba8_to_fi32_soa(gallivm,
type,
@@ -483,6 +485,37 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
return;
}
+ if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC &&
+ /* non-srgb case is already handled above */
+ format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB &&
+ type.floating && type.width == 32 &&
+ (type.length == 1 || (type.length % 4 == 0)) &&
+ cache) {
+ const struct util_format_description *format_decompressed;
+ LLVMValueRef packed;
+ packed = lp_build_fetch_cached_texels(gallivm,
+ format_desc,
+ type.length,
+ base_ptr,
+ offset,
+ i, j,
+ cache);
+ packed = LLVMBuildBitCast(builder, packed,
+ lp_build_int_vec_type(gallivm, type), "");
+ /*
+ * The values are now packed so they match ordinary srgb RGBA8 format,
+ * hence need to use matching format for unpack.
+ */
+ format_decompressed = util_format_description(PIPE_FORMAT_R8G8B8A8_SRGB);
+
+ lp_build_unpack_rgba_soa(gallivm,
+ format_decompressed,
+ type,
+ packed, rgba_out);
+
+ return;
+ }
+
/*
* Fallback to calling lp_build_fetch_rgba_aos for each pixel.
*
@@ -524,7 +557,7 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
/* Get a single float[4]={R,G,B,A} pixel */
tmp = lp_build_fetch_rgba_aos(gallivm, format_desc, tmp_type,
TRUE, base_ptr, offset_elem,
- i_elem, j_elem);
+ i_elem, j_elem, cache);
/*
* Insert the AoS tmp value channels into the SoA result vectors at