Flutter Engine
The Flutter Engine
third_party
skia
tests
graphite
MtlBackendTextureTest.mm
Go to the documentation of this file.
1
/*
2
* Copyright 2021 Google LLC
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#include "
tests/Test.h
"
9
10
#include "
include/gpu/graphite/BackendTexture.h
"
11
#include "
include/gpu/graphite/Context.h
"
12
#include "
include/gpu/graphite/Recorder.h
"
13
#include "
include/gpu/graphite/mtl/MtlGraphiteTypes.h
"
14
15
#import <Metal/Metal.h>
16
17
using namespace
skgpu::graphite
;
18
19
namespace
{
20
const
SkISize
kSize
= {16, 16};
21
}
22
23
DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT
(MtlBackendTextureTest,
reporter
, context, testContext) {
24
auto
recorder = context->makeRecorder();
25
26
MtlTextureInfo
textureInfo;
27
textureInfo.
fSampleCount
= 1;
28
textureInfo.
fMipmapped
=
skgpu::Mipmapped::kNo
;
29
textureInfo.
fFormat
= MTLPixelFormatRGBA8Unorm;
30
textureInfo.
fStorageMode
= MTLStorageModePrivate;
31
textureInfo.
fUsage
= MTLTextureUsageShaderRead;
32
33
// TODO: For now we are just testing the basic case of RGBA single sample because that is what
34
// we've added to the backend. However, once we expand the backend support to handle all the
35
// formats this test should iterate over a large set of combinations. See the Ganesh
36
// MtlBackendAllocationTest for example of doing this.
37
38
auto
beTexture = recorder->createBackendTexture(
kSize
, textureInfo);
39
REPORTER_ASSERT
(
reporter
, beTexture.isValid());
40
recorder->deleteBackendTexture(beTexture);
41
42
// It should also pass if we set the usage to be a render target
43
textureInfo.
fUsage
|= MTLTextureUsageRenderTarget;
44
beTexture = recorder->createBackendTexture(
kSize
, textureInfo);
45
REPORTER_ASSERT
(
reporter
, beTexture.isValid());
46
recorder->deleteBackendTexture(beTexture);
47
48
// It should fail with a format that isn't one of our supported formats
49
textureInfo.
fFormat
= MTLPixelFormatRGB9E5Float;
50
beTexture = recorder->createBackendTexture(
kSize
, textureInfo);
51
REPORTER_ASSERT
(
reporter
, !beTexture.isValid());
52
recorder->deleteBackendTexture(beTexture);
53
54
// It should fail with a sample count greater than 1
55
textureInfo.
fFormat
= MTLPixelFormatRGBA8Unorm;
56
textureInfo.
fSampleCount
= 4;
57
beTexture = recorder->createBackendTexture(
kSize
, textureInfo);
58
REPORTER_ASSERT
(
reporter
, !beTexture.isValid());
59
recorder->deleteBackendTexture(beTexture);
60
}
BackendTexture.h
Context.h
reporter
reporter
Definition:
FontMgrTest.cpp:39
DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT
DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT(MtlBackendTextureTest, reporter, context, testContext)
Definition:
MtlBackendTextureTest.mm:23
MtlGraphiteTypes.h
Recorder.h
Test.h
REPORTER_ASSERT
#define REPORTER_ASSERT(r, cond,...)
Definition:
Test.h:286
kSize
constexpr int kSize
Definition:
largeclippedpath.cpp:12
skgpu::graphite
Definition:
BoundsManagerBench.cpp:27
skgpu::Mipmapped::kNo
@ kNo
SkISize
Definition:
SkSize.h:16
skgpu::graphite::MtlTextureInfo
Definition:
MtlGraphiteTypes.h:39
skgpu::graphite::MtlTextureInfo::fSampleCount
uint32_t fSampleCount
Definition:
MtlGraphiteTypes.h:40
skgpu::graphite::MtlTextureInfo::fFormat
MtlPixelFormat fFormat
Definition:
MtlGraphiteTypes.h:45
skgpu::graphite::MtlTextureInfo::fStorageMode
MtlStorageMode fStorageMode
Definition:
MtlGraphiteTypes.h:47
skgpu::graphite::MtlTextureInfo::fMipmapped
skgpu::Mipmapped fMipmapped
Definition:
MtlGraphiteTypes.h:41
skgpu::graphite::MtlTextureInfo::fUsage
MtlTextureUsage fUsage
Definition:
MtlGraphiteTypes.h:46
Generated on Sun Jun 23 2024 21:56:39 for Flutter Engine by
1.9.4