Flutter Engine
The Flutter Engine
Functions
MtlBackendTextureTest.mm File Reference
#include "tests/Test.h"
#include "include/gpu/graphite/BackendTexture.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/mtl/MtlGraphiteTypes.h"
#import <Metal/Metal.h>

Go to the source code of this file.

Functions

 DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT (MtlBackendTextureTest, reporter, context, testContext)
 

Function Documentation

◆ DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT()

DEF_GRAPHITE_TEST_FOR_METAL_CONTEXT ( MtlBackendTextureTest  ,
reporter  ,
context  ,
testContext   
)

Definition at line 23 of file MtlBackendTextureTest.mm.

23 {
24 auto recorder = context->makeRecorder();
25
26 MtlTextureInfo textureInfo;
27 textureInfo.fSampleCount = 1;
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}
reporter
Definition: FontMgrTest.cpp:39
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
constexpr int kSize