|
|
f06792 |
From e4e52b06a9dec7d076ceeb4469bb2ca8b37c6cd5 Mon Sep 17 00:00:00 2001
|
|
|
f06792 |
From: Lyude <lyude@redhat.com>
|
|
|
f06792 |
Date: Tue, 2 May 2017 17:05:50 -0400
|
|
|
f06792 |
Subject: [PATCH] Revert "draw: use SoA fetch, not AoS one"
|
|
|
f06792 |
|
|
|
f06792 |
This reverts commit e827d9175675aaa6cfc0b981e2a80685fb7b3a74.
|
|
|
f06792 |
|
|
|
f06792 |
Signed-off-by: Lyude <lyude@redhat.com>
|
|
|
f06792 |
---
|
|
|
f06792 |
src/gallium/auxiliary/draw/draw_llvm.c | 71 +++++++++++++++++++++++-----------
|
|
|
f06792 |
1 file changed, 48 insertions(+), 23 deletions(-)
|
|
|
f06792 |
|
|
|
f06792 |
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
|
|
|
f06792 |
index 8952dc8..19b75a5 100644
|
|
|
f06792 |
--- a/src/gallium/auxiliary/draw/draw_llvm.c
|
|
|
f06792 |
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
|
|
|
f06792 |
@@ -713,6 +713,39 @@ fetch_instanced(struct gallivm_state *gallivm,
|
|
|
f06792 |
|
|
|
f06792 |
|
|
|
f06792 |
static void
|
|
|
f06792 |
+convert_to_soa(struct gallivm_state *gallivm,
|
|
|
f06792 |
+ LLVMValueRef src_aos[LP_MAX_VECTOR_WIDTH / 32],
|
|
|
f06792 |
+ LLVMValueRef dst_soa[TGSI_NUM_CHANNELS],
|
|
|
f06792 |
+ const struct lp_type soa_type)
|
|
|
f06792 |
+{
|
|
|
f06792 |
+ unsigned j, k;
|
|
|
f06792 |
+ struct lp_type aos_channel_type = soa_type;
|
|
|
f06792 |
+
|
|
|
f06792 |
+ LLVMValueRef aos_channels[TGSI_NUM_CHANNELS];
|
|
|
f06792 |
+ unsigned pixels_per_channel = soa_type.length / TGSI_NUM_CHANNELS;
|
|
|
f06792 |
+
|
|
|
f06792 |
+ debug_assert(TGSI_NUM_CHANNELS == 4);
|
|
|
f06792 |
+ debug_assert((soa_type.length % TGSI_NUM_CHANNELS) == 0);
|
|
|
f06792 |
+
|
|
|
f06792 |
+ aos_channel_type.length >>= 1;
|
|
|
f06792 |
+
|
|
|
f06792 |
+ for (j = 0; j < TGSI_NUM_CHANNELS; ++j) {
|
|
|
f06792 |
+ LLVMValueRef channel[LP_MAX_VECTOR_LENGTH] = { 0 };
|
|
|
f06792 |
+
|
|
|
f06792 |
+ assert(pixels_per_channel <= LP_MAX_VECTOR_LENGTH);
|
|
|
f06792 |
+
|
|
|
f06792 |
+ for (k = 0; k < pixels_per_channel; ++k) {
|
|
|
f06792 |
+ channel[k] = src_aos[j + TGSI_NUM_CHANNELS * k];
|
|
|
f06792 |
+ }
|
|
|
f06792 |
+
|
|
|
f06792 |
+ aos_channels[j] = lp_build_concat(gallivm, channel, aos_channel_type, pixels_per_channel);
|
|
|
f06792 |
+ }
|
|
|
f06792 |
+
|
|
|
f06792 |
+ lp_build_transpose_aos(gallivm, soa_type, aos_channels, dst_soa);
|
|
|
f06792 |
+}
|
|
|
f06792 |
+
|
|
|
f06792 |
+
|
|
|
f06792 |
+static void
|
|
|
f06792 |
fetch_vector(struct gallivm_state *gallivm,
|
|
|
f06792 |
const struct util_format_description *format_desc,
|
|
|
f06792 |
struct lp_type vs_type,
|
|
|
f06792 |
@@ -722,10 +755,11 @@ fetch_vector(struct gallivm_state *gallivm,
|
|
|
f06792 |
LLVMValueRef *inputs,
|
|
|
f06792 |
LLVMValueRef indices)
|
|
|
f06792 |
{
|
|
|
f06792 |
+ LLVMValueRef zero = LLVMConstNull(LLVMInt32TypeInContext(gallivm->context));
|
|
|
f06792 |
LLVMBuilderRef builder = gallivm->builder;
|
|
|
f06792 |
struct lp_build_context blduivec;
|
|
|
f06792 |
- struct lp_type fetch_type = vs_type;
|
|
|
f06792 |
LLVMValueRef offset, valid_mask;
|
|
|
f06792 |
+ LLVMValueRef aos_fetch[LP_MAX_VECTOR_WIDTH / 32];
|
|
|
f06792 |
unsigned i;
|
|
|
f06792 |
|
|
|
f06792 |
lp_build_context_init(&blduivec, gallivm, lp_uint_type(vs_type));
|
|
|
f06792 |
@@ -749,37 +783,28 @@ fetch_vector(struct gallivm_state *gallivm,
|
|
|
f06792 |
}
|
|
|
f06792 |
|
|
|
f06792 |
/*
|
|
|
f06792 |
- * Unlike fetch_instanced, use SoA fetch instead of multiple AoS fetches.
|
|
|
f06792 |
- * This should always produce better code.
|
|
|
f06792 |
+ * Note: we probably really want to use SoA fetch, not AoS one (albeit
|
|
|
f06792 |
+ * for most formats it will amount to the same as this isn't very
|
|
|
f06792 |
+ * optimized). But looks dangerous since it assumes alignment.
|
|
|
f06792 |
*/
|
|
|
f06792 |
+ for (i = 0; i < vs_type.length; i++) {
|
|
|
f06792 |
+ LLVMValueRef offset1, elem;
|
|
|
f06792 |
+ elem = lp_build_const_int32(gallivm, i);
|
|
|
f06792 |
+ offset1 = LLVMBuildExtractElement(builder, offset, elem, "");
|
|
|
f06792 |
|
|
|
f06792 |
- /* The type handling is annoying here... */
|
|
|
f06792 |
- if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB &&
|
|
|
f06792 |
- format_desc->channel[0].pure_integer) {
|
|
|
f06792 |
- if (format_desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) {
|
|
|
f06792 |
- fetch_type = lp_type_int_vec(vs_type.width, vs_type.width * vs_type.length);
|
|
|
f06792 |
- }
|
|
|
f06792 |
- else if (format_desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) {
|
|
|
f06792 |
- fetch_type = lp_type_uint_vec(vs_type.width, vs_type.width * vs_type.length);
|
|
|
f06792 |
- }
|
|
|
f06792 |
- }
|
|
|
f06792 |
-
|
|
|
f06792 |
- lp_build_fetch_rgba_soa(gallivm, format_desc,
|
|
|
f06792 |
- fetch_type, FALSE, map_ptr, offset,
|
|
|
f06792 |
- blduivec.zero, blduivec.zero,
|
|
|
f06792 |
- NULL, inputs);
|
|
|
f06792 |
-
|
|
|
f06792 |
- for (i = 0; i < TGSI_NUM_CHANNELS; i++) {
|
|
|
f06792 |
- inputs[i] = LLVMBuildBitCast(builder, inputs[i],
|
|
|
f06792 |
- lp_build_vec_type(gallivm, vs_type), "");
|
|
|
f06792 |
+ aos_fetch[i] = lp_build_fetch_rgba_aos(gallivm, format_desc,
|
|
|
f06792 |
+ lp_float32_vec4_type(),
|
|
|
f06792 |
+ FALSE, map_ptr, offset1,
|
|
|
f06792 |
+ zero, zero, NULL);
|
|
|
f06792 |
}
|
|
|
f06792 |
+ convert_to_soa(gallivm, aos_fetch, inputs, vs_type);
|
|
|
f06792 |
|
|
|
f06792 |
- /* out-of-bound fetches return all zeros */
|
|
|
f06792 |
for (i = 0; i < TGSI_NUM_CHANNELS; i++) {
|
|
|
f06792 |
inputs[i] = LLVMBuildBitCast(builder, inputs[i], blduivec.vec_type, "");
|
|
|
f06792 |
inputs[i] = LLVMBuildAnd(builder, inputs[i], valid_mask, "");
|
|
|
f06792 |
inputs[i] = LLVMBuildBitCast(builder, inputs[i],
|
|
|
f06792 |
lp_build_vec_type(gallivm, vs_type), "");
|
|
|
f06792 |
+
|
|
|
f06792 |
}
|
|
|
f06792 |
}
|
|
|
f06792 |
|
|
|
f06792 |
--
|
|
|
f06792 |
2.9.3
|
|
|
f06792 |
|