summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Gomez <agomez@igalia.com>2019-01-18 18:33:10 +0200
committerEmil Velikov <emil.l.velikov@gmail.com>2019-03-25 16:17:50 +0000
commit208fd66d80b16a9c70d7228256cdd3d3f4cbe2f7 (patch)
treebb4edd020e8ac1e2cdc341d9e6e5994ad19b937b
parent479b11040f1ab02d637f6931f5cfcbca709e26e6 (diff)
downloadmesa-208fd66d80b16a9c70d7228256cdd3d3f4cbe2f7.tar.gz
glsl/linker: simplify xfb_offset vs xfb_stride overflow check
Current implementation uses a complicated calculation which relies in an implicit conversion to check the integral part of 2 division results. However, the calculation actually checks that the xfb_offset is smaller or a multiplier of the xfb_stride. For example, while this is expected to fail, it actually succeeds: " ... layout(xfb_buffer = 2, xfb_stride = 12) out block3 { layout(xfb_offset = 0) vec3 c; layout(xfb_offset = 12) vec3 d; // ERROR, requires stride of 24 }; ... " Fixes: 2fab85aaea5 ("glsl: add xfb_stride link time validation") Cc: Timothy Arceri <tarceri@itsqueeze.com> Signed-off-by: Andres Gomez <agomez@igalia.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> (cherry picked from commit 422882e78f2cf0ab69ff4a58f3c9465fcb5fef0d)
-rw-r--r--src/compiler/glsl/link_varyings.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp
index 8aa5ba098c8..56fff60e07a 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -1178,8 +1178,7 @@ tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
return false;
}
- if ((this->offset / 4) / info->Buffers[buffer].Stride !=
- (xfb_offset - 1) / info->Buffers[buffer].Stride) {
+ if (xfb_offset > info->Buffers[buffer].Stride) {
linker_error(prog, "xfb_offset (%d) overflows xfb_stride (%d) for "
"buffer (%d)", xfb_offset * 4,
info->Buffers[buffer].Stride * 4, buffer);