Skip to content
Draft
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
15 changes: 11 additions & 4 deletions src/webgpu/api/operation/render_pass/clear_value.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ g.test('stencil_clear_value')
.combine('stencilFormat', kStencilTextureFormats)
.combine('stencilClearValue', [0, 1, 0xff, 0x100 + 2, 0x10000 + 3])
.combine('applyStencilClearValueAsStencilReferenceValue', [true, false])
.combine('createStencilTextureView', [false, true] as const)
.combine('createColorTextureView', [false, true] as const)
)
.fn(t => {
const { stencilFormat, stencilClearValue, applyStencilClearValueAsStencilReferenceValue } =
t.params;
const {
stencilFormat,
stencilClearValue,
applyStencilClearValueAsStencilReferenceValue,
createStencilTextureView,
createColorTextureView,
} = t.params;

t.skipIfTextureFormatNotSupported(stencilFormat);

Expand Down Expand Up @@ -112,7 +119,7 @@ g.test('stencil_clear_value')
const encoder = t.device.createCommandEncoder();

const depthStencilAttachment: GPURenderPassDepthStencilAttachment = {
view: stencilTexture.createView(),
view: createStencilTextureView ? stencilTexture.createView() : stencilTexture,
depthClearValue: 0,
stencilLoadOp: 'clear',
stencilStoreOp: 'store',
Expand All @@ -126,7 +133,7 @@ g.test('stencil_clear_value')
const renderPassEncoder = encoder.beginRenderPass({
colorAttachments: [
{
view: colorTexture.createView(),
view: createColorTextureView ? colorTexture.createView() : colorTexture,
loadOp: 'clear',
storeOp: 'store',
clearValue: [1, 0, 0, 1] as const,
Expand Down
48 changes: 32 additions & 16 deletions src/webgpu/api/operation/render_pass/resolve.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ Test basic render pass resolve behavior for combinations of:
.combine('slotsToResolve', kSlotsToResolve)
.combine('resolveTargetBaseMipLevel', [0, 1] as const)
.combine('resolveTargetBaseArrayLayer', [0, 1] as const)
.combine('createColorAttachmentView', [false, true] as const)
.combine('createResolveTargetTextureView', [false, true] as const)
.unless(
p =>
!p.createResolveTargetTextureView &&
(p.resolveTargetBaseMipLevel !== 0 || p.resolveTargetBaseArrayLayer !== 0)
)
)
.fn(t => {
const targets: GPUColorTargetState[] = [];
Expand Down Expand Up @@ -108,18 +115,23 @@ Test basic render pass resolve behavior for combinations of:
const kResolveTargetSize = kSize << t.params.resolveTargetBaseMipLevel;

for (let i = 0; i < t.params.numColorAttachments; i++) {
const colorAttachment = t
.createTextureTracked({
format: kFormat,
size: [kSize, kSize, 1],
sampleCount: 4,
mipLevelCount: 1,
usage:
GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
})
.createView();

let resolveTarget: GPUTextureView | undefined;
const colorAttachmentTexture = t.createTextureTracked({
format: kFormat,
size: [kSize, kSize, 1],
sampleCount: 4,
mipLevelCount: 1,
usage:
GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
});

let colorAttachment: GPUTexture | GPUTextureView;
if (t.params.createResolveTargetTextureView) {
colorAttachment = colorAttachmentTexture.createView();
} else {
colorAttachment = colorAttachmentTexture;
}

let resolveTarget: GPUTexture | GPUTextureView | undefined;
if (t.params.slotsToResolve.includes(i)) {
const resolveTargetTexture = t.createTextureTracked({
format: kFormat,
Expand All @@ -130,10 +142,14 @@ Test basic render pass resolve behavior for combinations of:
});
resolveTargets.push(resolveTargetTexture);

resolveTarget = resolveTargetTexture.createView({
baseMipLevel: t.params.resolveTargetBaseMipLevel,
baseArrayLayer: t.params.resolveTargetBaseArrayLayer,
});
if (t.params.createResolveTargetTextureView) {
resolveTarget = resolveTargetTexture.createView({
baseMipLevel: t.params.resolveTargetBaseMipLevel,
baseArrayLayer: t.params.resolveTargetBaseArrayLayer,
});
} else {
resolveTarget = resolveTargetTexture;
}
}

// Clear to black for the load operation. After the draw, the top left half of the attachment
Expand Down
66 changes: 35 additions & 31 deletions src/webgpu/api/operation/rendering/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,44 @@ import { checkElementsEqual } from '../../../util/check_contents.js';

export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

g.test('clear').fn(t => {
const dst = t.createBufferTracked({
size: 4,
usage: GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST,
});
g.test('clear')
.params(u => u.beginSubcases().combine('createColorAttachmentView', [false, true] as const))
.fn(t => {
const dst = t.createBufferTracked({
size: 4,
usage: GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST,
});

const colorAttachment = t.createTextureTracked({
format: 'rgba8unorm',
size: { width: 1, height: 1, depthOrArrayLayers: 1 },
usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
});
const colorAttachmentView = colorAttachment.createView();
const colorAttachment = t.createTextureTracked({
format: 'rgba8unorm',
size: { width: 1, height: 1, depthOrArrayLayers: 1 },
usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
});
const colorAttachmentView = t.params.createColorAttachmentView
? colorAttachment.createView()
: colorAttachment;

const encoder = t.device.createCommandEncoder();
const pass = encoder.beginRenderPass({
colorAttachments: [
{
view: colorAttachmentView,
clearValue: { r: 0.0, g: 1.0, b: 0.0, a: 1.0 },
loadOp: 'clear',
storeOp: 'store',
},
],
const encoder = t.device.createCommandEncoder();
const pass = encoder.beginRenderPass({
colorAttachments: [
{
view: colorAttachmentView,
clearValue: { r: 0.0, g: 1.0, b: 0.0, a: 1.0 },
loadOp: 'clear',
storeOp: 'store',
},
],
});
pass.end();
encoder.copyTextureToBuffer(
{ texture: colorAttachment, mipLevel: 0, origin: { x: 0, y: 0, z: 0 } },
{ buffer: dst, bytesPerRow: 256 },
{ width: 1, height: 1, depthOrArrayLayers: 1 }
);
t.device.queue.submit([encoder.finish()]);

t.expectGPUBufferValuesEqual(dst, new Uint8Array([0x00, 0xff, 0x00, 0xff]));
});
pass.end();
encoder.copyTextureToBuffer(
{ texture: colorAttachment, mipLevel: 0, origin: { x: 0, y: 0, z: 0 } },
{ buffer: dst, bytesPerRow: 256 },
{ width: 1, height: 1, depthOrArrayLayers: 1 }
);
t.device.queue.submit([encoder.finish()]);

t.expectGPUBufferValuesEqual(dst, new Uint8Array([0x00, 0xff, 0x00, 0xff]));
});

g.test('fullscreen_quad').fn(t => {
const dst = t.createBufferTracked({
Expand Down
26 changes: 20 additions & 6 deletions src/webgpu/api/operation/texture_view/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const kTextureSize = 16;
function writeTextureAndGetExpectedTexelView(
t: GPUTest,
method: TextureViewWriteMethod,
view: GPUTextureView,
view: GPUTexture | GPUTextureView,
format: RegularTextureFormat,
sampleCount: number
) {
Expand Down Expand Up @@ -334,10 +334,19 @@ TODO: Test rgb10a2uint when TexelRepresentation.numericRange is made per-compone

return true;
})
.combine('viewUsageMethod', kTextureViewUsageMethods)
.combine('bindTextureResource', [false, true] as const)
.expand('viewUsageMethod', function* ({ bindTextureResource }) {
if (bindTextureResource) {
yield;
} else {
for (const method of kTextureViewUsageMethods) {
yield method;
}
}
})
)
.fn(t => {
const { format, method, sampleCount, viewUsageMethod } = t.params;
const { format, method, sampleCount, bindTextureResource, viewUsageMethod } = t.params;
t.skipIfTextureFormatNotSupported(format);
if (sampleCount > 1) {
t.skipIfTextureFormatNotMultisampled(format);
Expand Down Expand Up @@ -377,9 +386,14 @@ TODO: Test rgb10a2uint when TexelRepresentation.numericRange is made per-compone
sampleCount,
});

const view = texture.createView({
usage: getTextureViewUsage(viewUsageMethod, textureUsageForMethod),
});
let view: GPUTexture | GPUTextureView;
if (bindTextureResource) {
view = texture;
} else {
view = texture.createView({
usage: getTextureViewUsage(viewUsageMethod!, textureUsageForMethod),
});
}
const expectedTexelView = writeTextureAndGetExpectedTexelView(
t,
method,
Expand Down