コード例 #1
0
int
D3DOverdrawWindow::
Loop(void)
{
    int nOverdraw = 0;
    IDirect3DQuery9* pOcclusionQuery;
    DWORD numberOfPixelsDrawn;
    d3d->CreateQuery(D3DQUERYTYPE_OCCLUSION, &pOcclusionQuery);

    for (unsigned int iViewpoint = 0; iViewpoint < m_nViewpointCount;
         iViewpoint++)
    {
        // Add an end marker to the command buffer queue.
        pOcclusionQuery->Issue(D3DISSUE_BEGIN);
        // Draw scene
        SetupDraw(iViewpoint);
        DrawModel();
        d3d->EndScene();
        d3d->Present(NULL, NULL, NULL, NULL);
        // Add an end marker to the command buffer queue.
        pOcclusionQuery->Issue(D3DISSUE_END);

        // Force the driver to execute the commands from the command buffer.
        // Empty the command buffer and wait until the GPU is idle.
        while (S_FALSE == pOcclusionQuery->GetData(&numberOfPixelsDrawn,
                                                   sizeof(DWORD), D3DGETDATA_FLUSH))
            ;

        nOverdraw += numberOfPixelsDrawn;
    }

    pOcclusionQuery->Release();
    return nOverdraw;
}
コード例 #2
0
ファイル: Direct3D9.cpp プロジェクト: romamik/Kore
void Graphics::renderOcclusionQuery(uint occlusionQuery, int triangles) {
	IDirect3DQuery9* pQuery = queryPool[occlusionQuery];
	if (pQuery != nullptr) {
		pQuery->Issue(D3DISSUE_BEGIN);
		device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, triangles);
		pQuery->Issue(D3DISSUE_END);
	}
}
コード例 #3
0
ファイル: Direct3D9.cpp プロジェクト: romamik/Kore
bool Graphics::isQueryResultsAvailable(uint occlusionQuery) {
	IDirect3DQuery9* pQuery = queryPool[occlusionQuery];
	if (pQuery != nullptr) {
		if (S_OK == pQuery->GetData(0, 0, 0)) {
			return true;
		}
	}
	return false;
}
コード例 #4
0
      void onBeginFrame()
      {
         if(!frequencyQuery)
         {
            static_cast<GFXPCD3D9Device*>(GFX)->getDevice()->CreateQuery(D3DQUERYTYPE_TIMESTAMPDISJOINT, &disjointQuery);
            static_cast<GFXPCD3D9Device*>(GFX)->getDevice()->CreateQuery(D3DQUERYTYPE_TIMESTAMPFREQ, &frequencyQuery);
         }

         disjointQuery->Issue(D3DISSUE_BEGIN);
         frequencyQuery->Issue(D3DISSUE_END);
      }
コード例 #5
0
ファイル: RenderSystemDX.cpp プロジェクト: 7orlum/xbmc
void CRenderSystemDX::FlushGPU()
{
  IDirect3DQuery9* pEvent = NULL;

  m_pD3DDevice->CreateQuery(D3DQUERYTYPE_EVENT, &pEvent);
  if (pEvent != NULL)
  {
    pEvent->Issue(D3DISSUE_END);
    while (S_FALSE == pEvent->GetData(NULL, 0, D3DGETDATA_FLUSH))
      Sleep(1);
  }
}
コード例 #6
0
ファイル: Direct3D9.cpp プロジェクト: romamik/Kore
void Graphics::getQueryResults(uint occlusionQuery, uint* pixelCount) {
	IDirect3DQuery9* pQuery = queryPool[occlusionQuery];
	if (pQuery != nullptr) {
		DWORD numberOfPixelsDrawn;
		HRESULT result = pQuery->GetData(&numberOfPixelsDrawn, sizeof(DWORD), 0);
		if (S_OK == result) {
			*pixelCount = numberOfPixelsDrawn;
		}
		else {
			Kore::log(Kore::LogLevel::Warning, "Check first if results are available");
			*pixelCount = 0;
		}
	}
}
コード例 #7
0
	void D3D9HardwareOcclusionQuery::endOcclusionQuery() 
	{ 
		IDirect3DDevice9* pCurDevice  = D3D9RenderSystem::getActiveD3D9Device();				
		DeviceToQueryIterator it      = mMapDeviceToQuery.find(pCurDevice);
		
		if (it == mMapDeviceToQuery.end())
		{
			OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, 
				"End occlusion called without matching begin call !!", 
				"D3D9HardwareOcclusionQuery::endOcclusionQuery" );
		}

		IDirect3DQuery9* pOccQuery = mMapDeviceToQuery[pCurDevice];

		if (pOccQuery != NULL)
			pOccQuery->Issue(D3DISSUE_END); 
	}	
コード例 #8
0
ファイル: Display.cpp プロジェクト: RickEyre/mozilla-central
bool Display::getOcclusionQuerySupport() const
{
    if (!isInitialized())
    {
        return false;
    }

    IDirect3DQuery9 *query = NULL;
    HRESULT result = mDevice->CreateQuery(D3DQUERYTYPE_OCCLUSION, &query);

    if (SUCCEEDED(result) && query)
    {
        query->Release();
        return true;
    }
    else
    {
        return false;
    }
}
コード例 #9
0
	//------------------------------------------------------------------
	// Occlusion query functions (see base class documentation for this)
	//--
	void D3D9HardwareOcclusionQuery::beginOcclusionQuery() 
	{	
		IDirect3DDevice9* pCurDevice  = D3D9RenderSystem::getActiveD3D9Device();				
		DeviceToQueryIterator it      = mMapDeviceToQuery.find(pCurDevice);

		// No resource exits for current device -> create it.
		if (it == mMapDeviceToQuery.end() || it->second == NULL)		
			createQuery(pCurDevice);			
		

		// Grab the query of the current device.
		IDirect3DQuery9* pOccQuery = mMapDeviceToQuery[pCurDevice];

		
		if (pOccQuery != NULL)
		{
			pOccQuery->Issue(D3DISSUE_BEGIN); 
			mIsQueryResultStillOutstanding = true;
			mPixelCount = 0;
		}		
	}
コード例 #10
0
ファイル: Display.cpp プロジェクト: RickEyre/mozilla-central
void Display::sync(bool block)
{
    HRESULT result;

    IDirect3DQuery9* query = allocateEventQuery();
    if (!query)
    {
        return;
    }

    result = query->Issue(D3DISSUE_END);
    ASSERT(SUCCEEDED(result));

    do
    {
        result = query->GetData(NULL, 0, D3DGETDATA_FLUSH);

        if(block && result == S_FALSE)
        {
            // Keep polling, but allow other threads to do something useful first
            Sleep(0);
            // explicitly check for device loss
            // some drivers seem to return S_FALSE even if the device is lost
            // instead of D3DERR_DEVICELOST like they should
            if (testDeviceLost())
            {
                result = D3DERR_DEVICELOST;
            }
        }
    }
    while(block && result == S_FALSE);

    freeEventQuery(query);

    if (isDeviceLostError(result))
    {
        notifyDeviceLost();
    }
}
コード例 #11
0
 void onEndFrame()
 {
    disjointQuery->Issue(D3DISSUE_END);
 }