Optimize Texture binding by only applying referenced textures.
Update ProgramGL to track which the current values of sampler uniforms so
that only the currently applied texture units have to be bound for the
draw call.
BUG=angleproject:882
Change-Id: I280aa106172b13a5fbb31cdefba27b6691c0a0e4
Reviewed-on: https://chromium-review.googlesource.com/264803
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/common/utilities.cpp b/src/common/utilities.cpp
index 9379c29..2cda267 100644
--- a/src/common/utilities.cpp
+++ b/src/common/utilities.cpp
@@ -279,6 +279,39 @@
return false;
}
+GLenum SamplerTypeToTextureType(GLenum samplerType)
+{
+ switch (samplerType)
+ {
+ case GL_SAMPLER_2D:
+ case GL_INT_SAMPLER_2D:
+ case GL_UNSIGNED_INT_SAMPLER_2D:
+ case GL_SAMPLER_2D_SHADOW:
+ return GL_TEXTURE_2D;
+
+ case GL_SAMPLER_CUBE:
+ case GL_INT_SAMPLER_CUBE:
+ case GL_UNSIGNED_INT_SAMPLER_CUBE:
+ case GL_SAMPLER_CUBE_SHADOW:
+ return GL_TEXTURE_CUBE_MAP;
+
+ case GL_SAMPLER_2D_ARRAY:
+ case GL_INT_SAMPLER_2D_ARRAY:
+ case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
+ case GL_SAMPLER_2D_ARRAY_SHADOW:
+ return GL_TEXTURE_2D_ARRAY;
+
+ case GL_SAMPLER_3D:
+ case GL_INT_SAMPLER_3D:
+ case GL_UNSIGNED_INT_SAMPLER_3D:
+ return GL_TEXTURE_3D;
+
+ default:
+ UNREACHABLE();
+ return 0;
+ }
+}
+
bool IsMatrixType(GLenum type)
{
return VariableRowCount(type) > 1;