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": "color", "type": "color", "annotation": "const*"}
] ]
}, },
{
"name": "set blend constant",
"args": [
{"name": "color", "type": "color", "annotation": "const*"}
]
},
{ {
"name": "set viewport", "name": "set viewport",
"args": [ "args": [

View File

@ -168,9 +168,9 @@ namespace dawn_native {
cmd->~SetScissorRectCmd(); cmd->~SetScissorRectCmd();
break; break;
} }
case Command::SetBlendColor: { case Command::SetBlendConstant: {
SetBlendColorCmd* cmd = commands->NextCommand<SetBlendColorCmd>(); SetBlendConstantCmd* cmd = commands->NextCommand<SetBlendConstantCmd>();
cmd->~SetBlendColorCmd(); cmd->~SetBlendConstantCmd();
break; break;
} }
case Command::SetBindGroup: { case Command::SetBindGroup: {
@ -315,8 +315,8 @@ namespace dawn_native {
commands->NextCommand<SetScissorRectCmd>(); commands->NextCommand<SetScissorRectCmd>();
break; break;
case Command::SetBlendColor: case Command::SetBlendConstant:
commands->NextCommand<SetBlendColorCmd>(); commands->NextCommand<SetBlendConstantCmd>();
break; break;
case Command::SetBindGroup: { case Command::SetBindGroup: {

View File

@ -59,7 +59,7 @@ namespace dawn_native {
SetStencilReference, SetStencilReference,
SetViewport, SetViewport,
SetScissorRect, SetScissorRect,
SetBlendColor, SetBlendConstant,
SetBindGroup, SetBindGroup,
SetIndexBuffer, SetIndexBuffer,
SetVertexBuffer, SetVertexBuffer,
@ -231,7 +231,7 @@ namespace dawn_native {
uint32_t x, y, width, height; uint32_t x, y, width, height;
}; };
struct SetBlendColorCmd { struct SetBlendConstantCmd {
Color color; 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 { mEncodingContext->TryEncode(this, [&](CommandAllocator* allocator) -> MaybeError {
SetBlendColorCmd* cmd = allocator->Allocate<SetBlendColorCmd>(Command::SetBlendColor); SetBlendConstantCmd* cmd =
allocator->Allocate<SetBlendConstantCmd>(Command::SetBlendConstant);
cmd->color = *color; cmd->color = *color;
return {}; return {};
}); });
} }
void RenderPassEncoder::APISetBlendColor(const Color* color) {
GetDevice()->EmitDeprecationWarning(
"SetBlendColor has been deprecated in favor of SetBlendConstant.");
APISetBlendConstant(color);
}
void RenderPassEncoder::APISetViewport(float x, void RenderPassEncoder::APISetViewport(float x,
float y, float y,
float width, float width,

View File

@ -40,7 +40,8 @@ namespace dawn_native {
void APIEndPass(); void APIEndPass();
void APISetStencilReference(uint32_t reference); 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, void APISetViewport(float x,
float y, float y,
float width, float width,

View File

@ -1450,8 +1450,8 @@ namespace dawn_native { namespace d3d12 {
break; break;
} }
case Command::SetBlendColor: { case Command::SetBlendConstant: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>(); SetBlendConstantCmd* cmd = mCommands.NextCommand<SetBlendConstantCmd>();
const std::array<float, 4> color = ConvertToFloatColor(cmd->color); const std::array<float, 4> color = ConvertToFloatColor(cmd->color);
commandList->OMSetBlendFactor(color.data()); commandList->OMSetBlendFactor(color.data());
break; break;

View File

@ -1281,8 +1281,8 @@ namespace dawn_native { namespace metal {
break; break;
} }
case Command::SetBlendColor: { case Command::SetBlendConstant: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>(); SetBlendConstantCmd* cmd = mCommands.NextCommand<SetBlendConstantCmd>();
[encoder setBlendColorRed:cmd->color.r [encoder setBlendColorRed:cmd->color.r
green:cmd->color.g green:cmd->color.g
blue:cmd->color.b blue:cmd->color.b

View File

@ -1218,8 +1218,8 @@ namespace dawn_native { namespace opengl {
break; break;
} }
case Command::SetBlendColor: { case Command::SetBlendConstant: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>(); SetBlendConstantCmd* cmd = mCommands.NextCommand<SetBlendConstantCmd>();
const std::array<float, 4> blendColor = ConvertToFloatColor(cmd->color); const std::array<float, 4> blendColor = ConvertToFloatColor(cmd->color);
gl.BlendColor(blendColor[0], blendColor[1], blendColor[2], blendColor[3]); gl.BlendColor(blendColor[0], blendColor[1], blendColor[2], blendColor[3]);
break; break;

View File

@ -1209,8 +1209,8 @@ namespace dawn_native { namespace vulkan {
return {}; return {};
} }
case Command::SetBlendColor: { case Command::SetBlendConstant: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>(); SetBlendConstantCmd* cmd = mCommands.NextCommand<SetBlendConstantCmd>();
const std::array<float, 4> blendConstants = ConvertToFloatColor(cmd->color); const std::array<float, 4> blendConstants = ConvertToFloatColor(cmd->color);
device->fn.CmdSetBlendConstants(commands, blendConstants.data()); device->fn.CmdSetBlendConstants(commands, blendConstants.data());
break; 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 // Test that after drawing a triangle with the base color, and then the given triangle spec, the
// color is as expected // color is as expected
void DoSingleSourceTest(RGBA8 base, const TriangleSpec& triangle, const RGBA8& expected) { void DoSingleSourceTest(RGBA8 base, const TriangleSpec& triangle, const RGBA8& expected) {
wgpu::Color blendColor{triangle.blendFactor[0], triangle.blendFactor[1], wgpu::Color blendConstant{triangle.blendFactor[0], triangle.blendFactor[1],
triangle.blendFactor[2], triangle.blendFactor[3]}; triangle.blendFactor[2], triangle.blendFactor[3]};
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); 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 // Then use the test pipeline to draw the test triangle with blending
pass.SetPipeline(testPipeline); pass.SetPipeline(testPipeline);
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({{triangle.color}}))); pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({{triangle.color}})));
pass.SetBlendColor(&blendColor); pass.SetBlendConstant(&blendConstant);
pass.Draw(3); pass.Draw(3);
pass.EndPass(); pass.EndPass();
} }
@ -975,7 +975,7 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(0, 0, 0, 0)}}))); MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(0, 0, 0, 0)}})));
pass.Draw(3); pass.Draw(3);
pass.SetPipeline(testPipeline); pass.SetPipeline(testPipeline);
pass.SetBlendColor(&kWhite); pass.SetBlendConstant(&kWhite);
pass.SetBindGroup( pass.SetBindGroup(
0, MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(255, 255, 255, 255)}}))); 0, MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(255, 255, 255, 255)}})));
pass.Draw(3); pass.Draw(3);
@ -999,7 +999,7 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(0, 0, 0, 0)}}))); MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(0, 0, 0, 0)}})));
pass.Draw(3); pass.Draw(3);
pass.SetPipeline(testPipeline); pass.SetPipeline(testPipeline);
pass.SetBlendColor(&kWhite); pass.SetBlendConstant(&kWhite);
pass.SetBindGroup( pass.SetBindGroup(
0, MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(255, 255, 255, 255)}}))); 0, MakeBindGroupForColors(std::array<RGBA8, 1>({{RGBA8(255, 255, 255, 255)}})));
pass.Draw(3); pass.Draw(3);

