Path: blob/main_old/src/compiler/translator/ImageFunctionHLSL.h
1693 views
//1// Copyright 2017 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// ImageFunctionHLSL: Class for writing implementations of ESSL image functions into HLSL output.6//78#ifndef COMPILER_TRANSLATOR_IMAGEFUNCTIONHLSL_H_9#define COMPILER_TRANSLATOR_IMAGEFUNCTIONHLSL_H_1011#include <set>1213#include "GLSLANG/ShaderLang.h"14#include "compiler/translator/BaseTypes.h"15#include "compiler/translator/Common.h"16#include "compiler/translator/InfoSink.h"17#include "compiler/translator/Types.h"1819namespace sh20{2122class ImageFunctionHLSL final : angle::NonCopyable23{24public:25// Returns the name of the image function implementation to caller.26// The name that's passed in is the name of the GLSL image function that it should implement.27ImmutableString useImageFunction(const ImmutableString &name,28const TBasicType &type,29TLayoutImageInternalFormat imageInternalFormat,30bool readonly);3132void imageFunctionHeader(TInfoSinkBase &out);33const std::set<std::string> &getUsedImage2DFunctionNames() const34{35return mUsedImage2DFunctionNames;36}3738private:39struct ImageFunction40{41// See ESSL 3.10.4 section 8.12 for reference about what the different methods below do.42enum class Method43{44SIZE,45LOAD,46STORE47};4849enum class DataType50{51NONE,52FLOAT4,53UINT4,54INT4,55UNORM_FLOAT4,56SNORM_FLOAT457};5859ImmutableString name() const;6061bool operator<(const ImageFunction &rhs) const;6263DataType getDataType(TLayoutImageInternalFormat format) const;6465const char *getReturnType() const;6667TBasicType image;68TLayoutImageInternalFormat imageInternalFormat;69bool readonly;70Method method;71DataType type;72};7374static ImmutableString GetImageReference(TInfoSinkBase &out,75const ImageFunctionHLSL::ImageFunction &imageFunction);76static void OutputImageFunctionArgumentList(77TInfoSinkBase &out,78const ImageFunctionHLSL::ImageFunction &imageFunction);79static void OutputImageSizeFunctionBody(TInfoSinkBase &out,80const ImageFunctionHLSL::ImageFunction &imageFunction,81const ImmutableString &imageReference);82static void OutputImageLoadFunctionBody(TInfoSinkBase &out,83const ImageFunctionHLSL::ImageFunction &imageFunction,84const ImmutableString &imageReference);85static void OutputImageStoreFunctionBody(TInfoSinkBase &out,86const ImageFunctionHLSL::ImageFunction &imageFunction,87const ImmutableString &imageReference);88using ImageFunctionSet = std::set<ImageFunction>;89ImageFunctionSet mUsesImage;90std::set<std::string> mUsedImage2DFunctionNames;91};9293} // namespace sh9495#endif // COMPILER_TRANSLATOR_IMAGEFUNCTIONHLSL_H_969798