Commit 45b5a875 by Lingfeng Yang Committed by Commit Bot

GLES1: Texture environment API

BUG=angleproject:2306 Change-Id: Ibb168d5c9f7aa96a48c96ffbe96ecead2276975e Reviewed-on: https://chromium-review.googlesource.com/1092101 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c950a572
...@@ -840,6 +840,30 @@ TextureEnvParameter FromGLenum<TextureEnvParameter>(GLenum from) ...@@ -840,6 +840,30 @@ TextureEnvParameter FromGLenum<TextureEnvParameter>(GLenum from)
return TextureEnvParameter::RgbScale; return TextureEnvParameter::RgbScale;
case GL_ALPHA_SCALE: case GL_ALPHA_SCALE:
return TextureEnvParameter::AlphaScale; return TextureEnvParameter::AlphaScale;
case GL_SRC0_RGB:
return TextureEnvParameter::Src0Rgb;
case GL_SRC1_RGB:
return TextureEnvParameter::Src1Rgb;
case GL_SRC2_RGB:
return TextureEnvParameter::Src2Rgb;
case GL_SRC0_ALPHA:
return TextureEnvParameter::Src0Alpha;
case GL_SRC1_ALPHA:
return TextureEnvParameter::Src1Alpha;
case GL_SRC2_ALPHA:
return TextureEnvParameter::Src2Alpha;
case GL_OPERAND0_RGB:
return TextureEnvParameter::Op0Rgb;
case GL_OPERAND1_RGB:
return TextureEnvParameter::Op1Rgb;
case GL_OPERAND2_RGB:
return TextureEnvParameter::Op2Rgb;
case GL_OPERAND0_ALPHA:
return TextureEnvParameter::Op0Alpha;
case GL_OPERAND1_ALPHA:
return TextureEnvParameter::Op1Alpha;
case GL_OPERAND2_ALPHA:
return TextureEnvParameter::Op2Alpha;
default: default:
return TextureEnvParameter::InvalidEnum; return TextureEnvParameter::InvalidEnum;
} }
...@@ -861,6 +885,30 @@ GLenum ToGLenum(TextureEnvParameter from) ...@@ -861,6 +885,30 @@ GLenum ToGLenum(TextureEnvParameter from)
return GL_RGB_SCALE; return GL_RGB_SCALE;
case TextureEnvParameter::AlphaScale: case TextureEnvParameter::AlphaScale:
return GL_ALPHA_SCALE; return GL_ALPHA_SCALE;
case TextureEnvParameter::Src0Rgb:
return GL_SRC0_RGB;
case TextureEnvParameter::Src1Rgb:
return GL_SRC1_RGB;
case TextureEnvParameter::Src2Rgb:
return GL_SRC2_RGB;
case TextureEnvParameter::Src0Alpha:
return GL_SRC0_ALPHA;
case TextureEnvParameter::Src1Alpha:
return GL_SRC1_ALPHA;
case TextureEnvParameter::Src2Alpha:
return GL_SRC2_ALPHA;
case TextureEnvParameter::Op0Rgb:
return GL_OPERAND0_RGB;
case TextureEnvParameter::Op1Rgb:
return GL_OPERAND1_RGB;
case TextureEnvParameter::Op2Rgb:
return GL_OPERAND2_RGB;
case TextureEnvParameter::Op0Alpha:
return GL_OPERAND0_ALPHA;
case TextureEnvParameter::Op1Alpha:
return GL_OPERAND1_ALPHA;
case TextureEnvParameter::Op2Alpha:
return GL_OPERAND2_ALPHA;
default: default:
UNREACHABLE(); UNREACHABLE();
return 0; return 0;
......
...@@ -336,9 +336,21 @@ enum class TextureEnvParameter : uint8_t ...@@ -336,9 +336,21 @@ enum class TextureEnvParameter : uint8_t
CombineAlpha = 3, CombineAlpha = 3,
RgbScale = 4, RgbScale = 4,
AlphaScale = 5, AlphaScale = 5,
Src0Rgb = 6,
InvalidEnum = 6, Src1Rgb = 7,
EnumCount = 6, Src2Rgb = 8,
Src0Alpha = 9,
Src1Alpha = 10,
Src2Alpha = 11,
Op0Rgb = 12,
Op1Rgb = 13,
Op2Rgb = 14,
Op0Alpha = 15,
Op1Alpha = 16,
Op2Alpha = 17,
InvalidEnum = 18,
EnumCount = 18,
}; };
template <> template <>
......
...@@ -141,7 +141,19 @@ ...@@ -141,7 +141,19 @@
"CombineRgb": "GL_COMBINE_RGB", "CombineRgb": "GL_COMBINE_RGB",
"CombineAlpha": "GL_COMBINE_ALPHA", "CombineAlpha": "GL_COMBINE_ALPHA",
"RgbScale": "GL_RGB_SCALE", "RgbScale": "GL_RGB_SCALE",
"AlphaScale": "GL_ALPHA_SCALE" "AlphaScale": "GL_ALPHA_SCALE",
"Src0Rgb": "GL_SRC0_RGB",
"Src1Rgb": "GL_SRC1_RGB",
"Src2Rgb": "GL_SRC2_RGB",
"Src0Alpha": "GL_SRC0_ALPHA",
"Src1Alpha": "GL_SRC1_ALPHA",
"Src2Alpha": "GL_SRC2_ALPHA",
"Op0Rgb": "GL_OPERAND0_RGB",
"Op1Rgb": "GL_OPERAND1_RGB",
"Op2Rgb": "GL_OPERAND2_RGB",
"Op0Alpha": "GL_OPERAND0_ALPHA",
"Op1Alpha": "GL_OPERAND1_ALPHA",
"Op2Alpha": "GL_OPERAND2_ALPHA"
}, },
"TextureOp": "TextureOp":
{ {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/GLES1Renderer.h" #include "libANGLE/GLES1Renderer.h"
#include "libANGLE/queryconversions.h"
#include "libANGLE/queryutils.h" #include "libANGLE/queryutils.h"
namespace namespace
...@@ -130,7 +131,7 @@ void Context::fogx(GLenum pname, GLfixed param) ...@@ -130,7 +131,7 @@ void Context::fogx(GLenum pname, GLfixed param)
{ {
if (GetFogParameterCount(pname) == 1) if (GetFogParameterCount(pname) == 1)
{ {
GLfloat paramf = pname == GL_FOG_MODE ? FixedToEnum(param) : FixedToFloat(param); GLfloat paramf = pname == GL_FOG_MODE ? ConvertToGLenum(param) : FixedToFloat(param);
fogf(pname, paramf); fogf(pname, paramf);
} }
else else
...@@ -148,7 +149,8 @@ void Context::fogxv(GLenum pname, const GLfixed *params) ...@@ -148,7 +149,8 @@ void Context::fogxv(GLenum pname, const GLfixed *params)
GLfloat paramsf[4]; GLfloat paramsf[4];
for (int i = 0; i < paramCount; i++) for (int i = 0; i < paramCount; i++)
{ {
paramsf[i] = pname == GL_FOG_MODE ? FixedToEnum(params[i]) : FixedToFloat(params[i]); paramsf[i] =
pname == GL_FOG_MODE ? ConvertToGLenum(params[i]) : FixedToFloat(params[i]);
} }
fogfv(pname, paramsf); fogfv(pname, paramsf);
} }
...@@ -224,19 +226,23 @@ void Context::getMaterialxv(GLenum face, MaterialParameter pname, GLfixed *param ...@@ -224,19 +226,23 @@ void Context::getMaterialxv(GLenum face, MaterialParameter pname, GLfixed *param
} }
} }
void Context::getTexEnvfv(TextureEnvTarget env, TextureEnvParameter pname, GLfloat *params) void Context::getTexEnvfv(TextureEnvTarget target, TextureEnvParameter pname, GLfloat *params)
{ {
UNIMPLEMENTED(); GetTextureEnv(mGLState.getActiveSampler(), &mGLState.gles1(), target, pname, params);
} }
void Context::getTexEnviv(TextureEnvTarget env, TextureEnvParameter pname, GLint *params) void Context::getTexEnviv(TextureEnvTarget target, TextureEnvParameter pname, GLint *params)
{ {
UNIMPLEMENTED(); GLfloat paramsf[4];
GetTextureEnv(mGLState.getActiveSampler(), &mGLState.gles1(), target, pname, paramsf);
ConvertTextureEnvToInt(pname, paramsf, params);
} }
void Context::getTexEnvxv(TextureEnvTarget target, TextureEnvParameter pname, GLfixed *params) void Context::getTexEnvxv(TextureEnvTarget target, TextureEnvParameter pname, GLfixed *params)
{ {
UNIMPLEMENTED(); GLfloat paramsf[4];
GetTextureEnv(mGLState.getActiveSampler(), &mGLState.gles1(), target, pname, paramsf);
ConvertTextureEnvToFixed(pname, paramsf, params);
} }
void Context::getTexParameterxv(TextureType target, GLenum pname, GLfixed *params) void Context::getTexParameterxv(TextureType target, GLenum pname, GLfixed *params)
...@@ -498,32 +504,40 @@ void Context::texCoordPointer(GLint size, GLenum type, GLsizei stride, const voi ...@@ -498,32 +504,40 @@ void Context::texCoordPointer(GLint size, GLenum type, GLsizei stride, const voi
void Context::texEnvf(TextureEnvTarget target, TextureEnvParameter pname, GLfloat param) void Context::texEnvf(TextureEnvTarget target, TextureEnvParameter pname, GLfloat param)
{ {
UNIMPLEMENTED(); SetTextureEnv(mGLState.getActiveSampler(), &mGLState.gles1(), target, pname, &param);
} }
void Context::texEnvfv(TextureEnvTarget target, TextureEnvParameter pname, const GLfloat *params) void Context::texEnvfv(TextureEnvTarget target, TextureEnvParameter pname, const GLfloat *params)
{ {
UNIMPLEMENTED(); SetTextureEnv(mGLState.getActiveSampler(), &mGLState.gles1(), target, pname, params);
} }
void Context::texEnvi(TextureEnvTarget target, TextureEnvParameter pname, GLint param) void Context::texEnvi(TextureEnvTarget target, TextureEnvParameter pname, GLint param)
{ {
UNIMPLEMENTED(); GLfloat paramsf[4] = {};
ConvertTextureEnvFromInt(pname, &param, paramsf);
SetTextureEnv(mGLState.getActiveSampler(), &mGLState.gles1(), target, pname, paramsf);
} }
void Context::texEnviv(TextureEnvTarget target, TextureEnvParameter pname, const GLint *params) void Context::texEnviv(TextureEnvTarget target, TextureEnvParameter pname, const GLint *params)
{ {
UNIMPLEMENTED(); GLfloat paramsf[4] = {};
ConvertTextureEnvFromInt(pname, params, paramsf);
SetTextureEnv(mGLState.getActiveSampler(), &mGLState.gles1(), target, pname, paramsf);
} }
void Context::texEnvx(TextureEnvTarget target, TextureEnvParameter pname, GLfixed param) void Context::texEnvx(TextureEnvTarget target, TextureEnvParameter pname, GLfixed param)
{ {
UNIMPLEMENTED(); GLfloat paramsf[4] = {};
ConvertTextureEnvFromFixed(pname, &param, paramsf);
SetTextureEnv(mGLState.getActiveSampler(), &mGLState.gles1(), target, pname, paramsf);
} }
void Context::texEnvxv(TextureEnvTarget target, TextureEnvParameter pname, const GLfixed *params) void Context::texEnvxv(TextureEnvTarget target, TextureEnvParameter pname, const GLfixed *params)
{ {
UNIMPLEMENTED(); GLfloat paramsf[4] = {};
ConvertTextureEnvFromFixed(pname, params, paramsf);
SetTextureEnv(mGLState.getActiveSampler(), &mGLState.gles1(), target, pname, paramsf);
} }
void Context::texParameterx(TextureType target, GLenum pname, GLfixed param) void Context::texParameterx(TextureType target, GLenum pname, GLfixed param)
......
...@@ -135,6 +135,13 @@ ERRMSG(InvalidShadingModel, "Invalid shading model."); ...@@ -135,6 +135,13 @@ ERRMSG(InvalidShadingModel, "Invalid shading model.");
ERRMSG(InvalidStencil, "Invalid stencil."); ERRMSG(InvalidStencil, "Invalid stencil.");
ERRMSG(InvalidStencilBitMask, "Invalid stencil bit mask."); ERRMSG(InvalidStencilBitMask, "Invalid stencil bit mask.");
ERRMSG(InvalidTarget, "Invalid target."); ERRMSG(InvalidTarget, "Invalid target.");
ERRMSG(InvalidTextureCombine, "Invalid texture combine mode.");
ERRMSG(InvalidTextureCombineSrc, "Invalid texture combine source.");
ERRMSG(InvalidTextureCombineOp, "Invalid texture combine operand.");
ERRMSG(InvalidTextureEnvMode, "Invalid texture environment mode.");
ERRMSG(InvalidTextureEnvParameter, "Invalid texture environment parameter.");
ERRMSG(InvalidTextureEnvScale, "Invalid texture environment scale.");
ERRMSG(InvalidTextureEnvTarget, "Invalid texture environment target.");
ERRMSG(InvalidTextureFilterParam, "Texture filter not recognized."); ERRMSG(InvalidTextureFilterParam, "Texture filter not recognized.");
ERRMSG(InvalidTextureName, "Not a valid texture object name."); ERRMSG(InvalidTextureName, "Not a valid texture object name.");
ERRMSG(InvalidTextureRange, "Cannot be less than 0 or greater than maximum number of textures."); ERRMSG(InvalidTextureRange, "Cannot be less than 0 or greater than maximum number of textures.");
......
...@@ -394,4 +394,16 @@ const FogParameters &GLES1State::fogParameters() const ...@@ -394,4 +394,16 @@ const FogParameters &GLES1State::fogParameters() const
return mFog; return mFog;
} }
TextureEnvironmentParameters &GLES1State::textureEnvironment(unsigned int unit)
{
assert(unit < mTextureEnvironments.size());
return mTextureEnvironments[unit];
}
const TextureEnvironmentParameters &GLES1State::textureEnvironment(unsigned int unit) const
{
assert(unit < mTextureEnvironments.size());
return mTextureEnvironments[unit];
}
} // namespace gl } // namespace gl
...@@ -76,29 +76,29 @@ struct FogParameters ...@@ -76,29 +76,29 @@ struct FogParameters
struct TextureEnvironmentParameters struct TextureEnvironmentParameters
{ {
TextureEnvMode envMode = TextureEnvMode::Modulate; TextureEnvMode mode = TextureEnvMode::Modulate;
TextureCombine combineRgb = TextureCombine::Modulate; TextureCombine combineRgb = TextureCombine::Modulate;
TextureCombine combineAlpha = TextureCombine::Modulate; TextureCombine combineAlpha = TextureCombine::Modulate;
TextureSrc src0rgb = TextureSrc::Texture; TextureSrc src0Rgb = TextureSrc::Texture;
TextureSrc src0alpha = TextureSrc::Texture; TextureSrc src0Alpha = TextureSrc::Texture;
TextureSrc src1rgb = TextureSrc::Previous; TextureSrc src1Rgb = TextureSrc::Previous;
TextureSrc src1alpha = TextureSrc::Previous; TextureSrc src1Alpha = TextureSrc::Previous;
TextureSrc src2rgb = TextureSrc::Constant; TextureSrc src2Rgb = TextureSrc::Constant;
TextureSrc src2alpha = TextureSrc::Constant; TextureSrc src2Alpha = TextureSrc::Constant;
TextureOp op0rgb = TextureOp::SrcColor; TextureOp op0Rgb = TextureOp::SrcColor;
TextureOp op0alpha = TextureOp::SrcAlpha; TextureOp op0Alpha = TextureOp::SrcAlpha;
TextureOp op1rgb = TextureOp::SrcColor; TextureOp op1Rgb = TextureOp::SrcColor;
TextureOp op1alpha = TextureOp::SrcAlpha; TextureOp op1Alpha = TextureOp::SrcAlpha;
TextureOp op2rgb = TextureOp::SrcAlpha; TextureOp op2Rgb = TextureOp::SrcAlpha;
TextureOp op2alpha = TextureOp::SrcAlpha; TextureOp op2Alpha = TextureOp::SrcAlpha;
ColorF envColor = {0.0f, 0.0f, 0.0f, 0.0f}; ColorF color = {0.0f, 0.0f, 0.0f, 0.0f};
GLfloat rgbScale = 1.0f; GLfloat rgbScale = 1.0f;
GLfloat alphaScale = 1.0f; GLfloat alphaScale = 1.0f;
...@@ -183,6 +183,9 @@ class GLES1State final : angle::NonCopyable ...@@ -183,6 +183,9 @@ class GLES1State final : angle::NonCopyable
FogParameters &fogParameters(); FogParameters &fogParameters();
const FogParameters &fogParameters() const; const FogParameters &fogParameters() const;
TextureEnvironmentParameters &textureEnvironment(unsigned int unit);
const TextureEnvironmentParameters &textureEnvironment(unsigned int unit) const;
private: private:
friend class State; friend class State;
friend class GLES1Renderer; friend class GLES1Renderer;
......
...@@ -81,6 +81,24 @@ GLenum ConvertToGLenum(ParamType param) ...@@ -81,6 +81,24 @@ GLenum ConvertToGLenum(ParamType param)
return ConvertToGLenum(GL_NONE, param); return ConvertToGLenum(GL_NONE, param);
} }
template <typename OutType>
OutType ConvertGLenum(GLenum param)
{
return static_cast<OutType>(param);
}
template <typename InType, typename OutType>
void ConvertGLenumValue(InType param, OutType *out)
{
*out = ConvertGLenum<OutType>(static_cast<GLenum>(param));
}
template <typename PackedEnumType, typename OutType>
void ConvertPackedEnum(PackedEnumType param, OutType *out)
{
*out = static_cast<OutType>(ToGLenum(param));
}
template <typename ParamType> template <typename ParamType>
GLint ConvertToGLint(ParamType param) GLint ConvertToGLint(ParamType param)
{ {
...@@ -101,8 +119,11 @@ GLboolean ConvertToGLBoolean(ParamType param) ...@@ -101,8 +119,11 @@ GLboolean ConvertToGLBoolean(ParamType param)
// The GL state query API types are: bool, int, uint, float, int64, uint64 // The GL state query API types are: bool, int, uint, float, int64, uint64
template <typename QueryT> template <typename QueryT>
void CastStateValues(Context *context, GLenum nativeType, GLenum pname, void CastStateValues(Context *context,
unsigned int numParams, QueryT *outParams); GLenum nativeType,
GLenum pname,
unsigned int numParams,
QueryT *outParams);
// The GL state query API types are: bool, int, uint, float, int64, uint64 // The GL state query API types are: bool, int, uint, float, int64, uint64
template <typename QueryT> template <typename QueryT>
......
...@@ -179,7 +179,23 @@ void SetFogParameters(GLES1State *state, GLenum pname, const GLfloat *params); ...@@ -179,7 +179,23 @@ void SetFogParameters(GLES1State *state, GLenum pname, const GLfloat *params);
void GetFogParameters(const GLES1State *state, GLenum pname, GLfloat *params); void GetFogParameters(const GLES1State *state, GLenum pname, GLfloat *params);
unsigned int GetFogParameterCount(GLenum pname); unsigned int GetFogParameterCount(GLenum pname);
GLenum FixedToEnum(GLfixed val); unsigned int GetTextureEnvParameterCount(TextureEnvParameter pname);
void ConvertTextureEnvFromInt(TextureEnvParameter pname, const GLint *input, GLfloat *output);
void ConvertTextureEnvFromFixed(TextureEnvParameter pname, const GLfixed *input, GLfloat *output);
void ConvertTextureEnvToInt(TextureEnvParameter pname, const GLfloat *input, GLint *output);
void ConvertTextureEnvToFixed(TextureEnvParameter pname, const GLfloat *input, GLfixed *output);
void SetTextureEnv(unsigned int unit,
GLES1State *state,
TextureEnvTarget target,
TextureEnvParameter pname,
const GLfloat *params);
void GetTextureEnv(unsigned int unit,
const GLES1State *state,
TextureEnvTarget target,
TextureEnvParameter pname,
GLfloat *params);
} // namespace gl } // namespace gl
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/ErrorStrings.h" #include "libANGLE/ErrorStrings.h"
#include "libANGLE/GLES1State.h" #include "libANGLE/GLES1State.h"
#include "libANGLE/queryconversions.h"
#include "libANGLE/queryutils.h" #include "libANGLE/queryutils.h"
#include "libANGLE/validationES.h" #include "libANGLE/validationES.h"
...@@ -368,6 +369,172 @@ bool ValidateFogCommon(Context *context, GLenum pname, const GLfloat *params) ...@@ -368,6 +369,172 @@ bool ValidateFogCommon(Context *context, GLenum pname, const GLfloat *params)
return true; return true;
} }
bool ValidateTexEnvCommon(Context *context,
TextureEnvTarget target,
TextureEnvParameter pname,
const GLfloat *params)
{
ANGLE_VALIDATE_IS_GLES1(context);
if (target != TextureEnvTarget::Env)
{
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureEnvTarget);
return false;
}
switch (pname)
{
case TextureEnvParameter::Mode:
{
TextureEnvMode mode = FromGLenum<TextureEnvMode>(ConvertToGLenum(params[0]));
switch (mode)
{
case TextureEnvMode::Add:
case TextureEnvMode::Blend:
case TextureEnvMode::Combine:
case TextureEnvMode::Decal:
case TextureEnvMode::Modulate:
case TextureEnvMode::Replace:
break;
default:
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureEnvMode);
return false;
}
break;
}
case TextureEnvParameter::CombineRgb:
case TextureEnvParameter::CombineAlpha:
{
TextureCombine combine = FromGLenum<TextureCombine>(ConvertToGLenum(params[0]));
switch (combine)
{
case TextureCombine::Add:
case TextureCombine::AddSigned:
case TextureCombine::Interpolate:
case TextureCombine::Modulate:
case TextureCombine::Replace:
case TextureCombine::Subtract:
break;
case TextureCombine::Dot3Rgb:
case TextureCombine::Dot3Rgba:
if (pname == TextureEnvParameter::CombineAlpha)
{
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureCombine);
return false;
}
break;
default:
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureCombine);
return false;
}
break;
}
case TextureEnvParameter::Src0Rgb:
case TextureEnvParameter::Src1Rgb:
case TextureEnvParameter::Src2Rgb:
case TextureEnvParameter::Src0Alpha:
case TextureEnvParameter::Src1Alpha:
case TextureEnvParameter::Src2Alpha:
{
TextureSrc combine = FromGLenum<TextureSrc>(ConvertToGLenum(params[0]));
switch (combine)
{
case TextureSrc::Constant:
case TextureSrc::Previous:
case TextureSrc::PrimaryColor:
case TextureSrc::Texture:
break;
default:
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureCombineSrc);
return false;
}
break;
}
case TextureEnvParameter::Op0Rgb:
case TextureEnvParameter::Op1Rgb:
case TextureEnvParameter::Op2Rgb:
case TextureEnvParameter::Op0Alpha:
case TextureEnvParameter::Op1Alpha:
case TextureEnvParameter::Op2Alpha:
{
TextureOp operand = FromGLenum<TextureOp>(ConvertToGLenum(params[0]));
switch (operand)
{
case TextureOp::SrcAlpha:
case TextureOp::OneMinusSrcAlpha:
break;
case TextureOp::SrcColor:
case TextureOp::OneMinusSrcColor:
if (pname == TextureEnvParameter::Op0Alpha ||
pname == TextureEnvParameter::Op1Alpha ||
pname == TextureEnvParameter::Op2Alpha)
{
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureCombine);
return false;
}
break;
default:
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureCombineOp);
return false;
}
break;
}
case TextureEnvParameter::RgbScale:
case TextureEnvParameter::AlphaScale:
if (params[0] != 1.0f && params[0] != 2.0f && params[0] != 4.0f)
{
ANGLE_VALIDATION_ERR(context, InvalidValue(), InvalidTextureEnvScale);
return false;
}
break;
case TextureEnvParameter::Color:
break;
default:
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidTextureEnvParameter);
return false;
}
return true;
}
bool ValidateGetTexEnvCommon(Context *context, TextureEnvTarget target, TextureEnvParameter pname)
{
GLfloat dummy[4] = {};
switch (pname)
{
case TextureEnvParameter::Mode:
ConvertPackedEnum(TextureEnvMode::Add, dummy);
break;
case TextureEnvParameter::CombineRgb:
case TextureEnvParameter::CombineAlpha:
ConvertPackedEnum(TextureCombine::Add, dummy);
break;
case TextureEnvParameter::Src0Rgb:
case TextureEnvParameter::Src1Rgb:
case TextureEnvParameter::Src2Rgb:
case TextureEnvParameter::Src0Alpha:
case TextureEnvParameter::Src1Alpha:
case TextureEnvParameter::Src2Alpha:
ConvertPackedEnum(TextureSrc::Constant, dummy);
break;
case TextureEnvParameter::Op0Rgb:
case TextureEnvParameter::Op1Rgb:
case TextureEnvParameter::Op2Rgb:
case TextureEnvParameter::Op0Alpha:
case TextureEnvParameter::Op1Alpha:
case TextureEnvParameter::Op2Alpha:
ConvertPackedEnum(TextureOp::SrcAlpha, dummy);
break;
case TextureEnvParameter::RgbScale:
case TextureEnvParameter::AlphaScale:
dummy[0] = 1.0f;
break;
default:
break;
}
return ValidateTexEnvCommon(context, target, pname, dummy);
}
} // namespace gl } // namespace gl
namespace gl namespace gl
...@@ -592,8 +759,7 @@ bool ValidateGetTexEnvfv(Context *context, ...@@ -592,8 +759,7 @@ bool ValidateGetTexEnvfv(Context *context,
TextureEnvParameter pname, TextureEnvParameter pname,
GLfloat *params) GLfloat *params)
{ {
UNIMPLEMENTED(); return ValidateGetTexEnvCommon(context, target, pname);
return true;
} }
bool ValidateGetTexEnviv(Context *context, bool ValidateGetTexEnviv(Context *context,
...@@ -601,8 +767,7 @@ bool ValidateGetTexEnviv(Context *context, ...@@ -601,8 +767,7 @@ bool ValidateGetTexEnviv(Context *context,
TextureEnvParameter pname, TextureEnvParameter pname,
GLint *params) GLint *params)
{ {
UNIMPLEMENTED(); return ValidateGetTexEnvCommon(context, target, pname);
return true;
} }
bool ValidateGetTexEnvxv(Context *context, bool ValidateGetTexEnvxv(Context *context,
...@@ -610,8 +775,7 @@ bool ValidateGetTexEnvxv(Context *context, ...@@ -610,8 +775,7 @@ bool ValidateGetTexEnvxv(Context *context,
TextureEnvParameter pname, TextureEnvParameter pname,
GLfixed *params) GLfixed *params)
{ {
UNIMPLEMENTED(); return ValidateGetTexEnvCommon(context, target, pname);
return true;
} }
bool ValidateGetTexParameterxv(Context *context, TextureType target, GLenum pname, GLfixed *params) bool ValidateGetTexParameterxv(Context *context, TextureType target, GLenum pname, GLfixed *params)
...@@ -953,8 +1117,7 @@ bool ValidateTexEnvf(Context *context, ...@@ -953,8 +1117,7 @@ bool ValidateTexEnvf(Context *context,
TextureEnvParameter pname, TextureEnvParameter pname,
GLfloat param) GLfloat param)
{ {
UNIMPLEMENTED(); return ValidateTexEnvCommon(context, target, pname, &param);
return true;
} }
bool ValidateTexEnvfv(Context *context, bool ValidateTexEnvfv(Context *context,
...@@ -962,8 +1125,7 @@ bool ValidateTexEnvfv(Context *context, ...@@ -962,8 +1125,7 @@ bool ValidateTexEnvfv(Context *context,
TextureEnvParameter pname, TextureEnvParameter pname,
const GLfloat *params) const GLfloat *params)
{ {
UNIMPLEMENTED(); return ValidateTexEnvCommon(context, target, pname, params);
return true;
} }
bool ValidateTexEnvi(Context *context, bool ValidateTexEnvi(Context *context,
...@@ -971,8 +1133,8 @@ bool ValidateTexEnvi(Context *context, ...@@ -971,8 +1133,8 @@ bool ValidateTexEnvi(Context *context,
TextureEnvParameter pname, TextureEnvParameter pname,
GLint param) GLint param)
{ {
UNIMPLEMENTED(); GLfloat paramf = static_cast<GLfloat>(param);
return true; return ValidateTexEnvCommon(context, target, pname, &paramf);
} }
bool ValidateTexEnviv(Context *context, bool ValidateTexEnviv(Context *context,
...@@ -980,8 +1142,12 @@ bool ValidateTexEnviv(Context *context, ...@@ -980,8 +1142,12 @@ bool ValidateTexEnviv(Context *context,
TextureEnvParameter pname, TextureEnvParameter pname,
const GLint *params) const GLint *params)
{ {
UNIMPLEMENTED(); GLfloat paramsf[4];
return true; for (unsigned int i = 0; i < GetTextureEnvParameterCount(pname); i++)
{
paramsf[i] = static_cast<GLfloat>(params[i]);
}
return ValidateTexEnvCommon(context, target, pname, paramsf);
} }
bool ValidateTexEnvx(Context *context, bool ValidateTexEnvx(Context *context,
...@@ -989,8 +1155,8 @@ bool ValidateTexEnvx(Context *context, ...@@ -989,8 +1155,8 @@ bool ValidateTexEnvx(Context *context,
TextureEnvParameter pname, TextureEnvParameter pname,
GLfixed param) GLfixed param)
{ {
UNIMPLEMENTED(); GLfloat paramf = static_cast<GLfloat>(param);
return true; return ValidateTexEnvCommon(context, target, pname, &paramf);
} }
bool ValidateTexEnvxv(Context *context, bool ValidateTexEnvxv(Context *context,
...@@ -998,8 +1164,12 @@ bool ValidateTexEnvxv(Context *context, ...@@ -998,8 +1164,12 @@ bool ValidateTexEnvxv(Context *context,
TextureEnvParameter pname, TextureEnvParameter pname,
const GLfixed *params) const GLfixed *params)
{ {
UNIMPLEMENTED(); GLfloat paramsf[4];
return true; for (unsigned int i = 0; i < GetTextureEnvParameterCount(pname); i++)
{
paramsf[i] = static_cast<GLfloat>(params[i]);
}
return ValidateTexEnvCommon(context, target, pname, paramsf);
} }
bool ValidateTexParameterx(Context *context, TextureType target, GLenum pname, GLfixed param) bool ValidateTexParameterx(Context *context, TextureType target, GLenum pname, GLfixed param)
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
'<(angle_path)/src/tests/gl_tests/gles1/MatrixStackTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/MatrixStackTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/LightsTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/LightsTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/ShadeModelTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/ShadeModelTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/TextureEnvTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/TextureTargetEnableTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/TextureTargetEnableTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/VertexPointerTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/VertexPointerTest.cpp',
'<(angle_path)/src/tests/gl_tests/GLSLTest.cpp', '<(angle_path)/src/tests/gl_tests/GLSLTest.cpp',
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
// TODO(jmadill): Rework this if Chromium decides to ban <random> // TODO(jmadill): Rework this if Chromium decides to ban <random>
#include <random> #include <random>
#include <vector>
#include <export.h> #include <export.h>
...@@ -38,6 +39,18 @@ class ANGLE_EXPORT RNG ...@@ -38,6 +39,18 @@ class ANGLE_EXPORT RNG
float randomFloatNonnegative(); float randomFloatNonnegative();
float randomNegativeOneToOne(); float randomNegativeOneToOne();
template <class T>
T &randomSelect(std::vector<T> &elements)
{
return elements[randomIntBetween(0, elements.size() - 1)];
}
template <class T>
const T &randomSelect(const std::vector<T> &elements)
{
return elements.at(randomIntBetween(0, elements.size() - 1));
}
private: private:
std::default_random_engine mGenerator; std::default_random_engine mGenerator;
}; };
......
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