@@ -81,8 +81,13 @@ impl Default for Usage {
8181/// Buffer allocation properties that control residency and CPU visibility.
8282#[ derive( Clone , Copy , Debug ) ]
8383///
84- /// Use `CPU_VISIBLE` for frequently updated data (e.g., uniform uploads).
85- /// Prefer `DEVICE_LOCAL` for static geometry uploaded once.
84+ /// Use `CPU_VISIBLE` for buffers you plan to update from the CPU using
85+ /// `Buffer::write_*` (this enables `wgpu::Queue::write_buffer` by adding the
86+ /// required `COPY_DST` usage).
87+ ///
88+ /// Prefer `DEVICE_LOCAL` for static geometry uploaded once and never modified.
89+ /// This is typically the best default for vertex and index buffers on discrete
90+ /// GPUs, where CPU-visible memory may live in system RAM rather than VRAM.
8691pub struct Properties {
8792 cpu_visible : bool ,
8893}
@@ -101,7 +106,7 @@ impl Properties {
101106
102107impl Default for Properties {
103108 fn default ( ) -> Self {
104- Properties :: CPU_VISIBLE
109+ Properties :: DEVICE_LOCAL
105110 }
106111}
107112
@@ -287,7 +292,7 @@ impl<T: PlainOldData> UniformBuffer<T> {
287292/// let vertices: Vec<Vertex> = build_vertices();
288293/// let vb = BufferBuilder::new()
289294/// .with_usage(Usage::VERTEX)
290- /// .with_properties( Properties::DEVICE_LOCAL)
295+ /// // Defaults to ` Properties::DEVICE_LOCAL` (recommended for static geometry).
291296/// .with_buffer_type(BufferType::Vertex)
292297/// .build(render_context, vertices)
293298/// .unwrap();
@@ -308,11 +313,16 @@ impl Default for BufferBuilder {
308313
309314impl BufferBuilder {
310315 /// Creates a new buffer builder of type vertex.
316+ ///
317+ /// Defaults:
318+ /// - `usage`: `Usage::VERTEX`
319+ /// - `properties`: `Properties::DEVICE_LOCAL`
320+ /// - `buffer_type`: `BufferType::Vertex`
311321 pub fn new ( ) -> Self {
312322 Self {
313323 buffer_length : 0 ,
314324 usage : Usage :: VERTEX ,
315- properties : Properties :: CPU_VISIBLE ,
325+ properties : Properties :: default ( ) ,
316326 buffer_type : BufferType :: Vertex ,
317327 label : None ,
318328 }
@@ -396,7 +406,7 @@ impl BufferBuilder {
396406 return builder
397407 . with_length ( std:: mem:: size_of_val ( mesh. vertices ( ) ) )
398408 . with_usage ( Usage :: VERTEX )
399- . with_properties ( Properties :: CPU_VISIBLE )
409+ . with_properties ( Properties :: DEVICE_LOCAL )
400410 . with_buffer_type ( BufferType :: Vertex )
401411 . build ( gpu, mesh. vertices ( ) . to_vec ( ) ) ;
402412 }
@@ -426,6 +436,17 @@ impl BufferBuilder {
426436mod tests {
427437 use super :: * ;
428438
439+ #[ test]
440+ fn properties_default_is_device_local ( ) {
441+ assert ! ( !Properties :: default ( ) . cpu_visible( ) ) ;
442+ }
443+
444+ #[ test]
445+ fn buffer_builder_defaults_to_device_local_properties ( ) {
446+ let builder = BufferBuilder :: new ( ) ;
447+ assert ! ( !builder. properties. cpu_visible( ) ) ;
448+ }
449+
429450 #[ test]
430451 fn resolve_length_rejects_zero ( ) {
431452 let builder = BufferBuilder :: new ( ) ;
0 commit comments