Skip to content

Commit

Permalink
chore: Restore minification optimized texture table (#2243)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen authored Sep 3, 2024
1 parent cbea545 commit a66ea8b
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 132 deletions.
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

0 comments on commit a66ea8b

Please sign in to comment.