From 671263b5c7639faf2f52700ae539952e2bbd63bd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 10 Dec 2020 11:34:48 -0800 Subject: [PATCH] gallium/tgsi_exec: Fix assertion failure about missing constbufs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GL by default gives you UB when you access a missing constbuf, and we were crashing on debug builds in that case. More importantly, we were assertion failing even under valid circumstances, when a !ExecMask channel had a bad value for the indirect buffer index and we tried to load from it anyway. In removing the assertion, also sink the buf declaration to after we've done the bounds check that determines that there's a constbuf actually bound to this index. Reviewed-by: Marek Olšák Part-of: --- .gitlab-ci/deqp-softpipe-fails.txt | 1 - src/gallium/auxiliary/tgsi/tgsi_exec.c | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci/deqp-softpipe-fails.txt b/.gitlab-ci/deqp-softpipe-fails.txt index d084b31577e..a5650f19459 100644 --- a/.gitlab-ci/deqp-softpipe-fails.txt +++ b/.gitlab-ci/deqp-softpipe-fails.txt @@ -492,7 +492,6 @@ dEQP-GLES31.functional.image_load_store.early_fragment_tests.early_fragment_test dEQP-GLES31.functional.image_load_store.early_fragment_tests.early_fragment_tests_stencil_fbo,Fail dEQP-GLES31.functional.image_load_store.early_fragment_tests.no_early_fragment_tests_depth,Fail dEQP-GLES31.functional.image_load_store.early_fragment_tests.no_early_fragment_tests_depth_fbo,Fail -dEQP-GLES31.functional.shaders.opaque_type_indexing.ubo.dynamically_uniform_geometry,Crash dEQP-GLES31.functional.state_query.integer.max_framebuffer_samples_getfloat,Fail dEQP-GLES31.functional.state_query.integer.max_framebuffer_samples_getinteger,Fail dEQP-GLES31.functional.state_query.integer.max_framebuffer_samples_getinteger64,Fail diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index c1f6ad1dd2d..b5fa1d8f263 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -1453,14 +1453,12 @@ fetch_src_file_channel(const struct tgsi_exec_machine *mach, case TGSI_FILE_CONSTANT: for (i = 0; i < TGSI_QUAD_SIZE; i++) { assert(index2D->i[i] >= 0 && index2D->i[i] < PIPE_MAX_CONSTANT_BUFFERS); - assert(mach->Consts[index2D->i[i]]); if (index->i[i] < 0) { chan->u[i] = 0; } else { /* NOTE: copying the const value as a uint instead of float */ const uint constbuf = index2D->i[i]; - const uint *buf = (const uint *)mach->Consts[constbuf]; const int pos = index->i[i] * 4 + swizzle; /* const buffer bounds check */ if (pos < 0 || pos >= (int) mach->ConstsSize[constbuf]) { @@ -1472,9 +1470,10 @@ fetch_src_file_channel(const struct tgsi_exec_machine *mach, " out of bounds\n", pos); } chan->u[i] = 0; - } - else + } else { + const uint *buf = (const uint *)mach->Consts[constbuf]; chan->u[i] = buf[pos]; + } } } break;