本文整理汇总了C++中EFBRectangle::ClampUL方法的典型用法代码示例。如果您正苦于以下问题:C++ EFBRectangle::ClampUL方法的具体用法?C++ EFBRectangle::ClampUL怎么用?C++ EFBRectangle::ClampUL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFBRectangle
的用法示例。
在下文中一共展示了EFBRectangle::ClampUL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Encode
size_t PSTextureEncoder::Encode(u8* dst, unsigned int dstFormat,
PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect,
bool isIntensity, bool scaleByHalf)
{
if (!m_ready) // Make sure we initialized OK
return 0;
// Clamp srcRect to 640x528. BPS: The Strike tries to encode an 800x600
// texture, which is invalid.
EFBRectangle correctSrc = srcRect;
correctSrc.ClampUL(0, 0, EFB_WIDTH, EFB_HEIGHT);
// Validate source rect size
if (correctSrc.GetWidth() <= 0 || correctSrc.GetHeight() <= 0)
return 0;
HRESULT hr;
unsigned int blockW = BLOCK_WIDTHS[dstFormat];
unsigned int blockH = BLOCK_HEIGHTS[dstFormat];
// Round up source dims to multiple of block size
unsigned int actualWidth = correctSrc.GetWidth() / (scaleByHalf ? 2 : 1);
actualWidth = (actualWidth + blockW-1) & ~(blockW-1);
unsigned int actualHeight = correctSrc.GetHeight() / (scaleByHalf ? 2 : 1);
actualHeight = (actualHeight + blockH-1) & ~(blockH-1);
unsigned int numBlocksX = actualWidth/blockW;
unsigned int numBlocksY = actualHeight/blockH;
unsigned int cacheLinesPerRow;
if (dstFormat == 0x6) // RGBA takes two cache lines per block; all others take one
cacheLinesPerRow = numBlocksX*2;
else
cacheLinesPerRow = numBlocksX;
_assert_msg_(VIDEO, cacheLinesPerRow*32 <= MAX_BYTES_PER_BLOCK_ROW, "cache lines per row sanity check");
unsigned int totalCacheLines = cacheLinesPerRow * numBlocksY;
_assert_msg_(VIDEO, totalCacheLines*32 <= MAX_BYTES_PER_ENCODE, "total encode size sanity check");
size_t encodeSize = 0;
// Reset API
g_renderer->ResetAPIState();
// Set up all the state for EFB encoding
{
D3D11_VIEWPORT vp = CD3D11_VIEWPORT(0.f, 0.f, FLOAT(cacheLinesPerRow * 8), FLOAT(numBlocksY));
D3D::context->RSSetViewports(1, &vp);
EFBRectangle fullSrcRect;
fullSrcRect.left = 0;
fullSrcRect.top = 0;
fullSrcRect.right = EFB_WIDTH;
fullSrcRect.bottom = EFB_HEIGHT;
TargetRectangle targetRect = g_renderer->ConvertEFBRectangle(fullSrcRect);
D3D::context->OMSetRenderTargets(1, &m_outRTV, nullptr);
ID3D11ShaderResourceView* pEFB = (srcFormat == PEControl::Z24) ?
FramebufferManager::GetResolvedEFBDepthTexture()->GetSRV() :
// FIXME: Instead of resolving EFB, it would be better to pick out a
// single sample from each pixel. The game may break if it isn't
// expecting the blurred edges around multisampled shapes.
FramebufferManager::GetResolvedEFBColorTexture()->GetSRV();
EFBEncodeParams params;
params.SrcLeft = correctSrc.left;
params.SrcTop = correctSrc.top;
params.DestWidth = actualWidth;
params.ScaleFactor = scaleByHalf ? 2 : 1;
D3D::context->UpdateSubresource(m_encodeParams, 0, nullptr, ¶ms, 0, 0);
D3D::stateman->SetPixelConstants(m_encodeParams);
// Use linear filtering if (bScaleByHalf), use point filtering otherwise
if (scaleByHalf)
D3D::SetLinearCopySampler();
else
D3D::SetPointCopySampler();
D3D::drawShadedTexQuad(pEFB,
targetRect.AsRECT(),
Renderer::GetTargetWidth(),
Renderer::GetTargetHeight(),
SetStaticShader(dstFormat, srcFormat, isIntensity, scaleByHalf),
VertexShaderCache::GetSimpleVertexShader(),
VertexShaderCache::GetSimpleInputLayout());
// Copy to staging buffer
D3D11_BOX srcBox = CD3D11_BOX(0, 0, 0, cacheLinesPerRow * 8, numBlocksY, 1);
D3D::context->CopySubresourceRegion(m_outStage, 0, 0, 0, 0, m_out, 0, &srcBox);
// Transfer staging buffer to GameCube/Wii RAM
D3D11_MAPPED_SUBRESOURCE map = { 0 };
hr = D3D::context->Map(m_outStage, 0, D3D11_MAP_READ, 0, &map);
CHECK(SUCCEEDED(hr), "map staging buffer (0x%x)", hr);
u8* src = (u8*)map.pData;
for (unsigned int y = 0; y < numBlocksY; ++y)
//.........这里部分代码省略.........