Exemplo n.º 1
0
static bool texture_image_render(d3d_video_t *d3d,
      struct texture_image *out_img,
      int x, int y, int w, int h, bool force_fullscreen)
{
   LPDIRECT3DTEXTURE d3dt;
   LPDIRECT3DVERTEXBUFFER d3dv;
   void *verts           = NULL;
   float fX              = (float)(x);
   float fY              = (float)(y);

   if (!d3d)
      return false;

   d3dt = (LPDIRECT3DTEXTURE)out_img->texture_buf;
   d3dv = (LPDIRECT3DVERTEXBUFFER)out_img->vertex_buf;

   if (!d3dt || !d3dv)
      return false;

   /* Create the new vertices. */
   Vertex newVerts[] =
   {
      // x,           y,              z,     color, u ,v
      {fX,            fY,             0.0f,  0,     0, 0},
      {fX + w,        fY,             0.0f,  0,     1, 0},
      {fX + w,        fY + h,         0.0f,  0,     1, 1},
      {fX,            fY + h,         0.0f,  0,     0, 1}
   };

   /* Load the existing vertices */
   verts = d3d_vertex_buffer_lock(d3dv);

   if (!verts)
      return false;

   /* Copy the new verts over the old verts */
   memcpy(verts, newVerts, sizeof(newVerts));
   d3d_vertex_buffer_unlock(d3dv);

   d3d_enable_blend_func(d3d->dev);
   d3d_enable_alpha_blend_texture_func(d3d->dev);

   /* Draw the quad. */
   d3d_set_texture(d3d->dev, 0, d3dt);
   d3d_set_stream_source(d3d->dev, 0,
         d3dv, 0, sizeof(Vertex));
   d3d_set_vertex_shader(d3d->dev, D3DFVF_CUSTOMVERTEX, NULL);

   if (force_fullscreen)
      d3d_set_viewport(d3d, w, h, force_fullscreen, false);
   d3d_draw_primitive(d3d->dev, D3DPT_QUADLIST, 0, 1);

   return true;
}
Exemplo n.º 2
0
static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay)
{
   struct video_viewport vp;
   unsigned width, height;
   void *verts;
   unsigned i;
   float vert[4][9];
   float overlay_width, overlay_height;

   if (!d3d || !overlay || !overlay->tex)
      return;

   if (!overlay->vert_buf)
   {
      overlay->vert_buf = d3d_vertex_buffer_new(
      d3d->dev, sizeof(vert), 0, 0, D3DPOOL_MANAGED, NULL);

	  if (!overlay->vert_buf)
		  return;
   }

   for (i = 0; i < 4; i++)
   {
      vert[i][2]   = 0.5f;
      vert[i][5]   = 1.0f;
      vert[i][6]   = 1.0f;
      vert[i][7]   = 1.0f;
      vert[i][8]   = overlay->alpha_mod;
   }
   
   d3d_viewport_info(d3d, &vp);

   overlay_width   = vp.width;
   overlay_height  = vp.height;

   vert[0][0]      = overlay->vert_coords[0] * overlay_width;
   vert[1][0]      = (overlay->vert_coords[0] + overlay->vert_coords[2])
      * overlay_width;
   vert[2][0]      = overlay->vert_coords[0] * overlay_width;
   vert[3][0]      = (overlay->vert_coords[0] + overlay->vert_coords[2])
      * overlay_width;
   vert[0][1]      = overlay->vert_coords[1] * overlay_height;
   vert[1][1]      = overlay->vert_coords[1] * overlay_height;
   vert[2][1]      = (overlay->vert_coords[1] + overlay->vert_coords[3])
      * overlay_height;
   vert[3][1]      = (overlay->vert_coords[1] + overlay->vert_coords[3])
      * overlay_height;

   vert[0][3]      = overlay->tex_coords[0];
   vert[1][3]      = overlay->tex_coords[0] + overlay->tex_coords[2];
   vert[2][3]      = overlay->tex_coords[0];
   vert[3][3]      = overlay->tex_coords[0] + overlay->tex_coords[2];
   vert[0][4]      = overlay->tex_coords[1];
   vert[1][4]      = overlay->tex_coords[1];
   vert[2][4]      = overlay->tex_coords[1] + overlay->tex_coords[3];
   vert[3][4]      = overlay->tex_coords[1] + overlay->tex_coords[3];

   /* Align texels and vertices. */
   for (i = 0; i < 4; i++)
   {
      vert[i][0]  -= 0.5f;
      vert[i][1]  += 0.5f;
   }

   verts = d3d_vertex_buffer_lock(overlay->vert_buf);
   memcpy(verts, vert, sizeof(vert));
   d3d_vertex_buffer_unlock(overlay->vert_buf);

   d3d_enable_blend_func(d3d->dev);

#ifndef _XBOX1
   {
      LPDIRECT3DVERTEXDECLARATION vertex_decl;
      /* set vertex declaration for overlay. */
      D3DVERTEXELEMENT vElems[4] = {
         {0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT,
            D3DDECLUSAGE_POSITION, 0},
         {0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT,
            D3DDECLUSAGE_TEXCOORD, 0},
         {0, 20, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT,
            D3DDECLUSAGE_COLOR, 0},
         D3DDECL_END()
      };
      d3d->dev->CreateVertexDeclaration(vElems, &vertex_decl);
      d3d_set_vertex_declaration(d3d->dev, vertex_decl);
      vertex_decl->Release();
   }
#endif

   d3d_set_stream_source(d3d->dev, 0, overlay->vert_buf,
         0, sizeof(*vert));


   if (overlay->fullscreen)
   {
      D3DVIEWPORT vp_full;

      video_driver_get_size(&width, &height);

      vp_full.X      = 0;
      vp_full.Y      = 0;
      vp_full.Width  = width;
      vp_full.Height = height;
      vp_full.MinZ   = 0.0f;
      vp_full.MaxZ   = 1.0f;
      d3d_set_viewports(d3d->dev, &vp_full);
   }

   /* Render overlay. */
   d3d_set_texture(d3d->dev, 0, overlay->tex);
   d3d_set_sampler_address_u(d3d->dev, 0, D3DTADDRESS_BORDER);
   d3d_set_sampler_address_v(d3d->dev, 0, D3DTADDRESS_BORDER);
   d3d_set_sampler_minfilter(d3d->dev, 0, D3DTEXF_LINEAR);
   d3d_set_sampler_magfilter(d3d->dev, 0, D3DTEXF_LINEAR);
   d3d_draw_primitive(d3d->dev, D3DPT_TRIANGLESTRIP, 0, 2);

   /* Restore previous state. */
   d3d_disable_blend_func(d3d->dev);
   d3d_set_viewports(d3d->dev, &d3d->final_viewport);
}
Exemplo n.º 3
0
static void renderchain_set_vertices(
      cg_renderchain_t *chain,
      Pass *pass,
      unsigned width, unsigned height,
      unsigned out_width, unsigned out_height,
      unsigned vp_width, unsigned vp_height,
      unsigned rotation)
{
   const LinkInfo *info = (const LinkInfo*)&pass->info;

   if (pass->last_width != width || pass->last_height != height)
   {
      Vertex vert[4];
      unsigned i;
      void *verts       = NULL;
      float _u          = float(width)  / info->tex_w;
      float _v          = float(height) / info->tex_h;

      pass->last_width  = width;
      pass->last_height = height;

      for (i = 0; i < 4; i++)
      {
         vert[i].z      = 0.5f;
         vert[i].r      = vert[i].g = vert[i].b = vert[i].a = 1.0f;
      }

      vert[0].x         = 0.0f;
      vert[1].x         = out_width;
      vert[2].x         = 0.0f;
      vert[3].x         = out_width;
      vert[0].y         = out_height;
      vert[1].y         = out_height;
      vert[2].y         = 0.0f;
      vert[3].y         = 0.0f;

      vert[0].u         = 0.0f;
      vert[1].u         = _u;
      vert[2].u         = 0.0f;
      vert[3].u         = _u;
      vert[0].v         = 0.0f;
      vert[1].v         = 0.0f;
      vert[2].v         = _v;
      vert[3].v         = _v;

      vert[0].lut_u     = 0.0f;
      vert[1].lut_u     = 1.0f;
      vert[2].lut_u     = 0.0f;
      vert[3].lut_u     = 1.0f;
      vert[0].lut_v     = 0.0f;
      vert[1].lut_v     = 0.0f;
      vert[2].lut_v     = 1.0f;
      vert[3].lut_v     = 1.0f;

      /* Align texels and vertices. */
      for (i = 0; i < 4; i++)
      {
         vert[i].x     -= 0.5f;
         vert[i].y     += 0.5f;
      }

      verts             = d3d_vertex_buffer_lock(pass->vertex_buf);
      memcpy(verts, vert, sizeof(vert));
      d3d_vertex_buffer_unlock(pass->vertex_buf);
   }

   renderchain_set_mvp(chain, pass->vPrg, vp_width, vp_height, rotation);
   renderchain_set_shader_params(chain, pass,
         width, height,
         info->tex_w, info->tex_h,
         vp_width, vp_height);
}
Exemplo n.º 4
0
static void menu_display_d3d_draw(void *data, video_frame_info_t *video_info)
{
   unsigned i;
   video_shader_ctx_mvp_t mvp;
   math_matrix_4x4 mop, m1, m2;
   unsigned width, height;
   d3d_video_t *d3d              = video_info ? (d3d_video_t*)video_info->userdata : NULL;   
   menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
   Vertex * pv                   = NULL;
   const float *vertex           = NULL;
   const float *tex_coord        = NULL;
   const float *color            = NULL;

   if (!d3d || !draw || draw->pipeline.id)
      return;
   if((d3d->menu_display.offset + draw->coords->vertices )
         > (unsigned)d3d->menu_display.size)
      return;

   pv           = (Vertex*)
      d3d_vertex_buffer_lock(d3d->menu_display.buffer);

   if (!pv)
      return;

   pv          += d3d->menu_display.offset;
   vertex       = draw->coords->vertex;
   tex_coord    = draw->coords->tex_coord;
   color        = draw->coords->color;

   if (!vertex)
      vertex    = menu_display_d3d_get_default_vertices();
   if (!tex_coord)
      tex_coord = menu_display_d3d_get_default_tex_coords();

   for (i = 0; i < draw->coords->vertices; i++)
   {
      int colors[4];

      colors[0]   = *color++ * 0xFF;
      colors[1]   = *color++ * 0xFF;
      colors[2]   = *color++ * 0xFF;
      colors[3]   = *color++ * 0xFF;

      pv[i].x     = *vertex++;
      pv[i].y     = *vertex++;
      pv[i].z     = 0.5f;
      pv[i].u     = *tex_coord++;
      pv[i].v     = *tex_coord++;
#ifdef HAVE_D3D8
	  if ((void*)draw->texture)
      {
         D3DSURFACE_DESC desc;
         if (d3d_texture_get_level_desc((void*)draw->texture, 0, &desc))
         {
            pv[i].u *= desc.Width;
            pv[i].v *= desc.Height;
         }
      }
#endif

      pv[i].color =
         D3DCOLOR_ARGB(
               colors[3], /* A */
               colors[0], /* R */
               colors[1], /* G */
               colors[2]  /* B */
               );
   }
   d3d_vertex_buffer_unlock(d3d->menu_display.buffer);

   if(!draw->matrix_data)
      draw->matrix_data = menu_display_d3d_get_default_mvp(video_info);

   /* ugh */
   video_driver_get_size(&width, &height);
   matrix_4x4_scale(m1,       2.0,  2.0, 0);
   matrix_4x4_translate(mop, -1.0, -1.0, 0);
   matrix_4x4_multiply(m2, mop, m1);
   matrix_4x4_multiply(m1,
         *((math_matrix_4x4*)draw->matrix_data), m2);
   matrix_4x4_scale(mop,
         (draw->width  / 2.0) / width,
         (draw->height / 2.0) / height, 0);
   matrix_4x4_multiply(m2, mop, m1);
   matrix_4x4_translate(mop,
         (draw->x + (draw->width  / 2.0)) / width,
         (draw->y + (draw->height / 2.0)) / height,
         0);
   matrix_4x4_multiply(m1, mop, m2);
   matrix_4x4_multiply(m2, d3d->mvp_transposed, m1);
   d3d_matrix_transpose(&m1, &m2);

   mvp.data   = d3d;
   mvp.matrix = &m1;
   video_driver_set_mvp(&mvp);
   menu_display_d3d_bind_texture(draw, (d3d_video_t*)video_info->userdata);
   d3d_draw_primitive(d3d->dev,
         menu_display_prim_to_d3d_enum(draw->prim_type),
         d3d->menu_display.offset,
         draw->coords->vertices - 
         ((draw->prim_type == MENU_DISPLAY_PRIM_TRIANGLESTRIP) 
          ? 2 : 0));

   d3d->menu_display.offset += draw->coords->vertices;
}
Exemplo n.º 5
0
static bool texture_image_render(d3d_video_t *d3d,
      struct texture_image *out_img,
      int x, int y, int w, int h, bool force_fullscreen)
{
   void *verts           = NULL;
   LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
   float fX              = (float)(x);
   float fY              = (float)(y);

   if (!d3d)
      return false;
   if (!out_img->pixels || !out_img->vertex_buf)
      return false;

   /* Create the new vertices. */
   Vertex newVerts[] =
   {
      // x,           y,              z,     color, u ,v
      {fX,            fY,             0.0f,  0,     0, 0},
      {fX + w,        fY,             0.0f,  0,     1, 0},
      {fX + w,        fY + h,         0.0f,  0,     1, 1},
      {fX,            fY + h,         0.0f,  0,     0, 1}
   };

   /* Load the existing vertices */
   verts = d3d_vertex_buffer_lock(out_img->vertex_buf);

   if (!verts)
      return false;

   /* Copy the new verts over the old verts */
   memcpy(verts, newVerts, sizeof(newVerts));
   d3d_vertex_buffer_unlock(out_img->vertex_buf);

   d3d_enable_blend_func(d3d->dev);

   /* Also blend the texture with the set alpha value. */
   d3d->dev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
   d3d->dev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
   d3d->dev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);

   /* Draw the quad. */
   d3d_set_texture(d3dr, 0, out_img->texture_buf);
   d3d_set_stream_source(d3dr, 0,
         out_img->vertex_buf, 0, sizeof(Vertex));
   d3d_set_vertex_shader(d3dr, D3DFVF_CUSTOMVERTEX, NULL);

   if (force_fullscreen)
   {
      D3DVIEWPORT vp = {0};
      vp.Width       = w;
      vp.Height      = h;
      vp.X           = 0;
      vp.Y           = 0;
      vp.MinZ        = 0.0f;
      vp.MaxZ        = 1.0f;
      d3d_set_viewport(d3dr, &vp);
   }
   d3d_draw_primitive(d3dr, D3DPT_QUADLIST, 0, 1);

   return true;
}
Exemplo n.º 6
0
static void renderchain_set_vertices(void *data, unsigned pass,
      unsigned width, unsigned height)
{
   d3d_video_t *d3d         = (d3d_video_t*)data;
   runloop_t *runloop       = rarch_main_get_ptr();
   global_t *global         = global_get_ptr();
   xdk_renderchain_t *chain = (xdk_renderchain_t*)d3d->renderchain_data;

   if (chain->last_width != width || chain->last_height != height)
   {
      unsigned i;
      Vertex vert[4];
      void *verts      = NULL;

      chain->last_width  = width;
      chain->last_height = height;

      float tex_w      = width;
      float tex_h      = height;
#ifdef _XBOX360
      tex_w           /= ((float)chain->tex_w);
      tex_h           /= ((float)chain->tex_h);
#endif

      vert[0].x        = -1.0f;
      vert[1].x        =  1.0f;
      vert[2].x        = -1.0f;
      vert[3].x        =  1.0f;

      vert[0].y        = -1.0f;
      vert[1].y        = -1.0f;
      vert[2].y        =  1.0f;
      vert[3].y        =  1.0f;
#if defined(_XBOX1)
      vert[0].z        =  1.0f;
      vert[1].z        =  1.0f;
      vert[2].z        =  1.0f;
      vert[3].z        =  1.0f;

      vert[0].rhw      = 0.0f;
      vert[1].rhw      = tex_w;
      vert[2].rhw      = 0.0f;
      vert[3].rhw      = tex_w;

      vert[0].u        = tex_h;
      vert[1].u        = tex_h;
      vert[2].u        = 0.0f;
      vert[3].u        = 0.0f;

      vert[0].v        = 0.0f;
      vert[1].v        = 0.0f;
      vert[2].v        = 0.0f;
      vert[3].v        = 0.0f;
#elif defined(_XBOX360)
      vert[0].u        = 0.0f;
      vert[1].u        = tex_w;
      vert[2].u        = 0.0f;
      vert[3].u        = tex_w;

      vert[0].v        = tex_h;
      vert[1].v        = tex_h;
      vert[2].v        = 0.0f;
      vert[3].v        = 0.0f;
#endif

      /* Align texels and vertices. */
      for (i = 0; i < 4; i++)
      {
         vert[i].x    -= 0.5f / ((float)chain->tex_w);
         vert[i].y    += 0.5f / ((float)chain->tex_h);
      }

      verts = d3d_vertex_buffer_lock(chain->vertex_buf);
      memcpy(verts, vert, sizeof(vert));
      d3d_vertex_buffer_unlock(chain->vertex_buf);
   }

#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL)
#ifdef _XBOX
   if (d3d->shader)
   {
      renderchain_set_mvp(d3d, global->video_data.width, global->video_data.height, d3d->dev_rotation);
      if (d3d->shader->use)
         d3d->shader->use(d3d, pass);
      if (d3d->shader->set_params)
         d3d->shader->set_params(d3d, width, height, chain->tex_w,
               chain->tex_h, global->video_data.width,
               global->video_data.height, runloop->frames.video.count,
               NULL, NULL, NULL, 0);
   }
#endif
#endif
}
Exemplo n.º 7
0
static void renderchain_set_vertices(void *data, unsigned pass,
      unsigned vert_width, unsigned vert_height, uint64_t frame_count)
{
   unsigned width, height;
   d3d_video_t *d3d         = (d3d_video_t*)data;
   xdk_renderchain_t *chain = d3d ? (xdk_renderchain_t*)d3d->renderchain_data : NULL;

   video_driver_get_size(&width, &height);

   if (!chain)
      return;

   if (chain->last_width != vert_width || chain->last_height != vert_height)
   {
      unsigned i;
      Vertex vert[4];
      void *verts      = NULL;

      chain->last_width  = vert_width;
      chain->last_height = vert_height;

      float tex_w        = vert_width;
      float tex_h        = vert_height;
#ifdef _XBOX360
      tex_w             /= ((float)chain->tex_w);
      tex_h             /= ((float)chain->tex_h);
#endif

      vert[0].x        = -1.0f;
      vert[1].x        =  1.0f;
      vert[2].x        = -1.0f;
      vert[3].x        =  1.0f;

      vert[0].y        = -1.0f;
      vert[1].y        = -1.0f;
      vert[2].y        =  1.0f;
      vert[3].y        =  1.0f;
#if defined(_XBOX1)
      vert[0].z        =  1.0f;
      vert[1].z        =  1.0f;
      vert[2].z        =  1.0f;
      vert[3].z        =  1.0f;

      vert[0].rhw      = 0.0f;
      vert[1].rhw      = tex_w;
      vert[2].rhw      = 0.0f;
      vert[3].rhw      = tex_w;

      vert[0].u        = tex_h;
      vert[1].u        = tex_h;
      vert[2].u        = 0.0f;
      vert[3].u        = 0.0f;

      vert[0].v        = 0.0f;
      vert[1].v        = 0.0f;
      vert[2].v        = 0.0f;
      vert[3].v        = 0.0f;
#elif defined(_XBOX360)
      vert[0].u        = 0.0f;
      vert[1].u        = tex_w;
      vert[2].u        = 0.0f;
      vert[3].u        = tex_w;

      vert[0].v        = tex_h;
      vert[1].v        = tex_h;
      vert[2].v        = 0.0f;
      vert[3].v        = 0.0f;
#endif

      /* Align texels and vertices. */
      for (i = 0; i < 4; i++)
      {
         vert[i].x    -= 0.5f / ((float)chain->tex_w);
         vert[i].y    += 0.5f / ((float)chain->tex_h);
      }

      verts = d3d_vertex_buffer_lock(chain->vertex_buf);
      memcpy(verts, vert, sizeof(vert));
      d3d_vertex_buffer_unlock(chain->vertex_buf);
   }

#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL)
#ifdef _XBOX
   renderchain_set_mvp(d3d, width, height, d3d->dev_rotation);
   video_shader_driver_use(d3d, pass);
   video_shader_driver_set_params(
         d3d, vert_width, vert_height, chain->tex_w,
         chain->tex_h, width, height, frame_count,
         NULL, NULL, NULL, NULL, 0);
#endif
#endif
}
Exemplo n.º 8
0
static void renderchain_set_vertices(
      cg_renderchain_t *chain,
      Pass *pass,
      unsigned width, unsigned height,
      unsigned out_width, unsigned out_height,
      unsigned vp_width, unsigned vp_height,
      unsigned rotation)
{
   const LinkInfo *info = (const LinkInfo*)&pass->info;

   if (pass->last_width != width || pass->last_height != height)
   {
      Vertex vert[4];
      unsigned i;
      void *verts       = NULL;
      float _u          = float(width)  / info->tex_w;
      float _v          = float(height) / info->tex_h;

      pass->last_width  = width;
      pass->last_height = height;

      vert[0].x         = 0.0f;
      vert[0].y         = out_height;
      vert[0].z         = 0.5f;
      vert[0].u         = 0.0f;
      vert[0].v         = 0.0f;
      vert[0].lut_u     = 0.0f;
      vert[0].lut_v     = 0.0f;
      vert[0].r         = 1.0f;
      vert[0].g         = 1.0f;
      vert[0].b         = 1.0f;
      vert[0].a         = 1.0f;

      vert[1].x         = out_width;
      vert[1].y         = out_height;
      vert[1].z         = 0.5f;
      vert[1].u         = _u;
      vert[1].v         = 0.0f;
      vert[1].lut_u     = 1.0f;
      vert[1].lut_v     = 0.0f;
      vert[1].r         = 1.0f;
      vert[1].g         = 1.0f;
      vert[1].b         = 1.0f;
      vert[1].a         = 1.0f;

      vert[2].x         = 0.0f;
      vert[2].y         = 0.0f;
      vert[2].z         = 0.5f;
      vert[2].u         = 0.0f;
      vert[2].v         = _v;
      vert[2].lut_u     = 0.0f;
      vert[2].lut_v     = 1.0f;
      vert[2].r         = 1.0f;
      vert[2].g         = 1.0f;
      vert[2].b         = 1.0f;
      vert[2].a         = 1.0f;

      vert[3].x         = out_width;
      vert[3].y         = 0.0f;
      vert[3].z         = 0.5f;
      vert[3].u         = _u;
      vert[3].v         = _v;
      vert[3].lut_u     = 1.0f;
      vert[3].lut_v     = 1.0f;
      vert[3].r         = 1.0f;
      vert[3].g         = 1.0f;
      vert[3].b         = 1.0f;
      vert[3].a         = 1.0f;

      /* Align texels and vertices. 
       *
       * Fixes infamous 'half-texel offset' issue of D3D9
       *	http://msdn.microsoft.com/en-us/library/bb219690%28VS.85%29.aspx.
       */
      for (i = 0; i < 4; i++)
      {
         vert[i].x     -= 0.5f;
         vert[i].y     += 0.5f;
      }

      verts             = d3d_vertex_buffer_lock(pass->vertex_buf);
      memcpy(verts, vert, sizeof(vert));
      d3d_vertex_buffer_unlock(pass->vertex_buf);
   }

   renderchain_set_mvp(chain, pass->vPrg, vp_width, vp_height, rotation);
   renderchain_set_shader_params(chain, pass,
         width, height,
         info->tex_w, info->tex_h,
         vp_width, vp_height);
}
Exemplo n.º 9
0
static void renderchain_set_vertices(void *data, unsigned pass,
      unsigned vert_width, unsigned vert_height, uint64_t frame_count)
{
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL)
#ifdef _XBOX
   video_shader_ctx_params_t params;
   video_shader_ctx_info_t shader_info;
