Cleanup: Rename dawn_wire Object "serial" to "generation"
This is a more accurate name and conflicts less with the callback
request serials.
Bug: none
Change-Id: I0f9660c24468064dadffb3ab9b3392d403f93c41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19260
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/generator/templates/dawn_wire/WireCmd.cpp b/generator/templates/dawn_wire/WireCmd.cpp
index 002f84c..653d79b 100644
--- a/generator/templates/dawn_wire/WireCmd.cpp
+++ b/generator/templates/dawn_wire/WireCmd.cpp
@@ -422,16 +422,20 @@
} while (0)
ObjectHandle::ObjectHandle() = default;
- ObjectHandle::ObjectHandle(ObjectId id, ObjectSerial serial) : id(id), serial(serial) {}
- ObjectHandle::ObjectHandle(const volatile ObjectHandle& rhs) : id(rhs.id), serial(rhs.serial) {}
+ ObjectHandle::ObjectHandle(ObjectId id, ObjectGeneration generation)
+ : id(id), generation(generation) {
+ }
+ ObjectHandle::ObjectHandle(const volatile ObjectHandle& rhs)
+ : id(rhs.id), generation(rhs.generation) {
+ }
ObjectHandle& ObjectHandle::AssignFrom(const ObjectHandle& rhs) {
id = rhs.id;
- serial = rhs.serial;
+ generation = rhs.generation;
return *this;
}
ObjectHandle& ObjectHandle::AssignFrom(const volatile ObjectHandle& rhs) {
id = rhs.id;
- serial = rhs.serial;
+ generation = rhs.generation;
return *this;
}
diff --git a/generator/templates/dawn_wire/WireCmd.h b/generator/templates/dawn_wire/WireCmd.h
index 11e2b78..b54f5de 100644
--- a/generator/templates/dawn_wire/WireCmd.h
+++ b/generator/templates/dawn_wire/WireCmd.h
@@ -20,13 +20,13 @@
namespace dawn_wire {
using ObjectId = uint32_t;
- using ObjectSerial = uint32_t;
+ using ObjectGeneration = uint32_t;
struct ObjectHandle {
ObjectId id;
- ObjectSerial serial;
+ ObjectGeneration generation;
ObjectHandle();
- ObjectHandle(ObjectId id, ObjectSerial serial);
+ ObjectHandle(ObjectId id, ObjectGeneration generation);
ObjectHandle(const volatile ObjectHandle& rhs);
// MSVC has a bug where it thinks the volatile copy assignment is a duplicate.
diff --git a/generator/templates/dawn_wire/client/ApiProcs.cpp b/generator/templates/dawn_wire/client/ApiProcs.cpp
index 1659cdf..cc126d7 100644
--- a/generator/templates/dawn_wire/client/ApiProcs.cpp
+++ b/generator/templates/dawn_wire/client/ApiProcs.cpp
@@ -47,7 +47,7 @@
//* For object creation, store the object ID the client will use for the result.
{% if method.return_type.category == "object" %}
auto* allocation = self->device->GetClient()->{{method.return_type.name.CamelCase()}}Allocator().New(self->device);
- cmd.result = ObjectHandle{allocation->object->id, allocation->serial};
+ cmd.result = ObjectHandle{allocation->object->id, allocation->generation};
{% endif %}
{% for arg in method.arguments %}
diff --git a/generator/templates/dawn_wire/client/ClientHandlers.cpp b/generator/templates/dawn_wire/client/ClientHandlers.cpp
index f275b33..0055e66 100644
--- a/generator/templates/dawn_wire/client/ClientHandlers.cpp
+++ b/generator/templates/dawn_wire/client/ClientHandlers.cpp
@@ -33,8 +33,8 @@
{% if member.type.dict_name == "ObjectHandle" %}
{{Type}}* {{name}} = {{Type}}Allocator().GetObject(cmd.{{name}}.id);
- uint32_t {{name}}Serial = {{Type}}Allocator().GetSerial(cmd.{{name}}.id);
- if ({{name}}Serial != cmd.{{name}}.serial) {
+ uint32_t {{name}}Generation = {{Type}}Allocator().GetGeneration(cmd.{{name}}.id);
+ if ({{name}}Generation != cmd.{{name}}.generation) {
{{name}} = nullptr;
}
{% endif %}
diff --git a/generator/templates/dawn_wire/server/ServerHandlers.cpp b/generator/templates/dawn_wire/server/ServerHandlers.cpp
index d480bde..8dc155e 100644
--- a/generator/templates/dawn_wire/server/ServerHandlers.cpp
+++ b/generator/templates/dawn_wire/server/ServerHandlers.cpp
@@ -52,7 +52,7 @@
if ({{name}}Data == nullptr) {
return false;
}
- {{name}}Data->serial = cmd.{{name}}.serial;
+ {{name}}Data->generation = cmd.{{name}}.generation;
{% endfor %}
//* Do command
diff --git a/src/dawn_wire/client/ApiProcs.cpp b/src/dawn_wire/client/ApiProcs.cpp
index b6af3a3..d4fdecf 100644
--- a/src/dawn_wire/client/ApiProcs.cpp
+++ b/src/dawn_wire/client/ApiProcs.cpp
@@ -121,7 +121,7 @@
DeviceCreateBufferCmd cmd;
cmd.self = cDevice;
cmd.descriptor = descriptor;
- cmd.result = ObjectHandle{buffer->id, bufferObjectAndSerial->serial};
+ cmd.result = ObjectHandle{buffer->id, bufferObjectAndSerial->generation};
size_t requiredSize = cmd.GetRequiredSize();
char* allocatedBuffer = static_cast<char*>(wireClient->GetCmdSpace(requiredSize));
@@ -176,7 +176,7 @@
DeviceCreateBufferMappedCmd cmd;
cmd.device = cDevice;
cmd.descriptor = descriptor;
- cmd.result = ObjectHandle{buffer->id, bufferObjectAndSerial->serial};
+ cmd.result = ObjectHandle{buffer->id, bufferObjectAndSerial->generation};
cmd.handleCreateInfoLength = handleCreateInfoLength;
cmd.handleCreateInfo = nullptr;
@@ -252,7 +252,7 @@
cmd.device = cDevice;
cmd.descriptor = descriptor;
cmd.requestSerial = serial;
- cmd.result = ObjectHandle{buffer->id, bufferObjectAndSerial->serial};
+ cmd.result = ObjectHandle{buffer->id, bufferObjectAndSerial->generation};
cmd.handleCreateInfoLength = handleCreateInfoLength;
cmd.handleCreateInfo = nullptr;
@@ -391,7 +391,7 @@
QueueCreateFenceCmd cmd;
cmd.self = cSelf;
auto* allocation = device->GetClient()->FenceAllocator().New(device);
- cmd.result = ObjectHandle{allocation->object->id, allocation->serial};
+ cmd.result = ObjectHandle{allocation->object->id, allocation->generation};
cmd.descriptor = descriptor;
size_t requiredSize = cmd.GetRequiredSize();
diff --git a/src/dawn_wire/client/Client.cpp b/src/dawn_wire/client/Client.cpp
index 572086f..71c1a5f 100644
--- a/src/dawn_wire/client/Client.cpp
+++ b/src/dawn_wire/client/Client.cpp
@@ -40,7 +40,7 @@
ReservedTexture result;
result.texture = reinterpret_cast<WGPUTexture>(allocation->object.get());
result.id = allocation->object->id;
- result.generation = allocation->serial;
+ result.generation = allocation->generation;
return result;
}
diff --git a/src/dawn_wire/client/ObjectAllocator.h b/src/dawn_wire/client/ObjectAllocator.h
index b8db86f..19a3122 100644
--- a/src/dawn_wire/client/ObjectAllocator.h
+++ b/src/dawn_wire/client/ObjectAllocator.h
@@ -33,11 +33,11 @@
public:
struct ObjectAndSerial {
- ObjectAndSerial(std::unique_ptr<T> object, uint32_t serial)
- : object(std::move(object)), serial(serial) {
+ ObjectAndSerial(std::unique_ptr<T> object, uint32_t generation)
+ : object(std::move(object)), generation(generation) {
}
std::unique_ptr<T> object;
- uint32_t serial;
+ uint32_t generation;
};
ObjectAllocator() {
@@ -55,10 +55,10 @@
} else {
ASSERT(mObjects[id].object == nullptr);
- mObjects[id].serial++;
- // The serial should never overflow. We don't recycle ObjectIds that would overflow
- // their next serial.
- ASSERT(mObjects[id].serial != 0);
+ mObjects[id].generation++;
+ // The generation should never overflow. We don't recycle ObjectIds that would
+ // overflow their next generation.
+ ASSERT(mObjects[id].generation != 0);
mObjects[id].object = std::move(object);
}
@@ -66,8 +66,9 @@
return &mObjects[id];
}
void Free(T* obj) {
- if (DAWN_LIKELY(mObjects[obj->id].serial != std::numeric_limits<uint32_t>::max())) {
- // Only recycle this ObjectId if the serial won't overflow on the next allocation.
+ if (DAWN_LIKELY(mObjects[obj->id].generation != std::numeric_limits<uint32_t>::max())) {
+ // Only recycle this ObjectId if the generation won't overflow on the next
+ // allocation.
FreeId(obj->id);
}
mObjects[obj->id].object = nullptr;
@@ -80,11 +81,11 @@
return mObjects[id].object.get();
}
- uint32_t GetSerial(uint32_t id) {
+ uint32_t GetGeneration(uint32_t id) {
if (id >= mObjects.size()) {
return 0;
}
- return mObjects[id].serial;
+ return mObjects[id].generation;
}
private:
diff --git a/src/dawn_wire/server/ObjectStorage.h b/src/dawn_wire/server/ObjectStorage.h
index e98966d..9963158 100644
--- a/src/dawn_wire/server/ObjectStorage.h
+++ b/src/dawn_wire/server/ObjectStorage.h
@@ -25,9 +25,9 @@
template <typename T>
struct ObjectDataBase {
- // The backend-provided handle and serial to this object.
+ // The backend-provided handle and generation to this object.
T handle;
- uint32_t serial = 0;
+ uint32_t generation = 0;
// Whether this object has been allocated, used by the KnownObjects queries
// TODO(cwallez@chromium.org): make this an internal bit vector in KnownObjects.
diff --git a/src/dawn_wire/server/Server.cpp b/src/dawn_wire/server/Server.cpp
index d05285d..31b52dc 100644
--- a/src/dawn_wire/server/Server.cpp
+++ b/src/dawn_wire/server/Server.cpp
@@ -50,7 +50,7 @@
}
data->handle = texture;
- data->serial = generation;
+ data->generation = generation;
data->allocated = true;
// The texture is externally owned so it shouldn't be destroyed when we receive a destroy
diff --git a/src/dawn_wire/server/ServerBuffer.cpp b/src/dawn_wire/server/ServerBuffer.cpp
index 5841a93..1d0f767 100644
--- a/src/dawn_wire/server/ServerBuffer.cpp
+++ b/src/dawn_wire/server/ServerBuffer.cpp
@@ -70,7 +70,7 @@
std::unique_ptr<MapUserdata> userdata = std::make_unique<MapUserdata>();
userdata->server = this;
- userdata->buffer = ObjectHandle{bufferId, buffer->serial};
+ userdata->buffer = ObjectHandle{bufferId, buffer->generation};
userdata->requestSerial = requestSerial;
// The handle will point to the mapped memory or staging memory for the mapping.
@@ -120,7 +120,7 @@
if (resultData == nullptr) {
return false;
}
- resultData->serial = bufferResult.serial;
+ resultData->generation = bufferResult.generation;
WGPUCreateBufferMappedResult result = mProcs.deviceCreateBufferMapped(device, descriptor);
ASSERT(result.buffer != nullptr);
@@ -168,7 +168,7 @@
ASSERT(bufferData != nullptr);
ReturnBufferMapWriteAsyncCallbackCmd cmd;
- cmd.buffer = ObjectHandle{bufferResult.id, bufferResult.serial};
+ cmd.buffer = ObjectHandle{bufferResult.id, bufferResult.generation};
cmd.requestSerial = requestSerial;
cmd.status = bufferData->mapWriteState == BufferMapWriteState::Mapped
? WGPUBufferMapAsyncStatus_Success
@@ -260,7 +260,7 @@
// Skip sending the callback if the buffer has already been destroyed.
auto* bufferData = BufferObjects().Get(data->buffer.id);
- if (bufferData == nullptr || bufferData->serial != data->buffer.serial) {
+ if (bufferData == nullptr || bufferData->generation != data->buffer.generation) {
return;
}
@@ -302,7 +302,7 @@
// Skip sending the callback if the buffer has already been destroyed.
auto* bufferData = BufferObjects().Get(data->buffer.id);
- if (bufferData == nullptr || bufferData->serial != data->buffer.serial) {
+ if (bufferData == nullptr || bufferData->generation != data->buffer.generation) {
return;
}
diff --git a/src/dawn_wire/server/ServerQueue.cpp b/src/dawn_wire/server/ServerQueue.cpp
index 9ed58b4..4ec808e 100644
--- a/src/dawn_wire/server/ServerQueue.cpp
+++ b/src/dawn_wire/server/ServerQueue.cpp
@@ -31,7 +31,7 @@
FenceCompletionUserdata* userdata = new FenceCompletionUserdata;
userdata->server = this;
- userdata->fence = ObjectHandle{fenceId, fence->serial};
+ userdata->fence = ObjectHandle{fenceId, fence->generation};
userdata->value = signalValue;
mProcs.fenceOnCompletion(cFence, signalValue, ForwardFenceCompletedValue, userdata);