这是indexloc提供的服务,不要输入任何密码
Skip to content

Buffer state validation in unmap() is unnecessary #3251

@kainino0x

Description

@kainino0x

Currently, unmap() validates that the buffer is currently mapped or pending. This seems unnecessary, as unmap() can be treated as idempotent, i.e. a no-op on buffers that aren't mapped.

Right now, there's a bit of an issue with the state. Unmap does the following:

  • Terminate access to the mapping from JS, and get the data out of the ArrayBuffer to send. <- State validation hasn't happened yet here, so this has to work regardless of the state.
  • Send the updated data to the GPU process to update the buffer, and mark it as available to the GPU again. <- sending a message to the GPU process is entirely unnecessary if the content process already knows it's going to fail.

An alternative would be to make this an exception instead of a no-op. However, I don't think an exception is necessary. Either way is fine because unmap() still does validation before messaging the GPU process.

Also note: This is the only validation error generated from a method of GPUBuffer, which forces GPUBuffer to know what GPUDevice (error scope stack) to report errors back to. (May interact with #3250.)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions