Flutter Engine
The Flutter Engine
third_party
skia
src
gpu
graphite
PipelineData.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2022 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 "
src/gpu/graphite/PipelineData.h
"
9
10
#include "
src/core/SkChecksum.h
"
11
#include "
src/gpu/graphite/ShaderCodeDictionary.h
"
12
13
namespace
skgpu::graphite
{
14
15
PipelineDataGatherer::PipelineDataGatherer
(
Layout
layout)
16
: fUniformManager(layout) {}
17
18
void
PipelineDataGatherer::resetWithNewLayout
(
Layout
layout) {
19
fUniformManager.
resetWithNewLayout
(layout);
20
fTextureDataBlock.
reset
();
21
}
22
23
#ifdef SK_DEBUG
24
void
PipelineDataGatherer::checkReset() {
25
SkASSERT
(fTextureDataBlock.
empty
());
26
SkASSERT
(fUniformManager.isReset());
27
}
28
29
void
PipelineDataGatherer::setExpectedUniforms(
SkSpan<const Uniform>
expectedUniforms) {
30
fUniformManager.setExpectedUniforms(expectedUniforms);
31
}
32
#endif
// SK_DEBUG
33
34
////////////////////////////////////////////////////////////////////////////////////////////////////
35
UniformDataBlock
*
UniformDataBlock::Make
(
const
UniformDataBlock
& other,
SkArenaAlloc
* arena) {
36
static
constexpr
size_t
kUniformAlignment =
alignof
(
void
*);
37
char
* mem =
static_cast<
char
*
>
(arena->
makeBytesAlignedTo
(other.
size
(), kUniformAlignment));
38
memcpy(mem, other.
data
(), other.
size
());
39
40
return
arena->
make
([&](
void
* ptr) {
41
return
new
(ptr)
UniformDataBlock
(
SkSpan<const char>
(mem, other.
size
()));
42
});
43
}
44
45
uint32_t
UniformDataBlock::hash
()
const
{
46
return
SkChecksum::Hash32
(fData.
data
(), fData.
size
());
47
}
48
49
////////////////////////////////////////////////////////////////////////////////////////////////////
50
TextureDataBlock
*
TextureDataBlock::Make
(
const
TextureDataBlock
& other,
51
SkArenaAlloc
* arena) {
52
return
arena->
make
([&](
void
*ptr) {
53
return
new
(ptr)
TextureDataBlock
(other);
54
});
55
}
56
57
bool
TextureDataBlock::operator==
(
const
TextureDataBlock
& other)
const
{
58
if
(fTextureData.size() != other.fTextureData.size()) {
59
return
false
;
60
}
61
62
for
(
size_t
i
= 0;
i
< fTextureData.size(); ++
i
) {
63
if
(fTextureData[
i
] != other.fTextureData[
i
]) {
64
return
false
;
65
}
66
}
67
68
return
true
;
69
}
70
71
uint32_t
TextureDataBlock::hash
()
const
{
72
uint32_t
hash
= 0;
73
74
for
(
auto
&
d
: fTextureData) {
75
SamplerDesc
samplerKey =
std::get<1>
(
d
);
76
hash
=
SkChecksum::Hash32
(&samplerKey,
sizeof
(samplerKey),
hash
);
77
78
// Because the lifetime of the TextureDataCache is for just one Recording and the
79
// TextureDataBlocks hold refs on their proxies, we can just use the proxy's pointer
80
// for the hash here.
81
uintptr_t proxy =
reinterpret_cast<
uintptr_t
>
(
std::get<0>
(
d
).get());
82
hash
=
SkChecksum::Hash32
(&proxy,
sizeof
(proxy),
hash
);
83
}
84
85
return
hash
;
86
}
87
88
#ifdef SK_DEBUG
89
UniformExpectationsValidator::UniformExpectationsValidator(
PipelineDataGatherer
*gatherer,
90
SkSpan<const Uniform>
expectedUniforms)
91
: fGatherer(gatherer) {
92
fGatherer->setExpectedUniforms(expectedUniforms);
93
}
94
#endif
95
96
}
// namespace skgpu::graphite
PipelineData.h
ShaderCodeDictionary.h
SkASSERT
#define SkASSERT(cond)
Definition:
SkAssert.h:116
SkChecksum.h
SkArenaAlloc
Definition:
SkArenaAlloc.h:105
SkArenaAlloc::makeBytesAlignedTo
void * makeBytesAlignedTo(size_t size, size_t align)
Definition:
SkArenaAlloc.h:200
SkArenaAlloc::make
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
Definition:
SkArenaAlloc.h:120
SkSpan
Definition:
SkSpan_impl.h:65
SkSpan::data
constexpr T * data() const
Definition:
SkSpan_impl.h:94
SkSpan::size
constexpr size_t size() const
Definition:
SkSpan_impl.h:95
skgpu::graphite::PipelineDataGatherer
Definition:
PipelineData.h:91
skgpu::graphite::PipelineDataGatherer::PipelineDataGatherer
PipelineDataGatherer(Layout layout)
Definition:
PipelineData.cpp:15
skgpu::graphite::PipelineDataGatherer::resetWithNewLayout
void resetWithNewLayout(Layout layout)
Definition:
PipelineData.cpp:18
skgpu::graphite::TextureDataBlock
Definition:
PipelineData.h:55
skgpu::graphite::TextureDataBlock::hash
uint32_t hash() const
Definition:
PipelineData.cpp:71
skgpu::graphite::TextureDataBlock::TextureDataBlock
TextureDataBlock()=default
skgpu::graphite::TextureDataBlock::operator==
bool operator==(const TextureDataBlock &) const
Definition:
PipelineData.cpp:57
skgpu::graphite::TextureDataBlock::Make
static TextureDataBlock * Make(const TextureDataBlock &, SkArenaAlloc *)
Definition:
PipelineData.cpp:50
skgpu::graphite::TextureDataBlock::empty
bool empty() const
Definition:
PipelineData.h:62
skgpu::graphite::TextureDataBlock::reset
void reset()
Definition:
PipelineData.h:74
skgpu::graphite::UniformDataBlock
Definition:
PipelineData.h:33
skgpu::graphite::UniformDataBlock::hash
uint32_t hash() const
Definition:
PipelineData.cpp:45
skgpu::graphite::UniformDataBlock::Make
static UniformDataBlock * Make(const UniformDataBlock &, SkArenaAlloc *)
Definition:
PipelineData.cpp:35
skgpu::graphite::UniformDataBlock::data
const char * data() const
Definition:
PipelineData.h:40
skgpu::graphite::UniformDataBlock::size
size_t size() const
Definition:
PipelineData.h:41
skgpu::graphite::UniformDataBlock::UniformDataBlock
UniformDataBlock()=default
skgpu::graphite::UniformManager::resetWithNewLayout
void resetWithNewLayout(Layout layout)
Definition:
UniformManager.cpp:61
d
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition:
main.cc:19
i
int i
Definition:
fl_socket_accessible.cc:18
SkChecksum::Hash32
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
Definition:
SkChecksum.cpp:113
myers::get< 1 >
const myers::Point & get< 1 >(const myers::Segment &s)
Definition:
Myers.h:81
myers::get< 0 >
const myers::Point & get< 0 >(const myers::Segment &s)
Definition:
Myers.h:80
skgpu::graphite
Definition:
BoundsManagerBench.cpp:27
skgpu::graphite::Layout
Layout
Definition:
ResourceTypes.h:77
skgpu::graphite::SamplerDesc
Definition:
ResourceTypes.h:212
Generated on Sun Jun 23 2024 21:56:27 for Flutter Engine by
1.9.4