Skip to content

Commit e98e861

Browse files
committed
KTX2Loader: Fix WebGPU feature detection.
1 parent f78867d commit e98e861

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

examples/jsm/loaders/KTX2Loader.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ class KTX2Loader extends Loader {
191191
this.workerConfig = {
192192
astcSupported: await renderer.hasFeatureAsync( 'texture-compression-astc' ),
193193
astcHDRSupported: false, // https://github.com/gpuweb/gpuweb/issues/3856
194-
etc1Supported: await renderer.hasFeatureAsync( 'texture-compression-etc1' ),
194+
etc1Supported: await renderer.hasFeatureAsync( 'texture-compression-etc2' ),
195195
etc2Supported: await renderer.hasFeatureAsync( 'texture-compression-etc2' ),
196196
dxtSupported: await renderer.hasFeatureAsync( 'texture-compression-bc' ),
197-
bptcSupported: await renderer.hasFeatureAsync( 'texture-compression-bptc' ),
197+
bptcSupported: await renderer.hasFeatureAsync( 'texture-compression-bc' ),
198198
pvrtcSupported: await renderer.hasFeatureAsync( 'texture-compression-pvrtc' )
199199
};
200200

@@ -216,10 +216,10 @@ class KTX2Loader extends Loader {
216216
this.workerConfig = {
217217
astcSupported: renderer.hasFeature( 'texture-compression-astc' ),
218218
astcHDRSupported: false, // https://github.com/gpuweb/gpuweb/issues/3856
219-
etc1Supported: renderer.hasFeature( 'texture-compression-etc1' ),
219+
etc1Supported: renderer.hasFeature( 'texture-compression-etc2' ),
220220
etc2Supported: renderer.hasFeature( 'texture-compression-etc2' ),
221221
dxtSupported: renderer.hasFeature( 'texture-compression-bc' ),
222-
bptcSupported: renderer.hasFeature( 'texture-compression-bptc' ),
222+
bptcSupported: renderer.hasFeature( 'texture-compression-bc' ),
223223
pvrtcSupported: renderer.hasFeature( 'texture-compression-pvrtc' )
224224
};
225225

@@ -1114,7 +1114,7 @@ async function createRawTexture( container ) {
11141114
}
11151115

11161116
// levelCount = 0 implies runtime-generated mipmaps.
1117-
const useMipmaps = container.levelCount === 0 || mipmaps.length > 1
1117+
const useMipmaps = container.levelCount === 0 || mipmaps.length > 1;
11181118

11191119
let texture;
11201120

examples/webgpu_loader_texture_ktx2.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@
115115
{ path: '2d_astc4x4.ktx2' },
116116
{ path: '2d_etc1.ktx2' },
117117
{ path: '2d_etc2.ktx2' },
118-
// { path: '2d_bc1.ktx2' }, TODO: Add support for WebGPU
118+
{ path: '2d_bc1.ktx2' },
119119
{ path: '2d_bc3.ktx2' },
120120
// { path: '2d_bc5.ktx2' },
121-
// { path: '2d_bc7.ktx2' }, TODO: Add support for WebGPU
121+
{ path: '2d_bc7.ktx2' },
122122
]
123123
},
124124

src/renderers/webgpu/utils/WebGPUConstants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export const GPUTextureFormat = {
158158
BC6HRGBUFloat: 'bc6h-rgb-ufloat',
159159
BC6HRGBFloat: 'bc6h-rgb-float',
160160
BC7RGBAUnorm: 'bc7-rgba-unorm',
161-
BC7RGBAUnormSRGB: 'bc7-rgba-srgb',
161+
BC7RGBAUnormSRGB: 'bc7-rgba-unorm-srgb',
162162

163163
// ETC2 compressed formats usable if 'texture-compression-etc2' is both
164164
// supported by the device/user agent and enabled in requestDevice.

src/renderers/webgpu/utils/WebGPUTextureUtils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format,
1515
RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type, UnsignedInt5999Type,
1616
NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat,
17-
UnsignedInt101111Type
17+
UnsignedInt101111Type, RGBA_BPTC_Format, RGB_ETC1_Format, RGB_S3TC_DXT1_Format
1818
} from '../../../constants.js';
1919
import { CubeTexture } from '../../../textures/CubeTexture.js';
2020
import { DepthTexture } from '../../../textures/DepthTexture.js';
@@ -1127,6 +1127,7 @@ export function getFormat( texture, device = null ) {
11271127

11281128
switch ( format ) {
11291129

1130+
case RGB_S3TC_DXT1_Format:
11301131
case RGBA_S3TC_DXT1_Format:
11311132
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
11321133
break;
@@ -1139,7 +1140,12 @@ export function getFormat( texture, device = null ) {
11391140
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
11401141
break;
11411142

1143+
case RGBA_BPTC_Format:
1144+
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC7RGBAUnormSRGB : GPUTextureFormat.BC7RGBAUnorm;
1145+
break;
1146+
11421147
case RGB_ETC2_Format:
1148+
case RGB_ETC1_Format:
11431149
formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
11441150
break;
11451151

0 commit comments

Comments
 (0)