#include <GrGpuBuffer.h>
Definition at line 24 of file GrGpuBuffer.h.
◆ MapType
Enumerator |
---|
kRead | Maps for reading. The effect of writes is undefined.
|
kWriteDiscard | Maps for writing. The existing contents are discarded and the initial contents of the buffer. Reads (even after overwriting initial contents) should be avoided for performance reasons as the memory may not be cached.
|
Definition at line 108 of file GrGpuBuffer.h.
108 {
109
111
112
113
114
115
116 kWriteDiscard,
117 };
◆ GrGpuBuffer()
Definition at line 19 of file GrGpuBuffer.cpp.
24 , fSizeInBytes(sizeInBytes)
25 , fAccessPattern(pattern)
26 , fIntendedType(
type) {}
GrGpuResource(GrGpu *, std::string_view label)
◆ accessPattern()
◆ clearToZero()
bool GrGpuBuffer::clearToZero |
( |
| ) |
|
Overwrites the buffer with zero bytes. Always fails for GrGpuBufferType::kXferGpuToCpu buffers. The buffer must not currently be mapped.
Definition at line 49 of file GrGpuBuffer.cpp.
49 {
51
53 return false;
54 }
55
57 return false;
58 }
59
61}
GrGpuBufferType intendedType() const
virtual bool onClearToZero()=0
bool wasDestroyed() const
◆ ComputeScratchKeyForDynamicBuffer()
Computes a scratch key for a GPU-side buffer with a "dynamic" access pattern. (Buffers with "static" and "stream" patterns are disqualified by nature from being cached and reused.)
Definition at line 86 of file GrGpuBuffer.cpp.
88 {
93 if (sizeof(size_t) > 4) {
95 }
96}
constexpr uint32_t SkToU32(S x)
size_t size() const final
static ResourceType GenerateResourceType()
◆ intendedType()
◆ isCpuBuffer()
bool GrGpuBuffer::isCpuBuffer |
( |
| ) |
const |
|
inlinefinalvirtual |
◆ isMapped()
bool GrGpuBuffer::isMapped |
( |
| ) |
const |
Queries whether the buffer has been mapped.
- Returns
- true if the buffer is mapped, false otherwise.
Definition at line 47 of file GrGpuBuffer.cpp.
static constexpr bool SkToBool(const T &x)
◆ map()
void * GrGpuBuffer::map |
( |
| ) |
|
Maps the buffer to be read or written by the CPU.
It is an error to draw from the buffer while it is mapped or transfer to/from the buffer. It may fail if the backend doesn't support mapping the buffer. Once a buffer is mapped, subsequent calls to map() trivially succeed. No matter how many times map() is called, umap() will unmap the buffer on the first call if it is mapped.
If the buffer is of type GrGpuBufferType::kXferGpuToCpu then it is mapped for reading only. Otherwise it is mapped writing only. Writing to a buffer that is mapped for reading or vice versa produces undefined results. If the buffer is mapped for writing then the buffer's previous contents are invalidated.
- Returns
- a pointer to the data or nullptr if the map fails.
Definition at line 28 of file GrGpuBuffer.cpp.
28 {
30 return nullptr;
31 }
33 this->
onMap(this->mapType());
34 }
36}
virtual void onMap(MapType)=0
◆ onClearToZero()
virtual bool GrGpuBuffer::onClearToZero |
( |
| ) |
|
|
privatepure virtual |
◆ onMap()
virtual void GrGpuBuffer::onMap |
( |
MapType |
| ) |
|
|
privatepure virtual |
◆ onUnmap()
virtual void GrGpuBuffer::onUnmap |
( |
MapType |
| ) |
|
|
privatepure virtual |
◆ onUpdateData()
virtual bool GrGpuBuffer::onUpdateData |
( |
const void * |
src, |
|
|
size_t |
offset, |
|
|
size_t |
size, |
|
|
bool |
preserve |
|
) |
| |
|
privatepure virtual |
◆ ref()
void GrGpuBuffer::ref |
( |
| ) |
const |
|
inlinefinalvirtual |
◆ size()
size_t GrGpuBuffer::size |
( |
| ) |
const |
|
inlinefinalvirtual |
Size of the buffer in bytes.
Implements GrBuffer.
Definition at line 34 of file GrGpuBuffer.h.
34{ return fSizeInBytes; }
◆ unmap()
void GrGpuBuffer::unmap |
( |
| ) |
|
Unmaps the buffer if it is mapped.
The pointer returned by the previous map call will no longer be valid.
Definition at line 38 of file GrGpuBuffer.cpp.
38 {
40 return;
41 }
45}
virtual void onUnmap(MapType)=0
◆ unref()
void GrGpuBuffer::unref |
( |
| ) |
const |
|
inlinefinalvirtual |
◆ updateData()
bool GrGpuBuffer::updateData |
( |
const void * |
src, |
|
|
size_t |
offset, |
|
|
size_t |
size, |
|
|
bool |
preserve |
|
) |
| |
Updates the buffer data.
The size of the buffer will be preserved. The src data will be placed at offset. If preserve is false then any remaining content before/after the range [offset, offset+size) becomes undefined. Preserving updates will fail if the size and offset are not aligned to GrCaps::bufferUpdateDataPreserveAlignment().
The buffer must not be mapped.
Fails for GrGpuBufferType::kXferGpuToCpu.
Note that buffer updates do not go through GrContext and therefore are not serialized with other operations.
- Returns
- returns true if the update succeeds, false otherwise.
Definition at line 63 of file GrGpuBuffer.cpp.
63 {
67
69 return false;
70 }
71
72 if (preserve) {
75 return false;
76 }
77 }
78
80 return false;
81 }
82
84}
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
size_t bufferUpdateDataPreserveAlignment() const
virtual bool onUpdateData(const void *src, size_t offset, size_t size, bool preserve)=0
const GrCaps * caps() const
◆ fMapPtr
void* GrGpuBuffer::fMapPtr |
|
protected |
The documentation for this class was generated from the following files: