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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 2674493003: Add compositor support for half-float RGBA buffers and textures (Closed)
Patch Set: Don't enable on non-ES3 yet Created 3 years, 10 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 | « cc/resources/resource_format_utils.cc ('k') | cc/resources/resource_provider_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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 GLenum TextureToStorageFormat(ResourceFormat format) { 81 GLenum TextureToStorageFormat(ResourceFormat format) {
82 GLenum storage_format = GL_RGBA8_OES; 82 GLenum storage_format = GL_RGBA8_OES;
83 switch (format) { 83 switch (format) {
84 case RGBA_8888: 84 case RGBA_8888:
85 break; 85 break;
86 case BGRA_8888: 86 case BGRA_8888:
87 storage_format = GL_BGRA8_EXT; 87 storage_format = GL_BGRA8_EXT;
88 break; 88 break;
89 case RGBA_F16:
90 storage_format = GL_RGBA16F_EXT;
91 break;
89 case RGBA_4444: 92 case RGBA_4444:
90 case ALPHA_8: 93 case ALPHA_8:
91 case LUMINANCE_8: 94 case LUMINANCE_8:
92 case RGB_565: 95 case RGB_565:
93 case ETC1: 96 case ETC1:
94 case RED_8: 97 case RED_8:
95 case LUMINANCE_F16: 98 case LUMINANCE_F16:
96 NOTREACHED(); 99 NOTREACHED();
97 break; 100 break;
98 } 101 }
99 102
100 return storage_format; 103 return storage_format;
101 } 104 }
102 105
103 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { 106 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) {
104 switch (format) { 107 switch (format) {
105 case RGBA_8888: 108 case RGBA_8888:
109 case RGBA_F16:
106 return true; 110 return true;
107 case BGRA_8888: 111 case BGRA_8888:
108 return use_bgra; 112 return use_bgra;
109 case RGBA_4444: 113 case RGBA_4444:
110 case ALPHA_8: 114 case ALPHA_8:
111 case LUMINANCE_8: 115 case LUMINANCE_8:
112 case RGB_565: 116 case RGB_565:
113 case ETC1: 117 case ETC1:
114 case RED_8: 118 case RED_8:
115 case LUMINANCE_F16: 119 case LUMINANCE_F16:
116 return false; 120 return false;
117 } 121 }
118 return false; 122 return false;
119 } 123 }
120 124
121 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { 125 GrPixelConfig ToGrPixelConfig(ResourceFormat format) {
122 switch (format) { 126 switch (format) {
123 case RGBA_8888: 127 case RGBA_8888:
124 return kRGBA_8888_GrPixelConfig; 128 return kRGBA_8888_GrPixelConfig;
125 case BGRA_8888: 129 case BGRA_8888:
126 return kBGRA_8888_GrPixelConfig; 130 return kBGRA_8888_GrPixelConfig;
127 case RGBA_4444: 131 case RGBA_4444:
128 return kRGBA_4444_GrPixelConfig; 132 return kRGBA_4444_GrPixelConfig;
133 case RGBA_F16:
134 return kRGBA_half_GrPixelConfig;
129 default: 135 default:
130 break; 136 break;
131 } 137 }
132 DCHECK(false) << "Unsupported resource format."; 138 DCHECK(false) << "Unsupported resource format.";
133 return kSkia8888_GrPixelConfig; 139 return kSkia8888_GrPixelConfig;
134 } 140 }
135 141
136 class ScopedSetActiveTexture { 142 class ScopedSetActiveTexture {
137 public: 143 public:
138 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) 144 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit)
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 case LUMINANCE_8: 536 case LUMINANCE_8:
531 return true; 537 return true;
532 case BGRA_8888: 538 case BGRA_8888:
533 return caps.texture_format_bgra8888; 539 return caps.texture_format_bgra8888;
534 case ETC1: 540 case ETC1:
535 return caps.texture_format_etc1; 541 return caps.texture_format_etc1;
536 case RED_8: 542 case RED_8:
537 return caps.texture_rg; 543 return caps.texture_rg;
538 case LUMINANCE_F16: 544 case LUMINANCE_F16:
539 return caps.texture_half_float_linear; 545 return caps.texture_half_float_linear;
546 case RGBA_F16:
547 // TODO(ccameron): This will always return false on pixel tests, which
548 // makes it un-test-able until we upgrade Mesa.
549 // https://crbug.com/687720
550 return caps.texture_half_float_linear && caps.color_buffer_float;
540 } 551 }
541 552
542 NOTREACHED(); 553 NOTREACHED();
543 return false; 554 return false;
544 } 555 }
545 556
546 bool ResourceProvider::InUseByConsumer(ResourceId id) { 557 bool ResourceProvider::InUseByConsumer(ResourceId id) {
547 Resource* resource = GetResource(id); 558 Resource* resource = GetResource(id);
548 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || 559 return resource->lock_for_read_count > 0 || resource->exported_count > 0 ||
549 resource->lost; 560 resource->lost;
(...skipping 19 matching lines...) Expand all
569 } 580 }
570 581
571 ResourceId ResourceProvider::CreateResource( 582 ResourceId ResourceProvider::CreateResource(
572 const gfx::Size& size, 583 const gfx::Size& size,
573 TextureHint hint, 584 TextureHint hint,
574 ResourceFormat format, 585 ResourceFormat format,
575 const gfx::ColorSpace& color_space) { 586 const gfx::ColorSpace& color_space) {
576 DCHECK(!size.IsEmpty()); 587 DCHECK(!size.IsEmpty());
577 switch (settings_.default_resource_type) { 588 switch (settings_.default_resource_type) {
578 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: 589 case RESOURCE_TYPE_GPU_MEMORY_BUFFER:
579 // GPU memory buffers don't support LUMINANCE_F16. 590 // GPU memory buffers don't support LUMINANCE_F16 or RGBA_F16 yet.
580 if (format != LUMINANCE_F16) { 591 if (format != LUMINANCE_F16 && format != RGBA_F16) {
581 return CreateGLTexture( 592 return CreateGLTexture(
582 size, hint, RESOURCE_TYPE_GPU_MEMORY_BUFFER, format, 593 size, hint, RESOURCE_TYPE_GPU_MEMORY_BUFFER, format,
583 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, color_space); 594 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, color_space);
584 } 595 }
585 // Fall through and use a regular texture. 596 // Fall through and use a regular texture.
586 case RESOURCE_TYPE_GL_TEXTURE: 597 case RESOURCE_TYPE_GL_TEXTURE:
587 return CreateGLTexture(size, hint, RESOURCE_TYPE_GL_TEXTURE, format, 598 return CreateGLTexture(size, hint, RESOURCE_TYPE_GL_TEXTURE, format,
588 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, 599 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE,
589 color_space); 600 color_space);
590 601
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 2174
2164 const int kImportance = 2; 2175 const int kImportance = 2;
2165 pmd->CreateSharedGlobalAllocatorDump(guid); 2176 pmd->CreateSharedGlobalAllocatorDump(guid);
2166 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2177 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2167 } 2178 }
2168 2179
2169 return true; 2180 return true;
2170 } 2181 }
2171 2182
2172 } // namespace cc 2183 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_format_utils.cc ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698