summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-19 21:01:48 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-19 21:01:48 +0000
commit8f1ccdacbcfb47fa2eeb6c7e748f55c7ae4bafec (patch)
tree7d14db579aba792e6f3f146237ce55bc82786147 /gpu
parentebd1048ab80dbf90baa05beffe4319cd53920091 (diff)
downloadchromium_src-8f1ccdacbcfb47fa2eeb6c7e748f55c7ae4bafec.zip
chromium_src-8f1ccdacbcfb47fa2eeb6c7e748f55c7ae4bafec.tar.gz
chromium_src-8f1ccdacbcfb47fa2eeb6c7e748f55c7ae4bafec.tar.bz2
Resubmit http://codereview.chromium.org/2096008/show
now that ANGLE has been updated or gcc 4.4.1 TEST=none BUG=none git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47721 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py5
-rw-r--r--gpu/command_buffer/service/context_group.cc43
-rw-r--r--gpu/command_buffer/service/context_group.h26
-rw-r--r--gpu/command_buffer/service/context_group_unittest.cc5
-rw-r--r--gpu/command_buffer/service/gl_utils.h6
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc86
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc34
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h34
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc37
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h5
-rw-r--r--gpu/command_buffer/service/shader_manager.h22
-rw-r--r--gpu/command_buffer/service/shader_manager_unittest.cc1
-rw-r--r--gpu/gpu.gyp5
13 files changed, 224 insertions, 85 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index 750dfdb..acea9d3 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -1214,7 +1214,8 @@ _FUNCTION_INFO = {
'type': 'STRn',
'get_len_func': 'glGetShaderiv',
'get_len_enum': 'GL_INFO_LOG_LENGTH',
- },
+ 'unit_test': False,
+ },
'GetShaderPrecisionFormat': {
'type': 'Custom',
'immediate': False,
@@ -3749,7 +3750,7 @@ TEST_F(%(test_name)s, %(name)sValidArgs) {
if get_len_func[0:2] == 'gl':
sub['expect_len_code'] = (
" EXPECT_CALL(*gl_, %s(%s, %s, _))\n"
- " .WillOnce(SetArgumentPointee<2>(strlen(kInfo)));") % (
+ " .WillOnce(SetArgumentPointee<2>(strlen(kInfo) + 1));") % (
get_len_func[2:], id_name, get_len_enum)
self.WriteValidUnitTest(func, file, valid_test, sub)
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc
index 7a62c72..71b796c 100644
--- a/gpu/command_buffer/service/context_group.cc
+++ b/gpu/command_buffer/service/context_group.cc
@@ -17,12 +17,23 @@ namespace gles2 {
ContextGroup::ContextGroup()
: initialized_(false),
max_vertex_attribs_(0u),
- max_texture_units_(0u) {
+ max_texture_units_(0u),
+ max_texture_image_units_(0u),
+ max_vertex_texture_image_units_(0u),
+ max_fragment_uniform_vectors_(0u),
+ max_varying_vectors_(0u),
+ max_vertex_uniform_vectors_(0u) {
}
ContextGroup::~ContextGroup() {
}
+static void GetIntegerv(GLenum pname, uint32* var) {
+ GLint value = 0;
+ glGetIntegerv(pname, &value);
+ *var = value;
+}
+
bool ContextGroup::Initialize() {
if (initialized_) {
return true;
@@ -35,14 +46,11 @@ bool ContextGroup::Initialize() {
program_manager_.reset(new ProgramManager());
// Lookup GL things we need to know.
- GLint value;
- glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &value);
- max_vertex_attribs_ = value;
+ GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs_);
const GLuint kGLES2RequiredMiniumumVertexAttribs = 8u;
DCHECK_GE(max_vertex_attribs_, kGLES2RequiredMiniumumVertexAttribs);
- glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &value);
- max_texture_units_ = value;
+ GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_texture_units_);
const GLuint kGLES2RequiredMiniumumTextureUnits = 8u;
DCHECK_GE(max_texture_units_, kGLES2RequiredMiniumumTextureUnits);
@@ -52,6 +60,29 @@ bool ContextGroup::Initialize() {
glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &max_cube_map_texture_size);
texture_manager_.reset(new TextureManager(max_texture_size,
max_cube_map_texture_size));
+
+ GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_image_units_);
+ GetIntegerv(
+ GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &max_vertex_texture_image_units_);
+
+#if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+
+ GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &max_fragment_uniform_vectors_);
+ GetIntegerv(GL_MAX_VARYING_VECTORS, &max_varying_vectors_);
+ GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &max_vertex_uniform_vectors_);
+
+#else // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+
+ GetIntegerv(
+ GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max_fragment_uniform_vectors_);
+ max_fragment_uniform_vectors_ /= 4;
+ GetIntegerv(GL_MAX_VARYING_FLOATS, &max_varying_vectors_);
+ max_varying_vectors_ /= 4;
+ GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &max_vertex_uniform_vectors_);
+ max_vertex_uniform_vectors_ /= 4;
+
+#endif // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+
initialized_ = true;
return true;
}
diff --git a/gpu/command_buffer/service/context_group.h b/gpu/command_buffer/service/context_group.h
index 2b0bf46..12fa7b6 100644
--- a/gpu/command_buffer/service/context_group.h
+++ b/gpu/command_buffer/service/context_group.h
@@ -42,6 +42,26 @@ class ContextGroup {
return max_texture_units_;
}
+ uint32 max_texture_image_units() const {
+ return max_texture_image_units_;
+ }
+
+ uint32 max_vertex_texture_image_units() const {
+ return max_vertex_texture_image_units_;
+ }
+
+ uint32 max_fragment_uniform_vectors() const {
+ return max_fragment_uniform_vectors_;
+ }
+
+ uint32 max_varying_vectors() const {
+ return max_varying_vectors_;
+ }
+
+ uint32 max_vertex_uniform_vectors() const {
+ return max_vertex_uniform_vectors_;
+ }
+
BufferManager* buffer_manager() const {
return buffer_manager_.get();
}
@@ -73,8 +93,12 @@ class ContextGroup {
bool initialized_;
uint32 max_vertex_attribs_;
-
uint32 max_texture_units_;
+ uint32 max_texture_image_units_;
+ uint32 max_vertex_texture_image_units_;
+ uint32 max_fragment_uniform_vectors_;
+ uint32 max_varying_vectors_;
+ uint32 max_vertex_uniform_vectors_;
scoped_ptr<BufferManager> buffer_manager_;
diff --git a/gpu/command_buffer/service/context_group_unittest.cc b/gpu/command_buffer/service/context_group_unittest.cc
index d46bec6..c997f7a 100644
--- a/gpu/command_buffer/service/context_group_unittest.cc
+++ b/gpu/command_buffer/service/context_group_unittest.cc
@@ -27,6 +27,11 @@ TEST_F(ContextGroupTest, Basic) {
// Test it starts off uninitialized.
EXPECT_EQ(0u, group_.max_vertex_attribs());
EXPECT_EQ(0u, group_.max_texture_units());
+ EXPECT_EQ(0u, group_.max_texture_image_units());
+ EXPECT_EQ(0u, group_.max_vertex_texture_image_units());
+ EXPECT_EQ(0u, group_.max_fragment_uniform_vectors());
+ EXPECT_EQ(0u, group_.max_varying_vectors());
+ EXPECT_EQ(0u, group_.max_vertex_uniform_vectors());
EXPECT_TRUE(group_.buffer_manager() == NULL);
EXPECT_TRUE(group_.framebuffer_manager() == NULL);
EXPECT_TRUE(group_.renderbuffer_manager() == NULL);
diff --git a/gpu/command_buffer/service/gl_utils.h b/gpu/command_buffer/service/gl_utils.h
index de2f044..c7cf11b 100644
--- a/gpu/command_buffer/service/gl_utils.h
+++ b/gpu/command_buffer/service/gl_utils.h
@@ -12,9 +12,15 @@
#if defined(UNIT_TEST)
#include "gpu/command_buffer/service/gl_mock.h"
+ // OpenGL constants not defined in OpenGL ES 2.0 needed when compiling
+ // unit tests. For native OpenGL ES 2.0 backend these are not used. For OpenGL
+ // backend these must be defined by the local system.
#if !defined(GL_VERTEX_PROGRAM_POINT_SIZE)
#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
#endif
+ #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+ #define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+ #define GL_MAX_VARYING_FLOATS 0x8B4B
#else
#if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
#include <GLES2/gl2.h> // NOLINT
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 3d68326..7a9d35f 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -41,17 +41,6 @@
#define GL_DEPTH24_STENCIL8 0x88F0
#endif
-#if defined(UNIT_TEST)
-
-// OpenGL constants not defined in OpenGL ES 2.0 needed when compiling
-// unit tests. For native OpenGL ES 2.0 backend these are not used. For OpenGL
-// backend these must be defined by the local system.
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
-#define GL_MAX_VARYING_FLOATS 0x8B4B
-
-#endif
-
namespace gpu {
namespace gles2 {
@@ -2203,22 +2192,19 @@ bool GLES2DecoderImpl::GetHelper(
case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
*num_written = 1;
if (params) {
- glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, params);
- *params /= 4;
+ *params = group_->max_fragment_uniform_vectors();
}
return true;
case GL_MAX_VARYING_VECTORS:
*num_written = 1;
if (params) {
- glGetIntegerv(GL_MAX_VARYING_FLOATS, params);
- *params /= 4;
+ *params = group_->max_varying_vectors();
}
return true;
case GL_MAX_VERTEX_UNIFORM_VECTORS:
*num_written = 1;
if (params) {
- glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, params);
- *params /= 4;
+ *params = group_->max_vertex_uniform_vectors();
}
return true;
#endif
@@ -3235,39 +3221,38 @@ void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
const char* shader_src = info->source().c_str();
#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) && !defined(UNIT_TEST)
#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
- ShHandle compiler;
+ ShHandle compiler = 0;
if (use_shader_translator_) {
int dbg_options = 0;
EShLanguage language = info->shader_type() == GL_VERTEX_SHADER ?
EShLangVertex : EShLangFragment;
TBuiltInResource resources;
- // TODO(alokp): Ask gman how to get appropriate values.
resources.maxVertexAttribs = group_->max_vertex_attribs();
- resources.maxVertexUniformVectors = 128;
- resources.maxVaryingVectors = 8;
- resources.maxVertexTextureImageUnits = 0;
+ resources.maxVertexUniformVectors =
+ group_->max_vertex_uniform_vectors();
+ resources.maxVaryingVectors = group_->max_varying_vectors();
+ resources.maxVertexTextureImageUnits =
+ group_->max_vertex_texture_image_units();
resources.maxCombinedTextureImageUnits = group_->max_texture_units();
- resources.maxTextureImageUnits = 8;
- resources.maxFragmentUniformVectors = 16;
+ resources.maxTextureImageUnits = group_->max_texture_image_units();
+ resources.maxFragmentUniformVectors =
+ group_->max_fragment_uniform_vectors();
resources.maxDrawBuffers = 1;
compiler = ShConstructCompiler(language, dbg_options);
if (!ShCompile(compiler, &shader_src, 1, EShOptNone, &resources,
dbg_options)) {
- // TODO(alokp): Ask gman where to set compile-status and info-log.
- // May be add member variables to ShaderManager::ShaderInfo?
- // const char* info_log = ShGetInfoLog(compiler);
+ info->SetTranslationStatus(false, ShGetInfoLog(compiler));
ShDestruct(compiler);
return;
}
+ info->SetTranslationStatus(true, "");
shader_src = ShGetObjectCode(compiler);
}
#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());
-
#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) && !defined(UNIT_TEST)
#ifdef GLES2_GPU_SERVICE_TRANSLATE_SHADER
if (use_shader_translator_) {
@@ -3284,11 +3269,26 @@ void GLES2DecoderImpl::DoGetShaderiv(
if (!info) {
return;
}
- if (pname == GL_SHADER_SOURCE_LENGTH) {
- *params = info->source().size();
- } else {
- glGetShaderiv(info->service_id(), pname, params);
+ switch (pname) {
+ case GL_SHADER_SOURCE_LENGTH:
+ *params = info->source().size();
+ return;
+ case GL_COMPILE_STATUS:
+ if (!info->translation_valid()) {
+ *params = GL_FALSE;
+ return;
+ }
+ break;
+ case GL_INFO_LOG_LENGTH:
+ if (!info->translation_valid()) {
+ *params = info->translation_log().size() + 1;
+ return;
+ }
+ break;
+ default:
+ break;
}
+ glGetShaderiv(info->service_id(), pname, params);
}
error::Error GLES2DecoderImpl::HandleGetShaderSource(
@@ -3318,10 +3318,10 @@ error::Error GLES2DecoderImpl::HandleGetProgramInfoLog(
}
GLint len = 0;
glGetProgramiv(info->service_id(), GL_INFO_LOG_LENGTH, &len);
- bucket->SetSize(len + 1);
+ bucket->SetSize(len);
glGetProgramInfoLog(
info->service_id(),
- len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1));
+ len, &len, bucket->GetDataAs<GLchar*>(0, len));
return error::kNoError;
}
@@ -3336,12 +3336,16 @@ error::Error GLES2DecoderImpl::HandleGetShaderInfoLog(
bucket->SetSize(0);
return error::kNoError;
}
- GLint len = 0;
- glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &len);
- bucket->SetSize(len + 1);
- glGetShaderInfoLog(
- info->service_id(),
- len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1));
+ if (!info->translation_valid()) {
+ bucket->SetFromString(info->translation_log());
+ } else {
+ GLint len = 0;
+ glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &len);
+ bucket->SetSize(len);
+ glGetShaderInfoLog(
+ info->service_id(),
+ len, &len, bucket->GetDataAs<GLchar*>(0, len));
+ }
return error::kNoError;
}
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 766dfae..a45c982 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -906,6 +906,40 @@ TEST_F(GLES2DecoderWithShaderTest, GetActiveAttribBadSharedMemoryFails) {
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
}
+TEST_F(GLES2DecoderWithShaderTest, GetShaderInfoLogValidArgs) {
+ const char* kInfo = "hello";
+ const uint32 kBucketId = 123;
+ CompileShader compile_cmd;
+ GetShaderInfoLog cmd;
+ EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _));
+ EXPECT_CALL(*gl_, CompileShader(kServiceShaderId));
+ EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_INFO_LOG_LENGTH, _))
+ .WillOnce(SetArgumentPointee<2>(strlen(kInfo) + 1))
+ .RetiresOnSaturation();
+ EXPECT_CALL(
+ *gl_, GetShaderInfoLog(kServiceShaderId, strlen(kInfo) + 1, _, _))
+ .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)),
+ SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1)));
+ compile_cmd.Init(client_shader_id_);
+ cmd.Init(client_shader_id_, kBucketId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(compile_cmd));
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
+ ASSERT_TRUE(bucket != NULL);
+ EXPECT_EQ(strlen(kInfo) + 1, bucket->size());
+ EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo,
+ bucket->size()));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+}
+
+TEST_F(GLES2DecoderWithShaderTest, GetShaderInfoLogInvalidArgs) {
+ const uint32 kBucketId = 123;
+ GetShaderInfoLog cmd;
+ cmd.Init(kInvalidClientId, kBucketId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+}
+
TEST_F(GLES2DecoderTest, CompileShaderValidArgs) {
EXPECT_CALL(*gl_, ShaderSource(kServiceShaderId, 1, _, _));
EXPECT_CALL(*gl_, CompileShader(kServiceShaderId));
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
index 824c051..76000af 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h
@@ -1486,7 +1486,7 @@ TEST_F(GLES2DecoderTest1, GetProgramInfoLogValidArgs) {
const uint32 kBucketId = 123;
SpecializedSetup<GetProgramInfoLog, 0>(true);
EXPECT_CALL(*gl_, GetProgramiv(kServiceProgramId, GL_INFO_LOG_LENGTH, _))
- .WillOnce(SetArgumentPointee<2>(strlen(kInfo)));
+ .WillOnce(SetArgumentPointee<2>(strlen(kInfo) + 1));
EXPECT_CALL(
*gl_, GetProgramInfoLog(kServiceProgramId, strlen(kInfo) + 1, _, _))
.WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)),
@@ -1623,37 +1623,7 @@ TEST_F(GLES2DecoderTest1, GetShaderivInvalidArgs2_1) {
EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
EXPECT_EQ(0u, result->size);
}
-
-TEST_F(GLES2DecoderTest1, GetShaderInfoLogValidArgs) {
- const char* kInfo = "hello";
- const uint32 kBucketId = 123;
- SpecializedSetup<GetShaderInfoLog, 0>(true);
- EXPECT_CALL(*gl_, GetShaderiv(kServiceShaderId, GL_INFO_LOG_LENGTH, _))
- .WillOnce(SetArgumentPointee<2>(strlen(kInfo)));
- EXPECT_CALL(
- *gl_, GetShaderInfoLog(kServiceShaderId, strlen(kInfo) + 1, _, _))
- .WillOnce(DoAll(SetArgumentPointee<2>(strlen(kInfo)),
- SetArrayArgument<3>(kInfo, kInfo + strlen(kInfo) + 1)));
- GetShaderInfoLog cmd;
- cmd.Init(client_shader_id_, kBucketId);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId);
- ASSERT_TRUE(bucket != NULL);
- EXPECT_EQ(strlen(kInfo) + 1, bucket->size());
- EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kInfo,
- bucket->size()));
- EXPECT_EQ(GL_NO_ERROR, GetGLError());
-}
-
-TEST_F(GLES2DecoderTest1, GetShaderInfoLogInvalidArgs) {
- const uint32 kBucketId = 123;
- EXPECT_CALL(*gl_, GetShaderInfoLog(_, _, _, _))
- .Times(0);
- GetShaderInfoLog cmd;
- cmd.Init(kInvalidClientId, kBucketId);
- EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
- EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
-}
+// TODO(gman): GetShaderInfoLog
// TODO(gman): GetShaderPrecisionFormat
// TODO(gman): GetShaderSource
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 33fbf54..a9cc632 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -45,6 +45,38 @@ void GLES2DecoderTestBase::SetUp() {
EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, _))
.WillOnce(SetArgumentPointee<1>(kMaxCubeMapTextureSize))
.RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxTextureImageUnits))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxVertexTextureImageUnits))
+ .RetiresOnSaturation();
+
+#if defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformVectors * 4))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VARYING_VECTORS, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxVaryingVectors * 4))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformVectors * 4))
+ .RetiresOnSaturation();
+
+#else // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxFragmentUniformVectors))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VARYING_FLOATS, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxVaryingVectors))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, _))
+ .WillOnce(SetArgumentPointee<1>(kMaxVertexUniformVectors))
+ .RetiresOnSaturation();
+
+#endif // !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
EXPECT_CALL(*gl_, EnableVertexAttribArray(0))
.Times(1)
@@ -309,6 +341,11 @@ const GLint GLES2DecoderTestBase::kMaxTextureSize;
const GLint GLES2DecoderTestBase::kMaxCubeMapTextureSize;
const GLint GLES2DecoderTestBase::kNumVertexAttribs;
const GLint GLES2DecoderTestBase::kNumTextureUnits;
+const GLint GLES2DecoderTestBase::kMaxTextureImageUnits;
+const GLint GLES2DecoderTestBase::kMaxVertexTextureImageUnits;
+const GLint GLES2DecoderTestBase::kMaxFragmentUniformVectors;
+const GLint GLES2DecoderTestBase::kMaxVaryingVectors;
+const GLint GLES2DecoderTestBase::kMaxVertexUniformVectors;
const GLuint GLES2DecoderTestBase::kServiceBlackTexture2dId;
const GLuint GLES2DecoderTestBase::kServiceBlackTextureCubemapId;
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 f18b598..e4e7be2 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h
@@ -42,6 +42,11 @@ class GLES2DecoderTestBase : public testing::Test {
static const GLint kMaxCubeMapTextureSize = 256;
static const GLint kNumVertexAttribs = 16;
static const GLint kNumTextureUnits = 8;
+ static const GLint kMaxTextureImageUnits = 8;
+ static const GLint kMaxVertexTextureImageUnits = 2;
+ static const GLint kMaxFragmentUniformVectors = 16;
+ static const GLint kMaxVaryingVectors = 8;
+ static const GLint kMaxVertexUniformVectors = 128;
static const GLuint kServiceBlackTexture2dId = 701;
static const GLuint kServiceBlackTextureCubemapId = 702;
diff --git a/gpu/command_buffer/service/shader_manager.h b/gpu/command_buffer/service/shader_manager.h
index caf41b4..3391ff6 100644
--- a/gpu/command_buffer/service/shader_manager.h
+++ b/gpu/command_buffer/service/shader_manager.h
@@ -30,7 +30,8 @@ class ShaderManager {
explicit ShaderInfo(GLuint service_id, GLenum shader_type)
: service_id_(service_id),
- shader_type_(shader_type) {
+ shader_type_(shader_type),
+ translation_valid_(true) {
}
void Update(const std::string& source) {
@@ -49,6 +50,19 @@ class ShaderManager {
return source_;
}
+ void SetTranslationStatus(bool valid, const std::string& log) {
+ translation_valid_ = valid;
+ translation_log_ = log;
+ }
+
+ const std::string& translation_log() const {
+ return translation_log_;
+ }
+
+ bool translation_valid() const {
+ return translation_valid_;
+ }
+
bool IsDeleted() const {
return service_id_ == 0;
}
@@ -67,8 +81,14 @@ class ShaderManager {
// Type of shader - GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
GLenum shader_type_;
+ // True if translation succeeded.
+ bool translation_valid_;
+
// The shader source as passed to glShaderSource.
std::string source_;
+
+ // The shader translation log.
+ std::string translation_log_;
};
ShaderManager() {
diff --git a/gpu/command_buffer/service/shader_manager_unittest.cc b/gpu/command_buffer/service/shader_manager_unittest.cc
index 70d733b..12ec9e4 100644
--- a/gpu/command_buffer/service/shader_manager_unittest.cc
+++ b/gpu/command_buffer/service/shader_manager_unittest.cc
@@ -37,6 +37,7 @@ TEST_F(ShaderManagerTest, Basic) {
EXPECT_EQ(kService1Id, info1->service_id());
// Check if the shader has correct type.
EXPECT_EQ(kShader1Type, info1->shader_type());
+ EXPECT_EQ(true, info1->translation_valid());
// Check we can set its source.
info1->Update(kClient1Source);
EXPECT_STREQ(kClient1Source.c_str(), info1->source().c_str());
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index b52d1fe..ef39e53 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -40,7 +40,6 @@
'command_buffer/service/texture_manager.h',
'command_buffer/service/texture_manager.cc',
],
- 'enable_shader_translation%': 0,
},
'targets': [
{
@@ -270,7 +269,9 @@
'../build/linux/system.gyp:gtk',
],
}],
- ['enable_shader_translation==1', {
+ # TODO(gman): Change this condition to be false if the backend is
+ # native OpenGL ES 2.0 and false if the backend is OpenGL.
+ ['1==1', {
'defines': [
'GLES2_GPU_SERVICE_TRANSLATE_SHADER',
],