File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
packages/typegpu/src/core/buffer Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -187,8 +187,23 @@ class TgpuBufferImpl<TData extends AnyData> implements TgpuBuffer<TData> {
187187 return this as this & UnionToIntersection < LiteralToUsageType < T [ number ] > > ;
188188 }
189189
190- // Temporary solution
191190 $addFlags ( flags : GPUBufferUsageFlags ) {
191+ if ( ! this . _ownBuffer ) {
192+ throw new Error (
193+ 'Cannot add flags to a buffer that is not managed by TypeGPU.' ,
194+ ) ;
195+ }
196+
197+ if ( flags & GPUBufferUsage . MAP_READ ) {
198+ this . flags = GPUBufferUsage . COPY_DST | GPUBufferUsage . MAP_READ ;
199+ return this ;
200+ }
201+
202+ if ( flags & GPUBufferUsage . MAP_WRITE ) {
203+ this . flags = GPUBufferUsage . COPY_SRC | GPUBufferUsage . MAP_WRITE ;
204+ return this ;
205+ }
206+
192207 this . flags |= flags ;
193208 return this ;
194209 }
You can’t perform that action at this time.
0 commit comments