Hash :
c4d18aac
Author :
Date :
2017-03-09T18:45:02
Use ErrorStream everywhere Eliminates one more usage of FormatString and its static initializer. Add more ErrorStream types and replace gl::Error and egl::Error with them. BUG=angleproject:1644 Change-Id: Ib498d0ae4b81a332ec71aed7cf709993b154e6bb Reviewed-on: https://chromium-review.googlesource.com/505429 Commit-Queue: Yuly Novikov <ynovikov@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
//
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Fence9.cpp: Defines the rx::FenceNV9 class.
#include "libANGLE/renderer/d3d/d3d9/Fence9.h"
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
namespace rx
{
FenceNV9::FenceNV9(Renderer9 *renderer) : FenceNVImpl(), mRenderer(renderer), mQuery(nullptr)
{
}
FenceNV9::~FenceNV9()
{
SafeRelease(mQuery);
}
gl::Error FenceNV9::set(GLenum condition)
{
if (!mQuery)
{
gl::Error error = mRenderer->allocateEventQuery(&mQuery);
if (error.isError())
{
return error;
}
}
HRESULT result = mQuery->Issue(D3DISSUE_END);
if (FAILED(result))
{
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
SafeRelease(mQuery);
return gl::OutOfMemory() << "Failed to end event query, " << gl::FmtHR(result);
}
return gl::NoError();
}
gl::Error FenceNV9::test(GLboolean *outFinished)
{
return testHelper(true, outFinished);
}
gl::Error FenceNV9::finish()
{
GLboolean finished = GL_FALSE;
while (finished != GL_TRUE)
{
gl::Error error = testHelper(true, &finished);
if (error.isError())
{
return error;
}
Sleep(0);
}
return gl::NoError();
}
gl::Error FenceNV9::testHelper(bool flushCommandBuffer, GLboolean *outFinished)
{
ASSERT(mQuery);
DWORD getDataFlags = (flushCommandBuffer ? D3DGETDATA_FLUSH : 0);
HRESULT result = mQuery->GetData(nullptr, 0, getDataFlags);
if (d3d9::isDeviceLostError(result))
{
mRenderer->notifyDeviceLost();
return gl::OutOfMemory() << "Device was lost while querying result of an event query.";
}
else if (FAILED(result))
{
return gl::OutOfMemory() << "Failed to get query data, " << gl::FmtHR(result);
}
ASSERT(result == S_OK || result == S_FALSE);
*outFinished = ((result == S_OK) ? GL_TRUE : GL_FALSE);
return gl::NoError();
}
}