Fix color write mask on GL backend.
Set the color mask even if blending is disabled.
This commit is contained in:
parent
10a659ad91
commit
a5aacc9cad
|
@ -85,13 +85,13 @@ namespace backend { namespace opengl {
|
|||
GLBlendFactor(info.colorBlend.dstFactor, false),
|
||||
GLBlendFactor(info.alphaBlend.srcFactor, true),
|
||||
GLBlendFactor(info.alphaBlend.dstFactor, true));
|
||||
glColorMaski(attachment, info.colorWriteMask & nxt::ColorWriteMask::Red,
|
||||
info.colorWriteMask & nxt::ColorWriteMask::Green,
|
||||
info.colorWriteMask & nxt::ColorWriteMask::Blue,
|
||||
info.colorWriteMask & nxt::ColorWriteMask::Alpha);
|
||||
} else {
|
||||
glDisablei(GL_BLEND, attachment);
|
||||
}
|
||||
glColorMaski(attachment, info.colorWriteMask & nxt::ColorWriteMask::Red,
|
||||
info.colorWriteMask & nxt::ColorWriteMask::Green,
|
||||
info.colorWriteMask & nxt::ColorWriteMask::Blue,
|
||||
info.colorWriteMask & nxt::ColorWriteMask::Alpha);
|
||||
}
|
||||
|
||||
}} // namespace backend::opengl
|
||||
|
|
|
@ -667,6 +667,32 @@ TEST_P(BlendStateTest, ColorWriteMask) {
|
|||
}
|
||||
}
|
||||
|
||||
// Check that the color write mask works when blending is disabled
|
||||
TEST_P(BlendStateTest, ColorWriteMaskBlendingDisabled) {
|
||||
{
|
||||
nxt::BlendState blendState = device.CreateBlendStateBuilder()
|
||||
.SetBlendEnabled(false)
|
||||
.SetColorWriteMask(nxt::ColorWriteMask::Red)
|
||||
.GetResult();
|
||||
SetupSingleSourcePipelines(blendState);
|
||||
|
||||
RGBA8 base(32, 64, 128, 192);
|
||||
RGBA8 expected(32, 0, 0, 0);
|
||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||
.BeginRenderPass(fb.renderPass, fb.framebuffer)
|
||||
.BeginRenderSubpass()
|
||||
.SetRenderPipeline(testPipeline)
|
||||
.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { base } })))
|
||||
.DrawArrays(3, 1, 0, 0)
|
||||
.EndRenderSubpass()
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
|
||||
queue.Submit(1, &commands);
|
||||
EXPECT_PIXEL_RGBA8_EQ(expected, fb.color, kRTSize / 2, kRTSize / 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Test that independent blend states on render targets works
|
||||
TEST_P(BlendStateTest, IndependentBlendState) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue