Commit 96310cda by Lingfeng Yang Committed by Commit Bot

GLES1: glClientActiveTexture

+ adds query for GL_MAX_TEXTURE_UNITS BUG=angleproject:2306 Change-Id: Ie89fa6a067551170856bf0f7e6d7b4452b3da132 Reviewed-on: https://chromium-review.googlesource.com/984894 Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent a3b220f3
...@@ -1602,6 +1602,10 @@ void Context::getIntegervImpl(GLenum pname, GLint *params) ...@@ -1602,6 +1602,10 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT: case GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT:
*params = mCaps.maxGeometryShaderStorageBlocks; *params = mCaps.maxGeometryShaderStorageBlocks;
break; break;
// GLES1 emulation: Caps queries
case GL_MAX_TEXTURE_UNITS:
*params = mCaps.maxMultitextureUnits;
break;
default: default:
handleError(mGLState.getIntegerv(this, pname, params)); handleError(mGLState.getIntegerv(this, pname, params));
break; break;
...@@ -6385,6 +6389,14 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu ...@@ -6385,6 +6389,14 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_FLOAT; *type = GL_FLOAT;
*numParams = 1; *numParams = 1;
return true; return true;
case GL_MAX_TEXTURE_UNITS:
*type = GL_INT;
*numParams = 1;
return true;
case GL_CLIENT_ACTIVE_TEXTURE:
*type = GL_INT;
*numParams = 1;
return true;
} }
} }
......
...@@ -36,7 +36,7 @@ void Context::clearDepthx(GLfixed depth) ...@@ -36,7 +36,7 @@ void Context::clearDepthx(GLfixed depth)
void Context::clientActiveTexture(GLenum texture) void Context::clientActiveTexture(GLenum texture)
{ {
UNIMPLEMENTED(); mGLState.gles1().setClientTextureUnit(texture - GL_TEXTURE0);
} }
void Context::clipPlanef(GLenum p, const GLfloat *eqn) void Context::clipPlanef(GLenum p, const GLfloat *eqn)
......
...@@ -64,6 +64,8 @@ ERRMSG(InvalidBorder, "Border must be 0."); ...@@ -64,6 +64,8 @@ ERRMSG(InvalidBorder, "Border must be 0.");
ERRMSG(InvalidBufferTypes, "Invalid buffer target enum."); ERRMSG(InvalidBufferTypes, "Invalid buffer target enum.");
ERRMSG(InvalidBufferUsage, "Invalid buffer usage enum."); ERRMSG(InvalidBufferUsage, "Invalid buffer usage enum.");
ERRMSG(InvalidClearMask, "Invalid mask bits."); ERRMSG(InvalidClearMask, "Invalid mask bits.");
ERRMSG(InvalidCombinedImageUnit,
"Specified unit must be in [GL_TEXTURE0, GL_TEXTURE0 + GL_MAX_COMBINED_IMAGE_UNITS)");
ERRMSG(InvalidConstantColor, ERRMSG(InvalidConstantColor,
"CONSTANT_COLOR (or ONE_MINUS_CONSTANT_COLOR) and CONSTANT_ALPHA (or " "CONSTANT_COLOR (or ONE_MINUS_CONSTANT_COLOR) and CONSTANT_ALPHA (or "
"ONE_MINUS_CONSTANT_ALPHA) cannot be used together as source and destination factors in the " "ONE_MINUS_CONSTANT_ALPHA) cannot be used together as source and destination factors in the "
...@@ -91,6 +93,8 @@ ERRMSG(InvalidInternalFormat, "Invalid internal format."); ...@@ -91,6 +93,8 @@ ERRMSG(InvalidInternalFormat, "Invalid internal format.");
ERRMSG(InvalidMatrixMode, "Invalid matrix mode."); ERRMSG(InvalidMatrixMode, "Invalid matrix mode.");
ERRMSG(InvalidMemoryBarrierBit, "Invalid memory barrier bit."); ERRMSG(InvalidMemoryBarrierBit, "Invalid memory barrier bit.");
ERRMSG(InvalidMipLevel, "Level of detail outside of range."); ERRMSG(InvalidMipLevel, "Level of detail outside of range.");
ERRMSG(InvalidMultitextureUnit,
"Specified unit must be in [GL_TEXTURE0, GL_TEXTURE0 + GL_MAX_TEXTURE_UNITS)");
ERRMSG(InvalidName, "Invalid name."); ERRMSG(InvalidName, "Invalid name.");
ERRMSG(InvalidNameCharacters, "Name contains invalid characters."); ERRMSG(InvalidNameCharacters, "Name contains invalid characters.");
ERRMSG(InvalidPname, "Invalid pname."); ERRMSG(InvalidPname, "Invalid pname.");
......
...@@ -32,6 +32,7 @@ GLES1State::GLES1State() ...@@ -32,6 +32,7 @@ GLES1State::GLES1State()
mReflectionMapEnabled(false), mReflectionMapEnabled(false),
mCurrentColor({0.0f, 0.0f, 0.0f, 0.0f}), mCurrentColor({0.0f, 0.0f, 0.0f, 0.0f}),
mCurrentNormal({0.0f, 0.0f, 0.0f}), mCurrentNormal({0.0f, 0.0f, 0.0f}),
mClientActiveTexture(0),
mCurrMatrixMode(MatrixType::Modelview), mCurrMatrixMode(MatrixType::Modelview),
mShadeModel(ShadingModel::Smooth), mShadeModel(ShadingModel::Smooth),
mAlphaTestFunc(AlphaTestFunc::AlwaysPass), mAlphaTestFunc(AlphaTestFunc::AlwaysPass),
...@@ -80,8 +81,8 @@ void GLES1State::initialize(const Context *context) ...@@ -80,8 +81,8 @@ void GLES1State::initialize(const Context *context)
mCurrentColor = {1.0f, 1.0f, 1.0f, 1.0f}; mCurrentColor = {1.0f, 1.0f, 1.0f, 1.0f};
mCurrentNormal = {0.0f, 0.0f, 1.0f}; mCurrentNormal = {0.0f, 0.0f, 1.0f};
mCurrentTextureCoords.resize(caps.maxMultitextureUnits); mCurrentTextureCoords.resize(caps.maxMultitextureUnits);
mClientActiveTexture = 0;
mTextureEnvironments.resize(caps.maxMultitextureUnits); mTextureEnvironments.resize(caps.maxMultitextureUnits);
...@@ -148,4 +149,14 @@ void GLES1State::setAlphaFunc(AlphaTestFunc func, GLfloat ref) ...@@ -148,4 +149,14 @@ void GLES1State::setAlphaFunc(AlphaTestFunc func, GLfloat ref)
mAlphaTestRef = ref; mAlphaTestRef = ref;
} }
void GLES1State::setClientTextureUnit(unsigned int unit)
{
mClientActiveTexture = unit;
}
unsigned int GLES1State::getClientTextureUnit() const
{
return mClientActiveTexture;
}
} // namespace gl } // namespace gl
...@@ -119,6 +119,8 @@ class GLES1State final : angle::NonCopyable ...@@ -119,6 +119,8 @@ class GLES1State final : angle::NonCopyable
void initialize(const Context *context); void initialize(const Context *context);
void setAlphaFunc(AlphaTestFunc func, GLfloat ref); void setAlphaFunc(AlphaTestFunc func, GLfloat ref);
void setClientTextureUnit(unsigned int unit);
unsigned int getClientTextureUnit() const;
private: private:
friend class State; friend class State;
...@@ -156,8 +158,12 @@ class GLES1State final : angle::NonCopyable ...@@ -156,8 +158,12 @@ class GLES1State final : angle::NonCopyable
// Table 6.3 // Table 6.3
ColorF mCurrentColor; ColorF mCurrentColor;
angle::Vector3 mCurrentNormal; angle::Vector3 mCurrentNormal;
// Invariant: mCurrentTextureCoords size is == GL_MAX_TEXTURE_UNITS.
std::vector<TextureCoordF> mCurrentTextureCoords; std::vector<TextureCoordF> mCurrentTextureCoords;
// Table 6.4
unsigned int mClientActiveTexture;
// Table 6.7 // Table 6.7
using MatrixStack = std::vector<angle::Mat4>; using MatrixStack = std::vector<angle::Mat4>;
MatrixType mCurrMatrixMode; MatrixType mCurrMatrixMode;
......
...@@ -2304,6 +2304,9 @@ Error State::getIntegerv(const Context *context, GLenum pname, GLint *params) ...@@ -2304,6 +2304,9 @@ Error State::getIntegerv(const Context *context, GLenum pname, GLint *params)
case GL_ALPHA_TEST_FUNC: case GL_ALPHA_TEST_FUNC:
*params = ToGLenum(mGLES1State.mAlphaTestFunc); *params = ToGLenum(mGLES1State.mAlphaTestFunc);
break; break;
case GL_CLIENT_ACTIVE_TEXTURE:
*params = mGLES1State.mClientActiveTexture + GL_TEXTURE0;
break;
default: default:
UNREACHABLE(); UNREACHABLE();
break; break;
......
...@@ -72,7 +72,14 @@ bool ValidateClearDepthx(Context *context, GLfixed depth) ...@@ -72,7 +72,14 @@ bool ValidateClearDepthx(Context *context, GLfixed depth)
bool ValidateClientActiveTexture(Context *context, GLenum texture) bool ValidateClientActiveTexture(Context *context, GLenum texture)
{ {
UNIMPLEMENTED(); ANGLE_VALIDATE_IS_GLES1(context);
if (texture < GL_TEXTURE0 ||
texture > GL_TEXTURE0 + context->getCaps().maxMultitextureUnits - 1)
{
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidMultitextureUnit);
return false;
}
return true; return true;
} }
......
...@@ -4340,7 +4340,7 @@ bool ValidateActiveTexture(Context *context, GLenum texture) ...@@ -4340,7 +4340,7 @@ bool ValidateActiveTexture(Context *context, GLenum texture)
if (texture < GL_TEXTURE0 || if (texture < GL_TEXTURE0 ||
texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1) texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
{ {
context->handleError(InvalidEnum()); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidCombinedImageUnit);
return false; return false;
} }
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
'<(angle_path)/src/tests/gl_tests/FramebufferTest.cpp', '<(angle_path)/src/tests/gl_tests/FramebufferTest.cpp',
'<(angle_path)/src/tests/gl_tests/GeometryShaderTest.cpp', '<(angle_path)/src/tests/gl_tests/GeometryShaderTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/AlphaFuncTest.cpp', '<(angle_path)/src/tests/gl_tests/gles1/AlphaFuncTest.cpp',
'<(angle_path)/src/tests/gl_tests/gles1/ClientActiveTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/GLSLTest.cpp', '<(angle_path)/src/tests/gl_tests/GLSLTest.cpp',
'<(angle_path)/src/tests/gl_tests/ImageTest.cpp', '<(angle_path)/src/tests/gl_tests/ImageTest.cpp',
'<(angle_path)/src/tests/gl_tests/IncompleteTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/IncompleteTextureTest.cpp',
......
//
// 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.
//
// ClientActiveTextureTest.cpp: Tests basic usage of glClientActiveTexture.
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
#include "random_utils.h"
#include <stdint.h>
using namespace angle;
class ClientActiveTextureTest : public ANGLETest
{
protected:
ClientActiveTextureTest()
{
setWindowWidth(32);
setWindowHeight(32);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
}
};
// State query: Checks the initial state is correct.
TEST_P(ClientActiveTextureTest, InitialState)
{
GLint clientActiveTexture = 0;
glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &clientActiveTexture);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(GL_TEXTURE0, clientActiveTexture);
}
// Negative test: Checks against invalid use of glClientActiveTexture.
TEST_P(ClientActiveTextureTest, Negative)
{
glClientActiveTexture(0);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
GLint maxTextureUnits = 0;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
glClientActiveTexture(GL_TEXTURE0 + maxTextureUnits);
EXPECT_GL_ERROR(GL_INVALID_ENUM);
}
// Checks that the number of multitexturing units is above spec minimum.
TEST_P(ClientActiveTextureTest, Limits)
{
GLint maxTextureUnits = 0;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
EXPECT_GE(maxTextureUnits, 2);
}
// Set test: Checks that GL_TEXTURE0..GL_TEXTURE[GL_MAX_TEXTURE_UNITS-1] can be set.
TEST_P(ClientActiveTextureTest, Set)
{
GLint maxTextureUnits = 0;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
for (GLint i = 0; i < maxTextureUnits; i++)
{
glClientActiveTexture(GL_TEXTURE0 + i);
EXPECT_GL_NO_ERROR();
GLint clientActiveTexture = 0;
glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, (GLint *)&clientActiveTexture);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(GL_TEXTURE0 + i, clientActiveTexture);
}
}
ANGLE_INSTANTIATE_TEST(ClientActiveTextureTest, ES1_D3D11(), ES1_OPENGL(), ES1_OPENGLES());
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