Beispiel #1
0
void DiluteSSAOMask( r3dScreenBuffer *sourceTex )
{
	D3DPERF_BeginEvent( 0, L"DiluteSSAOMask" ) ;

	r3dSetRestoreFSQuadVDecl setRestoreVDECL; (void)setRestoreVDECL;

	float resK;
	int HalfScale;

	resK = r_half_scale_ssao->GetInt() ? 0.5f : 1.0f ;
	HalfScale = !!r_half_scale_ssao->GetInt() ;

	float vConsts[ 4 ] = {	1.0f / r3dRenderer->ScreenW, 0.f, 0.f, 1.0f / r3dRenderer->ScreenH } ;
	D3D_V( r3dRenderer->pd3ddev->SetPixelShaderConstantF( 0, vConsts, 1 ) ) ;

	r3dRenderer->SetVertexShader( "VS_SSAO" ) ;
	r3dRenderer->SetPixelShader( "PS_SSAO_MASK_DILUTE" ) ;

	r3dRenderer->SetTex( sourceTex->Tex, 0 ) ;
	r3dSetFiltering( R3D_BILINEAR, 0 ) ;

	D3D_V( r3dRenderer->pd3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSU,   D3DTADDRESS_CLAMP ) );
	D3D_V( r3dRenderer->pd3ddev->SetSamplerState( 0, D3DSAMP_ADDRESSV,   D3DTADDRESS_CLAMP ) );

	D3DXVECTOR4 vconst = D3DXVECTOR4( 0.5f / r3dRenderer->ScreenW, 0.5f / r3dRenderer->ScreenH, resK, resK ) ;
	r3dRenderer->pd3ddev->SetVertexShaderConstantF(  0, (float *)&vconst, 1 ) ;

	r3dDrawFullScreenQuad(!!HalfScale);

	D3DPERF_EndEvent() ;
}
Beispiel #2
0
/**
 ****************************************************************************************************
	\fn			void Draw( void )
	\brief		Draw the quad on screen
	\param		NONE
	\return		NONE
 ****************************************************************************************************
*/
void RendererEngine::Quad::Draw( void )
{
	IDirect3DDevice9* direct3dDevice = g_mainRenderer::Get().GetDirect3dDevice();

#ifdef _DEBUG
	D3DPERF_BeginEvent( 0 , L"Draw quad" );
#endif	// #ifdef _DEBUG
	// Bind a specific vertex buffer to the device as a data source
	{
		// There can be multiple streams of data feeding the display adaptor at the same time
		unsigned int streamIndex = 0;
		// It's possible to start streaming data in the middle of a vertex buffer
		unsigned int bufferOffset = 0;
		// The "stride" defines how large a single vertex is in the stream of data
		unsigned int bufferStride = sizeof( Utilities::S_BASIC_VERTEX_DATA );
		HRESULT result = direct3dDevice->SetStreamSource( streamIndex, _vertexBuffer, bufferOffset, bufferStride );
		assert( SUCCEEDED( result ) );
	}
	// Render objects from the current streams
	{
		// We are using triangles as the "primitive" type,
		// and we have defined the vertex buffer as a triangle list
		// (meaning that every triangle is defined by three vertices)
		D3DPRIMITIVETYPE primitiveType = D3DPT_TRIANGLELIST;
		// It's possible to start rendering primitives in the middle of the stream
		unsigned int indexOfFirstVertexToRender = 0;
		// We are currently only rendering a single triangle
		unsigned int primitiveCountToRender = 2;
		HRESULT result = direct3dDevice->DrawPrimitive( primitiveType, indexOfFirstVertexToRender, primitiveCountToRender );
		assert( SUCCEEDED(result) );
	}
#ifdef _DEBUG
	D3DPERF_EndEvent();
#endif	// #ifdef _DEBUG
}
Beispiel #3
0
// Call the user's Render() callback (if it exists)
//-----------------------------------------------------------------------------
void CPUT_DX11::InnerExecutionLoop()
{
#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_BeginEvent(D3DCOLOR(0xff0000), L"CPUT User's Render() ");
#endif
    if(!mbShutdown)
    {
        double deltaSeconds = mpTimer->GetElapsedTime();
        Update(deltaSeconds);
        Present(); // Note: Presenting immediately before Rendering minimizes CPU stalls (i.e., execute Update() before Present() stalls)

        double totalSeconds = mpTimer->GetTotalTime();
        UpdatePerFrameConstantBuffer(totalSeconds);
        CPUTMaterialDX11::ResetStateTracking();
        Render(deltaSeconds);
        if(!CPUTOSServices::GetOSServices()->DoesWindowHaveFocus())
        {
            Sleep(100);
        }
    }
    else
    {
#ifndef _DEBUG
        exit(0);
#endif
        Present(); // Need to present, or will leak all references held by previous Render()!
        ShutdownAndDestroy();
    }

#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_EndEvent();
#endif
}
Beispiel #4
0
/**
 ****************************************************************************************************
	\fn			void Draw( void )
	\brief		Draw the line on screen
	\param		NONE
	\return		NONE
 ****************************************************************************************************
*/
void RendererEngine::Sphere::Draw( void )
{
	IDirect3DDevice9* direct3dDevice = g_mainRenderer::Get().GetDirect3dDevice();

#ifdef _DEBUG
	D3DPERF_BeginEvent( 0 , L"Draw sphere" );
#endif	// #ifdef _DEBUG

	Setter::SetVertexBuffer( _vertexBuffer, sizeof(Utilities::S_BASIC_VERTEX_DATA) );
	Setter::SetIndexBuffer( _indexBuffer );

	// Render objects from the current streams
	{
		// We are using triangles as the "primitive" type,
		// and we have defined the vertex buffer as a triangle list
		// (meaning that every triangle is defined by three vertices)
		D3DPRIMITIVETYPE primitiveType = D3DPT_TRIANGLELIST;
		// It's possible to start rendering primitives in the middle of the stream
		unsigned int indexOfFirstVertexToRender = 0;
		// We are currently only rendering a single triangle
		unsigned int startIndex = 0;
		//HRESULT result = direct3dDevice->DrawPrimitive( primitiveType, indexOfFirstVertexToRender, primitiveCountToRender );
		HRESULT result = g_mainRenderer::Get().GetDirect3dDevice()->DrawIndexedPrimitive( primitiveType, indexOfFirstVertexToRender,
			0, _u32VertexCount, startIndex, _u32PrimitiveCount );
		assert( SUCCEEDED(result) );
	}

#ifdef _DEBUG
	D3DPERF_EndEvent();
#endif	// #ifdef _DEBUG
}
void SpriteRenderer::Begin(ID3D11DeviceContext* deviceContext, FilterMode filterMode)
{
    _ASSERT(initialized);
    _ASSERT(!context);
    context = deviceContext;

    D3DPERF_BeginEvent(0xFFFFFFFF, L"SpriteRenderer Begin/End");

    // Set the index buffer
    context->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R16_UINT, 0);

    // Set primitive topology
    context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

    // Set the states
    float blendFactor[4] = {1, 1, 1, 1};
    context->RSSetState(rastState);
    context->OMSetBlendState(alphaBlendState, blendFactor, 0xFFFFFFFF);
    context->OMSetDepthStencilState(dsState, 0);

    if (filterMode == Linear)
        context->PSSetSamplers(0, 1, &(linearSamplerState.GetInterfacePtr()));
    else if (filterMode == Point)
        context->PSSetSamplers(0, 1, &(pointSamplerState.GetInterfacePtr()));

    // Set the shaders
    context->PSSetShader(pixelShader, nullptr, 0);
    context->GSSetShader(nullptr, nullptr, 0);
    context->DSSetShader(nullptr, nullptr, 0);
    context->HSSetShader(nullptr, nullptr, 0);
}
Beispiel #6
0
void RenderSSAOEffect ()
{
	if ( !r_ssao->GetBool() )
		return;

	D3DPERF_BeginEvent(D3DCOLOR_XRGB(255,255,255), L"RenderSSAOEffect" );

	R3DPROFILE_D3DSTART( D3DPROFILE_SSAO ) ;

	if( !__SSAOBlurEnable )
	{
		// with half scale ssao we don't use stencil so the background
		// is SSAOed. With full scale ssao we use stencil to avoid expensive
		// stuff where sky is, so we have to clear to not let it through.
		// ( this step is done later if SSAO blur is on )
		D3D_V( r3dRenderer->pd3ddev->Clear( 0, 0, D3DCLEAR_TARGET, 0xffffffff, 1.f, 0 ) ) ;
	}

	switch( r_ssao_method->GetInt() )
	{
	case SSM_REF:
		RenderSSAORefEffect();
		break;
	case SSM_DEFAULT:
		RenderSSAOEffect( true );
		break;
	case SSM_HQ:
		RenderSSAOEffect( false );
		break;
	}

	R3DPROFILE_D3DEND( D3DPROFILE_SSAO ) ;

	D3DPERF_EndEvent ();
}
void FD3DGPUProfiler::PushEvent(const TCHAR* Name, FColor Color)
{
#if WITH_DX_PERF
	D3DPERF_BeginEvent(Color.DWColor(), Name);
#endif

	FGPUProfiler::PushEvent(Name, Color);
}
	HRESULT Sprite::Set(IDirect3DDevice9 * i_direct3dDevice
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
		, std::string* o_errorMessage
#endif
		)
	{
		assert(i_direct3dDevice && m_vertexShader && m_fragmentShader && m_texture);

		HRESULT result = D3D_OK;
#ifdef EAE2014_GRAPHICS_AREPIXEVENTSENABLED
		std::wstringstream EventMessage;
		EventMessage << "Set Sprite " << (m_name.c_str());
		D3DPERF_BeginEvent(0, EventMessage.str().c_str());
#endif
		// Set the shaders
		result = i_direct3dDevice->SetVertexShader(m_vertexShader);
		assert(SUCCEEDED(result));
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
		if (FAILED(result))
		{
			if (o_errorMessage)
			{
				*o_errorMessage = "Direct3D failed to set the vertex shader";
			}
			return result;
		}
#endif
		result = i_direct3dDevice->SetPixelShader(m_fragmentShader);
		assert(SUCCEEDED(result));
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
		if (FAILED(result))
		{
			if (o_errorMessage)
			{
				*o_errorMessage = "Direct3D failed to set the fragment shader";
			}
			return result;
		}
#endif

		result = i_direct3dDevice->SetTexture(m_samplerRegister, m_texture);
		assert(SUCCEEDED(result));
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
		if (FAILED(result))
		{
			if (o_errorMessage)
			{
				*o_errorMessage = "Direct3D failed to set the texture";
			}
			return result;
		}
#endif

#ifdef EAE2014_GRAPHICS_AREPIXEVENTSENABLED
		D3DPERF_EndEvent();
#endif
		return result;
	}
