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

Tweaks to the mapAsync function. #796

@Kangz

Description

@Kangz

While discussing #708 there was some concern by @kvark that mapAsync didn't show clearly in the place where it was called if it was for reading and writing, and given the semantics of the two are very different, this can be confusing.

The two proposed solutions are:

  • Splitting into two different entrypoints mapReadAsync and mapWriteAsync:
partial interface GPUBuffer {
    Promise<void> mapReadAsync(
        optional GPUSize64 offset = 0,
        optional GPUSize64 size = 0);
    Promise<void> mapWriteAsync(
         optional GPUSize64 offset = 0,
         optional GPUSize64 size = 0);
    // getMappedRange and unmap are unchanged
}
  • Adding map flags (@jdashg's idea) that could later be used to extend mapAsync with more modes:
typedef [EnforceRange] unsigned long GPUMappingFlags;
interface GPUMapping {
    const GPUMappingFlags READ  = 0x01;
    const GPUMappingFlags WRITE = 0x02;
};

partial interface GPUBuffer {
    Promise<void> mapAsync(
         GPUMappingFlags flags,
         optional GPUSize64 offset = 0,
         optional GPUSize64 size = 0);
}

I think either solution would work well, and don't have an opinion either way, but resolution of this is blocking our implementation of the new mapping so it would be nice to decide.

+CC @kvark @jdashg @litherum @kainino0x @RafaelCintron

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions