Esempio n. 1
0
// classic way
void XenonGLDisplay()
{    	
	// Reset states and matrices
	XeGlResetDirty();
	xe_state.dirty = 1;
	
	// Set stream
    Xe_SetStreamSource(xe, 0, pVbGL, 0, 10);
	
    // update vb and ib cache !!!
    xe_Vertices = Xe_VB_Lock(xe, pVbGL, 0, xe_NumVerts * sizeof(glVerticesFormat_t), XE_LOCK_WRITE);
	Xe_VB_Unlock(xe, pVbGL);
	
	xe_indices = Xe_IB_Lock(xe, pIbGL, 0, xe_NumIndices * sizeof(short), XE_LOCK_WRITE);
	Xe_IB_Unlock(xe, pIbGL); 
    
    // Resolve
    Xe_Resolve(xe);
    //while(!Xe_IsVBlank(xe));
    
    Xe_Sync(xe);
    
    // Reset states
    Xe_InvalidateState(xe);
    
    
    
    // printf("xe_NumVerts %d xe_NumIndices %d\r\n", xe_NumVerts, xe_NumIndices);
    
    // Reset vertices
    xe_NumVerts = xe_PrevNumVerts = 0;
    xe_NumIndices = xe_PrevNumIndices = 0;
 
	ShowFPS();
}
Esempio n. 2
0
void SYSVideoUpdate() {
    /* resize uv to viewport */
    int vwidth = bitmap.viewport.w + (2 * bitmap.viewport.x);
    int vheight = bitmap.viewport.h + (2 * bitmap.viewport.y);

    update_texture_viewport();
    
    int video_filter = getVideoFitler();

    // apply video filter
    switch (video_filter){
        case VF_2XSAI:
            filter_Std2xSaI_ex8(bitmap.data, bitmap.pitch, texture_buffer, vwidth, vheight);
            g_pTexture->width = vwidth<<1;
            g_pTexture->height = vheight<<1;
            break;
        case VF_BLINEAR:
            g_pTexture->use_filtering = 0;
            XeTexSubImage(g_pTexture, bitmap.viewport.x, bitmap.viewport.y, bitmap.viewport.w, bitmap.viewport.h, bitmap.data);
            g_pTexture->width = vwidth;
            g_pTexture->height = vheight;
            break;
        default:
            g_pTexture->use_filtering = 1;
            XeTexSubImage(g_pTexture, bitmap.viewport.x, bitmap.viewport.y, bitmap.viewport.w, bitmap.viewport.h, bitmap.data);
            g_pTexture->width = vwidth;
            g_pTexture->height = vheight;
            break;
    }

    // Refresh texture cash
    Xe_Surface_LockRect(g_pVideoDevice, g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE);
    Xe_Surface_Unlock(g_pVideoDevice, g_pTexture);
        

    // Select stream and shaders
    Xe_SetTexture(g_pVideoDevice, 0, g_pTexture);
    Xe_SetCullMode(g_pVideoDevice, XE_CULL_NONE);
    Xe_SetStreamSource(g_pVideoDevice, 0, vb, 0, sizeof (DrawVerticeFormats));
    Xe_SetShader(g_pVideoDevice, SHADER_TYPE_PIXEL, g_pPixelTexturedShader, 0);
    Xe_SetShader(g_pVideoDevice, SHADER_TYPE_VERTEX, g_pVertexShader, 0);

    Xe_SetClearColor(g_pVideoDevice, 0xFF000000);
    // Draw
    Xe_DrawPrimitive(g_pVideoDevice, XE_PRIMTYPE_RECTLIST, 0, 1);

    // Resolve
    Xe_Resolve(g_pVideoDevice);
    //while (!Xe_IsVBlank(g_pVideoDevice));
    Xe_Sync(g_pVideoDevice);
    
    // Reset states
    Xe_InvalidateState(g_pVideoDevice);
}
Esempio n. 3
0
static bool xenon360_gfx_frame(void *data, const void *frame, unsigned width, unsigned height,
      uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info)
{
   gl_t *vid = data;

   ScreenUv[UV_TOP]	= ((float) (width) / (float) XE_W)*2;
   ScreenUv[UV_LEFT]	= ((float) (height) / (float) XE_H)*2;

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

   /* bottom left */
   Rect[1].v = ScreenUv[UV_LEFT];
   Rect[2].u = ScreenUv[UV_TOP];

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

   /* Refresh texture cache */
   uint16_t *dst       = Xe_Surface_LockRect(vid->gl_device, vid->g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE);
   const uint16_t *src = frame;
   unsigned stride_in  = pitch >>1;
   unsigned stride_out = vid->g_pTexture->wpitch >> 1;
   unsigned copy_size  = width << 1;

   for (unsigned y = 0; y < height; y++, dst += stride_out, src += stride_in)
      memcpy(dst, src, copy_size);
   Xe_Surface_Unlock(vid->gl_device, vid->g_pTexture);

   /* Reset states */
   Xe_InvalidateState(vid->gl_device);
   Xe_SetClearColor(vid->gl_device, 0);

   /* Select stream */
   Xe_SetTexture(vid->gl_device, 0, vid->g_pTexture);
   Xe_SetCullMode(vid->gl_device, XE_CULL_NONE);
   Xe_SetStreamSource(vid->gl_device, 0, vid->vb, 0, sizeof(DrawVerticeFormats));

   /* Select shaders */
   Xe_SetShader(vid->gl_device, SHADER_TYPE_PIXEL, vid->g_pPixelTexturedShader, 0);
   Xe_SetShader(vid->gl_device, SHADER_TYPE_VERTEX, vid->g_pVertexShader, 0);

#ifdef HAVE_MENU
   menu_driver_frame(video_info);
#endif

   /* Draw */
   Xe_DrawPrimitive(vid->gl_device, XE_PRIMTYPE_TRIANGLELIST, 0, 1);

   /* Resolve */
   Xe_Resolve(vid->gl_device);
   Xe_Sync(vid->gl_device);

   return true;
}
Esempio n. 4
0
void XenonBeginGl()
{	
	// Reset states
    Xe_InvalidateState(xe);
    
    Xe_Sync(xe);
    
    // Set stream
    Xe_SetStreamSource(xe, 0, pVbGL, 0, 10);
    
    // Xe_SetFrameBufferSurface(xe, frontbuffer);
    
    // Reset states and matrices
    XeGlResetDirty();
    xe_state.dirty = 1;    
}
Esempio n. 5
0
/**
 * mode / type
 **/ 
