Use D3D11 GetDimensions driver workaround for integer cube maps
Some NVIDIA D3D11 drivers are buggy and interprets the level passed to
GetDimensions as being relative to 0, rather than the SRV's MostDetailedMip.
This affects integer cube maps because the dimensions are used for sample
position calculations, which leads to sampling outside the cube side textures
when the base level is non-zero.
Bug: angleproject:3441
Change-Id: I151f9336b9c6d8ec7012bf5010a2d45fb2951e73
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1595688
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/TextureFunctionHLSL.cpp b/src/compiler/translator/TextureFunctionHLSL.cpp
index f4c6fc5..4fc1fce 100644
--- a/src/compiler/translator/TextureFunctionHLSL.cpp
+++ b/src/compiler/translator/TextureFunctionHLSL.cpp
@@ -611,12 +611,21 @@
}
if (IsSamplerCube(textureFunction.sampler))
{
+ if (getDimensionsIgnoresBaseLevel)
+ {
+ out << " int baseLevel = samplerMetadata[samplerIndex].baseLevel;\n";
+ }
+ else
+ {
+ out << " int baseLevel = 0;\n";
+ }
+
out << " float width; float height; float layers; float levels;\n";
out << " uint mip = 0;\n";
out << " " << textureReference
- << ".GetDimensions(mip, width, height, layers, levels);\n";
+ << ".GetDimensions(baseLevel + mip, width, height, layers, levels);\n";
out << " bool xMajor = abs(t.x) > abs(t.y) && abs(t.x) > abs(t.z);\n";
out << " bool yMajor = abs(t.y) > abs(t.z) && abs(t.y) > abs(t.x);\n";
@@ -687,7 +696,7 @@
}
out << " mip = uint(min(max(round(lod), 0), levels - 1));\n"
<< " " << textureReference
- << ".GetDimensions(mip, width, height, layers, levels);\n";
+ << ".GetDimensions(baseLevel + mip, width, height, layers, levels);\n";
}
// Convert from normalized floating-point to integer