示例#1
0
void CGLImpl::Init()
{
	use_aa = 1;// not working

	// The device-creation presentation params with reasonable defaults
	D3DPRESENT_PARAMETERS d3dpp =
	{
		1280,                // BackBufferWidth;
		720,                // BackBufferHeight;
		D3DFMT_A8R8G8B8,    // BackBufferFormat;
		1,                  // BackBufferCount;
		D3DMULTISAMPLE_NONE,// MultiSampleType;
		0,                  // MultiSampleQuality;
		D3DSWAPEFFECT_DISCARD, // SwapEffect;
		NULL,               // hDeviceWindow;
		FALSE,              // Windowed;
		TRUE,               // EnableAutoDepthStencil;
		D3DFMT_D24S8,       // AutoDepthStencilFormat;
		0,                  // Flags;
		0,                  // FullScreen_RefreshRateInHz;
		D3DPRESENT_INTERVAL_IMMEDIATE, // FullScreen_PresentationInterval;
	};

	if (use_aa) {
		//d3dpp.BackBufferFormat = ( D3DFORMAT )MAKESRGBFMT( D3DFMT_A8R8G8B8 );
		d3dpp.BackBufferCount = 0;
		d3dpp.EnableAutoDepthStencil = FALSE;
		d3dpp.DisableAutoBackBuffer = TRUE;
		d3dpp.DisableAutoFrontBuffer = TRUE;
		d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
	}

	XDKGlGetScreenSize((int*)&d3dpp.BackBufferWidth, (int*)&d3dpp.BackBufferHeight);

	HRESULT hr;
	// Create Direct3D
    LPDIRECT3D9 pD3D = Direct3DCreate9( D3D_SDK_VERSION );

    // Create the D3D device
    if( FAILED( hr = pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, NULL,
                                         NULL,
										 &d3dpp, &device ) ) )
    {
        printf( "Could not create D3D device!\n" );
        DebugBreak();
    }

    pD3D->Release();

	// init aa surface
	if (use_aa) {
		D3DSURFACE_PARAMETERS params = {0};
		int tile_w = 1280/4;
		int tile_h = 720;

		// render target
		params.Base = 0;
		device->CreateRenderTarget( tile_w, tile_h, D3DFMT_X8R8G8B8, D3DMULTISAMPLE_4_SAMPLES, 0, 0, &pRenderTarget, &params );

		// stencil+depth surface
		params.Base = pRenderTarget->Size / GPU_EDRAM_TILE_SIZE;
		params.HierarchicalZBase = D3DHIZFUNC_GREATER_EQUAL;
		device->CreateDepthStencilSurface( tile_w, tile_h, D3DFMT_D24S8, D3DMULTISAMPLE_4_SAMPLES, 0, 0, &pDepthStencilTarget, &params );

		device->CreateTexture( 1280, 720, 1, 0,
			( D3DFORMAT )MAKESRGBFMT( D3DFMT_LE_X8R8G8B8 ),
			D3DPOOL_DEFAULT,
			&pFrontBuffer,
			NULL );

		device->CreateTexture( 1280, 720, 1, 0,
			( D3DFORMAT )MAKESRGBFMT( D3DFMT_X8R8G8B8 ),
			D3DPOOL_DEFAULT,
			&pResolveBuffer,
			NULL );
	}

	// init stuff
	InitTextures();
	InitializeMatrices();
	InitStates();

	
	state.render_height = d3dpp.BackBufferHeight;
	state.render_width = d3dpp.BackBufferWidth;

#if USE_VB
	// create vb and stuff
	device->CreateVertexBuffer( 
		1024*1024*8,// 8 Mo
		0, 
		NULL,
		NULL, 
		&pVbGL, 
		NULL 
	);

	device->CreateIndexBuffer(
		1024*1024*8,// 8 Mo
		0,
		D3DFMT_INDEX32,
		NULL,
		&pIbGL,
		NULL);

	// refresh ib/vb cache
	GLImpl.pVbGL->Lock(0, 8*1024*1024, (void**)&GLImpl.prim.vertices.data, 0);
	//GLImpl.pVbGL->Unlock();
	GLImpl.pIbGL->Lock(0, 8*1024*1024, (void**)&GLImpl.prim.indices.data, 0);
	//GLImpl.pIbGL->Unlock();