void SpriteRenderer::RenderBatch(ID3D11ShaderResourceView* texture,
                                 const SpriteDrawData* drawData,
                                 uint64 numSprites)
{
    _ASSERT(context);
    _ASSERT(initialized);

    D3DPERF_BeginEvent(0xFFFFFFFF, L"SpriteRenderer RenderBatch");

    // Set the vertex shader
    context->VSSetShader(vertexShaderInstanced, nullptr, 0);

    // Set the input layout
    context->IASetInputLayout(inputLayoutInstanced);

    // Set per-batch constants
    D3D11_TEXTURE2D_DESC desc = SetPerBatchData(texture);

    // Make sure the draw rects are all valid
    for (uint64 i = 0; i < numSprites; ++i)
    {
        Float4 drawRect = drawData[i].DrawRect;
        _ASSERT(drawRect.x >= 0 && drawRect.x < desc.Width);
        _ASSERT(drawRect.y >= 0 && drawRect.y < desc.Height);
        _ASSERT(drawRect.z > 0 && drawRect.x + drawRect.z <= desc.Width);
        _ASSERT(drawRect.w > 0 && drawRect.y + drawRect.w <= desc.Height);
    }

    uint64 numSpritesToDraw = std::min(numSprites, MaxBatchSize);

    // Copy in the instance data
    D3D11_MAPPED_SUBRESOURCE mapped;
    DXCall(context->Map(instanceDataBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped));
    CopyMemory(mapped.pData, drawData, static_cast<size_t>(sizeof(SpriteDrawData) * numSpritesToDraw));
    context->Unmap(instanceDataBuffer, 0);

    // Set the constant buffer
    ID3D11Buffer* constantBuffers [1] = { vsPerBatchCB };
    context->VSSetConstantBuffers(0, 1, constantBuffers);

    // Set the vertex buffers
    UINT strides [2] = { sizeof(SpriteVertex), sizeof(SpriteDrawData) };
    UINT offsets [2] = { 0, 0 };
    ID3D11Buffer* vertexBuffers [2] = { vertexBuffer, instanceDataBuffer };
    context->IASetVertexBuffers(0, 2, vertexBuffers, strides, offsets);

    // Set the texture
    context->PSSetShaderResources(0, 1, &texture);

    // Draw
    context->DrawIndexedInstanced(6, static_cast<UINT>(numSpritesToDraw), 0, 0, 0);

    D3DPERF_EndEvent();

    // If there's any left to be rendered, do it recursively
    if(numSprites > numSpritesToDraw)
        RenderBatch(texture, drawData + numSpritesToDraw, numSprites - numSpritesToDraw);
}
void SpriteRenderer::Render(ID3D11ShaderResourceView* texture,
                            const Float4x4& transform,
                            const Float4& color,
                            const Float4* drawRect)
{
    _ASSERT(context);
    _ASSERT(initialized);

    D3DPERF_BeginEvent(0xFFFFFFFF, L"SpriteRenderer Render");

    // Set the vertex shader
    context->VSSetShader(vertexShader, nullptr, 0);

    // Set the input layout
    context->IASetInputLayout(inputLayout);

    // Set the vertex buffer
    UINT stride = sizeof(SpriteVertex);
    UINT offset = 0;
    ID3D11Buffer* vb = vertexBuffer.GetInterfacePtr();
    context->IASetVertexBuffers(0, 1, &vb, &stride, &offset);

    // Set per-batch constants
    D3D11_TEXTURE2D_DESC desc = SetPerBatchData(texture);

    // Set per-instance data
    SpriteDrawData perInstance;
    perInstance.Transform = Float4x4::Transpose(transform);
    perInstance.Color = color;

    // Draw rect
    if(drawRect == nullptr)
        perInstance.DrawRect = Float4(0, 0, static_cast<float>(desc.Width), static_cast<float>(desc.Height));
    else
    {
        _ASSERT(drawRect->x >= 0 && drawRect->x < desc.Width);
        _ASSERT(drawRect->y >= 0 && drawRect->y < desc.Height);
        _ASSERT(drawRect->z > 0 && drawRect->x + drawRect->z < desc.Width);
        _ASSERT(drawRect->w > 0 && drawRect->y + drawRect->w < desc.Height);
        perInstance.DrawRect = *drawRect;
    }

    // Copy in the buffer data
    D3D11_MAPPED_SUBRESOURCE mapped;
    DXCall(context->Map(vsPerInstanceCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped));
    CopyMemory(mapped.pData, &perInstance, sizeof(SpriteDrawData));
    context->Unmap(vsPerInstanceCB, 0);

    ID3D11Buffer* buffers [2] = { vsPerBatchCB, vsPerInstanceCB };
    context->VSSetConstantBuffers(0, 2, buffers);

    // Set the texture
    context->PSSetShaderResources(0, 1, &texture);

    context->DrawIndexed(6, 0, 0);

    D3DPERF_EndEvent();
}
void CollisionSolver::SolveClothCollision(const D3DXVECTOR3& minBounds, 
                                          const D3DXVECTOR3& maxBounds)
{
    D3DPERF_BeginEvent(D3DCOLOR(), L"CollisionSolver::SolveClothCollision");

    assert(!m_cloth.expired());
    auto cloth = m_cloth.lock();
    auto& particles = cloth->GetParticles();

    for(unsigned int i = 0; i < particles.size(); ++i)
    {
        // Solve the particles against themselves
        for(unsigned int j = i+1; j < particles.size(); ++j)
        {
            SolveParticleCollision(particles[i]->GetCollisionMesh(), 
                particles[j]->GetCollisionMesh());
        }

        // Solve the particle against the eight scene walls
        const D3DXVECTOR3& particlePosition = particles[i]->GetPosition();
        D3DXVECTOR3 position(0.0, 0.0, 0.0);

        // Check for ground and roof collisions
        if(particlePosition.y <= maxBounds.y)
        {
            position.y = maxBounds.y-particlePosition.y;
        }
        else if(particlePosition.y >= minBounds.y)
        {
            position.y = minBounds.y-particlePosition.y;
        }

        // Check for left and right wall collisions
        if(particlePosition.x >= maxBounds.x)
        {
            position.x = maxBounds.x-particlePosition.x;
        }
        else if(particlePosition.x <= minBounds.x)
        {
            position.x = minBounds.x-particlePosition.x;
        }

        // Check for forward and backward wall collisions
        if(particlePosition.z >= maxBounds.z)
        {
            position.z = maxBounds.z-particlePosition.z;
        }
        else if(particlePosition.z <= minBounds.z)
        {
            position.z = minBounds.z-particlePosition.z;
        }

        particles[i]->MovePosition(position);
    }

    D3DPERF_EndEvent();
}
Beispiel #12
0
//------------------------------------------------------------------------------
void GFXPCD3D9Device::enterDebugEvent(ColorI color, const char *name)
{
   // BJGFIX
   WCHAR  eventName[260];
   MultiByteToWideChar( CP_ACP, 0, name, -1, eventName, 260 );

   D3DPERF_BeginEvent(D3DCOLOR_ARGB(color.alpha, color.red, color.green, color.blue),
      (LPCWSTR)&eventName);
}
Beispiel #13
0
HRESULT World::frameRender(IDirect3DDevice9* pd3dDevice, double dTime, float fElapsedTime)
{
    EpCamera& camera = GetG().m_camera;
    HRESULT hr = S_OK;
    //////////////////////////////////////////////////////////////////////////
    // Perspective Rendering Phase
    pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE ); // TODO - Lighting
    D3DXMATRIX v, p, w;
    D3DXVECTOR3 eye(0, 0, -50), at(0, 0, 0), up(0, 1, 0);
    D3DXMatrixPerspectiveFovLH(&p, ArnToRadian(45.0), 1.0f, 0.0f, 1000.0f);
    D3DXMatrixLookAtRH(&v, &eye, &at, &up);
    D3DXMatrixIdentity(&w);
    pd3dDevice->SetTransform(D3DTS_VIEW, camera.GetViewMatrix());
    pd3dDevice->SetTransform(D3DTS_PROJECTION, camera.GetProjMatrix());

    //////////////////////////////////////////////////////////////////////////
    // Aran lib rendering routine (CW)
    pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
    //pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
    pd3dDevice->SetFVF(ArnVertex::FVF);
    D3DPERF_BeginEvent(0, L"World render");
    GetG().m_videoMan->renderMeshesOnly(m_modelSg->getSceneRoot());
    D3DPERF_EndEvent();

    //////////////////////////////////////////////////////////////////////////
    // EP rendering routine (CCW)
    UnitSet::iterator it = m_unitSet.begin();
    for ( ; it != m_unitSet.end(); ++it )
    {
        if ( !(*it)->getRemoveFlag() )
        {
            if ( (*it)->getType() != UT_UNITBASE )
            {
                // Locally created instance. Almost by script file.
                (*it)->frameRender( pd3dDevice, dTime, fElapsedTime );
            }
            else
            {
                // Remotely created instance by RakNet ReplicaManager.
                pd3dDevice->SetTransform( D3DTS_WORLD, (D3DMATRIX*)&((*it)->getLocalXformRaw()) );
                pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
                g_bst[BST_TEAPOT]->DrawSubset( 0 );
            }
        }
    }
    DialogList::iterator itDialog = m_scriptedDialog.begin();
    for ( ; itDialog != m_scriptedDialog.end(); ++itDialog )
    {
        (*itDialog)->frameRender(pd3dDevice, dTime, fElapsedTime);
    }
    WorldStateManager& wsm = WorldStateManager::getSingleton();
    wsm.getCurState()->frameRender(pd3dDevice, dTime, fElapsedTime);
    return hr;
}
Beispiel #14
0
//-------------------------------------------------------------------------------------------------
void sdEarlyZPass::Draw()
{
    if (!m_bInitialized || !m_bActived)
        return;

    D3DPERF_BeginEvent(0xff000000, L"EarlyZPass");

    IRenderDevice* pkRenderDevice = IRenderDevice::GetRenderDevice();
    NIASSERT(pkRenderDevice);

    // 清除数据绑定
    pkRenderDevice->ClearVertexBinding();
    pkRenderDevice->ClearTextureBinding();

    // Alpha
    pkRenderDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,	false);
    pkRenderDevice->SetRenderState(D3DRS_ALPHATESTENABLE,	false);

    // Z
    pkRenderDevice->SetRenderState(D3DRS_ZENABLE,			true);
    pkRenderDevice->SetRenderState(D3DRS_ZWRITEENABLE,		true);
    pkRenderDevice->SetRenderState(D3DRS_ZFUNC,				D3DCMP_LESSEQUAL);

    // Stencil
    if (m_uiStaticMeshStencilID)
    {
        pkRenderDevice->SetRenderState(D3DRS_STENCILENABLE,		true);
        pkRenderDevice->SetRenderState(D3DRS_STENCILFUNC,		D3DCMP_ALWAYS);
        pkRenderDevice->SetRenderState(D3DRS_STENCILFAIL,		D3DSTENCILOP_KEEP);
        pkRenderDevice->SetRenderState(D3DRS_STENCILZFAIL,		D3DSTENCILOP_KEEP);
        pkRenderDevice->SetRenderState(D3DRS_STENCILPASS,		D3DSTENCILOP_REPLACE);
        pkRenderDevice->SetRenderState(D3DRS_STENCILREF,		m_uiStaticMeshStencilID);
        pkRenderDevice->SetRenderState(D3DRS_STENCILWRITEMASK,	m_uiStaticMeshStencilIDMask);
    }
    else
    {
        pkRenderDevice->SetRenderState(D3DRS_STENCILENABLE,		false);
    }

    // 禁用第一个颜色缓存,以获取双倍输出
    // Then the most important one: Disable color output. Get double speed on ROP
    pkRenderDevice->SetRenderState(D3DRS_COLORWRITEENABLE,	0);

    // 绘制
    __super::Draw();

    // 恢复第一个颜色输出
    // Re-enable color output
    uint uiColorChannelMask = D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN |	D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA;
    pkRenderDevice->SetRenderState(D3DRS_COLORWRITEENABLE,	uiColorChannelMask);

    D3DPERF_EndEvent();
}
Beispiel #15
0
// start main message loop
//-----------------------------------------------------------------------------
int CPUT_DX11::CPUTMessageLoop()
{
#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_BeginEvent(D3DCOLOR(0xff0000), L"CPUTMessageLoop");
#endif

    return mpWindow->StartMessageLoop();

#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_EndEvent();
#endif
}
Beispiel #16
0
void RenderHandler::PerformRender(Renderable::RenderPhase phase)
{
	ResetDeviceState();

	D3DPERF_BeginEvent(D3DCOLOR_XRGB(255, 0, 0), L"RenderHandler::PerformRender");

	for (auto& r : m_renderables)
	{
		r->Render(phase);
	}

	D3DPERF_EndEvent();
}
Beispiel #17
0
HRESULT SkillObject::frameRender ( IDirect3DDevice9* pd3dDevice, double dTime, float fElapsedTime )
{
	HRESULT f = 0;
	D3DPERF_BeginEvent( 0, L"SkillObject Render" );

	HRESULT hr = S_OK;
	ArnMatrix mWorld;
	ArnMatrixIdentity( &mWorld );
	UINT iPass, cPasses;
	if ( SUCCEEDED(g_bombShader->setMainTechnique()) )
	{
		ArnMatrix arnvm, arnpm;
		memcpy(arnvm.m, GetG().m_camera.GetViewMatrix()->m, sizeof(float)*16);
		memcpy(arnpm.m, GetG().m_camera.GetProjMatrix()->m, sizeof(float)*16);

		V( g_bombShader->setWorldViewProj( dTime, fElapsedTime, &getLocalXform(), &arnvm, &arnpm) );

		V( g_bombShader->begin( &cPasses, 0 ) );
		for( iPass = 0; iPass < cPasses; iPass++ )
		{
			V( g_bombShader->beginPass( iPass ) );

			// TODO Mesh pointing should be done here? not OnResetDevice?
			if ( getMesh() == 0 )
			{
				setMesh( g_bst[ m_bst ] );
			}

			f = getMesh()->DrawSubset( 0 );

			V( g_bombShader->endPass() );
		}
		V( g_bombShader->end() );
	}
	else
	{
		// TODO Mesh pointing should be done here? not OnResetDevice?
		if ( getMesh() == 0 )
		{
			setMesh( g_bst[ m_bst ] );
		}
		pd3dDevice->SetTransform(D3DTS_WORLD, (const D3DXMATRIX*)getLocalXform().m);
		f = getMesh()->DrawSubset( 0 );
	}
	

	D3DPERF_EndEvent();
	return f;
}
Beispiel #18
0
// draw all the GUI controls
//-----------------------------------------------------------------------------
void CPUT_DX11::CPUTDrawGUI()
{
#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_BeginEvent(D3DCOLOR(0xff0000), L"CPUT Draw GUI");
#endif

    // draw all the Gui controls
    HEAPCHECK;
        CPUTGuiControllerDX11::GetController()->Draw(mpContext);
    HEAPCHECK;

#ifdef CPUT_GPA_INSTRUMENTATION
        D3DPERF_EndEvent();
#endif
}
void SpriteRenderer::RenderText(const SpriteFont& font,
                                const wchar* text,
                                const Float4x4& transform,
                                const Float4& color)
{
    D3DPERF_BeginEvent(0xFFFFFFFF, L"SpriteRenderer RenderText");

    size_t length = wcslen(text);

    Float4x4 textTransform;

    uint64 numCharsToDraw = std::min(length, MaxBatchSize);
    uint64 currentDraw = 0;
    for(uint64 i = 0; i < numCharsToDraw; ++i)
    {
        wchar character = text[i];
        if(character == ' ')
            textTransform._41 += font.SpaceWidth();
        else if(character == '\n')
        {
            textTransform._42 += font.CharHeight();
            textTransform._41 = 0;
        }
        else
        {
            SpriteFont::CharDesc desc = font.GetCharDescriptor(character);

            textDrawData[currentDraw].Transform = textTransform * transform;
            textDrawData[currentDraw].Color = color;
            textDrawData[currentDraw].DrawRect.x = desc.X;
            textDrawData[currentDraw].DrawRect.y = desc.Y;
            textDrawData[currentDraw].DrawRect.z = desc.Width;
            textDrawData[currentDraw].DrawRect.w = desc.Height;
            currentDraw++;

            textTransform._41 += desc.Width + 1;
        }
    }

    // Submit a batch
    RenderBatch(font.SRView(), textDrawData, currentDraw);

    D3DPERF_EndEvent();

    if(length > numCharsToDraw)
        RenderText(font, text + numCharsToDraw, textTransform, color);
}
void SpriteRenderer::RenderText(const SpriteFont& font,
                                const WCHAR* text,
            				    const XMMATRIX& transform,
                                const XMFLOAT4& color)
{
    D3DPERF_BeginEvent(0xFFFFFFFF, L"SpriteRenderer RenderText");

    size_t length = wcslen(text);

    XMMATRIX textTransform = XMMatrixIdentity();

    UINT64 numCharsToDraw = min(length, MaxBatchSize);
    UINT64 currentDraw = 0;
    for (UINT64 i = 0; i < numCharsToDraw; ++i)
    {
        WCHAR character = text[i];
        if(character == ' ')
            textTransform._41 += font.SpaceWidth();
        else if(character == '\n')
        {
            textTransform._42 += font.CharHeight();
            textTransform._41 = 0;
        }
        else
        {
            SpriteFont::CharDesc desc = font.GetCharDescriptor(character);

            textDrawData[currentDraw].Transform = XMMatrixMultiply(textTransform, transform);
            textDrawData[currentDraw].Color = color;
            textDrawData[currentDraw].DrawRect.x = desc.X;
            textDrawData[currentDraw].DrawRect.y = desc.Y;
            textDrawData[currentDraw].DrawRect.z = desc.Width;
            textDrawData[currentDraw].DrawRect.w = desc.Height;
            currentDraw++;

            textTransform._41 += desc.Width + 1;
        }
    }

    // Submit a batch
    RenderBatch(font.SRView(), textDrawData, currentDraw);

    D3DPERF_EndEvent();

    if(length > numCharsToDraw)
        RenderText(font, text + numCharsToDraw, textTransform, color);
}
Beispiel #21
0
void RenderSystem::debugEventPush(const char* name, uint32 color)
{
#if defined (SUPPORT_GPU_DEBUG_MARKERS)
  WCHAR buffer[255] = {0};
  MultiByteToWideChar(CP_ACP, 0, name, -1, buffer, 255);

  ID3DUserDefinedAnnotation* annotation = 0;
  if (SUCCEEDED(m_device->QueryInterface(__uuidof(ID3DUserDefinedAnnotation), (void**)&annotation)))
  {
    annotation->BeginEvent(buffer);
    annotation->Release();
  }
  else
  {
    D3DPERF_BeginEvent(color, buffer);
  }
#endif // SUPPORT_GPU_DEBUG_MARKERS
}
void CRtwShadowRenderer::DrawFirstPassDepth()
{
    GetDX11Context()->RSSetState(RasterizerStates::DepthRS);

    GetDX11Context()->RSSetViewports(1, &m_importanceViewport);

    ID3D11RenderTargetView* renderTargets[1] = { nullptr };
    GetDX11Context()->OMSetRenderTargets(1, renderTargets, m_depthStencilView);

    GetDX11Context()->ClearDepthStencilView(m_depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);

    GetDX11Context()->VSSetShader(m_depthVS, 0, 0);
    GetDX11Context()->PSSetShader(nullptr, 0, 0);

    GetDX11Context()->IASetInputLayout(m_inputLayout);

    XMMATRIX lightView     = XMLoadFloat4x4(&GetRenderer().mLightView);
    XMMATRIX lightProj     = XMLoadFloat4x4(&GetRenderer().mLightProj);
    XMMATRIX lightViewProj = XMMatrixMultiply(lightView, lightProj);

    int modelsCount = Globals::Get().scene.m_models.size();
    for(int i = 0; i < modelsCount; i++)
    {
        D3DPERF_BeginEvent(D3DCOLOR_XRGB( 255, 0, 0  ),  L"DRAW_DEPTH_FIRST_PASS");

        XMMATRIX world = Globals::Get().scene.m_models[i]->m_transformation.GetWorld();

        SDepthCBuffer2 cbuffer;
        cbuffer.gWorldLightViewProj = XMMatrixTranspose(world * lightViewProj);

        GetDX11Context()->UpdateSubresource(m_depthConstBuffer, 0, NULL, &cbuffer, 0, 0);

        GetDX11Context()->VSSetConstantBuffers(0, 1, &m_depthConstBuffer);

        uint offset = 0;
        GetDX11Context()->IASetIndexBuffer(Globals::Get().scene.m_models[i]->m_mesh->m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);
        GetDX11Context()->IASetVertexBuffers(0, 1, &Globals::Get().scene.m_models[i]->m_mesh->m_vertexBuffer, &Globals::Get().scene.m_models[i]->m_mesh->m_stride, &offset);

        GetDX11Context()->DrawIndexed(Globals::Get().scene.m_models[i]->m_mesh->m_indexCount, 0, 0 );

        D3DPERF_EndEvent();
    }
}
Beispiel #23
0
HRESULT Dialog::frameRender( IDirect3DDevice9* pd3dDevice,  double dTime, float fElapsedTime )
{
	if ( m_bInit )
	{
		pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
		pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
		pd3dDevice->SetTransform(D3DTS_VIEW, (const D3DXMATRIX*)GetG().g_fixedViewMat.m);
		pd3dDevice->SetTransform(D3DTS_PROJECTION, (const D3DXMATRIX*)GetG().g_orthoProjMat.m);

		D3DMATERIAL9 material;
		D3DCOLORVALUE cv, cv2;
		cv.a = 0.3f; cv.r = 0.1f; cv.g = 0.1f; cv.b = 0.1f;
		cv2.a = 0.3f; cv2.r = 1.0f; cv2.g = 0.1f; cv2.b = 0.3f;
		material.Ambient = cv;
		material.Diffuse = cv2;
		material.Emissive = cv;
		material.Power = 1.0f;
		material.Specular = cv2;
		pd3dDevice->SetMaterial(&material);

		//drawFixedText(scrWidth, scrHeight);

		pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);

		if( m_bTalking )
		{
			D3DPERF_BeginEvent(0x12345678, L"Draw Dialog Pane");
			//m_contentPic.draw();
			//m_namePic.draw();
			D3DPERF_EndEvent();

			printDialog();
			printName();

		}

		pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
	}
	
	return S_OK;
}
/**
 ****************************************************************************************************
	\fn			void Draw3D( const std::vector<S_ENTITY_TO_DRAW> &i_entitiesToDraw, const std::vector<S_LINE_TO_DRAW> &i_linesToDraw,
				const std::vector<S_SPHERE_TO_DRAW> &i_sphereToDraw,
				const D3DXMATRIX &i_cameraWorldToViewTransform, const D3DXMATRIX &i_cameraViewToProjectedTransform,
				const D3DXVECTOR3 &i_cameraPosition, const float &i_cameraFarView,
				const D3DXMATRIX &i_directionalLightWorldToViewTransform, const D3DXMATRIX &i_directionalLightViewToProjectedTransform,
				const D3DXVECTOR3 &i_directionalLightDirection, const D3DCOLOR &i_directionalLightColour,
				const float &i_directionalLightIntensity, const float &i_directionalLightFarView,
				const D3DCOLOR &i_pointLightColour, const D3DCOLOR &i_pointLightAmbient, const D3DXVECTOR3 &i_pointLightPosition,
				const float &i_pointLightIntensity, const float &i_pointLightRadius )
	\brief		Draw the 3D objects of the scene
	\param		i_entitiesToDraw the entities to be drawn
	\param		i_linesToDraw the lines to be drawn
	\param		i_sphereToDraw the sphere to be drawn
	\param		i_cameraWorldToViewTransform the camera world to view transformation matrix
	\param		i_cameraViewToProjectedTransform the camera view to projected transformation matrix
	\param		i_cameraPosition the position of camera
	\param		i_cameraFarView the far view distance of camera
	\param		i_directionalLightWorldToViewTransform the camera world to view transformation matrix
	\param		i_directionalLightViewToProjectedTransform the camera view to projected transformation matrix
	\param		i_directionalLightDirection the direction of directional light
	\param		i_directionalLightColour the colour of directional light
	\param		i_directionalLightIntensity the intensity of directional light
	\param		i_directionalLightFarView the far view of directional light
	\param		i_pointLightColour the colour of point light
	\param		i_pointLightAmbient the ambient colour of point light
	\param		i_pointLightPosition the position of point light
	\param		i_pointLightIntensity the intensity of point light
	\param		i_pointLightRadius the radius of point light
	\return		NONE
 ****************************************************************************************************
*/
void RendererEngine::Draw3D( const std::vector<S_ENTITY_TO_DRAW> &i_entitiesToDraw, const std::vector<S_LINE_TO_DRAW> &i_linesToDraw,
	const std::vector<S_SPHERE_TO_DRAW> &i_sphereToDraw,
	const D3DXMATRIX &i_cameraWorldToViewTransform, const D3DXMATRIX &i_cameraViewToProjectedTransform,
	const D3DXVECTOR3 &i_cameraPosition, const float &i_cameraFarView,
	const D3DXMATRIX &i_directionalLightWorldToViewTransform, const D3DXMATRIX &i_directionalLightViewToProjectedTransform,
	const D3DXVECTOR3 &i_directionalLightDirection, const D3DCOLOR &i_directionalLightColour,
	const float &i_directionalLightIntensity, const float &i_directionalLightFarView,
	const D3DCOLOR &i_pointLightColour, const D3DCOLOR &i_pointLightAmbient, const D3DXVECTOR3 &i_pointLightPosition,
	const float &i_pointLightIntensity, const float &i_pointLightRadius )
{
	Utilities::StringHash emptyHash = Utilities::StringHash( "" );

	std::map<Utilities::StringHash, S_ENTITY>::const_iterator entityIterator;
	std::map<Utilities::StringHash, S_EFFECT>::const_iterator effectIterator;
	std::map<Utilities::StringHash, S_FRAGMENT_SHADER>::const_iterator fragmentShaderIterator;
	std::map<Utilities::StringHash, S_MATERIAL>::const_iterator materialIterator;
	std::map<Utilities::StringHash, S_VERTEX_SHADER>::const_iterator vertexShaderIterator;
	std::map<Utilities::StringHash, S_MESH>::const_iterator meshIterator;
	std::map<Utilities::StringHash, IDirect3DTexture9*>::const_iterator textureIterator;
	std::map<Utilities::StringHash, IDirect3DTexture9*>::const_iterator normalMapTextureIterator;

	Utilities::StringHash prevEntityFile = emptyHash;
	Utilities::StringHash prevMaterialFile = emptyHash;
	Utilities::StringHash prevEffectFile = emptyHash;
	Utilities::StringHash prevMeshFile = emptyHash;
	Utilities::StringHash prevFragmentShaderFile = emptyHash;
	Utilities::StringHash prevVertexShaderFile = emptyHash;
	Utilities::StringHash prevTextureFile = emptyHash;

#ifdef _DEBUG
	D3DPERF_BeginEvent( 0 , L"Render 3D objects" );
#endif	// #ifdef _DEBUG

	// Draw 3D model
	if( i_entitiesToDraw.size() > 0 )
	{
		if( !g_mainRenderer::Get().SetNormalMapVertexDeclaration() )
			return;
	}

	for( std::vector<S_ENTITY_TO_DRAW>::const_iterator iter = i_entitiesToDraw.begin(); iter != i_entitiesToDraw.end(); iter++ )
	{
		// Get and set the correct data for this entity
		if( prevEntityFile != iter->entity )
		{
			prevEntityFile = iter->entity;
			if( !SET_REQUIRED_ITERATOR(entityIterator, iter->entity, entityDatabase) )
				continue;
		}

		// Get and set the correct data for this entity's material
		if( prevMaterialFile != entityIterator->second.materialFile )
		{
			if( !SET_REQUIRED_ITERATOR(materialIterator, entityIterator->second.materialFile, materialDatabase) )
				continue;
		}

		// Get and set the correct data for this entity's effect
		if( prevEffectFile != materialIterator->second.effectFile )
		{
			prevEffectFile = materialIterator->second.effectFile;
			if( !SET_REQUIRED_ITERATOR(effectIterator, materialIterator->second.effectFile, effectDatabase) )
				continue;
		}

		// Get and set the correct data for this entity's mesh
		if( prevMeshFile != entityIterator->second.meshFile )
		{
			prevMeshFile = entityIterator->second.meshFile;
			if( !SET_REQUIRED_ITERATOR(meshIterator, entityIterator->second.meshFile, meshDatabase) )
				continue;
		}

		// Get and set the correct data for this entity's fragment shader
		if( prevFragmentShaderFile != effectIterator->second.fragmentShaderFile )
		{
			if( !SET_REQUIRED_ITERATOR(fragmentShaderIterator, effectIterator->second.fragmentShaderFile, fragmentShaderDatabase) )
				continue;
		}

		// Get and set the correct data for this entity's vertex shader
		if( prevVertexShaderFile != effectIterator->second.vertexShaderFile )
		{
			if( !SET_REQUIRED_ITERATOR(vertexShaderIterator, effectIterator->second.vertexShaderFile, vertexShaderDatabase) )
				continue;
		}

		// Get and set the correct data for this entity's texture
		if( (prevTextureFile != materialIterator->second.textureFile) && (materialIterator->second.textureFile != emptyHash) )
		{
			if( !SET_REQUIRED_ITERATOR(textureIterator, materialIterator->second.textureFile, textureDatabase) )
				continue;
		}

		// Get and set the correct data for this entity's texture
		if( effectIterator->second.u8TextureMode & NORMAL_MAP )
		{
			if( !SET_REQUIRED_ITERATOR(normalMapTextureIterator, materialIterator->second.normalMapTexture, normalMapTextureDatabase) )
				continue;
		}

		if( prevVertexShaderFile != effectIterator->second.vertexShaderFile )
		{
			prevVertexShaderFile = effectIterator->second.vertexShaderFile;

			Setter::SetVertexShader( vertexShaderIterator->second.compiledShader, vertexShaderIterator->second.constantTable,
				TRUE, i_cameraWorldToViewTransform, i_cameraViewToProjectedTransform,
				i_directionalLightWorldToViewTransform, i_directionalLightViewToProjectedTransform );
		}

		if( prevFragmentShaderFile != effectIterator->second.fragmentShaderFile )
		{
		#ifdef _DEBUG
			D3DPERF_BeginEvent( 0 , L"Fragment shader" );
		#endif	// #ifdef _DEBUG
			prevFragmentShaderFile = effectIterator->second.fragmentShaderFile;

			Setter::SetFragmentShader( fragmentShaderIterator->second.compiledShader );
			Setter::SetDirectionalLight( fragmentShaderIterator->second.constantTable,
				i_directionalLightDirection, i_directionalLightColour, i_directionalLightIntensity, i_directionalLightFarView );
			Setter::SetPointLight( fragmentShaderIterator->second.constantTable, i_pointLightPosition, i_pointLightColour, i_pointLightAmbient,
				i_pointLightIntensity, i_pointLightRadius );
			Setter::SetCamera( fragmentShaderIterator->second.constantTable, i_cameraPosition, i_cameraFarView );
		#ifdef _DEBUG
			D3DPERF_EndEvent();
		#endif	// #ifdef _DEBUG
		}

		if( prevMaterialFile != entityIterator->second.materialFile )
		{
		#ifdef _DEBUG
			D3DPERF_BeginEvent( 0, L"Material" );
		#endif// #ifdef _DEBUG
			prevMaterialFile = entityIterator->second.materialFile;

			if( (prevTextureFile != materialIterator->second.textureFile) && (materialIterator->second.textureFile != emptyHash) )
			{
				prevTextureFile = materialIterator->second.textureFile;
				Setter::SetTexture( textureIterator->second, fragmentShaderIterator->second.constantTable );
			}
			if( effectIterator->second.u8TextureMode & NORMAL_MAP )
				Setter::SetNormalMap( normalMapTextureIterator->second, fragmentShaderIterator->second.constantTable );
		#ifdef _DEBUG
			D3DPERF_EndEvent();
		#endif	// #ifdef _DEBUG
		}

	#ifdef _DEBUG
		D3DPERF_BeginEvent( 0, L"Entity" );
	#endif// #ifdef _DEBUG
		Setter::SetModelToWorldTransformation( vertexShaderIterator->second.constantTable,
			iter->position, iter->scale, iter->orientation );

		Setter::SetVertexBuffer( meshIterator->second.vertexBuffer, sizeof(Utilities::S_NORMAL_MAP_VERTEX_DATA) );
		Setter::SetIndexBuffer( meshIterator->second.indexBuffer );

		// Render objects from the current streams
		{
			// We are using triangles as the "primitive" type,
			// and we have defined the vertex buffer as a triangle list
			// (meaning that every triangle is defined by three vertices)
			D3DPRIMITIVETYPE primitiveType = D3DPT_TRIANGLELIST;
			// It's possible to start rendering primitives in the middle of the stream
			unsigned int indexOfFirstVertexToRender = 0;
			// We are currently only rendering a single triangle
			unsigned int primitiveCountToRender = meshIterator->second.u32PrimitiveCount;
			unsigned int startIndex = 0;
			//HRESULT result = direct3dDevice->DrawPrimitive( primitiveType, indexOfFirstVertexToRender, primitiveCountToRender );
			HRESULT result = g_mainRenderer::Get().GetDirect3dDevice()->DrawIndexedPrimitive( primitiveType, indexOfFirstVertexToRender,
				0, meshIterator->second.u32VertexCount, startIndex, primitiveCountToRender );
			assert( SUCCEEDED(result) );
		}
	#ifdef _DEBUG
		D3DPERF_EndEvent();
	#endif	// #ifdef _DEBUG
	}

	// Set the basic vertex declaration
	if( (i_linesToDraw.size() > 0) || (i_sphereToDraw.size() > 0) )
	{
		if( !g_mainRenderer::Get().SetBasicVertexDeclaration() )
			return;
	}

	// Draw Line
	if( i_linesToDraw.size() > 0 )
	{
		bool bErrorFound = false;

		if( !SET_REQUIRED_ITERATOR(fragmentShaderIterator, g_line::Get().m_hashedFragmentShader, fragmentShaderDatabase) )
			bErrorFound = true;

		if( !SET_REQUIRED_ITERATOR(vertexShaderIterator, g_line::Get().m_hashedVertexShader, vertexShaderDatabase) )
			bErrorFound = true;

		if( !bErrorFound )
		{
			Setter::SetVertexShader( vertexShaderIterator->second.compiledShader, vertexShaderIterator->second.constantTable,
			TRUE, i_cameraWorldToViewTransform, i_cameraViewToProjectedTransform,
			i_directionalLightWorldToViewTransform, i_directionalLightViewToProjectedTransform );

		#ifdef _DEBUG
			D3DPERF_BeginEvent( 0 , L"Fragment shader" );
		#endif	// #ifdef _DEBUG
			Setter::SetFragmentShader( fragmentShaderIterator->second.compiledShader );
		#ifdef _DEBUG
			D3DPERF_EndEvent();
		#endif	// #ifdef _DEBUG

			for( std::vector<S_LINE_TO_DRAW>::const_iterator iter = i_linesToDraw.begin(); iter != i_linesToDraw.end(); ++iter )
			{
			#ifdef _DEBUG
				D3DPERF_BeginEvent( 0, L"Entity" );
			#endif// #ifdef _DEBUG
				g_line::Get().LoadVertexBuffer( (*iter) );
				Setter::SetModelToWorldTransformation( vertexShaderIterator->second.constantTable );

				g_line::Get().Draw();
			#ifdef _DEBUG
				D3DPERF_EndEvent();
			#endif	// #ifdef _DEBUG
			}
		}
	}

	// Draw sphere
	if( i_sphereToDraw.size() > 0 )
	{
		bool bErrorFound = false;

		g_mainRenderer::Get().GetDirect3dDevice()->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );

		if( !SET_REQUIRED_ITERATOR(fragmentShaderIterator, g_line::Get().m_hashedFragmentShader, fragmentShaderDatabase) )
			bErrorFound = true;

		if( !SET_REQUIRED_ITERATOR(vertexShaderIterator, g_line::Get().m_hashedVertexShader, vertexShaderDatabase) )
			bErrorFound = true;

		if( !bErrorFound )
		{
			Setter::SetVertexShader( vertexShaderIterator->second.compiledShader, vertexShaderIterator->second.constantTable,
				TRUE, i_cameraWorldToViewTransform, i_cameraViewToProjectedTransform,
				i_directionalLightWorldToViewTransform, i_directionalLightViewToProjectedTransform );

#ifdef _DEBUG
			D3DPERF_BeginEvent( 0 , L"Fragment shader" );
#endif	// #ifdef _DEBUG
			Setter::SetFragmentShader( fragmentShaderIterator->second.compiledShader );
#ifdef _DEBUG
			D3DPERF_EndEvent();
#endif	// #ifdef _DEBUG

			for( std::vector<S_SPHERE_TO_DRAW>::const_iterator iter = i_sphereToDraw.begin(); iter != i_sphereToDraw.end(); ++iter )
			{
#ifdef _DEBUG
				D3DPERF_BeginEvent( 0, L"Entity" );
#endif// #ifdef _DEBUG
				//g_sphere::Get().LoadVertexBuffer( (*iter) );
				float scale = iter->radius / Utilities::DEFAULT_DEBUG_SPHERE_RADIUS;
				Setter::SetModelToWorldTransformation( vertexShaderIterator->second.constantTable,
					iter->centre, D3DXVECTOR3(scale, scale, scale), 0.0f );

				g_sphere::Get().Draw();
#ifdef _DEBUG
				D3DPERF_EndEvent();
#endif	// #ifdef _DEBUG
			}
		}
		g_mainRenderer::Get().GetDirect3dDevice()->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
	}

