[19/63] shader_runner: Add commands to query index, loc, loc-index.

Submitted by apinheiro on Feb. 23, 2019, 11:45 p.m.

Details

Message ID 20190223234551.21111-20-apinheiro@igalia.com
State New
Headers show
Series "ARB_gl_spirv full series" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

apinheiro Feb. 23, 2019, 11:45 p.m.
From: Antia Puentes <apuentes@igalia.com>

Tests glGetProgramResourceIndex(), glGetProgramLocation() and
glGetProgramLocationIndex().
---
 tests/shaders/shader_runner.c | 97 +++++++++++++++++++++++++++++++++--
 1 file changed, 92 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 893a99422..58da5e7b1 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -3244,6 +3244,35 @@  query_resource_name(unsigned interface_type, GLuint index,
 			       expected_name, got_name);
 }
 
+static void
+query_resource_index(unsigned interface_type, const char *name, GLuint expected,
+		     const char *query_str)
+{
+	GLuint got = glGetProgramResourceIndex(prog, interface_type, name);
+
+	query_check_error_int(query_str, expected, got);
+}
+
+static void
+query_resource_location(unsigned interface_type, const char *name,
+			GLint expected, const char *query_str)
+{
+
+	GLint got = glGetProgramResourceLocation(prog, interface_type, name);
+
+	query_check_error_int(query_str, expected, got);
+}
+
+static void
+query_resource_location_index(unsigned interface_type, const char *name,
+			      GLint expected, const char *query_str)
+{
+	GLint got = glGetProgramResourceLocationIndex(prog, interface_type,
+						      name);
+
+	query_check_error_int(query_str, expected, got);
+}
+
 static void
 parse_resource_info(const char **line, unsigned interface_type,
 		    struct resource_info *resource)
@@ -3624,6 +3653,69 @@  verify_program_interface_query(const char *line,
 					       expected, query_str, block_data);
 		}
 
+	}
+		break;
+	case QUERY_RESOURCE_INDEX: {
+		static const struct string_to_enum invalid_index[] = {
+			ENUM_STRING(GL_INVALID_INDEX),
+			{ NULL, 0 }
+		};
+
+		char name[512];
+		GLuint expected;
+
+		if (parse_str(line, "\"\"", &line))
+			name[0] = '\0';
+		else
+			REQUIRE(parse_word_copy(line, name, sizeof(name),
+						&line),
+				"Bad name at: %s\n", line);
+
+		REQUIRE(parse_enum_tab(invalid_index, line,
+				       (unsigned *) &expected, &line) ||
+			parse_uint(line, &expected, &line),
+			"Bad expected index at: %s\n", line);
+
+		snprintf(query_str, sizeof(query_str),
+			 "glGetProgramResourceIndex (%s, %s)",
+			 piglit_get_gl_enum_name(interface_type),
+			 name);
+
+		query_resource_index(interface_type, name, expected, query_str);
+	}
+		break;
+	case QUERY_RESOURCE_LOCATION:
+	case QUERY_RESOURCE_LOCATION_INDEX: {
+		char name[512];
+		GLint expected;
+
+		if (parse_str(line, "\"\"", &line))
+			name[0] = '\0';
+		else
+			REQUIRE(parse_word_copy(line, name, sizeof(name),
+						&line),
+				"Bad name at: %s\n", line);
+
+		REQUIRE(parse_int(line, &expected, &line),
+			"Bad expected value at: %s\n", line);
+
+		if (query == QUERY_RESOURCE_LOCATION) {
+			snprintf(query_str, sizeof(query_str),
+				 "glGetProgramResourceLocation(%s, %s)",
+				 piglit_get_gl_enum_name(interface_type),
+				 name);
+
+			query_resource_location(interface_type, name, expected,
+						query_str);
+		} else {
+			snprintf(query_str, sizeof(query_str),
+				 "glGetProgramResourceLocationIndex(%s, %s)",
+				 piglit_get_gl_enum_name(interface_type),
+				 name);
+
+			query_resource_location_index(interface_type, name,
+						      expected, query_str);
+		}
 	}
 		break;
 	case QUERY_RESOURCE_NAME: {
@@ -3664,11 +3756,6 @@  verify_program_interface_query(const char *line,
 				    expected_length, expected_name, query_str);
 	}
 		break;
-	case QUERY_RESOURCE_INDEX:
-	case QUERY_RESOURCE_LOCATION:
-	case QUERY_RESOURCE_LOCATION_INDEX:
-		assert(!"Not implemented.");
-		break;
 	default:
 		assert(!"Should not get here.");
 	}