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)); }
GuiImage::GuiImage(int w, int h, GXColor c) { //image = (u8 *) memalign(32, w * h << 2); image = Xe_CreateTexture(g_pVideoDevice,w,h,0,(XE_FMT_8888|XE_FMT_ARGB),0); width = w; height = h; imageangle = 0; tile = -1; stripe = 0; imgType = IMAGE_COLOR; if (!image) return; buf = (u8*)Xe_Surface_LockRect(g_pVideoDevice,image,0,0,0,0,XE_LOCK_WRITE); int x,y; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { buf[0] = c.a; buf[1] = c.r; buf[2] = c.g; buf[3] = c.b; buf += 4; } } Xe_Surface_Unlock(g_pVideoDevice,image); }
struct XenosSurface * XeGetBitmapFromMemory(int width, int height, void *pixeldata) { printf("\t\t\tXeGetBitmapFromMemory(int width,int height,void *pixeldata) ...!!\n"); struct XenosSurface *surface = Xe_CreateTexture(xe, width, height, 1, XE_FMT_8888 | XE_FMT_ARGB, 0); Xe_Surface_LockRect(xe, surface, 0, 0, 0, 0, XE_LOCK_WRITE); unsigned long size = (surface->height) * (surface->pitch) + 1; printf("\t\t\tmemcpy ...!!\n"); memcpy(surface->base, pixeldata, size);//Copie la texture en mémoire dans la surface xe Xe_Surface_Unlock(xe, surface); return surface; }
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); }
static struct XenosSurface * MyXeCreateTexture(struct XenosDevice *xe, unsigned int width, unsigned int height, unsigned int levels, int format, int tiled) { int nwidth = width; int nheight = height; /* if (width < TEXMIN || height < TEXMIN) { while(nwidth<TEXMIN) nwidth<<=1; while(nheight<TEXMIN) nheight<<=1; } */ struct XenosSurface * surf = Xe_CreateTexture(xe, nwidth, nheight, levels, format, tiled); /* surf->width = width; surf->height = height; */ memset(surf->base, 0x00, surf->hpitch * surf->wpitch); return surf; }
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; }
void CreateDisplay(void) { #ifndef LZX_GUI g_pVideoDevice = &_xe; Xe_Init(g_pVideoDevice); #else g_pVideoDevice = getLzxVideoDevice(); #endif fb = Xe_GetFramebufferSurface(g_pVideoDevice); Xe_SetRenderTarget(g_pVideoDevice, fb); /* mame HLSL struct VS_INPUT { float4 Position : POSITION; float4 Color : COLOR0; float2 TexCoord : TEXCOORD0; }; */ 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}, } }; #ifdef MAME_SHADER g_pPixelTexturedShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) g_xps_ps_main); #else g_pPixelTexturedShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) g_xps_PS); #endif //g_pPixelTexturedShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) draw_t_p_psu); Xe_InstantiateShader(g_pVideoDevice, g_pPixelTexturedShader, 0); #ifdef MAME_SHADER g_pVertexShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) g_xvs_vs_main); #else g_pVertexShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) g_xvs_VS); #endif //g_pVertexShader = Xe_LoadShaderFromMemory(g_pVideoDevice, (void*) draw_v_vsu); Xe_InstantiateShader(g_pVideoDevice, g_pVertexShader, 0); Xe_ShaderApplyVFetchPatches(g_pVideoDevice, g_pVertexShader, 0, &vbf); edram_init(g_pVideoDevice); // Create the psxScreen texture if (g_pTexture) Xe_DestroyTexture(g_pVideoDevice, g_pTexture); g_pTexture = Xe_CreateTexture(g_pVideoDevice, psxRealW, psxRealH, 1, XE_FMT_8888 | XE_FMT_ARGB, 0); psxScreen = (unsigned char*) Xe_Surface_LockRect(g_pVideoDevice, g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE); g_pPitch = g_pTexture->wpitch; Xe_Surface_Unlock(g_pVideoDevice, g_pTexture); memset(psxScreen, 0, 1024 * 512 * 2); // move it to ini file float x = -1.0f; float y = -1.0f; float w = 2.0f; float h = 2.0f; // top left Rect[0].x = x; Rect[0].y = y + h; Rect[0].u = PsxScreenUv[UvBottom]; Rect[0].v = PsxScreenUv[UvRight]; Rect[0].color = 0; // bottom left Rect[1].x = x; Rect[1].y = y; Rect[1].u = PsxScreenUv[UvBottom]; Rect[1].v = PsxScreenUv[UvLeft]; Rect[1].color = 0; // top right Rect[2].x = x + w; Rect[2].y = y + h; Rect[2].u = PsxScreenUv[UvTop]; Rect[2].v = PsxScreenUv[UvRight]; Rect[2].color = 0; // top right Rect[3].x = x + w; Rect[3].y = y + h; Rect[3].u = PsxScreenUv[UvTop]; ; Rect[3].v = PsxScreenUv[UvRight]; Rect[3].color = 0; // bottom left Rect[4].x = x; Rect[4].y = y; Rect[4].u = PsxScreenUv[UvBottom]; Rect[4].v = PsxScreenUv[UvLeft]; Rect[4].color = 0; // bottom right Rect[5].x = x + w; Rect[5].y = y; Rect[5].u = PsxScreenUv[UvTop]; Rect[5].v = PsxScreenUv[UvLeft]; Rect[5].color = 0; int i = 0; for (i = 0; i < 6; i++) { Rect[i].z = 0.0; Rect[i].w = 1.0; } CreateTexture(psxRealW, psxRealH); Xe_SetClearColor(g_pVideoDevice, 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; }
static struct XenosSurface *loadPNGFromMemory(unsigned char *PNGdata) { int y = 0; int width, height; png_byte color_type; png_byte bit_depth; png_structp png_ptr; png_infop info_ptr; // int number_of_passes; png_bytep * row_pointers; offset = 0; struct file_buffer_t *file; file = (struct file_buffer_t *) malloc(sizeof (struct file_buffer_t)); file->length = 1024 * 1024 * 5; file->data = (unsigned char *) malloc(file->length); //5mo ... file->offset = 0; memcpy(file->data, PNGdata, file->length); /* initialize stuff */ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) { printf("[read_png_file] png_create_read_struct failed\n"); return 0; } info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { printf("[read_png_file] png_create_info_struct failed\n"); return 0; } png_set_read_fn(png_ptr, (png_voidp *) file, png_mem_read); //permet de lire à partir de pngfile buff //png_set_sig_bytes(png_ptr, 8);//on avance de 8 ? png_read_info(png_ptr, info_ptr); width = info_ptr->width; height = info_ptr->height; color_type = info_ptr->color_type; bit_depth = info_ptr->bit_depth; // number_of_passes = png_set_interlace_handling(png_ptr); if (color_type != PNG_COLOR_TYPE_RGB && color_type != PNG_COLOR_TYPE_RGB_ALPHA) { printf("no support :( \n bit_depth = %08x\n", bit_depth); return 0; } if (color_type == PNG_COLOR_TYPE_RGB) png_set_filler(png_ptr, 0xFF, PNG_FILLER_BEFORE); png_set_swap_alpha(png_ptr); png_read_update_info(png_ptr, info_ptr); //On créer la surface struct XenosSurface *surface = Xe_CreateTexture(g_pVideoDevice, width, height, 1, XE_FMT_8888 | XE_FMT_ARGB, 0); uint8_t *data = (uint8_t*) Xe_Surface_LockRect(g_pVideoDevice, surface, 0, 0, 0, 0, XE_LOCK_WRITE); row_pointers = (png_bytep*) malloc(sizeof (png_bytep) * surface->height); for (y = 0; y < surface->height; y++) row_pointers[y] = data + surface->wpitch * y; png_read_image(png_ptr, row_pointers); Xe_Surface_Unlock(g_pVideoDevice, surface); free(file->data); free(file); free(row_pointers); return surface; }
static struct XenosSurface * MyXeCreateTexture(struct XenosDevice *xe, unsigned int width, unsigned int height, unsigned int levels, int format, int tiled) { return Xe_CreateTexture(xe, width, height, levels, format, tiled); }
static struct XenosSurface * CreateSurface(int w, int h, int fmt) { struct XenosSurface * s = Xe_CreateTexture(g_pVideoDevice, w, h, 1, fmt, 0); memset(s->base, 0, s->hpitch * s->wpitch); return s; }