|
|
@@ -1,6 +1,7 @@
|
|
|
import {
|
|
|
GPUTextureFormat, GPUAddressMode, GPUFilterMode, GPUTextureDimension, GPUFeatureName, GPUTextureViewDimension
|
|
|
} from './WebGPUConstants.js';
|
|
|
+import { ColorManagement } from '../../../math/ColorManagement.js';
|
|
|
|
|
|
import WebGPUTexturePassUtils from './WebGPUTexturePassUtils.js';
|
|
|
|
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
NearestFilter, NearestMipmapNearestFilter, NearestMipmapLinearFilter,
|
|
|
RepeatWrapping, MirroredRepeatWrapping,
|
|
|
RGB_ETC2_Format, RGBA_ETC2_EAC_Format,
|
|
|
- RGBAFormat, RGBFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBColorSpace, DepthFormat, DepthStencilFormat,
|
|
|
+ RGBAFormat, RGBFormat, RedFormat, RGFormat, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, UnsignedByteType, FloatType, HalfFloatType, SRGBTransfer, DepthFormat, DepthStencilFormat,
|
|
|
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,
|
|
|
RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, UnsignedIntType, UnsignedShortType, UnsignedInt248Type, UnsignedInt5999Type,
|
|
|
NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, IntType, RedIntegerFormat, RGIntegerFormat, RGBAIntegerFormat,
|
|
|
@@ -1119,6 +1120,7 @@ export function getFormat( texture, device = null ) {
|
|
|
const format = texture.format;
|
|
|
const type = texture.type;
|
|
|
const colorSpace = texture.colorSpace;
|
|
|
+ const transfer = ColorManagement.getTransfer( colorSpace );
|
|
|
|
|
|
let formatGPU;
|
|
|
|
|
|
@@ -1127,83 +1129,83 @@ export function getFormat( texture, device = null ) {
|
|
|
switch ( format ) {
|
|
|
|
|
|
case RGBA_S3TC_DXT1_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC1RGBAUnormSRGB : GPUTextureFormat.BC1RGBAUnorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_S3TC_DXT3_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC2RGBAUnormSRGB : GPUTextureFormat.BC2RGBAUnorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_S3TC_DXT5_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.BC3RGBAUnormSRGB : GPUTextureFormat.BC3RGBAUnorm;
|
|
|
break;
|
|
|
|
|
|
case RGB_ETC2_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ETC2RGB8UnormSRGB : GPUTextureFormat.ETC2RGB8Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ETC2_EAC_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ETC2RGBA8UnormSRGB : GPUTextureFormat.ETC2RGBA8Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ETC2RGBA8UnormSRGB : GPUTextureFormat.ETC2RGBA8Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_4x4_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC4x4UnormSRGB : GPUTextureFormat.ASTC4x4Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC4x4UnormSRGB : GPUTextureFormat.ASTC4x4Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_5x4_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x4UnormSRGB : GPUTextureFormat.ASTC5x4Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC5x4UnormSRGB : GPUTextureFormat.ASTC5x4Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_5x5_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC5x5UnormSRGB : GPUTextureFormat.ASTC5x5Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC5x5UnormSRGB : GPUTextureFormat.ASTC5x5Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_6x5_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x5UnormSRGB : GPUTextureFormat.ASTC6x5Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC6x5UnormSRGB : GPUTextureFormat.ASTC6x5Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_6x6_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC6x6UnormSRGB : GPUTextureFormat.ASTC6x6Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC6x6UnormSRGB : GPUTextureFormat.ASTC6x6Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_8x5_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x5UnormSRGB : GPUTextureFormat.ASTC8x5Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC8x5UnormSRGB : GPUTextureFormat.ASTC8x5Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_8x6_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x6UnormSRGB : GPUTextureFormat.ASTC8x6Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC8x6UnormSRGB : GPUTextureFormat.ASTC8x6Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_8x8_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC8x8UnormSRGB : GPUTextureFormat.ASTC8x8Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC8x8UnormSRGB : GPUTextureFormat.ASTC8x8Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_10x5_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x5UnormSRGB : GPUTextureFormat.ASTC10x5Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC10x5UnormSRGB : GPUTextureFormat.ASTC10x5Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_10x6_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x6UnormSRGB : GPUTextureFormat.ASTC10x6Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC10x6UnormSRGB : GPUTextureFormat.ASTC10x6Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_10x8_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x8UnormSRGB : GPUTextureFormat.ASTC10x8Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC10x8UnormSRGB : GPUTextureFormat.ASTC10x8Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_10x10_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC10x10UnormSRGB : GPUTextureFormat.ASTC10x10Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC10x10UnormSRGB : GPUTextureFormat.ASTC10x10Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_12x10_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x10UnormSRGB : GPUTextureFormat.ASTC12x10Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC12x10UnormSRGB : GPUTextureFormat.ASTC12x10Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBA_ASTC_12x12_Format:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.ASTC12x12UnormSRGB : GPUTextureFormat.ASTC12x12Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.ASTC12x12UnormSRGB : GPUTextureFormat.ASTC12x12Unorm;
|
|
|
break;
|
|
|
|
|
|
case RGBAFormat:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
@@ -1239,7 +1241,7 @@ export function getFormat( texture, device = null ) {
|
|
|
break;
|
|
|
|
|
|
case UnsignedByteType:
|
|
|
- formatGPU = ( colorSpace === SRGBColorSpace ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
|
|
|
+ formatGPU = ( transfer === SRGBTransfer ) ? GPUTextureFormat.RGBA8UnormSRGB : GPUTextureFormat.RGBA8Unorm;
|
|
|
break;
|
|
|
|
|
|
case HalfFloatType:
|