2 // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 // Fence11.cpp: Defines the rx::Fence11 class which implements rx::FenceImpl.
9 #include "libGLESv2/renderer/d3d/d3d11/Fence11.h"
10 #include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
11 #include "libGLESv2/main.h"
16 Fence11::Fence11(rx::Renderer11 *renderer)
27 bool Fence11::isSet() const
29 return mQuery != NULL;
36 D3D11_QUERY_DESC queryDesc;
37 queryDesc.Query = D3D11_QUERY_EVENT;
38 queryDesc.MiscFlags = 0;
40 if (FAILED(mRenderer->getDevice()->CreateQuery(&queryDesc, &mQuery)))
42 return gl::error(GL_OUT_OF_MEMORY);
46 mRenderer->getDeviceContext()->End(mQuery);
49 bool Fence11::test(bool flushCommandBuffer)
53 UINT getDataFlags = (flushCommandBuffer ? 0 : D3D11_ASYNC_GETDATA_DONOTFLUSH);
54 HRESULT result = mRenderer->getDeviceContext()->GetData(mQuery, NULL, 0, getDataFlags);
56 if (mRenderer->isDeviceLost())
58 return gl::error(GL_OUT_OF_MEMORY, true);
61 ASSERT(result == S_OK || result == S_FALSE);
62 return (result == S_OK);
65 bool Fence11::hasError() const
67 return mRenderer->isDeviceLost();