コード例 #1
0
ファイル: xdk360_fonts.cpp プロジェクト: Wyrick/RetroArch
void d3d9_render_msg_post(xdk360_video_font_t * font)
{
   if( --font->m_dwNestedBeginCount > 0 )
      return;

   // Restore state
   if( font->m_bSaveState )
   {
      // Cache the global pointer into a register
      xdk_d3d_video_t *vid = (xdk_d3d_video_t*)driver.video_data;
      D3DDevice *pD3dDevice = vid->d3d_render_device;

      D3DDevice_SetTexture_Inline(pD3dDevice, 0, NULL);
      D3DDevice_SetVertexDeclaration(pD3dDevice, NULL);
      D3DDevice_SetVertexShader(pD3dDevice, NULL );
      D3DDevice_SetPixelShader(pD3dDevice, NULL );
      D3DDevice_SetRenderState_AlphaBlendEnable(pD3dDevice, font->m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHABLENDENABLE ]);
      D3DDevice_SetRenderState_SrcBlend(pD3dDevice, font->m_dwSavedState[ SAVEDSTATE_D3DRS_SRCBLEND ] );
      D3DDevice_SetRenderState_DestBlend( pD3dDevice, font->m_dwSavedState[ SAVEDSTATE_D3DRS_DESTBLEND ] );
      D3DDevice_SetRenderState_BlendOp( pD3dDevice, font->m_dwSavedState[ SAVEDSTATE_D3DRS_BLENDOP ] );
      pD3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, font->m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHATESTENABLE ] );
      pD3dDevice->SetRenderState( D3DRS_ALPHAREF, font->m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHAREF ] );
      pD3dDevice->SetRenderState( D3DRS_ALPHAFUNC, font->m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHAFUNC ] );
      pD3dDevice->SetRenderState( D3DRS_FILLMODE, font->m_dwSavedState[ SAVEDSTATE_D3DRS_FILLMODE ] );
      pD3dDevice->SetRenderState( D3DRS_CULLMODE, font->m_dwSavedState[ SAVEDSTATE_D3DRS_CULLMODE ] );
      pD3dDevice->SetRenderState( D3DRS_VIEWPORTENABLE, font->m_dwSavedState[ SAVEDSTATE_D3DRS_VIEWPORTENABLE ] );
      D3DDevice_SetSamplerState_MinFilter(pD3dDevice, 0, font->m_dwSavedState[ SAVEDSTATE_D3DSAMP_MINFILTER ] );
      D3DDevice_SetSamplerState_MagFilter(pD3dDevice, 0, font->m_dwSavedState[ SAVEDSTATE_D3DSAMP_MAGFILTER ] );
      D3DDevice_SetSamplerState_AddressU_Inline(pD3dDevice, 0, font->m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSU ] );
      D3DDevice_SetSamplerState_AddressV_Inline(pD3dDevice, 0, font->m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSV ] );
   }
}
コード例 #2
0
ファイル: shader_hlsl.c プロジェクト: AbelFlos/RetroArch
static void hlsl_use(unsigned index)
{
   if (hlsl_active && prg[index].vprg && prg[index].fprg)
   {
      active_index = index;
#ifdef _XBOX
      D3DDevice_SetVertexShader(d3d_device_ptr, prg[index].vprg);
      D3DDevice_SetPixelShader(d3d_device_ptr, prg[index].fprg);
#else
      d3d_device_ptr->SetVertexShader(prg[index].vprg);
      d3d_device_ptr->SetPixelShader(prg[index].fprg);
#endif
   }
}
コード例 #3
0
ファイル: shader_hlsl.c プロジェクト: ChowZenki/RetroArch
static void hlsl_use(void *data, unsigned index)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
   if (hlsl_active && prg[index].vprg && prg[index].fprg)
   {
      active_index = index;
#ifdef _XBOX
      D3DDevice_SetVertexShader(d3dr, prg[index].vprg);
      D3DDevice_SetPixelShader(d3dr, prg[index].fprg);
#else
      d3dr->SetVertexShader(prg[index].vprg);
      d3dr->SetPixelShader(prg[index].fprg);
#endif
   }
}
コード例 #4
0
static void hlsl_use(void *data, unsigned idx)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
   driver_t *driver = driver_get_ptr();
   hlsl_shader_data_t *hlsl = (hlsl_shader_data_t*)driver->video_shader_data;

   if (hlsl && hlsl->prg[idx].vprg && hlsl->prg[idx].fprg)
   {
      hlsl->active_idx = idx;
      d3d_set_vertex_shader(d3dr, idx, hlsl->prg[idx].vprg);
#ifdef _XBOX
      D3DDevice_SetPixelShader(d3dr, hlsl->prg[idx].fprg);
#else
      d3dr->SetPixelShader(hlsl->prg[idx].fprg);
#endif
   }
}
コード例 #5
0
ファイル: AtgDevice.cpp プロジェクト: oukiar/vdash
//--------------------------------------------------------------------------------------
// Name: SetPixelShader()
// Desc: Overloaded function to avoid redundant calls to D3D
//--------------------------------------------------------------------------------------
D3DVOID WINAPI D3DDevice::SetPixelShader( D3DPixelShader* pShader )
{
    static D3DPixelShader* g_pShader = NULL;
    // Synchronize with current D3D device state, to catch subsystems that do not go
    // through this codepath
    D3DPixelShader* pCurrentPS = NULL;
    D3DDevice_GetPixelShader( this, &pCurrentPS );
    g_pShader = pCurrentPS;
    if( pCurrentPS != NULL )
        pCurrentPS->Release();
    // Only update shader if it has changed
    if( g_pShader != pShader )
    {
        D3DDevice_SetPixelShader( this, pShader );
        g_pShader = pShader;
    }
    D3DVOIDRETURN;
}
コード例 #6
0
ファイル: shader_hlsl.c プロジェクト: arakerlu/RetroArch
static void hlsl_use(void *data, void *shader_data, unsigned idx, bool set_active)
{
   d3d_video_t *d3d = (d3d_video_t*)data;
   hlsl_shader_data_t *hlsl_data = (hlsl_shader_data_t*)shader_data;
   LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;

   if (hlsl_data && hlsl_data->prg[idx].vprg && hlsl_data->prg[idx].fprg)
   {
      if (set_active)
         hlsl_data->active_idx = idx;

      d3d_set_vertex_shader(d3dr, idx, hlsl_data->prg[idx].vprg);
#ifdef _XBOX
      D3DDevice_SetPixelShader(d3dr, hlsl_data->prg[idx].fprg);
#else
      d3dr->SetPixelShader(hlsl_data->prg[idx].fprg);
#endif
   }
}
コード例 #7
0
ファイル: xdk360_fonts.cpp プロジェクト: Wyrick/RetroArch
void d3d9_render_msg_pre(xdk360_video_font_t * font)
{
   // Set state on the first call
   if( font->m_dwNestedBeginCount == 0 )
   {
      // Cache the global pointer into a register
      xdk_d3d_video_t *vid = (xdk_d3d_video_t*)driver.video_data;
      D3DDevice *pD3dDevice = vid->d3d_render_device;

      // Save state
      if( font->m_bSaveState )
      {
         pD3dDevice->GetRenderState( D3DRS_ALPHABLENDENABLE, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHABLENDENABLE ] );
         pD3dDevice->GetRenderState( D3DRS_SRCBLEND, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_SRCBLEND ] );
		 pD3dDevice->GetRenderState( D3DRS_DESTBLEND, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_DESTBLEND ] );
		 pD3dDevice->GetRenderState( D3DRS_BLENDOP, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_BLENDOP ] );
		 pD3dDevice->GetRenderState( D3DRS_ALPHATESTENABLE, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHATESTENABLE ] );
		 pD3dDevice->GetRenderState( D3DRS_ALPHAREF, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHAREF ] );
		 pD3dDevice->GetRenderState( D3DRS_ALPHAFUNC, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_ALPHAFUNC ] );
		 pD3dDevice->GetRenderState( D3DRS_FILLMODE, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_FILLMODE ] );
		 pD3dDevice->GetRenderState( D3DRS_CULLMODE, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_CULLMODE ] );
		 pD3dDevice->GetRenderState( D3DRS_VIEWPORTENABLE, &font->m_dwSavedState[ SAVEDSTATE_D3DRS_VIEWPORTENABLE ] );
		 font->m_dwSavedState[ SAVEDSTATE_D3DSAMP_MINFILTER ] = D3DDevice_GetSamplerState_MinFilter( pD3dDevice, 0 );
		 font->m_dwSavedState[ SAVEDSTATE_D3DSAMP_MAGFILTER ] = D3DDevice_GetSamplerState_MagFilter( pD3dDevice, 0 );
		 font->m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSU ] = D3DDevice_GetSamplerState_AddressU( pD3dDevice, 0);
		 font->m_dwSavedState[ SAVEDSTATE_D3DSAMP_ADDRESSV ]  = D3DDevice_GetSamplerState_AddressV( pD3dDevice, 0);
      }

      // Set the texture scaling factor as a vertex shader constant
      D3DSURFACE_DESC TextureDesc;
      D3DTexture_GetLevelDesc(font->m_pFontTexture, 0, &TextureDesc); // Get the description

      // Set render state
      D3DDevice_SetTexture_Inline(pD3dDevice, 0, font->m_pFontTexture);

      // Read the TextureDesc here to ensure no load/hit/store from GetLevelDesc()
      float vTexScale[4];
      vTexScale[0] = 1.0f / TextureDesc.Width;		// LHS due to int->float conversion
      vTexScale[1] = 1.0f / TextureDesc.Height;
      vTexScale[2] = 0.0f;
      vTexScale[3] = 0.0f;

      D3DDevice_SetRenderState_AlphaBlendEnable( pD3dDevice, TRUE );
      D3DDevice_SetRenderState_SrcBlend(pD3dDevice, D3DBLEND_SRCALPHA );
      D3DDevice_SetRenderState_DestBlend( pD3dDevice, D3DBLEND_INVSRCALPHA );
      D3DDevice_SetRenderState_BlendOp( pD3dDevice, D3DBLENDOP_ADD );
      pD3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
      pD3dDevice->SetRenderState( D3DRS_ALPHAREF, 0x08 );
      pD3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL );
      pD3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
      pD3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
      pD3dDevice->SetRenderState( D3DRS_VIEWPORTENABLE, FALSE );
      D3DDevice_SetSamplerState_MinFilter(pD3dDevice, 0, D3DTEXF_LINEAR );
      D3DDevice_SetSamplerState_MagFilter(pD3dDevice, 0, D3DTEXF_LINEAR );
      D3DDevice_SetSamplerState_AddressU_Inline(pD3dDevice, 0, D3DTADDRESS_CLAMP );
      D3DDevice_SetSamplerState_AddressV_Inline(pD3dDevice, 0, D3DTADDRESS_CLAMP );

      D3DDevice_SetVertexDeclaration(pD3dDevice, s_FontLocals.m_pFontVertexDecl );
      D3DDevice_SetVertexShader(pD3dDevice, s_FontLocals.m_pFontVertexShader );
      D3DDevice_SetPixelShader(pD3dDevice, s_FontLocals.m_pFontPixelShader );

      // Set the texture scaling factor as a vertex shader constant
      // Call here to avoid load hit store from writing to vTexScale above
      pD3dDevice->SetVertexShaderConstantF( 2, vTexScale, 1 );
   }

   // Keep track of the nested begin/end calls.
   font->m_dwNestedBeginCount++;
}