| 330 | } |
| 331 | |
| 332 | HRESULT CDX11VideoProcessor::TextureResizeShader( |
| 333 | const Tex2D_t& Tex, ID3D11Texture2D* pRenderTarget, |
| 334 | const CRect& srcRect, const CRect& dstRect, |
| 335 | ID3D11PixelShader* pPixelShader, |
| 336 | const int iRotation, const bool bFlip) |
| 337 | { |
| 338 | CComPtr<ID3D11RenderTargetView> pRenderTargetView; |
| 339 | |
| 340 | HRESULT hr = m_pDevice->CreateRenderTargetView(pRenderTarget, nullptr, &pRenderTargetView); |
| 341 | if (FAILED(hr)) { |
| 342 | DLog(L"CDX11VideoProcessor::TextureResizeShader() : CreateRenderTargetView() failed with error {}", HR2Str(hr)); |
| 343 | return hr; |
| 344 | } |
| 345 | |
| 346 | hr = FillVertexBuffer(m_pDeviceContext, m_pVertexBuffer, Tex.desc.Width, Tex.desc.Height, srcRect, iRotation, bFlip); |
| 347 | if (FAILED(hr)) { |
| 348 | return hr; |
| 349 | } |
| 350 | |
| 351 | const FLOAT constants[][4] = { |
| 352 | {(float)Tex.desc.Width, (float)Tex.desc.Height, 1.0f / Tex.desc.Width, 1.0f / Tex.desc.Height}, |
| 353 | {(float)srcRect.Width() / dstRect.Width(), (float)srcRect.Height() / dstRect.Height(), 0, 0} |
| 354 | }; |
| 355 | |
| 356 | D3D11_MAPPED_SUBRESOURCE mr; |
| 357 | hr = m_pDeviceContext->Map(m_pResizeShaderConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mr); |
| 358 | if (FAILED(hr)) { |
| 359 | DLog(L"CDX11VideoProcessor::TextureResizeShader() : Map() failed with error {}", HR2Str(hr)); |
| 360 | return hr; |
| 361 | } |
| 362 | |
| 363 | memcpy(mr.pData, &constants, sizeof(constants)); |
| 364 | m_pDeviceContext->Unmap(m_pResizeShaderConstantBuffer, 0); |
| 365 | |
| 366 | D3D11_VIEWPORT VP; |
| 367 | VP.TopLeftX = (FLOAT)dstRect.left; |
| 368 | VP.TopLeftY = (FLOAT)dstRect.top; |
| 369 | VP.Width = (FLOAT)dstRect.Width(); |
| 370 | VP.Height = (FLOAT)dstRect.Height(); |
| 371 | VP.MinDepth = 0.0f; |
| 372 | VP.MaxDepth = 1.0f; |
| 373 | |
| 374 | TextureBlt11(m_pDeviceContext, pRenderTargetView, VP, m_pVSimpleInputLayout, m_pVS_Simple, pPixelShader, Tex.pShaderResource, m_pSamplerPoint, m_pResizeShaderConstantBuffer, m_pVertexBuffer); |
| 375 | |
| 376 | return hr; |
| 377 | } |
| 378 | |
| 379 | // CDX11VideoProcessor |
| 380 |
nothing calls this directly
no test coverage detected