Beispiel #1
0
static void *switch_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
   unsigned x, y;
   switch_video_t *sw = (switch_video_t*)calloc(1, sizeof(*sw));
   if (!sw)
      return NULL;

   RARCH_LOG("loading switch gfx driver, width: %d, height: %d\n", video->width, video->height);

   result_t r = display_init();
   if (r != RESULT_OK)
   {
      free(sw);
      return NULL;
   }
   r = display_open_layer(&sw->surface);

   if (r != RESULT_OK)
   {
      display_finalize();
      free(sw);
      return NULL;
   }
   r = display_get_vsync_event(&sw->vsync_h);

   if (r != RESULT_OK)
   {
	   display_close_layer(&sw->surface);
      display_finalize();
      free(sw);
      return NULL;
   }

   sw->vp.x           = 0;
   sw->vp.y           = 0;
   sw->vp.width       = 1280;
   sw->vp.height      = 720;
   sw->vp.full_width  = 1280;
   sw->vp.full_height = 720;
   video_driver_set_size(&sw->vp.width, &sw->vp.height);

   sw->vsync = video->vsync;
   sw->rgb32 = video->rgb32;

   *input = NULL;
   *input_data = NULL;

   return sw;
}
Beispiel #2
0
static void switch_free(void *data)
{
	switch_video_t *sw = data;
	svcCloseHandle(sw->vsync_h);
	display_close_layer(&sw->surface);
	display_finalize();
	free(sw);
}
Beispiel #3
0
// Closes the native display and deallocates all resources from FFVADisplay
void
ffva_display_free(FFVADisplay *display)
{
    if (!display)
        return;
    display_finalize(display);
    free(display);
}
Beispiel #4
0
int main() {
	display_add_log("inicjowanie wyświetlacza");
	if (display_init()) {
		return -1;
	}

	snake_start();
	
	display_add_log("zwalnianie zasobów...");
	display_finalize();

	display_add_log("koniec programu");
	pthread_exit(NULL);
}
Beispiel #5
0
static bool switch_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)
{
	static uint64_t last_frame = 0;
	
   unsigned x, y;
   result_t r;
   int tgtw, tgth, centerx, centery;
   uint32_t *out_buffer   = NULL;
   switch_video_t *sw     = data;
   int xsf                = 1280 / width;
   int ysf                = 720  / height;
   int sf                 = xsf;

   if (ysf < sf)
      sf = ysf;

   tgtw                   = width * sf;
   tgth                   = height * sf;
   centerx                = (1280-tgtw)/2;
   centery                = (720-tgth)/2;

   // clear image to black
   for(y = 0; y < 720; y++)
   {
      for(x = 0; x < 1280; x++)
      {
         sw->image[y*1280+x] = 0xFF000000;
      }
   }

   if(width > 0 && height > 0) {
	   if(sw->last_width != width ||
	      sw->last_height != height)
		   {
			   scaler_ctx_gen_reset(&sw->scaler);
			   
			   sw->scaler.in_width = width;
			   sw->scaler.in_height = height;
			   sw->scaler.in_stride = pitch;
			   sw->scaler.in_fmt = sw->rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGB565;
			   
			   sw->scaler.out_width = tgtw;
			   sw->scaler.out_height = tgth;
			   sw->scaler.out_stride = 1280 * sizeof(uint32_t);
			   sw->scaler.out_fmt = SCALER_FMT_ABGR8888;
			   
			   sw->scaler.scaler_type = SCALER_TYPE_POINT;
			   
			   if(!scaler_ctx_gen_filter(&sw->scaler)) {
				   RARCH_ERR("failed to generate scaler for main image\n");
				   return false;
			   }

			   sw->last_width = width;
			   sw->last_height = height;
		   }

	   scaler_ctx_scale(&sw->scaler, sw->image + (centery * 1280) + centerx, frame);
   }

#if defined(HAVE_MENU)
   if (sw->menu_texture.enable)
	{
		menu_driver_frame(video_info);

		if (sw->menu_texture.pixels)
		{
#if 0
			if (sw->menu_texture.fullscreen)
         {
#endif
	         scaler_ctx_scale(&sw->menu_texture.scaler, sw->image +
	                          ((720-sw->menu_texture.tgth)/2)*1280 +
	                          ((1280-sw->menu_texture.tgtw)/2), sw->menu_texture.pixels);
#if 0
         }
         else
         {
         }
#endif
		}
	}
   else if (video_info->statistics_show)
   {
      struct font_params *osd_params = (struct font_params*)
         &video_info->osd_stat_params;

      if (osd_params)
      {
         font_driver_render_msg(video_info, NULL, video_info->stat_text,
               (const struct font_params*)&video_info->osd_stat_params);
      }
   }
#endif

#if 0
   if (frame_count > 6000)
   {
      display_finalize();
      exit(0);
   }
#endif

   if (msg && strlen(msg) > 0)
      RARCH_LOG("message: %s\n", msg);

   r = surface_dequeue_buffer(&sw->surface, &out_buffer);
   if (sw->vsync)
	   switch_wait_vsync(sw);
   svcSleepThread(10000);
   if(r != RESULT_OK) {
	   return true; // just skip the frame
   }
   
   gfx_slow_swizzling_blit(out_buffer, sw->image, 1280, 720, 0, 0);
   
   r = surface_queue_buffer(&sw->surface);
   
   if (r != RESULT_OK)
      return false;

   last_frame = svcGetSystemTick();
   return true;
}
Beispiel #6
0
/*-----------------------------------------------------------
 * Programme principal
 *----------------------------------------------------------*/
