Пример #1
0
void osd_xenon_video_hw_init(running_machine &machine) {
    XenosSurface * fb = Xe_GetFramebufferSurface(g_pVideoDevice);

    Xe_SetRenderTarget(g_pVideoDevice, fb);

    LoadShaderEffects();

    g_pTexture = Xe_CreateTexture(g_pVideoDevice, XE_W, XE_H, 1, XE_FMT_8888 | XE_FMT_ARGB, 0);
    screen = (unsigned int*) Xe_Surface_LockRect(g_pVideoDevice, g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE);
    Xe_Surface_Unlock(g_pVideoDevice, g_pTexture);

    g_pTexture->use_filtering = 0;

    pitch = g_pTexture->wpitch;

    screen_width = fb->width;
    screen_height = fb->height;

    vb = Xe_CreateVertexBuffer(g_pVideoDevice, 65536 * sizeof (MameVerticeFormats));
    soft_vb = Xe_CreateVertexBuffer(g_pVideoDevice, 65536 * sizeof (MameVerticeFormats));


    float w = fb->width;
    float h = fb->height;

    Xe_SetClearColor(g_pVideoDevice, 0);

    osd_xenon_video_resume();

    // on mame exit
    machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_xenon_video_cleanup), &machine));
}
Пример #2
0
void osd_xenon_video_init() {
    g_pVideoDevice = &_xe;
    Xe_Init(g_pVideoDevice);

    XenosSurface * fb = Xe_GetFramebufferSurface(g_pVideoDevice);

    Xe_SetRenderTarget(g_pVideoDevice, fb);

    static const struct XenosVBFFormat vbf = {
        3,
        {
            {XE_USAGE_POSITION, 0, XE_TYPE_FLOAT4},
            {XE_USAGE_COLOR, 0, XE_TYPE_UBYTE4},
            {XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},
        }
    };

    g_pPixelTexturedShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) g_xps_ps_main);
    Xe_InstantiateShader(g_pVideoDevice, g_pPixelTexturedShader, 0);

    g_pVertexShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) g_xvs_VSmain);
    Xe_InstantiateShader(g_pVideoDevice, g_pVertexShader, 0);
    Xe_ShaderApplyVFetchPatches(g_pVideoDevice, g_pVertexShader, 0, &vbf);

    g_pTexture = Xe_CreateTexture(g_pVideoDevice, XE_W, XE_H, 1, XE_FMT_8888 | XE_FMT_ARGB, 0);
    screen = (unsigned int*) Xe_Surface_LockRect(g_pVideoDevice, g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE);
    Xe_Surface_Unlock(g_pVideoDevice, g_pTexture);

    g_pTexture->use_filtering = 0;

    pitch = g_pTexture->wpitch;

    screen_width = fb->width;
    screen_height = fb->height;

    vb = Xe_CreateVertexBuffer(g_pVideoDevice, 65536 * sizeof (DrawVerticeFormats));
    soft_vb = Xe_CreateVertexBuffer(g_pVideoDevice, 65536 * sizeof (DrawVerticeFormats));


    float w = fb->width;
    float h = fb->height;

    Xe_SetClearColor(g_pVideoDevice, 0);

    edram_init(g_pVideoDevice);
}
Пример #3
0
void XenonGLInit(){
	// init video
	xe=&_xe;
	
	Xe_Init(xe);
	
	edram_init(xe);
	Xe_SetRenderTarget(xe, Xe_GetFramebufferSurface(xe));
	static const struct XenosVBFFormat vbf = {
		4,
		{
			{XE_USAGE_POSITION, 0, XE_TYPE_FLOAT4},
			{XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},			
			{XE_USAGE_TEXCOORD, 1, XE_TYPE_FLOAT2},
			{XE_USAGE_COLOR, 0, XE_TYPE_UBYTE4},
		}
	};
	
	pPixelShader = Xe_LoadShaderFromMemory(xe, (void*) g_xps_ps_main);
	Xe_InstantiateShader(xe, pPixelShader, 0);

	pVertexShader = Xe_LoadShaderFromMemory(xe, (void*) g_xvs_vs_main);
	Xe_InstantiateShader(xe, pVertexShader, 0);
	Xe_ShaderApplyVFetchPatches(xe, pVertexShader, 0, &vbf);
	
	// Create vb
	pVbGL = Xe_CreateVertexBuffer(xe, XE_MAX_VERTICES);
	xe_Vertices = Xe_VB_Lock(xe, pVbGL, 0, XE_MAX_VERTICES, XE_LOCK_WRITE);
	Xe_VB_Unlock(xe, pVbGL);
	
	// init matrices
	XeGlInitializeMatrix(&projection_matrix);
	XeGlInitializeMatrix(&modelview_matrix);
	
	// init vertices
	xe_NumVerts = 0;
	xe_CurrentColor.u32 = 0xFFFFFFFF;
	
	// init textures
	// not yet ...
	Xe_InvalidateState(xe);
	Xe_SetClearColor(xe, 0);
	
}
Пример #4
0
void CreateTexture(int width, int height) {
    // Create display
    static int old_width = 0;
    static int old_height = 0;

    if ((width != old_width) || (old_height != height)) {

        texturesize[1] = width;
        texturesize[0] = height;

        //printf("Old w:%d - h:%d\r\n", old_width, old_height);
        //printf("New w:%d - h:%d\r\n", width, height);

        PsxScreenUv[UvTop] = (float) width / psxRealW;
        PsxScreenUv[UvLeft] = (float) height / psxRealH;

        // top left
        Rect[0].u = PsxScreenUv[UvBottom];
        Rect[0].v = PsxScreenUv[UvRight];

        // bottom left
        Rect[4].u = Rect[1].u = PsxScreenUv[UvBottom];
        Rect[4].v = Rect[1].v = PsxScreenUv[UvLeft];

        // top right
        Rect[3].u = Rect[2].u = PsxScreenUv[UvTop];
        Rect[3].v = Rect[2].v = PsxScreenUv[UvRight];

        // bottom right
        Rect[5].u = PsxScreenUv[UvTop];
        Rect[5].v = PsxScreenUv[UvLeft];

        vb = Xe_CreateVertexBuffer(g_pVideoDevice, 6 * sizeof (DrawVerticeFormats));
        void *v = Xe_VB_Lock(g_pVideoDevice, vb, 0, 6 * sizeof (DrawVerticeFormats), XE_LOCK_WRITE);
        memcpy(v, Rect, 6 * sizeof (DrawVerticeFormats));
        Xe_VB_Unlock(g_pVideoDevice, vb);

        old_width = width;
        old_height = height;
    }
}
Пример #5
0
static void *xenon360_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data)
{
   gl_t * gl = calloc(1, sizeof(gl_t));
   if (!gl)
      return NULL;

   gl->gl_device = &gl->real_device;

   Xe_Init(gl->gl_device);

   Xe_SetRenderTarget(gl->gl_device, Xe_GetFramebufferSurface(gl->gl_device));

   static const struct XenosVBFFormat vbf =
   {
      3,
      {
         {XE_USAGE_POSITION, 0, XE_TYPE_FLOAT4},
	 {XE_USAGE_COLOR, 0, XE_TYPE_UBYTE4},
	 {XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},
      }
   };

   gl->g_pPixelTexturedShader = Xe_LoadShaderFromMemory(gl->gl_device, (void*)g_xps_PS);
   Xe_InstantiateShader(gl->gl_device, gl->g_pPixelTexturedShader, 0);

   gl->g_pVertexShader = Xe_LoadShaderFromMemory(gl->gl_device, (void*)g_xvs_VS);
   Xe_InstantiateShader(gl->gl_device, gl->g_pVertexShader, 0);
   Xe_ShaderApplyVFetchPatches(gl->gl_device, gl->g_pVertexShader, 0, &vbf);

   gl->g_pTexture = Xe_CreateTexture(gl->gl_device, XE_W, XE_H, 1, XE_FMT_5551 | XE_FMT_16BE, 0);
   gl->g_pTexture->use_filtering = 1;

   edram_init(gl->gl_device);


   // enable filtering for now

   float x = -1.0f;
   float y = 1.0f;
   float w = 4.0f;
   float h = 4.0f;

   gl->vb = Xe_CreateVertexBuffer(gl->gl_device, 3 * sizeof(DrawVerticeFormats));
   DrawVerticeFormats *Rect = Xe_VB_Lock(gl->gl_device, gl->vb, 0, 3 * sizeof (DrawVerticeFormats), XE_LOCK_WRITE);

   ScreenUv[UV_TOP] = ScreenUv[UV_TOP] * 2;
   ScreenUv[UV_LEFT] = ScreenUv[UV_LEFT] * 2;

   // top left
   Rect[0].x = x;
   Rect[0].y = y;
   Rect[0].u = ScreenUv[UV_BOTTOM];
   Rect[0].v = ScreenUv[UV_RIGHT];
   Rect[0].color = 0;

   // bottom left
   Rect[1].x = x;
   Rect[1].y = y - h;
   Rect[1].u = ScreenUv[UV_BOTTOM];
   Rect[1].v = ScreenUv[UV_LEFT];
   Rect[1].color = 0;

   // top right
   Rect[2].x = x + w;
   Rect[2].y = y;
   Rect[2].u = ScreenUv[UV_TOP];
   Rect[2].v = ScreenUv[UV_RIGHT];
   Rect[2].color = 0;

   Rect[3].x = x + w;
   Rect[3].y = y;
   Rect[3].u = ScreenUv[UV_TOP];
   Rect[3].v = ScreenUv[UV_RIGHT];
   Rect[3].color = 0;

   int i = 0;
   for (i = 0; i < 3; i++)
   {
      Rect[i].z = 0.0;
      Rect[i].w = 1.0;
   }

   Xe_VB_Unlock(gl->gl_device, gl->vb);

   Xe_SetClearColor(gl->gl_device, 0);

   return gl;
}
Пример #6
0
void XenonGLInit(){
	
	// init video
	xe=&_xe;
	
	Xe_Init(xe);
	
	edram_init(xe);
	Xe_SetRenderTarget(xe, Xe_GetFramebufferSurface(xe));
	static const struct XenosVBFFormat vbf = {
		4,
		{
			{XE_USAGE_POSITION, 0, XE_TYPE_FLOAT4},
			{XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},			
			{XE_USAGE_TEXCOORD, 1, XE_TYPE_FLOAT2},
			{XE_USAGE_COLOR, 0, XE_TYPE_UBYTE4},
		}
	};
	
	struct XenosSurface * fb = Xe_GetFramebufferSurface(xe);
	
	pPixelTextureShader = Xe_LoadShaderFromMemory(xe, (void*) g_xps_ps_texture);
	Xe_InstantiateShader(xe, pPixelTextureShader, 0);
	
	pPixelModulateShader = Xe_LoadShaderFromMemory(xe, (void*) g_xps_ps_modulate);
	Xe_InstantiateShader(xe, pPixelModulateShader, 0);
	
	pPixelModulateShader2 = Xe_LoadShaderFromMemory(xe, (void*) g_xps_ps_modulate_2);
	Xe_InstantiateShader(xe, pPixelModulateShader2, 0);
	
	pPixelColorShader = Xe_LoadShaderFromMemory(xe, (void*) g_xps_ps_color);
	Xe_InstantiateShader(xe, pPixelColorShader, 0);
	
	pCurrentPs = g_xps_ps_color;
	pCurrentTexturedPs = g_xps_ps_texture;

	pVertexShader = Xe_LoadShaderFromMemory(xe, (void*) g_xvs_vs_main);
	Xe_InstantiateShader(xe, pVertexShader, 0);
	Xe_ShaderApplyVFetchPatches(xe, pVertexShader, 0, &vbf);
	
	// Create vb
	pVbGL = Xe_CreateVertexBuffer(xe, XE_MAX_VERTICES * sizeof(glVerticesFormat_t));
	xe_Vertices = Xe_VB_Lock(xe, pVbGL, 0, XE_MAX_VERTICES * sizeof(glVerticesFormat_t), XE_LOCK_WRITE);
	Xe_VB_Unlock(xe, pVbGL);
	
	// Create indices
	pIbGL = Xe_CreateIndexBuffer(xe, XE_MAX_INDICES_PER_DRAW, XE_FMT_INDEX16);
	xe_indices = Xe_IB_Lock(xe, pIbGL, 0, XE_MAX_INDICES_PER_DRAW, XE_LOCK_WRITE);
	Xe_IB_Unlock(xe, pIbGL);
	
	// init matrices
	XeGlInitializeMatrix(&projection_matrix);
	XeGlInitializeMatrix(&modelview_matrix);
	
	// frontbuffer = Xe_CreateTexture(xe, fb->width, fb->height, 0, XE_FMT_8888 | XE_FMT_BGRA, 1);
	
	// init vertices
	xe_NumVerts = 0;
	xe_NumIndices = 0;
	xe_CurrentColor.u32 = 0x0;
	
	// init textures
	XeGLInitTextures();
	
	// init states
	XeInitStates();
	
	// not yet ...
	Xe_InvalidateState(xe);
	Xe_SetClearColor(xe, 0);
	
	GL_InitShaderCache();
	
}
Пример #7
0
void SYSVideoInit() {


    g_pVideoDevice = GetVideoDevice();

    Xe_SetRenderTarget(g_pVideoDevice, Xe_GetFramebufferSurface(g_pVideoDevice));

    if (video_initialised == 0) {
        // init 2xsai buffer
        hq_buffer = (unsigned char*) malloc(1024 * 1024 * 4);


        static const struct XenosVBFFormat vbf = {
            3,
            {
                {XE_USAGE_POSITION, 0, XE_TYPE_FLOAT4},
                {XE_USAGE_COLOR, 0, XE_TYPE_UBYTE4},
                {XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},
            }
        };

        g_pPixelTexturedShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) g_xps_PS);
        Xe_InstantiateShader(g_pVideoDevice, g_pPixelTexturedShader, 0);

        g_pVertexShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) g_xvs_VS);
        Xe_InstantiateShader(g_pVideoDevice, g_pVertexShader, 0);
        Xe_ShaderApplyVFetchPatches(g_pVideoDevice, g_pVertexShader, 0, &vbf);

        if (g_pTexture == NULL)
            g_pTexture = Xe_CreateTexture(g_pVideoDevice, XE_W, XE_H, 1, XE_FMT_8888 | XE_FMT_ARGB, 0);

        texture_buffer = (unsigned char*) Xe_Surface_LockRect(g_pVideoDevice, g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE);
        pitch = g_pTexture->wpitch;
        Xe_Surface_Unlock(g_pVideoDevice, g_pTexture);

    }

    memset(hq_buffer, 0, 1024 * 1024 * 4);

    // disable filtering
