@@ -70,45 +70,32 @@ void pgraph_gl_image_blit(NV2AState *d)
7070 hwaddr source_addr = source - d -> vram_ptr ;
7171 hwaddr dest_addr = dest - d -> vram_ptr ;
7272
73- SurfaceBinding * surf_src = pgraph_gl_surface_get (d , source_addr );
74- if (surf_src ) {
75- pgraph_gl_surface_download_if_dirty (d , surf_src );
76- }
77-
78- SurfaceBinding * surf_dest = pgraph_gl_surface_get (d , dest_addr );
79- if (surf_dest ) {
80- if (image_blit -> height < surf_dest -> height ||
81- image_blit -> width < surf_dest -> width ) {
82- pgraph_gl_surface_download_if_dirty (d , surf_dest );
83- } else {
84- // The blit will completely replace the surface so any pending
85- // download should be discarded.
86- surf_dest -> download_pending = false;
87- surf_dest -> draw_dirty = false;
88- }
89- surf_dest -> upload_pending = true;
90- pg -> draw_time ++ ;
91- }
92-
9373 hwaddr source_offset = image_blit -> in_y * context_surfaces -> source_pitch +
9474 image_blit -> in_x * bytes_per_pixel ;
9575 hwaddr dest_offset = image_blit -> out_y * context_surfaces -> dest_pitch +
9676 image_blit -> out_x * bytes_per_pixel ;
9777
78+ source_addr += source_offset ;
79+ dest_addr += dest_offset ;
80+
9881 hwaddr source_size =
9982 (image_blit -> height - 1 ) * context_surfaces -> source_pitch +
10083 image_blit -> width * bytes_per_pixel ;
10184 hwaddr dest_size = (image_blit -> height - 1 ) * context_surfaces -> dest_pitch +
10285 image_blit -> width * bytes_per_pixel ;
10386
10487 /* FIXME: What does hardware do in this case? */
105- assert (source_addr + source_offset + source_size <=
106- memory_region_size (d -> vram ));
107- assert (dest_addr + dest_offset + dest_size <= memory_region_size (d -> vram ));
88+ assert (source_addr + source_size <= memory_region_size (d -> vram ));
89+ assert (dest_addr + dest_size <= memory_region_size (d -> vram ));
10890
10991 uint8_t * source_row = source + source_offset ;
11092 uint8_t * dest_row = dest + dest_offset ;
11193
94+ pgraph_gl_download_surfaces_in_range_if_dirty (d , source_addr , source_size );
95+
96+ // TODO: just clear dirty_draw flag on surfaces that are fully overlapped.
97+ pgraph_gl_download_surfaces_in_range_if_dirty (d , dest_addr , dest_size );
98+
11299 if (image_blit -> operation == NV09F_SET_OPERATION_SRCCOPY ) {
113100 // NV2A_GL_DPRINTF(false, "NV09F_SET_OPERATION_SRCCOPY");
114101 for (unsigned int y = 0 ; y < image_blit -> height ; y ++ ) {
@@ -135,11 +122,9 @@ void pgraph_gl_image_blit(NV2AState *d)
135122 } else {
136123 fprintf (stderr , "Unknown blit operation: 0x%x\n" ,
137124 image_blit -> operation );
138- assert (false && "Unknown blit operation" );
125+ assert (! "Unknown blit operation" );
139126 }
140127
141- NV2A_DPRINTF (" - 0x%tx -> 0x%tx\n" , source_addr , dest_addr );
142-
143128 bool needs_alpha_patching ;
144129 uint8_t alpha_override ;
145130 switch (context_surfaces -> color_format ) {
@@ -166,9 +151,12 @@ void pgraph_gl_image_blit(NV2AState *d)
166151 }
167152 }
168153
169- dest_addr += dest_offset ;
170154 memory_region_set_client_dirty (d -> vram , dest_addr , dest_size ,
171155 DIRTY_MEMORY_VGA );
172156 memory_region_set_client_dirty (d -> vram , dest_addr , dest_size ,
173157 DIRTY_MEMORY_NV2A_TEX );
158+
159+ if (pgraph_gl_mark_surfaces_in_range_for_upload (d , dest_addr , dest_size )) {
160+ ++ pg -> draw_time ;
161+ }
174162}
0 commit comments