void glDrawElements(GLenum mode, GLsizei numIndexes, GLenum type, const GLvoid * indices)
{
	int i = 0;
	
	union {
		float f;
		unsigned int u32;
	} color;
	
	// Begin
	xe_PrevNumVerts = xe_NumVerts;
	xe_PrevNumIndices = xe_NumIndices;
	
	unsigned int * indexes = (unsigned int*)indices;
	void * vertice_ptr = vertexPointer.pointer;
	void * color_ptr = colorPointer.pointer;
	void * texcoords0_ptr = texCoordPointer[0].pointer;
	void * texcoords1_ptr = texCoordPointer[1].pointer;
	
	// vertices
	for (i = 0 ; i < vertexPointer.count ; i++) {
		float * v = (float*) vertice_ptr;
		float * t0 = (float*) texcoords0_ptr;
		float * t1 = (float*) texcoords1_ptr;
		unsigned char * c = (unsigned char*) color_ptr;
		color.u32 = COLOR_ARGB(c[3], c[2], c[1], c[0]);
		//color.u32 = 0xFFFFFFFF;
		
		*xe_Vertices++ = v[0];
		*xe_Vertices++ = v[1];
		*xe_Vertices++ = v[2];
		*xe_Vertices++ = 1;
		
		if (texcoords0_ptr) {
			*xe_Vertices++ = t0[0];
			*xe_Vertices++ = t0[1];
		} else {
			*xe_Vertices++ = 0;
			*xe_Vertices++ = 0;
		}
		
		if (texcoords1_ptr) {
			*xe_Vertices++ = t1[0];
			*xe_Vertices++ = t1[1];
		} else {
			*xe_Vertices++ = 0;
			*xe_Vertices++ = 0;
		}
		
		*xe_Vertices++ = color.f;		
		
		vertice_ptr += vertexPointer.stride;
		if (texcoords0_ptr) {
			texcoords0_ptr += 2 * sizeof(float);
		}
		if (texcoords1_ptr) {
			texcoords1_ptr += 2 * sizeof(float);
		}
		color_ptr += 4 * sizeof(char);
				
		xe_NumVerts++;
	}
	
	// indices
	for (i = 0 ; i < numIndexes ; i++) {
		*xe_indices++ = indexes[i] + xe_PrevNumVerts;
		xe_NumIndices++;
	}
	
	
	XeUpdateStates();
	XeGlCheckDirtyMatrix(&projection_matrix);
	XeGlCheckDirtyMatrix(&modelview_matrix);
	
	// setup shaders and textures
	Xe_SetShader(xe, SHADER_TYPE_VERTEX, pVertexShader, 0);
	GL_SelectShaders();
	GL_SelectTextures();
	
	Xe_SetIndices(xe, pIbGL);
	Xe_SetStreamSource(xe, 0, pVbGL, 0, 10);
		
	Xe_DrawIndexedPrimitive(
		xe, 
		XE_PRIMTYPE_TRIANGLELIST, 
		0, 0,
		vertexPointer.count, 
		xe_PrevNumIndices, 
		numIndexes/3
	);
}
Esempio n. 6
0
void osd_xenon_update_video(render_primitive_list &primlist) {

    //primlist->acquire_lock();
    currList = &primlist;
	pre_render();

	int minwidth, minheight;
	int newwidth, newheight;

	// get the minimum width/height for the current layout
	xenos_target->compute_minimum_size(minwidth, minheight);

//            minwidth = screen_width;
//            minheight = screen_height;

	// make that the size of our target
	xenos_target->set_bounds(minwidth, minheight);

	xenos_target->compute_visible_area(screen_width, screen_height, screen_width / screen_height, xenos_target->orientation(), newwidth, newheight);

	//ShaderEffects.at(2).Render(minwidth, minheight);
	ShaderEffects.at(0).Render(minwidth, minheight);

	Xe_SetStreamSource(g_pVideoDevice, 0, soft_vb, nb_vertices, sizeof (MameVerticeFormats));

	vertices = (MameVerticeFormats *) Xe_VB_Lock(g_pVideoDevice, soft_vb, 0, 3 * sizeof (MameVerticeFormats), XE_LOCK_WRITE);
	//CreateRect(((float) newwidth / (float) screen_width), -((float) newheight / (float) screen_height), vertices);
	CreateRectHlsl(screen_width, screen_height, vertices);
	Xe_VB_Unlock(g_pVideoDevice, soft_vb);

	// update texture
	//draw32_draw_primitives(primlist, screen, minwidth, minheight, g_pTexture->wpitch / 4);

	/* loop over the list and render each element */
	const render_primitive *prim;
	void *dstdata = (void *) screen;
	UINT32 width = minwidth;
	UINT32 height = minheight;
	UINT32 pitch = g_pTexture->wpitch / 4;
	/*
	for (prim = currList->first(); prim != NULL; prim = prim->next()) {
		switch (prim->type) {
			case render_primitive::LINE:
				draw32_draw_line(prim, dstdata, width, height, pitch);
				break;

			case render_primitive::QUAD:
				if (!prim->texture.base)
					draw32_draw_rect(prim, dstdata, width, height, pitch);
				else
					draw32_setup_and_draw_textured_quad(prim, dstdata, width, height, pitch);
				break;

			default:
				throw emu_fatalerror("Unexpected render_primitive type");
		}
	}
	* */
	
	software_renderer<UINT32, 0,0,0, 16,8,0>::draw_primitives(primlist, dstdata, width, height, pitch);

	Xe_Surface_LockRect(g_pVideoDevice, g_pTexture, 0, 0, 0, 0, XE_LOCK_WRITE);
	Xe_Surface_Unlock(g_pVideoDevice, g_pTexture);

	// correct texture size
	g_pTexture->width = minwidth;
	g_pTexture->height = minheight;

	// draw
	Xe_SetTexture(g_pVideoDevice, 0, g_pTexture);
	Xe_DrawPrimitive(g_pVideoDevice, XE_PRIMTYPE_RECTLIST, 0, 1);

	render();
}
Esempio n. 7
0
static void draw_quad(render_primitive *prim) {
    void * texture = (prim->texture.base);

    //void Xe_SetBlendControl(struct XenosDevice *xe, int col_src, int col_op, int col_dst, int alpha_src, int alpha_op, int alpha_dst);
    switch (PRIMFLAG_GET_BLENDMODE(prim->flags)) {
        case BLENDMODE_NONE:
            Xe_SetAlphaTestEnable(g_pVideoDevice,0);
            Xe_SetBlendOp(g_pVideoDevice, XE_BLENDOP_ADD);
            Xe_SetSrcBlend(g_pVideoDevice, XE_BLEND_SRCALPHA);
            Xe_SetDestBlend(g_pVideoDevice, XE_BLEND_INVSRCALPHA);
            break;
        case BLENDMODE_ALPHA:
            Xe_SetAlphaTestEnable(g_pVideoDevice,1);
            Xe_SetBlendOp(g_pVideoDevice, XE_BLENDOP_ADD);
            Xe_SetSrcBlend(g_pVideoDevice, XE_BLEND_SRCALPHA);
            Xe_SetDestBlend(g_pVideoDevice, XE_BLEND_INVSRCALPHA);
            break;
        case BLENDMODE_RGB_MULTIPLY:
            Xe_SetAlphaTestEnable(g_pVideoDevice,1);
            Xe_SetBlendOp(g_pVideoDevice, XE_BLENDOP_ADD);
            Xe_SetSrcBlend(g_pVideoDevice, XE_BLEND_DESTCOLOR);
            Xe_SetDestBlend(g_pVideoDevice, XE_BLEND_ZERO);
            break;
        case BLENDMODE_ADD:
            Xe_SetAlphaTestEnable(g_pVideoDevice,1);
            Xe_SetBlendOp(g_pVideoDevice, XE_BLENDOP_ADD);
            Xe_SetSrcBlend(g_pVideoDevice, XE_BLEND_SRCALPHA);
            Xe_SetDestBlend(g_pVideoDevice, XE_BLEND_ONE);
            break;
    }

    DrawVerticeFormats *vertex = (DrawVerticeFormats *) Xe_VB_Lock(g_pVideoDevice, vb, nb_vertices, 3 * sizeof (DrawVerticeFormats), XE_LOCK_WRITE);
    memset(vertex, 0, 3 * sizeof (DrawVerticeFormats));
    {
        vertex[0].x = prim->bounds.x0 - 0.5f;
        vertex[0].y = prim->bounds.y0 - 0.5f;
        vertex[1].x = prim->bounds.x1 - 0.5f;
        vertex[1].y = prim->bounds.y0 - 0.5f;
        vertex[2].x = prim->bounds.x0 - 0.5f;
        vertex[2].y = prim->bounds.y1 - 0.5f;
        vertex[3].x = prim->bounds.x1 - 0.5f;
        vertex[3].y = prim->bounds.y1 - 0.5f;

        // set the texture coordinates
        if (texture != NULL) {
            vertex[0].u = prim->texcoords.tl.u;
            vertex[0].v = prim->texcoords.tl.v;
            vertex[1].u = prim->texcoords.tr.u;
            vertex[1].v = prim->texcoords.tr.v;
            vertex[2].u = prim->texcoords.bl.u;
            vertex[2].v = prim->texcoords.bl.v;
            vertex[3].u = prim->texcoords.br.u;
            vertex[3].v = prim->texcoords.br.v;
            n++;
        }

        XeColor color;
        color.r = (prim->color.r * 255.0f);
        color.g = (prim->color.g * 255.0f);
        color.b = (prim->color.b * 255.0f);
        color.a = (prim->color.a * 255.0f);

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


    Xe_VB_Unlock(g_pVideoDevice, vb);

    Xe_SetStreamSource(g_pVideoDevice, 0, vb, nb_vertices, sizeof (DrawVerticeFormats));
    Xe_DrawPrimitive(g_pVideoDevice, XE_PRIMTYPE_RECTLIST, 0, 1);

    nb_vertices += 256;
}