Use texture base level to implement textureSize on D3D11 HLSL

HLSL GetDimensions call doesn't take the texture base level into account,
so ANGLE needs to use the texture base level passed in uniforms to
emulate ESSL textureSize() which does take it into account.

After this change the relevant dEQP tests pass on NVIDIA, Intel is still
suffering from an issue where a wrong value is returned when the lod
is > 0 (tested on Intel HD Graphics 4600). AMD is also suffering from an
unknown issue.

BUG=angleproject:596
TEST=dEQP-GLES3.functional.shaders.texture_functions.texturesize.*
     (all pass on NVIDIA now), angle_end2end_tests

Change-Id: I13e33d126008ecdf2b89461a3fb5040949cf19e2
Reviewed-on: https://chromium-review.googlesource.com/322123
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index 90aa734..3337022 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -858,26 +858,29 @@
 
         if (textureFunction->method == TextureFunction::SIZE)
         {
+            out << "int baseLevel = samplerMetadata[samplerIndex];\n";
             if (IsSampler2D(textureFunction->sampler) || IsSamplerCube(textureFunction->sampler))
             {
-                if (IsSamplerArray(textureFunction->sampler))
+                if (IsSamplerArray(textureFunction->sampler) ||
+                    (IsIntegerSampler(textureFunction->sampler) &&
+                     IsSamplerCube(textureFunction->sampler)))
                 {
                     out << "    uint width; uint height; uint layers; uint numberOfLevels;\n"
-                        << "    " << textureReference
-                        << ".GetDimensions(lod, width, height, layers, numberOfLevels);\n";
+                        << "    " << textureReference << ".GetDimensions(baseLevel + lod, width, "
+                                                         "height, layers, numberOfLevels);\n";
                 }
                 else
                 {
                     out << "    uint width; uint height; uint numberOfLevels;\n"
                         << "    " << textureReference
-                        << ".GetDimensions(lod, width, height, numberOfLevels);\n";
+                        << ".GetDimensions(baseLevel + lod, width, height, numberOfLevels);\n";
                 }
             }
             else if (IsSampler3D(textureFunction->sampler))
             {
                 out << "    uint width; uint height; uint depth; uint numberOfLevels;\n"
                     << "    " << textureReference
-                    << ".GetDimensions(lod, width, height, depth, numberOfLevels);\n";
+                    << ".GetDimensions(baseLevel + lod, width, height, depth, numberOfLevels);\n";
             }
             else UNREACHABLE();