int main (int argc, char **argv) {
  struct ctx_s ctx;
  int i;
  int *recopy;
  double timer_start, timer_end;
  double runtime;
  char output[256];

  /* Initialisation MPI */
  initalize_mpi(argc, argv, &ctx);

  /* Initialisation de la taille du domain (grille carree) */
  ctx.X = GRIDSZ / ctx.size;
  ctx.Y = GRIDSZ;
  ctx.grid = init_grid(&ctx);
  randomize_grid(&ctx, ctx.grid);
  ctx.grid_next = init_grid(&ctx);
  fprintf(stderr, "Starting task %d (%dx%d)\n", ctx.rank, ctx.X, ctx.Y);

  /* Initialisation affichage */
  sprintf(output, "output/Rank%d", ctx.rank);
  display_init(&ctx, output, GRIDSZ,GRIDSZ,0 ); // taille 0 pour la 3ieme dimension signifie une grille 2D

  /* Mettre la case au milieu du sous-domaine de la tache 0 en feu ! */
  if (ctx.rank == 0) {
    ctx.grid[(ctx.X+2)/2][(ctx.Y+2)/2] = burning;
  }

  recopy = recopy_grid(&ctx, ctx.grid);
  gather_grid(&ctx, recopy);

  timer_start = get_timer();
  for (i=0; i < MAX_STEPS; ++i) {
    int **swap;
    /* Nombre de cellules mises à jour depuis le pas
     * de temps precedent */
    int nb_updated_cells;
    /* Si la simulation est terminee */
    int leave;

    exchange_ghost_cells(&ctx);

    nb_updated_cells = update_cells(&ctx);

    leave = check_final_conditions(&ctx, nb_updated_cells);
    if (leave) break;

    swap = ctx.grid;
    ctx.grid = ctx.grid_next;
    ctx.grid_next = swap;

    recopy = recopy_grid(&ctx, ctx.grid);
    gather_grid(&ctx, recopy);
    if (ctx.rank == 0 && i%10 == 0) {
      fprintf(stderr, "..[%d]", i);
    }
  }
  timer_end = get_timer();

  if (ctx.rank == 0) {
    fprintf(stderr, "\n");
  }

  display_finalize(&ctx);
  runtime = diff_time(timer_end, timer_start);
  print_time (&ctx, runtime);

  /* Fin de la simulation */
  finalize_mpi(&ctx);
  exit(0);
}