ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/video_vosf.h
(Generate patch)

Comparing BasiliskII/src/Unix/video_vosf.h (file contents):
Revision 1.39 by gbeauche, 2004-06-24T15:19:56Z vs.
Revision 1.46 by gbeauche, 2004-12-11T10:20:32Z

# Line 24 | Line 24
24   // Note: this file must be #include'd only in video_x.cpp
25   #ifdef ENABLE_VOSF
26  
27 #include <fcntl.h>
28 #include <sys/mman.h>
27   #include "sigsegv.h"
28   #include "vm_alloc.h"
29 + #ifdef _WIN32
30 + #include "util_windows.h"
31 + #endif
32  
33   // Glue for SDL and X11 support
34   #ifdef USE_SDL_VIDEO
# Line 156 | Line 157 | static inline int find_next_page_clear(i
157   static spinlock_t vosf_lock = SPIN_LOCK_UNLOCKED;                               // Mutex to protect frame buffer (dirtyPages in fact)
158   #define LOCK_VOSF spin_lock(&vosf_lock)
159   #define UNLOCK_VOSF spin_unlock(&vosf_lock)
160 + #elif defined(_WIN32)
161 + static mutex_t vosf_lock;                                                                               // Mutex to protect frame buffer (dirtyPages in fact)
162 + #define LOCK_VOSF vosf_lock.lock();
163 + #define UNLOCK_VOSF vosf_lock.unlock();
164   #elif defined(HAVE_PTHREADS)
165   static pthread_mutex_t vosf_lock = PTHREAD_MUTEX_INITIALIZER;   // Mutex to protect frame buffer (dirtyPages in fact)
166   #define LOCK_VOSF pthread_mutex_lock(&vosf_lock);
# Line 179 | Line 184 | static int log_base_2(uint32 x)
184   // Extend size to page boundary
185   static uint32 page_extend(uint32 size)
186   {
187 <        const uint32 page_size = getpagesize();
187 >        const uint32 page_size = vm_page_size();
188          const uint32 page_mask = page_size - 1;
189          return (size + page_mask) & ~page_mask;
190   }
191  
192  
193   /*
194 + *  Check if VOSF acceleration is profitable on this platform
195 + */
196 +
197 + const int VOSF_PROFITABLE_TRIES = 3;                    // Make 3 attempts for full screen update
198 + const int VOSF_PROFITABLE_THRESHOLD = 16667;    // 60 Hz
199 +
200 + static bool video_vosf_profitable(void)
201 + {
202 +        int64 durations[VOSF_PROFITABLE_TRIES];
203 +        int mean_duration = 0;
204 +
205 +        for (int i = 0; i < VOSF_PROFITABLE_TRIES; i++) {
206 +                uint64 start = GetTicks_usec();
207 +                for (int p = 0; p < mainBuffer.pageCount; p++) {
208 +                        uint8 *addr = (uint8 *)(mainBuffer.memStart + (p * mainBuffer.pageSize));
209 +                        addr[0] = 0; // Trigger Screen_fault_handler()
210 +                }
211 +                int64 duration = GetTicks_usec() - start;
212 +                mean_duration += duration;
213 +                durations[i] = duration;
214 +
215 +                PFLAG_CLEAR_ALL;
216 +                mainBuffer.dirty = false;
217 +                if (vm_protect((char *)mainBuffer.memStart, mainBuffer.memLength, VM_PAGE_READ) != 0)
218 +                        return false;
219 +        }
220 +
221 +        mean_duration /= VOSF_PROFITABLE_TRIES;
222 +        D(bug("Triggered %d screen faults in %ld usec on average\n", mainBuffer.pageCount, mean_duration));
223 +        return (mean_duration < (VOSF_PROFITABLE_THRESHOLD * (frame_skip ? frame_skip : 1)));
224 + }
225 +
226 +
227 + /*
228   *  Initialize the VOSF system (mainBuffer structure, SIGSEGV handler)
229   */
230  
231   static bool video_vosf_init(MONITOR_INIT)
232   {
233 <        VIDEO_MODE_INIT;
233 >        VIDEO_MODE_INIT_MONITOR;
234  
235 <        const uintptr page_size = getpagesize();
235 >        const uintptr page_size = vm_page_size();
236          const uintptr page_mask = page_size - 1;
237          
238          // Round up frame buffer base to page boundary
# Line 356 | Line 395 | static inline void update_display_window
395  
396                  VIDEO_DRV_LOCK_PIXELS;
397  
398 <                if (VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) {
398 >                if ((int)VIDEO_MODE_DEPTH < VIDEO_DEPTH_8BIT) {
399  
400                          // Update the_host_buffer and copy of the_buffer
401                          const int src_bytes_per_row = VIDEO_MODE_ROW_BYTES;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines