Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 299043003: Adding bindless variants mailbox produce/consume (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Addressed, added more tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 930
931 // Wrapper for TexStorage2DEXT. 931 // Wrapper for TexStorage2DEXT.
932 void DoTexStorage2DEXT( 932 void DoTexStorage2DEXT(
933 GLenum target, 933 GLenum target,
934 GLint levels, 934 GLint levels,
935 GLenum internal_format, 935 GLenum internal_format,
936 GLsizei width, 936 GLsizei width,
937 GLsizei height); 937 GLsizei height);
938 938
939 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); 939 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key);
940 void DoProduceTextureDirectCHROMIUM(GLuint texture, GLenum target,
941 const GLbyte* key);
942 void ProduceTextureRef(std::string func_name, TextureRef* texture_ref,
943 GLenum target, const GLbyte* data);
944
940 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); 945 void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key);
946 void DoCreateAndConsumeTextureCHROMIUM(GLenum target, const GLbyte* key,
947 GLuint client_id);
941 948
942 void DoBindTexImage2DCHROMIUM( 949 void DoBindTexImage2DCHROMIUM(
943 GLenum target, 950 GLenum target,
944 GLint image_id); 951 GLint image_id);
945 void DoReleaseTexImage2DCHROMIUM( 952 void DoReleaseTexImage2DCHROMIUM(
946 GLenum target, 953 GLenum target,
947 GLint image_id); 954 GLint image_id);
948 955
949 void DoTraceEndCHROMIUM(void); 956 void DoTraceEndCHROMIUM(void);
950 957
(...skipping 9222 matching lines...) Expand 10 before | Expand all | Expand 10 after
10173 uint32 immediate_data_size, const cmds::GenMailboxCHROMIUM& c) { 10180 uint32 immediate_data_size, const cmds::GenMailboxCHROMIUM& c) {
10174 return error::kUnknownCommand; 10181 return error::kUnknownCommand;
10175 } 10182 }
10176 10183
10177 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, 10184 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target,
10178 const GLbyte* data) { 10185 const GLbyte* data) {
10179 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM", 10186 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM",
10180 "context", logger_.GetLogPrefix(), 10187 "context", logger_.GetLogPrefix(),
10181 "mailbox[0]", static_cast<unsigned char>(data[0])); 10188 "mailbox[0]", static_cast<unsigned char>(data[0]));
10182 10189
10190 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
10191 &state_, target);
10192 ProduceTextureRef("glProduceTextureCHROMIUM", texture_ref, target, data);
10193 }
10194
10195 void GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM(GLuint client_id,
10196 GLenum target, const GLbyte* data) {
10197 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureDirectCHROMIUM",
10198 "context", logger_.GetLogPrefix(),
10199 "mailbox[0]", static_cast<unsigned char>(data[0]));
10200
10201 ProduceTextureRef("glProduceTextureDirectCHROMIUM", GetTexture(client_id),
10202 target, data);
10203 }
10204
10205 void GLES2DecoderImpl::ProduceTextureRef(std::string func_name,
10206 TextureRef* texture_ref, GLenum target, const GLbyte* data) {
10183 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); 10207 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data);
10184 DLOG_IF(ERROR, !mailbox.Verify()) << "ProduceTextureCHROMIUM was passed a " 10208 DLOG_IF(ERROR, !mailbox.Verify()) << func_name << " was passed a "
10185 "mailbox that was not generated by " 10209 "mailbox that was not generated by "
10186 "GenMailboxCHROMIUM."; 10210 "GenMailboxCHROMIUM.";
10187 10211
10188 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
10189 &state_, target);
10190 if (!texture_ref) { 10212 if (!texture_ref) {
10191 LOCAL_SET_GL_ERROR( 10213 LOCAL_SET_GL_ERROR(
10192 GL_INVALID_OPERATION, 10214 GL_INVALID_OPERATION, func_name.c_str(), "unknown texture for target");
10193 "glProduceTextureCHROMIUM", "unknown texture for target");
10194 return; 10215 return;
10195 } 10216 }
10196 10217
10197 Texture* produced = texture_manager()->Produce(texture_ref); 10218 Texture* produced = texture_manager()->Produce(texture_ref);
10198 if (!produced) { 10219 if (!produced) {
10199 LOCAL_SET_GL_ERROR( 10220 LOCAL_SET_GL_ERROR(
10200 GL_INVALID_OPERATION, 10221 GL_INVALID_OPERATION, func_name.c_str(), "invalid texture");
10201 "glProduceTextureCHROMIUM", "invalid texture");
10202 return; 10222 return;
10203 } 10223 }
10204 10224
10225 if (produced->target() != target) {
10226 LOCAL_SET_GL_ERROR(
10227 GL_INVALID_OPERATION, func_name.c_str(), "invalid target");
10228 return;
10229 }
10230
10205 group_->mailbox_manager()->ProduceTexture(target, mailbox, produced); 10231 group_->mailbox_manager()->ProduceTexture(target, mailbox, produced);
10206 } 10232 }
10207 10233
10208 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, 10234 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target,
10209 const GLbyte* data) { 10235 const GLbyte* data) {
10210 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", 10236 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM",
10211 "context", logger_.GetLogPrefix(), 10237 "context", logger_.GetLogPrefix(),
10212 "mailbox[0]", static_cast<unsigned char>(data[0])); 10238 "mailbox[0]", static_cast<unsigned char>(data[0]));
10213 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data); 10239 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data);
10214 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a " 10240 DLOG_IF(ERROR, !mailbox.Verify()) << "ConsumeTextureCHROMIUM was passed a "
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
10262 break; 10288 break;
10263 case GL_TEXTURE_RECTANGLE_ARB: 10289 case GL_TEXTURE_RECTANGLE_ARB:
10264 unit.bound_texture_rectangle_arb = texture_ref; 10290 unit.bound_texture_rectangle_arb = texture_ref;
10265 break; 10291 break;
10266 default: 10292 default:
10267 NOTREACHED(); // Validation should prevent us getting here. 10293 NOTREACHED(); // Validation should prevent us getting here.
10268 break; 10294 break;
10269 } 10295 }
10270 } 10296 }
10271 10297
10298 error::Error GLES2DecoderImpl::HandleCreateAndConsumeTextureCHROMIUMImmediate(
10299 uint32_t immediate_data_size,
10300 const gles2::cmds::CreateAndConsumeTextureCHROMIUMImmediate& c) {
10301 GLenum target = static_cast<GLenum>(c.target);
10302 uint32_t data_size;
10303 if (!ComputeDataSize(1, sizeof(GLbyte), 64, &data_size)) {
10304 return error::kOutOfBounds;
10305 }
10306 if (data_size > immediate_data_size) {
10307 return error::kOutOfBounds;
10308 }
10309 const GLbyte* mailbox =
10310 GetImmediateDataAs<const GLbyte*>(c, data_size, immediate_data_size);
10311 if (!validators_->texture_bind_target.IsValid(target)) {
10312 LOCAL_SET_GL_ERROR_INVALID_ENUM(
10313 "glCreateAndConsumeTextureCHROMIUM", target, "target");
10314 return error::kNoError;
10315 }
10316 if (mailbox == NULL) {
10317 return error::kOutOfBounds;
10318 }
10319 uint32_t client_id = c.client_id;
10320 DoCreateAndConsumeTextureCHROMIUM(target, mailbox, client_id);
10321 return error::kNoError;
10322 }
10323
10324 void GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM(GLenum target,
10325 const GLbyte* data, GLuint client_id) {
10326 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoCreateAndConsumeTextureCHROMIUM",
10327 "context", logger_.GetLogPrefix(),
10328 "mailbox[0]", static_cast<unsigned char>(data[0]));
10329 const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data);
10330 DLOG_IF(ERROR, !mailbox.Verify()) << "CreateAndConsumeTextureCHROMIUM was "
10331 "passed a mailbox that was not "
10332 "generated by GenMailboxCHROMIUM.";
10333
10334 TextureRef* texture_ref = GetTexture(client_id);
10335 if (texture_ref) {
10336 LOCAL_SET_GL_ERROR(
10337 GL_INVALID_OPERATION,
10338 "glCreateAndConsumeTextureCHROMIUM", "client id already in use");
10339 return;
10340 }
10341 Texture* texture = group_->mailbox_manager()->ConsumeTexture(target, mailbox);
10342 if (!texture) {
10343 LOCAL_SET_GL_ERROR(
10344 GL_INVALID_OPERATION,
10345 "glCreateAndConsumeTextureCHROMIUM", "invalid mailbox name");
10346 return;
10347 }
10348 if (texture->target() != target) {
10349 LOCAL_SET_GL_ERROR(
10350 GL_INVALID_OPERATION,
10351 "glCreateAndConsumeTextureCHROMIUM", "invalid target");
10352 return;
10353 }
10354
10355 IdAllocatorInterface* id_allocator =
10356 group_->GetIdAllocator(id_namespaces::kTextures);
10357 id_allocator->MarkAsUsed(client_id);
10358
10359 texture_ref = texture_manager()->Consume(client_id, texture);
10360 }
10361
10272 void GLES2DecoderImpl::DoInsertEventMarkerEXT( 10362 void GLES2DecoderImpl::DoInsertEventMarkerEXT(
10273 GLsizei length, const GLchar* marker) { 10363 GLsizei length, const GLchar* marker) {
10274 if (!marker) { 10364 if (!marker) {
10275 marker = ""; 10365 marker = "";
10276 } 10366 }
10277 debug_marker_manager_.SetMarker( 10367 debug_marker_manager_.SetMarker(
10278 length ? std::string(marker, length) : std::string(marker)); 10368 length ? std::string(marker, length) : std::string(marker));
10279 } 10369 }
10280 10370
10281 void GLES2DecoderImpl::DoPushGroupMarkerEXT( 10371 void GLES2DecoderImpl::DoPushGroupMarkerEXT(
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
10769 } 10859 }
10770 } 10860 }
10771 10861
10772 // Include the auto-generated part of this file. We split this because it means 10862 // Include the auto-generated part of this file. We split this because it means
10773 // we can easily edit the non-auto generated parts right here in this file 10863 // we can easily edit the non-auto generated parts right here in this file
10774 // instead of having to edit some template or the code generator. 10864 // instead of having to edit some template or the code generator.
10775 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10865 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10776 10866
10777 } // namespace gles2 10867 } // namespace gles2
10778 } // namespace gpu 10868 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698