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)
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)
{
switch (type)
......
......@@ -1790,7 +1790,11 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{
TString name = TFunction::unmangleName(node->getFunctionSymbolInfo()->getName());
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(
name, samplerType, coords, arguments->size(), lod0, mShaderType);
out << textureFunctionName << "(";
......
......@@ -319,6 +319,8 @@ void OutputTextureFunctionArgumentList(TInfoSinkBase &out,
{
switch (textureFunction.coords)
{
case 0:
break; // textureSize(gSampler2DMS sampler)
case 1:
out << ", int lod";
break; // textureSize()
......@@ -457,13 +459,20 @@ void OutputTextureSizeFunctionBody(TInfoSinkBase &out,
const TString &textureReference,
bool getDimensionsIgnoresBaseLevel)
{
if (IsSampler2DMS(textureFunction.sampler))
{
out << " uint width; uint height; uint samples;\n"
<< " " << textureReference << ".GetDimensions(width, height, samples);\n";
}
else
{
if (getDimensionsIgnoresBaseLevel)
{
out << "int baseLevel = samplerMetadata[samplerIndex].baseLevel;\n";
out << " int baseLevel = samplerMetadata[samplerIndex].baseLevel;\n";
}
else
{
out << "int baseLevel = 0;\n";
out << " int baseLevel = 0;\n";
}
if (IsSampler3D(textureFunction.sampler) || IsSamplerArray(textureFunction.sampler) ||
......@@ -491,14 +500,15 @@ void OutputTextureSizeFunctionBody(TInfoSinkBase &out,
}
else
UNREACHABLE();
}
if (strcmp(textureFunction.getReturnType(), "int3") == 0)
{
out << " return int3(width, height, depth);";
out << " return int3(width, height, depth);\n";
}
else
{
out << " return int2(width, height);";
out << " return int2(width, height);\n";
}
}
......@@ -1048,6 +1058,9 @@ const char *TextureFunctionHLSL::TextureFunction::getReturnType() const
case EbtUSamplerCube:
case EbtSamplerCubeShadow:
case EbtSamplerExternalOES:
case EbtSampler2DMS:
case EbtISampler2DMS:
case EbtUSampler2DMS:
return "int2";
case EbtSampler3D:
case EbtISampler3D:
......
......@@ -53,6 +53,8 @@ HLSLTextureSamplerGroup TextureGroup(const TBasicType type)
return HLSL_TEXTURE_2D_ARRAY;
case EbtSampler3D:
return HLSL_TEXTURE_3D;
case EbtSampler2DMS:
return HLSL_TEXTURE_2D_MS;
case EbtISampler2D:
return HLSL_TEXTURE_2D_INT4;
case EbtISampler3D:
......@@ -61,6 +63,8 @@ HLSLTextureSamplerGroup TextureGroup(const TBasicType type)
return HLSL_TEXTURE_2D_ARRAY_INT4;
case EbtISampler2DArray:
return HLSL_TEXTURE_2D_ARRAY_INT4;
case EbtISampler2DMS:
return HLSL_TEXTURE_2D_MS_INT4;
case EbtUSampler2D:
return HLSL_TEXTURE_2D_UINT4;
case EbtUSampler3D:
......@@ -69,6 +73,8 @@ HLSLTextureSamplerGroup TextureGroup(const TBasicType type)
return HLSL_TEXTURE_2D_ARRAY_UINT4;
case EbtUSampler2DArray:
return HLSL_TEXTURE_2D_ARRAY_UINT4;
case EbtUSampler2DMS:
return HLSL_TEXTURE_2D_MS_UINT4;
case EbtSampler2DShadow:
return HLSL_TEXTURE_2D_COMPARISON;
case EbtSamplerCubeShadow:
......@@ -93,18 +99,24 @@ TString TextureString(const HLSLTextureSamplerGroup type)
return "Texture2DArray";
case HLSL_TEXTURE_3D:
return "Texture3D";
case HLSL_TEXTURE_2D_MS:
return "Texture2DMS<float4>";
case HLSL_TEXTURE_2D_INT4:
return "Texture2D<int4>";
case HLSL_TEXTURE_3D_INT4:
return "Texture3D<int4>";
case HLSL_TEXTURE_2D_ARRAY_INT4:
return "Texture2DArray<int4>";
case HLSL_TEXTURE_2D_MS_INT4:
return "Texture2DMS<int4>";
case HLSL_TEXTURE_2D_UINT4:
return "Texture2D<uint4>";
case HLSL_TEXTURE_3D_UINT4:
return "Texture3D<uint4>";
case HLSL_TEXTURE_2D_ARRAY_UINT4:
return "Texture2DArray<uint4>";
case HLSL_TEXTURE_2D_MS_UINT4:
return "Texture2DMS<uint4>";
case HLSL_TEXTURE_2D_COMPARISON:
return "Texture2D";
case HLSL_TEXTURE_CUBE_COMPARISON:
......@@ -135,18 +147,24 @@ TString TextureGroupSuffix(const HLSLTextureSamplerGroup type)
return "2DArray";
case HLSL_TEXTURE_3D:
return "3D";
case HLSL_TEXTURE_2D_MS:
return "2DMS";
case HLSL_TEXTURE_2D_INT4:
return "2D_int4_";
case HLSL_TEXTURE_3D_INT4:
return "3D_int4_";
case HLSL_TEXTURE_2D_ARRAY_INT4:
return "2DArray_int4_";
case HLSL_TEXTURE_2D_MS_INT4:
return "2DMS_int4_";
case HLSL_TEXTURE_2D_UINT4:
return "2D_uint4_";
case HLSL_TEXTURE_3D_UINT4:
return "3D_uint4_";
case HLSL_TEXTURE_2D_ARRAY_UINT4:
return "2DArray_uint4_";
case HLSL_TEXTURE_2D_MS_UINT4:
return "2DMS_uint4_";
case HLSL_TEXTURE_2D_COMPARISON:
return "2D_comparison";
case HLSL_TEXTURE_CUBE_COMPARISON:
......
......@@ -31,12 +31,15 @@ enum HLSLTextureSamplerGroup
HLSL_TEXTURE_CUBE,
HLSL_TEXTURE_2D_ARRAY,
HLSL_TEXTURE_3D,
HLSL_TEXTURE_2D_MS,
HLSL_TEXTURE_2D_INT4,
HLSL_TEXTURE_3D_INT4,
HLSL_TEXTURE_2D_ARRAY_INT4,
HLSL_TEXTURE_2D_MS_INT4,
HLSL_TEXTURE_2D_UINT4,
HLSL_TEXTURE_3D_UINT4,
HLSL_TEXTURE_2D_ARRAY_UINT4,
HLSL_TEXTURE_2D_MS_UINT4,
// Comparison samplers
......
......@@ -35,7 +35,6 @@
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.state_query.shader.sampler_type = SKIP
1422 D3D11 : dEQP-GLES31.functional.shaders.builtin_functions.texture_size.* = SKIP
// OpenGL Failing Tests
1442 OPENGL : dEQP-GLES31.functional.texture.multisample.samples_1.sample_mask_only = FAIL
......@@ -108,6 +107,7 @@
// D3D11 Failing Tests
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_depth_texture_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