mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-09 22:56:06 +00:00
Use toggle to turn off vsync on D3D12
Parameter syncInterval of function Preset specifies how to synchronize presentation of a frame. To turn off vsync in D3D12 backend, set syncInterval to 0 which represents the presentation occurs immediately. BUG=dawn:237 Change-Id: Ic17f00bae5af9fd6bca4130d6e2282f3c34de4e6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12303 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Yizhou Jiang <yizhou.jiang@intel.com>
This commit is contained in:
parent
b2b2ef57a5
commit
4794168ef8
@ -39,7 +39,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
NativeSwapChainImpl::NativeSwapChainImpl(Device* device, HWND window)
|
NativeSwapChainImpl::NativeSwapChainImpl(Device* device, HWND window)
|
||||||
: mWindow(window), mDevice(device) {
|
: mWindow(window), mDevice(device), mInterval(1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeSwapChainImpl::~NativeSwapChainImpl() {
|
NativeSwapChainImpl::~NativeSwapChainImpl() {
|
||||||
@ -59,6 +59,8 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
ComPtr<IDXGIFactory4> factory = mDevice->GetFactory();
|
ComPtr<IDXGIFactory4> factory = mDevice->GetFactory();
|
||||||
ComPtr<ID3D12CommandQueue> queue = mDevice->GetCommandQueue();
|
ComPtr<ID3D12CommandQueue> queue = mDevice->GetCommandQueue();
|
||||||
|
|
||||||
|
mInterval = mDevice->IsToggleEnabled(Toggle::TurnOffVsync) == true ? 0 : 1;
|
||||||
|
|
||||||
// Create the D3D12 swapchain, assuming only two buffers for now
|
// Create the D3D12 swapchain, assuming only two buffers for now
|
||||||
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
|
DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
|
||||||
swapChainDesc.Width = width;
|
swapChainDesc.Width = width;
|
||||||
@ -103,7 +105,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
DawnSwapChainError NativeSwapChainImpl::Present() {
|
DawnSwapChainError NativeSwapChainImpl::Present() {
|
||||||
// This assumes the texture has already been transition to the PRESENT state.
|
// This assumes the texture has already been transition to the PRESENT state.
|
||||||
|
|
||||||
ASSERT_SUCCESS(mSwapChain->Present(1, 0));
|
ASSERT_SUCCESS(mSwapChain->Present(mInterval, 0));
|
||||||
// TODO(cwallez@chromium.org): Make the serial ticking implicit.
|
// TODO(cwallez@chromium.org): Make the serial ticking implicit.
|
||||||
ASSERT(mDevice->NextSerial().IsSuccess());
|
ASSERT(mDevice->NextSerial().IsSuccess());
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
private:
|
private:
|
||||||
HWND mWindow = nullptr;
|
HWND mWindow = nullptr;
|
||||||
Device* mDevice = nullptr;
|
Device* mDevice = nullptr;
|
||||||
|
UINT mInterval;
|
||||||
|
|
||||||
ComPtr<IDXGISwapChain3> mSwapChain = nullptr;
|
ComPtr<IDXGISwapChain3> mSwapChain = nullptr;
|
||||||
std::vector<ComPtr<ID3D12Resource>> mBuffers;
|
std::vector<ComPtr<ID3D12Resource>> mBuffers;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user