| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 } | 2229 } |
| 2230 | 2230 |
| 2231 if (bound_pixel_pack_transfer_buffer_id_) { | 2231 if (bound_pixel_pack_transfer_buffer_id_) { |
| 2232 GLuint offset = ToGLuint(pixels); | 2232 GLuint offset = ToGLuint(pixels); |
| 2233 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( | 2233 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( |
| 2234 bound_pixel_pack_transfer_buffer_id_, | 2234 bound_pixel_pack_transfer_buffer_id_, |
| 2235 "glReadPixels", offset, padded_row_size * height); | 2235 "glReadPixels", offset, padded_row_size * height); |
| 2236 if (buffer && buffer->shm_id() != -1) { | 2236 if (buffer && buffer->shm_id() != -1) { |
| 2237 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, | 2237 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, |
| 2238 buffer->shm_id(), buffer->shm_offset(), | 2238 buffer->shm_id(), buffer->shm_offset(), |
| 2239 0, 0); | 2239 0, 0, true); |
| 2240 buffer->set_transfer_ready_token(helper_->InsertToken()); | |
| 2241 CheckGLError(); | 2240 CheckGLError(); |
| 2242 } | 2241 } |
| 2243 return; | 2242 return; |
| 2244 } | 2243 } |
| 2245 | 2244 |
| 2246 if (!pixels) { | 2245 if (!pixels) { |
| 2247 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL"); | 2246 SetGLError(GL_INVALID_OPERATION, "glReadPixels", "pixels = NULL"); |
| 2248 return; | 2247 return; |
| 2249 } | 2248 } |
| 2250 | 2249 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2262 // NOTE: We must look up the address of the result area AFTER allocation | 2261 // NOTE: We must look up the address of the result area AFTER allocation |
| 2263 // of the transfer buffer since the transfer buffer may be reallocated. | 2262 // of the transfer buffer since the transfer buffer may be reallocated. |
| 2264 Result* result = GetResultAs<Result*>(); | 2263 Result* result = GetResultAs<Result*>(); |
| 2265 if (!result) { | 2264 if (!result) { |
| 2266 return; | 2265 return; |
| 2267 } | 2266 } |
| 2268 *result = 0; // mark as failed. | 2267 *result = 0; // mark as failed. |
| 2269 helper_->ReadPixels( | 2268 helper_->ReadPixels( |
| 2270 xoffset, yoffset, width, num_rows, format, type, | 2269 xoffset, yoffset, width, num_rows, format, type, |
| 2271 buffer.shm_id(), buffer.offset(), | 2270 buffer.shm_id(), buffer.offset(), |
| 2272 GetResultShmId(), GetResultShmOffset()); | 2271 GetResultShmId(), GetResultShmOffset(), |
| 2272 false); |
| 2273 WaitForCmd(); | 2273 WaitForCmd(); |
| 2274 if (*result != 0) { | 2274 if (*result != 0) { |
| 2275 // when doing a y-flip we have to iterate through top-to-bottom chunks | 2275 // when doing a y-flip we have to iterate through top-to-bottom chunks |
| 2276 // of the dst. The service side handles reversing the rows within a | 2276 // of the dst. The service side handles reversing the rows within a |
| 2277 // chunk. | 2277 // chunk. |
| 2278 int8* rows_dst; | 2278 int8* rows_dst; |
| 2279 if (pack_reverse_row_order_) { | 2279 if (pack_reverse_row_order_) { |
| 2280 rows_dst = dest + (height - num_rows) * padded_row_size; | 2280 rows_dst = dest + (height - num_rows) * padded_row_size; |
| 2281 } else { | 2281 } else { |
| 2282 rows_dst = dest; | 2282 rows_dst = dest; |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3168 GLsizei n, const GLuint* queries) { | 3168 GLsizei n, const GLuint* queries) { |
| 3169 // TODO(gman): Remove this as queries are not shared resources. | 3169 // TODO(gman): Remove this as queries are not shared resources. |
| 3170 if (!GetIdHandler(id_namespaces::kQueries)->FreeIds( | 3170 if (!GetIdHandler(id_namespaces::kQueries)->FreeIds( |
| 3171 this, n, queries, &GLES2Implementation::DeleteQueriesStub)) { | 3171 this, n, queries, &GLES2Implementation::DeleteQueriesStub)) { |
| 3172 SetGLError( | 3172 SetGLError( |
| 3173 GL_INVALID_VALUE, | 3173 GL_INVALID_VALUE, |
| 3174 "glDeleteTextures", "id not created by this context."); | 3174 "glDeleteTextures", "id not created by this context."); |
| 3175 return; | 3175 return; |
| 3176 } | 3176 } |
| 3177 // When you delete a query you can't mark its memory as unused until it's | 3177 // When you delete a query you can't mark its memory as unused until it's |
| 3178 // completed. | 3178 // either completed, or deleted in the gpu process. |
| 3179 // Note: If you don't do this you won't mess up the service but you will mess | 3179 // Note: If you don't do this you won't mess up the service but you will mess |
| 3180 // up yourself. | 3180 // up yourself. |
| 3181 | 3181 |
| 3182 // TODO(gman): Consider making this faster by putting pending quereies | |
| 3183 // on some queue to be removed when they are finished. | |
| 3184 bool query_pending = false; | 3182 bool query_pending = false; |
| 3185 for (GLsizei ii = 0; ii < n; ++ii) { | 3183 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3186 QueryTracker::Query* query = query_tracker_->GetQuery(queries[ii]); | 3184 QueryTracker::Query* query = query_tracker_->GetQuery(queries[ii]); |
| 3187 if (query && query->Pending()) { | 3185 if (query && !query->CheckResultsAvailable(helper_)) { |
| 3188 query_pending = true; | 3186 query_pending = true; |
| 3189 break; | 3187 break; |
| 3190 } | 3188 } |
| 3191 } | 3189 } |
| 3192 | 3190 |
| 3191 helper_->DeleteQueriesEXTImmediate(n, queries); |
| 3192 |
| 3193 if (query_pending) { | 3193 if (query_pending) { |
| 3194 // This should make sure that the GPU process have deleted the queries |
| 3195 // and given up any claim on the shared memory that goes along with |
| 3196 // those queries so that we can safely re-use the shared memory. |
| 3194 WaitForCmd(); | 3197 WaitForCmd(); |
| 3195 } | 3198 } |
| 3196 | 3199 |
| 3197 for (GLsizei ii = 0; ii < n; ++ii) { | 3200 for (GLsizei ii = 0; ii < n; ++ii) { |
| 3198 QueryTracker::Query* query = query_tracker_->GetQuery(queries[ii]); | |
| 3199 if (query && query->Pending()) { | |
| 3200 if (!query->CheckResultsAvailable(helper_)) { | |
| 3201 // Should only get here on context lost. | |
| 3202 MustBeContextLost(); | |
| 3203 } | |
| 3204 } | |
| 3205 query_tracker_->RemoveQuery(queries[ii], helper_->IsContextLost()); | 3201 query_tracker_->RemoveQuery(queries[ii], helper_->IsContextLost()); |
| 3206 } | 3202 } |
| 3207 helper_->DeleteQueriesEXTImmediate(n, queries); | |
| 3208 } | 3203 } |
| 3209 | 3204 |
| 3210 // TODO(gman): Remove this. Queries are not shared resources. | 3205 // TODO(gman): Remove this. Queries are not shared resources. |
| 3211 void GLES2Implementation::DeleteQueriesStub( | 3206 void GLES2Implementation::DeleteQueriesStub( |
| 3212 GLsizei /* n */, const GLuint* /* queries */) { | 3207 GLsizei /* n */, const GLuint* /* queries */) { |
| 3213 } | 3208 } |
| 3214 | 3209 |
| 3215 GLboolean GLES2Implementation::IsQueryEXT(GLuint id) { | 3210 GLboolean GLES2Implementation::IsQueryEXT(GLuint id) { |
| 3216 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3211 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 3217 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] IsQueryEXT(" << id << ")"); | 3212 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] IsQueryEXT(" << id << ")"); |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3851 CheckGLError(); | 3846 CheckGLError(); |
| 3852 } | 3847 } |
| 3853 | 3848 |
| 3854 // Include the auto-generated part of this file. We split this because it means | 3849 // Include the auto-generated part of this file. We split this because it means |
| 3855 // we can easily edit the non-auto generated parts right here in this file | 3850 // we can easily edit the non-auto generated parts right here in this file |
| 3856 // instead of having to edit some template or the code generator. | 3851 // instead of having to edit some template or the code generator. |
| 3857 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 3852 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 3858 | 3853 |
| 3859 } // namespace gles2 | 3854 } // namespace gles2 |
| 3860 } // namespace gpu | 3855 } // namespace gpu |
| OLD | NEW |