static void X11_GL_InitExtensions(_THIS) { Display *display = ((SDL_VideoData *) _this->driverdata)->display; int screen = ((SDL_DisplayData *) SDL_CurrentDisplay->driverdata)->screen; XVisualInfo *vinfo; XSetWindowAttributes xattr; Window w; GLXContext context; const char *(*glXQueryExtensionsStringFunc) (Display *, int); const char *extensions; vinfo = X11_GL_GetVisual(_this, display, screen); if (!vinfo) { return; } xattr.background_pixel = 0; xattr.border_pixel = 0; xattr.colormap = XCreateColormap(display, RootWindow(display, screen), vinfo->visual, AllocNone); w = XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0, vinfo->depth, InputOutput, vinfo->visual, (CWBackPixel | CWBorderPixel | CWColormap), &xattr); context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True); if (context) { _this->gl_data->glXMakeCurrent(display, w, context); } XFree(vinfo); glXQueryExtensionsStringFunc = (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this, "glXQueryExtensionsString"); if (glXQueryExtensionsStringFunc) { extensions = glXQueryExtensionsStringFunc(display, screen); } else { extensions = NULL; } /* Check for SGI_swap_control */ if (HasExtension("GLX_SGI_swap_control", extensions)) { _this->gl_data->glXSwapIntervalSGI = (int (*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); } /* Check for GLX_MESA_swap_control */ if (HasExtension("GLX_MESA_swap_control", extensions)) { _this->gl_data->glXSwapIntervalMESA = (GLint(*)(unsigned)) X11_GL_GetProcAddress(_this, "glXSwapIntervalMESA"); _this->gl_data->glXGetSwapIntervalMESA = (GLint(*)(void)) X11_GL_GetProcAddress(_this, "glXGetSwapIntervalMESA"); } /* Check for GLX_EXT_visual_rating */ if (HasExtension("GLX_EXT_visual_rating", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE; } if (context) { _this->gl_data->glXMakeCurrent(display, None, NULL); _this->gl_data->glXDestroyContext(display, context); } XDestroyWindow(display, w); X11_PumpEvents(_this); }
void gen_interupt(void) { /*static int count=0, time=0; count++; if (count >= 500) { double f = (500.0)/(SDL_GetTicks() - time); DebugMessage(M64MSG_INFO, "gen_interrupt: %.3fKHz", f); count = 0; time = SDL_GetTicks(); }*/ if (stop == 1) { vi_counter = 0; // debug dyna_stop(); } if (!interupt_unsafe_state) { if (savestates_get_job() == savestates_job_load) { savestates_load(); return; } if (reset_hard_job) { reset_hard(); reset_hard_job = 0; return; } } if (skip_jump) { unsigned int dest = skip_jump; skip_jump = 0; #ifdef NEW_COUNT next_interupt = q->count; #else if (q->count > Count || (Count - q->count) < 0x80000000) next_interupt = q->count; else next_interupt = 0; #endif last_addr = dest; generic_jump_to(dest); return; } //DEBUG_PRINT("gen_interupt() %d, Count = %d\n", q->type, Count); switch(q->type) { case SPECIAL_INT: if (Count > 0x10000000) return; remove_interupt_event(); #ifdef USE_SPECIAL add_interupt_event_count(SPECIAL_INT, 0); #endif return; break; case VI_INT: if(vi_counter < 60) { if (vi_counter == 0) cheat_apply_cheats(ENTRY_BOOT); vi_counter++; } else { cheat_apply_cheats(ENTRY_VI); } gfx.updateScreen(); #ifdef WITH_LIRC lircCheckInput(); #endif SDL_PumpEvents(); X11_PumpEvents(); refresh_stat(); // if paused, poll for input events if(rompause) { osd_render(); // draw Paused message in case gfx.updateScreen didn't do it VidExt_GL_SwapBuffers(); while(rompause) { SDL_Delay(10); SDL_PumpEvents(); X11_PumpEvents(); #ifdef WITH_LIRC lircCheckInput(); #endif //WITH_LIRC } } new_vi(); if (vi_register.vi_v_sync == 0) { vi_register.vi_delay = 500000; } else { vi_register.vi_delay = ((vi_register.vi_v_sync + 1)*1500); } next_vi += vi_register.vi_delay; if (vi_register.vi_status&0x40) vi_field=1-vi_field; else vi_field=0; remove_interupt_event(); add_interupt_event_count(VI_INT, next_vi); MI_register.mi_intr_reg |= 0x08; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case COMPARE_INT: remove_interupt_event(); #ifdef USE_COMPARE Count+=2; add_interupt_event_count(COMPARE_INT, Compare); Count-=2; #endif Cause = (Cause | 0x8000) & 0xFFFFFF83; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case CHECK_INT: remove_interupt_event(); break; case SI_INT: #ifdef WITH_LIRC lircCheckInput(); #endif //WITH_LIRC SDL_PumpEvents(); X11_PumpEvents(); PIF_RAMb[0x3F] = 0x0; remove_interupt_event(); MI_register.mi_intr_reg |= 0x02; si_register.si_stat |= 0x1000; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case PI_INT: remove_interupt_event(); MI_register.mi_intr_reg |= 0x10; pi_register.read_pi_status_reg &= ~3; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case AI_INT: if (ai_register.ai_status & 0x80000000) // full { unsigned int ai_event = get_event(AI_INT); remove_interupt_event(); ai_register.ai_status &= ~0x80000000; ai_register.current_delay = ai_register.next_delay; ai_register.current_len = ai_register.next_len; add_interupt_event_count(AI_INT, ai_event+ai_register.next_delay); DebugMessage(M64MSG_VERBOSE, "AI_INT"); MI_register.mi_intr_reg |= 0x04; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; } else { remove_interupt_event(); ai_register.ai_status &= ~0x40000000; //------- MI_register.mi_intr_reg |= 0x04; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; } break; case SP_INT: remove_interupt_event(); sp_register.sp_status_reg |= 0x203; // sp_register.sp_status_reg |= 0x303; if (!(sp_register.sp_status_reg & 0x40)) return; // !intr_on_break MI_register.mi_intr_reg |= 0x01; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case DP_INT: remove_interupt_event(); dpc_register.dpc_status &= ~2; dpc_register.dpc_status |= 0x81; MI_register.mi_intr_reg |= 0x20; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case HW2_INT: // Hardware Interrupt 2 -- remove interrupt event from queue remove_interupt_event(); // setup r4300 Status flags: reset TS, and SR, set IM2 Status = (Status & ~0x00380000) | 0x1000; Cause = (Cause | 0x1000) & 0xFFFFFF83; /* the exception_general() call below will jump to the interrupt vector (0x80000180) and setup the * interpreter or dynarec */ break; case NMI_INT: // Non Maskable Interrupt -- remove interrupt event from queue remove_interupt_event(); // setup r4300 Status flags: reset TS and SR, set BEV, ERL, and SR Status = (Status & ~0x00380000) | 0x00500004; Cause = 0x00000000; // simulate the soft reset code which would run from the PIF ROM r4300_reset_soft(); // clear all interrupts, reset interrupt counters back to 0 Count = 0; vi_counter = 0; init_interupt(); // clear the audio status register so that subsequent write_ai() calls will work properly ai_register.ai_status = 0; // set ErrorEPC with the last instruction address ErrorEPC = PC->addr; // reset the r4300 internal state if (r4300emu != CORE_PURE_INTERPRETER) { // clear all the compiled instruction blocks and re-initialize free_blocks(); init_blocks(); } // adjust ErrorEPC if we were in a delay slot, and clear the delay_slot and dyna_interp flags if(delay_slot==1 || delay_slot==3) { ErrorEPC-=4; } delay_slot = 0; dyna_interp = 0; // set next instruction address to reset vector last_addr = 0xa4000040; DEBUG_PRINT("generic_jump_to(0xa4000040)\n"); generic_jump_to(0xa4000040); return; default: DebugMessage(M64MSG_ERROR, "Unknown interrupt queue event type %.8X.", q->type); remove_interupt_event(); break; } #ifdef NEW_DYNAREC if (r4300emu == CORE_DYNAREC) { DEBUG_PRINT("Setting PC for Dynarec %X\n", pcaddr); EPC = pcaddr; pcaddr = 0x80000180; Status |= 2; Cause &= 0x7FFFFFFF; pending_exception=1; } else { exception_general(); } #else exception_general(); #endif if (!interupt_unsafe_state) { if (savestates_get_job() == savestates_job_save) { savestates_save(); return; } } }
static void X11_GL_InitExtensions(_THIS) { Display *display = ((SDL_VideoData *) _this->driverdata)->display; const int screen = DefaultScreen(display); XVisualInfo *vinfo = NULL; Window w = 0; GLXContext prev_ctx = 0; GLXDrawable prev_drawable = 0; GLXContext context = 0; const char *(*glXQueryExtensionsStringFunc) (Display *, int); const char *extensions; vinfo = X11_GL_GetVisual(_this, display, screen); if (vinfo) { GLXContext (*glXGetCurrentContextFunc) (void) = (GLXContext(*)(void)) X11_GL_GetProcAddress(_this, "glXGetCurrentContext"); GLXDrawable (*glXGetCurrentDrawableFunc) (void) = (GLXDrawable(*)(void)) X11_GL_GetProcAddress(_this, "glXGetCurrentDrawable"); if (glXGetCurrentContextFunc && glXGetCurrentDrawableFunc) { XSetWindowAttributes xattr; prev_ctx = glXGetCurrentContextFunc(); prev_drawable = glXGetCurrentDrawableFunc(); xattr.background_pixel = 0; xattr.border_pixel = 0; xattr.colormap = X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual, AllocNone); w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0, vinfo->depth, InputOutput, vinfo->visual, (CWBackPixel | CWBorderPixel | CWColormap), &xattr); context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True); if (context) { _this->gl_data->glXMakeCurrent(display, w, context); } } X11_XFree(vinfo); } glXQueryExtensionsStringFunc = (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this, "glXQueryExtensionsString"); if (glXQueryExtensionsStringFunc) { extensions = glXQueryExtensionsStringFunc(display, screen); } else { extensions = NULL; } /* Check for GLX_EXT_swap_control(_tear) */ _this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_FALSE; if (HasExtension("GLX_EXT_swap_control", extensions)) { _this->gl_data->glXSwapIntervalEXT = (void (*)(Display*,GLXDrawable,int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalEXT"); if (HasExtension("GLX_EXT_swap_control_tear", extensions)) { _this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_TRUE; } } /* Check for GLX_MESA_swap_control */ if (HasExtension("GLX_MESA_swap_control", extensions)) { _this->gl_data->glXSwapIntervalMESA = (int(*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalMESA"); _this->gl_data->glXGetSwapIntervalMESA = (int(*)(void)) X11_GL_GetProcAddress(_this, "glXGetSwapIntervalMESA"); } /* Check for GLX_SGI_swap_control */ if (HasExtension("GLX_SGI_swap_control", extensions)) { _this->gl_data->glXSwapIntervalSGI = (int (*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); } /* Check for GLX_ARB_create_context */ if (HasExtension("GLX_ARB_create_context", extensions)) { _this->gl_data->glXCreateContextAttribsARB = (GLXContext (*)(Display*,GLXFBConfig,GLXContext,Bool,const int *)) X11_GL_GetProcAddress(_this, "glXCreateContextAttribsARB"); _this->gl_data->glXChooseFBConfig = (GLXFBConfig *(*)(Display *, int, const int *, int *)) X11_GL_GetProcAddress(_this, "glXChooseFBConfig"); } /* Check for GLX_EXT_visual_rating */ if (HasExtension("GLX_EXT_visual_rating", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE; } /* Check for GLX_EXT_visual_info */ if (HasExtension("GLX_EXT_visual_info", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE; } /* Check for GLX_EXT_create_context_es2_profile */ if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) { /* this wants to call glGetString(), so it needs a context. */ /* !!! FIXME: it would be nice not to make a context here though! */ if (context) { SDL_GL_DeduceMaxSupportedESProfile( &_this->gl_data->es_profile_max_supported_version.major, &_this->gl_data->es_profile_max_supported_version.minor ); } } /* Check for GLX_ARB_context_flush_control */ if (HasExtension("GLX_ARB_context_flush_control", extensions)) { _this->gl_data->HAS_GLX_ARB_context_flush_control = SDL_TRUE; } /* Check for GLX_ARB_create_context_robustness */ if (HasExtension("GLX_ARB_create_context_robustness", extensions)) { _this->gl_data->HAS_GLX_ARB_create_context_robustness = SDL_TRUE; } /* Check for GLX_ARB_create_context_no_error */ if (HasExtension("GLX_ARB_create_context_no_error", extensions)) { _this->gl_data->HAS_GLX_ARB_create_context_no_error = SDL_TRUE; } if (context) { _this->gl_data->glXMakeCurrent(display, None, NULL); _this->gl_data->glXDestroyContext(display, context); if (prev_ctx && prev_drawable) { _this->gl_data->glXMakeCurrent(display, prev_drawable, prev_ctx); } } if (w) { X11_XDestroyWindow(display, w); } X11_PumpEvents(_this); }
static void X11_GL_InitExtensions(_THIS) { Display *display = ((SDL_VideoData *) _this->driverdata)->display; int screen = DefaultScreen(display); XVisualInfo *vinfo; XSetWindowAttributes xattr; Window w; GLXContext context; const char *(*glXQueryExtensionsStringFunc) (Display *, int); const char *extensions; vinfo = X11_GL_GetVisual(_this, display, screen); if (!vinfo) { return; } xattr.background_pixel = 0; xattr.border_pixel = 0; xattr.colormap = X11_XCreateColormap(display, RootWindow(display, screen), vinfo->visual, AllocNone); w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0, vinfo->depth, InputOutput, vinfo->visual, (CWBackPixel | CWBorderPixel | CWColormap), &xattr); context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True); if (context) { _this->gl_data->glXMakeCurrent(display, w, context); } X11_XFree(vinfo); glXQueryExtensionsStringFunc = (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this, "glXQueryExtensionsString"); if (glXQueryExtensionsStringFunc) { extensions = glXQueryExtensionsStringFunc(display, screen); } else { extensions = NULL; } /* Check for GLX_EXT_swap_control(_tear) */ _this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_FALSE; if (HasExtension("GLX_EXT_swap_control", extensions)) { _this->gl_data->glXSwapIntervalEXT = (void (*)(Display*,GLXDrawable,int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalEXT"); if (HasExtension("GLX_EXT_swap_control_tear", extensions)) { _this->gl_data->HAS_GLX_EXT_swap_control_tear = SDL_TRUE; } } /* Check for GLX_MESA_swap_control */ if (HasExtension("GLX_MESA_swap_control", extensions)) { _this->gl_data->glXSwapIntervalMESA = (int(*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalMESA"); _this->gl_data->glXGetSwapIntervalMESA = (int(*)(void)) X11_GL_GetProcAddress(_this, "glXGetSwapIntervalMESA"); } /* Check for GLX_SGI_swap_control */ if (HasExtension("GLX_SGI_swap_control", extensions)) { _this->gl_data->glXSwapIntervalSGI = (int (*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); } /* Check for GLX_EXT_visual_rating */ if (HasExtension("GLX_EXT_visual_rating", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE; } /* Check for GLX_EXT_visual_info */ if (HasExtension("GLX_EXT_visual_info", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE; } /* Check for GLX_EXT_create_context_es2_profile */ if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) { _this->gl_data->HAS_GLX_EXT_create_context_es2_profile = SDL_TRUE; } /* Check for GLX_MESA_query_renderer */ if (HasExtension("GLX_MESA_query_renderer", extensions)) { _this->gl_data->glXQueryRendererIntegerMESA = (int(*)(int)) X11_GL_GetProcAddress( _this, "glXQueryRendererIntegerMESA"); _this->gl_data->glXQueryCurrentRendererIntegerMESA = (int(*)(void)) X11_GL_GetProcAddress( _this, "glXQueryCurrentRendererIntegerMESA"); _this->gl_data->glXQueryRendererStringMESA = (int(*)(int)) X11_GL_GetProcAddress( _this, "glXQueryRendererStringMESA"); _this->gl_data->glXQueryCurrentRendererStringMESA = (int(*)(void)) X11_GL_GetProcAddress( _this, "glXQueryCurrentRendererStringMESA"); } /* Check for GL_NVX_gpu_memory_info */ if (HasExtension("GL_NVX_gpu_memory_info", extensions)) { _this->gl_data->HAS_GL_NVX_gpu_memory_info = SDL_TRUE; } /* Check for GL_NVX_gpu_memory_info */ if (HasExtension("GL_NVX_gpu_memory_info", extensions)) { _this->gl_data->HAS_GL_NVX_gpu_memory_info = SDL_TRUE; } if (context) { _this->gl_data->glXMakeCurrent(display, None, NULL); _this->gl_data->glXDestroyContext(display, context); } X11_XDestroyWindow(display, w); X11_PumpEvents(_this); }