-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tweak maxMipLevelCount signature, move standardizeExtent3D inside
- Loading branch information
Showing
2 changed files
with
15 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
export function maxMipLevelCount( | ||
size: GPUExtent3DDict, | ||
dimension: GPUTextureDimension | undefined | ||
): number { | ||
let maxMippedDimension = size.width; | ||
if (dimension !== '1d') maxMippedDimension = Math.max(maxMippedDimension, size.height); | ||
if (dimension === '3d') maxMippedDimension = Math.max(maxMippedDimension, size.depth); | ||
import { standardizeExtent3D } from '../../util/unions.js'; | ||
|
||
export function maxMipLevelCount({ | ||
size, | ||
dimension = '2d', | ||
}: { | ||
readonly size: GPUExtent3D; | ||
readonly dimension?: GPUTextureDimension; | ||
}): number { | ||
const sizeDict = standardizeExtent3D(size); | ||
|
||
let maxMippedDimension = sizeDict.width; | ||
if (dimension !== '1d') maxMippedDimension = Math.max(maxMippedDimension, sizeDict.height); | ||
if (dimension === '3d') maxMippedDimension = Math.max(maxMippedDimension, sizeDict.depth); | ||
return Math.floor(Math.log2(maxMippedDimension)) + 1; | ||
} |