#endif
#endif
   unsigned width, height;
   d3d_video_t *d3d         = (d3d_video_t*)data;
   xdk_renderchain_t *chain = d3d ? (xdk_renderchain_t*)d3d->renderchain_data : NULL;

   video_driver_get_size(&width, &height);

   if (!chain)
      return;

   if (chain->last_width != vert_width || chain->last_height != vert_height)
   {
      unsigned i;
      Vertex vert[4];
      void *verts      = NULL;

      chain->last_width  = vert_width;
      chain->last_height = vert_height;

      float tex_w        = vert_width;
      float tex_h        = vert_height;
#ifdef _XBOX360
      tex_w             /= ((float)chain->tex_w);
      tex_h             /= ((float)chain->tex_h);
#endif

      vert[0].x        = -1.0f;
      vert[1].x        =  1.0f;
      vert[2].x        = -1.0f;
      vert[3].x        =  1.0f;

      vert[0].y        = -1.0f;
      vert[1].y        = -1.0f;
      vert[2].y        =  1.0f;
      vert[3].y        =  1.0f;
#if defined(_XBOX1)
      vert[0].z        =  1.0f;
      vert[1].z        =  1.0f;
      vert[2].z        =  1.0f;
      vert[3].z        =  1.0f;

      vert[0].rhw      = 0.0f;
      vert[1].rhw      = tex_w;
      vert[2].rhw      = 0.0f;
      vert[3].rhw      = tex_w;

      vert[0].u        = tex_h;
      vert[1].u        = tex_h;
      vert[2].u        = 0.0f;
      vert[3].u        = 0.0f;

      vert[0].v        = 0.0f;
      vert[1].v        = 0.0f;
      vert[2].v        = 0.0f;
      vert[3].v        = 0.0f;
#elif defined(_XBOX360)
      vert[0].u        = 0.0f;
      vert[1].u        = tex_w;
      vert[2].u        = 0.0f;
      vert[3].u        = tex_w;

      vert[0].v        = tex_h;
      vert[1].v        = tex_h;
      vert[2].v        = 0.0f;
      vert[3].v        = 0.0f;
#endif

      /* Align texels and vertices. */
      for (i = 0; i < 4; i++)
      {
         vert[i].x    -= 0.5f / ((float)chain->tex_w);
         vert[i].y    += 0.5f / ((float)chain->tex_h);
      }

      verts = d3d_vertex_buffer_lock(chain->vertex_buf);
      memcpy(verts, vert, sizeof(vert));
      d3d_vertex_buffer_unlock(chain->vertex_buf);
   }

#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL)
#ifdef _XBOX
   renderchain_set_mvp(d3d, width, height, d3d->dev_rotation);

   shader_info.data = d3d;
   shader_info.idx  = pass;
   shader_info.set_active = true;

   video_shader_driver_use(shader_info);

   params.data          = d3d;
   params.width         = vert_width;
   params.height        = vert_height;
   params.tex_width     = chain->tex_w;
   params.tex_height    = chain->tex_h;
   params.out_width     = width;
   params.out_height    = height;
   params.frame_counter = (unsigned int)frame_count;
   params.info          = NULL;
   params.prev_info     = NULL;
   params.feedback_info = NULL;
   params.fbo_info      = NULL;
   params.fbo_info_cnt  = 0;

   video_shader_driver_set_parameters(params);
#endif
#endif
}