Commit 8fbd9d96 by Olli Etuaho Committed by Commit Bot

Use ImmutableString in ImageFunctionHLSL

This code is analoguous to the code in TextureFunctionHLSL and is now implemented in a similar manner. BUG=angleproject:2267 TEST=angle_unittests, angle_end2end_tests Change-Id: Ie3503766217dad4f3848f2d4b2fc3f62b3edce0c Reviewed-on: https://chromium-review.googlesource.com/1110366Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 7e585118
......@@ -169,28 +169,34 @@ void ImageFunctionHLSL::OutputImageStoreFunctionBody(
UNREACHABLE();
}
TString ImageFunctionHLSL::ImageFunction::name() const
ImmutableString ImageFunctionHLSL::ImageFunction::name() const
{
TString name = "gl_image";
static const ImmutableString kGlImageName("gl_image");
ImmutableString suffix(nullptr);
if (readonly)
{
name += TextureTypeSuffix(image, imageInternalFormat);
suffix = ImmutableString(TextureTypeSuffix(image, imageInternalFormat));
}
else
{
name += RWTextureTypeSuffix(image, imageInternalFormat);
suffix = ImmutableString(RWTextureTypeSuffix(image, imageInternalFormat));
}
ImmutableStringBuilder name(kGlImageName.length() + suffix.length() + 5u);
name << kGlImageName << suffix;
switch (method)
{
case Method::SIZE:
name += "Size";
name << "Size";
break;
case Method::LOAD:
name += "Load";
name << "Load";
break;
case Method::STORE:
name += "Store";
name << "Store";
break;
default:
UNREACHABLE();
......@@ -293,10 +299,10 @@ bool ImageFunctionHLSL::ImageFunction::operator<(const ImageFunction &rhs) const
std::tie(rhs.image, rhs.type, rhs.method, rhs.readonly);
}
TString ImageFunctionHLSL::useImageFunction(const ImmutableString &name,
const TBasicType &type,
TLayoutImageInternalFormat imageInternalFormat,
bool readonly)
ImmutableString ImageFunctionHLSL::useImageFunction(const ImmutableString &name,
const TBasicType &type,
TLayoutImageInternalFormat imageInternalFormat,
bool readonly)
{
ASSERT(IsImage(type));
ImageFunction imageFunction;
......
......@@ -25,10 +25,10 @@ class ImageFunctionHLSL final : angle::NonCopyable
public:
// Returns the name of the image function implementation to caller.
// The name that's passed in is the name of the GLSL image function that it should implement.
TString useImageFunction(const ImmutableString &name,
const TBasicType &type,
TLayoutImageInternalFormat imageInternalFormat,
bool readonly);
ImmutableString useImageFunction(const ImmutableString &name,
const TBasicType &type,
TLayoutImageInternalFormat imageInternalFormat,
bool readonly);
void imageFunctionHeader(TInfoSinkBase &out);
......@@ -53,7 +53,7 @@ class ImageFunctionHLSL final : angle::NonCopyable
SNORM_FLOAT4
};
TString name() const;
ImmutableString name() const;
bool operator<(const ImageFunction &rhs) const;
......
......@@ -1941,8 +1941,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
else if (node->getFunction()->isImageFunction())
{
const ImmutableString &name = node->getFunction()->name();
TType type = (*arguments)[0]->getAsTyped()->getType();
TString imageFunctionName = mImageFunctionHLSL->useImageFunction(
TType type = (*arguments)[0]->getAsTyped()->getType();
const ImmutableString &imageFunctionName = mImageFunctionHLSL->useImageFunction(
name, type.getBasicType(), type.getLayoutQualifier().imageInternalFormat,
type.getMemoryQualifier().readonly);
out << imageFunctionName << "(";
......
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