Make setBlendColor take in a Color instead of 4 floats
BUG= Change-Id: Ic70d5b664c0ea64c038129cdb83f4ba05fb61830 Reviewed-on: https://dawn-review.googlesource.com/c/4341 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
d1be0e7077
commit
00976d0db1
|
@ -815,10 +815,7 @@
|
|||
{
|
||||
"name": "set blend color",
|
||||
"args": [
|
||||
{"name": "r", "type": "float"},
|
||||
{"name": "g", "type": "float"},
|
||||
{"name": "b", "type": "float"},
|
||||
{"name": "a", "type": "float"}
|
||||
{"name": "color", "type": "color", "annotation": "const*"}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace dawn_native {
|
|||
};
|
||||
|
||||
struct SetBlendColorCmd {
|
||||
float r, g, b, a;
|
||||
Color color;
|
||||
};
|
||||
|
||||
struct SetBindGroupCmd {
|
||||
|
|
|
@ -90,17 +90,14 @@ namespace dawn_native {
|
|||
cmd->reference = reference;
|
||||
}
|
||||
|
||||
void RenderPassEncoderBase::SetBlendColor(float r, float g, float b, float a) {
|
||||
void RenderPassEncoderBase::SetBlendColor(const Color* color) {
|
||||
if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetBlendColorCmd* cmd = mAllocator->Allocate<SetBlendColorCmd>(Command::SetBlendColor);
|
||||
new (cmd) SetBlendColorCmd;
|
||||
cmd->r = r;
|
||||
cmd->g = g;
|
||||
cmd->b = b;
|
||||
cmd->a = a;
|
||||
cmd->color = *color;
|
||||
}
|
||||
|
||||
void RenderPassEncoderBase::SetScissorRect(uint32_t x,
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace dawn_native {
|
|||
void SetPipeline(RenderPipelineBase* pipeline);
|
||||
|
||||
void SetStencilReference(uint32_t reference);
|
||||
void SetBlendColor(float r, float g, float b, float a);
|
||||
void SetBlendColor(const Color* color);
|
||||
void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -637,7 +637,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
case Command::SetBlendColor: {
|
||||
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
||||
commandList->OMSetBlendFactor(static_cast<const FLOAT*>(&cmd->r));
|
||||
commandList->OMSetBlendFactor(static_cast<const FLOAT*>(&cmd->color.r));
|
||||
} break;
|
||||
|
||||
case Command::SetBindGroup: {
|
||||
|
|
|
@ -483,7 +483,10 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
case Command::SetBlendColor: {
|
||||
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
||||
[encoder setBlendColorRed:cmd->r green:cmd->g blue:cmd->b alpha:cmd->a];
|
||||
[encoder setBlendColorRed:cmd->color.r
|
||||
green:cmd->color.g
|
||||
blue:cmd->color.b
|
||||
alpha:cmd->color.a];
|
||||
} break;
|
||||
|
||||
case Command::SetBindGroup: {
|
||||
|
|
|
@ -662,7 +662,7 @@ namespace dawn_native { namespace opengl {
|
|||
|
||||
case Command::SetBlendColor: {
|
||||
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
||||
glBlendColor(cmd->r, cmd->g, cmd->b, cmd->a);
|
||||
glBlendColor(cmd->color.r, cmd->color.g, cmd->color.b, cmd->color.a);
|
||||
} break;
|
||||
|
||||
case Command::SetBindGroup: {
|
||||
|
|
|
@ -347,10 +347,10 @@ namespace dawn_native { namespace vulkan {
|
|||
case Command::SetBlendColor: {
|
||||
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
|
||||
float blendConstants[4] = {
|
||||
cmd->r,
|
||||
cmd->g,
|
||||
cmd->b,
|
||||
cmd->a,
|
||||
cmd->color.r,
|
||||
cmd->color.g,
|
||||
cmd->color.b,
|
||||
cmd->color.a,
|
||||
};
|
||||
device->fn.CmdSetBlendConstants(commands, blendConstants);
|
||||
} break;
|
||||
|
|
|
@ -104,6 +104,8 @@ class BlendStateTest : 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) {
|
||||
dawn::Color blendColor{triangle.blendFactor[0], triangle.blendFactor[1], triangle.blendFactor[2], triangle.blendFactor[3]};
|
||||
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
|
@ -115,7 +117,7 @@ class BlendStateTest : 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(triangle.blendFactor[0], triangle.blendFactor[1], triangle.blendFactor[2], triangle.blendFactor[3]);
|
||||
pass.SetBlendColor(&blendColor);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
@ -884,6 +886,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
testDescriptor.cBlendStates[0].alphaBlend = blend;
|
||||
|
||||
testPipeline = device.CreateRenderPipeline(&testDescriptor);
|
||||
constexpr dawn::Color kWhite{1.0f, 1.0f, 1.0f, 1.0f};
|
||||
|
||||
// Check that the initial blend color is (0,0,0,0)
|
||||
{
|
||||
|
@ -914,7 +917,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.SetPipeline(testPipeline);
|
||||
pass.SetBlendColor(1, 1, 1, 1);
|
||||
pass.SetBlendColor(&kWhite);
|
||||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(255, 255, 255, 255) } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
|
@ -935,7 +938,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) {
|
|||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.SetPipeline(testPipeline);
|
||||
pass.SetBlendColor(1, 1, 1, 1);
|
||||
pass.SetBlendColor(&kWhite);
|
||||
pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(255, 255, 255, 255) } })));
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
|
|
|
@ -68,7 +68,8 @@ TEST_F(SetBlendColorTest, Success) {
|
|||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetBlendColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
constexpr dawn::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f};
|
||||
pass.SetBlendColor(&kTransparentBlack);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
|
@ -81,7 +82,8 @@ TEST_F(SetBlendColorTest, AnyValueAllowed) {
|
|||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetBlendColor(-1.0f, 42.0f, -0.0f, 0.0f);
|
||||
constexpr dawn::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f};
|
||||
pass.SetBlendColor(&kAnyColorValue);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
|
@ -90,7 +92,7 @@ TEST_F(SetBlendColorTest, AnyValueAllowed) {
|
|||
class SetStencilReferenceTest : public ValidationTest {
|
||||
};
|
||||
|
||||
// Test to check basic use of SetBlendColor
|
||||
// Test to check basic use of SetStencilReferenceTest
|
||||
TEST_F(SetStencilReferenceTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
|
|
Loading…
Reference in New Issue