#ifdef _DEBUG
	D3DPERF_EndEvent();
#endif	// #ifdef _DEBUG
}
Beispiel #25
0
void DebugAnnotator9::beginEvent(const wchar_t *eventName)
{
    D3DPERF_BeginEvent(0, eventName);
}
/**
 ****************************************************************************************************
	\fn			void Draw2D( const std::vector<S_QUAD_TO_DRAW> &i_quadsToDraw, const std::vector<S_TEXT_TO_DRAW> &i_textToDraw )
	\brief		Draw the 2D objects of the scene
	\param		i_quadsToDraw the quads to be drawn
	\param		i_textToDraw the text to be drawn
	\return		NONE
 ****************************************************************************************************
*/
void RendererEngine::Draw2D( const std::vector<S_QUAD_TO_DRAW> &i_quadsToDraw, const std::vector<S_TEXT_TO_DRAW> &i_textToDraw )
{
	Utilities::StringHash emptyHash = Utilities::StringHash( "" );
	std::map<Utilities::StringHash, S_ENTITY>::const_iterator entityIterator;
	std::map<Utilities::StringHash, S_EFFECT>::const_iterator effectIterator;
	std::map<Utilities::StringHash, S_FRAGMENT_SHADER>::const_iterator fragmentShaderIterator;
	std::map<Utilities::StringHash, S_MATERIAL>::const_iterator materialIterator;
	std::map<Utilities::StringHash, S_VERTEX_SHADER>::const_iterator vertexShaderIterator;
	std::map<Utilities::StringHash, S_MESH>::const_iterator meshIterator;
	std::map<Utilities::StringHash, IDirect3DTexture9*>::const_iterator textureIterator;

#ifdef _DEBUG
	D3DPERF_BeginEvent( 0 , L"Render 2D objects" );
#endif	// #ifdef _DEBUG

	// Set the basic vertex declaration
	if( i_quadsToDraw.size() > 0 )
	{
		if( !g_mainRenderer::Get().SetBasicVertexDeclaration() )
			return;
	}

	// Draw quad
	if( i_quadsToDraw.size() > 0 )
	{
		bool bErrorFound = false;

		if( !SET_REQUIRED_ITERATOR(vertexShaderIterator, g_quad::Get().m_hashedVertexShader, vertexShaderDatabase) )
			bErrorFound = true;

		if( !SET_REQUIRED_ITERATOR(fragmentShaderIterator, g_quad::Get().m_hashedFragmentShader, fragmentShaderDatabase) )
			bErrorFound = true;

		if( !bErrorFound )
		{
			Setter::SetVertexShader( vertexShaderIterator->second.compiledShader );

		#ifdef _DEBUG
			D3DPERF_BeginEvent( 0 , L"Fragment shader" );
		#endif	// #ifdef _DEBUG
			Setter::SetFragmentShader( fragmentShaderIterator->second.compiledShader );
		#ifdef _DEBUG
			D3DPERF_EndEvent();
		#endif	// #ifdef _DEBUG

			for( std::vector<S_QUAD_TO_DRAW>::const_iterator iter = i_quadsToDraw.begin(); iter != i_quadsToDraw.end(); iter++ )
			{
				if( iter->texture != emptyHash )
				{
					Setter::SetTextureUsage( true, fragmentShaderIterator->second.constantTable );

					if( !SET_REQUIRED_ITERATOR(textureIterator, iter->texture, textureDatabase) )
						continue;

				#ifdef _DEBUG
					D3DPERF_BeginEvent( 0, L"Material" );
				#endif// #ifdef _DEBUG
					Setter::SetTexture( textureIterator->second, fragmentShaderIterator->second.constantTable );
				#ifdef _DEBUG
					D3DPERF_EndEvent();
				#endif	// #ifdef _DEBUG
				}
				else
					Setter::SetTextureUsage( false, fragmentShaderIterator->second.constantTable );

				Setter::SetSize( vertexShaderIterator->second.constantTable, iter->size );
				Setter::SetPosition( vertexShaderIterator->second.constantTable, iter->position );

				g_quad::Get().LoadVertexBuffer( iter->colour );
				g_quad::Get().Draw();
			}
		}
	}

	// Text


	if( i_textToDraw.size() > 0 )
	{
		g_text::Get().BeginText();
		for( UINT8 i = 0; i < i_textToDraw.size(); ++i )
		{
			g_text::Get().Draw( i_textToDraw[i] );
		}
		g_text::Get().EndText();
	}

#ifdef _DEBUG
	D3DPERF_EndEvent();
#endif	// #ifdef _DEBUG
}
Beispiel #27
0
	void Graphics::Render()
	{
		// Every frame an entirely new image will be created.
		// Before drawing anything, then, the previous image will be erased
		// by "clearing" the image buffer (filling it with a solid color)
		{
			const D3DRECT* subRectanglesToClear = NULL;
			const DWORD subRectangleCount = 0;
			const DWORD clearColorAndDepth = D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER;
			const D3DCOLOR colorToClear = D3DCOLOR_XRGB(0, 0, 0);
			const float depthToClear = 1.0f;
			const DWORD noStencilBuffer = 0;
			HRESULT result = s_direct3dDevice->Clear(subRectangleCount, subRectanglesToClear,
				clearColorAndDepth, colorToClear, depthToClear, noStencilBuffer);
			assert(SUCCEEDED(result));
		}

		// The actual function calls that draw geometry must be made between paired calls to
		// BeginScene() and EndScene()
		{
		HRESULT result = s_direct3dDevice->BeginScene();
		assert(SUCCEEDED(result));
		{
			{
#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
				D3DPERF_BeginEvent(0, L"Mesh Rendering");
#endif
				
				float values_light_dirn[3] = { posn_x_light, posn_y_light, posn_z_light };
				default_material->SetLight(values_light_dirn);
				//debug_menu->Render();
				for (unsigned int i = 0; i < mesh_array->size(); i++)
				{
					Mesh *currMesh = (Mesh *)mesh_array->at(i);
					currMesh->Render();
				}
				
				mainCamera_->SetCamera();
#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
				D3DPERF_EndEvent();
#endif
#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
				D3DPERF_BeginEvent(0, L"Font Rendering");
#endif
				//g_font->Render();


				defaultText->m_string = "Default_2";
#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
				D3DPERF_EndEvent();
#endif

#ifdef _DEBUG
				if (debug_menu->isDebugEnabled_)
				{
#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
					D3DPERF_BeginEvent(0, L"Debug Rendering");
#endif
					for (unsigned int i = 0; i < debugLine_array->size(); i++)
					{
						DebugLine *currDebugLine = (DebugLine *)debugLine_array->at(i);
						currDebugLine->Render();
					}
#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
					D3DPERF_BeginEvent(0, L"Debug Mesh Rendering");
#endif
					s_direct3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
					for (unsigned int i = 0; i < debug_mesh_array->size(); i++)
					{
						Mesh *currMesh = (Mesh *)debug_mesh_array->at(i);
						currMesh->Render();
					}
					debug_menu->Render();
					s_direct3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
					D3DPERF_EndEvent();
#endif

#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
					D3DPERF_EndEvent();
#endif

				}
#endif

#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
				D3DPERF_BeginEvent(0, L"Sprite Rendering");
#endif
				
				for (unsigned int i = 0; i < sprite_array->size(); i++)
				{
					Sprite *currSprite = (Sprite *)sprite_array->at(i);
					currSprite->Render();
				}

				
#ifdef EAE6320_GRAPHICS_AREPIXEVENTSENABLED
				D3DPERF_EndEvent();
#endif
			}
		}
		result = s_direct3dDevice->EndScene();
		assert(SUCCEEDED(result));
	}

		char buf[2048];
		sprintf_s(buf, "test_value: %f\n", mainCamera_->camSpeed);
		//OutputDebugString(buf);
		// Everything has been drawn to the "back buffer", which is just an image in memory.
		// In order to display it, the contents of the back buffer must be "presented"
		// (to the front buffer)
		{
			const RECT* noSourceRectangle = NULL;
			const RECT* noDestinationRectangle = NULL;
			const HWND useDefaultWindow = NULL;
			const RGNDATA* noDirtyRegion = NULL;
			HRESULT result = s_direct3dDevice->Present(noSourceRectangle, noDestinationRectangle, useDefaultWindow, noDirtyRegion);
			if (ResetCamera_)
			{
				ResetCamera_ = false;
				mainCamera_->ResetCamera();
			}
			assert(SUCCEEDED(result));
		}
	}
