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

Clean up deprecated .sampleType/.copySrc from kTextureFormatInfo #3394

Merged
merged 7 commits into from
Feb 16, 2024
Merged
31 changes: 15 additions & 16 deletions src/unittests/texture_ok.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Test for texture_ok utils.

import { makeTestGroup } from '../common/framework/test_group.js';
import { typedArrayFromParam, typedArrayParam } from '../common/util/util.js';
import { RegularTextureFormat } from '../webgpu/format_info.js';
import { TexelView } from '../webgpu/util/texture/texel_view.js';
import { findFailedPixels } from '../webgpu/util/texture/texture_ok.js';

Expand All @@ -30,103 +29,103 @@ g.test('findFailedPixels')
u.combineWithParams([
// Sanity Check
{
format: 'rgba8unorm' as RegularTextureFormat,
format: 'rgba8unorm',
actual: typedArrayParam('Uint8Array', [0x00, 0x40, 0x80, 0xff]),
expected: typedArrayParam('Uint8Array', [0x00, 0x40, 0x80, 0xff]),
isSame: true,
},
// Slightly different values
{
format: 'rgba8unorm' as RegularTextureFormat,
format: 'rgba8unorm',
actual: typedArrayParam('Uint8Array', [0x00, 0x40, 0x80, 0xff]),
expected: typedArrayParam('Uint8Array', [0x00, 0x40, 0x81, 0xff]),
isSame: false,
},
// Different representations of the same value
{
format: 'rgb9e5ufloat' as RegularTextureFormat,
format: 'rgb9e5ufloat',
actual: typedArrayParam('Uint8Array', [0x78, 0x56, 0x34, 0x12]),
expected: typedArrayParam('Uint8Array', [0xf0, 0xac, 0x68, 0x0c]),
isSame: true,
},
// Slightly different values
{
format: 'rgb9e5ufloat' as RegularTextureFormat,
format: 'rgb9e5ufloat',
actual: typedArrayParam('Uint8Array', [0x78, 0x56, 0x34, 0x12]),
expected: typedArrayParam('Uint8Array', [0xf1, 0xac, 0x68, 0x0c]),
isSame: false,
},
// Test NaN === NaN
{
format: 'r32float' as RegularTextureFormat,
format: 'r32float',
actual: typedArrayParam('Float32Array', [parseFloat('abc')]),
expected: typedArrayParam('Float32Array', [parseFloat('def')]),
isSame: true,
},
// Sanity Check
{
format: 'r32float' as RegularTextureFormat,
format: 'r32float',
actual: typedArrayParam('Float32Array', [1.23]),
expected: typedArrayParam('Float32Array', [1.23]),
isSame: true,
},
// Slightly different values.
{
format: 'r32float' as RegularTextureFormat,
format: 'r32float',
actual: typedArrayParam('Uint32Array', [0x3f9d70a4]),
expected: typedArrayParam('Uint32Array', [0x3f9d70a5]),
isSame: false,
},
// Slightly different
{
format: 'rg11b10ufloat' as RegularTextureFormat,
format: 'rg11b10ufloat',
actual: typedArrayParam('Uint32Array', [0x3ce]),
expected: typedArrayParam('Uint32Array', [0x3cf]),
isSame: false,
},
// Positive.Infinity === Positive.Infinity (red)
{
format: 'rg11b10ufloat' as RegularTextureFormat,
format: 'rg11b10ufloat',
actual: typedArrayParam('Uint32Array', [0b11111000000]),
expected: typedArrayParam('Uint32Array', [0b11111000000]),
isSame: true,
},
// Positive.Infinity === Positive.Infinity (green)
{
format: 'rg11b10ufloat' as RegularTextureFormat,
format: 'rg11b10ufloat',
actual: typedArrayParam('Uint32Array', [0b11111000000_00000000000]),
expected: typedArrayParam('Uint32Array', [0b11111000000_00000000000]),
isSame: true,
},
// Positive.Infinity === Positive.Infinity (blue)
{
format: 'rg11b10ufloat' as RegularTextureFormat,
format: 'rg11b10ufloat',
actual: typedArrayParam('Uint32Array', [0b1111100000_00000000000_00000000000]),
expected: typedArrayParam('Uint32Array', [0b1111100000_00000000000_00000000000]),
isSame: true,
},
// NaN === NaN (red)
{
format: 'rg11b10ufloat' as RegularTextureFormat,
format: 'rg11b10ufloat',
actual: typedArrayParam('Uint32Array', [0b11111000001]),
expected: typedArrayParam('Uint32Array', [0b11111000010]),
isSame: true,
},
// NaN === NaN (green)
{
format: 'rg11b10ufloat' as RegularTextureFormat,
format: 'rg11b10ufloat',
actual: typedArrayParam('Uint32Array', [0b11111000100_00000000000]),
expected: typedArrayParam('Uint32Array', [0b11111001000_00000000000]),
isSame: true,
},
// NaN === NaN (blue)
{
format: 'rg11b10ufloat' as RegularTextureFormat,
format: 'rg11b10ufloat',
actual: typedArrayParam('Uint32Array', [0b1111110000_00000000000_00000000000]),
expected: typedArrayParam('Uint32Array', [0b1111101000_00000000000_00000000000]),
isSame: true,
},
])
] as const)
)
.fn(t => {
const { format, actual, expected, isSame } = t.params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import {
DepthStencilFormat,
ColorTextureFormat,
isCompressedTextureFormat,
isEncodableTextureformat,
viewCompatible,
EncodableTextureFormat,
RegularTextureFormat,
isRegularTextureFormat,
} from '../../../format_info.js';
import { GPUTest, TextureTestMixin } from '../../../gpu_test.js';
import { makeBufferWithContents } from '../../../util/buffer.js';
Expand Down Expand Up @@ -346,21 +346,21 @@ class F extends TextureTestMixin(GPUTest) {
return;
}

assert(isEncodableTextureformat(dstFormat));
const encodableDstFormat = dstFormat as EncodableTextureFormat;
assert(isRegularTextureFormat(dstFormat));
const regularDstFormat = dstFormat as RegularTextureFormat;

// Verify the content of the whole subresource of dstTexture at dstCopyLevel (in dstBuffer) is expected.
const checkByTextureFormat = (actual: Uint8Array) => {
const zero = { x: 0, y: 0, z: 0 };

const actTexelView = TexelView.fromTextureDataByReference(encodableDstFormat, actual, {
const actTexelView = TexelView.fromTextureDataByReference(regularDstFormat, actual, {
bytesPerRow: bytesInRow,
rowsPerImage: dstBlockRowsPerImage,
subrectOrigin: zero,
subrectSize: dstTextureSizeAtLevel,
});
const expTexelView = TexelView.fromTextureDataByReference(
encodableDstFormat,
regularDstFormat,
expectedUint8DataWithPadding,
{
bytesPerRow: bytesInRow,
Expand All @@ -371,7 +371,7 @@ class F extends TextureTestMixin(GPUTest) {
);

const failedPixelsMessage = findFailedPixels(
encodableDstFormat,
regularDstFormat,
zero,
dstTextureSizeAtLevel,
{ actTexelView, expTexelView },
Expand Down
6 changes: 3 additions & 3 deletions src/webgpu/api/operation/rendering/color_target_state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { assert, TypedArrayBufferView, unreachable } from '../../../../common/util/util.js';
import { kBlendFactors, kBlendOperations } from '../../../capability_info.js';
import { GPUConst } from '../../../constants.js';
import { kEncodableTextureFormats, kTextureFormatInfo } from '../../../format_info.js';
import { kRegularTextureFormats, kTextureFormatInfo } from '../../../format_info.js';
import { GPUTest, TextureTestMixin } from '../../../gpu_test.js';
import { clamp } from '../../../util/math.js';
import { TexelView } from '../../../util/texture/texel_view.js';
Expand Down Expand Up @@ -318,9 +318,9 @@ struct Uniform {
);
});

const kBlendableFormats = kEncodableTextureFormats.filter(f => {
const kBlendableFormats = kRegularTextureFormats.filter(f => {
const info = kTextureFormatInfo[f];
return info.renderable && info.sampleType === 'float';
return info.colorRender && info.color.type === 'float';
});

g.test('blending,formats')
Expand Down
4 changes: 2 additions & 2 deletions src/webgpu/api/validation/image_copy/image_copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ export function formatCopyableWithMethod({ format, method }: WithFormatAndMethod
return supportedAspects.length > 0;
}
if (method === 'CopyT2B') {
return info.copySrc;
return info.color.copySrc;
} else {
return info.copyDst;
return info.color.copyDst;
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/webgpu/api/validation/render_pipeline/common.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
import { kTextureFormatInfo } from '../../../format_info.js';
import { ColorTextureFormat, kTextureFormatInfo } from '../../../format_info.js';
import {
getFragmentShaderCodeWithOutput,
getPlainTypeInfo,
kDefaultVertexShaderCode,
} from '../../../util/shader.js';
import { ValidationTest } from '../validation_test.js';

type ColorTargetState = GPUColorTargetState & { format: ColorTextureFormat };

const values = [0, 1, 0, 1];
export class CreateRenderPipelineValidationTest extends ValidationTest {
getDescriptor(
options: {
primitive?: GPUPrimitiveState;
targets?: GPUColorTargetState[];
targets?: ColorTargetState[];
multisample?: GPUMultisampleState;
depthStencil?: GPUDepthStencilState;
fragmentShaderCode?: string;
noFragment?: boolean;
fragmentConstants?: Record<string, GPUPipelineConstantValue>;
} = {}
): GPURenderPipelineDescriptor {
const defaultTargets: GPUColorTargetState[] = [{ format: 'rgba8unorm' }];
const {
primitive = {},
targets = defaultTargets,
targets = [{ format: 'rgba8unorm' }] as const,
multisample = {},
depthStencil,
fragmentShaderCode = getFragmentShaderCodeWithOutput([
{
values,
plainType: getPlainTypeInfo(
kTextureFormatInfo[targets[0] ? targets[0].format : 'rgba8unorm'].sampleType
kTextureFormatInfo[targets[0] ? targets[0].format : 'rgba8unorm'].color.type
),
componentCount: 4,
},
Expand Down
18 changes: 3 additions & 15 deletions src/webgpu/api/validation/render_pipeline/fragment_state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,24 +211,12 @@ g.test('limits,maxColorAttachmentBytesPerSample,unaligned')
// become 4 and 4+4+8+16+1 > 32. Re-ordering this so the R8Unorm's are at the end, however
// is allowed: 4+8+16+1+1 < 32.
{
formats: [
'r8unorm',
'r32float',
'rgba8unorm',
'rgba32float',
'r8unorm',
] as GPUTextureFormat[],
formats: ['r8unorm', 'r32float', 'rgba8unorm', 'rgba32float', 'r8unorm'],
},
{
formats: [
'r32float',
'rgba8unorm',
'rgba32float',
'r8unorm',
'r8unorm',
] as GPUTextureFormat[],
formats: ['r32float', 'rgba8unorm', 'rgba32float', 'r8unorm', 'r8unorm'],
},
])
] as const)
.beginSubcases()
.combine('isAsync', [false, true])
)
Expand Down
Loading
Loading