Skip to content

op: Add 'color_write_mask,blending_disabled' to blending.spec.ts #1994

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Nov 21, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function computeBlendOperation(
}
}

g.test('GPUBlendComponent')
g.test('blending,GPUBlendComponent')
.desc(
`Test all combinations of parameters for GPUBlendComponent.

Expand Down Expand Up @@ -339,7 +339,7 @@ const kBlendableFormats = kEncodableTextureFormats.filter(f => {
return info.renderable && info.sampleType === 'float';
});

g.test('formats')
g.test('blending,formats')
.desc(
`Test blending results works for all formats that support it, and that blending is not applied
for formats that do not. Blending should be done in linear space for srgb formats.`
Expand Down Expand Up @@ -425,7 +425,7 @@ g.test('formats')
t.expectOK(result);
});

g.test('simple_blend_constant,initial_blend_constant')
g.test('blend_constant,initial')
.desc(`Test that the blend constant is set to [0,0,0,0] at the beginning of a pass.`)
.fn(async t => {
const format = 'rgba8unorm';
Expand Down Expand Up @@ -481,7 +481,7 @@ g.test('simple_blend_constant,initial_blend_constant')
t.expectOK(result);
});

g.test('simple_blend_constant,setting_blend_constant')
g.test('blend_constant,setting')
.desc(`Test that setting the blend constant to the RGBA values works at the beginning of a pass.`)
.paramsSubcasesOnly([
{ r: 1.0, g: 1.0, b: 1.0, a: 1.0 },
Expand Down Expand Up @@ -544,7 +544,7 @@ g.test('simple_blend_constant,setting_blend_constant')
t.expectOK(result);
});

g.test('simple_blend_constant,blend_constant_non_inherited')
g.test('blend_constant,not_inherited')
.desc(`Test that the blending constant is not inherited between render passes.`)
.fn(async t => {
const format = 'rgba8unorm';
Expand Down Expand Up @@ -621,14 +621,76 @@ g.test('simple_blend_constant,blend_constant_non_inherited')
t.expectOK(result);
});

g.test('clamp,blend_factor')
g.test('color_write_mask,blending_disabled')
.desc(
`Test that the color write mask works when blending is disabled or set to the defaults
(which has the same blending result).`
)
.params(u => u.combine('disabled', [false, true]))
.fn(async t => {
const format = 'rgba8unorm';
const kSize = 1;

const blend = t.params.disabled ? undefined : { color: {}, alpha: {} };

const testPipeline = t.createRenderPipelineForTest({
format,
blend,
writeMask: GPUColorWrite.RED,
});

const renderTarget = t.device.createTexture({
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
size: [kSize, kSize],
format,
});

const kBaseColorData = new Float32Array([32, 64, 128, 192]);

const commandEncoder = t.device.createCommandEncoder();
{
const renderPass = commandEncoder.beginRenderPass({
colorAttachments: [
{
view: renderTarget.createView(),
loadOp: 'load',
storeOp: 'store',
},
],
});
renderPass.setPipeline(testPipeline);
renderPass.setBindGroup(
0,
t.createBindGroupForTest(testPipeline.getBindGroupLayout(0), kBaseColorData)
);
// Draw [1,1,1,1] with `src * 1 + dst * 0`. So the
// result is `[1,1,1,1] * [1,1,1,1] + [0,0,0,0] * 0` = [1,1,1,1].
renderPass.draw(3);
renderPass.end();
}
t.device.queue.submit([commandEncoder.finish()]);

const expColor = { R: 1, G: 0, B: 0, A: 0 };
const expTexelView = TexelView.fromTexelsAsColors(format, coords => expColor);

const result = await textureContentIsOKByT2B(
t,
{ texture: renderTarget },
[kSize, kSize],
{ expTexelView },
{ maxDiffULPsForNormFormat: 1 }
);
t.expectOK(result);
});

g.test('blending,clamp,blend_factor')
.desc('For fixed-point formats, test that the blend factor is clamped in the blend equation.')
.unimplemented();

g.test('clamp,blend_color')
g.test('blending,clamp,blend_color')
.desc('For fixed-point formats, test that the blend color is clamped in the blend equation.')
.unimplemented();

g.test('clamp,blend_result')
g.test('blending,clamp,blend_result')
.desc('For fixed-point formats, test that the blend result is clamped in the blend equation.')
.unimplemented();