/*
    if (config.video_filter)
        g_pTexture->use_filtering = 1;
    else
        g_pTexture->use_filtering = 0;
*/

    
    /*
        screen = texture_buffer;
     * pitch = g_pTexture->wpitch;
     */
    screen = hq_buffer;

    /*
        float w = 2.0f;
        float h = 2.0f;
     */
    if (video_initialised == 0) {

        // move it to ini file
        float x = -1.0f;
        float y = 1.0f;
        float w = 2.0f;
        float h = 2.0f;

        vb = Xe_CreateVertexBuffer(g_pVideoDevice, 3 * sizeof (DrawVerticeFormats));
        DrawVerticeFormats *Rect = Xe_VB_Lock(g_pVideoDevice, vb, 0, 3 * sizeof (DrawVerticeFormats), XE_LOCK_WRITE);
        {
            // top left
            Rect[0].x = x;
            Rect[0].y = y;
            Rect[0].u = ScreenUv[UvBottom];
            Rect[0].v = ScreenUv[UvRight];
            Rect[0].color = 0;

            // bottom left
            Rect[1].x = x;
            Rect[1].y = y - h;
            Rect[1].u = ScreenUv[UvBottom];
            Rect[1].v = ScreenUv[UvLeft];
            Rect[1].color = 0;

            // top right
            Rect[2].x = x + w;
            Rect[2].y = y;
            Rect[2].u = ScreenUv[UvTop];
            Rect[2].v = ScreenUv[UvRight];
            Rect[2].color = 0;

            int i = 0;
            for (i = 0; i < 3; i++) {
                Rect[i].z = 0.0;
                Rect[i].w = 1.0;
            }
        }
        Xe_VB_Unlock(g_pVideoDevice, vb);

    }
    if (video_initialised == 0)
        video_initialised = 1;
}
Пример #8
0
void	VID_Init (void)
{
	TR;
    refimport_t	ri;

    viddef.width = 320;
    viddef.height = 240;

    ri.Cmd_AddCommand = Cmd_AddCommand;
    ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
    ri.Cmd_Argc = Cmd_Argc;
    ri.Cmd_Argv = Cmd_Argv;
    ri.Cmd_ExecuteText = Cbuf_ExecuteText;
    ri.Con_Printf = VID_Printf;
    ri.Sys_Error = VID_Error;
    ri.FS_LoadFile = FS_LoadFile;
    ri.FS_FreeFile = FS_FreeFile;
    ri.FS_Gamedir = FS_Gamedir;
    ri.Vid_MenuInit = VID_MenuInit;
	ri.Vid_NewWindow = VID_NewWindow;
    ri.Cvar_Get = Cvar_Get;
    ri.Cvar_Set = Cvar_Set;
    ri.Cvar_SetValue = Cvar_SetValue;
    ri.Vid_GetModeInfo = VID_GetModeInfo;

    re = GetRefAPI(ri);
	xe=&_xe;
	
	Xe_Init(xe);
	
	edram_init(xe);
	Xe_SetRenderTarget(xe, Xe_GetFramebufferSurface(xe));
	static const struct XenosVBFFormat vbf = {
		3,
		{
			{XE_USAGE_POSITION, 0, XE_TYPE_FLOAT4},
			{XE_USAGE_COLOR, 0, XE_TYPE_UBYTE4},
			{XE_USAGE_TEXCOORD, 0, XE_TYPE_FLOAT2},
		}
	};
	
	pPixelShader = Xe_LoadShaderFromMemory(xe, (void*) g_xps_PS);
	Xe_InstantiateShader(xe, pPixelShader, 0);

	pVertexShader = Xe_LoadShaderFromMemory(xe, (void*) g_xvs_VS);
	Xe_InstantiateShader(xe, pVertexShader, 0);
	Xe_ShaderApplyVFetchPatches(xe, pVertexShader, 0, &vbf);
	
	// Create vb
	pVBSw = Xe_CreateVertexBuffer(xe, 3 * sizeof (DrawVerticeFormats));
	
	DrawVerticeFormats *Rect = Xe_VB_Lock(xe, pVBSw, 0, 3 * sizeof (DrawVerticeFormats), XE_LOCK_WRITE);
	{
		// top left
		Rect[0].x = -1;
		Rect[0].y = 1;
		Rect[0].u = 0;
		Rect[0].v = 0;
		Rect[0].color = 0;

		// bottom left
		Rect[1].x = -1;
		Rect[1].y = -1;
		Rect[1].u = 0;
		Rect[1].v = 1;
		Rect[1].color = 0;

		// top right
		Rect[2].x = 1;
		Rect[2].y = 1;
		Rect[2].u = 1;
		Rect[2].v = 0;
		Rect[2].color = 0;

		int i = 0;
		for (i = 0; i < 3; i++) {
			Rect[i].z = 0.0;
			Rect[i].w = 1.0;
		}
	}
	Xe_VB_Unlock(xe, pVBSw);
	
	pVideoSurface = NULL;
		
	if (re.api_version != API_VERSION)
        Com_Error (ERR_FATAL, "Re has incompatible api_version");
    
        // call the init function
    if (re.Init (NULL, NULL) == -1)
		Com_Error (ERR_FATAL, "Couldn't start refresh");
}