summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2018-12-21 00:57:04 +0100
committerRoland Scheidegger <[email protected]>2018-12-21 17:35:05 +0100
commitf3b1acff48492cf1b0dc0f5dab71ecc3f5806265 (patch)
treec37b5b1b483b3c7151cf28ffda5e72cd21aa8dff /src/gallium/drivers
parenta8d020c3dcb9afa720e60f1785bff1505cfbc115 (diff)
gallivm: don't use pavg.b intrinsic on llvm >= 6.0
This intrinsic disppeared with llvm 6.0, using it ends up in segfaults (due to llvm issuing call to NULL address in the jited shaders). Add code doing the same thing as the autoupgrade code in llvm so it can be matched and replaced back with a pavgb. While here, also improve lp_test_format, so it tests both with and without cache (as it was, it tested the cache versions only, whereas cache is actually disabled in llvmpipe, and in any case even with it enabled vertex and geometry shaders wouldn't use it). (Although at least for the unorm8 uncached fetch, the code is still quite different to what llvmpipe is using, since that would use unorm8x16 type, whereas the test code is using unorm8x4 type, hence disabling some intrinsic paths.) Fixes: 6f4083143bb8 ("gallivm: use llvm jit code for decoding s3tc") Reviewed-by: Jose Fonseca <[email protected]> Tested-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_test_format.c91
1 files changed, 49 insertions, 42 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c
index a8aa33d8ae9..885d886cfa9 100644
--- a/src/gallium/drivers/llvmpipe/lp_test_format.c
+++ b/src/gallium/drivers/llvmpipe/lp_test_format.c
@@ -44,8 +44,6 @@
#include "lp_test.h"
-#define USE_TEXTURE_CACHE 1
-
static struct lp_build_format_cache *cache_ptr;
void
@@ -80,7 +78,8 @@ typedef void
static LLVMValueRef
add_fetch_rgba_test(struct gallivm_state *gallivm, unsigned verbose,
const struct util_format_description *desc,
- struct lp_type type)
+ struct lp_type type,
+ unsigned use_cache)
{
char name[256];
LLVMContextRef context = gallivm->context;
@@ -114,7 +113,7 @@ add_fetch_rgba_test(struct gallivm_state *gallivm, unsigned verbose,
i = LLVMGetParam(func, 2);
j = LLVMGetParam(func, 3);
- if (cache_ptr) {
+ if (use_cache) {
cache = LLVMGetParam(func, 4);
}
@@ -137,7 +136,8 @@ add_fetch_rgba_test(struct gallivm_state *gallivm, unsigned verbose,
PIPE_ALIGN_STACK
static boolean
test_format_float(unsigned verbose, FILE *fp,
- const struct util_format_description *desc)
+ const struct util_format_description *desc,
+ unsigned use_cache)
{
LLVMContextRef context;
struct gallivm_state *gallivm;
@@ -152,7 +152,8 @@ test_format_float(unsigned verbose, FILE *fp,
context = LLVMContextCreate();
gallivm = gallivm_create("test_module_float", context);
- fetch = add_fetch_rgba_test(gallivm, verbose, desc, lp_float32_vec4_type());
+ fetch = add_fetch_rgba_test(gallivm, verbose, desc,
+ lp_float32_vec4_type(), use_cache);
gallivm_compile_module(gallivm);
@@ -181,7 +182,7 @@ test_format_float(unsigned verbose, FILE *fp,
memset(unpacked, 0, sizeof unpacked);
- fetch_ptr(unpacked, packed, j, i, cache_ptr);
+ fetch_ptr(unpacked, packed, j, i, use_cache ? cache_ptr : NULL);
for(k = 0; k < 4; ++k) {
if (util_double_inf_sign(test->unpacked[i][j][k]) != util_inf_sign(unpacked[k])) {
@@ -236,7 +237,8 @@ test_format_float(unsigned verbose, FILE *fp,
PIPE_ALIGN_STACK
static boolean
test_format_unorm8(unsigned verbose, FILE *fp,
- const struct util_format_description *desc)
+ const struct util_format_description *desc,
+ unsigned use_cache)
{
LLVMContextRef context;
struct gallivm_state *gallivm;
@@ -251,7 +253,8 @@ test_format_unorm8(unsigned verbose, FILE *fp,
context = LLVMContextCreate();
gallivm = gallivm_create("test_module_unorm8", context);
- fetch = add_fetch_rgba_test(gallivm, verbose, desc, lp_unorm8_vec4_type());
+ fetch = add_fetch_rgba_test(gallivm, verbose, desc,
+ lp_unorm8_vec4_type(), use_cache);
gallivm_compile_module(gallivm);
@@ -280,7 +283,7 @@ test_format_unorm8(unsigned verbose, FILE *fp,
memset(unpacked, 0, sizeof unpacked);
- fetch_ptr(unpacked, packed, j, i, cache_ptr);
+ fetch_ptr(unpacked, packed, j, i, use_cache ? cache_ptr : NULL);
match = TRUE;
for(k = 0; k < 4; ++k) {
@@ -335,15 +338,16 @@ test_format_unorm8(unsigned verbose, FILE *fp,
static boolean
test_one(unsigned verbose, FILE *fp,
- const struct util_format_description *format_desc)
+ const struct util_format_description *format_desc,
+ unsigned use_cache)
{
boolean success = TRUE;
- if (!test_format_float(verbose, fp, format_desc)) {
+ if (!test_format_float(verbose, fp, format_desc, use_cache)) {
success = FALSE;
}
- if (!test_format_unorm8(verbose, fp, format_desc)) {
+ if (!test_format_unorm8(verbose, fp, format_desc, use_cache)) {
success = FALSE;
}
@@ -356,49 +360,52 @@ test_all(unsigned verbose, FILE *fp)
{
enum pipe_format format;
boolean success = TRUE;
+ unsigned use_cache;
-#if USE_TEXTURE_CACHE
cache_ptr = align_malloc(sizeof(struct lp_build_format_cache), 16);
-#endif
- for (format = 1; format < PIPE_FORMAT_COUNT; ++format) {
- const struct util_format_description *format_desc;
+ for (use_cache = 0; use_cache < 2; use_cache++) {
+ for (format = 1; format < PIPE_FORMAT_COUNT; ++format) {
+ const struct util_format_description *format_desc;
- format_desc = util_format_description(format);
- if (!format_desc) {
- continue;
- }
+ format_desc = util_format_description(format);
+ if (!format_desc) {
+ continue;
+ }
+ /*
+ * TODO: test more
+ */
- /*
- * TODO: test more
- */
+ if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
+ continue;
+ }
- if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
- continue;
- }
+ if (util_format_is_pure_integer(format))
+ continue;
- if (util_format_is_pure_integer(format))
- continue;
+ /* only have util fetch func for etc1 */
+ if (format_desc->layout == UTIL_FORMAT_LAYOUT_ETC &&
+ format != PIPE_FORMAT_ETC1_RGB8) {
+ continue;
+ }
- /* only have util fetch func for etc1 */
- if (format_desc->layout == UTIL_FORMAT_LAYOUT_ETC &&
- format != PIPE_FORMAT_ETC1_RGB8) {
- continue;
- }
+ /* missing fetch funcs */
+ if (format_desc->layout == UTIL_FORMAT_LAYOUT_ASTC) {
+ continue;
+ }
- /* missing fetch funcs */
- if (format_desc->layout == UTIL_FORMAT_LAYOUT_ASTC) {
- continue;
- }
+ /* only test twice with formats which can use cache */
+ if (format_desc->layout != UTIL_FORMAT_LAYOUT_S3TC && use_cache) {
+ continue;
+ }
- if (!test_one(verbose, fp, format_desc)) {
- success = FALSE;
+ if (!test_one(verbose, fp, format_desc, use_cache)) {
+ success = FALSE;
+ }
}
}
-#if USE_TEXTURE_CACHE
align_free(cache_ptr);
-#endif
return success;
}