Beispiel #28
0
int
main(int argc, char *argv[])
{
    HRESULT hr;

    HINSTANCE hInstance = GetModuleHandle(NULL);

    WNDCLASSEX wc = {
        sizeof(WNDCLASSEX),
        CS_CLASSDC,
        DefWindowProc,
        0,
        0,
        hInstance,
        NULL,
        NULL,
        NULL,
        NULL,
        "SimpleDX10",
        NULL
    };
    RegisterClassEx(&wc);

    const int WindowWidth = 250;
    const int WindowHeight = 250;
    BOOL Windowed = TRUE;

    DWORD dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW;

    RECT rect = {0, 0, WindowWidth, WindowHeight};
    AdjustWindowRect(&rect, dwStyle, FALSE);

    HWND hWnd = CreateWindow(wc.lpszClassName,
                             "Simple example using DirectX10",
                             dwStyle,
                             CW_USEDEFAULT, CW_USEDEFAULT,
                             rect.right - rect.left,
                             rect.bottom - rect.top,
                             NULL,
                             NULL,
                             hInstance,
                             NULL);
    if (!hWnd) {
        return 1;
    }

    UINT Flags = 0;
    hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_NULL, 0, D3D11_CREATE_DEVICE_DEBUG, NULL, 0, D3D11_SDK_VERSION, NULL, NULL, NULL);
    if (SUCCEEDED(hr)) {
        Flags |= D3D11_CREATE_DEVICE_DEBUG;
    }

    DXGI_SWAP_CHAIN_DESC SwapChainDesc;
    ZeroMemory(&SwapChainDesc, sizeof SwapChainDesc);
    SwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;;
    SwapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
    SwapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
    SwapChainDesc.SampleDesc.Quality = 0;
    SwapChainDesc.SampleDesc.Count = 1;
    SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    SwapChainDesc.BufferCount = 2;
    SwapChainDesc.OutputWindow = hWnd;
    SwapChainDesc.Windowed = true;
    SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;

    static const D3D_FEATURE_LEVEL FeatureLevels[] = {
        D3D_FEATURE_LEVEL_11_0,
        D3D_FEATURE_LEVEL_10_1,
        D3D_FEATURE_LEVEL_10_0
    };

    com_ptr<ID3D11Device> pDevice;
    com_ptr<ID3D11DeviceContext> pDeviceContext;
    com_ptr<IDXGISwapChain> pSwapChain;
    hr = D3D11CreateDeviceAndSwapChain(NULL, /* pAdapter */
                                       D3D_DRIVER_TYPE_HARDWARE,
                                       NULL, /* Software */
                                       Flags,
                                       FeatureLevels,
                                       sizeof FeatureLevels / sizeof FeatureLevels[0],
                                       D3D11_SDK_VERSION,
                                       &SwapChainDesc,
                                       &pSwapChain,
                                       &pDevice,
                                       NULL, /* pFeatureLevel */
                                       &pDeviceContext); /* ppImmediateContext */
    if (FAILED(hr)) {
        return 1;
    }

    D3DPERF_SetMarker(D3DCOLOR_XRGB(128, 128, 128), L"Marker");

    setObjectName(pDevice, "Device");

    com_ptr<ID3D11Texture2D> pBackBuffer;
    hr = pSwapChain->GetBuffer(0, IID_ID3D11Texture2D, (void **)&pBackBuffer);
    if (FAILED(hr)) {
        return 1;
    }

    setObjectName(pBackBuffer, "BackBuffer");

    D3D11_RENDER_TARGET_VIEW_DESC RenderTargetViewDesc;
    ZeroMemory(&RenderTargetViewDesc, sizeof RenderTargetViewDesc);
    RenderTargetViewDesc.Format = SwapChainDesc.BufferDesc.Format;
    RenderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
    RenderTargetViewDesc.Texture2D.MipSlice = 0;

    com_ptr<ID3D11RenderTargetView> pRenderTargetView;
    hr = pDevice->CreateRenderTargetView(pBackBuffer, &RenderTargetViewDesc, &pRenderTargetView);
    if (FAILED(hr)) {
        return 1;
    }

    ID3D11RenderTargetView *pRenderTargetViews[1] = { pRenderTargetView };
    pDeviceContext->OMSetRenderTargets(_countof(pRenderTargetViews), pRenderTargetViews, NULL);

    D3DPERF_BeginEvent(D3DCOLOR_XRGB(128, 128, 128), L"Frame");

    D3DPERF_BeginEvent(D3DCOLOR_XRGB(128, 128, 128), L"Clear");
    const float clearColor[4] = { 0.3f, 0.1f, 0.3f, 1.0f };
    pDeviceContext->ClearRenderTargetView(pRenderTargetView, clearColor);
    D3DPERF_EndEvent(); // Clear

    com_ptr<ID3D11VertexShader> pVertexShader;
    hr = pDevice->CreateVertexShader(g_VS, sizeof g_VS, NULL, &pVertexShader);
    if (FAILED(hr)) {
        return 1;
    }

    struct Vertex {
        float position[4];
        float color[4];
    };

    static const D3D11_INPUT_ELEMENT_DESC InputElementDescs[] = {
        { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(Vertex, position), D3D11_INPUT_PER_VERTEX_DATA, 0 },
        { "COLOR",    0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, offsetof(Vertex, color),    D3D11_INPUT_PER_VERTEX_DATA, 0 }
    };

    com_ptr<ID3D11InputLayout> pVertexLayout;
    hr = pDevice->CreateInputLayout(InputElementDescs,
                                    2,
                                    g_VS, sizeof g_VS,
                                    &pVertexLayout);
    if (FAILED(hr)) {
        return 1;
    }

    pDeviceContext->IASetInputLayout(pVertexLayout);

    com_ptr<ID3D11PixelShader> pPixelShader;
    hr = pDevice->CreatePixelShader(g_PS, sizeof g_PS, NULL, &pPixelShader);
    if (FAILED(hr)) {
        return 1;
    }

    pDeviceContext->VSSetShader(pVertexShader, NULL, 0);
    pDeviceContext->PSSetShader(pPixelShader, NULL, 0);

    static const Vertex vertices[] = {
        { { -0.9f, -0.9f, 0.5f, 1.0f}, { 0.8f, 0.0f, 0.0f, 0.1f } },
        { {  0.9f, -0.9f, 0.5f, 1.0f}, { 0.0f, 0.9f, 0.0f, 0.1f } },
        { {  0.0f,  0.9f, 0.5f, 1.0f}, { 0.0f, 0.0f, 0.7f, 0.1f } },
    };

    D3D11_BUFFER_DESC BufferDesc;
    ZeroMemory(&BufferDesc, sizeof BufferDesc);
    BufferDesc.Usage = D3D11_USAGE_DYNAMIC;
    BufferDesc.ByteWidth = sizeof vertices;
    BufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
    BufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    BufferDesc.MiscFlags = 0;

    D3D11_SUBRESOURCE_DATA BufferData;
    BufferData.pSysMem = vertices;
    BufferData.SysMemPitch = 0;
    BufferData.SysMemSlicePitch = 0;

    com_ptr<ID3D11Buffer> pVertexBuffer;
    hr = pDevice->CreateBuffer(&BufferDesc, &BufferData, &pVertexBuffer);
    if (FAILED(hr)) {
        return 1;
    }

    ID3D11Buffer *pVertexBuffers[1] = { pVertexBuffer };
    UINT Stride = sizeof(Vertex);
    UINT Offset = 0;
    pDeviceContext->IASetVertexBuffers(0, _countof(pVertexBuffers), pVertexBuffers, &Stride, &Offset);

    D3D11_VIEWPORT ViewPort;
    ViewPort.TopLeftX = 0;
    ViewPort.TopLeftY = 0;
    ViewPort.Width = WindowWidth;
    ViewPort.Height = WindowHeight;
    ViewPort.MinDepth = 0.0f;
    ViewPort.MaxDepth = 1.0f;
    pDeviceContext->RSSetViewports(1, &ViewPort);

    D3D11_RASTERIZER_DESC RasterizerDesc;
    ZeroMemory(&RasterizerDesc, sizeof RasterizerDesc);
    RasterizerDesc.CullMode = D3D11_CULL_NONE;
    RasterizerDesc.FillMode = D3D11_FILL_SOLID;
    RasterizerDesc.FrontCounterClockwise = true;
    RasterizerDesc.DepthClipEnable = true;
    com_ptr<ID3D11RasterizerState> pRasterizerState;
    hr = pDevice->CreateRasterizerState(&RasterizerDesc, &pRasterizerState);
    if (FAILED(hr)) {
        return 1;
    }
    pDeviceContext->RSSetState(pRasterizerState);

    pDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);

    D3DPERF_BeginEvent(D3DCOLOR_XRGB(128, 128, 128), L"Draw");
    pDeviceContext->Draw(3, 0);
    D3DPERF_EndEvent(); // Draw

    D3DPERF_EndEvent(); // Frame

    pSwapChain->Present(0, 0);


    ID3D11Buffer *pNullBuffer = NULL;
    UINT NullStride = 0;
    UINT NullOffset = 0;
    pDeviceContext->IASetVertexBuffers(0, 1, &pNullBuffer, &NullStride, &NullOffset);

    pDeviceContext->OMSetRenderTargets(0, NULL, NULL);

    pDeviceContext->IASetInputLayout(NULL);

    pDeviceContext->VSSetShader(NULL, NULL, 0);

    pDeviceContext->PSSetShader(NULL, NULL, 0);

    pDeviceContext->RSSetState(NULL);

    DestroyWindow(hWnd);

    return 0;
}
void PostProcessorBase::PostProcess(ID3D11PixelShader* pixelShader, const wchar* name)
{
    Assert_(context);

    Assert_(inputs.size() <= MaxInputs);

    D3DPERF_BeginEvent(0xFFFFFFFF, name);

    // Set the outputs
    ID3D11RenderTargetView** renderTargets = reinterpret_cast<ID3D11RenderTargetView**>(&outputs[0]);
    uint32 numRTs = static_cast<uint32>(outputs.size());
    if(uaViews.size() == 0)
        context->OMSetRenderTargets(numRTs, renderTargets, nullptr);
    else
    {
        ID3D11UnorderedAccessView** uavs = reinterpret_cast<ID3D11UnorderedAccessView**>(&uaViews[0]);
        UINT numUAVs = static_cast<uint32>(uaViews.size());
        UINT initialCounts[D3D11_PS_CS_UAV_REGISTER_COUNT] = { 0 };
        context->OMSetRenderTargetsAndUnorderedAccessViews(numRTs, renderTargets, nullptr, numRTs, numUAVs, uavs, initialCounts);
    }

    // Set the input textures
    ID3D11ShaderResourceView** textures = reinterpret_cast<ID3D11ShaderResourceView**>(&inputs[0]);
    context->PSSetShaderResources(0, static_cast<uint32>(inputs.size()), textures);

    // Set the constants
    D3D11_MAPPED_SUBRESOURCE mapped;
    DXCall(context->Map(psConstants, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped));
    PSConstants* constants = reinterpret_cast<PSConstants*>(mapped.pData);

    for (size_t i = 0; i < inputs.size(); ++i)
    {
        if(inputs[i] == nullptr)
        {
            constants->InputSize[i].x = 0.0f;
            constants->InputSize[i].y = 0.0f;
            continue;
        }

        ID3D11Resource* resource;
        ID3D11Texture2DPtr texture;
        D3D11_TEXTURE2D_DESC desc;
        D3D11_SHADER_RESOURCE_VIEW_DESC srDesc;
        inputs[i]->GetDesc(&srDesc);
        uint32 mipLevel = srDesc.Texture2D.MostDetailedMip;
        inputs[i]->GetResource(&resource);
        texture.Attach(reinterpret_cast<ID3D11Texture2D*>(resource));
        texture->GetDesc(&desc);
        constants->InputSize[i].x = static_cast<float>(std::max<uint32>(desc.Width / (1 << mipLevel), 1));
        constants->InputSize[i].y = static_cast<float>(std::max<uint32>(desc.Height / (1 << mipLevel), 1));
    }

    ID3D11Resource* resource;
    ID3D11Texture2DPtr texture;
    D3D11_TEXTURE2D_DESC desc;
    D3D11_RENDER_TARGET_VIEW_DESC rtDesc;
    outputs[0]->GetResource(&resource);
    outputs[0]->GetDesc(&rtDesc);
    uint32 mipLevel = rtDesc.Texture2D.MipSlice;
    texture.Attach(reinterpret_cast<ID3D11Texture2D*>(resource));
    texture->GetDesc(&desc);
    constants->OutputSize.x = static_cast<float>(std::max<uint32>(desc.Width / (1 << mipLevel), 1));
    constants->OutputSize.y = static_cast<float>(std::max<uint32>(desc.Height / (1 << mipLevel), 1));

    context->Unmap(psConstants, 0);

    ID3D11Buffer* constantBuffers[1] = { psConstants };
    context->PSSetConstantBuffers(0, 1, constantBuffers);

    // Set the viewports
    D3D11_VIEWPORT viewports[16];
    for (UINT_PTR i = 0; i < 16; ++i)
    {
        viewports[i].Width = static_cast<float>(std::max<uint32>(desc.Width / (1 << mipLevel), 1));
        viewports[i].Height = static_cast<float>(std::max<uint32>(desc.Height / (1 << mipLevel), 1));
        viewports[i].TopLeftX = 0;
        viewports[i].TopLeftY = 0;
        viewports[i].MinDepth = 0.0f;
        viewports[i].MaxDepth = 1.0f;
    }
    context->RSSetViewports(static_cast<uint32>(outputs.size()), viewports);

    // Set the pixel shader
    context->PSSetShader(pixelShader, nullptr, 0);

    // Draw the quad
    context->DrawIndexed(6, 0, 0);

    // Clear the SRV's and RT's
    ID3D11ShaderResourceView* srViews[16] = { nullptr };
    context->PSSetShaderResources(0, static_cast<uint32>(inputs.size()), srViews);

    ID3D11RenderTargetView* rtViews[16] = { nullptr };
    context->OMSetRenderTargets(static_cast<uint32>(outputs.size() + uaViews.size()), rtViews, nullptr);

    inputs.clear();
    outputs.clear();
    uaViews.clear();

    texture = nullptr;
    D3DPERF_EndEvent();
}
Beispiel #30
0
 void beginEvent(const std::wstring &eventName)
 {
     D3DPERF_BeginEvent(0, eventName.c_str());
 }