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>
This commit is contained in:
Brandon Jones 2021-04-15 19:33:58 +00:00 committed by Commit Bot service account
parent 22b923cc91
commit 413dcf8a40
12 changed files with 56 additions and 30 deletions

View File

@ -1546,6 +1546,12 @@
{"name": "color", "type": "color", "annotation": "const*"}
]
},
{
"name": "set blend constant",
"args": [
{"name": "color", "type": "color", "annotation": "const*"}
]
},
{
"name": "set viewport",
"args": [

View File

@ -168,9 +168,9 @@ namespace dawn_native {
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 @@ namespace dawn_native {
commands->NextCommand<SetScissorRectCmd>();
break;
case Command::SetBlendColor:
commands->NextCommand<SetBlendColorCmd>();
case Command::SetBlendConstant:
commands->NextCommand<SetBlendConstantCmd>();
break;
case Command::SetBindGroup: {

View File

@ -59,7 +59,7 @@ namespace dawn_native {
SetStencilReference,
SetViewport,
SetScissorRect,
SetBlendColor,
SetBlendConstant,
SetBindGroup,
SetIndexBuffer,
SetVertexBuffer,
@ -231,7 +231,7 @@ namespace dawn_native {
uint32_t x, y, width, height;
};
struct SetBlendColorCmd {
struct SetBlendConstantCmd {
Color color;
};

View File

@ -115,15 +115,22 @@ namespace dawn_native {
});
}
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,

View File

@ -40,7 +40,8 @@ namespace dawn_native {
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,

View File

@ -1450,8 +1450,8 @@ namespace dawn_native { namespace d3d12 {
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;

View File

@ -1281,8 +1281,8 @@ namespace dawn_native { namespace metal {
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

View File

@ -1218,8 +1218,8 @@ namespace dawn_native { namespace opengl {
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;

View File

@ -1209,8 +1209,8 @@ namespace dawn_native { namespace vulkan {
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;

View File

@ -106,8 +106,8 @@ class ColorStateTest : public DawnTest {
// 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 @@ class ColorStateTest : public DawnTest {
// 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 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
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 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
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);

View File

@ -51,6 +51,18 @@ TEST_P(DeprecationTests, SetIndexBufferWithFormat) {
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) {

View File

@ -203,31 +203,31 @@ TEST_F(SetScissorTest, ScissorLargerThanFramebuffer) {
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();