| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 GLenum target, | 896 GLenum target, |
| 897 GLenum pname, | 897 GLenum pname, |
| 898 GLsizei bufsize, | 898 GLsizei bufsize, |
| 899 GLsizei* length, | 899 GLsizei* length, |
| 900 GLint* params) { | 900 GLint* params) { |
| 901 glGetBufferParameterivRobustANGLE(target, pname, bufsize, length, params); | 901 glGetBufferParameterivRobustANGLE(target, pname, bufsize, length, params); |
| 902 return error::kNoError; | 902 return error::kNoError; |
| 903 } | 903 } |
| 904 | 904 |
| 905 error::Error GLES2DecoderPassthroughImpl::DoGetError(uint32_t* result) { | 905 error::Error GLES2DecoderPassthroughImpl::DoGetError(uint32_t* result) { |
| 906 *result = glGetError(); | 906 FlushErrors(); |
| 907 *result = PopError(); |
| 907 return error::kNoError; | 908 return error::kNoError; |
| 908 } | 909 } |
| 909 | 910 |
| 910 error::Error GLES2DecoderPassthroughImpl::DoGetFloatv(GLenum pname, | 911 error::Error GLES2DecoderPassthroughImpl::DoGetFloatv(GLenum pname, |
| 911 GLsizei bufsize, | 912 GLsizei bufsize, |
| 912 GLsizei* length, | 913 GLsizei* length, |
| 913 GLfloat* params) { | 914 GLfloat* params) { |
| 914 glGetFloatvRobustANGLE(pname, bufsize, length, params); | 915 glGetFloatvRobustANGLE(pname, bufsize, length, params); |
| 915 return error::kNoError; | 916 return error::kNoError; |
| 916 } | 917 } |
| (...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2132 GLsizei n, | 2133 GLsizei n, |
| 2133 volatile GLuint* queries) { | 2134 volatile GLuint* queries) { |
| 2134 return GenHelper(n, queries, &query_id_map_, [](GLsizei n, GLuint* queries) { | 2135 return GenHelper(n, queries, &query_id_map_, [](GLsizei n, GLuint* queries) { |
| 2135 glGenQueries(n, queries); | 2136 glGenQueries(n, queries); |
| 2136 }); | 2137 }); |
| 2137 } | 2138 } |
| 2138 | 2139 |
| 2139 error::Error GLES2DecoderPassthroughImpl::DoDeleteQueriesEXT( | 2140 error::Error GLES2DecoderPassthroughImpl::DoDeleteQueriesEXT( |
| 2140 GLsizei n, | 2141 GLsizei n, |
| 2141 const volatile GLuint* queries) { | 2142 const volatile GLuint* queries) { |
| 2143 std::vector<GLuint> queries_copy(queries, queries + n); |
| 2144 // If any of these queries are pending or active, remove them from the lists |
| 2145 for (GLuint query_client_id : queries_copy) { |
| 2146 GLuint query_service_id = 0; |
| 2147 if (!query_id_map_.GetServiceID(query_client_id, &query_service_id) || |
| 2148 query_service_id == 0) { |
| 2149 continue; |
| 2150 } |
| 2151 |
| 2152 QueryInfo query_info = query_info_map_[query_service_id]; |
| 2153 query_info_map_.erase(query_service_id); |
| 2154 |
| 2155 if (query_info.type == GL_NONE) { |
| 2156 // Query was never started |
| 2157 continue; |
| 2158 } |
| 2159 |
| 2160 auto active_queries_iter = active_queries_.find(query_info.type); |
| 2161 if (active_queries_iter != active_queries_.end()) { |
| 2162 active_queries_.erase(active_queries_iter); |
| 2163 } |
| 2164 |
| 2165 auto pending_iter = |
| 2166 std::find_if(pending_queries_.begin(), pending_queries_.end(), |
| 2167 [query_service_id](const PendingQuery& pending_query) { |
| 2168 return pending_query.service_id == query_service_id; |
| 2169 }); |
| 2170 if (pending_iter != pending_queries_.end()) { |
| 2171 pending_queries_.erase(pending_iter); |
| 2172 } |
| 2173 } |
| 2142 return DeleteHelper( | 2174 return DeleteHelper( |
| 2143 n, queries, &query_id_map_, | 2175 queries_copy.size(), queries_copy.data(), &query_id_map_, |
| 2144 [](GLsizei n, GLuint* queries) { glDeleteQueries(n, queries); }); | 2176 [](GLsizei n, GLuint* queries) { glDeleteQueries(n, queries); }); |
| 2145 } | 2177 } |
| 2146 | 2178 |
| 2147 error::Error GLES2DecoderPassthroughImpl::DoQueryCounterEXT(GLuint id, | 2179 error::Error GLES2DecoderPassthroughImpl::DoQueryCounterEXT( |
| 2148 GLenum target) { | 2180 GLuint id, |
| 2149 glQueryCounter(GetQueryServiceID(id, &query_id_map_), target); | 2181 GLenum target, |
| 2182 int32_t sync_shm_id, |
| 2183 uint32_t sync_shm_offset, |
| 2184 uint32_t submit_count) { |
| 2185 GLuint service_id = GetQueryServiceID(id, &query_id_map_); |
| 2186 |
| 2187 // Flush all previous errors |
| 2188 FlushErrors(); |
| 2189 |
| 2190 glQueryCounter(service_id, target); |
| 2191 |
| 2192 // Check if a new error was generated |
| 2193 if (FlushErrors()) { |
| 2194 return error::kNoError; |
| 2195 } |
| 2196 |
| 2197 QueryInfo* query_info = &query_info_map_[service_id]; |
| 2198 query_info->type = target; |
| 2199 |
| 2200 PendingQuery pending_query; |
| 2201 pending_query.target = target; |
| 2202 pending_query.service_id = service_id; |
| 2203 pending_query.shm_id = sync_shm_id; |
| 2204 pending_query.shm_offset = sync_shm_offset; |
| 2205 pending_query.submit_count = submit_count; |
| 2206 pending_queries_.push_back(pending_query); |
| 2207 |
| 2208 return ProcessQueries(false); |
| 2209 } |
| 2210 |
| 2211 error::Error GLES2DecoderPassthroughImpl::DoBeginQueryEXT( |
| 2212 GLenum target, |
| 2213 GLuint id, |
| 2214 int32_t sync_shm_id, |
| 2215 uint32_t sync_shm_offset) { |
| 2216 GLuint service_id = GetQueryServiceID(id, &query_id_map_); |
| 2217 QueryInfo* query_info = &query_info_map_[service_id]; |
| 2218 |
| 2219 if (IsEmulatedQueryTarget(target)) { |
| 2220 if (active_queries_.find(target) != active_queries_.end()) { |
| 2221 InsertError(GL_INVALID_OPERATION, "Query already active on target."); |
| 2222 return error::kNoError; |
| 2223 } |
| 2224 |
| 2225 if (id == 0) { |
| 2226 InsertError(GL_INVALID_OPERATION, "Query id is 0."); |
| 2227 return error::kNoError; |
| 2228 } |
| 2229 |
| 2230 if (query_info->type != GL_NONE && query_info->type != target) { |
| 2231 InsertError(GL_INVALID_OPERATION, |
| 2232 "Query type does not match the target."); |
| 2233 return error::kNoError; |
| 2234 } |
| 2235 } else { |
| 2236 // Flush all previous errors |
| 2237 FlushErrors(); |
| 2238 |
| 2239 glBeginQuery(target, service_id); |
| 2240 |
| 2241 // Check if a new error was generated |
| 2242 if (FlushErrors()) { |
| 2243 return error::kNoError; |
| 2244 } |
| 2245 } |
| 2246 |
| 2247 query_info->type = target; |
| 2248 |
| 2249 ActiveQuery query; |
| 2250 query.service_id = service_id; |
| 2251 query.shm_id = sync_shm_id; |
| 2252 query.shm_offset = sync_shm_offset; |
| 2253 active_queries_[target] = query; |
| 2254 |
| 2150 return error::kNoError; | 2255 return error::kNoError; |
| 2151 } | 2256 } |
| 2152 | 2257 |
| 2153 error::Error GLES2DecoderPassthroughImpl::DoBeginQueryEXT(GLenum target, | |
| 2154 GLuint id) { | |
| 2155 // TODO(geofflang): Track active queries | |
| 2156 glBeginQuery(target, GetQueryServiceID(id, &query_id_map_)); | |
| 2157 return error::kNoError; | |
| 2158 } | |
| 2159 | |
| 2160 error::Error GLES2DecoderPassthroughImpl::DoBeginTransformFeedback( | 2258 error::Error GLES2DecoderPassthroughImpl::DoBeginTransformFeedback( |
| 2161 GLenum primitivemode) { | 2259 GLenum primitivemode) { |
| 2162 glBeginTransformFeedback(primitivemode); | 2260 glBeginTransformFeedback(primitivemode); |
| 2163 return error::kNoError; | 2261 return error::kNoError; |
| 2164 } | 2262 } |
| 2165 | 2263 |
| 2166 error::Error GLES2DecoderPassthroughImpl::DoEndQueryEXT(GLenum target) { | 2264 error::Error GLES2DecoderPassthroughImpl::DoEndQueryEXT(GLenum target, |
| 2167 // TODO(geofflang): Track active queries | 2265 uint32_t submit_count) { |
| 2168 glEndQuery(target); | 2266 if (IsEmulatedQueryTarget(target)) { |
| 2169 return error::kNoError; | 2267 if (active_queries_.find(target) == active_queries_.end()) { |
| 2268 InsertError(GL_INVALID_OPERATION, "No active query on target."); |
| 2269 return error::kNoError; |
| 2270 } |
| 2271 } else { |
| 2272 // Flush all previous errors |
| 2273 FlushErrors(); |
| 2274 |
| 2275 glEndQuery(target); |
| 2276 |
| 2277 // Check if a new error was generated |
| 2278 if (FlushErrors()) { |
| 2279 return error::kNoError; |
| 2280 } |
| 2281 } |
| 2282 |
| 2283 DCHECK(active_queries_.find(target) != active_queries_.end()); |
| 2284 ActiveQuery active_query = active_queries_[target]; |
| 2285 active_queries_.erase(target); |
| 2286 |
| 2287 PendingQuery pending_query; |
| 2288 pending_query.target = target; |
| 2289 pending_query.service_id = active_query.service_id; |
| 2290 pending_query.shm_id = active_query.shm_id; |
| 2291 pending_query.shm_offset = active_query.shm_offset; |
| 2292 pending_query.submit_count = submit_count; |
| 2293 pending_queries_.push_back(pending_query); |
| 2294 |
| 2295 return ProcessQueries(false); |
| 2170 } | 2296 } |
| 2171 | 2297 |
| 2172 error::Error GLES2DecoderPassthroughImpl::DoEndTransformFeedback() { | 2298 error::Error GLES2DecoderPassthroughImpl::DoEndTransformFeedback() { |
| 2173 glEndTransformFeedback(); | 2299 glEndTransformFeedback(); |
| 2174 return error::kNoError; | 2300 return error::kNoError; |
| 2175 } | 2301 } |
| 2176 | 2302 |
| 2177 error::Error GLES2DecoderPassthroughImpl::DoSetDisjointValueSyncCHROMIUM( | 2303 error::Error GLES2DecoderPassthroughImpl::DoSetDisjointValueSyncCHROMIUM( |
| 2178 DisjointValueSync* sync) { | 2304 DisjointValueSync* sync) { |
| 2179 NOTIMPLEMENTED(); | 2305 NOTIMPLEMENTED(); |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3030 GLES2DecoderPassthroughImpl::DoUniformMatrix4fvStreamTextureMatrixCHROMIUM( | 3156 GLES2DecoderPassthroughImpl::DoUniformMatrix4fvStreamTextureMatrixCHROMIUM( |
| 3031 GLint location, | 3157 GLint location, |
| 3032 GLboolean transpose, | 3158 GLboolean transpose, |
| 3033 const volatile GLfloat* defaultValue) { | 3159 const volatile GLfloat* defaultValue) { |
| 3034 NOTIMPLEMENTED(); | 3160 NOTIMPLEMENTED(); |
| 3035 return error::kNoError; | 3161 return error::kNoError; |
| 3036 } | 3162 } |
| 3037 | 3163 |
| 3038 } // namespace gles2 | 3164 } // namespace gles2 |
| 3039 } // namespace gpu | 3165 } // namespace gpu |
| OLD | NEW |