-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webgl): Enforce WebGPU style topology
- Loading branch information
Showing
24 changed files
with
199 additions
and
485 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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,28 +1,49 @@ | ||
import {VertexFormat, VertexType} from '../types/vertex-formats'; | ||
import { decodeVertexType } from './decode-data-type'; | ||
import {decodeVertexType} from './decode-data-type'; | ||
|
||
/** | ||
* Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized) | ||
*/ | ||
export function decodeVertexFormat(format: VertexFormat): { | ||
export type VertexFormatInfo = { | ||
/** Length in bytes */ | ||
byteLength: number; | ||
/** Type of each component */ | ||
type: VertexType; | ||
/** Number of components per vertex / row */ | ||
components: number; | ||
/** Is this an integer format (normalized integer formats are not integer) */ | ||
integer: boolean; | ||
/** Is this a signed format? */ | ||
signed: boolean; | ||
/** Is this a normalized format? */ | ||
normalized: boolean; | ||
} { | ||
/** Is this a webgl only format? */ | ||
webglOnly?: boolean; | ||
}; | ||
|
||
/** | ||
* Decodes a vertex format, returning type, components, byte length and flags (integer, signed, normalized) | ||
*/ | ||
export function decodeVertexFormat(format: VertexFormat): VertexFormatInfo { | ||
// Strip the -webgl ending if present | ||
let webglOnly: boolean | undefined; | ||
if (format.endsWith('-webgl')) { | ||
format.replace('-webgl', ''); | ||
webglOnly = true; | ||
} | ||
// split components from type | ||
const [type_, count] = format.split('x'); | ||
const type = type_ as VertexType; | ||
const components = count ? parseInt(count) : 1; | ||
// decode the type | ||
const decodedType = decodeVertexType(type); | ||
return { | ||
const result: VertexFormatInfo = { | ||
type, | ||
components, | ||
byteLength: decodedType.byteLength * components, | ||
integer: decodedType.integer, | ||
signed: decodedType.signed, | ||
normalized: decodedType.normalized | ||
}; | ||
if (webglOnly) { | ||
result.webglOnly = true; | ||
} | ||
return result; | ||
} |
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
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
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
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
Oops, something went wrong.