mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-05 14:13:39 +00:00
Make CompilationInfo extensible.
This adds overloads for WireCmd [De]serialization that don't take the object id provider/resolvers and produce a fatal error as soon as an object is encountered. Bug: dawn:1186 Change-Id: I13e796a5d8f59c26279b9079d4496390506c739a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68941 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Loko Kung <lokokung@google.com>
This commit is contained in:
parent
0931cf730e
commit
61c853276f
@ -594,8 +594,7 @@
|
|||||||
},
|
},
|
||||||
"compilation info": {
|
"compilation info": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"extensible": false,
|
"extensible": "in",
|
||||||
"_TODO": "should be extensible, but need to make that work in wire: https://github.com/webgpu-native/webgpu-headers/issues/82",
|
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "message count", "type": "uint32_t"},
|
{"name": "message count", "type": "uint32_t"},
|
||||||
{"name": "messages", "type": "compilation message", "annotation": "const*", "length": "message count"}
|
{"name": "messages", "type": "compilation message", "annotation": "const*", "length": "message count"}
|
||||||
@ -603,7 +602,6 @@
|
|||||||
},
|
},
|
||||||
"compilation info callback": {
|
"compilation info callback": {
|
||||||
"category": "callback",
|
"category": "callback",
|
||||||
"tags": ["dawn"],
|
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "status", "type": "compilation info request status"},
|
{"name": "status", "type": "compilation info request status"},
|
||||||
{"name": "compilation info", "type": "compilation info", "annotation": "const*"},
|
{"name": "compilation info", "type": "compilation info", "annotation": "const*"},
|
||||||
@ -612,7 +610,6 @@
|
|||||||
},
|
},
|
||||||
"compilation info request status": {
|
"compilation info request status": {
|
||||||
"category": "enum",
|
"category": "enum",
|
||||||
"tags": ["dawn"],
|
|
||||||
"values": [
|
"values": [
|
||||||
{"value": 0, "name": "success"},
|
{"value": 0, "name": "success"},
|
||||||
{"value": 1, "name": "error"},
|
{"value": 1, "name": "error"},
|
||||||
@ -622,8 +619,7 @@
|
|||||||
},
|
},
|
||||||
"compilation message": {
|
"compilation message": {
|
||||||
"category": "structure",
|
"category": "structure",
|
||||||
"extensible": false,
|
"extensible": "in",
|
||||||
"_TODO": "should be extensible, but need to make that work in wire: https://github.com/webgpu-native/webgpu-headers/issues/82",
|
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "message", "type": "char", "annotation": "const*", "length": "strlen", "optional": true},
|
{"name": "message", "type": "char", "annotation": "const*", "length": "strlen", "optional": true},
|
||||||
{"name": "type", "type": "compilation message type"},
|
{"name": "type", "type": "compilation message type"},
|
||||||
@ -1942,7 +1938,6 @@
|
|||||||
"methods": [
|
"methods": [
|
||||||
{
|
{
|
||||||
"name": "get compilation info",
|
"name": "get compilation info",
|
||||||
"tags": ["dawn"],
|
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "callback", "type": "compilation info callback"},
|
{"name": "callback", "type": "compilation info callback"},
|
||||||
{"name": "userdata", "type": "void", "annotation": "*"}
|
{"name": "userdata", "type": "void", "annotation": "*"}
|
||||||
|
@ -416,37 +416,63 @@
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
WireResult {{Cmd}}::Serialize(size_t commandSize, SerializeBuffer* buffer
|
{% if command.may_have_dawn_object %}
|
||||||
{%- if command.may_have_dawn_object -%}
|
WireResult {{Cmd}}::Serialize(
|
||||||
, const ObjectIdProvider& provider
|
size_t commandSize,
|
||||||
{%- endif -%}
|
SerializeBuffer* buffer,
|
||||||
) const {
|
const ObjectIdProvider& provider
|
||||||
{{Name}}Transfer* transfer;
|
) const {
|
||||||
WIRE_TRY(buffer->Next(&transfer));
|
{{Name}}Transfer* transfer;
|
||||||
transfer->commandSize = commandSize;
|
WIRE_TRY(buffer->Next(&transfer));
|
||||||
|
transfer->commandSize = commandSize;
|
||||||
|
return ({{Name}}Serialize(*this, transfer, buffer, provider));
|
||||||
|
}
|
||||||
|
WireResult {{Cmd}}::Serialize(size_t commandSize, SerializeBuffer* buffer) const {
|
||||||
|
ErrorObjectIdProvider provider;
|
||||||
|
return Serialize(commandSize, buffer, provider);
|
||||||
|
}
|
||||||
|
|
||||||
WIRE_TRY({{Name}}Serialize(*this, transfer, buffer
|
WireResult {{Cmd}}::Deserialize(
|
||||||
{%- if command.may_have_dawn_object -%}
|
DeserializeBuffer* deserializeBuffer,
|
||||||
, provider
|
DeserializeAllocator* allocator,
|
||||||
{%- endif -%}
|
const ObjectIdResolver& resolver
|
||||||
));
|
) {
|
||||||
return WireResult::Success;
|
const volatile {{Name}}Transfer* transfer;
|
||||||
}
|
WIRE_TRY(deserializeBuffer->Read(&transfer));
|
||||||
|
return {{Name}}Deserialize(this, transfer, deserializeBuffer, allocator, resolver);
|
||||||
|
}
|
||||||
|
WireResult {{Cmd}}::Deserialize(DeserializeBuffer* deserializeBuffer, DeserializeAllocator* allocator) {
|
||||||
|
ErrorObjectIdResolver resolver;
|
||||||
|
return Deserialize(deserializeBuffer, allocator, resolver);
|
||||||
|
}
|
||||||
|
{% else %}
|
||||||
|
WireResult {{Cmd}}::Serialize(size_t commandSize, SerializeBuffer* buffer) const {
|
||||||
|
{{Name}}Transfer* transfer;
|
||||||
|
WIRE_TRY(buffer->Next(&transfer));
|
||||||
|
transfer->commandSize = commandSize;
|
||||||
|
return ({{Name}}Serialize(*this, transfer, buffer));
|
||||||
|
}
|
||||||
|
WireResult {{Cmd}}::Serialize(
|
||||||
|
size_t commandSize,
|
||||||
|
SerializeBuffer* buffer,
|
||||||
|
const ObjectIdProvider&
|
||||||
|
) const {
|
||||||
|
return Serialize(commandSize, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
WireResult {{Cmd}}::Deserialize(DeserializeBuffer* deserializeBuffer, DeserializeAllocator* allocator
|
WireResult {{Cmd}}::Deserialize(DeserializeBuffer* deserializeBuffer, DeserializeAllocator* allocator) {
|
||||||
{%- if command.may_have_dawn_object -%}
|
const volatile {{Name}}Transfer* transfer;
|
||||||
, const ObjectIdResolver& resolver
|
WIRE_TRY(deserializeBuffer->Read(&transfer));
|
||||||
{%- endif -%}
|
return {{Name}}Deserialize(this, transfer, deserializeBuffer, allocator);
|
||||||
) {
|
}
|
||||||
const volatile {{Name}}Transfer* transfer;
|
WireResult {{Cmd}}::Deserialize(
|
||||||
WIRE_TRY(deserializeBuffer->Read(&transfer));
|
DeserializeBuffer* deserializeBuffer,
|
||||||
|
DeserializeAllocator* allocator,
|
||||||
return {{Name}}Deserialize(this, transfer, deserializeBuffer, allocator
|
const ObjectIdResolver&
|
||||||
{%- if command.may_have_dawn_object -%}
|
) {
|
||||||
, resolver
|
return Deserialize(deserializeBuffer, allocator);
|
||||||
{%- endif -%}
|
}
|
||||||
);
|
{% endif %}
|
||||||
}
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro make_chained_struct_serialization_helpers(out=None) %}
|
{% macro make_chained_struct_serialization_helpers(out=None) %}
|
||||||
|
@ -98,17 +98,9 @@ namespace dawn_wire {
|
|||||||
|
|
||||||
//* Serialize the structure and everything it points to into serializeBuffer which must be
|
//* Serialize the structure and everything it points to into serializeBuffer which must be
|
||||||
//* big enough to contain all the data (as queried from GetRequiredSize).
|
//* big enough to contain all the data (as queried from GetRequiredSize).
|
||||||
{% if command.may_have_dawn_object %}
|
WireResult Serialize(size_t commandSize, SerializeBuffer* serializeBuffer, const ObjectIdProvider& objectIdProvider) const;
|
||||||
WireResult Serialize(size_t commandSize, SerializeBuffer* serializeBuffer, const ObjectIdProvider& objectIdProvider) const;
|
// Override which produces a FatalError if any object is used.
|
||||||
{% else %}
|
WireResult Serialize(size_t commandSize, SerializeBuffer* serializeBuffer) const;
|
||||||
WireResult Serialize(size_t commandSize, SerializeBuffer* serializeBuffer) const;
|
|
||||||
// Override which drops the provider if it's not needed.
|
|
||||||
WireResult Serialize(size_t commandSize,
|
|
||||||
SerializeBuffer* serializeBuffer,
|
|
||||||
const ObjectIdProvider&) const {
|
|
||||||
return Serialize(commandSize, serializeBuffer);
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
//* Deserializes the structure from a buffer, consuming a maximum of *size bytes. When this
|
//* Deserializes the structure from a buffer, consuming a maximum of *size bytes. When this
|
||||||
//* function returns, buffer and size will be updated by the number of bytes consumed to
|
//* function returns, buffer and size will be updated by the number of bytes consumed to
|
||||||
@ -117,11 +109,9 @@ namespace dawn_wire {
|
|||||||
//* Deserialize returns:
|
//* Deserialize returns:
|
||||||
//* - Success if everything went well (yay!)
|
//* - Success if everything went well (yay!)
|
||||||
//* - FatalError is something bad happened (buffer too small for example)
|
//* - FatalError is something bad happened (buffer too small for example)
|
||||||
WireResult Deserialize(DeserializeBuffer* deserializeBuffer, DeserializeAllocator* allocator
|
WireResult Deserialize(DeserializeBuffer* deserializeBuffer, DeserializeAllocator* allocator, const ObjectIdResolver& resolver);
|
||||||
{%- if command.may_have_dawn_object -%}
|
// Override which produces a FatalError if any object is used.
|
||||||
, const ObjectIdResolver& resolver
|
WireResult Deserialize(DeserializeBuffer* deserializeBuffer, DeserializeAllocator* allocator);
|
||||||
{%- endif -%}
|
|
||||||
);
|
|
||||||
|
|
||||||
{% if command.derived_method %}
|
{% if command.derived_method %}
|
||||||
//* Command handlers want to know the object ID in addition to the backing object.
|
//* Command handlers want to know the object ID in addition to the backing object.
|
||||||
|
@ -37,6 +37,7 @@ namespace dawn_native {
|
|||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
OwnedCompilationMessages::OwnedCompilationMessages() {
|
OwnedCompilationMessages::OwnedCompilationMessages() {
|
||||||
|
mCompilationInfo.nextInChain = 0;
|
||||||
mCompilationInfo.messageCount = 0;
|
mCompilationInfo.messageCount = 0;
|
||||||
mCompilationInfo.messages = nullptr;
|
mCompilationInfo.messages = nullptr;
|
||||||
}
|
}
|
||||||
@ -51,8 +52,8 @@ namespace dawn_native {
|
|||||||
ASSERT(mCompilationInfo.messages == nullptr);
|
ASSERT(mCompilationInfo.messages == nullptr);
|
||||||
|
|
||||||
mMessageStrings.push_back(message);
|
mMessageStrings.push_back(message);
|
||||||
mMessages.push_back({nullptr, static_cast<WGPUCompilationMessageType>(type), lineNum,
|
mMessages.push_back({nullptr, nullptr, static_cast<WGPUCompilationMessageType>(type),
|
||||||
linePos, offset, length});
|
lineNum, linePos, offset, length});
|
||||||
}
|
}
|
||||||
|
|
||||||
void OwnedCompilationMessages::AddMessage(const tint::diag::Diagnostic& diagnostic) {
|
void OwnedCompilationMessages::AddMessage(const tint::diag::Diagnostic& diagnostic) {
|
||||||
@ -100,8 +101,8 @@ namespace dawn_native {
|
|||||||
mMessageStrings.push_back(diagnostic.message);
|
mMessageStrings.push_back(diagnostic.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
mMessages.push_back({nullptr, tintSeverityToMessageType(diagnostic.severity), lineNum,
|
mMessages.push_back({nullptr, nullptr, tintSeverityToMessageType(diagnostic.severity),
|
||||||
linePos, offset, length});
|
lineNum, linePos, offset, length});
|
||||||
}
|
}
|
||||||
|
|
||||||
void OwnedCompilationMessages::AddMessages(const tint::diag::List& diagnostics) {
|
void OwnedCompilationMessages::AddMessages(const tint::diag::List& diagnostics) {
|
||||||
|
@ -87,8 +87,10 @@ class WireShaderModuleTests : public WireTest {
|
|||||||
TEST_F(WireShaderModuleTests, GetCompilationInfo) {
|
TEST_F(WireShaderModuleTests, GetCompilationInfo) {
|
||||||
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockGetCompilationInfoCallback, nullptr);
|
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockGetCompilationInfoCallback, nullptr);
|
||||||
|
|
||||||
WGPUCompilationMessage message = {"Test Message", WGPUCompilationMessageType_Info, 2, 4, 6, 8};
|
WGPUCompilationMessage message = {
|
||||||
|
nullptr, "Test Message", WGPUCompilationMessageType_Info, 2, 4, 6, 8};
|
||||||
WGPUCompilationInfo compilationInfo;
|
WGPUCompilationInfo compilationInfo;
|
||||||
|
compilationInfo.nextInChain = nullptr;
|
||||||
compilationInfo.messageCount = 1;
|
compilationInfo.messageCount = 1;
|
||||||
compilationInfo.messages = &message;
|
compilationInfo.messages = &message;
|
||||||
|
|
||||||
@ -108,6 +110,7 @@ TEST_F(WireShaderModuleTests, GetCompilationInfo) {
|
|||||||
}
|
}
|
||||||
const WGPUCompilationMessage* infoMessage = &info->messages[0];
|
const WGPUCompilationMessage* infoMessage = &info->messages[0];
|
||||||
return strcmp(infoMessage->message, message.message) == 0 &&
|
return strcmp(infoMessage->message, message.message) == 0 &&
|
||||||
|
infoMessage->nextInChain == message.nextInChain &&
|
||||||
infoMessage->type == message.type &&
|
infoMessage->type == message.type &&
|
||||||
infoMessage->lineNum == message.lineNum &&
|
infoMessage->lineNum == message.lineNum &&
|
||||||
infoMessage->linePos == message.linePos &&
|
infoMessage->linePos == message.linePos &&
|
||||||
@ -124,8 +127,10 @@ TEST_F(WireShaderModuleTests, GetCompilationInfo) {
|
|||||||
TEST_F(WireShaderModuleTests, GetCompilationInfoBeforeDisconnect) {
|
TEST_F(WireShaderModuleTests, GetCompilationInfoBeforeDisconnect) {
|
||||||
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockGetCompilationInfoCallback, nullptr);
|
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockGetCompilationInfoCallback, nullptr);
|
||||||
|
|
||||||
WGPUCompilationMessage message = {"Test Message", WGPUCompilationMessageType_Info, 2, 4, 6, 8};
|
WGPUCompilationMessage message = {
|
||||||
|
nullptr, "Test Message", WGPUCompilationMessageType_Info, 2, 4, 6, 8};
|
||||||
WGPUCompilationInfo compilationInfo;
|
WGPUCompilationInfo compilationInfo;
|
||||||
|
compilationInfo.nextInChain = nullptr;
|
||||||
compilationInfo.messageCount = 1;
|
compilationInfo.messageCount = 1;
|
||||||
compilationInfo.messages = &message;
|
compilationInfo.messages = &message;
|
||||||
|
|
||||||
@ -182,8 +187,10 @@ TEST_F(WireShaderModuleTests, GetCompilationInfoInsideCallbackBeforeDisconnect)
|
|||||||
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockBufferMapCallbackWithNewRequests,
|
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockBufferMapCallbackWithNewRequests,
|
||||||
&testData);
|
&testData);
|
||||||
|
|
||||||
WGPUCompilationMessage message = {"Test Message", WGPUCompilationMessageType_Info, 2, 4, 6, 8};
|
WGPUCompilationMessage message = {
|
||||||
|
nullptr, "Test Message", WGPUCompilationMessageType_Info, 2, 4, 6, 8};
|
||||||
WGPUCompilationInfo compilationInfo;
|
WGPUCompilationInfo compilationInfo;
|
||||||
|
compilationInfo.nextInChain = nullptr;
|
||||||
compilationInfo.messageCount = 1;
|
compilationInfo.messageCount = 1;
|
||||||
compilationInfo.messages = &message;
|
compilationInfo.messages = &message;
|
||||||
|
|
||||||
@ -207,8 +214,10 @@ TEST_F(WireShaderModuleTests, GetCompilationInfoInsideCallbackBeforeDestruction)
|
|||||||
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockBufferMapCallbackWithNewRequests,
|
wgpuShaderModuleGetCompilationInfo(shaderModule, ToMockBufferMapCallbackWithNewRequests,
|
||||||
&testData);
|
&testData);
|
||||||
|
|
||||||
WGPUCompilationMessage message = {"Test Message", WGPUCompilationMessageType_Info, 2, 4, 6, 8};
|
WGPUCompilationMessage message = {
|
||||||
|
nullptr, "Test Message", WGPUCompilationMessageType_Info, 2, 4, 6, 8};
|
||||||
WGPUCompilationInfo compilationInfo;
|
WGPUCompilationInfo compilationInfo;
|
||||||
|
compilationInfo.nextInChain = nullptr;
|
||||||
compilationInfo.messageCount = 1;
|
compilationInfo.messageCount = 1;
|
||||||
compilationInfo.messages = &message;
|
compilationInfo.messages = &message;
|
||||||
|
|
||||||
@ -223,4 +232,4 @@ TEST_F(WireShaderModuleTests, GetCompilationInfoInsideCallbackBeforeDestruction)
|
|||||||
Call(WGPUCompilationInfoRequestStatus_Unknown, nullptr, _))
|
Call(WGPUCompilationInfoRequestStatus_Unknown, nullptr, _))
|
||||||
.Times(1 + testData.numRequests);
|
.Times(1 + testData.numRequests);
|
||||||
wgpuShaderModuleRelease(shaderModule);
|
wgpuShaderModuleRelease(shaderModule);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user