Skip to content

Commit

Permalink
quick fix hang due to u32 overflow when computing wgpu buffer limits
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfouilleul committed Jun 3, 2024
1 parent e76738b commit ffc3c8a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/graphics/wgpu_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2297,9 +2297,9 @@ bool oc_wgpu_grow_buffer_if_needed(oc_wgpu_canvas_renderer* renderer,
wgpuBufferRelease(*buffer);
}

u32 newCap = oc_max(minCap * 1.5, OC_WGPU_CANVAS_BUFFER_DEFAULT_LEN);
u32 bufferLimit = oc_min(renderer->limits.maxBufferSize, renderer->limits.maxStorageBufferBindingSize);
u32 newSize = oc_clamp_high(newCap * eltSize, bufferLimit);
u64 newCap = oc_max(minCap * 1.5, OC_WGPU_CANVAS_BUFFER_DEFAULT_LEN);
u64 bufferLimit = oc_min(renderer->limits.maxBufferSize, renderer->limits.maxStorageBufferBindingSize);
u64 newSize = oc_clamp_high(newCap * eltSize, bufferLimit);

WGPUBufferDescriptor desc = {
.label = label,
Expand Down Expand Up @@ -3039,8 +3039,8 @@ bool oc_wgpu_canvas_encode_batch(oc_wgpu_canvas_encoding_context* context)

//NOTE: check encoding limits
{
u32 bufferLimit = oc_min(renderer->limits.maxBufferSize, renderer->limits.maxStorageBufferBindingSize);
u32 maxTileQueues = oc_min(context->maxBinQueueCount, context->screenTilesCount);
u64 bufferLimit = oc_min(renderer->limits.maxBufferSize, renderer->limits.maxStorageBufferBindingSize);
u64 maxTileQueues = oc_min(context->maxBinQueueCount, context->screenTilesCount);

if(context->pathCount * sizeof(oc_wgpu_path) >= bufferLimit
|| context->eltCount * sizeof(oc_wgpu_path_elt) >= bufferLimit
Expand Down

0 comments on commit ffc3c8a

Please sign in to comment.