Skip to content

Commit e7e7c62

Browse files
committed
allow to prevent cache hits in buffer from array
1 parent 5fa2253 commit e7e7c62

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

webgpu/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def create_buffer(
527527

528528

529529
def buffer_from_array(
530-
data, usage=BufferUsage.STORAGE, label="from_array", reuse: Buffer | None = None
530+
data, usage=BufferUsage.STORAGE, label="from_array", reuse: Buffer | None = None, use_cache: bool = True
531531
) -> Buffer:
532532

533533
device = get_device()
@@ -537,7 +537,7 @@ def buffer_from_array(
537537

538538
n = len(data)
539539

540-
if n < 1024:
540+
if use_cache and n < 1024:
541541
if reuse and hasattr(reuse, '_data') and data == reuse._data:
542542
return reuse
543543
ori_data = data
@@ -559,7 +559,7 @@ def buffer_from_array(
559559
else:
560560
device.queue.writeBuffer(buffer, 0, data, 0, len(data))
561561

562-
if n < 1024:
562+
if use_cache and n < 1024:
563563
buffer._data = ori_data
564564

565565
return buffer

0 commit comments

Comments
 (0)