| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 | 8 |
| 9 namespace gpu { | 9 namespace gpu { |
| 10 namespace gles2 { | 10 namespace gles2 { |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 | 689 |
| 690 error::Error GLES2DecoderPassthroughImpl::DoFenceSync(GLenum condition, | 690 error::Error GLES2DecoderPassthroughImpl::DoFenceSync(GLenum condition, |
| 691 GLbitfield flags, | 691 GLbitfield flags, |
| 692 GLuint client_id) { | 692 GLuint client_id) { |
| 693 NOTIMPLEMENTED(); | 693 NOTIMPLEMENTED(); |
| 694 return error::kNoError; | 694 return error::kNoError; |
| 695 } | 695 } |
| 696 | 696 |
| 697 error::Error GLES2DecoderPassthroughImpl::DoFinish() { | 697 error::Error GLES2DecoderPassthroughImpl::DoFinish() { |
| 698 glFinish(); | 698 glFinish(); |
| 699 return error::kNoError; | 699 return ProcessQueries(true); |
| 700 } | 700 } |
| 701 | 701 |
| 702 error::Error GLES2DecoderPassthroughImpl::DoFlush() { | 702 error::Error GLES2DecoderPassthroughImpl::DoFlush() { |
| 703 glFlush(); | 703 glFlush(); |
| 704 return error::kNoError; | 704 return ProcessQueries(false); |
| 705 } | 705 } |
| 706 | 706 |
| 707 error::Error GLES2DecoderPassthroughImpl::DoFlushMappedBufferRange( | 707 error::Error GLES2DecoderPassthroughImpl::DoFlushMappedBufferRange( |
| 708 GLenum target, | 708 GLenum target, |
| 709 GLintptr offset, | 709 GLintptr offset, |
| 710 GLsizeiptr size) { | 710 GLsizeiptr size) { |
| 711 return error::kNoError; | 711 return error::kNoError; |
| 712 } | 712 } |
| 713 | 713 |
| 714 error::Error GLES2DecoderPassthroughImpl::DoFramebufferRenderbuffer( | 714 error::Error GLES2DecoderPassthroughImpl::DoFramebufferRenderbuffer( |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 GLenum target, | 899 GLenum target, |
| 900 GLenum pname, | 900 GLenum pname, |
| 901 GLsizei bufsize, | 901 GLsizei bufsize, |
| 902 GLsizei* length, | 902 GLsizei* length, |
| 903 GLint* params) { | 903 GLint* params) { |
| 904 glGetBufferParameterivRobustANGLE(target, pname, bufsize, length, params); | 904 glGetBufferParameterivRobustANGLE(target, pname, bufsize, length, params); |
| 905 return error::kNoError; | 905 return error::kNoError; |
| 906 } | 906 } |
| 907 | 907 |
| 908 error::Error GLES2DecoderPassthroughImpl::DoGetError(uint32_t* result) { | 908 error::Error GLES2DecoderPassthroughImpl::DoGetError(uint32_t* result) { |
| 909 *result = glGetError(); | 909 FlushErrors(); |
| 910 *result = PopError(); |
| 910 return error::kNoError; | 911 return error::kNoError; |
| 911 } | 912 } |
| 912 | 913 |
| 913 error::Error GLES2DecoderPassthroughImpl::DoGetFloatv(GLenum pname, | 914 error::Error GLES2DecoderPassthroughImpl::DoGetFloatv(GLenum pname, |
| 914 GLsizei bufsize, | 915 GLsizei bufsize, |
| 915 GLsizei* length, | 916 GLsizei* length, |
| 916 GLfloat* params) { | 917 GLfloat* params) { |
| 917 return GetNumericHelper( | 918 return GetNumericHelper( |
| 918 pname, bufsize, length, params, | 919 pname, bufsize, length, params, |
| 919 [](GLenum pname, GLsizei bufsize, GLsizei* length, GLfloat* params) { | 920 [](GLenum pname, GLsizei bufsize, GLsizei* length, GLfloat* params) { |
| (...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2159 GLsizei n, | 2160 GLsizei n, |
| 2160 volatile GLuint* queries) { | 2161 volatile GLuint* queries) { |
| 2161 return GenHelper(n, queries, &query_id_map_, [](GLsizei n, GLuint* queries) { | 2162 return GenHelper(n, queries, &query_id_map_, [](GLsizei n, GLuint* queries) { |
| 2162 glGenQueries(n, queries); | 2163 glGenQueries(n, queries); |
| 2163 }); | 2164 }); |
| 2164 } | 2165 } |
| 2165 | 2166 |
| 2166 error::Error GLES2DecoderPassthroughImpl::DoDeleteQueriesEXT( | 2167 error::Error GLES2DecoderPassthroughImpl::DoDeleteQueriesEXT( |
| 2167 GLsizei n, | 2168 GLsizei n, |
| 2168 const volatile GLuint* queries) { | 2169 const volatile GLuint* queries) { |
| 2170 std::vector<GLuint> queries_copy(queries, queries + n); |
| 2171 // If any of these queries are pending or active, remove them from the lists |
| 2172 for (GLuint query_client_id : queries_copy) { |
| 2173 GLuint query_service_id = 0; |
| 2174 if (!query_id_map_.GetServiceID(query_client_id, &query_service_id) || |
| 2175 query_service_id == 0) { |
| 2176 continue; |
| 2177 } |
| 2178 |
| 2179 QueryInfo query_info = query_info_map_[query_service_id]; |
| 2180 query_info_map_.erase(query_service_id); |
| 2181 |
| 2182 if (query_info.type == GL_NONE) { |
| 2183 // Query was never started |
| 2184 continue; |
| 2185 } |
| 2186 |
| 2187 auto active_queries_iter = active_queries_.find(query_info.type); |
| 2188 if (active_queries_iter != active_queries_.end()) { |
| 2189 active_queries_.erase(active_queries_iter); |
| 2190 } |
| 2191 |
| 2192 auto pending_iter = |
| 2193 std::find_if(pending_queries_.begin(), pending_queries_.end(), |
| 2194 [query_service_id](const PendingQuery& pending_query) { |
| 2195 return pending_query.service_id == query_service_id; |
| 2196 }); |
| 2197 if (pending_iter != pending_queries_.end()) { |
| 2198 pending_queries_.erase(pending_iter); |
| 2199 } |
| 2200 } |
| 2169 return DeleteHelper( | 2201 return DeleteHelper( |
| 2170 n, queries, &query_id_map_, | 2202 queries_copy.size(), queries_copy.data(), &query_id_map_, |
| 2171 [](GLsizei n, GLuint* queries) { glDeleteQueries(n, queries); }); | 2203 [](GLsizei n, GLuint* queries) { glDeleteQueries(n, queries); }); |
| 2172 } | 2204 } |
| 2173 | 2205 |
| 2174 error::Error GLES2DecoderPassthroughImpl::DoQueryCounterEXT(GLuint id, | 2206 error::Error GLES2DecoderPassthroughImpl::DoQueryCounterEXT( |
| 2175 GLenum target) { | 2207 GLuint id, |
| 2176 glQueryCounter(GetQueryServiceID(id, &query_id_map_), target); | 2208 GLenum target, |
| 2209 int32_t sync_shm_id, |
| 2210 uint32_t sync_shm_offset, |
| 2211 uint32_t submit_count) { |
| 2212 GLuint service_id = GetQueryServiceID(id, &query_id_map_); |
| 2213 |
| 2214 // Flush all previous errors |
| 2215 FlushErrors(); |
| 2216 |
| 2217 glQueryCounter(service_id, target); |
| 2218 |
| 2219 // Check if a new error was generated |
| 2220 if (FlushErrors()) { |
| 2221 return error::kNoError; |
| 2222 } |
| 2223 |
| 2224 QueryInfo* query_info = &query_info_map_[service_id]; |
| 2225 query_info->type = target; |
| 2226 |
| 2227 PendingQuery pending_query; |
| 2228 pending_query.target = target; |
| 2229 pending_query.service_id = service_id; |
| 2230 pending_query.shm_id = sync_shm_id; |
| 2231 pending_query.shm_offset = sync_shm_offset; |
| 2232 pending_query.submit_count = submit_count; |
| 2233 pending_queries_.push_back(pending_query); |
| 2234 |
| 2235 return ProcessQueries(false); |
| 2236 } |
| 2237 |
| 2238 error::Error GLES2DecoderPassthroughImpl::DoBeginQueryEXT( |
| 2239 GLenum target, |
| 2240 GLuint id, |
| 2241 int32_t sync_shm_id, |
| 2242 uint32_t sync_shm_offset) { |
| 2243 GLuint service_id = GetQueryServiceID(id, &query_id_map_); |
| 2244 QueryInfo* query_info = &query_info_map_[service_id]; |
| 2245 |
| 2246 if (IsEmulatedQueryTarget(target)) { |
| 2247 if (active_queries_.find(target) != active_queries_.end()) { |
| 2248 InsertError(GL_INVALID_OPERATION, "Query already active on target."); |
| 2249 return error::kNoError; |
| 2250 } |
| 2251 |
| 2252 if (id == 0) { |
| 2253 InsertError(GL_INVALID_OPERATION, "Query id is 0."); |
| 2254 return error::kNoError; |
| 2255 } |
| 2256 |
| 2257 if (query_info->type != GL_NONE && query_info->type != target) { |
| 2258 InsertError(GL_INVALID_OPERATION, |
| 2259 "Query type does not match the target."); |
| 2260 return error::kNoError; |
| 2261 } |
| 2262 } else { |
| 2263 // Flush all previous errors |
| 2264 FlushErrors(); |
| 2265 |
| 2266 glBeginQuery(target, service_id); |
| 2267 |
| 2268 // Check if a new error was generated |
| 2269 if (FlushErrors()) { |
| 2270 return error::kNoError; |
| 2271 } |
| 2272 } |
| 2273 |
| 2274 query_info->type = target; |
| 2275 |
| 2276 ActiveQuery query; |
| 2277 query.service_id = service_id; |
| 2278 query.shm_id = sync_shm_id; |
| 2279 query.shm_offset = sync_shm_offset; |
| 2280 active_queries_[target] = query; |
| 2281 |
| 2177 return error::kNoError; | 2282 return error::kNoError; |
| 2178 } | 2283 } |
| 2179 | 2284 |
| 2180 error::Error GLES2DecoderPassthroughImpl::DoBeginQueryEXT(GLenum target, | |
| 2181 GLuint id) { | |
| 2182 // TODO(geofflang): Track active queries | |
| 2183 glBeginQuery(target, GetQueryServiceID(id, &query_id_map_)); | |
| 2184 return error::kNoError; | |
| 2185 } | |
| 2186 | |
| 2187 error::Error GLES2DecoderPassthroughImpl::DoBeginTransformFeedback( | 2285 error::Error GLES2DecoderPassthroughImpl::DoBeginTransformFeedback( |
| 2188 GLenum primitivemode) { | 2286 GLenum primitivemode) { |
| 2189 glBeginTransformFeedback(primitivemode); | 2287 glBeginTransformFeedback(primitivemode); |
| 2190 return error::kNoError; | 2288 return error::kNoError; |
| 2191 } | 2289 } |
| 2192 | 2290 |
| 2193 error::Error GLES2DecoderPassthroughImpl::DoEndQueryEXT(GLenum target) { | 2291 error::Error GLES2DecoderPassthroughImpl::DoEndQueryEXT(GLenum target, |
| 2194 // TODO(geofflang): Track active queries | 2292 uint32_t submit_count) { |
| 2195 glEndQuery(target); | 2293 if (IsEmulatedQueryTarget(target)) { |
| 2196 return error::kNoError; | 2294 if (active_queries_.find(target) == active_queries_.end()) { |
| 2295 InsertError(GL_INVALID_OPERATION, "No active query on target."); |
| 2296 return error::kNoError; |
| 2297 } |
| 2298 } else { |
| 2299 // Flush all previous errors |
| 2300 FlushErrors(); |
| 2301 |
| 2302 glEndQuery(target); |
| 2303 |
| 2304 // Check if a new error was generated |
| 2305 if (FlushErrors()) { |
| 2306 return error::kNoError; |
| 2307 } |
| 2308 } |
| 2309 |
| 2310 DCHECK(active_queries_.find(target) != active_queries_.end()); |
| 2311 ActiveQuery active_query = active_queries_[target]; |
| 2312 active_queries_.erase(target); |
| 2313 |
| 2314 PendingQuery pending_query; |
| 2315 pending_query.target = target; |
| 2316 pending_query.service_id = active_query.service_id; |
| 2317 pending_query.shm_id = active_query.shm_id; |
| 2318 pending_query.shm_offset = active_query.shm_offset; |
| 2319 pending_query.submit_count = submit_count; |
| 2320 pending_queries_.push_back(pending_query); |
| 2321 |
| 2322 return ProcessQueries(false); |
| 2197 } | 2323 } |
| 2198 | 2324 |
| 2199 error::Error GLES2DecoderPassthroughImpl::DoEndTransformFeedback() { | 2325 error::Error GLES2DecoderPassthroughImpl::DoEndTransformFeedback() { |
| 2200 glEndTransformFeedback(); | 2326 glEndTransformFeedback(); |
| 2201 return error::kNoError; | 2327 return error::kNoError; |
| 2202 } | 2328 } |
| 2203 | 2329 |
| 2204 error::Error GLES2DecoderPassthroughImpl::DoSetDisjointValueSyncCHROMIUM( | 2330 error::Error GLES2DecoderPassthroughImpl::DoSetDisjointValueSyncCHROMIUM( |
| 2205 DisjointValueSync* sync) { | 2331 DisjointValueSync* sync) { |
| 2206 NOTIMPLEMENTED(); | 2332 NOTIMPLEMENTED(); |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3057 GLES2DecoderPassthroughImpl::DoUniformMatrix4fvStreamTextureMatrixCHROMIUM( | 3183 GLES2DecoderPassthroughImpl::DoUniformMatrix4fvStreamTextureMatrixCHROMIUM( |
| 3058 GLint location, | 3184 GLint location, |
| 3059 GLboolean transpose, | 3185 GLboolean transpose, |
| 3060 const volatile GLfloat* defaultValue) { | 3186 const volatile GLfloat* defaultValue) { |
| 3061 NOTIMPLEMENTED(); | 3187 NOTIMPLEMENTED(); |
| 3062 return error::kNoError; | 3188 return error::kNoError; |
| 3063 } | 3189 } |
| 3064 | 3190 |
| 3065 } // namespace gles2 | 3191 } // namespace gles2 |
| 3066 } // namespace gpu | 3192 } // namespace gpu |
| OLD | NEW |