@@ -53,7 +53,7 @@ static void perform_blit(int operation, uint8_t *source, uint8_t *dest,
5353 }
5454 } else {
5555 fprintf (stderr , "Unknown blit operation: 0x%x\n" , operation );
56- assert (false && "Unknown blit operation" );
56+ assert (! "Unknown blit operation" );
5757 }
5858}
5959
@@ -115,15 +115,13 @@ void pgraph_gl_image_blit(NV2AState *d)
115115 dest += context_surfaces -> dest_offset ;
116116 hwaddr dest_addr = dest - d -> vram_ptr ;
117117
118- SurfaceBinding * surf_src = pgraph_gl_surface_get (d , source_addr );
119- if (surf_src ) {
120- pgraph_gl_surface_download_if_dirty (d , surf_src );
121- }
122-
123118 hwaddr source_offset = image_blit -> in_y * context_surfaces -> source_pitch +
124119 image_blit -> in_x * bytes_per_pixel ;
120+ source_addr += source_offset ;
121+
125122 hwaddr dest_offset = image_blit -> out_y * context_surfaces -> dest_pitch +
126123 image_blit -> out_x * bytes_per_pixel ;
124+ dest_addr += dest_offset ;
127125
128126 size_t max_row_pixels =
129127 MIN (context_surfaces -> source_pitch , context_surfaces -> dest_pitch ) /
@@ -150,20 +148,12 @@ void pgraph_gl_image_blit(NV2AState *d)
150148 leftover_bytes = clipped_dest_size - consumed_bytes ;
151149 }
152150
153- SurfaceBinding * surf_dest = pgraph_gl_surface_get (d , dest_addr );
154- if (surf_dest ) {
155- if (adjusted_height < surf_dest -> height ||
156- row_pixels < surf_dest -> width ) {
157- pgraph_gl_surface_download_if_dirty (d , surf_dest );
158- } else {
159- // The blit will completely replace the surface so any pending
160- // download should be discarded.
161- surf_dest -> download_pending = false;
162- surf_dest -> draw_dirty = false;
163- }
164- surf_dest -> upload_pending = true;
165- pg -> draw_time ++ ;
166- }
151+ hwaddr source_size = adjusted_height * context_surfaces -> source_pitch +
152+ image_blit -> width * bytes_per_pixel ;
153+ pgraph_gl_download_surfaces_in_range_if_dirty (pg , source_addr , source_size );
154+
155+ // TODO: just clear dirty_draw flag on surfaces that are fully overlapped.
156+ pgraph_gl_download_surfaces_in_range_if_dirty (pg , dest_addr , clipped_dest_size );
167157
168158 NV2A_DPRINTF (" blit 0x%tx -> 0x%tx (Size: %llu, Clipped Height: %zu)\n" ,
169159 source_addr , dest_addr , dest_size , adjusted_height );
@@ -215,9 +205,12 @@ void pgraph_gl_image_blit(NV2AState *d)
215205 }
216206 }
217207
218- dest_addr += dest_offset ;
219208 memory_region_set_client_dirty (d -> vram , dest_addr , clipped_dest_size ,
220209 DIRTY_MEMORY_VGA );
221210 memory_region_set_client_dirty (d -> vram , dest_addr , clipped_dest_size ,
222211 DIRTY_MEMORY_NV2A_TEX );
212+
213+ if (pgraph_gl_mark_surfaces_in_range_for_upload (d , dest_addr , dest_size )) {
214+ ++ pg -> draw_time ;
215+ }
223216}
0 commit comments