Hash :
779aa261
Author :
Date :
2013-02-28T23:04:58
Enclose error(GLint) and error(EGLint) into gl and egl namespaces. This should generate a compile time error if we try to call the wrong function. TRAC #22411 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1856 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
//
// 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.
//
// Query11.cpp: Defines the rx::Query11 class which implements rx::QueryImpl.
#include "libGLESv2/renderer/Query11.h"
#include "libGLESv2/main.h"
namespace rx
{
Query11::Query11(rx::Renderer11 *renderer, GLenum type) : QueryImpl(type)
{
mRenderer = renderer;
mQuery = NULL;
}
Query11::~Query11()
{
if (mQuery)
{
mQuery->Release();
mQuery = NULL;
}
}
void Query11::begin()
{
if (mQuery == NULL)
{
D3D11_QUERY_DESC queryDesc;
queryDesc.Query = D3D11_QUERY_OCCLUSION;
queryDesc.MiscFlags = 0;
if (FAILED(mRenderer->getDevice()->CreateQuery(&queryDesc, &mQuery)))
{
return gl::error(GL_OUT_OF_MEMORY);
}
}
mRenderer->getDeviceContext()->Begin(mQuery);
}
void Query11::end()
{
if (mQuery == NULL)
{
return gl::error(GL_INVALID_OPERATION);
}
mRenderer->getDeviceContext()->End(mQuery);
setStatus(GL_FALSE);
setResult(GL_FALSE);
}
GLuint Query11::getResult()
{
if (mQuery != NULL)
{
while (!testQuery())
{
Sleep(0);
// explicitly check for device loss, some drivers seem to return S_FALSE
// if the device is lost
if (mRenderer->testDeviceLost(true))
{
return gl::error(GL_OUT_OF_MEMORY, 0);
}
}
}
return getResult();
}
GLboolean Query11::isResultAvailable()
{
if (mQuery != NULL)
{
testQuery();
}
return getStatus();
}
GLboolean Query11::testQuery()
{
if (mQuery != NULL && getStatus() != GL_TRUE)
{
UINT64 numPixels = 0;
HRESULT result = mRenderer->getDeviceContext()->GetData(mQuery, &numPixels, sizeof(UINT64), 0);
if (result == S_OK)
{
setStatus(GL_TRUE);
switch (getType())
{
case GL_ANY_SAMPLES_PASSED_EXT:
case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
setResult((numPixels > 0) ? GL_TRUE : GL_FALSE);
break;
default:
UNREACHABLE();
}
}
else if (mRenderer->testDeviceLost(true))
{
return gl::error(GL_OUT_OF_MEMORY, GL_TRUE);
}
return getStatus();
}
return GL_TRUE; // prevent blocking when query is null
}
}