Skip to content

Commit

Permalink
[d3d8] Clamp blocks per row to 1
Browse files Browse the repository at this point in the history
Avoids divide by zero for very tiny textures
  • Loading branch information
AlpyneDreams committed Feb 23, 2023
1 parent 5b02cf1 commit 51267ed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/d3d8/d3d8_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ namespace dxvk {
UINT rectHeightBlocks = ((rect.bottom-rect.top) / blockHeight);

// Compute bytes per block
UINT blocksPerRow = textureWidth / blockWidth;
UINT bytesPerBlock = lockPitch / blocksPerRow;
UINT blocksPerRow = std::max(textureWidth / blockWidth, 1u);
UINT bytesPerBlock = lockPitch / blocksPerRow;

return bytesPerBlock * (rectHeightBlocks * rectWidthBlocks);
}
Expand Down

0 comments on commit 51267ed

Please sign in to comment.