Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
tests
graphite
BufferManagerTest.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2023 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/Context.h
"
11
#include "
include/gpu/graphite/Recorder.h
"
12
#include "
include/gpu/graphite/Recording.h
"
13
#include "
src/gpu/graphite/Buffer.h
"
14
#include "
src/gpu/graphite/BufferManager.h
"
15
#include "
src/gpu/graphite/Caps.h
"
16
#include "
src/gpu/graphite/ContextPriv.h
"
17
#include "
src/gpu/graphite/RecorderPriv.h
"
18
#include "
src/gpu/graphite/RecordingPriv.h
"
19
20
namespace
skgpu::graphite
{
21
namespace
{
22
23
static
bool
is_offset_aligned(
size_t
offset
,
size_t
alignment) {
24
return
0 == (
offset
& (alignment - 1));
25
}
26
27
}
// namespace
28
29
DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS
(BufferManagerGpuOnlyBufferTest,
reporter
, context,
30
CtsEnforcement::kNextRelease
) {
31
std::unique_ptr<Recorder> recorder = context->makeRecorder();
32
DrawBufferManager
* mgr = recorder->priv().drawBufferManager();
33
34
// Allocate a series of GPU-only buffers. These buffers should not be mapped before and after
35
// they get transferred to the recording.
36
auto
ssbo = mgr->
getStorage
(10);
37
auto
vertex = mgr->
getVertexStorage
(10);
38
auto
index = mgr->
getIndexStorage
(10);
39
auto
indirect = mgr->
getIndirectStorage
(10);
40
41
REPORTER_ASSERT
(
reporter
, !ssbo.fBuffer->isMapped());
42
REPORTER_ASSERT
(
reporter
, !vertex.fBuffer->isMapped());
43
REPORTER_ASSERT
(
reporter
, !index.fBuffer->isMapped());
44
REPORTER_ASSERT
(
reporter
, !indirect.fBuffer->isMapped());
45
46
// Ensure that the buffers' starting alignment matches the required storage buffer alignment.
47
size_t
requiredAlignment = context->priv().caps()->requiredStorageBufferAlignment();
48
REPORTER_ASSERT
(
reporter
, is_offset_aligned(ssbo.fOffset, requiredAlignment));
49
REPORTER_ASSERT
(
reporter
, is_offset_aligned(vertex.fOffset, requiredAlignment));
50
REPORTER_ASSERT
(
reporter
, is_offset_aligned(index.fOffset, requiredAlignment));
51
REPORTER_ASSERT
(
reporter
, is_offset_aligned(indirect.fOffset, requiredAlignment));
52
53
// Transfers the ownership of used buffers to a Recording.
54
auto
recording = recorder->snap();
55
56
// Ensure that the buffers are still unmapped.
57
REPORTER_ASSERT
(
reporter
, !ssbo.fBuffer->isMapped());
58
REPORTER_ASSERT
(
reporter
, !vertex.fBuffer->isMapped());
59
REPORTER_ASSERT
(
reporter
, !index.fBuffer->isMapped());
60
REPORTER_ASSERT
(
reporter
, !indirect.fBuffer->isMapped());
61
62
// Since these buffers never need their contents to be host-visible, no buffer transfer/copy
63
// tasks should have been created for them.
64
REPORTER_ASSERT
(
reporter
, !recording->priv().hasTasks());
65
66
// Request a mapped ssbo followed by an unmapped one. The two buffers should be distinct.
67
auto
[ssboPtr, mappedSsbo] = mgr->
getStoragePointer
(10);
68
ssbo = mgr->
getStorage
(10);
69
REPORTER_ASSERT
(
reporter
, !ssbo.fBuffer->isMapped());
70
REPORTER_ASSERT
(
reporter
, ssbo.fBuffer != mappedSsbo.fBuffer);
71
}
72
73
}
// namespace skgpu::graphite
BufferManager.h
Buffer.h
Caps.h
ContextPriv.h
Context.h
reporter
reporter
Definition
FontMgrTest.cpp:39
RecorderPriv.h
Recorder.h
RecordingPriv.h
Recording.h
Test.h
REPORTER_ASSERT
#define REPORTER_ASSERT(r, cond,...)
Definition
Test.h:286
DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS
#define DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS(name, reporter, graphite_context, ctsEnforcement)
Definition
Test.h:377
CtsEnforcement::kNextRelease
@ kNextRelease
Definition
CtsEnforcement.h:40
skgpu::graphite::DrawBufferManager
Definition
BufferManager.h:99
skgpu::graphite::DrawBufferManager::getIndexStorage
BindBufferInfo getIndexStorage(size_t requiredBytes)
Definition
BufferManager.cpp:233
skgpu::graphite::DrawBufferManager::getStoragePointer
std::pair< void *, BindBufferInfo > getStoragePointer(size_t requiredBytes)
Definition
BufferManager.cpp:201
skgpu::graphite::DrawBufferManager::getStorage
BindBufferInfo getStorage(size_t requiredBytes, ClearBuffer cleared=ClearBuffer::kNo)
Definition
BufferManager.cpp:211
skgpu::graphite::DrawBufferManager::getIndirectStorage
BindBufferInfo getIndirectStorage(size_t requiredBytes, ClearBuffer cleared=ClearBuffer::kNo)
Definition
BufferManager.cpp:242
skgpu::graphite::DrawBufferManager::getVertexStorage
BindBufferInfo getVertexStorage(size_t requiredBytes)
Definition
BufferManager.cpp:224
skgpu::graphite
Definition
BoundsManagerBench.cpp:27
offset
Point offset
Definition
stroke_path_geometry.cc:256
Generated on Fri Apr 26 2024 06:17:43 for Flutter Engine by
1.9.8