summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-24 21:54:25 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-24 21:54:25 +0000
commita51788ec675f333ebd4b33934f2cc467f518c4e0 (patch)
treefb1cb19fe2cd1c91b40934655b9fc67f65aba453 /gpu/command_buffer/service
parent097f2995f157a8f8130aa930533d75d743d3a7f9 (diff)
downloadchromium_src-a51788ec675f333ebd4b33934f2cc467f518c4e0.zip
chromium_src-a51788ec675f333ebd4b33934f2cc467f518c4e0.tar.gz
chromium_src-a51788ec675f333ebd4b33934f2cc467f518c4e0.tar.bz2
Fixes ReadPixel to have a result so the client
side can know if it should or should not copy the results. This is the way the spec is. If ReadPixels fails it's not supposed to modify client side memory. Unfortunately that makes it slow because it stalls the GPU pipeline 3 times. The service side has to call glGetError to save up any current errors. That's one stall. Then it calls ReadPixels, another stall, finally calls glGetError a 3rd time to see if ReadPixels succeeded so that it can tell the client side implementation of ReadPixels whether or not to copy memory. We could decide to change the behavior of ReadPixels so it always copies. That wouldn't be spec complient but suspect most developers never expect it to fail and don't count on it not always writing to their memory. TEST=none BUG=none Review URL: http://codereview.chromium.org/652213 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39930 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index df18f39..c018356 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1942,19 +1942,31 @@ error::Error GLES2DecoderImpl::HandleReadPixels(
GLsizei height = c.height;
GLenum format = c.format;
GLenum type = c.type;
+ // TODO(gman): Handle out of range rectangles.
+ typedef gles2::ReadPixels::Result Result;
uint32 pixels_size = GLES2Util::ComputeImageDataSize(
width, height, format, type, pack_alignment_);
void* pixels = GetSharedMemoryAs<void*>(
c.pixels_shm_id, c.pixels_shm_offset, pixels_size);
- if (!pixels) {
+ Result* result = GetSharedMemoryAs<Result*>(
+ c.result_shm_id, c.result_shm_offset, sizeof(*result));
+ if (!pixels || !result) {
return error::kOutOfBounds;
}
+
if (!ValidateGLenumReadPixelFormat(format) ||
!ValidateGLenumPixelType(type)) {
SetGLError(GL_INVALID_VALUE);
return error::kNoError;
}
+ CopyRealGLErrorsToWrapper();
glReadPixels(x, y, width, height, format, type, pixels);
+ GLenum error = glGetError();
+ if (error == GL_NO_ERROR) {
+ *result = true;
+ } else {
+ SetGLError(error);
+ }
return error::kNoError;
}