Commit c2ed9380 by Corentin Wallez

Revert "Refactor texture function handling in OutputHLSL"

It triggered an include guard warning on Windows Clang This reverts commit 6f6c5580. Change-Id: Ibd4f2851f311a494f16376d8eed38f3119594761 Reviewed-on: https://chromium-review.googlesource.com/338933Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 6f6c5580
......@@ -184,8 +184,6 @@
'compiler/translator/SeparateExpressionsReturningArrays.h',
'compiler/translator/StructureHLSL.cpp',
'compiler/translator/StructureHLSL.h',
'compiler/translator/TextureFunctionHLSL.cpp',
'compiler/translator/TextureFunctionHLSL.h',
'compiler/translator/TranslatorHLSL.cpp',
'compiler/translator/TranslatorHLSL.h',
'compiler/translator/UnfoldShortCircuitToIf.cpp',
......
......@@ -8,6 +8,7 @@
#define COMPILER_TRANSLATOR_OUTPUTHLSL_H_
#include <list>
#include <set>
#include <map>
#include <stack>
......@@ -20,9 +21,8 @@ class BuiltInFunctionEmulator;
namespace sh
{
class StructureHLSL;
class TextureFunctionHLSL;
class UnfoldShortCircuit;
class StructureHLSL;
class UniformHLSL;
typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
......@@ -139,9 +139,36 @@ class OutputHLSL : public TIntermTraverser
StructureHLSL *mStructureHLSL;
UniformHLSL *mUniformHLSL;
TextureFunctionHLSL *mTextureFunctionHLSL;
struct TextureFunction
{
enum Method
{
IMPLICIT, // Mipmap LOD determined implicitly (standard lookup)
BIAS,
LOD,
LOD0,
LOD0BIAS,
SIZE, // textureSize()
FETCH,
GRAD
};
TBasicType sampler;
int coords;
bool proj;
bool offset;
Method method;
TString name() const;
bool operator<(const TextureFunction &rhs) const;
};
typedef std::set<TextureFunction> TextureFunctionSet;
// Parameters determining what goes in the header output
TextureFunctionSet mUsesTexture;
bool mUsesFragColor;
bool mUsesFragData;
bool mUsesDepthRange;
......
//
// Copyright (c) 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// TextureFunctionHLSL: Class for writing implementations of ESSL texture functions into HLSL
// output. Some of the implementations are straightforward and just call the HLSL equivalent of the
// ESSL texture function, others do more work to emulate ESSL texture sampling or size query
// behavior.
//
#ifndef COMPILER_TRANSLATOR_TEXTUREFUNCTIONHLSL_H_
#define COMPILER_TRANSLATOR_TEXTUREFUNCTIOnHLSL_H_
#include <set>
#include "compiler/translator/BaseTypes.h"
#include "compiler/translator/Common.h"
#include "compiler/translator/InfoSink.h"
#include "GLSLANG/ShaderLang.h"
namespace sh
{
class TextureFunctionHLSL final : angle::NonCopyable
{
public:
struct TextureFunction
{
// See ESSL 3.00.6 section 8.8 for reference about what the different methods below do.
enum Method
{
IMPLICIT, // Mipmap LOD determined implicitly (standard lookup)
BIAS,
LOD,
LOD0,
LOD0BIAS,
SIZE, // textureSize()
FETCH,
GRAD
};
TString name() const;
bool operator<(const TextureFunction &rhs) const;
const char *getReturnType() const;
TBasicType sampler;
int coords;
bool proj;
bool offset;
Method method;
};
// Returns the name of the texture function implementation to call.
// The name that's passed in is the name of the GLSL texture function that it should implement.
TString useTextureFunction(const TString &name,
TBasicType samplerType,
int coords,
size_t argumentCount,
bool lod0,
sh::GLenum shaderType);
void textureFunctionHeader(TInfoSinkBase &out, const ShShaderOutput outputType);
private:
typedef std::set<TextureFunction> TextureFunctionSet;
TextureFunctionSet mUsesTexture;
};
} // namespace sh
#endif // COMPILER_TRANSLATOR_TEXTUREFUNCTIONHLSL_H_
......@@ -396,6 +396,46 @@ TString QualifierString(TQualifier qualifier)
return "";
}
int HLSLTextureCoordsCount(const TBasicType samplerType)
{
switch (samplerType)
{
case EbtSampler2D:
return 2;
case EbtSampler3D:
return 3;
case EbtSamplerCube:
return 3;
case EbtSampler2DArray:
return 3;
case EbtISampler2D:
return 2;
case EbtISampler3D:
return 3;
case EbtISamplerCube:
return 3;
case EbtISampler2DArray:
return 3;
case EbtUSampler2D:
return 2;
case EbtUSampler3D:
return 3;
case EbtUSamplerCube:
return 3;
case EbtUSampler2DArray:
return 3;
case EbtSampler2DShadow:
return 2;
case EbtSamplerCubeShadow:
return 3;
case EbtSampler2DArrayShadow:
return 3;
default:
UNREACHABLE();
}
return 0;
}
TString DisambiguateFunctionName(const TIntermSequence *parameters)
{
TString disambiguatingString;
......
......@@ -73,6 +73,7 @@ TString QualifiedStructNameString(const TStructure &structure, bool useHLSLRowMa
bool useStd140Packing);
TString InterpolationString(TQualifier qualifier);
TString QualifierString(TQualifier qualifier);
int HLSLTextureCoordsCount(const TBasicType samplerType);
// Parameters may need to be included in function names to disambiguate between overloaded
// functions.
TString DisambiguateFunctionName(const TIntermSequence *parameters);
......
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