@@ -27,9 +27,9 @@ impl Atlas {
2727 context : & crate :: context:: Context ,
2828 ) -> Self {
2929 let max_size = context. max_texture_dimension_2d ( ) ;
30- let size = std:: cmp:: min ( 4096 , max_size) ;
30+ let size = std:: cmp:: min ( 2048 , max_size) ;
3131
32- tracing:: info!( "Creating layer atlas with size: {}x{}" , size, size) ;
32+ tracing:: info!( "Creating layer atlas with size: {}x{} (reduced from 4096 for memory efficiency) " , size, size) ;
3333
3434 let layers = match backend {
3535 wgpu:: Backend :: Gl => vec ! [ Layer :: Empty , Layer :: Empty ] ,
@@ -42,8 +42,7 @@ impl Atlas {
4242 depth_or_array_layers : layers. len ( ) as u32 ,
4343 } ;
4444
45- let texture_format = context. get_optimal_texture_format ( 4 ) ;
46-
45+ let texture_format = wgpu:: TextureFormat :: Rgba8Unorm ;
4746 let texture = device. create_texture ( & wgpu:: TextureDescriptor {
4847 label : Some ( "image texture atlas" ) ,
4948 size : extent,
@@ -107,7 +106,7 @@ impl Atlas {
107106 & mut self ,
108107 device : & wgpu:: Device ,
109108 backend : wgpu:: Backend ,
110- context : & crate :: context:: Context ,
109+ _context : & crate :: context:: Context ,
111110 ) {
112111 self . layers = match backend {
113112 wgpu:: Backend :: Gl => vec ! [ Layer :: Empty , Layer :: Empty ] ,
@@ -120,8 +119,7 @@ impl Atlas {
120119 depth_or_array_layers : self . layers . len ( ) as u32 ,
121120 } ;
122121
123- let texture_format = context. get_optimal_texture_format ( 4 ) ;
124-
122+ let texture_format = wgpu:: TextureFormat :: Rgba8Unorm ;
125123 self . texture = device. create_texture ( & wgpu:: TextureDescriptor {
126124 label : Some ( "image texture atlas" ) ,
127125 size : extent,
@@ -150,7 +148,7 @@ impl Atlas {
150148 width : u32 ,
151149 height : u32 ,
152150 data : & [ u8 ] ,
153- context : & crate :: context:: Context ,
151+ _context : & crate :: context:: Context ,
154152 ) -> Option < Entry > {
155153 let entry = {
156154 let current_size = self . layers . len ( ) ;
@@ -164,9 +162,7 @@ impl Atlas {
164162
165163 tracing:: info!( "Allocated atlas entry: {:?}" , entry) ;
166164
167- let converted_data = context. convert_rgba8_to_optimal_format ( data) ;
168165 let bytes_per_pixel = self . get_bytes_per_pixel ( ) ;
169-
170166 let align = wgpu:: COPY_BYTES_PER_ROW_ALIGNMENT ;
171167 let row_bytes = bytes_per_pixel * width;
172168 let padding = ( align - row_bytes % align) % align;
@@ -180,7 +176,7 @@ impl Atlas {
180176 let src_row_bytes = ( bytes_per_pixel * width) as usize ;
181177
182178 padded_data[ offset..offset + src_row_bytes] . copy_from_slice (
183- & converted_data [ row * src_row_bytes..( row + 1 ) * src_row_bytes] ,
179+ & data [ row * src_row_bytes..( row + 1 ) * src_row_bytes] ,
184180 )
185181 }
186182
0 commit comments