MCPcopy Create free account
hub / github.com/Aleksoid1978/VideoRenderer / FinalPass

Method FinalPass

Source/DX9VideoProcessor.cpp:2544–2598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2542}
2543
2544HRESULT CDX9VideoProcessor::FinalPass(IDirect3DTexture9* pTexture, IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& dstRect)
2545{
2546 HRESULT hr = m_pD3DDevEx->SetRenderTarget(0, pRenderTarget);
2547
2548 D3DSURFACE_DESC desc;
2549 if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
2550 return E_FAIL;
2551 }
2552
2553 const float w = (float)desc.Width;
2554 const float h = (float)desc.Height;
2555 const float dx = 1.0f / w;
2556 const float dy = 1.0f / h;
2557
2558 MYD3DVERTEX<1> v[] = {
2559 { {(float)dstRect.left - 0.5f, (float)dstRect.top - 0.5f, 0.5f, 2.0f}, {{srcRect.left * dx, srcRect.top * dy}} },
2560 { {(float)dstRect.right - 0.5f, (float)dstRect.top - 0.5f, 0.5f, 2.0f}, {{srcRect.right * dx, srcRect.top * dy}} },
2561 { {(float)dstRect.left - 0.5f, (float)dstRect.bottom - 0.5f, 0.5f, 2.0f}, {{srcRect.left * dx, srcRect.bottom * dy}} },
2562 { {(float)dstRect.right - 0.5f, (float)dstRect.bottom - 0.5f, 0.5f, 2.0f}, {{srcRect.right * dx, srcRect.bottom * dy}} },
2563 };
2564
2565 hr = m_pD3DDevEx->SetPixelShader(m_pPSFinalPass);
2566
2567 // Set sampler: image
2568 hr = m_pD3DDevEx->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
2569 hr = m_pD3DDevEx->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
2570 hr = m_pD3DDevEx->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
2571
2572 hr = m_pD3DDevEx->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
2573 hr = m_pD3DDevEx->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
2574
2575 hr = m_pD3DDevEx->SetTexture(0, pTexture);
2576
2577 // Set sampler: ditherMap
2578 hr = m_pD3DDevEx->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
2579 hr = m_pD3DDevEx->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_POINT);
2580 hr = m_pD3DDevEx->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
2581
2582 hr = m_pD3DDevEx->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
2583 hr = m_pD3DDevEx->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
2584
2585 hr = m_pD3DDevEx->SetTexture(1, m_TexDither.pTexture);
2586
2587 // Set constants
2588 float fConstData[][4] = {
2589 {w / dither_size, h / dither_size, 0.0f, 0.0f}
2590 };
2591 hr = m_pD3DDevEx->SetPixelShaderConstantF(0, (float*)fConstData, std::size(fConstData));
2592
2593 hr = TextureBlt(m_pD3DDevEx, v, D3DTEXF_POINT);
2594
2595 m_pD3DDevEx->SetTexture(1, nullptr);
2596
2597 return hr;
2598}
2599
2600void CDX9VideoProcessor::DrawSubtitles(IDirect3DSurface9* pRenderTarget)
2601{

Callers

nothing calls this directly

Calls 1

TextureBltFunction · 0.85

Tested by

no test coverage detected