gallium/tgsi_exec: Fix assertion failure about missing constbufs.

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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8196>
This commit is contained in:
Eric Anholt
2020-12-10 11:34:48 -08:00
parent 0034f7b209
commit 671263b5c7
2 changed files with 3 additions and 5 deletions
-1
View File
@@ -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
+3 -4
View File
@@ -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;