7
7
#include < optional>
8
8
#include < utility>
9
9
10
- #include " flutter/fml/logging.h"
11
10
#include " flutter/fml/mapping.h"
12
11
#include " flutter/fml/trace_event.h"
13
12
#include " impeller/base/allocation.h"
18
17
19
18
namespace impeller {
20
19
21
- static bool IsDepthStencilFormat (PixelFormat format) {
22
- switch (format) {
23
- case PixelFormat::kS8UInt :
24
- case PixelFormat::kD24UnormS8Uint :
25
- case PixelFormat::kD32FloatS8UInt :
26
- return true ;
27
- case PixelFormat::kUnknown :
28
- case PixelFormat::kA8UNormInt :
29
- case PixelFormat::kR8UNormInt :
30
- case PixelFormat::kR8G8UNormInt :
31
- case PixelFormat::kR8G8B8A8UNormInt :
32
- case PixelFormat::kR8G8B8A8UNormIntSRGB :
33
- case PixelFormat::kB8G8R8A8UNormInt :
34
- case PixelFormat::kB8G8R8A8UNormIntSRGB :
35
- case PixelFormat::kR32G32B32A32Float :
36
- case PixelFormat::kR16G16B16A16Float :
37
- case PixelFormat::kB10G10R10XR :
38
- case PixelFormat::kB10G10R10XRSRGB :
39
- case PixelFormat::kB10G10R10A10XR :
40
- return false ;
41
- }
42
- FML_UNREACHABLE ();
43
- }
44
-
45
20
static TextureGLES::Type GetTextureTypeFromDescriptor (
46
21
const TextureDescriptor& desc) {
47
22
const auto usage = static_cast <TextureUsageMask>(desc.usage );
48
23
const auto render_target =
49
24
static_cast <TextureUsageMask>(TextureUsage::kRenderTarget );
50
25
const auto is_msaa = desc.sample_count == SampleCount::kCount4 ;
51
- if (usage == render_target && IsDepthStencilFormat ( desc.format ) ) {
26
+ if (usage == render_target && desc.format == PixelFormat:: kS8UInt ) {
52
27
return is_msaa ? TextureGLES::Type::kRenderBufferMultisampled
53
28
: TextureGLES::Type::kRenderBuffer ;
54
29
}
@@ -482,20 +457,19 @@ TextureGLES::Type TextureGLES::GetType() const {
482
457
return type_;
483
458
}
484
459
485
- static GLenum ToAttachmentType (TextureGLES::AttachmentType point) {
460
+ static GLenum ToAttachmentPoint (TextureGLES::AttachmentPoint point) {
486
461
switch (point) {
487
- case TextureGLES::AttachmentType ::kColor0 :
462
+ case TextureGLES::AttachmentPoint ::kColor0 :
488
463
return GL_COLOR_ATTACHMENT0;
489
- case TextureGLES::AttachmentType ::kDepth :
464
+ case TextureGLES::AttachmentPoint ::kDepth :
490
465
return GL_DEPTH_ATTACHMENT;
491
- case TextureGLES::AttachmentType ::kStencil :
466
+ case TextureGLES::AttachmentPoint ::kStencil :
492
467
return GL_STENCIL_ATTACHMENT;
493
468
}
494
469
}
495
470
496
- bool TextureGLES::SetAsFramebufferAttachment (
497
- GLenum target,
498
- AttachmentType attachment_type) const {
471
+ bool TextureGLES::SetAsFramebufferAttachment (GLenum target,
472
+ AttachmentPoint point) const {
499
473
if (!IsValid ()) {
500
474
return false ;
501
475
}
@@ -508,30 +482,29 @@ bool TextureGLES::SetAsFramebufferAttachment(
508
482
509
483
switch (type_) {
510
484
case Type::kTexture :
511
- gl.FramebufferTexture2D (target, // target
512
- ToAttachmentType (attachment_type ), // attachment
513
- GL_TEXTURE_2D, // textarget
514
- handle.value (), // texture
515
- 0 // level
485
+ gl.FramebufferTexture2D (target, // target
486
+ ToAttachmentPoint (point ), // attachment
487
+ GL_TEXTURE_2D, // textarget
488
+ handle.value (), // texture
489
+ 0 // level
516
490
);
517
491
break ;
518
492
case Type::kTextureMultisampled :
519
493
gl.FramebufferTexture2DMultisampleEXT (
520
- target, // target
521
- ToAttachmentType (attachment_type ), // attachment
522
- GL_TEXTURE_2D, // textarget
523
- handle.value (), // texture
524
- 0 , // level
525
- 4 // samples
494
+ target, // target
495
+ ToAttachmentPoint (point ), // attachment
496
+ GL_TEXTURE_2D, // textarget
497
+ handle.value (), // texture
498
+ 0 , // level
499
+ 4 // samples
526
500
);
527
501
break ;
528
502
case Type::kRenderBuffer :
529
503
case Type::kRenderBufferMultisampled :
530
- gl.FramebufferRenderbuffer (
531
- target, // target
532
- ToAttachmentType (attachment_type), // attachment
533
- GL_RENDERBUFFER, // render-buffer target
534
- handle.value () // render-buffer
504
+ gl.FramebufferRenderbuffer (target, // target
505
+ ToAttachmentPoint (point), // attachment
506
+ GL_RENDERBUFFER, // render-buffer target
507
+ handle.value () // render-buffer
535
508
);
536
509
break ;
537
510
}
0 commit comments