summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 20:49:10 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 20:49:10 +0000
commit939e7367d5d984efe1f402c7e5135503beaebfae (patch)
tree749c5b189a679e96c9f6d1e933f36cf51f12090c /gpu
parent451371ef73d2b718758a210640d06fad0182ac7d (diff)
downloadchromium_src-939e7367d5d984efe1f402c7e5135503beaebfae.zip
chromium_src-939e7367d5d984efe1f402c7e5135503beaebfae.tar.gz
chromium_src-939e7367d5d984efe1f402c7e5135503beaebfae.tar.bz2
Adds wrapping to support BOOL types on uniforms since some OpenGL drivers
fail at this. TEST=conformance tests. BUG=43258 Review URL: http://codereview.chromium.org/2067002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py92
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils.cc6
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc181
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_autogen.h28
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc60
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h8
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc44
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h39
8 files changed, 391 insertions, 67 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index b3e5ade..9c7f358 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -1348,7 +1348,13 @@ _FUNCTION_INFO = {
'decoder_func': 'DoTexParameteriv',
},
'TexSubImage2D': {'type': 'Data'},
- 'Uniform1fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 1},
+ 'Uniform1f': {'type': 'PUTXn', 'data_type': 'GLfloat', 'count': 1},
+ 'Uniform1fv': {
+ 'type': 'PUTn',
+ 'data_type': 'GLfloat',
+ 'count': 1,
+ 'decoder_func': 'DoUniform1fv',
+ },
'Uniform1i': {'decoder_func': 'DoUniform1i', 'unit_test': False},
'Uniform1iv': {
'type': 'PUTn',
@@ -1357,11 +1363,31 @@ _FUNCTION_INFO = {
'decoder_func': 'DoUniform1iv',
'unit_test': False,
},
- 'Uniform2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 2},
+ 'Uniform2f': {'type': 'PUTXn', 'data_type': 'GLfloat', 'count': 2},
+ 'Uniform2fv': {
+ 'type': 'PUTn',
+ 'data_type': 'GLfloat',
+ 'count': 2,
+ 'decoder_func': 'DoUniform2fv',
+ },
'Uniform2iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 2},
- 'Uniform3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 3},
+ 'Uniform3f': {'type': 'PUTXn', 'data_type': 'GLfloat', 'count': 3},
+ 'Uniform3fv': {
+ 'type': 'PUTn',
+ 'data_type': 'GLfloat',
+ 'count': 3,
+ 'decoder_func': 'DoUniform3fv',
+ },
'Uniform3iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 3},
- 'Uniform4fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 4},
+ 'Uniform4f': {
+ 'type': 'PUTXn', 'data_type': 'GLfloat', 'count': 4
+ },
+ 'Uniform4fv': {
+ 'type': 'PUTn',
+ 'data_type': 'GLfloat',
+ 'count': 4,
+ 'decoder_func': 'DoUniform4fv',
+ },
'Uniform4iv': {'type': 'PUTn', 'data_type': 'GLint', 'count': 4},
'UniformMatrix2fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 4},
'UniformMatrix3fv': {'type': 'PUTn', 'data_type': 'GLfloat', 'count': 9},
@@ -3284,6 +3310,63 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
file.Write("\n")
+class PUTXnHandler(TypeHandler):
+ """Handler for glUniform?f functions."""
+ def __init__(self):
+ TypeHandler.__init__(self)
+
+ def WriteHandlerImplementation(self, func, file):
+ """Overrriden from TypeHandler."""
+ code = """ GLfloat temp[%(count)s] = { %(values)s};
+ DoUniform%(count)sfv(%(location)s, 1, &temp[0]);
+"""
+ values = ""
+ args = func.GetOriginalArgs()
+ count = int(func.GetInfo('count'))
+ num_args = len(args)
+ for ii in range(count):
+ values += "%s, " % args[len(args) - count + ii].name
+
+ file.Write(code % {
+ 'count': func.GetInfo('count'),
+ 'location': args[0].name,
+ 'args': func.MakeOriginalArgString(""),
+ 'values': values,
+ })
+
+ def WriteServiceUnitTest(self, func, file):
+ """Overrriden from TypeHandler."""
+ valid_test = """
+TEST_F(%(test_name)s, %(name)sValidArgs) {
+ EXPECT_CALL(*gl_, Uniform%(count)sfv(%(local_args)s));
+ SpecializedSetup<%(name)s, 0>();
+ %(name)s cmd;
+ cmd.Init(%(args)s);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
+"""
+ args = func.GetOriginalArgs()
+ local_args = "%s, 1, _" % args[0].GetValidArg(0, 0)
+ self.WriteValidUnitTest(func, file, valid_test, {
+ 'count': func.GetInfo('count'),
+ 'local_args': local_args,
+ })
+
+ invalid_test = """
+TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
+ EXPECT_CALL(*gl_, Uniform%(count)s(_, _, _).Times(0);
+ SpecializedSetup<%(name)s, 0>();
+ %(name)s cmd;
+ cmd.Init(%(args)s);
+ EXPECT_EQ(error::%(parse_result)s, ExecuteCmd(cmd));%(gl_error_test)s
+}
+"""
+ self.WriteInvalidUnitTest(func, file, invalid_test, {
+ 'count': func.GetInfo('count'),
+ })
+
+
class GLcharHandler(CustomHandler):
"""Handler for functions that pass a single string ."""
@@ -4444,6 +4527,7 @@ class GLGenerator(object):
'Manual': ManualHandler(),
'PUT': PUTHandler(),
'PUTn': PUTnHandler(),
+ 'PUTXn': PUTXnHandler(),
'STRn': STRnHandler(),
'Todo': TodoHandler(),
}
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
index 79a4a48..bde062d 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -393,11 +393,11 @@ uint32 GLES2Util::GetGLDataTypeSizeForUniforms(int type) {
case GL_BOOL:
return sizeof(GLint); // NOLINT
case GL_BOOL_VEC2:
- return sizeof(GLint) * 1; // NOLINT
- case GL_BOOL_VEC3:
return sizeof(GLint) * 2; // NOLINT
- case GL_BOOL_VEC4:
+ case GL_BOOL_VEC3:
return sizeof(GLint) * 3; // NOLINT
+ case GL_BOOL_VEC4:
+ return sizeof(GLint) * 4; // NOLINT
case GL_FLOAT_MAT2:
return sizeof(GLfloat) * 2 * 2; // NOLINT
case GL_FLOAT_MAT3:
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 5fa47fc..63f8626 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -752,6 +752,23 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
error::Error ShaderSourceHelper(
GLuint client_id, const char* data, uint32 data_size);
+ // Checks if the current program exists and is valid. If not generates the
+ // appropriate GL error. Returns true if the current program is in a usable
+ // state.
+ bool CheckCurrentProgram(const char* function_name);
+
+ // Checks if the current program exists and is valid and that location is not
+ // -1. If the current program is not valid generates the appropriate GL
+ // error. Returns true if the current program is in a usable state and
+ // location is not -1.
+ bool CheckCurrentProgramForUniform(GLint location, const char* function_name);
+
+ // Gets the type of a uniform for a location in the current program. Sets GL
+ // errors if the current program is not valid. Returns true if the current
+ // program is valid and the location exists.
+ bool GetUniformTypeByLocation(
+ GLint location, const char* function_name, GLenum* type);
+
// Helper for glGetBooleanv, glGetFloatv and glGetIntegerv
bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written);
@@ -886,7 +903,14 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
// Wrappers for glUniform1i and glUniform1iv as according to the GLES2
// spec only these 2 functions can be used to set sampler uniforms.
void DoUniform1i(GLint location, GLint v0);
- void DoUniform1iv(GLint location, GLsizei count, const GLint *value);
+ void DoUniform1iv(GLint location, GLsizei count, const GLint* value);
+
+ // Wrappers for glUniformfv because some drivers don't correctly accept
+ // bool uniforms.
+ void DoUniform1fv(GLint location, GLsizei count, const GLfloat* value);
+ void DoUniform2fv(GLint location, GLsizei count, const GLfloat* value);
+ void DoUniform3fv(GLint location, GLsizei count, const GLfloat* value);
+ void DoUniform4fv(GLint location, GLsizei count, const GLfloat* value);
// Wrapper for glUseProgram
void DoUseProgram(GLuint program);
@@ -963,7 +987,8 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
bool GetUniformSetup(
GLuint program, GLint location,
uint32 shm_id, uint32 shm_offset,
- error::Error* error, GLuint* service_id, void** result);
+ error::Error* error, GLuint* service_id, void** result,
+ GLenum* result_type);
bool ValidateGLenumCompressedTextureInternalFormat(GLenum format);
@@ -2624,10 +2649,45 @@ void GLES2DecoderImpl::DoTexParameteriv(
}
}
-void GLES2DecoderImpl::DoUniform1i(GLint location, GLint v0) {
+bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) {
if (!current_program_ || current_program_->IsDeleted()) {
- // The program does not exist.
- SetGLError(GL_INVALID_OPERATION, "glUniform1i: no program in use");
+ // The program does not exist.
+ SetGLError(GL_INVALID_OPERATION,
+ (std::string(function_name) + ": no program in use").c_str());
+ return false;
+ }
+ if (!current_program_->IsValid()) {
+ SetGLError(GL_INVALID_OPERATION,
+ (std::string(function_name) + ": program not linked").c_str());
+ return false;
+ }
+ return true;
+}
+
+bool GLES2DecoderImpl::CheckCurrentProgramForUniform(
+ GLint location, const char* function_name) {
+ if (!CheckCurrentProgram(function_name)) {
+ return false;
+ }
+ return location != -1;
+}
+
+bool GLES2DecoderImpl::GetUniformTypeByLocation(
+ GLint location, const char* function_name, GLenum* type) {
+ if (!CheckCurrentProgramForUniform(location, function_name)) {
+ return false;
+ }
+ if (!current_program_->GetUniformTypeByLocation(location, type)) {
+ SetGLError(GL_INVALID_OPERATION,
+ (std::string(function_name) + ": program not linked").c_str());
+ return false;
+ }
+ return true;
+}
+
+
+void GLES2DecoderImpl::DoUniform1i(GLint location, GLint v0) {
+ if (!CheckCurrentProgramForUniform(location, "glUniform1i")) {
return;
}
current_program_->SetSamplers(location, 1, &v0);
@@ -2636,15 +2696,84 @@ void GLES2DecoderImpl::DoUniform1i(GLint location, GLint v0) {
void GLES2DecoderImpl::DoUniform1iv(
GLint location, GLsizei count, const GLint *value) {
- if (!current_program_ || current_program_->IsDeleted()) {
- // The program does not exist.
- SetGLError(GL_INVALID_OPERATION, "glUniform1iv: no program in use");
+ if (!CheckCurrentProgramForUniform(location, "glUniform1iv")) {
return;
}
current_program_->SetSamplers(location, count, value);
glUniform1iv(location, count, value);
}
+void GLES2DecoderImpl::DoUniform1fv(
+ GLint location, GLsizei count, const GLfloat* value) {
+ GLenum type;
+ if (!GetUniformTypeByLocation(location, "glUniform1fv", &type)) {
+ return;
+ }
+ if (type == GL_BOOL) {
+ scoped_array<GLint> temp(new GLint[count]);
+ for (GLsizei ii = 0; ii < count; ++ii) {
+ temp[ii] = static_cast<GLint>(value[ii]);
+ }
+ DoUniform1iv(location, count, temp.get());
+ } else {
+ glUniform1fv(location, count, value);
+ }
+}
+
+void GLES2DecoderImpl::DoUniform2fv(
+ GLint location, GLsizei count, const GLfloat* value) {
+ GLenum type;
+ if (!GetUniformTypeByLocation(location, "glUniform2fv", &type)) {
+ return;
+ }
+ if (type == GL_BOOL_VEC2) {
+ GLsizei num_values = count * 2;
+ scoped_array<GLint> temp(new GLint[num_values]);
+ for (GLsizei ii = 0; ii < num_values; ++ii) {
+ temp[ii] = static_cast<GLint>(value[ii]);
+ }
+ glUniform2iv(location, count, temp.get());
+ } else {
+ glUniform2fv(location, count, value);
+ }
+}
+
+void GLES2DecoderImpl::DoUniform3fv(
+ GLint location, GLsizei count, const GLfloat* value) {
+ GLenum type;
+ if (!GetUniformTypeByLocation(location, "glUniform3fv", &type)) {
+ return;
+ }
+ if (type == GL_BOOL_VEC3) {
+ GLsizei num_values = count * 3;
+ scoped_array<GLint> temp(new GLint[num_values]);
+ for (GLsizei ii = 0; ii < num_values; ++ii) {
+ temp[ii] = static_cast<GLint>(value[ii]);
+ }
+ glUniform3iv(location, count, temp.get());
+ } else {
+ glUniform3fv(location, count, value);
+ }
+}
+
+void GLES2DecoderImpl::DoUniform4fv(
+ GLint location, GLsizei count, const GLfloat* value) {
+ GLenum type;
+ if (!GetUniformTypeByLocation(location, "glUniform4fv", &type)) {
+ return;
+ }
+ if (type == GL_BOOL_VEC4) {
+ GLsizei num_values = count * 4;
+ scoped_array<GLint> temp(new GLint[num_values]);
+ for (GLsizei ii = 0; ii < num_values; ++ii) {
+ temp[ii] = static_cast<GLint>(value[ii]);
+ }
+ glUniform4iv(location, count, temp.get());
+ } else {
+ glUniform4fv(location, count, value);
+ }
+}
+
void GLES2DecoderImpl::DoUseProgram(GLuint program) {
GLuint service_id = 0;
ProgramManager::ProgramInfo* info = NULL;
@@ -2774,7 +2903,8 @@ void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() {
}
bool GLES2DecoderImpl::IsDrawValid(GLuint max_vertex_accessed) {
- if (!current_program_ || current_program_->IsDeleted()) {
+ if (!current_program_ || current_program_->IsDeleted() ||
+ !current_program_->IsValid()) {
// The program does not exist.
// But GL says no ERROR.
return false;
@@ -2967,6 +3097,7 @@ void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
+ shader_src = info->source().c_str();
glShaderSource(info->service_id(), 1, &shader_src, NULL);
glCompileShader(info->service_id());
@@ -3775,7 +3906,12 @@ error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv(
bool GLES2DecoderImpl::GetUniformSetup(
GLuint program, GLint location,
uint32 shm_id, uint32 shm_offset,
- error::Error* error, GLuint* service_id, void** result_pointer) {
+ error::Error* error, GLuint* service_id, void** result_pointer,
+ GLenum* result_type) {
+ DCHECK(error);
+ DCHECK(service_id);
+ DCHECK(result_pointer);
+ DCHECK(result_type);
*error = error::kNoError;
// Make sure we have enough room for the result on failure.
SizedResult<GLint>* result;
@@ -3817,6 +3953,7 @@ bool GLES2DecoderImpl::GetUniformSetup(
return false;
}
result->size = size;
+ *result_type = type;
return true;
}
@@ -3825,11 +3962,12 @@ error::Error GLES2DecoderImpl::HandleGetUniformiv(
GLuint program = c.program;
GLint location = c.location;
GLuint service_id;
+ GLenum result_type;
Error error;
void* result;
if (GetUniformSetup(
program, location, c.params_shm_id, c.params_shm_offset,
- &error, &service_id, &result)) {
+ &error, &service_id, &result, &result_type)) {
glGetUniformiv(
service_id, location,
static_cast<gles2::GetUniformiv::Result*>(result)->GetData());
@@ -3843,15 +3981,24 @@ error::Error GLES2DecoderImpl::HandleGetUniformfv(
GLint location = c.location;
GLuint service_id;
Error error;
- void* result;
typedef gles2::GetUniformfv::Result Result;
+ Result* result;
+ GLenum result_type;
if (GetUniformSetup(
program, location, c.params_shm_id, c.params_shm_offset,
- &error, &service_id, &result)) {
- glGetUniformfv(
- service_id,
- location,
- static_cast<gles2::GetUniformfv::Result*>(result)->GetData());
+ &error, &service_id, reinterpret_cast<void**>(&result), &result_type)) {
+ if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 ||
+ result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) {
+ GLsizei num_values = result->GetNumResults();
+ scoped_array<GLint> temp(new GLint[num_values]);
+ glGetUniformiv(service_id, location, temp.get());
+ GLfloat* dst = result->GetData();
+ for (GLsizei ii = 0; ii < num_values; ++ii) {
+ dst[ii] = (temp[ii] != 0);
+ }
+ } else {
+ glGetUniformfv(service_id, location, result->GetData());
+ }
}
return error;
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
index f7e9c87..1db0b6a 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -1884,7 +1884,8 @@ error::Error GLES2DecoderImpl::HandleUniform1f(
uint32 immediate_data_size, const gles2::Uniform1f& c) {
GLint location = static_cast<GLint>(c.location);
GLfloat x = static_cast<GLfloat>(c.x);
- glUniform1f(location, x);
+ GLfloat temp[1] = { x, };
+ DoUniform1fv(location, 1, &temp[0]);
return error::kNoError;
}
@@ -1905,7 +1906,7 @@ error::Error GLES2DecoderImpl::HandleUniform1fv(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform1fv(location, count, v);
+ DoUniform1fv(location, count, v);
return error::kNoError;
}
@@ -1929,7 +1930,7 @@ error::Error GLES2DecoderImpl::HandleUniform1fvImmediate(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform1fv(location, count, v);
+ DoUniform1fv(location, count, v);
return error::kNoError;
}
@@ -1991,7 +1992,8 @@ error::Error GLES2DecoderImpl::HandleUniform2f(
GLint location = static_cast<GLint>(c.location);
GLfloat x = static_cast<GLfloat>(c.x);
GLfloat y = static_cast<GLfloat>(c.y);
- glUniform2f(location, x, y);
+ GLfloat temp[2] = { x, y, };
+ DoUniform2fv(location, 1, &temp[0]);
return error::kNoError;
}
@@ -2012,7 +2014,7 @@ error::Error GLES2DecoderImpl::HandleUniform2fv(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform2fv(location, count, v);
+ DoUniform2fv(location, count, v);
return error::kNoError;
}
@@ -2036,7 +2038,7 @@ error::Error GLES2DecoderImpl::HandleUniform2fvImmediate(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform2fv(location, count, v);
+ DoUniform2fv(location, count, v);
return error::kNoError;
}
@@ -2100,7 +2102,8 @@ error::Error GLES2DecoderImpl::HandleUniform3f(
GLfloat x = static_cast<GLfloat>(c.x);
GLfloat y = static_cast<GLfloat>(c.y);
GLfloat z = static_cast<GLfloat>(c.z);
- glUniform3f(location, x, y, z);
+ GLfloat temp[3] = { x, y, z, };
+ DoUniform3fv(location, 1, &temp[0]);
return error::kNoError;
}
@@ -2121,7 +2124,7 @@ error::Error GLES2DecoderImpl::HandleUniform3fv(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform3fv(location, count, v);
+ DoUniform3fv(location, count, v);
return error::kNoError;
}
@@ -2145,7 +2148,7 @@ error::Error GLES2DecoderImpl::HandleUniform3fvImmediate(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform3fv(location, count, v);
+ DoUniform3fv(location, count, v);
return error::kNoError;
}
@@ -2211,7 +2214,8 @@ error::Error GLES2DecoderImpl::HandleUniform4f(
GLfloat y = static_cast<GLfloat>(c.y);
GLfloat z = static_cast<GLfloat>(c.z);
GLfloat w = static_cast<GLfloat>(c.w);
- glUniform4f(location, x, y, z, w);
+ GLfloat temp[4] = { x, y, z, w, };
+ DoUniform4fv(location, 1, &temp[0]);
return error::kNoError;
}
@@ -2232,7 +2236,7 @@ error::Error GLES2DecoderImpl::HandleUniform4fv(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform4fv(location, count, v);
+ DoUniform4fv(location, count, v);
return error::kNoError;
}
@@ -2256,7 +2260,7 @@ error::Error GLES2DecoderImpl::HandleUniform4fvImmediate(
if (v == NULL) {
return error::kOutOfBounds;
}
- glUniform4fv(location, count, v);
+ DoUniform4fv(location, count, v);
return error::kNoError;
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc
index 832e0c5..5d7540c 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2.cc
@@ -52,6 +52,66 @@ void GLES2DecoderTestBase::SpecializedSetup<LinkProgram, 0>() {
};
template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform1f, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform1fv, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform1fvImmediate, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform2f, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform2fv, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform2fvImmediate, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform3f, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform3fv, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform3fvImmediate, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform4f, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform4fv, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
+void GLES2DecoderTestBase::SpecializedSetup<Uniform4fvImmediate, 0>() {
+ SetupShaderForUniform();
+};
+
+template <>
void GLES2DecoderTestBase::SpecializedSetup<RenderbufferStorage, 0>() {
DoBindRenderbuffer(GL_RENDERBUFFER, client_renderbuffer_id_,
kServiceRenderbufferId);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h
index a7453ca..456acdc 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h
@@ -744,7 +744,7 @@ TEST_F(GLES2DecoderTest2, TexParameterivImmediateInvalidArgs1_0) {
TEST_F(GLES2DecoderTest2, Uniform1fValidArgs) {
- EXPECT_CALL(*gl_, Uniform1f(1, 2));
+ EXPECT_CALL(*gl_, Uniform1fv(1, 1, _));
SpecializedSetup<Uniform1f, 0>();
Uniform1f cmd;
cmd.Init(1, 2);
@@ -806,7 +806,7 @@ TEST_F(GLES2DecoderTest2, Uniform1fvImmediateValidArgs) {
// TODO(gman): Uniform1ivImmediate
TEST_F(GLES2DecoderTest2, Uniform2fValidArgs) {
- EXPECT_CALL(*gl_, Uniform2f(1, 2, 3));
+ EXPECT_CALL(*gl_, Uniform2fv(1, 1, _));
SpecializedSetup<Uniform2f, 0>();
Uniform2f cmd;
cmd.Init(1, 2, 3);
@@ -924,7 +924,7 @@ TEST_F(GLES2DecoderTest2, Uniform2ivImmediateValidArgs) {
}
TEST_F(GLES2DecoderTest2, Uniform3fValidArgs) {
- EXPECT_CALL(*gl_, Uniform3f(1, 2, 3, 4));
+ EXPECT_CALL(*gl_, Uniform3fv(1, 1, _));
SpecializedSetup<Uniform3f, 0>();
Uniform3f cmd;
cmd.Init(1, 2, 3, 4);
@@ -1042,7 +1042,7 @@ TEST_F(GLES2DecoderTest2, Uniform3ivImmediateValidArgs) {
}
TEST_F(GLES2DecoderTest2, Uniform4fValidArgs) {
- EXPECT_CALL(*gl_, Uniform4f(1, 2, 3, 4, 5));
+ EXPECT_CALL(*gl_, Uniform4fv(1, 1, _));
SpecializedSetup<Uniform4f, 0>();
Uniform4f cmd;
cmd.Init(1, 2, 3, 4, 5);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index e16f0a4..e8a91e8 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -179,6 +179,24 @@ void GLES2DecoderTestBase::SetBucketAsCString(
}
}
+void GLES2DecoderTestBase::SetupShaderForUniform() {
+ static AttribInfo attribs[] = {
+ { "foo", 1, GL_FLOAT, 1, },
+ };
+ static UniformInfo uniforms[] = {
+ { "bar", 1, GL_INT, 1, },
+ };
+ SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms),
+ client_program_id_, kServiceProgramId);
+
+ EXPECT_CALL(*gl_, UseProgram(kServiceProgramId))
+ .Times(1)
+ .RetiresOnSaturation();
+ UseProgram cmd;
+ cmd.Init(client_program_id_);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
void GLES2DecoderTestBase::DoBindFramebuffer(
GLenum target, GLuint client_id, GLuint service_id) {
EXPECT_CALL(*gl_, BindFramebufferEXT(target, service_id))
@@ -287,9 +305,9 @@ void GLES2DecoderWithShaderTestBase::TearDown() {
GLES2DecoderTestBase::TearDown();
}
-void GLES2DecoderWithShaderTestBase::SetupShader(
- GLES2DecoderWithShaderTestBase::AttribInfo* attribs, size_t num_attribs,
- GLES2DecoderWithShaderTestBase::UniformInfo* uniforms, size_t num_uniforms,
+void GLES2DecoderTestBase::SetupShader(
+ GLES2DecoderTestBase::AttribInfo* attribs, size_t num_attribs,
+ GLES2DecoderTestBase::UniformInfo* uniforms, size_t num_uniforms,
GLuint client_id, GLuint service_id) {
LinkProgram cmd;
cmd.Init(client_id);
@@ -306,15 +324,19 @@ void GLES2DecoderWithShaderTestBase::SetupShader(
GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTES, _))
.WillOnce(SetArgumentPointee<2>(num_attribs))
.RetiresOnSaturation();
+ size_t max_attrib_len = 0;
+ for (size_t ii = 0; ii < num_attribs; ++ii) {
+ size_t len = strlen(attribs[ii].name) + 1;
+ max_attrib_len = std::max(max_attrib_len, len);
+ }
EXPECT_CALL(*gl_,
GetProgramiv(service_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, _))
- .WillOnce(SetArgumentPointee<2>(kMaxAttribLength))
+ .WillOnce(SetArgumentPointee<2>(max_attrib_len))
.RetiresOnSaturation();
for (size_t ii = 0; ii < num_attribs; ++ii) {
const AttribInfo& info = attribs[ii];
EXPECT_CALL(*gl_,
- GetActiveAttrib(service_id, ii,
- kMaxAttribLength, _, _, _, _))
+ GetActiveAttrib(service_id, ii, max_attrib_len, _, _, _, _))
.WillOnce(DoAll(
SetArgumentPointee<3>(strlen(info.name)),
SetArgumentPointee<4>(info.size),
@@ -333,15 +355,19 @@ void GLES2DecoderWithShaderTestBase::SetupShader(
GetProgramiv(service_id, GL_ACTIVE_UNIFORMS, _))
.WillOnce(SetArgumentPointee<2>(num_uniforms))
.RetiresOnSaturation();
+ size_t max_uniform_len = 0;
+ for (size_t ii = 0; ii < num_uniforms; ++ii) {
+ size_t len = strlen(uniforms[ii].name) + 1;
+ max_uniform_len = std::max(max_uniform_len, len);
+ }
EXPECT_CALL(*gl_,
GetProgramiv(service_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, _))
- .WillOnce(SetArgumentPointee<2>(kMaxUniformLength))
+ .WillOnce(SetArgumentPointee<2>(max_uniform_len))
.RetiresOnSaturation();
for (size_t ii = 0; ii < num_uniforms; ++ii) {
const UniformInfo& info = uniforms[ii];
EXPECT_CALL(*gl_,
- GetActiveUniform(service_id, ii,
- kMaxUniformLength, _, _, _, _))
+ GetActiveUniform(service_id, ii, max_uniform_len, _, _, _, _))
.WillOnce(DoAll(
SetArgumentPointee<3>(strlen(info.name)),
SetArgumentPointee<4>(info.size),
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
index b7781b6..e1279fc 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
@@ -157,6 +157,27 @@ class GLES2DecoderTestBase : public testing::Test {
void SetBucketAsCString(uint32 bucket_id, const char* str);
+ struct AttribInfo {
+ const char* name;
+ GLint size;
+ GLenum type;
+ GLint location;
+ };
+
+ struct UniformInfo {
+ const char* name;
+ GLint size;
+ GLenum type;
+ GLint location;
+ };
+
+ void SetupShader(AttribInfo* attribs, size_t num_attribs,
+ UniformInfo* uniforms, size_t num_uniforms,
+ GLuint client_id, GLuint service_id);
+
+ // Setups up a shader for testing glUniform.
+ void SetupShaderForUniform();
+
// Note that the error is returned as GLint instead of GLenum.
// This is because there is a mismatch in the types of GLenum and
// the error values GL_NO_ERROR, GL_INVALID_ENUM, etc. GLenum is
@@ -287,27 +308,9 @@ class GLES2DecoderWithShaderTestBase : public GLES2DecoderTestBase {
static const GLint kBadUniformIndex = 1000;
protected:
- struct AttribInfo {
- const char* name;
- GLint size;
- GLenum type;
- GLint location;
- };
-
- struct UniformInfo {
- const char* name;
- GLint size;
- GLenum type;
- GLint location;
- };
-
virtual void SetUp();
virtual void TearDown();
- void SetupShader(AttribInfo* attribs, size_t num_attribs,
- UniformInfo* uniforms, size_t num_uniforms,
- GLuint client_id, GLuint service_id);
-
void SetupTexture();
GLvoid* BufferOffset(unsigned i) {