Rename setBlendColor->setBlendConstant
Matches most recent spec changes. setBlendColor has been marked as
deprecated.
Bug: chromium:1199057
Change-Id: I4584ce789bd7d14401244509d5ada62a46236a5d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47901
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
diff --git a/dawn.json b/dawn.json
index cf5356f..5b7d2c9 100644
--- a/dawn.json
+++ b/dawn.json
@@ -1547,6 +1547,12 @@
]
},
{
+ "name": "set blend constant",
+ "args": [
+ {"name": "color", "type": "color", "annotation": "const*"}
+ ]
+ },
+ {
"name": "set viewport",
"args": [
{"name": "x", "type": "float"},
diff --git a/src/dawn_native/Commands.cpp b/src/dawn_native/Commands.cpp
index eba44c6..e3f852e 100644
--- a/src/dawn_native/Commands.cpp
+++ b/src/dawn_native/Commands.cpp
@@ -168,9 +168,9 @@
cmd->~SetScissorRectCmd();
break;
}
- case Command::SetBlendColor: {
- SetBlendColorCmd* cmd = commands->NextCommand<SetBlendColorCmd>();
- cmd->~SetBlendColorCmd();
+ case Command::SetBlendConstant: {
+ SetBlendConstantCmd* cmd = commands->NextCommand<SetBlendConstantCmd>();
+ cmd->~SetBlendConstantCmd();
break;
}
case Command::SetBindGroup: {
@@ -315,8 +315,8 @@
commands->NextCommand<SetScissorRectCmd>();
break;
- case Command::SetBlendColor:
- commands->NextCommand<SetBlendColorCmd>();
+ case Command::SetBlendConstant:
+ commands->NextCommand<SetBlendConstantCmd>();
break;
case Command::SetBindGroup: {
diff --git a/src/dawn_native/Commands.h b/src/dawn_native/Commands.h
index aa93c83..3c958fa 100644
--- a/src/dawn_native/Commands.h
+++ b/src/dawn_native/Commands.h
@@ -59,7 +59,7 @@
SetStencilReference,
SetViewport,
SetScissorRect,
- SetBlendColor,
+ SetBlendConstant,
SetBindGroup,
SetIndexBuffer,
SetVertexBuffer,
@@ -231,7 +231,7 @@
uint32_t x, y, width, height;
};
- struct SetBlendColorCmd {
+ struct SetBlendConstantCmd {
Color color;
};
diff --git a/src/dawn_native/RenderPassEncoder.cpp b/src/dawn_native/RenderPassEncoder.cpp
index 4c48bb4..1ab9023 100644
--- a/src/dawn_native/RenderPassEncoder.cpp
+++ b/src/dawn_native/RenderPassEncoder.cpp
@@ -115,15 +115,22 @@
});
}
- void RenderPassEncoder::APISetBlendColor(const Color* color) {
+ void RenderPassEncoder::APISetBlendConstant(const Color* color) {
mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
- SetBlendColorCmd* cmd = allocator->Allocate<SetBlendColorCmd>(Command::SetBlendColor);
+ SetBlendConstantCmd* cmd =
+ allocator->Allocate<SetBlendConstantCmd>(Command::SetBlendConstant);
cmd->color = *color;
return {};
});
}
+ void RenderPassEncoder::APISetBlendColor(const Color* color) {
+ GetDevice()->EmitDeprecationWarning(
+ "SetBlendColor has been deprecated in favor of SetBlendConstant.");
+ APISetBlendConstant(color);
+ }
+
void RenderPassEncoder::APISetViewport(float x,
float y,
float width,
diff --git a/src/dawn_native/RenderPassEncoder.h b/src/dawn_native/RenderPassEncoder.h
index a8bf460..dc22bf1 100644
--- a/src/dawn_native/RenderPassEncoder.h
+++ b/src/dawn_native/RenderPassEncoder.h
@@ -40,7 +40,8 @@
void APIEndPass();
void APISetStencilReference(uint32_t reference);
- void APISetBlendColor(const Color* color);
+ void APISetBlendConstant(const Color* color);
+ void APISetBlendColor(const Color* color); // Deprecated
void APISetViewport(float x,
float y,
float width,
diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp
index 7fb5e22..08b181c 100644
--- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp
+++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp
@@ -1450,8 +1450,8 @@
break;
}
- case Command::SetBlendColor: {
- SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
+ case Command::SetBlendConstant: {
+ SetBlendConstantCmd* cmd = mCommands.NextCommand<SetBlendConstantCmd>();
const std::array<float, 4> color = ConvertToFloatColor(cmd->color);
commandList->OMSetBlendFactor(color.data());
break;
diff --git a/src/dawn_native/metal/CommandBufferMTL.mm b/src/dawn_native/metal/CommandBufferMTL.mm
index 71f0d0f..f93737d 100644
--- a/src/dawn_native/metal/CommandBufferMTL.mm
+++ b/src/dawn_native/metal/CommandBufferMTL.mm
@@ -1281,8 +1281,8 @@
break;
}
- case Command::SetBlendColor: {
- SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
+ case Command::SetBlendConstant: {
+ SetBlendConstantCmd* cmd = mCommands.NextCommand<SetBlendConstantCmd>();
[encoder setBlendColorRed:cmd->color.r
green:cmd->color.g
blue:cmd->color.b
diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp
index 478bdaf..afb15a2 100644
--- a/src/dawn_native/opengl/CommandBufferGL.cpp
+++ b/src/dawn_native/opengl/CommandBufferGL.cpp
@@ -1218,8 +1218,8 @@
break;
}
- case Command::SetBlendColor: {
- SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
+ case Command::SetBlendConstant: {
+ SetBlendConstantCmd* cmd = mCommands.NextCommand<SetBlendConstantCmd>();
const std::array<float, 4> blendColor = ConvertToFloatColor(cmd->color);
gl.BlendColor(blendColor[0], blendColor[1], blendColor[2], blendColor[3]);
break;
diff --git a/src/dawn_native/vulkan/CommandBufferVk.cpp b/src/dawn_native/vulkan/CommandBufferVk.cpp
index 47fac44..16d8100 100644
--- a/src/dawn_native/vulkan/CommandBufferVk.cpp
+++ b/src/dawn_native/vulkan/CommandBufferVk.cpp
@@ -1209,8 +1209,8 @@
return {};
}
- case Command::SetBlendColor: {
- SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
+ case Command::SetBlendConstant: {
+ SetBlendConstantCmd* cmd = mCommands.NextCommand<SetBlendConstantCmd>();
const std::array<float, 4> blendConstants = ConvertToFloatColor(cmd->color);
device->fn.CmdSetBlendConstants(commands, blendConstants.data());
break;
diff --git a/src/tests/end2end/ColorStateTests.cpp b/src/tests/end2end/ColorStateTests.cpp
index 1e91432..5a4266c 100644
--- a/src/tests/end2end/ColorStateTests.cpp
+++ b/src/tests/end2end/ColorStateTests.cpp
@@ -106,8 +106,8 @@
// Test that after drawing a triangle with the base color, and then the given triangle spec, the
// color is as expected
void DoSingleSourceTest(RGBA8 base, const TriangleSpec& triangle, const RGBA8& expected) {
- wgpu::Color blendColor{triangle.blendFactor[0], triangle.blendFactor[1],
- triangle.blendFactor[2], triangle.blendFactor[3]};
+ wgpu::Color blendConstant{triangle.blendFactor[0], triangle.blendFactor[1],
+ triangle.blendFactor[2], triangle.blendFactor[3]};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
@@ -120,7 +120,7 @@
// Then use the test pipeline to draw the test triangle with blending
pass.SetPipeline(testPipeline);
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({{triangle.color}})));
- pass.SetBlendColor(&blendColor);
+ pass.SetBlendConstant(&blendConstant);
pass.Draw(3);
pass.EndPass();
}
@@ -975,7 +975,7 @@
MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(0, 0, 0, 0)}})));
pass.Draw(3);
pass.SetPipeline(testPipeline);
- pass.SetBlendColor(&kWhite);
+ pass.SetBlendConstant(&kWhite);
pass.SetBindGroup(
0, MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(255, 255, 255, 255)}})));
pass.Draw(3);
@@ -999,7 +999,7 @@
MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(0, 0, 0, 0)}})));
pass.Draw(3);
pass.SetPipeline(testPipeline);
- pass.SetBlendColor(&kWhite);
+ pass.SetBlendConstant(&kWhite);
pass.SetBindGroup(
0, MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(255, 255, 255, 255)}})));
pass.Draw(3);
diff --git a/src/tests/end2end/DeprecatedAPITests.cpp b/src/tests/end2end/DeprecatedAPITests.cpp
index aaadf5e..40d8d38 100644
--- a/src/tests/end2end/DeprecatedAPITests.cpp
+++ b/src/tests/end2end/DeprecatedAPITests.cpp
@@ -51,6 +51,18 @@
pass.EndPass();
}
+// Test that SetBlendColor is deprecated.
+TEST_P(DeprecationTests, SetSetBlendColor) {
+ wgpu::Color blendColor{1.0, 0.0, 0.0, 1.0};
+
+ utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
+
+ wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
+ EXPECT_DEPRECATION_WARNING(pass.SetBlendColor(&blendColor));
+ pass.EndPass();
+}
+
// Test that BindGroupLayoutEntry cannot have a type if buffer, sampler, texture, or storageTexture
// are defined.
TEST_P(DeprecationTests, BindGroupLayoutEntryTypeConflict) {
diff --git a/src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp b/src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp
index d66a529..458d277 100644
--- a/src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp
+++ b/src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp
@@ -203,31 +203,31 @@
TestScissorCall(false, 0, std::numeric_limits<uint32_t>::max(), kWidth, kHeight);
}
-class SetBlendColorTest : public ValidationTest {};
+class SetBlendConstantTest : public ValidationTest {};
-// Test to check basic use of SetBlendColor
-TEST_F(SetBlendColorTest, Success) {
+// Test to check basic use of SetBlendConstantTest
+TEST_F(SetBlendConstantTest, Success) {
DummyRenderPass renderPass(device);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
constexpr wgpu::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f};
- pass.SetBlendColor(&kTransparentBlack);
+ pass.SetBlendConstant(&kTransparentBlack);
pass.EndPass();
}
encoder.Finish();
}
-// Test that SetBlendColor allows any value, large, small or negative
-TEST_F(SetBlendColorTest, AnyValueAllowed) {
+// Test that SetBlendConstant allows any value, large, small or negative
+TEST_F(SetBlendConstantTest, AnyValueAllowed) {
DummyRenderPass renderPass(device);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
constexpr wgpu::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f};
- pass.SetBlendColor(&kAnyColorValue);
+ pass.SetBlendConstant(&kAnyColorValue);
pass.EndPass();
}
encoder.Finish();