Commit cf8ad760 by Jiawei Shao Committed by Commit Bot

ES31: Support translating textureGatherOffset into HLSL

This patch implements the translation from GLSL texture function textureGatherOffset into HLSL by using the optional "offset" parameter of Texture2D.Gather[Red|Green|Blue|Alpha]. This patch also defines the implementation-dependent limit MIN_PROGRAM_TEXTURE_GATHER_OFFSET and MAX_PROGRAM_TEXTURE_GATHER_OFFSET on D3D11. According to MSDN, the valid range of "offset" used in Gather should be [-32, 31]. https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/gather4-po--sm5---asm- This patch also refactors OutputTextureGatherFunctionBody() so that some redundant code can be removed. BUG=angleproject:2826 TEST=dEQP-GLES31.functional.texture.gather.offset.min_required_offset.2d.rgba8.* dEQP-GLES31.functional.texture.gather.offset.min_required_offset.2d_array.rgba8.* dEQP-GLES31.functional.texture.gather.offset.implementation_offset.2d.rgba8.* dEQP-GLES31.functional.texture.gather.offset.implementation_offset.2d_array.rgba8.* (without texture_swizzle) Change-Id: Id0f411257b64c8a97428f16b1a86950ec6d36e2f Reviewed-on: https://chromium-review.googlesource.com/1237303Reviewed-by: 's avatarJiajia Qin <jiajia.qin@intel.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
parent 219ef05b
...@@ -850,25 +850,24 @@ void OutputTextureGatherFunctionBody(TInfoSinkBase &out, ...@@ -850,25 +850,24 @@ void OutputTextureGatherFunctionBody(TInfoSinkBase &out,
ImmutableString samplerCoordString(samplerCoordBuilder); ImmutableString samplerCoordString(samplerCoordBuilder);
constexpr std::array<const char *, 4> kHLSLGatherFunctions = {
{"GatherRed", "GatherGreen", "GatherBlue", "GatherAlpha"}};
out << " switch(comp)\n" out << " switch(comp)\n"
" {\n" " {\n";
" case 0:\n" for (size_t component = 0; component < kHLSLGatherFunctions.size(); ++component)
" return " {
<< textureReference << ".GatherRed(" << samplerReference << ", " << samplerCoordString out << " case " << component << ":\n"
<< ");\n" << " return " << textureReference << "." << kHLSLGatherFunctions[component]
" case 1:\n" << "(" << samplerReference << ", " << samplerCoordString;
" return " if (textureFunction.offset)
<< textureReference << ".GatherGreen(" << samplerReference << ", " << samplerCoordString {
<< ");\n" out << ", offset";
" case 2:\n" }
" return " out << ");\n";
<< textureReference << ".GatherBlue(" << samplerReference << ", " << samplerCoordString }
<< ");\n"
" case 3:\n" out << " default:\n"
" return "
<< textureReference << ".GatherAlpha(" << samplerReference << ", " << samplerCoordString
<< ");\n"
" default:\n"
" return float4(0.0, 0.0, 0.0, 1.0);\n" " return float4(0.0, 0.0, 0.0, 1.0);\n"
" }\n"; " }\n";
} }
...@@ -1320,6 +1319,11 @@ ImmutableString TextureFunctionHLSL::useTextureFunction(const ImmutableString &n ...@@ -1320,6 +1319,11 @@ ImmutableString TextureFunctionHLSL::useTextureFunction(const ImmutableString &n
{ {
textureFunction.method = TextureFunction::GATHER; textureFunction.method = TextureFunction::GATHER;
} }
else if (name == "textureGatherOffset")
{
textureFunction.method = TextureFunction::GATHER;
textureFunction.offset = true;
}
else else
UNREACHABLE(); UNREACHABLE();
......
...@@ -1049,6 +1049,50 @@ int GetMaximumTexelOffset(D3D_FEATURE_LEVEL featureLevel) ...@@ -1049,6 +1049,50 @@ int GetMaximumTexelOffset(D3D_FEATURE_LEVEL featureLevel)
} }
} }
int GetMinimumTextureGatherOffset(D3D_FEATURE_LEVEL featureLevel)
{
switch (featureLevel)
{
// https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/gather4-po--sm5---asm-
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return -32;
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_10_0:
case D3D_FEATURE_LEVEL_9_3:
case D3D_FEATURE_LEVEL_9_2:
case D3D_FEATURE_LEVEL_9_1:
return 0;
default:
UNREACHABLE();
return 0;
}
}
int GetMaximumTextureGatherOffset(D3D_FEATURE_LEVEL featureLevel)
{
switch (featureLevel)
{
// https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/gather4-po--sm5---asm-
case D3D_FEATURE_LEVEL_11_1:
case D3D_FEATURE_LEVEL_11_0:
return 31;
case D3D_FEATURE_LEVEL_10_1:
case D3D_FEATURE_LEVEL_10_0:
case D3D_FEATURE_LEVEL_9_3:
case D3D_FEATURE_LEVEL_9_2:
case D3D_FEATURE_LEVEL_9_1:
return 0;
default:
UNREACHABLE();
return 0;
}
}
size_t GetMaximumConstantBufferSize(D3D_FEATURE_LEVEL featureLevel) size_t GetMaximumConstantBufferSize(D3D_FEATURE_LEVEL featureLevel)
{ {
// Returns a size_t despite the limit being a GLuint64 because size_t is the maximum // Returns a size_t despite the limit being a GLuint64 because size_t is the maximum
...@@ -1506,6 +1550,10 @@ void GenerateCaps(ID3D11Device *device, ...@@ -1506,6 +1550,10 @@ void GenerateCaps(ID3D11Device *device,
static_cast<GLuint>(GetMaximumRenderToBufferWindowSize(featureLevel)); static_cast<GLuint>(GetMaximumRenderToBufferWindowSize(featureLevel));
caps->maxFramebufferHeight = caps->maxFramebufferWidth; caps->maxFramebufferHeight = caps->maxFramebufferWidth;
// Texture gather offset limits
caps->minProgramTextureGatherOffset = GetMinimumTextureGatherOffset(featureLevel);
caps->maxProgramTextureGatherOffset = GetMaximumTextureGatherOffset(featureLevel);
// GL extension support // GL extension support
extensions->setTextureExtensionSupport(*textureCapsMap); extensions->setTextureExtensionSupport(*textureCapsMap);
extensions->elementIndexUint = true; extensions->elementIndexUint = true;
......
...@@ -1578,7 +1578,19 @@ ...@@ -1578,7 +1578,19 @@
2826 D3D11 : dEQP-GLES31.functional.texture.gather.basic.cube.rgba8.texture_swizzle.* = FAIL 2826 D3D11 : dEQP-GLES31.functional.texture.gather.basic.cube.rgba8.texture_swizzle.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.basic.cube.rgba8i.* = FAIL 2826 D3D11 : dEQP-GLES31.functional.texture.gather.basic.cube.rgba8i.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.basic.cube.rgba8ui.* = FAIL 2826 D3D11 : dEQP-GLES31.functional.texture.gather.basic.cube.rgba8ui.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.* = FAIL 2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.min_required_offset.2d.rgba8ui.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.min_required_offset.2d.rgba8i.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.min_required_offset.2d.depth32f.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.min_required_offset.2d_array.rgba8ui.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.min_required_offset.2d_array.rgba8i.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.min_required_offset.2d_array.depth32f.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.implementation_offset.2d.rgba8ui.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.implementation_offset.2d.rgba8i.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.implementation_offset.2d.depth32f.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.implementation_offset.2d_array.rgba8.texture_swizzle.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.implementation_offset.2d_array.rgba8ui.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.implementation_offset.2d_array.rgba8i.* = FAIL
2826 D3D11 : dEQP-GLES31.functional.texture.gather.offset.implementation_offset.2d_array.depth32f.* = FAIL
// Recetly added tests failing on D3D11 Windows. // Recetly added tests failing on D3D11 Windows.
2619 D3D11 : dEQP-GLES31.functional.shaders.builtin_functions.uniform.findLSBMinusOne.highp_compute = FAIL 2619 D3D11 : dEQP-GLES31.functional.shaders.builtin_functions.uniform.findLSBMinusOne.highp_compute = FAIL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment