summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shader_query.cpp
diff options
context:
space:
mode:
authorAntia Puentes <[email protected]>2018-08-13 18:48:37 +0200
committerAlejandro PiƱeiro <[email protected]>2019-07-12 23:42:41 +0200
commit96d6156678929d3d480fca3b4458767df31f4ee7 (patch)
treeef132aa2e969e59345eb459d2b74abb3995ee79c /src/mesa/main/shader_query.cpp
parent3ebd60b4917bb45d5b5339a10ba3aa4561925c66 (diff)
mesa/shader_query: Fix NAME_LENGTH queries (ARB_gl_spirv)
For shaders constructed from SPIR-V binaries, it is possible that no name reflection information is available. In that case, - glGetProgramInterfaceiv(.., pname=MAX_NAME_LENGTH, ..) - gletProgramResourceiv(.., props=NAME_LENGTH, ..) should return 1. Signed-off-by: Antia Puentes <[email protected]> Signed-off-by: Andres Gomez <[email protected]> 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.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 3fcd4fcedc5..a3365107648 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -778,7 +778,15 @@ add_index_to_name(struct gl_program_resource *res)
extern unsigned
_mesa_program_resource_name_len(struct gl_program_resource *res)
{
- unsigned length = strlen(_mesa_program_resource_name(res));
+ const char* name = _mesa_program_resource_name(res);
+
+ /* For shaders constructed from SPIR-V binaries, variables may not
+ * have names associated with them.
+ */
+ if (!name)
+ return 0;
+
+ unsigned length = strlen(name);
if (_mesa_program_resource_array_size(res) && add_index_to_name(res))
length += 3;
return length;
@@ -819,7 +827,11 @@ _mesa_get_program_resource_name(struct gl_shader_program *shProg,
_mesa_copy_string(name, bufSize, length, _mesa_program_resource_name(res));
- if (_mesa_program_resource_array_size(res) && add_index_to_name(res)) {
+ /* The resource name can be NULL for shaders constructed from SPIR-V
+ * binaries. In that case, we do not add the '[0]'.
+ */
+ if (name && name[0] != '\0' &&
+ _mesa_program_resource_array_size(res) && add_index_to_name(res)) {
int i;
/* The comparison is strange because *length does *NOT* include the