Hash :
27290c1b
Author :
Date :
2012-11-28T20:57:47
Use convenience function for downcasting the renderer. TRAC #22016 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1497 736b8ea6-26fd-11df-bfd4-992fa37f6226
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
//
// Copyright (c) 2002-2010 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.
//
// Fence.cpp: Implements the gl::Fence class, which supports the GL_NV_fence extension.
#include "libGLESv2/Fence.h"
#include "libGLESv2/renderer/renderer9_utils.h"
namespace gl
{
Fence::Fence(rx::Renderer *renderer)
{
mRenderer = rx::Renderer9::makeRenderer9(renderer); // D3D9_REPLACE
mQuery = NULL;
mCondition = GL_NONE;
mStatus = GL_FALSE;
}
Fence::~Fence()
{
if (mQuery != NULL)
{
mRenderer->freeEventQuery(mQuery);
}
}
GLboolean Fence::isFence()
{
// GL_NV_fence spec:
// A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence.
return mQuery != NULL;
}
// D3D9_REPLACE
void Fence::setFence(GLenum condition)
{
if (!mQuery)
{
mQuery = mRenderer->allocateEventQuery();
if (!mQuery)
{
return error(GL_OUT_OF_MEMORY);
}
}
HRESULT result = mQuery->Issue(D3DISSUE_END);
ASSERT(SUCCEEDED(result));
mCondition = condition;
mStatus = GL_FALSE;
}
// D3D9_REPLACE
GLboolean Fence::testFence()
{
if (mQuery == NULL)
{
return error(GL_INVALID_OPERATION, GL_TRUE);
}
HRESULT result = mQuery->GetData(NULL, 0, D3DGETDATA_FLUSH);
if (checkDeviceLost(result))
{
return error(GL_OUT_OF_MEMORY, GL_TRUE);
}
ASSERT(result == S_OK || result == S_FALSE);
mStatus = result == S_OK;
return mStatus;
}
void Fence::finishFence()
{
if (mQuery == NULL)
{
return error(GL_INVALID_OPERATION);
}
while (!testFence())
{
Sleep(0);
}
}
void Fence::getFenceiv(GLenum pname, GLint *params)
{
if (mQuery == NULL)
{
return error(GL_INVALID_OPERATION);
}
switch (pname)
{
case GL_FENCE_STATUS_NV:
{
// GL_NV_fence spec:
// Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
// or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
if (mStatus)
{
params[0] = GL_TRUE;
return;
}
HRESULT result = mQuery->GetData(NULL, 0, 0); // D3D9_REPLACE
if (checkDeviceLost(result))
{
params[0] = GL_TRUE;
return error(GL_OUT_OF_MEMORY);
}
ASSERT(result == S_OK || result == S_FALSE);
mStatus = result == S_OK;
params[0] = mStatus;
break;
}
case GL_FENCE_CONDITION_NV:
params[0] = mCondition;
break;
default:
return error(GL_INVALID_ENUM);
break;
}
}
}