dawn.node: Detach buffer mappings on GPUBuffer.destroy.
Bug: dawn:1123 Change-Id: I662c60346a5c57030e932d636ea2f9d8519c5fc8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86142 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
6d7c44caa3
commit
f6bac0ca86
|
@ -139,23 +139,32 @@ namespace wgpu::binding {
|
|||
}
|
||||
|
||||
void GPUBuffer::unmap(Napi::Env env) {
|
||||
buffer_.Unmap();
|
||||
|
||||
if (state_ != State::Destroyed && state_ != State::Unmapped) {
|
||||
DetachMappings();
|
||||
state_ = State::Unmapped;
|
||||
}
|
||||
}
|
||||
|
||||
void GPUBuffer::destroy(Napi::Env) {
|
||||
if (state_ == State::Destroyed) {
|
||||
device_.InjectError(wgpu::ErrorType::Validation,
|
||||
"unmap() called on a destroyed buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (state_ != State::Unmapped) {
|
||||
DetachMappings();
|
||||
}
|
||||
|
||||
buffer_.Destroy();
|
||||
state_ = State::Destroyed;
|
||||
}
|
||||
|
||||
void GPUBuffer::DetachMappings() {
|
||||
for (auto& mapping : mapped_) {
|
||||
mapping.buffer.Value().Detach();
|
||||
}
|
||||
mapped_.clear();
|
||||
buffer_.Unmap();
|
||||
state_ = State::Unmapped;
|
||||
}
|
||||
|
||||
void GPUBuffer::destroy(Napi::Env) {
|
||||
buffer_.Destroy();
|
||||
state_ = State::Destroyed;
|
||||
}
|
||||
|
||||
std::variant<std::string, interop::UndefinedType> GPUBuffer::getLabel(Napi::Env) {
|
||||
|
|
|
@ -55,6 +55,8 @@ namespace wgpu::binding {
|
|||
void setLabel(Napi::Env, std::variant<std::string, interop::UndefinedType> value) override;
|
||||
|
||||
private:
|
||||
void DetachMappings();
|
||||
|
||||
struct Mapping {
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
|
|
Loading…
Reference in New Issue