Commit 92db39e8 by Olli Etuaho Committed by Commit Bot

Fix multisample texture operations crashing HLSL generation

This includes a partial implementation of multisample texture operations on the HLSL backend. It can't be fully tested yet, since the API side isn't implemented. BUG=angleproject:1442 TEST=dEQP-GLES31.functional.shaders.builtin_functions.texture_size.* (successfully compiles instead of crashing) Change-Id: Ief782db28388a3f8fd8113cc86ce3c4f500f322a Reviewed-on: https://chromium-review.googlesource.com/443264Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 21534776
...@@ -235,6 +235,19 @@ inline bool IsIntegerSampler(TBasicType type) ...@@ -235,6 +235,19 @@ inline bool IsIntegerSampler(TBasicType type)
return false; return false;
} }
inline bool IsSampler2DMS(TBasicType type)
{
switch (type)
{
case EbtSampler2DMS:
case EbtISampler2DMS:
case EbtUSampler2DMS:
return true;
default:
return false;
}
}
inline bool IsFloatImage(TBasicType type) inline bool IsFloatImage(TBasicType type)
{ {
switch (type) switch (type)
......
...@@ -1790,7 +1790,11 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1790,7 +1790,11 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{ {
TString name = TFunction::unmangleName(node->getFunctionSymbolInfo()->getName()); TString name = TFunction::unmangleName(node->getFunctionSymbolInfo()->getName());
TBasicType samplerType = (*arguments)[0]->getAsTyped()->getType().getBasicType(); TBasicType samplerType = (*arguments)[0]->getAsTyped()->getType().getBasicType();
int coords = (*arguments)[1]->getAsTyped()->getNominalSize(); int coords = 0; // textureSize(gsampler2DMS) doesn't have a second argument.
if (arguments->size() > 1)
{
coords = (*arguments)[1]->getAsTyped()->getNominalSize();
}
TString textureFunctionName = mTextureFunctionHLSL->useTextureFunction( TString textureFunctionName = mTextureFunctionHLSL->useTextureFunction(
name, samplerType, coords, arguments->size(), lod0, mShaderType); name, samplerType, coords, arguments->size(), lod0, mShaderType);
out << textureFunctionName << "("; out << textureFunctionName << "(";
......
...@@ -319,6 +319,8 @@ void OutputTextureFunctionArgumentList(TInfoSinkBase &out, ...@@ -319,6 +319,8 @@ void OutputTextureFunctionArgumentList(TInfoSinkBase &out,
{ {
switch (textureFunction.coords) switch (textureFunction.coords)
{ {
case 0:
break; // textureSize(gSampler2DMS sampler)
case 1: case 1:
out << ", int lod"; out << ", int lod";
break; // textureSize() break; // textureSize()
...@@ -457,48 +459,56 @@ void OutputTextureSizeFunctionBody(TInfoSinkBase &out, ...@@ -457,48 +459,56 @@ void OutputTextureSizeFunctionBody(TInfoSinkBase &out,
const TString &textureReference, const TString &textureReference,
bool getDimensionsIgnoresBaseLevel) bool getDimensionsIgnoresBaseLevel)
{ {
if (getDimensionsIgnoresBaseLevel) if (IsSampler2DMS(textureFunction.sampler))
{ {
out << "int baseLevel = samplerMetadata[samplerIndex].baseLevel;\n"; out << " uint width; uint height; uint samples;\n"
<< " " << textureReference << ".GetDimensions(width, height, samples);\n";
} }
else else
{ {
out << "int baseLevel = 0;\n"; if (getDimensionsIgnoresBaseLevel)
} {
out << " int baseLevel = samplerMetadata[samplerIndex].baseLevel;\n";
}
else
{
out << " int baseLevel = 0;\n";
}
if (IsSampler3D(textureFunction.sampler) || IsSamplerArray(textureFunction.sampler) || if (IsSampler3D(textureFunction.sampler) || IsSamplerArray(textureFunction.sampler) ||
(IsIntegerSampler(textureFunction.sampler) && IsSamplerCube(textureFunction.sampler))) (IsIntegerSampler(textureFunction.sampler) && IsSamplerCube(textureFunction.sampler)))
{ {
// "depth" stores either the number of layers in an array texture or 3D depth // "depth" stores either the number of layers in an array texture or 3D depth
out << " uint width; uint height; uint depth; uint numberOfLevels;\n" out << " uint width; uint height; uint depth; uint numberOfLevels;\n"
<< " " << textureReference << " " << textureReference
<< ".GetDimensions(baseLevel, width, height, depth, numberOfLevels);\n" << ".GetDimensions(baseLevel, width, height, depth, numberOfLevels);\n"
<< " width = max(width >> lod, 1);\n" << " width = max(width >> lod, 1);\n"
<< " height = max(height >> lod, 1);\n"; << " height = max(height >> lod, 1);\n";
if (!IsSamplerArray(textureFunction.sampler)) if (!IsSamplerArray(textureFunction.sampler))
{
out << " depth = max(depth >> lod, 1);\n";
}
}
else if (IsSampler2D(textureFunction.sampler) || IsSamplerCube(textureFunction.sampler))
{ {
out << " depth = max(depth >> lod, 1);\n"; out << " uint width; uint height; uint numberOfLevels;\n"
<< " " << textureReference
<< ".GetDimensions(baseLevel, width, height, numberOfLevels);\n"
<< " width = max(width >> lod, 1);\n"
<< " height = max(height >> lod, 1);\n";
} }
else
UNREACHABLE();
} }
else if (IsSampler2D(textureFunction.sampler) || IsSamplerCube(textureFunction.sampler))
{
out << " uint width; uint height; uint numberOfLevels;\n"
<< " " << textureReference
<< ".GetDimensions(baseLevel, width, height, numberOfLevels);\n"
<< " width = max(width >> lod, 1);\n"
<< " height = max(height >> lod, 1);\n";
}
else
UNREACHABLE();
if (strcmp(textureFunction.getReturnType(), "int3") == 0) if (strcmp(textureFunction.getReturnType(), "int3") == 0)
{ {
out << " return int3(width, height, depth);"; out << " return int3(width, height, depth);\n";
} }
else else
{ {
out << " return int2(width, height);"; out << " return int2(width, height);\n";
} }
} }
...@@ -1048,6 +1058,9 @@ const char *TextureFunctionHLSL::TextureFunction::getReturnType() const ...@@ -1048,6 +1058,9 @@ const char *TextureFunctionHLSL::TextureFunction::getReturnType() const
case EbtUSamplerCube: case EbtUSamplerCube:
case EbtSamplerCubeShadow: case EbtSamplerCubeShadow:
case EbtSamplerExternalOES: case EbtSamplerExternalOES:
case EbtSampler2DMS:
case EbtISampler2DMS:
case EbtUSampler2DMS:
return "int2"; return "int2";
case EbtSampler3D: case EbtSampler3D:
case EbtISampler3D: case EbtISampler3D:
......
...@@ -53,6 +53,8 @@ HLSLTextureSamplerGroup TextureGroup(const TBasicType type) ...@@ -53,6 +53,8 @@ HLSLTextureSamplerGroup TextureGroup(const TBasicType type)
return HLSL_TEXTURE_2D_ARRAY; return HLSL_TEXTURE_2D_ARRAY;
case EbtSampler3D: case EbtSampler3D:
return HLSL_TEXTURE_3D; return HLSL_TEXTURE_3D;
case EbtSampler2DMS:
return HLSL_TEXTURE_2D_MS;
case EbtISampler2D: case EbtISampler2D:
return HLSL_TEXTURE_2D_INT4; return HLSL_TEXTURE_2D_INT4;
case EbtISampler3D: case EbtISampler3D:
...@@ -61,6 +63,8 @@ HLSLTextureSamplerGroup TextureGroup(const TBasicType type) ...@@ -61,6 +63,8 @@ HLSLTextureSamplerGroup TextureGroup(const TBasicType type)
return HLSL_TEXTURE_2D_ARRAY_INT4; return HLSL_TEXTURE_2D_ARRAY_INT4;
case EbtISampler2DArray: case EbtISampler2DArray:
return HLSL_TEXTURE_2D_ARRAY_INT4; return HLSL_TEXTURE_2D_ARRAY_INT4;
case EbtISampler2DMS:
return HLSL_TEXTURE_2D_MS_INT4;
case EbtUSampler2D: case EbtUSampler2D:
return HLSL_TEXTURE_2D_UINT4; return HLSL_TEXTURE_2D_UINT4;
case EbtUSampler3D: case EbtUSampler3D:
...@@ -69,6 +73,8 @@ HLSLTextureSamplerGroup TextureGroup(const TBasicType type) ...@@ -69,6 +73,8 @@ HLSLTextureSamplerGroup TextureGroup(const TBasicType type)
return HLSL_TEXTURE_2D_ARRAY_UINT4; return HLSL_TEXTURE_2D_ARRAY_UINT4;
case EbtUSampler2DArray: case EbtUSampler2DArray:
return HLSL_TEXTURE_2D_ARRAY_UINT4; return HLSL_TEXTURE_2D_ARRAY_UINT4;
case EbtUSampler2DMS:
return HLSL_TEXTURE_2D_MS_UINT4;
case EbtSampler2DShadow: case EbtSampler2DShadow:
return HLSL_TEXTURE_2D_COMPARISON; return HLSL_TEXTURE_2D_COMPARISON;
case EbtSamplerCubeShadow: case EbtSamplerCubeShadow:
...@@ -93,18 +99,24 @@ TString TextureString(const HLSLTextureSamplerGroup type) ...@@ -93,18 +99,24 @@ TString TextureString(const HLSLTextureSamplerGroup type)
return "Texture2DArray"; return "Texture2DArray";
case HLSL_TEXTURE_3D: case HLSL_TEXTURE_3D:
return "Texture3D"; return "Texture3D";
case HLSL_TEXTURE_2D_MS:
return "Texture2DMS<float4>";
case HLSL_TEXTURE_2D_INT4: case HLSL_TEXTURE_2D_INT4:
return "Texture2D<int4>"; return "Texture2D<int4>";
case HLSL_TEXTURE_3D_INT4: case HLSL_TEXTURE_3D_INT4:
return "Texture3D<int4>"; return "Texture3D<int4>";
case HLSL_TEXTURE_2D_ARRAY_INT4: case HLSL_TEXTURE_2D_ARRAY_INT4:
return "Texture2DArray<int4>"; return "Texture2DArray<int4>";
case HLSL_TEXTURE_2D_MS_INT4:
return "Texture2DMS<int4>";
case HLSL_TEXTURE_2D_UINT4: case HLSL_TEXTURE_2D_UINT4:
return "Texture2D<uint4>"; return "Texture2D<uint4>";
case HLSL_TEXTURE_3D_UINT4: case HLSL_TEXTURE_3D_UINT4:
return "Texture3D<uint4>"; return "Texture3D<uint4>";
case HLSL_TEXTURE_2D_ARRAY_UINT4: case HLSL_TEXTURE_2D_ARRAY_UINT4:
return "Texture2DArray<uint4>"; return "Texture2DArray<uint4>";
case HLSL_TEXTURE_2D_MS_UINT4:
return "Texture2DMS<uint4>";
case HLSL_TEXTURE_2D_COMPARISON: case HLSL_TEXTURE_2D_COMPARISON:
return "Texture2D"; return "Texture2D";
case HLSL_TEXTURE_CUBE_COMPARISON: case HLSL_TEXTURE_CUBE_COMPARISON:
...@@ -135,18 +147,24 @@ TString TextureGroupSuffix(const HLSLTextureSamplerGroup type) ...@@ -135,18 +147,24 @@ TString TextureGroupSuffix(const HLSLTextureSamplerGroup type)
return "2DArray"; return "2DArray";
case HLSL_TEXTURE_3D: case HLSL_TEXTURE_3D:
return "3D"; return "3D";
case HLSL_TEXTURE_2D_MS:
return "2DMS";
case HLSL_TEXTURE_2D_INT4: case HLSL_TEXTURE_2D_INT4:
return "2D_int4_"; return "2D_int4_";
case HLSL_TEXTURE_3D_INT4: case HLSL_TEXTURE_3D_INT4:
return "3D_int4_"; return "3D_int4_";
case HLSL_TEXTURE_2D_ARRAY_INT4: case HLSL_TEXTURE_2D_ARRAY_INT4:
return "2DArray_int4_"; return "2DArray_int4_";
case HLSL_TEXTURE_2D_MS_INT4:
return "2DMS_int4_";
case HLSL_TEXTURE_2D_UINT4: case HLSL_TEXTURE_2D_UINT4:
return "2D_uint4_"; return "2D_uint4_";
case HLSL_TEXTURE_3D_UINT4: case HLSL_TEXTURE_3D_UINT4:
return "3D_uint4_"; return "3D_uint4_";
case HLSL_TEXTURE_2D_ARRAY_UINT4: case HLSL_TEXTURE_2D_ARRAY_UINT4:
return "2DArray_uint4_"; return "2DArray_uint4_";
case HLSL_TEXTURE_2D_MS_UINT4:
return "2DMS_uint4_";
case HLSL_TEXTURE_2D_COMPARISON: case HLSL_TEXTURE_2D_COMPARISON:
return "2D_comparison"; return "2D_comparison";
case HLSL_TEXTURE_CUBE_COMPARISON: case HLSL_TEXTURE_CUBE_COMPARISON:
......
...@@ -31,12 +31,15 @@ enum HLSLTextureSamplerGroup ...@@ -31,12 +31,15 @@ enum HLSLTextureSamplerGroup
HLSL_TEXTURE_CUBE, HLSL_TEXTURE_CUBE,
HLSL_TEXTURE_2D_ARRAY, HLSL_TEXTURE_2D_ARRAY,
HLSL_TEXTURE_3D, HLSL_TEXTURE_3D,
HLSL_TEXTURE_2D_MS,
HLSL_TEXTURE_2D_INT4, HLSL_TEXTURE_2D_INT4,
HLSL_TEXTURE_3D_INT4, HLSL_TEXTURE_3D_INT4,
HLSL_TEXTURE_2D_ARRAY_INT4, HLSL_TEXTURE_2D_ARRAY_INT4,
HLSL_TEXTURE_2D_MS_INT4,
HLSL_TEXTURE_2D_UINT4, HLSL_TEXTURE_2D_UINT4,
HLSL_TEXTURE_3D_UINT4, HLSL_TEXTURE_3D_UINT4,
HLSL_TEXTURE_2D_ARRAY_UINT4, HLSL_TEXTURE_2D_ARRAY_UINT4,
HLSL_TEXTURE_2D_MS_UINT4,
// Comparison samplers // Comparison samplers
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
1442 OPENGL D3D11 : dEQP-GLES31.functional.program_interface_query.transform_feedback_varying.type.vertex_fragment.struct.* = SKIP 1442 OPENGL D3D11 : dEQP-GLES31.functional.program_interface_query.transform_feedback_varying.type.vertex_fragment.struct.* = SKIP
1442 D3D11 : dEQP-GLES31.functional.stencil_texturing.* = SKIP 1442 D3D11 : dEQP-GLES31.functional.stencil_texturing.* = SKIP
1442 D3D11 : dEQP-GLES31.functional.state_query.shader.sampler_type = SKIP 1442 D3D11 : dEQP-GLES31.functional.state_query.shader.sampler_type = SKIP
1422 D3D11 : dEQP-GLES31.functional.shaders.builtin_functions.texture_size.* = SKIP
// OpenGL Failing Tests // OpenGL Failing Tests
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_1.sample_mask_only = FAIL 1442 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_1.sample_mask_only = FAIL
...@@ -108,6 +107,7 @@ ...@@ -108,6 +107,7 @@
// D3D11 Failing Tests // D3D11 Failing Tests
1442 D3D11 : dEQP-GLES31.functional.draw_indirect.* = FAIL 1442 D3D11 : dEQP-GLES31.functional.draw_indirect.* = FAIL
1442 D3D11 : dEQP-GLES31.functional.shaders.builtin_functions.texture_size.* = FAIL
1442 D3D11 : dEQP-GLES31.functional.state_query.integer.max_color_texture_samples_* = FAIL 1442 D3D11 : dEQP-GLES31.functional.state_query.integer.max_color_texture_samples_* = FAIL
1442 D3D11 : dEQP-GLES31.functional.state_query.integer.max_depth_texture_samples_* = FAIL 1442 D3D11 : dEQP-GLES31.functional.state_query.integer.max_depth_texture_samples_* = FAIL
1442 D3D11 : dEQP-GLES31.functional.state_query.integer.max_integer_samples_* = FAIL 1442 D3D11 : dEQP-GLES31.functional.state_query.integer.max_integer_samples_* = 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