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( ...@@ -169,28 +169,34 @@ void ImageFunctionHLSL::OutputImageStoreFunctionBody(
UNREACHABLE(); 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) if (readonly)
{ {
name += TextureTypeSuffix(image, imageInternalFormat); suffix = ImmutableString(TextureTypeSuffix(image, imageInternalFormat));
} }
else else
{ {
name += RWTextureTypeSuffix(image, imageInternalFormat); suffix = ImmutableString(RWTextureTypeSuffix(image, imageInternalFormat));
} }
ImmutableStringBuilder name(kGlImageName.length() + suffix.length() + 5u);
name << kGlImageName << suffix;
switch (method) switch (method)
{ {
case Method::SIZE: case Method::SIZE:
name += "Size"; name << "Size";
break; break;
case Method::LOAD: case Method::LOAD:
name += "Load"; name << "Load";
break; break;
case Method::STORE: case Method::STORE:
name += "Store"; name << "Store";
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -293,10 +299,10 @@ bool ImageFunctionHLSL::ImageFunction::operator<(const ImageFunction &rhs) const ...@@ -293,10 +299,10 @@ bool ImageFunctionHLSL::ImageFunction::operator<(const ImageFunction &rhs) const
std::tie(rhs.image, rhs.type, rhs.method, rhs.readonly); std::tie(rhs.image, rhs.type, rhs.method, rhs.readonly);
} }
TString ImageFunctionHLSL::useImageFunction(const ImmutableString &name, ImmutableString ImageFunctionHLSL::useImageFunction(const ImmutableString &name,
const TBasicType &type, const TBasicType &type,
TLayoutImageInternalFormat imageInternalFormat, TLayoutImageInternalFormat imageInternalFormat,
bool readonly) bool readonly)
{ {
ASSERT(IsImage(type)); ASSERT(IsImage(type));
ImageFunction imageFunction; ImageFunction imageFunction;
......
...@@ -25,10 +25,10 @@ class ImageFunctionHLSL final : angle::NonCopyable ...@@ -25,10 +25,10 @@ class ImageFunctionHLSL final : angle::NonCopyable
public: public:
// Returns the name of the image function implementation to caller. // 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. // The name that's passed in is the name of the GLSL image function that it should implement.
TString useImageFunction(const ImmutableString &name, ImmutableString useImageFunction(const ImmutableString &name,
const TBasicType &type, const TBasicType &type,
TLayoutImageInternalFormat imageInternalFormat, TLayoutImageInternalFormat imageInternalFormat,
bool readonly); bool readonly);
void imageFunctionHeader(TInfoSinkBase &out); void imageFunctionHeader(TInfoSinkBase &out);
...@@ -53,7 +53,7 @@ class ImageFunctionHLSL final : angle::NonCopyable ...@@ -53,7 +53,7 @@ class ImageFunctionHLSL final : angle::NonCopyable
SNORM_FLOAT4 SNORM_FLOAT4
}; };
TString name() const; ImmutableString name() const;
bool operator<(const ImageFunction &rhs) const; bool operator<(const ImageFunction &rhs) const;
......
...@@ -1941,8 +1941,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1941,8 +1941,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
else if (node->getFunction()->isImageFunction()) else if (node->getFunction()->isImageFunction())
{ {
const ImmutableString &name = node->getFunction()->name(); const ImmutableString &name = node->getFunction()->name();
TType type = (*arguments)[0]->getAsTyped()->getType(); TType type = (*arguments)[0]->getAsTyped()->getType();
TString imageFunctionName = mImageFunctionHLSL->useImageFunction( const ImmutableString &imageFunctionName = mImageFunctionHLSL->useImageFunction(
name, type.getBasicType(), type.getLayoutQualifier().imageInternalFormat, name, type.getBasicType(), type.getLayoutQualifier().imageInternalFormat,
type.getMemoryQualifier().readonly); type.getMemoryQualifier().readonly);
out << imageFunctionName << "("; 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