Jump to content
  • Advertisement
vivek.soni

DX12 Direct2D, Directx11on12 example VSYNC ISSUE...

Recommended Posts

Hi guys...

i am following microsofts directx11on12 example to create a direct2d component and draw a circle and text...

so far i am able to draw circle and text ... but my FPS is now capped at 60 fps.... earlier it was 400 fps... 

so how to disable vsync in Direct2d ...

 

i cant even set rendertarget present flags to D2D1_PRESENT_OPTIONS_IMMEDIATELY  as i am creating a rendertarget like this...

// Query the desktop's dpi settings, which will be used to create
// D2D's render targets.
float dpiX;
float dpiY;
m_d2dFactory->GetDesktopDpi(&dpiX, &dpiY);
D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1(
  D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW,
  D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
  dpiX,
  dpiY
);
 for (int i = 0; i < MAX_BUFFERED_FRAMES; i++)
{
  // Create a wrapped 11On12 resource of this back buffer. Since we are
  // rendering all D3D12 content first and then all D2D content, we specify
  // the In resource state as RENDER_TARGET - because D3D12 will have last
  // used it in this state - and the Out resource state as PRESENT. When
  // ReleaseWrappedResources() is called on the 11On12 device, the resource
  // will be transitioned to the PRESENT state.
  D3D11_RESOURCE_FLAGS d3d11Flags = { D3D11_BIND_RENDER_TARGET };
  hr = m_device11on12->CreateWrappedResource(
   backBufferRenderTarget,
   &d3d11Flags,
   D3D12_RESOURCE_STATE_RENDER_TARGET,
   D3D12_RESOURCE_STATE_PRESENT,
   IID_PPV_ARGS(&m_wrappedBackBuffers)
  );
  if (FAILED(hr))
  {
   return false;
  }
// Create a render target for D2D to draw directly to this back buffer.
  IDXGISurface* surface;
  hr = m_wrappedBackBuffers->QueryInterface(&surface);
  if (FAILED(hr))
  {
   return false;
  }
hr = m_d2dDeviceContext->CreateBitmapFromDxgiSurface(
   surface,
   &bitmapProperties,
   &m_d2dRenderTargets
  );
  if (FAILED(hr))
  {
   return false;
  }
}

https://github.com/microsoft/DirectX-Graphics-Samples/tree/master/Samples/UWP/D3D1211On12

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!