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

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

Issue 14402003: Add OES_texture_half_float extension support in Chromium for desktop GL implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove support for glReadPixels and update test cases Created 7 years, 7 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
« no previous file with comments | « no previous file | gpu/command_buffer/tests/gl_oes_texture_half_float_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 gl_internal_format = GL_ALPHA16F_ARB; 300 gl_internal_format = GL_ALPHA16F_ARB;
301 break; 301 break;
302 default: 302 default:
303 NOTREACHED(); 303 NOTREACHED();
304 break; 304 break;
305 } 305 }
306 } 306 }
307 return gl_internal_format; 307 return gl_internal_format;
308 } 308 }
309 309
310 static inline GLenum GetTexType(GLenum type) {
311 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
312 if (type == GL_HALF_FLOAT_OES)
313 return GL_HALF_FLOAT_ARB;
314 }
315 return type;
316 }
317
310 static void WrappedTexImage2D( 318 static void WrappedTexImage2D(
311 GLenum target, 319 GLenum target,
312 GLint level, 320 GLint level,
313 GLenum internal_format, 321 GLenum internal_format,
314 GLsizei width, 322 GLsizei width,
315 GLsizei height, 323 GLsizei height,
316 GLint border, 324 GLint border,
317 GLenum format, 325 GLenum format,
318 GLenum type, 326 GLenum type,
319 const void* pixels) { 327 const void* pixels) {
320 glTexImage2D( 328 glTexImage2D(
321 target, level, GetTexInternalFormat(internal_format, format, type), 329 target, level, GetTexInternalFormat(internal_format, format, type),
322 width, height, border, format, type, pixels); 330 width, height, border, format, GetTexType(type), pixels);
331 }
332
333 static void WrappedTexSubImage2D(
334 GLenum target,
335 GLint level,
336 GLint xoffset,
337 GLint yoffset,
338 GLsizei width,
339 GLsizei height,
340 GLenum format,
341 GLenum type,
342 const void * data) {
343 glTexSubImage2D(
344 target, level, xoffset, yoffset, width, height, format,
345 GetTexType(type), data);
323 } 346 }
324 347
325 // Wrapper for glEnable/glDisable that doesn't suck. 348 // Wrapper for glEnable/glDisable that doesn't suck.
326 static void EnableDisable(GLenum pname, bool enable) { 349 static void EnableDisable(GLenum pname, bool enable) {
327 if (enable) { 350 if (enable) {
328 glEnable(pname); 351 glEnable(pname);
329 } else { 352 } else {
330 glDisable(pname); 353 glDisable(pname);
331 } 354 }
332 } 355 }
(...skipping 7545 matching lines...) Expand 10 before | Expand all | Expand 10 after
7878 } 7901 }
7879 7902
7880 if (texture->IsAttachedToFramebuffer()) { 7903 if (texture->IsAttachedToFramebuffer()) {
7881 clear_state_dirty_ = true; 7904 clear_state_dirty_ = true;
7882 // TODO(gman): If textures tracked which framebuffers they were attached to 7905 // TODO(gman): If textures tracked which framebuffers they were attached to
7883 // we could just mark those framebuffers as not complete. 7906 // we could just mark those framebuffers as not complete.
7884 framebuffer_manager()->IncFramebufferStateChangeCount(); 7907 framebuffer_manager()->IncFramebufferStateChangeCount();
7885 } 7908 }
7886 7909
7887 if (!teximage2d_faster_than_texsubimage2d_ && level_is_same && pixels) { 7910 if (!teximage2d_faster_than_texsubimage2d_ && level_is_same && pixels) {
7888 glTexSubImage2D(target, level, 0, 0, width, height, format, type, pixels); 7911 WrappedTexSubImage2D(target, level, 0, 0, width, height, format,
7912 type, pixels);
7889 texture_manager()->SetLevelCleared(texture, target, level, true); 7913 texture_manager()->SetLevelCleared(texture, target, level, true);
7890 tex_image_2d_failed_ = false; 7914 tex_image_2d_failed_ = false;
7891 return; 7915 return;
7892 } 7916 }
7893 7917
7894 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glTexImage2D"); 7918 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glTexImage2D");
7895 WrappedTexImage2D( 7919 WrappedTexImage2D(
7896 target, level, internal_format, width, height, border, format, type, 7920 target, level, internal_format, width, height, border, format, type,
7897 pixels); 7921 pixels);
7898 GLenum error = LOCAL_PEEK_GL_ERROR("glTexImage2D"); 7922 GLenum error = LOCAL_PEEK_GL_ERROR("glTexImage2D");
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
8368 bool ok = texture->GetLevelSize(target, level, &tex_width, &tex_height); 8392 bool ok = texture->GetLevelSize(target, level, &tex_width, &tex_height);
8369 DCHECK(ok); 8393 DCHECK(ok);
8370 if (xoffset != 0 || yoffset != 0 || 8394 if (xoffset != 0 || yoffset != 0 ||
8371 width != tex_width || height != tex_height) { 8395 width != tex_width || height != tex_height) {
8372 if (!texture_manager()->ClearTextureLevel(this, texture, target, level)) { 8396 if (!texture_manager()->ClearTextureLevel(this, texture, target, level)) {
8373 LOCAL_SET_GL_ERROR( 8397 LOCAL_SET_GL_ERROR(
8374 GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big"); 8398 GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big");
8375 return error::kNoError; 8399 return error::kNoError;
8376 } 8400 }
8377 ScopedTextureUploadTimer timer(this); 8401 ScopedTextureUploadTimer timer(this);
8378 glTexSubImage2D( 8402 WrappedTexSubImage2D(
8379 target, level, xoffset, yoffset, width, height, format, type, data); 8403 target, level, xoffset, yoffset, width, height, format, type, data);
8380 return error::kNoError; 8404 return error::kNoError;
8381 } 8405 }
8382 8406
8383 if (teximage2d_faster_than_texsubimage2d_ && !texture->IsImmutable()) { 8407 if (teximage2d_faster_than_texsubimage2d_ && !texture->IsImmutable()) {
8384 ScopedTextureUploadTimer timer(this); 8408 ScopedTextureUploadTimer timer(this);
8385 // NOTE: In OpenGL ES 2.0 border is always zero and format is always the 8409 // NOTE: In OpenGL ES 2.0 border is always zero and format is always the
8386 // same as internal_foramt. If that changes we'll need to look them up. 8410 // same as internal_foramt. If that changes we'll need to look them up.
8387 WrappedTexImage2D( 8411 WrappedTexImage2D(
8388 target, level, format, width, height, 0, format, type, data); 8412 target, level, format, width, height, 0, format, type, data);
8389 } else { 8413 } else {
8390 ScopedTextureUploadTimer timer(this); 8414 ScopedTextureUploadTimer timer(this);
8391 glTexSubImage2D( 8415 WrappedTexSubImage2D(
8392 target, level, xoffset, yoffset, width, height, format, type, data); 8416 target, level, xoffset, yoffset, width, height, format, type, data);
8393 } 8417 }
8394 texture_manager()->SetLevelCleared(texture, target, level, true); 8418 texture_manager()->SetLevelCleared(texture, target, level, true);
8395 return error::kNoError; 8419 return error::kNoError;
8396 } 8420 }
8397 8421
8398 error::Error GLES2DecoderImpl::HandleTexSubImage2D( 8422 error::Error GLES2DecoderImpl::HandleTexSubImage2D(
8399 uint32 immediate_data_size, const cmds::TexSubImage2D& c) { 8423 uint32 immediate_data_size, const cmds::TexSubImage2D& c) {
8400 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexSubImage2D"); 8424 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexSubImage2D");
8401 GLboolean internal = static_cast<GLboolean>(c.internal); 8425 GLboolean internal = static_cast<GLboolean>(c.internal);
(...skipping 1861 matching lines...) Expand 10 before | Expand all | Expand 10 after
10263 // it might need to be duped to prevent use-after-free of the memory. 10287 // it might need to be duped to prevent use-after-free of the memory.
10264 gpu::Buffer buffer = GetSharedMemoryBuffer(c.pixels_shm_id); 10288 gpu::Buffer buffer = GetSharedMemoryBuffer(c.pixels_shm_id);
10265 base::SharedMemory* shared_memory = buffer.shared_memory; 10289 base::SharedMemory* shared_memory = buffer.shared_memory;
10266 uint32 shm_size = buffer.size; 10290 uint32 shm_size = buffer.size;
10267 uint32 shm_data_offset = c.pixels_shm_offset; 10291 uint32 shm_data_offset = c.pixels_shm_offset;
10268 uint32 shm_data_size = pixels_size; 10292 uint32 shm_data_size = pixels_size;
10269 10293
10270 // Setup the parameters. 10294 // Setup the parameters.
10271 GLenum gl_internal_format = 10295 GLenum gl_internal_format =
10272 GetTexInternalFormat(internal_format, format, type); 10296 GetTexInternalFormat(internal_format, format, type);
10297 GLenum gl_type = GetTexType(type);
greggman 2013/05/03 06:26:21 Hey Jun, Sorry about this but I just remembered th
10273 gfx::AsyncTexImage2DParams tex_params = {target, level, gl_internal_format, 10298 gfx::AsyncTexImage2DParams tex_params = {target, level, gl_internal_format,
10274 width, height, border, format, type}; 10299 width, height, border, format,
10300 gl_type};
10275 gfx::AsyncMemoryParams mem_params = {shared_memory, shm_size, 10301 gfx::AsyncMemoryParams mem_params = {shared_memory, shm_size,
10276 shm_data_offset, shm_data_size}; 10302 shm_data_offset, shm_data_size};
10277 10303
10278 // Set up the async state if needed, and make the texture 10304 // Set up the async state if needed, and make the texture
10279 // immutable so the async state stays valid. The level info 10305 // immutable so the async state stays valid. The level info
10280 // is set up lazily when the transfer completes. 10306 // is set up lazily when the transfer completes.
10281 DCHECK(!texture->GetAsyncTransferState()); 10307 DCHECK(!texture->GetAsyncTransferState());
10282 texture->SetAsyncTransferState( 10308 texture->SetAsyncTransferState(
10283 make_scoped_ptr( 10309 make_scoped_ptr(
10284 async_pixel_transfer_delegate_->CreatePixelTransferState( 10310 async_pixel_transfer_delegate_->CreatePixelTransferState(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
10353 10379
10354 // We know the memory/size is safe, so get the real shared memory since 10380 // We know the memory/size is safe, so get the real shared memory since
10355 // it might need to be duped to prevent use-after-free of the memory. 10381 // it might need to be duped to prevent use-after-free of the memory.
10356 gpu::Buffer buffer = GetSharedMemoryBuffer(c.data_shm_id); 10382 gpu::Buffer buffer = GetSharedMemoryBuffer(c.data_shm_id);
10357 base::SharedMemory* shared_memory = buffer.shared_memory; 10383 base::SharedMemory* shared_memory = buffer.shared_memory;
10358 uint32 shm_size = buffer.size; 10384 uint32 shm_size = buffer.size;
10359 uint32 shm_data_offset = c.data_shm_offset; 10385 uint32 shm_data_offset = c.data_shm_offset;
10360 uint32 shm_data_size = data_size; 10386 uint32 shm_data_size = data_size;
10361 10387
10362 // Setup the parameters. 10388 // Setup the parameters.
10389 GLenum gl_type = GetTexType(type);
10363 gfx::AsyncTexSubImage2DParams tex_params = {target, level, xoffset, yoffset, 10390 gfx::AsyncTexSubImage2DParams tex_params = {target, level, xoffset, yoffset,
10364 width, height, format, type}; 10391 width, height, format, gl_type};
10365 gfx::AsyncMemoryParams mem_params = {shared_memory, shm_size, 10392 gfx::AsyncMemoryParams mem_params = {shared_memory, shm_size,
10366 shm_data_offset, shm_data_size}; 10393 shm_data_offset, shm_data_size};
10367 if (!texture->GetAsyncTransferState()) { 10394 if (!texture->GetAsyncTransferState()) {
10368 // TODO(epenner): We may want to enforce exclusive use 10395 // TODO(epenner): We may want to enforce exclusive use
10369 // of async APIs in which case this should become an error, 10396 // of async APIs in which case this should become an error,
10370 // (the texture should have been async defined). 10397 // (the texture should have been async defined).
10371 gfx::AsyncTexImage2DParams define_params = {target, level, 10398 gfx::AsyncTexImage2DParams define_params = {target, level,
10372 0, 0, 0, 0, 0, 0}; 10399 0, 0, 0, 0, 0, 0};
10373 texture->GetLevelSize(target, level, &define_params.width, 10400 texture->GetLevelSize(target, level, &define_params.width,
10374 &define_params.height); 10401 &define_params.height);
10375 texture->GetLevelType(target, level, &define_params.type, 10402 texture->GetLevelType(target, level, &define_params.type,
10376 &define_params.internal_format); 10403 &define_params.internal_format);
10404
10405 // Update the internal_format and type for PixelTransferState if needed.
10406 define_params.internal_format =
10407 GetTexInternalFormat(define_params.internal_format,
10408 define_params.internal_format, type);
10409 define_params.type = GetTexType(define_params.type);
10410
10377 // Set up the async state if needed, and make the texture 10411 // Set up the async state if needed, and make the texture
10378 // immutable so the async state stays valid. 10412 // immutable so the async state stays valid.
10379 texture->SetAsyncTransferState( 10413 texture->SetAsyncTransferState(
10380 make_scoped_ptr( 10414 make_scoped_ptr(
10381 async_pixel_transfer_delegate_->CreatePixelTransferState( 10415 async_pixel_transfer_delegate_->CreatePixelTransferState(
10382 texture->service_id(), 10416 texture->service_id(),
10383 define_params))); 10417 define_params)));
10384 texture->SetImmutable(true); 10418 texture->SetImmutable(true);
10385 } 10419 }
10386 10420
(...skipping 25 matching lines...) Expand all
10412 return error::kNoError; 10446 return error::kNoError;
10413 } 10447 }
10414 10448
10415 // Include the auto-generated part of this file. We split this because it means 10449 // Include the auto-generated part of this file. We split this because it means
10416 // we can easily edit the non-auto generated parts right here in this file 10450 // we can easily edit the non-auto generated parts right here in this file
10417 // instead of having to edit some template or the code generator. 10451 // instead of having to edit some template or the code generator.
10418 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10452 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10419 10453
10420 } // namespace gles2 10454 } // namespace gles2
10421 } // namespace gpu 10455 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/tests/gl_oes_texture_half_float_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698