#endif

	if (use_aa) {
		device->SetRenderTarget( 0, pRenderTarget );
		device->SetDepthStencilSurface( pDepthStencilTarget );
	}

	//device->SynchronizeToPresentationInterval();
	if (use_aa == 0) {
		device->GetFrontBuffer(&pFrontBuffer);
	}
}
示例#2
0
void d3d_make_d3dpp(void *data,
      const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp)
{
   d3d_video_t     *d3d = (d3d_video_t*)data;
   settings_t *settings = config_get_ptr();
   global_t *global     = global_get_ptr();

   memset(d3dpp, 0, sizeof(*d3dpp));

   d3dpp->Windowed             = false;
#ifndef _XBOX
   d3dpp->Windowed             = settings->video.windowed_fullscreen || !info->fullscreen;
#endif
   d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

   if (info->vsync)
   {
      switch (settings->video.swap_interval)
      {
         default:
         case 1:
            d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
            break;
         case 2:
            d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO;
            break;
         case 3:
            d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE;
            break;
         case 4:
            d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR;
            break;
      }
   }

   d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD;
   d3dpp->BackBufferCount = 2;
#ifdef _XBOX
   d3dpp->BackBufferFormat = 
#ifdef _XBOX360
      global->console.screen.gamma_correction ? 
      (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) :
#endif
      info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5;
#else
   d3dpp->hDeviceWindow    = d3d->hWnd;
   d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN;
#endif

   if (!d3dpp->Windowed)
   {
#ifdef _XBOX
      unsigned width          = 0;
      unsigned height         = 0;

      if (d3d->ctx_driver && d3d->ctx_driver->get_video_size)
         d3d->ctx_driver->get_video_size(d3d, &width, &height);

      d3d->screen_width       = width;
      d3d->screen_height      = height;
#endif
      d3dpp->BackBufferWidth  = d3d->screen_width;
      d3dpp->BackBufferHeight = d3d->screen_height;
   }

#ifdef _XBOX
   d3dpp->MultiSampleType         = D3DMULTISAMPLE_NONE;
   d3dpp->EnableAutoDepthStencil  = FALSE;
#if defined(_XBOX1)
   /* Get the "video mode" */
   DWORD video_mode               = XGetVideoFlags();

   /* Check if we are able to use progressive mode. */
   if (video_mode & XC_VIDEO_FLAGS_HDTV_480p)
      d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
   else
      d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;

   /* Only valid in PAL mode, not valid for HDTV modes. */
   if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
   {
      if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
         d3dpp->FullScreen_RefreshRateInHz = 60;
      else
         d3dpp->FullScreen_RefreshRateInHz = 50;
   }

   if (XGetAVPack() == XC_AV_PACK_HDTV)
   {
      if (video_mode & XC_VIDEO_FLAGS_HDTV_480p)
         d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
      else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p)
         d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
      else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i)
         d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;
   }

   if (widescreen_mode)
      d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN;
#elif defined(_XBOX360)
   if (!widescreen_mode)
      d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX;

   if (global->console.screen.gamma_correction)
      d3dpp->FrontBufferFormat       = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8);
   else
      d3dpp->FrontBufferFormat       = D3DFMT_LE_X8R8G8B8;
   d3dpp->MultiSampleQuality      = 0;
#endif
#endif
}
示例#3
0
void xdk_d3d_generate_pp(D3DPRESENT_PARAMETERS *d3dpp, const video_info_t *video)
{
   xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
   uint64_t lifecycle_mode_state = g_extern.lifecycle_mode_state;

   memset(d3dpp, 0, sizeof(*d3dpp));

   d3d->texture_fmt = video->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5;
   d3d->base_size   = video->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);

   unsigned width, height;
   d3d->ctx_driver->get_video_size(&width, &height);

   d3dpp->BackBufferWidth  = d3d->win_width = width;
   d3dpp->BackBufferHeight = d3d->win_height = height;

#if defined(_XBOX1)
   // Get the "video mode"
   DWORD video_mode = XGetVideoFlags();

   // Check if we are able to use progressive mode
   if (video_mode & XC_VIDEO_FLAGS_HDTV_480p)
      d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
   else
      d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;

   // Only valid in PAL mode, not valid for HDTV modes!
   if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
   {
      if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
         d3dpp->FullScreen_RefreshRateInHz = 60;
      else
         d3dpp->FullScreen_RefreshRateInHz = 50;
   }

   if (XGetAVPack() == XC_AV_PACK_HDTV)
   {
      if (video_mode & XC_VIDEO_FLAGS_HDTV_480p)
         d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
      else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p)
         d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
      else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i)
         d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;
   }

   if (lifecycle_mode_state & MODE_MENU_WIDESCREEN)
      d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN;

   d3dpp->BackBufferFormat                     = D3DFMT_X8R8G8B8;
   d3dpp->FullScreen_PresentationInterval	   = d3d->vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
   d3dpp->SwapEffect                           = D3DSWAPEFFECT_COPY;
#elif defined(_XBOX360)
   if (!(lifecycle_mode_state & (1ULL << MODE_MENU_WIDESCREEN)))
      d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX;

   if (g_extern.console.screen.gamma_correction)
   {
      d3dpp->BackBufferFormat        = (D3DFORMAT)MAKESRGBFMT(d3d->texture_fmt);
      d3dpp->FrontBufferFormat       = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8);
   }
   else
   {
      d3dpp->BackBufferFormat        = d3d->texture_fmt;
      d3dpp->FrontBufferFormat       = D3DFMT_LE_X8R8G8B8;
   }
   d3dpp->MultiSampleQuality      = 0;
   d3dpp->PresentationInterval    = d3d->vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
   d3dpp->SwapEffect              = D3DSWAPEFFECT_DISCARD;
#endif
   d3dpp->BackBufferCount         = 2;
   d3dpp->MultiSampleType         = D3DMULTISAMPLE_NONE;
   d3dpp->EnableAutoDepthStencil  = FALSE;
}