Skip to content

Commit

Permalink
Remove explicit type WGpuBufferMappedRangeStartOffset - it is unneces…
Browse files Browse the repository at this point in the history
…sary, and not a real type in the spec.
  • Loading branch information
juj committed Nov 30, 2022
1 parent d6a9f6f commit 4f15eee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
9 changes: 4 additions & 5 deletions lib/lib_webgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ extern "C" {
// address 2^53 == 9007199254740992 = ~9.0 petabytes.
typedef double double_int53_t;

typedef double_int53_t WGpuBufferMappedRangeStartOffset;

// Returns the number of WebGPU objects referenced by the WebGPU JS library.
uint32_t wgpu_get_num_live_objects(void);
Expand Down Expand Up @@ -482,13 +481,13 @@ void wgpu_buffer_map_async(WGpuBuffer buffer, WGpuBufferMapCallback callback, vo
// Maps the given WGpuBuffer synchronously. Requires building with -sASYNCIFY=1 linker flag to work.
void wgpu_buffer_map_sync(WGpuBuffer buffer, WGPU_MAP_MODE_FLAGS mode, double_int53_t offset _WGPU_DEFAULT_VALUE(0), double_int53_t size _WGPU_DEFAULT_VALUE(WGPU_MAP_MAX_LENGTH));

#define WGPU_BUFFER_GET_MAPPED_RANGE_FAILED ((WGpuBufferMappedRangeStartOffset)-1)
#define WGPU_BUFFER_GET_MAPPED_RANGE_FAILED ((double_int53_t)-1)

// Calls buffer.getMappedRange(). Returns `startOffset`, which is used as an ID token to wgpu_buffer_read/write_mapped_range().
// If .getMappedRange() fails, the value WGPU_BUFFER_GET_MAPPED_RANGE_FAILED (-1) will be returned.
WGpuBufferMappedRangeStartOffset wgpu_buffer_get_mapped_range(WGpuBuffer buffer, double_int53_t startOffset, double_int53_t size _WGPU_DEFAULT_VALUE(WGPU_MAP_MAX_LENGTH));
void wgpu_buffer_read_mapped_range(WGpuBuffer buffer, WGpuBufferMappedRangeStartOffset startOffset, double_int53_t subOffset, void *dst __attribute__((nonnull)), double_int53_t size);
void wgpu_buffer_write_mapped_range(WGpuBuffer buffer, WGpuBufferMappedRangeStartOffset startOffset, double_int53_t subOffset, const void *src __attribute__((nonnull)), double_int53_t size);
double_int53_t wgpu_buffer_get_mapped_range(WGpuBuffer buffer, double_int53_t startOffset, double_int53_t size _WGPU_DEFAULT_VALUE(WGPU_MAP_MAX_LENGTH));
void wgpu_buffer_read_mapped_range(WGpuBuffer buffer, double_int53_t startOffset, double_int53_t subOffset, void *dst __attribute__((nonnull)), double_int53_t size);
void wgpu_buffer_write_mapped_range(WGpuBuffer buffer, double_int53_t startOffset, double_int53_t subOffset, const void *src __attribute__((nonnull)), double_int53_t size);
void wgpu_buffer_unmap(WGpuBuffer buffer);

// Getters for retrieving buffer properties:
Expand Down
2 changes: 0 additions & 2 deletions lib/lib_webgpu_fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ extern "C" {

typedef double double_int53_t;

typedef double_int53_t WGpuBufferMappedRangeStartOffset;

// The following should be kept sorted in the order of the WebIDL for easier diffing across changes to the spec: https://www.w3.org/TR/webgpu/#idl-index
// with the exception that the callback typedefs should appear last in this file to see the necessary definitions.

Expand Down
2 changes: 1 addition & 1 deletion samples/gpu_oom/gpu_oom.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void alloc_gpu_buffer()
WGpuBuffer buffer = wgpu_device_create_buffer(device, &bufferDesc);
wgpu_device_pop_error_scope_async(device, oom, 0);

WGpuBufferMappedRangeStartOffset ofs = wgpu_buffer_get_mapped_range(buffer, 0, allocSize);
double_int53_t ofs = wgpu_buffer_get_mapped_range(buffer, 0, allocSize);
if (ofs == WGPU_BUFFER_GET_MAPPED_RANGE_FAILED)
{
emscripten_mini_stdio_fprintf(EM_STDERR, "wgpu_buffer_get_mapped_range() of size %f failed!\n", (double)allocSize);
Expand Down

0 comments on commit 4f15eee

Please sign in to comment.