Example #1
0
void D11State::draw() {
	clock_t t = clock();
	float elapsed = static_cast<float>(t - timeT) / CLOCKS_PER_SEC;
	++frameCount;
	if (elapsed > OVERLAY_FPS_INTERVAL) {
		OverlayMsg om;
		om.omh.uiMagic = OVERLAY_MAGIC_NUMBER;
		om.omh.uiType = OVERLAY_MSGTYPE_FPS;
		om.omh.iLength = sizeof(OverlayMsgFps);
		om.omf.fps = frameCount / elapsed;

		sendMessage(om);

		frameCount = 0;
		timeT = t;
	}

	checkMessage(static_cast<unsigned int>(vp.Width), static_cast<unsigned int>(vp.Height));

	if (a_ucTexture && pSRView && (uiLeft != uiRight)) {
		if (!bDeferredContext) {
			pOrigStateBlock->Capture();
			pMyStateBlock->Apply();
		}

		// Set vertex buffer
		UINT stride = sizeof(SimpleVertex);
		UINT offset = 0;
		pDeviceContext->IASetVertexBuffers(0, 1, &pVertexBuffer, &stride, &offset);

		pDeviceContext->VSSetShader(pVertexShader, NULL, 0);
		pDeviceContext->GSSetShader(NULL, NULL, 0);
		pDeviceContext->PSSetShaderResources(0, 1, &pSRView);
		pDeviceContext->PSSetShader(pPixelShader, NULL, 0);
		pDeviceContext->DrawIndexed(6, 0, 0);

		if (bDeferredContext) {
			ID3D11CommandList *pCommandList;
			pDeviceContext->FinishCommandList(TRUE, &pCommandList);
			ID3D11DeviceContext *ctx = NULL;
			pDevice->GetImmediateContext(&ctx);
			ctx->ExecuteCommandList(pCommandList, TRUE);
			ctx->Release();
			pCommandList->Release();
		} else {
			pDeviceContext->Flush();
			pMyStateBlock->Capture();
			pOrigStateBlock->Apply();
		}
	}
}
Example #2
0
//---------------------------------------------------------------------------------------------
unsigned int CJobProcessRenderCommands::Execute(unsigned int ThreadID)
{	
	ID3D11DeviceContext* pDeviceContext = m_pRenderer->GetDeferredContext(ThreadID);
	bool EndFrame;
	m_pRenderer->InitDevice(pDeviceContext);
	m_pConstantsSystem->SetConstantBuffer(CConstantsSystem::eView, pDeviceContext);
	m_pConstantsSystem->SetConstantBuffer(CConstantsSystem::eLights, pDeviceContext);
	for (unsigned int CommandIndex = 0; CommandIndex < m_NumCommands; CommandIndex++)
	{
		IRenderCommand* pRenderCommand;
		m_pRWBuffer->BeginRead((void**)&pRenderCommand, sizeof(IRenderCommand));		// this makes an assumption that the compiler stores the 																					// virtual function table pointer as the 1st piece of data in a class
		pRenderCommand->Execute(pDeviceContext, EndFrame);
		m_pRWBuffer->EndRead(pRenderCommand->Size());
	}
	pDeviceContext->FinishCommandList(FALSE, m_ppCommandList);
	m_pRWBuffer->SwapModes(); // Finished processing this buffer
	m_pRenderer->ReturnCommandBufferSegment(m_pRWBuffer);
	m_pEventArray->Set(m_EventIndex); // Signal completion of processing of this CL
	return 0;
}