Commit dbb9c534 by Lingfeng Yang Committed by Commit Bot

GLES1: state: Define / initialize GLES1-specific states

Contains definitions of GLES1-specific states such as material / lighting. Tweaked the Color class for easier copying to uniforms / reading as a float array. This CL also adds the GLES1-specific state in GLES1State, which is then part of the State class and is initialized to the spec's values if the context major version is ES 1. + Some clang-format BUG=angleproject:2306 Change-Id: I7fc3bd9a22ebf0ffcd98d931d0176f21e17b1c5c Reviewed-on: https://chromium-review.googlesource.com/936424 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 92de2af5
......@@ -15,13 +15,16 @@ namespace angle
template <typename T>
struct Color
{
Color();
Color(T r, T g, T b, T a);
const T *data() const { return &red; }
T *ptr() { return &red; }
T red;
T green;
T blue;
T alpha;
Color();
Color(T r, T g, T b, T a);
};
template <typename T>
......
//
// Copyright 2018 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.
//
// GLES1State.cpp: Implements the GLES1State class, tracking state
// for GLES1 contexts.
#include "libANGLE/GLES1State.h"
#include "libANGLE/Context.h"
namespace gl
{
GLES1State::GLES1State()
: mVertexArrayEnabled(false),
mNormalArrayEnabled(false),
mColorArrayEnabled(false),
mPointSizeArrayEnabled(false),
mLineSmoothEnabled(false),
mPointSmoothEnabled(false),
mPointSpriteEnabled(false),
mAlphaTestEnabled(false),
mLogicOpEnabled(false),
mLightingEnabled(false),
mFogEnabled(false),
mRescaleNormalEnabled(false),
mNormalizeEnabled(false),
mColorMaterialEnabled(false),
mReflectionMapEnabled(false),
mCurrentColor({0.0f, 0.0f, 0.0f, 0.0f}),
mCurrentNormal({0.0f, 0.0f, 0.0f}),
mCurrMatrixMode(MatrixType::Modelview),
mShadeModel(ShadingModel::Smooth),
mAlphaFunc(AlphaTestFunc::AlwaysPass),
mAlphaTestRef(0.0f),
mLogicOp(LogicalOperation::Copy),
mLineSmoothHint(HintSetting::DontCare),
mPointSmoothHint(HintSetting::DontCare),
mPerspectiveCorrectionHint(HintSetting::DontCare),
mFogHint(HintSetting::DontCare)
{
}
GLES1State::~GLES1State() = default;
// Taken from the GLES 1.x spec which specifies all initial state values.
void GLES1State::initialize(const Context *context)
{
const Caps &caps = context->getCaps();
mTexUnitEnables.resize(caps.maxMultitextureUnits);
for (auto &enables : mTexUnitEnables)
{
enables.enable2D = false;
enables.enableCubeMap = false;
}
mVertexArrayEnabled = false;
mNormalArrayEnabled = false;
mColorArrayEnabled = false;
mPointSizeArrayEnabled = false;
mTexCoordArrayEnabled.resize(caps.maxMultitextureUnits, false);
mLineSmoothEnabled = false;
mPointSmoothEnabled = false;
mPointSpriteEnabled = false;
mLogicOpEnabled = false;
mAlphaTestEnabled = false;
mLightingEnabled = false;
mFogEnabled = false;
mRescaleNormalEnabled = false;
mNormalizeEnabled = false;
mColorMaterialEnabled = false;
mReflectionMapEnabled = false;
mCurrMatrixMode = MatrixType::Modelview;
mCurrentColor = {1.0f, 1.0f, 1.0f, 1.0f};
mCurrentNormal = {0.0f, 0.0f, 1.0f};
mCurrentTextureCoords.resize(caps.maxMultitextureUnits);
mTextureEnvironments.resize(caps.maxMultitextureUnits);
mProjMatrices.resize(caps.maxProjectionMatrixStackDepth);
mModelviewMatrices.resize(caps.maxModelviewMatrixStackDepth);
mTextureMatrices.resize(caps.maxMultitextureUnits);
for (auto &textureMatrixStack : mTextureMatrices)
{
textureMatrixStack.resize(caps.maxTextureMatrixStackDepth);
}
mMaterial.ambient = {0.2f, 0.2f, 0.2f, 1.0f};
mMaterial.diffuse = {0.8f, 0.8f, 0.8f, 1.0f};
mMaterial.specular = {0.0f, 0.0f, 0.0f, 1.0f};
mMaterial.emissive = {0.0f, 0.0f, 0.0f, 1.0f};
mMaterial.specularExponent = 0.0f;
mLightModel.color = {0.2f, 0.2f, 0.2f, 1.0f};
mLightModel.twoSided = false;
mLights.resize(caps.maxLights);
// GL_LIGHT0 is special and has default state that avoids all-black renderings.
mLights[0].diffuse = {1.0f, 1.0f, 1.0f, 1.0f};
mLights[0].specular = {1.0f, 1.0f, 1.0f, 1.0f};
mFog.mode = FogMode::Exp;
mFog.density = 1.0f;
mFog.start = 0.0f;
mFog.end = 1.0f;
mFog.color = {0.0f, 0.0f, 0.0f, 0.0f};
mShadeModel = ShadingModel::Smooth;
mAlphaFunc = AlphaTestFunc::AlwaysPass;
mAlphaTestRef = 0.0f;
mLogicOp = LogicalOperation::Copy;
mClipPlaneEnabled.resize(caps.maxClipPlanes, false);
mClipPlanes.resize(caps.maxClipPlanes, angle::Vector4(0.0f, 0.0f, 0.0f, 0.0f));
mPointParameters.pointSizeMin = 0.1f;
mPointParameters.pointSizeMax = 100.0f;
mPointParameters.pointFadeThresholdSize = 0.1f;
mPointParameters.pointDistanceAttenuation[0] = 1.0f;
mPointParameters.pointDistanceAttenuation[1] = 0.0f;
mPointParameters.pointDistanceAttenuation[2] = 0.0f;
mPointParameters.pointSize = 1.0f;
mLineSmoothHint = HintSetting::DontCare;
mPointSmoothHint = HintSetting::DontCare;
mPerspectiveCorrectionHint = HintSetting::DontCare;
mFogHint = HintSetting::DontCare;
}
} // namespace gl
//
// Copyright 2018 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.
//
// GLES1State.h: Defines the GLES1State class holding the state of
// a GLES1 context.
#ifndef LIBANGLE_GLES1STATE_H_
#define LIBANGLE_GLES1STATE_H_
#include <unordered_set>
#include "common/angleutils.h"
#include "common/matrix_utils.h"
#include "common/vector_utils.h"
#include "libANGLE/angletypes.h"
namespace gl
{
// State types specific to GLES1 contexts, from the OpenGL ES 1.1 spec "State Tables" section
struct TextureCoordF
{
GLfloat s = 0.0f;
GLfloat t = 0.0f;
GLfloat r = 0.0f;
GLfloat q = 0.0f;
};
struct MaterialParameters
{
ColorF ambient;
ColorF diffuse;
ColorF specular;
ColorF emissive;
GLfloat specularExponent;
};
struct LightModelParameters
{
ColorF color;
bool twoSided;
};
struct LightParameters
{
bool enabled = false;
ColorF ambient = {0.0f, 0.0f, 0.0f, 1.0f};
ColorF diffuse = {0.0f, 0.0f, 0.0f, 1.0f};
ColorF specular = {0.0f, 0.0f, 0.0f, 1.0f};
angle::Vector4 position = {0.0f, 0.0f, 1.0f, 0.0f};
angle::Vector3 direction = {0.0f, 0.0f, -1.0f};
GLfloat spotlightExponent = 0.0f;
GLfloat spotlightCutoffAngle = 180.0f;
GLfloat attenuationConst = 1.0f;
GLfloat attenuationLinear = 0.0f;
GLfloat attenuationQuadratic = 0.0f;
};
struct FogParameters
{
FogMode mode;
GLfloat density;
GLfloat start;
GLfloat end;
ColorF color;
};
struct TextureEnvironmentParameters
{
TextureEnvMode envMode = TextureEnvMode::Modulate;
TextureCombine combineRgb = TextureCombine::Modulate;
TextureCombine combineAlpha = TextureCombine::Modulate;
TextureSrc src0rgb = TextureSrc::Texture;
TextureSrc src0alpha = TextureSrc::Texture;
TextureSrc src1rgb = TextureSrc::Previous;
TextureSrc src1alpha = TextureSrc::Previous;
TextureSrc src2rgb = TextureSrc::Constant;
TextureSrc src2alpha = TextureSrc::Constant;
TextureOp op0rgb = TextureOp::SrcColor;
TextureOp op0alpha = TextureOp::SrcAlpha;
TextureOp op1rgb = TextureOp::SrcColor;
TextureOp op1alpha = TextureOp::SrcAlpha;
TextureOp op2rgb = TextureOp::SrcAlpha;
TextureOp op2alpha = TextureOp::SrcAlpha;
ColorF envColor = {0.0f, 0.0f, 0.0f, 0.0f};
GLfloat rgbScale = 1.0f;
GLfloat alphaScale = 1.0f;
bool pointSpriteCoordReplace = false;
};
struct PointParameters
{
GLfloat pointSizeMin;
GLfloat pointSizeMax;
GLfloat pointFadeThresholdSize;
angle::Vector3 pointDistanceAttenuation;
GLfloat pointSize;
};
class Context;
class GLES1State final : angle::NonCopyable
{
public:
GLES1State();
~GLES1State();
void initialize(const Context *context);
private:
// All initial state values come from the
// OpenGL ES 1.1 spec.
struct TextureEnables
{
bool enable2D = false;
bool enableCubeMap = false;
};
std::vector<TextureEnables> mTexUnitEnables;
// Table 6.4, 6.5 (IsEnabled)
bool mVertexArrayEnabled;
bool mNormalArrayEnabled;
bool mColorArrayEnabled;
bool mPointSizeArrayEnabled;
std::vector<bool> mTexCoordArrayEnabled;
// Table 6.7-6.16 (IsEnabled)
std::vector<bool> mClipPlaneEnabled;
bool mLineSmoothEnabled;
bool mPointSmoothEnabled;
bool mPointSpriteEnabled;
bool mAlphaTestEnabled;
bool mLogicOpEnabled;
bool mLightingEnabled;
bool mFogEnabled;
bool mRescaleNormalEnabled;
bool mNormalizeEnabled;
bool mColorMaterialEnabled;
bool mReflectionMapEnabled;
// Table 6.3
ColorF mCurrentColor;
angle::Vector3 mCurrentNormal;
std::vector<TextureCoordF> mCurrentTextureCoords;
// Table 6.7
using MatrixStack = std::vector<angle::Mat4>;
MatrixType mCurrMatrixMode;
MatrixStack mProjMatrices;
MatrixStack mModelviewMatrices;
std::vector<MatrixStack> mTextureMatrices;
// Table 6.15
using TextureEnvironments = std::vector<TextureEnvironmentParameters>;
TextureEnvironments mTextureEnvironments;
// Table 6.9, 2.8
MaterialParameters mMaterial;
LightModelParameters mLightModel;
// Table 6.10
std::vector<LightParameters> mLights;
// Table 6.8
FogParameters mFog;
ShadingModel mShadeModel;
// Table 6.11
PointParameters mPointParameters;
// Table 6.16
AlphaTestFunc mAlphaFunc;
GLfloat mAlphaTestRef;
LogicalOperation mLogicOp;
// Table 6.7
std::vector<angle::Vector4> mClipPlanes;
// Table 6.19
HintSetting mLineSmoothHint;
HintSetting mPointSmoothHint;
HintSetting mPerspectiveCorrectionHint;
HintSetting mFogHint;
};
} // namespace gl
#endif // LIBANGLE_GLES1STATE_H_
......@@ -16,6 +16,58 @@ namespace gl
{
template <>
AlphaTestFunc FromGLenum<AlphaTestFunc>(GLenum from)
{
switch (from)
{
case GL_ALWAYS:
return AlphaTestFunc::AlwaysPass;
case GL_EQUAL:
return AlphaTestFunc::Equal;
case GL_GEQUAL:
return AlphaTestFunc::Gequal;
case GL_GREATER:
return AlphaTestFunc::Greater;
case GL_LEQUAL:
return AlphaTestFunc::Lequal;
case GL_LESS:
return AlphaTestFunc::Less;
case GL_NEVER:
return AlphaTestFunc::Never;
case GL_NOTEQUAL:
return AlphaTestFunc::NotEqual;
default:
return AlphaTestFunc::InvalidEnum;
}
}
GLenum ToGLenum(AlphaTestFunc from)
{
switch (from)
{
case AlphaTestFunc::AlwaysPass:
return GL_ALWAYS;
case AlphaTestFunc::Equal:
return GL_EQUAL;
case AlphaTestFunc::Gequal:
return GL_GEQUAL;
case AlphaTestFunc::Greater:
return GL_GREATER;
case AlphaTestFunc::Lequal:
return GL_LEQUAL;
case AlphaTestFunc::Less:
return GL_LESS;
case AlphaTestFunc::Never:
return GL_NEVER;
case AlphaTestFunc::NotEqual:
return GL_NOTEQUAL;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
BufferBinding FromGLenum<BufferBinding>(GLenum from)
{
switch (from)
......@@ -172,6 +224,382 @@ GLenum ToGLenum(CullFaceMode from)
}
template <>
FogMode FromGLenum<FogMode>(GLenum from)
{
switch (from)
{
case GL_EXP:
return FogMode::Exp;
case GL_EXP2:
return FogMode::Exp2;
case GL_LINEAR:
return FogMode::Linear;
default:
return FogMode::InvalidEnum;
}
}
GLenum ToGLenum(FogMode from)
{
switch (from)
{
case FogMode::Exp:
return GL_EXP;
case FogMode::Exp2:
return GL_EXP2;
case FogMode::Linear:
return GL_LINEAR;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
HintSetting FromGLenum<HintSetting>(GLenum from)
{
switch (from)
{
case GL_DONT_CARE:
return HintSetting::DontCare;
case GL_FASTEST:
return HintSetting::Fastest;
case GL_NICEST:
return HintSetting::Nicest;
default:
return HintSetting::InvalidEnum;
}
}
GLenum ToGLenum(HintSetting from)
{
switch (from)
{
case HintSetting::DontCare:
return GL_DONT_CARE;
case HintSetting::Fastest:
return GL_FASTEST;
case HintSetting::Nicest:
return GL_NICEST;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
LogicalOperation FromGLenum<LogicalOperation>(GLenum from)
{
switch (from)
{
case GL_AND:
return LogicalOperation::And;
case GL_AND_INVERTED:
return LogicalOperation::AndInverted;
case GL_AND_REVERSE:
return LogicalOperation::AndReverse;
case GL_CLEAR:
return LogicalOperation::Clear;
case GL_COPY:
return LogicalOperation::Copy;
case GL_COPY_INVERTED:
return LogicalOperation::CopyInverted;
case GL_EQUIV:
return LogicalOperation::Equiv;
case GL_INVERT:
return LogicalOperation::Invert;
case GL_NAND:
return LogicalOperation::Nand;
case GL_NOOP:
return LogicalOperation::Noop;
case GL_NOR:
return LogicalOperation::Nor;
case GL_OR:
return LogicalOperation::Or;
case GL_OR_INVERTED:
return LogicalOperation::OrInverted;
case GL_OR_REVERSE:
return LogicalOperation::OrReverse;
case GL_SET:
return LogicalOperation::Set;
case GL_XOR:
return LogicalOperation::Xor;
default:
return LogicalOperation::InvalidEnum;
}
}
GLenum ToGLenum(LogicalOperation from)
{
switch (from)
{
case LogicalOperation::And:
return GL_AND;
case LogicalOperation::AndInverted:
return GL_AND_INVERTED;
case LogicalOperation::AndReverse:
return GL_AND_REVERSE;
case LogicalOperation::Clear:
return GL_CLEAR;
case LogicalOperation::Copy:
return GL_COPY;
case LogicalOperation::CopyInverted:
return GL_COPY_INVERTED;
case LogicalOperation::Equiv:
return GL_EQUIV;
case LogicalOperation::Invert:
return GL_INVERT;
case LogicalOperation::Nand:
return GL_NAND;
case LogicalOperation::Noop:
return GL_NOOP;
case LogicalOperation::Nor:
return GL_NOR;
case LogicalOperation::Or:
return GL_OR;
case LogicalOperation::OrInverted:
return GL_OR_INVERTED;
case LogicalOperation::OrReverse:
return GL_OR_REVERSE;
case LogicalOperation::Set:
return GL_SET;
case LogicalOperation::Xor:
return GL_XOR;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
MatrixType FromGLenum<MatrixType>(GLenum from)
{
switch (from)
{
case GL_MODELVIEW:
return MatrixType::Modelview;
case GL_PROJECTION:
return MatrixType::Projection;
case GL_TEXTURE:
return MatrixType::Texture;
default:
return MatrixType::InvalidEnum;
}
}
GLenum ToGLenum(MatrixType from)
{
switch (from)
{
case MatrixType::Modelview:
return GL_MODELVIEW;
case MatrixType::Projection:
return GL_PROJECTION;
case MatrixType::Texture:
return GL_TEXTURE;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
ShadingModel FromGLenum<ShadingModel>(GLenum from)
{
switch (from)
{
case GL_FLAT:
return ShadingModel::Flat;
case GL_SMOOTH:
return ShadingModel::Smooth;
default:
return ShadingModel::InvalidEnum;
}
}
GLenum ToGLenum(ShadingModel from)
{
switch (from)
{
case ShadingModel::Flat:
return GL_FLAT;
case ShadingModel::Smooth:
return GL_SMOOTH;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
TextureCombine FromGLenum<TextureCombine>(GLenum from)
{
switch (from)
{
case GL_ADD:
return TextureCombine::Add;
case GL_ADD_SIGNED:
return TextureCombine::AddSigned;
case GL_DOT3_RGB:
return TextureCombine::Dot3Rgb;
case GL_DOT3_RGBA:
return TextureCombine::Dot3Rgba;
case GL_INTERPOLATE:
return TextureCombine::Interpolate;
case GL_MODULATE:
return TextureCombine::Modulate;
case GL_REPLACE:
return TextureCombine::Replace;
case GL_SUBTRACT:
return TextureCombine::Subtract;
default:
return TextureCombine::InvalidEnum;
}
}
GLenum ToGLenum(TextureCombine from)
{
switch (from)
{
case TextureCombine::Add:
return GL_ADD;
case TextureCombine::AddSigned:
return GL_ADD_SIGNED;
case TextureCombine::Dot3Rgb:
return GL_DOT3_RGB;
case TextureCombine::Dot3Rgba:
return GL_DOT3_RGBA;
case TextureCombine::Interpolate:
return GL_INTERPOLATE;
case TextureCombine::Modulate:
return GL_MODULATE;
case TextureCombine::Replace:
return GL_REPLACE;
case TextureCombine::Subtract:
return GL_SUBTRACT;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
TextureEnvMode FromGLenum<TextureEnvMode>(GLenum from)
{
switch (from)
{
case GL_ADD:
return TextureEnvMode::Add;
case GL_BLEND:
return TextureEnvMode::Blend;
case GL_COMBINE:
return TextureEnvMode::Combine;
case GL_DECAL:
return TextureEnvMode::Decal;
case GL_MODULATE:
return TextureEnvMode::Modulate;
case GL_REPLACE:
return TextureEnvMode::Replace;
default:
return TextureEnvMode::InvalidEnum;
}
}
GLenum ToGLenum(TextureEnvMode from)
{
switch (from)
{
case TextureEnvMode::Add:
return GL_ADD;
case TextureEnvMode::Blend:
return GL_BLEND;
case TextureEnvMode::Combine:
return GL_COMBINE;
case TextureEnvMode::Decal:
return GL_DECAL;
case TextureEnvMode::Modulate:
return GL_MODULATE;
case TextureEnvMode::Replace:
return GL_REPLACE;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
TextureOp FromGLenum<TextureOp>(GLenum from)
{
switch (from)
{
case GL_ONE_MINUS_SRC_ALPHA:
return TextureOp::OneMinusSrcAlpha;
case GL_ONE_MINUS_SRC_COLOR:
return TextureOp::OneMinusSrcColor;
case GL_SRC_ALPHA:
return TextureOp::SrcAlpha;
case GL_SRC_COLOR:
return TextureOp::SrcColor;
default:
return TextureOp::InvalidEnum;
}
}
GLenum ToGLenum(TextureOp from)
{
switch (from)
{
case TextureOp::OneMinusSrcAlpha:
return GL_ONE_MINUS_SRC_ALPHA;
case TextureOp::OneMinusSrcColor:
return GL_ONE_MINUS_SRC_COLOR;
case TextureOp::SrcAlpha:
return GL_SRC_ALPHA;
case TextureOp::SrcColor:
return GL_SRC_COLOR;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
TextureSrc FromGLenum<TextureSrc>(GLenum from)
{
switch (from)
{
case GL_CONSTANT:
return TextureSrc::Constant;
case GL_PREVIOUS:
return TextureSrc::Previous;
case GL_PRIMARY_COLOR:
return TextureSrc::PrimaryColor;
case GL_TEXTURE:
return TextureSrc::Texture;
default:
return TextureSrc::InvalidEnum;
}
}
GLenum ToGLenum(TextureSrc from)
{
switch (from)
{
case TextureSrc::Constant:
return GL_CONSTANT;
case TextureSrc::Previous:
return GL_PREVIOUS;
case TextureSrc::PrimaryColor:
return GL_PRIMARY_COLOR;
case TextureSrc::Texture:
return GL_TEXTURE;
default:
UNREACHABLE();
return GL_NONE;
}
}
template <>
TextureTarget FromGLenum<TextureTarget>(GLenum from)
{
switch (from)
......@@ -287,4 +715,44 @@ GLenum ToGLenum(TextureType from)
}
}
template <>
VertexArrayType FromGLenum<VertexArrayType>(GLenum from)
{
switch (from)
{
case GL_COLOR_ARRAY:
return VertexArrayType::Color;
case GL_NORMAL_ARRAY:
return VertexArrayType::Normal;
case GL_POINT_SIZE_ARRAY_OES:
return VertexArrayType::PointSize;
case GL_TEXTURE_COORD_ARRAY:
return VertexArrayType::TextureCoord;
case GL_VERTEX_ARRAY:
return VertexArrayType::Vertex;
default:
return VertexArrayType::InvalidEnum;
}
}
GLenum ToGLenum(VertexArrayType from)
{
switch (from)
{
case VertexArrayType::Color:
return GL_COLOR_ARRAY;
case VertexArrayType::Normal:
return GL_NORMAL_ARRAY;
case VertexArrayType::PointSize:
return GL_POINT_SIZE_ARRAY_OES;
case VertexArrayType::TextureCoord:
return GL_TEXTURE_COORD_ARRAY;
case VertexArrayType::Vertex:
return GL_VERTEX_ARRAY;
default:
UNREACHABLE();
return GL_NONE;
}
}
} // namespace gl
......@@ -22,6 +22,25 @@ namespace gl
template <typename Enum>
Enum FromGLenum(GLenum from);
enum class AlphaTestFunc : uint8_t
{
AlwaysPass = 0,
Equal = 1,
Gequal = 2,
Greater = 3,
Lequal = 4,
Less = 5,
Never = 6,
NotEqual = 7,
InvalidEnum = 8,
EnumCount = 8,
};
template <>
AlphaTestFunc FromGLenum<AlphaTestFunc>(GLenum from);
GLenum ToGLenum(AlphaTestFunc from);
enum class BufferBinding : uint8_t
{
Array = 0,
......@@ -79,6 +98,154 @@ template <>
CullFaceMode FromGLenum<CullFaceMode>(GLenum from);
GLenum ToGLenum(CullFaceMode from);
enum class FogMode : uint8_t
{
Exp = 0,
Exp2 = 1,
Linear = 2,
InvalidEnum = 3,
EnumCount = 3,
};
template <>
FogMode FromGLenum<FogMode>(GLenum from);
GLenum ToGLenum(FogMode from);
enum class HintSetting : uint8_t
{
DontCare = 0,
Fastest = 1,
Nicest = 2,
InvalidEnum = 3,
EnumCount = 3,
};
template <>
HintSetting FromGLenum<HintSetting>(GLenum from);
GLenum ToGLenum(HintSetting from);
enum class LogicalOperation : uint8_t
{
And = 0,
AndInverted = 1,
AndReverse = 2,
Clear = 3,
Copy = 4,
CopyInverted = 5,
Equiv = 6,
Invert = 7,
Nand = 8,
Noop = 9,
Nor = 10,
Or = 11,
OrInverted = 12,
OrReverse = 13,
Set = 14,
Xor = 15,
InvalidEnum = 16,
EnumCount = 16,
};
template <>
LogicalOperation FromGLenum<LogicalOperation>(GLenum from);
GLenum ToGLenum(LogicalOperation from);
enum class MatrixType : uint8_t
{
Modelview = 0,
Projection = 1,
Texture = 2,
InvalidEnum = 3,
EnumCount = 3,
};
template <>
MatrixType FromGLenum<MatrixType>(GLenum from);
GLenum ToGLenum(MatrixType from);
enum class ShadingModel : uint8_t
{
Flat = 0,
Smooth = 1,
InvalidEnum = 2,
EnumCount = 2,
};
template <>
ShadingModel FromGLenum<ShadingModel>(GLenum from);
GLenum ToGLenum(ShadingModel from);
enum class TextureCombine : uint8_t
{
Add = 0,
AddSigned = 1,
Dot3Rgb = 2,
Dot3Rgba = 3,
Interpolate = 4,
Modulate = 5,
Replace = 6,
Subtract = 7,
InvalidEnum = 8,
EnumCount = 8,
};
template <>
TextureCombine FromGLenum<TextureCombine>(GLenum from);
GLenum ToGLenum(TextureCombine from);
enum class TextureEnvMode : uint8_t
{
Add = 0,
Blend = 1,
Combine = 2,
Decal = 3,
Modulate = 4,
Replace = 5,
InvalidEnum = 6,
EnumCount = 6,
};
template <>
TextureEnvMode FromGLenum<TextureEnvMode>(GLenum from);
GLenum ToGLenum(TextureEnvMode from);
enum class TextureOp : uint8_t
{
OneMinusSrcAlpha = 0,
OneMinusSrcColor = 1,
SrcAlpha = 2,
SrcColor = 3,
InvalidEnum = 4,
EnumCount = 4,
};
template <>
TextureOp FromGLenum<TextureOp>(GLenum from);
GLenum ToGLenum(TextureOp from);
enum class TextureSrc : uint8_t
{
Constant = 0,
Previous = 1,
PrimaryColor = 2,
Texture = 3,
InvalidEnum = 4,
EnumCount = 4,
};
template <>
TextureSrc FromGLenum<TextureSrc>(GLenum from);
GLenum ToGLenum(TextureSrc from);
enum class TextureTarget : uint8_t
{
_2D = 0,
......@@ -120,6 +287,22 @@ template <>
TextureType FromGLenum<TextureType>(GLenum from);
GLenum ToGLenum(TextureType from);
enum class VertexArrayType : uint8_t
{
Color = 0,
Normal = 1,
PointSize = 2,
TextureCoord = 3,
Vertex = 4,
InvalidEnum = 5,
EnumCount = 5,
};
template <>
VertexArrayType FromGLenum<VertexArrayType>(GLenum from);
GLenum ToGLenum(VertexArrayType from);
} // namespace gl
#endif // LIBANGLE_PACKEDGLENUMS_AUTOGEN_H_
......@@ -238,6 +238,13 @@ void State::initialize(const Context *context,
mRobustResourceInit = robustResourceInit;
mProgramBinaryCacheEnabled = programBinaryCacheEnabled;
// GLES1 emulation: Initialize state for GLES1 if version
// applies
if (clientVersion < Version(2, 0))
{
mGLES1State.initialize(context);
}
}
void State::reset(const Context *context)
......
......@@ -16,6 +16,7 @@
#include "common/angleutils.h"
#include "common/bitset_utils.h"
#include "libANGLE/Debug.h"
#include "libANGLE/GLES1State.h"
#include "libANGLE/Program.h"
#include "libANGLE/ProgramPipeline.h"
#include "libANGLE/RefCountObject.h"
......@@ -601,6 +602,10 @@ class State : public angle::ObserverInterface, angle::NonCopyable
// GL_ANGLE_program_cache_control
bool mProgramBinaryCacheEnabled;
// GLES1 emulation: state specific to GLES1
friend class GLES1State;
GLES1State mGLES1State;
DirtyBits mDirtyBits;
mutable DirtyObjects mDirtyObjects;
mutable AttributesMask mDirtyCurrentValues;
......
......@@ -9,7 +9,9 @@
#ifndef LIBANGLE_ANGLETYPES_H_
#define LIBANGLE_ANGLETYPES_H_
#include "common/Color.h"
#include "common/bitset_utils.h"
#include "common/vector_utils.h"
#include "libANGLE/Constants.h"
#include "libANGLE/Error.h"
#include "libANGLE/PackedGLEnums.h"
......@@ -75,12 +77,12 @@ bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *in
struct Offset
{
Offset() : x(0), y(0), z(0) {}
Offset(int x_in, int y_in, int z_in) : x(x_in), y(y_in), z(z_in) {}
int x;
int y;
int z;
Offset() : x(0), y(0), z(0) { }
Offset(int x_in, int y_in, int z_in) : x(x_in), y(y_in), z(z_in) { }
};
bool operator==(const Offset &a, const Offset &b);
......@@ -88,17 +90,17 @@ bool operator!=(const Offset &a, const Offset &b);
struct Extents
{
int width;
int height;
int depth;
Extents() : width(0), height(0), depth(0) { }
Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { }
Extents() : width(0), height(0), depth(0) {}
Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) {}
Extents(const Extents &other) = default;
Extents &operator=(const Extents &other) = default;
bool empty() const { return (width * height * depth) == 0; }
int width;
int height;
int depth;
};
bool operator==(const Extents &lhs, const Extents &rhs);
......@@ -106,18 +108,29 @@ bool operator!=(const Extents &lhs, const Extents &rhs);
struct Box
{
Box() : x(0), y(0), z(0), width(0), height(0), depth(0) {}
Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in)
: x(x_in), y(y_in), z(z_in), width(width_in), height(height_in), depth(depth_in)
{
}
Box(const Offset &offset, const Extents &size)
: x(offset.x),
y(offset.y),
z(offset.z),
width(size.width),
height(size.height),
depth(size.depth)
{
}
bool operator==(const Box &other) const;
bool operator!=(const Box &other) const;
int x;
int y;
int z;
int width;
int height;
int depth;
Box() : x(0), y(0), z(0), width(0), height(0), depth(0) { }
Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in) : x(x_in), y(y_in), z(z_in), width(width_in), height(height_in), depth(depth_in) { }
Box(const Offset &offset, const Extents &size) : x(offset.x), y(offset.y), z(offset.z), width(size.width), height(size.height), depth(size.depth) { }
bool operator==(const Box &other) const;
bool operator!=(const Box &other) const;
};
struct RasterizerState final
......@@ -336,12 +349,14 @@ namespace rx
#if __has_feature(cxx_rtti)
#define ANGLE_HAS_DYNAMIC_CAST 1
#endif
#elif !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) && (!defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || defined(__GXX_RTTI))
#elif !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) && \
(!defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || \
defined(__GXX_RTTI))
#define ANGLE_HAS_DYNAMIC_CAST 1
#endif
#ifdef ANGLE_HAS_DYNAMIC_CAST
#define ANGLE_HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast<type >(obj) != nullptr)
#define ANGLE_HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast<type>(obj) != nullptr)
#undef ANGLE_HAS_DYNAMIC_CAST
#else
#define ANGLE_HAS_DYNAMIC_TYPE(type, obj) (obj != nullptr)
......@@ -351,15 +366,15 @@ namespace rx
template <typename DestT, typename SrcT>
inline DestT *GetAs(SrcT *src)
{
ASSERT(ANGLE_HAS_DYNAMIC_TYPE(DestT*, src));
return static_cast<DestT*>(src);
ASSERT(ANGLE_HAS_DYNAMIC_TYPE(DestT *, src));
return static_cast<DestT *>(src);
}
template <typename DestT, typename SrcT>
inline const DestT *GetAs(const SrcT *src)
{
ASSERT(ANGLE_HAS_DYNAMIC_TYPE(const DestT*, src));
return static_cast<const DestT*>(src);
ASSERT(ANGLE_HAS_DYNAMIC_TYPE(const DestT *, src));
return static_cast<const DestT *>(src);
}
#undef ANGLE_HAS_DYNAMIC_TYPE
......@@ -501,4 +516,4 @@ class ContextState;
} // namespace gl
#endif // LIBANGLE_ANGLETYPES_H_
#endif // LIBANGLE_ANGLETYPES_H_
{
"AlphaTestFunc":
{
"Never": "GL_NEVER",
"AlwaysPass": "GL_ALWAYS",
"Less": "GL_LESS",
"Lequal": "GL_LEQUAL",
"Equal": "GL_EQUAL",
"Gequal": "GL_GEQUAL",
"Greater": "GL_GREATER",
"NotEqual": "GL_NOTEQUAL"
},
"BufferBinding":
{
"Array": "GL_ARRAY_BUFFER",
......@@ -32,6 +43,82 @@
"Front": "GL_FRONT",
"FrontAndBack": "GL_FRONT_AND_BACK"
},
"FogMode":
{
"Exp": "GL_EXP",
"Exp2": "GL_EXP2",
"Linear": "GL_LINEAR"
},
"HintSetting":
{
"DontCare" : "GL_DONT_CARE",
"Nicest" : "GL_NICEST",
"Fastest" : "GL_FASTEST"
},
"LogicalOperation":
{
"Clear" : "GL_CLEAR",
"And" : "GL_AND",
"AndReverse" : "GL_AND_REVERSE",
"Copy" : "GL_COPY",
"AndInverted" : "GL_AND_INVERTED",
"Noop" : "GL_NOOP",
"Xor" : "GL_XOR",
"Or" : "GL_OR",
"Nor" : "GL_NOR",
"Equiv" : "GL_EQUIV",
"Invert" : "GL_INVERT",
"OrReverse" : "GL_OR_REVERSE",
"CopyInverted" : "GL_COPY_INVERTED",
"OrInverted" : "GL_OR_INVERTED",
"Nand" : "GL_NAND",
"Set" : "GL_SET"
},
"MatrixType":
{
"Modelview" : "GL_MODELVIEW",
"Projection" : "GL_PROJECTION",
"Texture" : "GL_TEXTURE"
},
"ShadingModel":
{
"Flat" : "GL_FLAT",
"Smooth" : "GL_SMOOTH"
},
"TextureCombine":
{
"Replace" : "GL_REPLACE",
"Modulate" : "GL_MODULATE",
"Add" : "GL_ADD",
"AddSigned" : "GL_ADD_SIGNED",
"Interpolate" : "GL_INTERPOLATE",
"Subtract" : "GL_SUBTRACT",
"Dot3Rgb" : "GL_DOT3_RGB",
"Dot3Rgba" : "GL_DOT3_RGBA"
},
"TextureEnvMode":
{
"Replace" : "GL_REPLACE",
"Modulate" : "GL_MODULATE",
"Decal" : "GL_DECAL",
"Blend" : "GL_BLEND",
"Add" : "GL_ADD",
"Combine" : "GL_COMBINE"
},
"TextureOp":
{
"SrcColor" : "GL_SRC_COLOR",
"OneMinusSrcColor" : "GL_ONE_MINUS_SRC_COLOR",
"SrcAlpha" : "GL_SRC_ALPHA",
"OneMinusSrcAlpha" : "GL_ONE_MINUS_SRC_ALPHA"
},
"TextureSrc":
{
"Texture" : "GL_TEXTURE",
"Constant" : "GL_CONSTANT",
"PrimaryColor" : "GL_PRIMARY_COLOR",
"Previous" : "GL_PREVIOUS"
},
"TextureType":
[
{"name": "_2D", "gl_name": "GL_TEXTURE_2D", "value": 0},
......@@ -56,5 +143,13 @@
{"name": "CubeMapNegativeY", "gl_name": "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y", "value": 9},
{"name": "CubeMapPositiveZ", "gl_name": "GL_TEXTURE_CUBE_MAP_POSITIVE_Z", "value": 10},
{"name": "CubeMapNegativeZ", "gl_name": "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z", "value": 11}
]
],
"VertexArrayType":
{
"Vertex" : "GL_VERTEX_ARRAY",
"Normal" : "GL_NORMAL_ARRAY",
"Color" : "GL_COLOR_ARRAY",
"PointSize" : "GL_POINT_SIZE_ARRAY_OES",
"TextureCoord" : "GL_TEXTURE_COORD_ARRAY"
}
}
......@@ -165,6 +165,7 @@
'libANGLE/Framebuffer.h',
'libANGLE/FramebufferAttachment.cpp',
'libANGLE/FramebufferAttachment.h',
'libANGLE/GLES1State.cpp',
'libANGLE/HandleAllocator.cpp',
'libANGLE/HandleAllocator.h',
'libANGLE/HandleRangeAllocator.h',
......
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