dawn_wire: use memcpy on structures when possible

This patch sets 'is_wire_transparent' on the structures whose members
are all wire transparent and are not pointers, so that we can use
memcpy when serializing and deserializing these structures:
- GPUBlendComponent
- GPUColor
- GPUExtent3D
- GPULimits
- GPUOrigin3D
- GPUStencilFaceState
- GPUVertexAttribute
- GPUBlendState

In the next patch we will support memcpy on the qualified structures
whose members contain pointers (e.g. GPUVertexBufferLayout).

BUG=chromium:1266727

Change-Id: If46289f2d10cc7b17e6f5330cd2c2d4dc481f8b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/73000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao
2021-12-21 04:04:51 +00:00
committed by Dawn LUCI CQ
parent b9467591a4
commit 1fa386cc87
2 changed files with 33 additions and 8 deletions

View File

@@ -242,6 +242,21 @@ class StructureType(Record, Type):
# two nextInChain members.
assert not (self.extensible and self.chained)
def update_metadata(self):
Record.update_metadata(self)
if self.may_have_dawn_object:
self.is_wire_transparent = False
return
assert not (self.chained or self.extensible)
def get_is_wire_transparent(member):
return member.type.is_wire_transparent and member.annotation == 'value'
self.is_wire_transparent = all(
get_is_wire_transparent(m) for m in self.members)
@property
def output(self):
return self.chained == "out" or self.extensible == "out"