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 // Fence9.cpp: Defines the rx::Fence9 class. 9 10 #include "libGLESv2/renderer/d3d9/Fence9.h" 11 #include "libGLESv2/main.h" 12 #include "libGLESv2/renderer/d3d9/renderer9_utils.h" 13 #include "libGLESv2/renderer/d3d9/Renderer9.h" 14 15 namespace rx 16 { 17 18 Fence9::Fence9(rx::Renderer9 *renderer) 19 { 20 mRenderer = renderer; 21 mQuery = NULL; 22 } 23 24 Fence9::~Fence9() 25 { 26 SafeRelease(mQuery); 27 } 28 29 bool Fence9::isSet() const 30 { 31 return mQuery != NULL; 32 } 33 34 void Fence9::set() 35 { 36 if (!mQuery) 37 { 38 mQuery = mRenderer->allocateEventQuery(); 39 if (!mQuery) 40 { 41 return gl::error(GL_OUT_OF_MEMORY); 42 } 43 } 44 45 HRESULT result = mQuery->Issue(D3DISSUE_END); 46 UNUSED_ASSERTION_VARIABLE(result); 47 ASSERT(SUCCEEDED(result)); 48 } 49 50 bool Fence9::test(bool flushCommandBuffer) 51 { 52 ASSERT(mQuery); 53 54 DWORD getDataFlags = (flushCommandBuffer ? D3DGETDATA_FLUSH : 0); 55 HRESULT result = mQuery->GetData(NULL, 0, getDataFlags); 56 57 if (d3d9::isDeviceLostError(result)) 58 { 59 mRenderer->notifyDeviceLost(); 60 return gl::error(GL_OUT_OF_MEMORY, true); 61 } 62 63 ASSERT(result == S_OK || result == S_FALSE); 64 65 return (result == S_OK); 66 } 67 68 bool Fence9::hasError() const 69 { 70 return mRenderer->isDeviceLost(); 71 } 72 73 } 74