Remove deprecated SetBlendColor and blend factors
Bug: chromium:1199057 Change-Id: I6fdc08f0a62b579b556c4c910611d095fcb3a66f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63381 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
parent
fdfbb3aab3
commit
10b9cce816
15
dawn.json
15
dawn.json
|
@ -223,14 +223,7 @@
|
|||
{"value": 9, "name": "one minus dst alpha"},
|
||||
{"value": 10, "name": "src alpha saturated"},
|
||||
{"value": 11, "name": "constant"},
|
||||
{"value": 12, "name": "one minus constant"},
|
||||
|
||||
{"value": 102, "name": "src color"},
|
||||
{"value": 103, "name": "one minus src color"},
|
||||
{"value": 106, "name": "dst color"},
|
||||
{"value": 107, "name": "one minus dst color"},
|
||||
{"value": 111, "name": "blend color"},
|
||||
{"value": 112, "name": "one minus blend color"}
|
||||
{"value": 12, "name": "one minus constant"}
|
||||
]
|
||||
},
|
||||
"blend operation": {
|
||||
|
@ -1474,12 +1467,6 @@
|
|||
{"name": "reference", "type": "uint32_t"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set blend color",
|
||||
"args": [
|
||||
{"name": "color", "type": "color", "annotation": "const*"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set blend constant",
|
||||
"args": [
|
||||
|
|
|
@ -215,25 +215,6 @@ namespace dawn_native {
|
|||
return {};
|
||||
}
|
||||
|
||||
static constexpr wgpu::BlendFactor kFirstDeprecatedBlendFactor =
|
||||
wgpu::BlendFactor::SrcColor;
|
||||
static constexpr uint32_t kDeprecatedBlendFactorOffset = 100;
|
||||
|
||||
bool IsDeprecatedBlendFactor(wgpu::BlendFactor blendFactor) {
|
||||
return blendFactor >= kFirstDeprecatedBlendFactor;
|
||||
}
|
||||
|
||||
wgpu::BlendFactor NormalizeBlendFactor(wgpu::BlendFactor blendFactor) {
|
||||
// If the specified format is from the deprecated range return the corresponding
|
||||
// non-deprecated format.
|
||||
if (blendFactor >= kFirstDeprecatedBlendFactor) {
|
||||
uint32_t blendFactorValue = static_cast<uint32_t>(blendFactor);
|
||||
return static_cast<wgpu::BlendFactor>(blendFactorValue -
|
||||
kDeprecatedBlendFactorOffset);
|
||||
}
|
||||
return blendFactor;
|
||||
}
|
||||
|
||||
MaybeError ValidateBlendState(DeviceBase* device, const BlendState* descriptor) {
|
||||
DAWN_TRY(ValidateBlendOperation(descriptor->alpha.operation));
|
||||
DAWN_TRY(ValidateBlendFactor(descriptor->alpha.srcFactor));
|
||||
|
@ -241,15 +222,6 @@ namespace dawn_native {
|
|||
DAWN_TRY(ValidateBlendOperation(descriptor->color.operation));
|
||||
DAWN_TRY(ValidateBlendFactor(descriptor->color.srcFactor));
|
||||
DAWN_TRY(ValidateBlendFactor(descriptor->color.dstFactor));
|
||||
|
||||
if (IsDeprecatedBlendFactor(descriptor->alpha.srcFactor) ||
|
||||
IsDeprecatedBlendFactor(descriptor->alpha.dstFactor) ||
|
||||
IsDeprecatedBlendFactor(descriptor->color.srcFactor) ||
|
||||
IsDeprecatedBlendFactor(descriptor->color.dstFactor)) {
|
||||
device->EmitDeprecationWarning(
|
||||
"Blend factor enums have changed and the old enums will be removed soon.");
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -566,14 +538,6 @@ namespace dawn_native {
|
|||
if (target->blend != nullptr) {
|
||||
mTargetBlend[i] = *target->blend;
|
||||
mTargets[i].blend = &mTargetBlend[i];
|
||||
mTargetBlend[i].alpha.srcFactor =
|
||||
NormalizeBlendFactor(mTargetBlend[i].alpha.srcFactor);
|
||||
mTargetBlend[i].alpha.dstFactor =
|
||||
NormalizeBlendFactor(mTargetBlend[i].alpha.dstFactor);
|
||||
mTargetBlend[i].color.srcFactor =
|
||||
NormalizeBlendFactor(mTargetBlend[i].color.srcFactor);
|
||||
mTargetBlend[i].color.dstFactor =
|
||||
NormalizeBlendFactor(mTargetBlend[i].color.dstFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,15 +173,6 @@ namespace dawn_native { namespace d3d12 {
|
|||
return D3D12_BLEND_BLEND_FACTOR;
|
||||
case wgpu::BlendFactor::OneMinusConstant:
|
||||
return D3D12_BLEND_INV_BLEND_FACTOR;
|
||||
|
||||
// Deprecated blend factors should be normalized prior to this call.
|
||||
case wgpu::BlendFactor::SrcColor:
|
||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
||||
case wgpu::BlendFactor::DstColor:
|
||||
case wgpu::BlendFactor::OneMinusDstColor:
|
||||
case wgpu::BlendFactor::BlendColor:
|
||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,15 +158,6 @@ namespace dawn_native { namespace metal {
|
|||
case wgpu::BlendFactor::OneMinusConstant:
|
||||
return alpha ? MTLBlendFactorOneMinusBlendAlpha
|
||||
: MTLBlendFactorOneMinusBlendColor;
|
||||
|
||||
// Deprecated blend factors should be normalized prior to this call.
|
||||
case wgpu::BlendFactor::SrcColor:
|
||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
||||
case wgpu::BlendFactor::DstColor:
|
||||
case wgpu::BlendFactor::OneMinusDstColor:
|
||||
case wgpu::BlendFactor::BlendColor:
|
||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,15 +84,6 @@ namespace dawn_native { namespace opengl {
|
|||
return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR;
|
||||
case wgpu::BlendFactor::OneMinusConstant:
|
||||
return alpha ? GL_ONE_MINUS_CONSTANT_ALPHA : GL_ONE_MINUS_CONSTANT_COLOR;
|
||||
|
||||
// Deprecated blend factors should be normalized prior to this call.
|
||||
case wgpu::BlendFactor::SrcColor:
|
||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
||||
case wgpu::BlendFactor::DstColor:
|
||||
case wgpu::BlendFactor::OneMinusDstColor:
|
||||
case wgpu::BlendFactor::BlendColor:
|
||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -180,15 +180,6 @@ namespace dawn_native { namespace vulkan {
|
|||
return VK_BLEND_FACTOR_CONSTANT_COLOR;
|
||||
case wgpu::BlendFactor::OneMinusConstant:
|
||||
return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR;
|
||||
|
||||
// Deprecated blend factors should be normalized prior to this call.
|
||||
case wgpu::BlendFactor::SrcColor:
|
||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
||||
case wgpu::BlendFactor::DstColor:
|
||||
case wgpu::BlendFactor::OneMinusDstColor:
|
||||
case wgpu::BlendFactor::BlendColor:
|
||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,18 +34,6 @@ class DeprecationTests : public DawnTest {
|
|||
}
|
||||
};
|
||||
|
||||
// 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 setting attachment rather than view for render pass color and depth/stencil attachments
|
||||
// is deprecated.
|
||||
TEST_P(DeprecationTests, SetAttachmentDescriptorAttachment) {
|
||||
|
@ -156,120 +144,3 @@ DAWN_INSTANTIATE_TEST(DeprecationTests,
|
|||
OpenGLBackend(),
|
||||
OpenGLESBackend(),
|
||||
VulkanBackend());
|
||||
|
||||
class ImageCopyBufferDeprecationTests : public DeprecationTests {
|
||||
protected:
|
||||
wgpu::ImageCopyTexture MakeImageCopyTexture() {
|
||||
wgpu::TextureDescriptor desc = {};
|
||||
desc.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::CopyDst;
|
||||
desc.dimension = wgpu::TextureDimension::e2D;
|
||||
desc.size = {1, 1, 2};
|
||||
desc.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||
|
||||
wgpu::ImageCopyTexture copy;
|
||||
copy.texture = device.CreateTexture(&desc);
|
||||
copy.origin = {0, 0, 1};
|
||||
return copy;
|
||||
}
|
||||
|
||||
wgpu::Extent3D copySize = {1, 1, 1};
|
||||
};
|
||||
|
||||
// Tests that deprecated blend factors properly raise a deprecation warning when used
|
||||
class BlendFactorDeprecationTests : public DeprecationTests {
|
||||
protected:
|
||||
// Runs the test
|
||||
void DoTest(const wgpu::BlendFactor blendFactor, bool deprecated) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)");
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
||||
utils::ComboRenderPipelineDescriptor descriptor;
|
||||
descriptor.vertex.module = vsModule;
|
||||
descriptor.cFragment.module = fsModule;
|
||||
descriptor.cTargets[0].blend = &descriptor.cBlends[0];
|
||||
|
||||
descriptor.cBlends[0].color.srcFactor = blendFactor;
|
||||
if (deprecated) {
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
|
||||
} else {
|
||||
device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
descriptor.cBlends[0].color.srcFactor = wgpu::BlendFactor::One;
|
||||
|
||||
descriptor.cBlends[0].color.dstFactor = blendFactor;
|
||||
if (deprecated) {
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
|
||||
} else {
|
||||
device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
descriptor.cBlends[0].color.dstFactor = wgpu::BlendFactor::Zero;
|
||||
|
||||
descriptor.cBlends[0].alpha.srcFactor = blendFactor;
|
||||
if (deprecated) {
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
|
||||
} else {
|
||||
device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
descriptor.cBlends[0].alpha.srcFactor = wgpu::BlendFactor::One;
|
||||
|
||||
descriptor.cBlends[0].alpha.dstFactor = blendFactor;
|
||||
if (deprecated) {
|
||||
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
|
||||
} else {
|
||||
device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
descriptor.cBlends[0].alpha.dstFactor = wgpu::BlendFactor::Zero;
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr std::array<wgpu::BlendFactor, 13> kBlendFactors = {
|
||||
wgpu::BlendFactor::Zero,
|
||||
wgpu::BlendFactor::One,
|
||||
wgpu::BlendFactor::Src,
|
||||
wgpu::BlendFactor::OneMinusSrc,
|
||||
wgpu::BlendFactor::SrcAlpha,
|
||||
wgpu::BlendFactor::OneMinusSrcAlpha,
|
||||
wgpu::BlendFactor::Dst,
|
||||
wgpu::BlendFactor::OneMinusDst,
|
||||
wgpu::BlendFactor::DstAlpha,
|
||||
wgpu::BlendFactor::OneMinusDstAlpha,
|
||||
wgpu::BlendFactor::SrcAlphaSaturated,
|
||||
wgpu::BlendFactor::Constant,
|
||||
wgpu::BlendFactor::OneMinusConstant,
|
||||
};
|
||||
|
||||
TEST_P(BlendFactorDeprecationTests, CurrentBlendFactors) {
|
||||
// Using the new blend factors does not emit a warning.
|
||||
for (auto& format : kBlendFactors) {
|
||||
DoTest(format, false);
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr std::array<wgpu::BlendFactor, 6> kDeprecatedBlendFactors = {
|
||||
wgpu::BlendFactor::SrcColor, wgpu::BlendFactor::OneMinusSrcColor,
|
||||
wgpu::BlendFactor::DstColor, wgpu::BlendFactor::OneMinusDstColor,
|
||||
wgpu::BlendFactor::BlendColor, wgpu::BlendFactor::OneMinusBlendColor,
|
||||
};
|
||||
|
||||
TEST_P(BlendFactorDeprecationTests, DeprecatedBlendFactors) {
|
||||
// Using deprecated blend factors does emit a warning.
|
||||
for (auto& format : kDeprecatedBlendFactors) {
|
||||
DoTest(format, true);
|
||||
}
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(BlendFactorDeprecationTests,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
NullBackend(),
|
||||
OpenGLBackend(),
|
||||
OpenGLESBackend(),
|
||||
VulkanBackend());
|
||||
|
|
Loading…
Reference in New Issue