Commit 5858f7e3 by Olli Etuaho

Re-land "Refactor texture function handling in OutputHLSL"

This change is pure refactoring, it does not introduce any functional changes. Separate texture function output into a helper class and further into different helper functions to make the code more maintainable. Some of the logic is simplified slightly by eliminating duplicate cases and limiting the scope of variables where possible, but care has been taken to preserve the exact same functionality as before. Re-land with a fix to typo in include guard. BUG=angleproject:1349 TEST=dEQP-GLES3.functional.shaders.texture_functions.* (no regression) dEQP-GLES3.texture.* (no regression) Change-Id: I57c1ec1950fa05bd16275ca578eb5ee99b34a5ae Reviewed-on: https://chromium-review.googlesource.com/339180Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c2ed9380
......@@ -184,6 +184,8 @@
'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,7 +8,6 @@
#define COMPILER_TRANSLATOR_OUTPUTHLSL_H_
#include <list>
#include <set>
#include <map>
#include <stack>
......@@ -21,8 +20,9 @@ class BuiltInFunctionEmulator;
namespace sh
{
class UnfoldShortCircuit;
class StructureHLSL;
class TextureFunctionHLSL;
class UnfoldShortCircuit;
class UniformHLSL;
typedef std::map<TString, TIntermSymbol*> ReferencedSymbols;
......@@ -139,36 +139,9 @@ class OutputHLSL : public TIntermTraverser
StructureHLSL *mStructureHLSL;
UniformHLSL *mUniformHLSL;
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;
TextureFunctionHLSL *mTextureFunctionHLSL;
// 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,46 +396,6 @@ 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,7 +73,6 @@ 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