View File

@ -51,6 +51,18 @@ TEST_P(DeprecationTests, SetIndexBufferWithFormat) {
pass.EndPass(); 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 // Test that BindGroupLayoutEntry cannot have a type if buffer, sampler, texture, or storageTexture
// are defined. // are defined.
TEST_P(DeprecationTests, BindGroupLayoutEntryTypeConflict) { 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); 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 to check basic use of SetBlendConstantTest
TEST_F(SetBlendColorTest, Success) { TEST_F(SetBlendConstantTest, Success) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
constexpr wgpu::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f}; constexpr wgpu::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f};
pass.SetBlendColor(&kTransparentBlack); pass.SetBlendConstant(&kTransparentBlack);
pass.EndPass(); pass.EndPass();
} }
encoder.Finish(); encoder.Finish();
} }
// Test that SetBlendColor allows any value, large, small or negative // Test that SetBlendConstant allows any value, large, small or negative
TEST_F(SetBlendColorTest, AnyValueAllowed) { TEST_F(SetBlendConstantTest, AnyValueAllowed) {
DummyRenderPass renderPass(device); DummyRenderPass renderPass(device);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
constexpr wgpu::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f}; constexpr wgpu::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f};
pass.SetBlendColor(&kAnyColorValue); pass.SetBlendConstant(&kAnyColorValue);
pass.EndPass(); pass.EndPass();
} }
encoder.Finish(); encoder.Finish();