summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shader_query.cpp
diff options
context:
space:
mode:
authorAlejandro Piñeiro <[email protected]>2017-11-18 10:04:42 +0100
committerAlejandro Piñeiro <[email protected]>2019-07-12 23:42:41 +0200
commit3ebd60b4917bb45d5b5339a10ba3aa4561925c66 (patch)
tree3c7be8bbe7238210e706edbb29c45d0290f0c358 /src/mesa/main/shader_query.cpp
parentcafc1a40d465a42805bb2ae45b18997e87bbac75 (diff)
mesa: Fix ACTIVE_*_MAX_LENGTH program queries (ARB_gl_spirv)
Since ARB_gl_spirv it is possible to miss a lot of name reflection information, so it is needed to add NULL name checks for several queries, and return a specific value on those cases. This commit add them for ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, ACTIVE_ATTRIBUTE_MAX_LENGTH and ACTIVE_UNIFORM_MAX_LENGTH. From ARB_gl_spirv spec: "If pname is ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, the length of the longest active uniform block name, including the null terminator, is returned. If no active uniform blocks exist, zero is returned. If no name reflection information is available, one is returned. If pname is ACTIVE_ATTRIBUTE_MAX_LENGTH, the length of the longest active attribute name, including a null terminator, is returned. If no active attributes exist, zero is returned. If no name reflection information is available, one is returned. If pname is ACTIVE_UNIFORM_MAX_LENGTH, the length of the longest active uniform name, including a null terminator, is returned. If no active uniforms exist, zero is returned. If no name reflection information is available, one is returned." Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/mesa/main/shader_query.cpp')
-rw-r--r--src/mesa/main/shader_query.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index d3549535ea0..3fcd4fcedc5 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -244,9 +244,18 @@ _mesa_longest_attribute_name_length(struct gl_shader_program *shProg)
if (res->Type == GL_PROGRAM_INPUT &&
res->StageReferences & (1 << MESA_SHADER_VERTEX)) {
- const size_t length = strlen(RESOURCE_VAR(res)->name);
- if (length >= longest)
- longest = length + 1;
+ /* From the ARB_gl_spirv spec:
+ *
+ * "If pname is ACTIVE_ATTRIBUTE_MAX_LENGTH, the length of the
+ * longest active attribute name, including a null terminator, is
+ * returned. If no active attributes exist, zero is returned. If
+ * no name reflection information is available, one is returned."
+ */
+ const size_t length = RESOURCE_VAR(res)->name != NULL ?
+ strlen(RESOURCE_VAR(res)->name) : 0;
+
+ if (length >= longest)
+ longest = length + 1;
}
}