summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-13 08:12:28 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-13 08:12:28 +0000
commit2fe6c79fdf2d51e309bfd4d6a3b21cdf5442dc69 (patch)
treec099bef596ace5aa5a3459e1006bbf588c7c857d /gpu/command_buffer/service
parentb1d7db76383c55c7bff0551270d8fdd339f0bdec (diff)
downloadchromium_src-2fe6c79fdf2d51e309bfd4d6a3b21cdf5442dc69.zip
chromium_src-2fe6c79fdf2d51e309bfd4d6a3b21cdf5442dc69.tar.gz
chromium_src-2fe6c79fdf2d51e309bfd4d6a3b21cdf5442dc69.tar.bz2
Adds client side arrays
The code is conditional. I guess my gaming side spidey senses can't stand the overhead but I could be convinced to make it non-conditional. TEST=various unit tests BUG=none Review URL: http://codereview.chromium.org/1629004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44334 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
-rw-r--r--gpu/command_buffer/service/gl_interface.h3
-rw-r--r--gpu/command_buffer/service/gl_mock.h3
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc18
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_autogen.h28
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc55
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_1_autogen.h2
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_2_autogen.h3
7 files changed, 110 insertions, 2 deletions
diff --git a/gpu/command_buffer/service/gl_interface.h b/gpu/command_buffer/service/gl_interface.h
index 0629e20..fd934bf 100644
--- a/gpu/command_buffer/service/gl_interface.h
+++ b/gpu/command_buffer/service/gl_interface.h
@@ -400,6 +400,9 @@ class GLInterface {
virtual void SwapBuffers() = 0;
+ virtual GLuint GetMaxValueInBuffer(
+ GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) = 0;
+
private:
static GLInterface* interface_;
};
diff --git a/gpu/command_buffer/service/gl_mock.h b/gpu/command_buffer/service/gl_mock.h
index ca038bb..41be895 100644
--- a/gpu/command_buffer/service/gl_mock.h
+++ b/gpu/command_buffer/service/gl_mock.h
@@ -376,6 +376,9 @@ class MockGLInterface : public GLInterface {
MOCK_METHOD4(Viewport, void(GLint x, GLint y, GLsizei width, GLsizei height));
MOCK_METHOD0(SwapBuffers, void());
+
+ MOCK_METHOD4(GetMaxValueInBuffer, GLuint(
+ GLuint buffer_id, GLsizei count, GLenum type, GLuint offset));
};
} // namespace gles2
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 706407a..3d8b0af 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -679,6 +679,10 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
// Wrapper for DoGetIntegerv.
void DoGetIntegerv(GLenum pname, GLint* params);
+ // Gets the max value in a range in a buffer.
+ GLuint DoGetMaxValueInBuffer(
+ GLuint buffer_id, GLsizei count, GLenum type, GLuint offset);
+
// Wrapper for glRenderbufferParameteriv.
void DoGetRenderbufferParameteriv(
GLenum target, GLenum pname, GLint* params);
@@ -2354,6 +2358,20 @@ error::Error GLES2DecoderImpl::HandleDrawElements(
return error::kNoError;
}
+GLuint GLES2DecoderImpl::DoGetMaxValueInBuffer(
+ GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) {
+ GLuint max_vertex_accessed = 0;
+ BufferManager::BufferInfo* info = GetBufferInfo(buffer_id);
+ if (info->target() != GL_ELEMENT_ARRAY_BUFFER) {
+ SetGLError(GL_INVALID_OPERATION);
+ } else {
+ if (!info->GetMaxValueForRange(offset, count, type, &max_vertex_accessed)) {
+ SetGLError(GL_INVALID_OPERATION);
+ }
+ }
+ return max_vertex_accessed;
+}
+
// Calls glShaderSource for the various versions of the ShaderSource command.
// Assumes that data / data_size points to a piece of memory that is in range
// of whatever context it came from (shared memory, immediate memory, bucket
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
index 01e9dd2..0bda376 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_autogen.h
@@ -2828,5 +2828,33 @@ error::Error GLES2DecoderImpl::HandleViewport(
return error::kNoError;
}
+error::Error GLES2DecoderImpl::HandleGetMaxValueInBuffer(
+ uint32 immediate_data_size, const gles2::GetMaxValueInBuffer& c) {
+ GLuint buffer_id;
+ if (!id_manager()->GetServiceId(c.buffer_id, &buffer_id)) {
+ SetGLError(GL_INVALID_VALUE);
+ return error::kNoError;
+ }
+ GLsizei count = static_cast<GLsizei>(c.count);
+ GLenum type = static_cast<GLenum>(c.type);
+ GLuint offset = static_cast<GLuint>(c.offset);
+ typedef GetMaxValueInBuffer::Result Result;
+ Result* result_dst = GetSharedMemoryAs<Result*>(
+ c.result_shm_id, c.result_shm_offset, sizeof(*result_dst));
+ if (!result_dst) {
+ return error::kOutOfBounds;
+ }
+ if (count < 0) {
+ SetGLError(GL_INVALID_VALUE);
+ return error::kNoError;
+ }
+ if (!ValidateGLenumIndexType(type)) {
+ SetGLError(GL_INVALID_ENUM);
+ return error::kNoError;
+ }
+ *result_dst = DoGetMaxValueInBuffer(buffer_id, count, type, offset);
+ return error::kNoError;
+}
+
#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_AUTOGEN_H_
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index b916f8e..1f64b79 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -1885,6 +1885,61 @@ TEST_F(GLES2DecoderWithShaderTest, GetUniformLocationBucketInvalidArgs) {
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
}
+TEST_F(GLES2DecoderWithShaderTest, GetMaxValueInBuffer) {
+ SetupIndexBuffer();
+ GetMaxValueInBuffer::Result* result =
+ static_cast<GetMaxValueInBuffer::Result*>(shared_memory_address_);
+ *result = 0;
+
+ GetMaxValueInBuffer cmd;
+ cmd.Init(client_element_buffer_id_, kValidIndexRangeCount, GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(7u, *result);
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1,
+ GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(100u, *result);
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+
+ cmd.Init(kInvalidClientId, kValidIndexRangeCount,
+ GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
+ cmd.Init(client_element_buffer_id_, kOutOfRangeIndexRangeEnd,
+ GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+ cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1,
+ GL_UNSIGNED_SHORT,
+ kOutOfRangeIndexRangeEnd * 2, kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+ cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1,
+ GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ cmd.Init(client_buffer_id_, kValidIndexRangeCount + 1,
+ GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2, kSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
+ cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1,
+ GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2,
+ kInvalidSharedMemoryId, kSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+ cmd.Init(client_element_buffer_id_, kValidIndexRangeCount + 1,
+ GL_UNSIGNED_SHORT,
+ kValidIndexRangeStart * 2,
+ kSharedMemoryId, kInvalidSharedMemoryOffset);
+ EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
+}
+
// TODO(gman): BufferData
// TODO(gman): BufferDataImmediate
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 203ec06..c91acde 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
@@ -1851,5 +1851,7 @@ TEST_F(GLES2DecoderTest1, GetTexParameterivInvalidArgs2_1) {
}
// TODO(gman): GetUniformfv
+// TODO(gman): GetUniformiv
+
#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_1_AUTOGEN_H_
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 bdf34cf..64f1424 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
@@ -8,8 +8,6 @@
#ifndef GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_
#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_
-// TODO(gman): GetUniformiv
-
// TODO(gman): GetUniformLocation
// TODO(gman): GetUniformLocationImmediate
@@ -1635,5 +1633,6 @@ TEST_F(GLES2DecoderTest2, ViewportInvalidArgs3_0) {
EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
}
// TODO(gman): SwapBuffers
+// TODO(gman): GetMaxValueInBuffer
#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_DECODER_UNITTEST_2_AUTOGEN_H_