Flutter Engine
The Flutter Engine
Functions
F16StagesTest.cpp File Reference
#include "src/core/SkRasterPipeline.h"
#include "src/core/SkRasterPipelineOpContexts.h"
#include "src/core/SkRasterPipelineOpList.h"
#include "tests/Test.h"
#include <cstdint>

Go to the source code of this file.

Functions

 DEF_TEST (F16Stages, r)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( F16Stages  ,
 
)

Definition at line 15 of file F16StagesTest.cpp.

15 {
16 // Make sure SkRasterPipelineOp::load_f16 and store_f16 can handle a range of
17 // ordinary (0<=x<=1) and interesting (x<0, x>1) values.
18 float floats[16] = {
19 0.0f, 0.25f, 0.5f, 1.0f,
20 -1.25f, -0.5f, 1.25f, 2.0f,
21 0,0,0,0, 0,0,0,0, // pad a bit to make sure we qualify for platform-specific code
22 };
23 uint64_t halfs[4] = {0,0,0,0};
24
25 SkRasterPipeline_MemoryCtx f32 = { floats, 0 },
26 f16 = { halfs, 0 };
27
28 {
30 p.append(SkRasterPipelineOp:: load_f32, &f32);
31 p.append(SkRasterPipelineOp::store_f16, &f16);
32 p.run(0,0,16/4,1);
33 }
34 REPORTER_ASSERT(r, ((halfs[0] >> 0) & 0xffff) == 0x0000);
35 REPORTER_ASSERT(r, ((halfs[0] >> 16) & 0xffff) == 0x3400);
36 REPORTER_ASSERT(r, ((halfs[0] >> 32) & 0xffff) == 0x3800);
37 REPORTER_ASSERT(r, ((halfs[0] >> 48) & 0xffff) == 0x3c00);
38 REPORTER_ASSERT(r, ((halfs[1] >> 0) & 0xffff) == 0xbd00);
39 REPORTER_ASSERT(r, ((halfs[1] >> 16) & 0xffff) == 0xb800);
40 REPORTER_ASSERT(r, ((halfs[1] >> 32) & 0xffff) == 0x3d00);
41 REPORTER_ASSERT(r, ((halfs[1] >> 48) & 0xffff) == 0x4000);
42
43 {
45 p.append(SkRasterPipelineOp:: load_f16, &f16);
46 p.append(SkRasterPipelineOp::store_f32, &f32);
47 p.run(0,0,16/4,1);
48 }
49 REPORTER_ASSERT(r, floats[0] == 0.00f);
50 REPORTER_ASSERT(r, floats[1] == 0.25f);
51 REPORTER_ASSERT(r, floats[2] == 0.50f);
52 REPORTER_ASSERT(r, floats[3] == 1.00f);
53 REPORTER_ASSERT(r, floats[4] == -1.25f);
54 REPORTER_ASSERT(r, floats[5] == -0.50f);
55 REPORTER_ASSERT(r, floats[6] == 1.25f);
56 REPORTER_ASSERT(r, floats[7] == 2.00f);
57}
static const uint64_t f16[kNumPixels]
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286