1 |
From 33d331859a2c35134c18ad2ab37d2e529d76816e Mon Sep 17 00:00:00 2001 |
2 |
From: Andres Gomez <agomez@igalia.com> |
3 |
Date: Fri, 18 Jan 2019 18:33:10 +0200 |
4 |
Subject: [PATCH 21/22] glsl/linker: simplify xfb_offset vs xfb_stride overflow |
5 |
check |
6 |
|
7 |
Current implementation uses a complicated calculation which relies in |
8 |
an implicit conversion to check the integral part of 2 division |
9 |
results. |
10 |
|
11 |
However, the calculation actually checks that the xfb_offset is |
12 |
smaller or a multiplier of the xfb_stride. For example, while this is |
13 |
expected to fail, it actually succeeds: |
14 |
|
15 |
" |
16 |
|
17 |
... |
18 |
|
19 |
layout(xfb_buffer = 2, xfb_stride = 12) out block3 { |
20 |
layout(xfb_offset = 0) vec3 c; |
21 |
layout(xfb_offset = 12) vec3 d; // ERROR, requires stride of 24 |
22 |
}; |
23 |
|
24 |
... |
25 |
|
26 |
" |
27 |
|
28 |
Fixes: 2fab85aaea5 ("glsl: add xfb_stride link time validation") |
29 |
Cc: Timothy Arceri <tarceri@itsqueeze.com> |
30 |
Signed-off-by: Andres Gomez <agomez@igalia.com> |
31 |
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> |
32 |
(cherry picked from commit 422882e78f2cf0ab69ff4a58f3c9465fcb5fef0d) |
33 |
--- |
34 |
src/compiler/glsl/link_varyings.cpp | 3 +-- |
35 |
1 file changed, 1 insertion(+), 2 deletions(-) |
36 |
|
37 |
diff --git a/src/compiler/glsl/link_varyings.cpp b/src/compiler/glsl/link_varyings.cpp |
38 |
index 8aa5ba098c8..56fff60e07a 100644 |
39 |
--- a/src/compiler/glsl/link_varyings.cpp |
40 |
+++ b/src/compiler/glsl/link_varyings.cpp |
41 |
@@ -1178,8 +1178,7 @@ tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog, |
42 |
return false; |
43 |
} |
44 |
|
45 |
- if ((this->offset / 4) / info->Buffers[buffer].Stride != |
46 |
- (xfb_offset - 1) / info->Buffers[buffer].Stride) { |
47 |
+ if (xfb_offset > info->Buffers[buffer].Stride) { |
48 |
linker_error(prog, "xfb_offset (%d) overflows xfb_stride (%d) for " |
49 |
"buffer (%d)", xfb_offset * 4, |
50 |
info->Buffers[buffer].Stride * 4, buffer); |
51 |
-- |
52 |
2.21.0 |
53 |
|