[dawn][headers] Removes default UTF16 support.
- Removes the UTF16 fields from the default CompilationMessage
struct now that it has been moved into the extension.
Bug: 377940841
Change-Id: I1dd6d28efd65761781cff70f3b25b90bd0f9e032
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/228956
Commit-Queue: Loko Kung <lokokung@google.com>
Auto-Submit: Loko Kung <lokokung@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json
index 49e0fa8..c84def4 100644
--- a/src/dawn/dawn.json
+++ b/src/dawn/dawn.json
@@ -958,10 +958,7 @@
{"name": "line num", "type": "uint64_t"},
{"name": "line pos", "type": "uint64_t"},
{"name": "offset", "type": "uint64_t"},
- {"name": "length", "type": "uint64_t"},
- {"name": "utf16 line pos", "type": "uint64_t", "default": "0"},
- {"name": "utf16 offset", "type": "uint64_t", "default": "0"},
- {"name": "utf16 length", "type": "uint64_t", "default": "0"}
+ {"name": "length", "type": "uint64_t"}
]
},
"dawn compilation message utf16": {
diff --git a/src/dawn/native/CompilationMessages.cpp b/src/dawn/native/CompilationMessages.cpp
index 56d3e37..a3499ac 100644
--- a/src/dawn/native/CompilationMessages.cpp
+++ b/src/dawn/native/CompilationMessages.cpp
@@ -94,7 +94,7 @@
m.type = type;
AddMessage(m);
- mUtf16.push_back(std::nullopt);
+ mUtf16.push_back({});
}
void OwnedCompilationMessages::AddMessageForTesting(std::string_view message,
@@ -182,9 +182,6 @@
m.linePos = linePosInBytes;
m.offset = offsetInBytes;
m.length = lengthInBytes;
- m.utf16LinePos = linePosInUTF16;
- m.utf16Offset = offsetInUTF16;
- m.utf16Length = lengthInUTF16;
AddMessage(m);
DawnCompilationMessageUtf16 utf16 = {};
@@ -242,9 +239,7 @@
// Append the UTF16 extension now.
DAWN_ASSERT(mMessages.size() == mUtf16.size());
for (size_t i = 0; i < mMessages.size(); i++) {
- if (const auto& utf16 = mUtf16.at(i)) {
- mMessages[i].nextInChain = &utf16.value();
- }
+ mMessages[i].nextInChain = &mUtf16[i];
}
(*info).emplace();
diff --git a/src/dawn/native/CompilationMessages.h b/src/dawn/native/CompilationMessages.h
index bfac70b..78548f7 100644
--- a/src/dawn/native/CompilationMessages.h
+++ b/src/dawn/native/CompilationMessages.h
@@ -79,7 +79,7 @@
MutexProtected<std::optional<CompilationInfo>> mCompilationInfo = std::nullopt;
std::vector<std::unique_ptr<std::string>> mMessageStrings;
std::vector<CompilationMessage> mMessages;
- std::vector<std::optional<DawnCompilationMessageUtf16>> mUtf16;
+ std::vector<DawnCompilationMessageUtf16> mUtf16;
std::vector<std::string> mFormattedTintMessages;
};
diff --git a/src/dawn/node/binding/GPUShaderModule.cpp b/src/dawn/node/binding/GPUShaderModule.cpp
index 1f044c0..73f0831 100644
--- a/src/dawn/node/binding/GPUShaderModule.cpp
+++ b/src/dawn/node/binding/GPUShaderModule.cpp
@@ -55,21 +55,20 @@
explicit GPUCompilationMessage(const wgpu::CompilationMessage& m)
: lineNum(m.lineNum),
- linePos(m.linePos),
- offset(m.offset),
- length(m.length),
message(m.message) {
- // If possible, we always want to take the UTF-16 values, otherwise, by default we take
- // the UTF-8 ones specified in wgpu::CompilationMessage;
+ bool foundUtf16 = false;
for (const auto* chain = m.nextInChain; chain != nullptr; chain = chain->nextInChain) {
if (chain->sType == wgpu::SType::DawnCompilationMessageUtf16) {
+ assert(!foundUtf16);
+ foundUtf16 = true;
const auto* utf16 =
- reinterpret_cast<const wgpu::DawnCompilationMessageUtf16*>(m.nextInChain);
+ reinterpret_cast<const wgpu::DawnCompilationMessageUtf16*>(chain);
linePos = utf16->linePos;
offset = utf16->offset;
length = utf16->length;
}
}
+ assert(foundUtf16);
switch (m.type) {
case wgpu::CompilationMessageType::Error:
diff --git a/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp b/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp
index db00dcd..37bc486 100644
--- a/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/ShaderModuleValidationTests.cpp
@@ -758,7 +758,6 @@
ASSERT_EQ(wgpu::CompilationMessageType::Error, message->type);
ASSERT_EQ(0u, message->lineNum);
ASSERT_EQ(0u, message->linePos);
- ASSERT_EQ(nullptr, message->nextInChain);
});
FlushWire();