| Flutter Impeller |

texture_gles.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "impeller/renderer/backend/gles/texture_gles.h"
6
7 #include <optional>
8 #include <utility>
9
10 #include "flutter/fml/logging.h"
11 #include "flutter/fml/mapping.h"
12 #include "flutter/fml/trace_event.h"
13 #include "impeller/base/allocation.h"
14 #include "impeller/base/strings.h"
15 #include "impeller/base/validation.h"
16 #include "impeller/core/formats.h"
17 #include "impeller/core/texture_descriptor.h"
18 #include "impeller/renderer/backend/gles/formats_gles.h"
19
20 namespace impeller {
21
22 namespace {
23 static bool IsDepthStencilFormat(PixelFormat format) {
24 switch (format) {
25 case PixelFormat::kS8UInt:
26 case PixelFormat::kD24UnormS8Uint:
27 case PixelFormat::kD32FloatS8UInt:
28 return true;
29 case PixelFormat::kUnknown:
30 case PixelFormat::kA8UNormInt:
31 case PixelFormat::kR8UNormInt:
32 case PixelFormat::kR8G8UNormInt:
33 case PixelFormat::kR8G8B8A8UNormInt:
34 case PixelFormat::kR8G8B8A8UNormIntSRGB:
35 case PixelFormat::kB8G8R8A8UNormInt:
36 case PixelFormat::kB8G8R8A8UNormIntSRGB:
37 case PixelFormat::kR32G32B32A32Float:
38 case PixelFormat::kR16G16B16A16Float:
39 case PixelFormat::kB10G10R10XR:
40 case PixelFormat::kB10G10R10XRSRGB:
41 case PixelFormat::kB10G10R10A10XR:
42 return false;
43 }
44 FML_UNREACHABLE();
45 }
46
47 static TextureGLES::Type GetTextureTypeFromDescriptor(
48 const TextureDescriptor& desc,
49 const std::shared_ptr<const CapabilitiesGLES>& capabilities) {
50 const auto usage = static_cast<TextureUsageMask>(desc.usage);
51 const auto render_target = TextureUsage::kRenderTarget;
52 const auto is_msaa = desc.sample_count == SampleCount::kCount4;
53 if (usage == render_target && IsDepthStencilFormat(desc.format)) {
54 return is_msaa ? TextureGLES::Type::kRenderBufferMultisampled
55 : TextureGLES::Type::kRenderBuffer;
56 }
57 return is_msaa ? (capabilities->SupportsImplicitResolvingMSAA()
58 ? TextureGLES::Type::kTextureMultisampled
59 : TextureGLES::Type::kRenderBufferMultisampled)
60 : TextureGLES::Type::kTexture;
61 }
62
63 struct TexImage2DData {
64 GLint internal_format = 0;
65 GLenum external_format = GL_NONE;
66 GLenum type = GL_NONE;
67 std::shared_ptr<const fml::Mapping> data;
68
69 explicit TexImage2DData(PixelFormat pixel_format) {
70 switch (pixel_format) {
71 case PixelFormat::kA8UNormInt:
72 internal_format = GL_ALPHA;
73 external_format = GL_ALPHA;
74 type = GL_UNSIGNED_BYTE;
75 break;
76 case PixelFormat::kR8UNormInt:
77 internal_format = GL_RED;
78 external_format = GL_RED;
79 type = GL_UNSIGNED_BYTE;
80 break;
81 case PixelFormat::kR8G8B8A8UNormInt:
82 case PixelFormat::kB8G8R8A8UNormInt:
83 case PixelFormat::kR8G8B8A8UNormIntSRGB:
84 case PixelFormat::kB8G8R8A8UNormIntSRGB:
85 internal_format = GL_RGBA;
86 external_format = GL_RGBA;
87 type = GL_UNSIGNED_BYTE;
88 break;
89 case PixelFormat::kR32G32B32A32Float:
90 internal_format = GL_RGBA;
91 external_format = GL_RGBA;
92 type = GL_FLOAT;
93 break;
94 case PixelFormat::kR16G16B16A16Float:
95 internal_format = GL_RGBA;
96 external_format = GL_RGBA;
97 type = GL_HALF_FLOAT;
98 break;
99 case PixelFormat::kS8UInt:
100 // Pure stencil textures are only available in OpenGL 4.4+, which is
101 // ~0% of mobile devices. Instead, we use a depth-stencil texture and
102 // only use the stencil component.
103 //
104 // https://registry.khronos.org/OpenGL-Refpages/gl4/html/glTexImage2D.xhtml
105 case PixelFormat::kD24UnormS8Uint:
106 internal_format = GL_DEPTH_STENCIL;
107 external_format = GL_DEPTH_STENCIL;
108 type = GL_UNSIGNED_INT_24_8;
109 break;
110 case PixelFormat::kUnknown:
111 case PixelFormat::kD32FloatS8UInt:
112 case PixelFormat::kR8G8UNormInt:
113 case PixelFormat::kB10G10R10XRSRGB:
114 case PixelFormat::kB10G10R10XR:
115 case PixelFormat::kB10G10R10A10XR:
116 return;
117 }
118 is_valid_ = true;
119 }
120
121 TexImage2DData(PixelFormat pixel_format,
122 std::shared_ptr<const fml::Mapping> mapping)
123 : TexImage2DData(pixel_format) {
124 data = std::move(mapping);
125 }
126
127 bool IsValid() const { return is_valid_; }
128
129 private:
130 bool is_valid_ = false;
131 };
132 } // namespace
133
134 HandleType ToHandleType(TextureGLES::Type type) {
135 switch (type) {
136 case TextureGLES::Type::kTexture:
137 case TextureGLES::Type::kTextureMultisampled:
138 return HandleType::kTexture;
139 case TextureGLES::Type::kRenderBuffer:
140 case TextureGLES::Type::kRenderBufferMultisampled:
141 return HandleType::kRenderBuffer;
142 }
143 FML_UNREACHABLE();
144 }
145
146 std::shared_ptr<TextureGLES> TextureGLES::WrapFBO(
147 std::shared_ptr<ReactorGLES> reactor,
148 TextureDescriptor desc,
149 GLuint fbo) {
150 auto texture = std::shared_ptr<TextureGLES>(
151 new TextureGLES(std::move(reactor), desc, fbo, std::nullopt));
152 if (!texture->IsValid()) {
153 return nullptr;
154 }
155 return texture;
156 }
157
158 std::shared_ptr<TextureGLES> TextureGLES::WrapTexture(
159 std::shared_ptr<ReactorGLES> reactor,
160 TextureDescriptor desc,
161 HandleGLES external_handle) {
162 if (external_handle.IsDead()) {
163 VALIDATION_LOG << "Cannot wrap a dead handle.";
164 return nullptr;
165 }
166 if (external_handle.GetType() != HandleType::kTexture) {
167 VALIDATION_LOG << "Cannot wrap a non-texture handle.";
168 return nullptr;
169 }
170 auto texture = std::shared_ptr<TextureGLES>(
171 new TextureGLES(std::move(reactor), desc, std::nullopt, external_handle));
172 if (!texture->IsValid()) {
173 return nullptr;
174 }
175 return texture;
176 }
177
178 std::shared_ptr<TextureGLES> TextureGLES::CreatePlaceholder(
179 std::shared_ptr<ReactorGLES> reactor,
180 TextureDescriptor desc) {
181 return TextureGLES::WrapFBO(std::move(reactor), desc, 0u);
182 }
183
184 TextureGLES::TextureGLES(std::shared_ptr<ReactorGLES> reactor,
185 TextureDescriptor desc)
186 : TextureGLES(std::move(reactor), //
187 desc, //
188 std::nullopt, //
189 std::nullopt //
190 ) {}
191
192 TextureGLES::TextureGLES(std::shared_ptr<ReactorGLES> reactor,
193 TextureDescriptor desc,
194 std::optional<GLuint> fbo,
195 std::optional<HandleGLES> external_handle)
196 : Texture(desc),
197 reactor_(std::move(reactor)),
198 type_(GetTextureTypeFromDescriptor(
199 GetTextureDescriptor(),
200 reactor_->GetProcTable().GetCapabilities())),
201 handle_(external_handle.has_value()
202 ? external_handle.value()
203 : reactor_->CreateUntrackedHandle(ToHandleType(type_))),
204 is_wrapped_(fbo.has_value() || external_handle.has_value()),
205 wrapped_fbo_(fbo) {
206 // Ensure the texture descriptor itself is valid.
207 if (!GetTextureDescriptor().IsValid()) {
208 VALIDATION_LOG << "Invalid texture descriptor.";
209 return;
210 }
211 // Ensure the texture doesn't exceed device capabilities.
212 const auto tex_size = GetTextureDescriptor().size;
213 const auto max_size =
214 reactor_->GetProcTable().GetCapabilities()->max_texture_size;
215 if (tex_size.Max(max_size) != max_size) {
216 VALIDATION_LOG << "Texture of size " << tex_size
217 << " would exceed max supported size of " << max_size << ".";
218 return;
219 }
220
221 is_valid_ = true;
222 }
223
224 // |Texture|
225 TextureGLES::~TextureGLES() {
226 reactor_->CollectHandle(handle_);
227 if (!cached_fbo_.IsDead()) {
228 reactor_->CollectHandle(cached_fbo_);
229 }
230 }
231
232 // |Texture|
233 bool TextureGLES::IsValid() const {
234 return is_valid_;
235 }
236
237 // |Texture|
238 void TextureGLES::SetLabel(std::string_view label) {
239 #ifdef IMPELLER_DEBUG
240 reactor_->SetDebugLabel(handle_, label);
241 #endif // IMPELLER_DEBUG
242 }
243
244 // |Texture|
245 void TextureGLES::SetLabel(std::string_view label, std::string_view trailing) {
246 #ifdef IMPELLER_DEBUG
247 if (reactor_->CanSetDebugLabels()) {
248 reactor_->SetDebugLabel(handle_,
249 SPrintF("%s %s", label.data(), trailing.data()));
250 }
251 #endif // IMPELLER_DEBUG
252 }
253
254 // |Texture|
255 bool TextureGLES::OnSetContents(const uint8_t* contents,
256 size_t length,
257 size_t slice) {
258 return OnSetContents(CreateMappingWithCopy(contents, Bytes{length}), slice);
259 }
260
261 // |Texture|
262 bool TextureGLES::OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
263 size_t slice) {
264 if (!mapping) {
265 return false;
266 }
267
268 if (mapping->GetSize() == 0u) {
269 return true;
270 }
271
272 if (mapping->GetMapping() == nullptr) {
273 return false;
274 }
275
276 if (GetType() != Type::kTexture) {
277 VALIDATION_LOG << "Incorrect texture usage flags for setting contents on "
278 "this texture object.";
279 return false;
280 }
281
282 if (is_wrapped_) {
283 VALIDATION_LOG << "Cannot set the contents of a wrapped texture.";
284 return false;
285 }
286
287 const auto& tex_descriptor = GetTextureDescriptor();
288
289 if (tex_descriptor.size.IsEmpty()) {
290 return true;
291 }
292
293 if (!tex_descriptor.IsValid() ||
294 mapping->GetSize() < tex_descriptor.GetByteSizeOfBaseMipLevel()) {
295 return false;
296 }
297
298 GLenum texture_type;
299 GLenum texture_target;
300 switch (tex_descriptor.type) {
301 case TextureType::kTexture2D:
302 texture_type = GL_TEXTURE_2D;
303 texture_target = GL_TEXTURE_2D;
304 break;
305 case TextureType::kTexture2DMultisample:
306 VALIDATION_LOG << "Multisample texture uploading is not supported for "
307 "the OpenGLES backend.";
308 return false;
309 case TextureType::kTextureCube:
310 texture_type = GL_TEXTURE_CUBE_MAP;
311 texture_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + slice;
312 break;
313 case TextureType::kTextureExternalOES:
314 texture_type = GL_TEXTURE_EXTERNAL_OES;
315 texture_target = GL_TEXTURE_EXTERNAL_OES;
316 break;
317 }
318
319 auto data = std::make_shared<TexImage2DData>(tex_descriptor.format,
320 std::move(mapping));
321 if (!data || !data->IsValid()) {
322 VALIDATION_LOG << "Invalid texture format.";
323 return false;
324 }
325
326 ReactorGLES::Operation texture_upload = [handle = handle_, //
327 data, //
328 size = tex_descriptor.size, //
329 texture_type, //
330 texture_target //
331 ](const auto& reactor) {
332 auto gl_handle = reactor.GetGLHandle(handle);
333 if (!gl_handle.has_value()) {
334 VALIDATION_LOG
335 << "Texture was collected before it could be uploaded to the GPU.";
336 return;
337 }
338 const auto& gl = reactor.GetProcTable();
339 gl.BindTexture(texture_type, gl_handle.value());
340 const GLvoid* tex_data = nullptr;
341 if (data->data) {
342 tex_data = data->data->GetMapping();
343 }
344
345 {
346 TRACE_EVENT1("impeller", "TexImage2DUpload", "Bytes",
347 std::to_string(data->data->GetSize()).c_str());
348 gl.PixelStorei(GL_UNPACK_ALIGNMENT, 1);
349 gl.TexImage2D(texture_target, // target
350 0u, // LOD level
351 data->internal_format, // internal format
352 size.width, // width
353 size.height, // height
354 0u, // border
355 data->external_format, // external format
356 data->type, // type
357 tex_data // data
358 );
359 }
360 };
361
362 slices_initialized_ = reactor_->AddOperation(texture_upload);
363 return slices_initialized_[0];
364 }
365
366 // |Texture|
367 ISize TextureGLES::GetSize() const {
368 return GetTextureDescriptor().size;
369 }
370
371 static std::optional<GLenum> ToRenderBufferFormat(PixelFormat format) {
372 switch (format) {
373 case PixelFormat::kB8G8R8A8UNormInt:
374 case PixelFormat::kR8G8B8A8UNormInt:
375 return GL_RGBA8;
376 case PixelFormat::kR32G32B32A32Float:
377 return GL_RGBA32F;
378 case PixelFormat::kR16G16B16A16Float:
379 return GL_RGBA16F;
380 case PixelFormat::kS8UInt:
381 return GL_STENCIL_INDEX8;
382 case PixelFormat::kD24UnormS8Uint:
383 return GL_DEPTH24_STENCIL8;
384 case PixelFormat::kD32FloatS8UInt:
385 return GL_DEPTH32F_STENCIL8;
386 case PixelFormat::kUnknown:
387 case PixelFormat::kA8UNormInt:
388 case PixelFormat::kR8UNormInt:
389 case PixelFormat::kR8G8UNormInt:
390 case PixelFormat::kR8G8B8A8UNormIntSRGB:
391 case PixelFormat::kB8G8R8A8UNormIntSRGB:
392 case PixelFormat::kB10G10R10XRSRGB:
393 case PixelFormat::kB10G10R10XR:
394 case PixelFormat::kB10G10R10A10XR:
395 return std::nullopt;
396 }
397 FML_UNREACHABLE();
398 }
399
400 TextureGLES::Type TextureGLES::ComputeTypeForBinding(GLenum target) const {
401 // When binding to a GL_READ_FRAMEBUFFER, any multisampled
402 // textures must be bound as single sampled.
403 if (target == GL_READ_FRAMEBUFFER && type_ == Type::kTextureMultisampled) {
404 return Type::kTexture;
405 }
406 return type_;
407 }
408
409 void TextureGLES::InitializeContentsIfNecessary() const {
410 if (!IsValid() || slices_initialized_[0]) {
411 return;
412 }
413 slices_initialized_[0] = true;
414
415 if (is_wrapped_) {
416 return;
417 }
418
419 auto size = GetSize();
420
421 if (size.IsEmpty()) {
422 return;
423 }
424
425 const auto& gl = reactor_->GetProcTable();
426 std::optional<GLuint> handle = reactor_->GetGLHandle(handle_);
427 if (!handle.has_value()) {
428 VALIDATION_LOG << "Could not initialize the contents of texture.";
429 return;
430 }
431
432 switch (type_) {
433 case Type::kTexture:
434 case Type::kTextureMultisampled: {
435 TexImage2DData tex_data(GetTextureDescriptor().format);
436 if (!tex_data.IsValid()) {
437 VALIDATION_LOG << "Invalid format for texture image.";
438 return;
439 }
440 gl.BindTexture(GL_TEXTURE_2D, handle.value());
441 {
442 TRACE_EVENT0("impeller", "TexImage2DInitialization");
443 gl.TexImage2D(GL_TEXTURE_2D, // target
444 0u, // LOD level (base mip level size checked)
445 tex_data.internal_format, // internal format
446 size.width, // width
447 size.height, // height
448 0u, // border
449 tex_data.external_format, // format
450 tex_data.type, // type
451 nullptr // data
452 );
453 }
454 } break;
455 case Type::kRenderBuffer:
456 case Type::kRenderBufferMultisampled: {
457 auto render_buffer_format =
458 ToRenderBufferFormat(GetTextureDescriptor().format);
459 if (!render_buffer_format.has_value()) {
460 VALIDATION_LOG << "Invalid format for render-buffer image.";
461 return;
462 }
463 gl.BindRenderbuffer(GL_RENDERBUFFER, handle.value());
464 {
465 if (type_ == Type::kRenderBufferMultisampled) {
466 // BEWARE: these functions are not at all equivalent! the extensions
467 // are from EXT_multisampled_render_to_texture and cannot be used
468 // with regular GLES 3.0 multisampled renderbuffers/textures.
469 if (gl.GetCapabilities()->SupportsImplicitResolvingMSAA()) {
470 gl.RenderbufferStorageMultisampleEXT(
471 /*target=*/GL_RENDERBUFFER, //
472 /*samples=*/4, //
473 /*internal_format=*/render_buffer_format.value(), //
474 /*width=*/size.width, //
475 /*height=*/size.height //
476 );
477 } else {
478 gl.RenderbufferStorageMultisample(
479 /*target=*/GL_RENDERBUFFER, //
480 /*samples=*/4, //
481 /*internal_format=*/render_buffer_format.value(), //
482 /*width=*/size.width, //
483 /*height=*/size.height //
484 );
485 }
486 } else {
487 gl.RenderbufferStorage(
488 /*target=*/GL_RENDERBUFFER, //
489 /*internal_format=*/render_buffer_format.value(), //
490 /*width=*/size.width, //
491 /*height=*/size.height //
492 );
493 }
494 }
495 } break;
496 }
497 }
498
499 std::optional<GLuint> TextureGLES::GetGLHandle() const {
500 if (!IsValid()) {
501 return std::nullopt;
502 }
503 return reactor_->GetGLHandle(handle_);
504 }
505
506 bool TextureGLES::Bind() const {
507 auto handle = GetGLHandle();
508 if (!handle.has_value()) {
509 return false;
510 }
511 const auto& gl = reactor_->GetProcTable();
512
513 if (fence_.has_value()) {
514 std::optional<GLsync> fence = reactor_->GetGLFence(fence_.value());
515 if (fence.has_value()) {
516 gl.WaitSync(fence.value(), 0, GL_TIMEOUT_IGNORED);
517 }
518 reactor_->CollectHandle(fence_.value());
519 fence_ = std::nullopt;
520 }
521
522 switch (type_) {
523 case Type::kTexture:
524 case Type::kTextureMultisampled: {
525 const auto target = ToTextureTarget(GetTextureDescriptor().type);
526 if (!target.has_value()) {
527 VALIDATION_LOG << "Could not bind texture of this type.";
528 return false;
529 }
530 gl.BindTexture(target.value(), handle.value());
531 } break;
532 case Type::kRenderBuffer:
533 case Type::kRenderBufferMultisampled:
534 gl.BindRenderbuffer(GL_RENDERBUFFER, handle.value());
535 break;
536 }
537 InitializeContentsIfNecessary();
538 return true;
539 }
540
541 void TextureGLES::MarkContentsInitialized() {
542 for (size_t i = 0; i < slices_initialized_.size(); i++) {
543 slices_initialized_[i] = true;
544 }
545 }
546
547 void TextureGLES::MarkSliceInitialized(size_t slice) const {
548 slices_initialized_[slice] = true;
549 }
550
551 bool TextureGLES::IsSliceInitialized(size_t slice) const {
552 return slices_initialized_[slice];
553 }
554
555 bool TextureGLES::GenerateMipmap() {
556 if (!IsValid()) {
557 return false;
558 }
559
560 auto type = GetTextureDescriptor().type;
561 switch (type) {
562 case TextureType::kTexture2D:
563 break;
564 case TextureType::kTexture2DMultisample:
565 VALIDATION_LOG << "Generating mipmaps for multisample textures is not "
566 "supported in the GLES backend.";
567 return false;
568 case TextureType::kTextureCube:
569 break;
570 case TextureType::kTextureExternalOES:
571 break;
572 }
573
574 if (!Bind()) {
575 return false;
576 }
577
578 auto handle = GetGLHandle();
579 if (!handle.has_value()) {
580 return false;
581 }
582
583 const auto& gl = reactor_->GetProcTable();
584 gl.GenerateMipmap(ToTextureType(type));
585 mipmap_generated_ = true;
586 return true;
587 }
588
589 TextureGLES::Type TextureGLES::GetType() const {
590 return type_;
591 }
592
593 static GLenum ToAttachmentType(TextureGLES::AttachmentType point) {
594 switch (point) {
595 case TextureGLES::AttachmentType::kColor0:
596 return GL_COLOR_ATTACHMENT0;
597 case TextureGLES::AttachmentType::kDepth:
598 return GL_DEPTH_ATTACHMENT;
599 case TextureGLES::AttachmentType::kStencil:
600 return GL_STENCIL_ATTACHMENT;
601 }
602 }
603
604 bool TextureGLES::SetAsFramebufferAttachment(
605 GLenum target,
606 AttachmentType attachment_type) const {
607 if (!IsValid()) {
608 return false;
609 }
610 InitializeContentsIfNecessary();
611 auto handle = GetGLHandle();
612 if (!handle.has_value()) {
613 return false;
614 }
615 const auto& gl = reactor_->GetProcTable();
616
617 switch (ComputeTypeForBinding(target)) {
618 case Type::kTexture:
619 gl.FramebufferTexture2D(target, // target
620 ToAttachmentType(attachment_type), // attachment
621 GL_TEXTURE_2D, // textarget
622 handle.value(), // texture
623 0 // level
624 );
625 break;
626 case Type::kTextureMultisampled:
627 gl.FramebufferTexture2DMultisampleEXT(
628 target, // target
629 ToAttachmentType(attachment_type), // attachment
630 GL_TEXTURE_2D, // textarget
631 handle.value(), // texture
632 0, // level
633 4 // samples
634 );
635 break;
636 case Type::kRenderBuffer:
637 case Type::kRenderBufferMultisampled:
638 gl.FramebufferRenderbuffer(
639 target, // target
640 ToAttachmentType(attachment_type), // attachment
641 GL_RENDERBUFFER, // render-buffer target
642 handle.value() // render-buffer
643 );
644 break;
645 }
646
647 return true;
648 }
649
650 // |Texture|
651 Scalar TextureGLES::GetYCoordScale() const {
652 switch (GetCoordinateSystem()) {
653 case TextureCoordinateSystem::kUploadFromHost:
654 return 1.0;
655 case TextureCoordinateSystem::kRenderToTexture:
656 return -1.0;
657 }
658 FML_UNREACHABLE();
659 }
660
661 bool TextureGLES::IsWrapped() const {
662 return is_wrapped_;
663 }
664
665 std::optional<GLuint> TextureGLES::GetFBO() const {
666 return wrapped_fbo_;
667 }
668
669 void TextureGLES::SetFence(HandleGLES fence) {
670 FML_DCHECK(!fence_.has_value());
671 fence_ = fence;
672 }
673
674 // Visible for testing.
675 std::optional<HandleGLES> TextureGLES::GetSyncFence() const {
676 return fence_;
677 }
678
679 void TextureGLES::SetCachedFBO(HandleGLES fbo) {
680 cached_fbo_ = fbo;
681 }
682
683 const HandleGLES& TextureGLES::GetCachedFBO() const {
684 return cached_fbo_;
685 }
686
687 } // namespace impeller
allocation.h
impeller::HandleGLES
Represents a handle to an underlying OpenGL object. Unlike OpenGL object handles, these handles can b...
Definition: handle_gles.h:37
impeller::HandleGLES::IsDead
constexpr bool IsDead() const
Determines if the handle is dead.
Definition: handle_gles.h:53
impeller::HandleGLES::GetType
HandleType GetType() const
Definition: handle_gles.h:74
impeller::ReactorGLES::Operation
std::function< void(const ReactorGLES &reactor)> Operation
Definition: reactor_gles.h:214
impeller::TextureGLES
Definition: texture_gles.h:19
impeller::TextureGLES::WrapFBO
static std::shared_ptr< TextureGLES > WrapFBO(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc, GLuint fbo)
Create a texture by wrapping an external framebuffer object whose lifecycle is owned by the caller.
Definition: texture_gles.cc:146
impeller::TextureGLES::MarkContentsInitialized
void MarkContentsInitialized()
Indicates that all texture storage has already been allocated and contents initialized.
Definition: texture_gles.cc:541
impeller::TextureGLES::GetCachedFBO
const HandleGLES & GetCachedFBO() const
Retrieve the cached FBO object, or a dead handle if there is no object.
Definition: texture_gles.cc:683
impeller::TextureGLES::GetSyncFence
std::optional< HandleGLES > GetSyncFence() const
Definition: texture_gles.cc:675
impeller::TextureGLES::IsSliceInitialized
bool IsSliceInitialized(size_t slice) const
Definition: texture_gles.cc:551
impeller::TextureGLES::Bind
bool Bind() const
Definition: texture_gles.cc:506
impeller::TextureGLES::Type
Type
Definition: texture_gles.h:21
impeller::TextureGLES::Type::kTexture
@ kTexture
impeller::TextureGLES::Type::kRenderBuffer
@ kRenderBuffer
impeller::TextureGLES::Type::kTextureMultisampled
@ kTextureMultisampled
impeller::TextureGLES::Type::kRenderBufferMultisampled
@ kRenderBufferMultisampled
impeller::TextureGLES::IsValid
bool IsValid() const override
Definition: texture_gles.cc:233
impeller::TextureGLES::SetFence
void SetFence(HandleGLES fence)
Attach a sync fence to this texture that will be waited on before encoding a rendering operation that...
Definition: texture_gles.cc:669
impeller::TextureGLES::AttachmentType
AttachmentType
Definition: texture_gles.h:92
impeller::TextureGLES::AttachmentType::kStencil
@ kStencil
impeller::TextureGLES::AttachmentType::kDepth
@ kDepth
impeller::TextureGLES::AttachmentType::kColor0
@ kColor0
impeller::TextureGLES::GetType
Type GetType() const
Definition: texture_gles.cc:589
impeller::TextureGLES::SetCachedFBO
void SetCachedFBO(HandleGLES fbo)
Definition: texture_gles.cc:679
impeller::TextureGLES::SetAsFramebufferAttachment
bool SetAsFramebufferAttachment(GLenum target, AttachmentType attachment_type) const
Definition: texture_gles.cc:604
impeller::TextureGLES::CreatePlaceholder
static std::shared_ptr< TextureGLES > CreatePlaceholder(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc)
Create a "texture" that is never expected to be bound/unbound explicitly or initialized in any way....
Definition: texture_gles.cc:178
impeller::TextureGLES::TextureGLES
TextureGLES(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc)
Definition: texture_gles.cc:184
impeller::TextureGLES::GetFBO
std::optional< GLuint > GetFBO() const
Definition: texture_gles.cc:665
impeller::TextureGLES::ComputeTypeForBinding
Type ComputeTypeForBinding(GLenum target) const
Definition: texture_gles.cc:400
impeller::TextureGLES::MarkSliceInitialized
void MarkSliceInitialized(size_t slice) const
Indicates that a specific texture slice has been initialized.
Definition: texture_gles.cc:547
impeller::TextureGLES::GenerateMipmap
bool GenerateMipmap()
Definition: texture_gles.cc:555
impeller::TextureGLES::GetGLHandle
std::optional< GLuint > GetGLHandle() const
Definition: texture_gles.cc:499
impeller::TextureGLES::~TextureGLES
~TextureGLES() override
Definition: texture_gles.cc:225
impeller::TextureGLES::WrapTexture
static std::shared_ptr< TextureGLES > WrapTexture(std::shared_ptr< ReactorGLES > reactor, TextureDescriptor desc, HandleGLES external_handle)
Create a texture by wrapping an external OpenGL texture handle. Ownership of the texture handle is as...
Definition: texture_gles.cc:158
impeller::TextureGLES::IsWrapped
bool IsWrapped() const
Definition: texture_gles.cc:661
impeller::Texture
Definition: texture.h:17
impeller::Texture::GetTextureDescriptor
const TextureDescriptor & GetTextureDescriptor() const
Definition: texture.cc:57
impeller::Texture::GetCoordinateSystem
TextureCoordinateSystem GetCoordinateSystem() const
Definition: texture.cc:77
impeller::Texture::mipmap_generated_
bool mipmap_generated_
Definition: texture.h:79
formats.h
value
int32_t value
Definition: dl_golden_unittests.cc:459
formats_gles.h
impeller::android::GetProcTable
const ProcTable & GetProcTable()
Definition: proc_table.cc:12
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::CreateMappingWithCopy
std::shared_ptr< fml::Mapping > CreateMappingWithCopy(const uint8_t *contents, Bytes length)
Creates a mapping with copy of the bytes.
Definition: allocation.cc:83
impeller::Bytes
AllocationSize< 1u > Bytes
Definition: allocation_size.h:151
impeller::SPrintF
std::string SPrintF(const char *format,...)
Definition: strings.cc:12
impeller::PixelFormat
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
impeller::PixelFormat::kD24UnormS8Uint
@ kD24UnormS8Uint
impeller::PixelFormat::kR8G8B8A8UNormIntSRGB
@ kR8G8B8A8UNormIntSRGB
impeller::PixelFormat::kR8UNormInt
@ kR8UNormInt
impeller::PixelFormat::kUnknown
@ kUnknown
impeller::PixelFormat::kR32G32B32A32Float
@ kR32G32B32A32Float
impeller::PixelFormat::kA8UNormInt
@ kA8UNormInt
impeller::PixelFormat::kB10G10R10A10XR
@ kB10G10R10A10XR
impeller::PixelFormat::kB8G8R8A8UNormInt
@ kB8G8R8A8UNormInt
impeller::PixelFormat::kS8UInt
@ kS8UInt
impeller::PixelFormat::kB10G10R10XRSRGB
@ kB10G10R10XRSRGB
impeller::PixelFormat::kD32FloatS8UInt
@ kD32FloatS8UInt
impeller::PixelFormat::kB10G10R10XR
@ kB10G10R10XR
impeller::PixelFormat::kR8G8UNormInt
@ kR8G8UNormInt
impeller::PixelFormat::kB8G8R8A8UNormIntSRGB
@ kB8G8R8A8UNormIntSRGB
impeller::PixelFormat::kR16G16B16A16Float
@ kR16G16B16A16Float
impeller::PixelFormat::kR8G8B8A8UNormInt
@ kR8G8B8A8UNormInt
impeller::ToTextureType
constexpr GLenum ToTextureType(TextureType type)
Definition: formats_gles.h:171
impeller::ToRenderBufferFormat
static std::optional< GLenum > ToRenderBufferFormat(PixelFormat format)
Definition: texture_gles.cc:371
impeller::TextureType::kTextureExternalOES
@ kTextureExternalOES
impeller::TextureType::kTexture2DMultisample
@ kTexture2DMultisample
impeller::TextureType::kTexture2D
@ kTexture2D
impeller::TextureType::kTextureCube
@ kTextureCube
impeller::TextureCoordinateSystem::kUploadFromHost
@ kUploadFromHost
impeller::TextureCoordinateSystem::kRenderToTexture
@ kRenderToTexture
impeller::ToTextureTarget
constexpr std::optional< GLenum > ToTextureTarget(TextureType type)
Definition: formats_gles.h:185
impeller::ISize
ISize64 ISize
Definition: size.h:162
impeller::HandleType
HandleType
Definition: handle_gles.h:18
impeller::HandleType::kTexture
@ kTexture
impeller::HandleType::kRenderBuffer
@ kRenderBuffer
impeller::ToAttachmentType
static GLenum ToAttachmentType(TextureGLES::AttachmentType point)
Definition: texture_gles.cc:593
impeller::TextureUsageMask
Mask< TextureUsage > TextureUsageMask
Definition: formats.h:308
impeller::TextureUsage::kRenderTarget
@ kRenderTarget
impeller::SampleCount::kCount4
@ kCount4
impeller::ToHandleType
HandleType ToHandleType(TextureGLES::Type type)
Definition: texture_gles.cc:134
std
Definition: comparable.h:95
strings.h
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:38
impeller::TextureDescriptor::type
TextureType type
Definition: texture_descriptor.h:40
impeller::TextureDescriptor::size
ISize size
Definition: texture_descriptor.h:42
texture_descriptor.h
type
GLenum type
Definition: texture_gles.cc:66
external_format
GLenum external_format
Definition: texture_gles.cc:65
internal_format
GLint internal_format
Definition: texture_gles.cc:64
data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:67
texture_gles.h
validation.h
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91