summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/linker.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2016-10-25 03:38:54 -0700
committerEmil Velikov <emil.l.velikov@gmail.com>2016-10-27 11:33:14 +0100
commit02d5e60ee0261a86227a0dbd058a87608dc174bf (patch)
treee949728d07b9de42bea0aa6e99e8aefd07f2d622 /src/compiler/glsl/linker.cpp
parent649a47a8343fbc35e17f17fac6e010a106e34b64 (diff)
downloadexternal_mesa3d-02d5e60ee0261a86227a0dbd058a87608dc174bf.zip
external_mesa3d-02d5e60ee0261a86227a0dbd058a87608dc174bf.tar.gz
external_mesa3d-02d5e60ee0261a86227a0dbd058a87608dc174bf.tar.bz2
glsl: Size TCS->TES unsized arrays to gl_MaxPatchVertices for queries.
SSO validation and other program interface queries want to see that unsized (non-patch) TCS output/TES input arrays are implicitly sized to gl_MaxPatchVertices. By the time we create the program resource lists, we've sized the arrays to their actual size. (We try to create TCS output arrays to match the output patch size right away, and at this point, we should have shrunk TES input arrays.) One option would be to keep them sized to gl_MaxPatchVertices, and defer shrinking them. But that's a big change, and I don't think it's a good idea. Instead, this patch introduces a new ir_variable flag which indicates the variable is implicitly to gl_MaxPatchVertices. Then, the linker munges the types when creating the resource list, ignoring the size in the IR's types. Basically, lie about it for resource queries. It's ugly, but I think it ought to work. We probably could use var->data.implicit_sized_array for this, but I opted for a separate bit to try and avoid convoluting the existing SSBO handling. They're similar in concept, but share none of the same code... Fixes: ES31-CTS.core.tessellation_shader.single.xfb_captures_data_from_correct_stage and the ES32-CTS and ESEXT-CTS variants. v2: Add a comment (requested by Timothy, written by me). Cc: mesa-stable@lists.freedesktop.org Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> (cherry picked from commit 173558445dce26ce641faf260a17696221acf23d)
Diffstat (limited to 'src/compiler/glsl/linker.cpp')
-rw-r--r--src/compiler/glsl/linker.cpp41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index d2a72e8..f5c177e 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -3574,6 +3574,7 @@ static gl_shader_variable *
create_shader_variable(struct gl_shader_program *shProg,
const ir_variable *in,
const char *name, const glsl_type *type,
+ const glsl_type *interface_type,
bool use_implicit_location, int location,
const glsl_type *outermost_struct_type)
{
@@ -3631,7 +3632,7 @@ create_shader_variable(struct gl_shader_program *shProg,
out->type = type;
out->outermost_struct_type = outermost_struct_type;
- out->interface_type = in->get_interface_type();
+ out->interface_type = interface_type;
out->component = in->data.location_frac;
out->index = in->data.index;
out->patch = in->data.patch;
@@ -3643,6 +3644,17 @@ create_shader_variable(struct gl_shader_program *shProg,
return out;
}
+static const glsl_type *
+resize_to_max_patch_vertices(const struct gl_context *ctx,
+ const glsl_type *type)
+{
+ if (!type)
+ return NULL;
+
+ return glsl_type::get_array_instance(type->fields.array,
+ ctx->Const.MaxPatchVertices);
+}
+
static bool
add_shader_variable(const struct gl_context *ctx,
struct gl_shader_program *shProg,
@@ -3689,6 +3701,29 @@ add_shader_variable(const struct gl_context *ctx,
}
default: {
+ const glsl_type *interface_type = var->get_interface_type();
+
+ /* Unsized (non-patch) TCS output/TES input arrays are implicitly
+ * sized to gl_MaxPatchVertices. Internally, we shrink them to a
+ * smaller size.
+ *
+ * This can cause trouble with SSO programs. Since the TCS declares
+ * the number of output vertices, we can always shrink TCS output
+ * arrays. However, the TES might not be linked with a TCS, in
+ * which case it won't know the size of the patch. In other words,
+ * the TCS and TES may disagree on the (smaller) array sizes. This
+ * can result in the resource names differing across stages, causing
+ * SSO validation failures and other cascading issues.
+ *
+ * Expanding the array size to the full gl_MaxPatchVertices fixes
+ * these issues. It's also what program interface queries expect,
+ * as that is the official size of the array.
+ */
+ if (var->data.tess_varying_implicit_sized_array) {
+ type = resize_to_max_patch_vertices(ctx, type);
+ interface_type = resize_to_max_patch_vertices(ctx, interface_type);
+ }
+
/* Issue #16 of the ARB_program_interface_query spec says:
*
* "* If a variable is a member of an interface block without an
@@ -3701,8 +3736,7 @@ add_shader_variable(const struct gl_context *ctx,
*/
const char *prefixed_name = (var->data.from_named_ifc_block &&
!is_gl_identifier(var->name))
- ? ralloc_asprintf(shProg, "%s.%s", var->get_interface_type()->name,
- name)
+ ? ralloc_asprintf(shProg, "%s.%s", interface_type->name, name)
: name;
/* The ARB_program_interface_query spec says:
@@ -3713,6 +3747,7 @@ add_shader_variable(const struct gl_context *ctx,
*/
gl_shader_variable *sha_v =
create_shader_variable(shProg, var, prefixed_name, type,
+ interface_type,
use_implicit_location, location,
outermost_struct_type);
if (!sha_v)