1 #include "precompiled.h" 2 // 3 // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style license that can be 5 // found in the LICENSE file. 6 // 7 8 // Fence11.cpp: Defines the rx::Fence11 class which implements rx::FenceImpl. 9 10 #include "libGLESv2/renderer/d3d11/Fence11.h" 11 #include "libGLESv2/main.h" 12 #include "libGLESv2/renderer/d3d11/Renderer11.h" 13 14 namespace rx 15 { 16 17 Fence11::Fence11(rx::Renderer11 *renderer) 18 { 19 mRenderer = renderer; 20 mQuery = NULL; 21 } 22 23 Fence11::~Fence11() 24 { 25 SafeRelease(mQuery); 26 } 27 28 bool Fence11::isSet() const 29 { 30 return mQuery != NULL; 31 } 32 33 void Fence11::set() 34 { 35 if (!mQuery) 36 { 37 D3D11_QUERY_DESC queryDesc; 38 queryDesc.Query = D3D11_QUERY_EVENT; 39 queryDesc.MiscFlags = 0; 40 41 if (FAILED(mRenderer->getDevice()->CreateQuery(&queryDesc, &mQuery))) 42 { 43 return gl::error(GL_OUT_OF_MEMORY); 44 } 45 } 46 47 mRenderer->getDeviceContext()->End(mQuery); 48 } 49 50 bool Fence11::test(bool flushCommandBuffer) 51 { 52 ASSERT(mQuery); 53 54 UINT getDataFlags = (flushCommandBuffer ? 0 : D3D11_ASYNC_GETDATA_DONOTFLUSH); 55 HRESULT result = mRenderer->getDeviceContext()->GetData(mQuery, NULL, 0, getDataFlags); 56 57 if (mRenderer->isDeviceLost()) 58 { 59 return gl::error(GL_OUT_OF_MEMORY, true); 60 } 61 62 ASSERT(result == S_OK || result == S_FALSE); 63 return (result == S_OK); 64 } 65 66 bool Fence11::hasError() const 67 { 68 return mRenderer->isDeviceLost(); 69 } 70 71 } 72