Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Restore minification optimized texture table #2243

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions modules/core/src/gpu-type-utils/decode-texture-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {VertexType} from './vertex-formats';
import {decodeVertexType} from './decode-data-type';
import {TextureFormatInfo} from './texture-format-info';

import {TEXTURE_FORMAT_TABLE} from './texture-format-table';
import {getTextureFormatDefinition} from './texture-format-table';

// prettier-ignore
const COMPRESSED_TEXTURE_FORMAT_PREFIXES = [
Expand Down Expand Up @@ -96,16 +96,13 @@ export function decodeTextureFormat(format: TextureFormat): TextureFormatInfo {

/** Decode texture format info from the table */
function decodeTextureFormatUsingTable(format: TextureFormat): TextureFormatInfo {
const info = TEXTURE_FORMAT_TABLE[format];
if (!info) {
throw new Error(`Unknown texture format ${format}`);
}
const info = getTextureFormatDefinition(format);

const bytesPerPixel = info.bytesPerPixel || 1;
const bitsPerChannel = info.bitsPerChannel || [8, 8, 8, 8];
delete info.bitsPerChannel;
delete info.bytesPerPixel;
delete info.create;
delete info.f;
delete info.render;
delete info.filter;
delete info.blend;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {TextureFormat} from './texture-formats';
import type {TextureFeature} from './texture-features';
import {decodeTextureFormat} from './decode-texture-format';

import {TEXTURE_FORMAT_TABLE} from './texture-format-table';
import {getTextureFormatDefinition} from './texture-format-table';

/**
* Texture format capabilities.
Expand All @@ -27,14 +27,11 @@ export type TextureFormatCapabilities = {
};

export function getTextureFormatCapabilities(format: TextureFormat): TextureFormatCapabilities {
const info = TEXTURE_FORMAT_TABLE[format];
if (!info) {
throw new Error(`Unknown texture format ${format}`);
}
const info = getTextureFormatDefinition(format);

const formatCapabilities: Required<TextureFormatCapabilities> = {
format,
create: info.create ?? true,
create: info.f ?? true,
render: info.render ?? true,
filter: info.filter ?? true,
blend: info.blend ?? true,
Expand Down
Loading
Loading