ES31: Add glGetProgramResourceLocation API
Add API entry and validation checks(GLES 3.1 section 7.3).
Add the first 2 interfaces(PROGRAM_INPUT and PROGRAM_OUTPUT) implementation.
BUG=angleproject:1920
TEST=angle_end2end_tests:ProgramInterfaceTestES31.*
Change-Id: I5128cda43b0d9176c910b036cdc76bf37757670e
Reviewed-on: https://chromium-review.googlesource.com/474212
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES31.cpp b/src/libANGLE/validationES31.cpp
index 0711029..4856d85 100644
--- a/src/libANGLE/validationES31.cpp
+++ b/src/libANGLE/validationES31.cpp
@@ -41,6 +41,19 @@
}
}
+bool ValidateLocationProgramInterface(GLenum programInterface)
+{
+ switch (programInterface)
+ {
+ case GL_UNIFORM:
+ case GL_PROGRAM_INPUT:
+ case GL_PROGRAM_OUTPUT:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool ValidateProgramResourceIndex(const Program *programObject,
GLenum programInterface,
GLuint index)
@@ -895,4 +908,36 @@
return true;
}
+
+bool ValidateGetProgramResourceLocation(Context *context,
+ GLuint program,
+ GLenum programInterface,
+ const GLchar *name)
+{
+ if (context->getClientVersion() < ES_3_1)
+ {
+ context->handleError(InvalidOperation() << "Context does not support GLES3.1.");
+ return false;
+ }
+
+ Program *programObject = GetValidProgram(context, program);
+ if (programObject == nullptr)
+ {
+ return false;
+ }
+
+ if (!programObject->isLinked())
+ {
+ context->handleError(InvalidOperation() << "Program is not successfully linked.");
+ return false;
+ }
+
+ if (!ValidateLocationProgramInterface(programInterface))
+ {
+ context->handleError(InvalidEnum() << "Invalid program interface.");
+ return false;
+ }
+ return true;
+}
+
} // namespace gl