mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-15 03:41:34 +00:00
Updated BlendFactor enum to match spec
Several of the enum names have changed recently. Update them to match the spec and mark the older ones as deprecated. BUG: chromium:1199057 Change-Id: I7a29588dd18b8fb738773c2478b173093f2aa834 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47860 Commit-Queue: Brandon Jones <bajones@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
5c9b6a8f81
commit
22b923cc91
19
dawn.json
19
dawn.json
@ -226,17 +226,24 @@
|
|||||||
"values": [
|
"values": [
|
||||||
{"value": 0, "name": "zero"},
|
{"value": 0, "name": "zero"},
|
||||||
{"value": 1, "name": "one"},
|
{"value": 1, "name": "one"},
|
||||||
{"value": 2, "name": "src color"},
|
{"value": 2, "name": "src"},
|
||||||
{"value": 3, "name": "one minus src color"},
|
{"value": 3, "name": "one minus src"},
|
||||||
{"value": 4, "name": "src alpha"},
|
{"value": 4, "name": "src alpha"},
|
||||||
{"value": 5, "name": "one minus src alpha"},
|
{"value": 5, "name": "one minus src alpha"},
|
||||||
{"value": 6, "name": "dst color"},
|
{"value": 6, "name": "dst"},
|
||||||
{"value": 7, "name": "one minus dst color"},
|
{"value": 7, "name": "one minus dst"},
|
||||||
{"value": 8, "name": "dst alpha"},
|
{"value": 8, "name": "dst alpha"},
|
||||||
{"value": 9, "name": "one minus dst alpha"},
|
{"value": 9, "name": "one minus dst alpha"},
|
||||||
{"value": 10, "name": "src alpha saturated"},
|
{"value": 10, "name": "src alpha saturated"},
|
||||||
{"value": 11, "name": "blend color"},
|
{"value": 11, "name": "constant"},
|
||||||
{"value": 12, "name": "one minus blend color"}
|
{"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"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"blend operation": {
|
"blend operation": {
|
||||||
|
@ -211,7 +211,26 @@ namespace dawn_native {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ValidateBlendState(const BlendState* descriptor) {
|
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(ValidateBlendOperation(descriptor->alpha.operation));
|
||||||
DAWN_TRY(ValidateBlendFactor(descriptor->alpha.srcFactor));
|
DAWN_TRY(ValidateBlendFactor(descriptor->alpha.srcFactor));
|
||||||
DAWN_TRY(ValidateBlendFactor(descriptor->alpha.dstFactor));
|
DAWN_TRY(ValidateBlendFactor(descriptor->alpha.dstFactor));
|
||||||
@ -219,10 +238,18 @@ namespace dawn_native {
|
|||||||
DAWN_TRY(ValidateBlendFactor(descriptor->color.srcFactor));
|
DAWN_TRY(ValidateBlendFactor(descriptor->color.srcFactor));
|
||||||
DAWN_TRY(ValidateBlendFactor(descriptor->color.dstFactor));
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ValidateColorTargetState(const DeviceBase* device,
|
MaybeError ValidateColorTargetState(DeviceBase* device,
|
||||||
const ColorTargetState* descriptor,
|
const ColorTargetState* descriptor,
|
||||||
bool fragmentWritten,
|
bool fragmentWritten,
|
||||||
wgpu::TextureComponentType fragmentOutputBaseType) {
|
wgpu::TextureComponentType fragmentOutputBaseType) {
|
||||||
@ -231,7 +258,7 @@ namespace dawn_native {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor->blend) {
|
if (descriptor->blend) {
|
||||||
DAWN_TRY(ValidateBlendState(descriptor->blend));
|
DAWN_TRY(ValidateBlendState(device, descriptor->blend));
|
||||||
}
|
}
|
||||||
|
|
||||||
DAWN_TRY(ValidateColorWriteMask(descriptor->writeMask));
|
DAWN_TRY(ValidateColorWriteMask(descriptor->writeMask));
|
||||||
@ -440,6 +467,14 @@ namespace dawn_native {
|
|||||||
if (target->blend != nullptr) {
|
if (target->blend != nullptr) {
|
||||||
mTargetBlend[i] = *target->blend;
|
mTargetBlend[i] = *target->blend;
|
||||||
mTargets[i].blend = &mTargetBlend[i];
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,17 +151,17 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
return D3D12_BLEND_ZERO;
|
return D3D12_BLEND_ZERO;
|
||||||
case wgpu::BlendFactor::One:
|
case wgpu::BlendFactor::One:
|
||||||
return D3D12_BLEND_ONE;
|
return D3D12_BLEND_ONE;
|
||||||
case wgpu::BlendFactor::SrcColor:
|
case wgpu::BlendFactor::Src:
|
||||||
return D3D12_BLEND_SRC_COLOR;
|
return D3D12_BLEND_SRC_COLOR;
|
||||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
case wgpu::BlendFactor::OneMinusSrc:
|
||||||
return D3D12_BLEND_INV_SRC_COLOR;
|
return D3D12_BLEND_INV_SRC_COLOR;
|
||||||
case wgpu::BlendFactor::SrcAlpha:
|
case wgpu::BlendFactor::SrcAlpha:
|
||||||
return D3D12_BLEND_SRC_ALPHA;
|
return D3D12_BLEND_SRC_ALPHA;
|
||||||
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
||||||
return D3D12_BLEND_INV_SRC_ALPHA;
|
return D3D12_BLEND_INV_SRC_ALPHA;
|
||||||
case wgpu::BlendFactor::DstColor:
|
case wgpu::BlendFactor::Dst:
|
||||||
return D3D12_BLEND_DEST_COLOR;
|
return D3D12_BLEND_DEST_COLOR;
|
||||||
case wgpu::BlendFactor::OneMinusDstColor:
|
case wgpu::BlendFactor::OneMinusDst:
|
||||||
return D3D12_BLEND_INV_DEST_COLOR;
|
return D3D12_BLEND_INV_DEST_COLOR;
|
||||||
case wgpu::BlendFactor::DstAlpha:
|
case wgpu::BlendFactor::DstAlpha:
|
||||||
return D3D12_BLEND_DEST_ALPHA;
|
return D3D12_BLEND_DEST_ALPHA;
|
||||||
@ -169,10 +169,39 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
return D3D12_BLEND_INV_DEST_ALPHA;
|
return D3D12_BLEND_INV_DEST_ALPHA;
|
||||||
case wgpu::BlendFactor::SrcAlphaSaturated:
|
case wgpu::BlendFactor::SrcAlphaSaturated:
|
||||||
return D3D12_BLEND_SRC_ALPHA_SAT;
|
return D3D12_BLEND_SRC_ALPHA_SAT;
|
||||||
case wgpu::BlendFactor::BlendColor:
|
case wgpu::BlendFactor::Constant:
|
||||||
return D3D12_BLEND_BLEND_FACTOR;
|
return D3D12_BLEND_BLEND_FACTOR;
|
||||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
case wgpu::BlendFactor::OneMinusConstant:
|
||||||
return D3D12_BLEND_INV_BLEND_FACTOR;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// When a blend factor is defined for the alpha channel, any of the factors that don't
|
||||||
|
// explicitly state that they apply to alpha should be treated as their explicitly-alpha
|
||||||
|
// equivalents. See: https://github.com/gpuweb/gpuweb/issues/65
|
||||||
|
D3D12_BLEND D3D12AlphaBlend(wgpu::BlendFactor factor) {
|
||||||
|
switch (factor) {
|
||||||
|
case wgpu::BlendFactor::Src:
|
||||||
|
return D3D12_BLEND_SRC_ALPHA;
|
||||||
|
case wgpu::BlendFactor::OneMinusSrc:
|
||||||
|
return D3D12_BLEND_INV_SRC_ALPHA;
|
||||||
|
case wgpu::BlendFactor::Dst:
|
||||||
|
return D3D12_BLEND_DEST_ALPHA;
|
||||||
|
case wgpu::BlendFactor::OneMinusDst:
|
||||||
|
return D3D12_BLEND_INV_DEST_ALPHA;
|
||||||
|
|
||||||
|
// Other blend factors translate to the same D3D12 enum as the color blend factors.
|
||||||
|
default:
|
||||||
|
return D3D12Blend(factor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,8 +243,8 @@ namespace dawn_native { namespace d3d12 {
|
|||||||
blendDesc.SrcBlend = D3D12Blend(state->blend->color.srcFactor);
|
blendDesc.SrcBlend = D3D12Blend(state->blend->color.srcFactor);
|
||||||
blendDesc.DestBlend = D3D12Blend(state->blend->color.dstFactor);
|
blendDesc.DestBlend = D3D12Blend(state->blend->color.dstFactor);
|
||||||
blendDesc.BlendOp = D3D12BlendOperation(state->blend->color.operation);
|
blendDesc.BlendOp = D3D12BlendOperation(state->blend->color.operation);
|
||||||
blendDesc.SrcBlendAlpha = D3D12Blend(state->blend->alpha.srcFactor);
|
blendDesc.SrcBlendAlpha = D3D12AlphaBlend(state->blend->alpha.srcFactor);
|
||||||
blendDesc.DestBlendAlpha = D3D12Blend(state->blend->alpha.dstFactor);
|
blendDesc.DestBlendAlpha = D3D12AlphaBlend(state->blend->alpha.dstFactor);
|
||||||
blendDesc.BlendOpAlpha = D3D12BlendOperation(state->blend->alpha.operation);
|
blendDesc.BlendOpAlpha = D3D12BlendOperation(state->blend->alpha.operation);
|
||||||
}
|
}
|
||||||
blendDesc.RenderTargetWriteMask = D3D12RenderTargetWriteMask(state->writeMask);
|
blendDesc.RenderTargetWriteMask = D3D12RenderTargetWriteMask(state->writeMask);
|
||||||
|
@ -135,17 +135,17 @@ namespace dawn_native { namespace metal {
|
|||||||
return MTLBlendFactorZero;
|
return MTLBlendFactorZero;
|
||||||
case wgpu::BlendFactor::One:
|
case wgpu::BlendFactor::One:
|
||||||
return MTLBlendFactorOne;
|
return MTLBlendFactorOne;
|
||||||
case wgpu::BlendFactor::SrcColor:
|
case wgpu::BlendFactor::Src:
|
||||||
return MTLBlendFactorSourceColor;
|
return MTLBlendFactorSourceColor;
|
||||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
case wgpu::BlendFactor::OneMinusSrc:
|
||||||
return MTLBlendFactorOneMinusSourceColor;
|
return MTLBlendFactorOneMinusSourceColor;
|
||||||
case wgpu::BlendFactor::SrcAlpha:
|
case wgpu::BlendFactor::SrcAlpha:
|
||||||
return MTLBlendFactorSourceAlpha;
|
return MTLBlendFactorSourceAlpha;
|
||||||
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
||||||
return MTLBlendFactorOneMinusSourceAlpha;
|
return MTLBlendFactorOneMinusSourceAlpha;
|
||||||
case wgpu::BlendFactor::DstColor:
|
case wgpu::BlendFactor::Dst:
|
||||||
return MTLBlendFactorDestinationColor;
|
return MTLBlendFactorDestinationColor;
|
||||||
case wgpu::BlendFactor::OneMinusDstColor:
|
case wgpu::BlendFactor::OneMinusDst:
|
||||||
return MTLBlendFactorOneMinusDestinationColor;
|
return MTLBlendFactorOneMinusDestinationColor;
|
||||||
case wgpu::BlendFactor::DstAlpha:
|
case wgpu::BlendFactor::DstAlpha:
|
||||||
return MTLBlendFactorDestinationAlpha;
|
return MTLBlendFactorDestinationAlpha;
|
||||||
@ -153,11 +153,20 @@ namespace dawn_native { namespace metal {
|
|||||||
return MTLBlendFactorOneMinusDestinationAlpha;
|
return MTLBlendFactorOneMinusDestinationAlpha;
|
||||||
case wgpu::BlendFactor::SrcAlphaSaturated:
|
case wgpu::BlendFactor::SrcAlphaSaturated:
|
||||||
return MTLBlendFactorSourceAlphaSaturated;
|
return MTLBlendFactorSourceAlphaSaturated;
|
||||||
case wgpu::BlendFactor::BlendColor:
|
case wgpu::BlendFactor::Constant:
|
||||||
return alpha ? MTLBlendFactorBlendAlpha : MTLBlendFactorBlendColor;
|
return alpha ? MTLBlendFactorBlendAlpha : MTLBlendFactorBlendColor;
|
||||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
case wgpu::BlendFactor::OneMinusConstant:
|
||||||
return alpha ? MTLBlendFactorOneMinusBlendAlpha
|
return alpha ? MTLBlendFactorOneMinusBlendAlpha
|
||||||
: MTLBlendFactorOneMinusBlendColor;
|
: 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,17 +62,17 @@ namespace dawn_native { namespace opengl {
|
|||||||
return GL_ZERO;
|
return GL_ZERO;
|
||||||
case wgpu::BlendFactor::One:
|
case wgpu::BlendFactor::One:
|
||||||
return GL_ONE;
|
return GL_ONE;
|
||||||
case wgpu::BlendFactor::SrcColor:
|
case wgpu::BlendFactor::Src:
|
||||||
return GL_SRC_COLOR;
|
return GL_SRC_COLOR;
|
||||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
case wgpu::BlendFactor::OneMinusSrc:
|
||||||
return GL_ONE_MINUS_SRC_COLOR;
|
return GL_ONE_MINUS_SRC_COLOR;
|
||||||
case wgpu::BlendFactor::SrcAlpha:
|
case wgpu::BlendFactor::SrcAlpha:
|
||||||
return GL_SRC_ALPHA;
|
return GL_SRC_ALPHA;
|
||||||
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
||||||
return GL_ONE_MINUS_SRC_ALPHA;
|
return GL_ONE_MINUS_SRC_ALPHA;
|
||||||
case wgpu::BlendFactor::DstColor:
|
case wgpu::BlendFactor::Dst:
|
||||||
return GL_DST_COLOR;
|
return GL_DST_COLOR;
|
||||||
case wgpu::BlendFactor::OneMinusDstColor:
|
case wgpu::BlendFactor::OneMinusDst:
|
||||||
return GL_ONE_MINUS_DST_COLOR;
|
return GL_ONE_MINUS_DST_COLOR;
|
||||||
case wgpu::BlendFactor::DstAlpha:
|
case wgpu::BlendFactor::DstAlpha:
|
||||||
return GL_DST_ALPHA;
|
return GL_DST_ALPHA;
|
||||||
@ -80,10 +80,19 @@ namespace dawn_native { namespace opengl {
|
|||||||
return GL_ONE_MINUS_DST_ALPHA;
|
return GL_ONE_MINUS_DST_ALPHA;
|
||||||
case wgpu::BlendFactor::SrcAlphaSaturated:
|
case wgpu::BlendFactor::SrcAlphaSaturated:
|
||||||
return GL_SRC_ALPHA_SATURATE;
|
return GL_SRC_ALPHA_SATURATE;
|
||||||
case wgpu::BlendFactor::BlendColor:
|
case wgpu::BlendFactor::Constant:
|
||||||
return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR;
|
return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR;
|
||||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
case wgpu::BlendFactor::OneMinusConstant:
|
||||||
return alpha ? GL_ONE_MINUS_CONSTANT_ALPHA : GL_ONE_MINUS_CONSTANT_COLOR;
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,17 +158,17 @@ namespace dawn_native { namespace vulkan {
|
|||||||
return VK_BLEND_FACTOR_ZERO;
|
return VK_BLEND_FACTOR_ZERO;
|
||||||
case wgpu::BlendFactor::One:
|
case wgpu::BlendFactor::One:
|
||||||
return VK_BLEND_FACTOR_ONE;
|
return VK_BLEND_FACTOR_ONE;
|
||||||
case wgpu::BlendFactor::SrcColor:
|
case wgpu::BlendFactor::Src:
|
||||||
return VK_BLEND_FACTOR_SRC_COLOR;
|
return VK_BLEND_FACTOR_SRC_COLOR;
|
||||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
case wgpu::BlendFactor::OneMinusSrc:
|
||||||
return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR;
|
return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR;
|
||||||
case wgpu::BlendFactor::SrcAlpha:
|
case wgpu::BlendFactor::SrcAlpha:
|
||||||
return VK_BLEND_FACTOR_SRC_ALPHA;
|
return VK_BLEND_FACTOR_SRC_ALPHA;
|
||||||
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
||||||
return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||||
case wgpu::BlendFactor::DstColor:
|
case wgpu::BlendFactor::Dst:
|
||||||
return VK_BLEND_FACTOR_DST_COLOR;
|
return VK_BLEND_FACTOR_DST_COLOR;
|
||||||
case wgpu::BlendFactor::OneMinusDstColor:
|
case wgpu::BlendFactor::OneMinusDst:
|
||||||
return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR;
|
return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR;
|
||||||
case wgpu::BlendFactor::DstAlpha:
|
case wgpu::BlendFactor::DstAlpha:
|
||||||
return VK_BLEND_FACTOR_DST_ALPHA;
|
return VK_BLEND_FACTOR_DST_ALPHA;
|
||||||
@ -176,10 +176,19 @@ namespace dawn_native { namespace vulkan {
|
|||||||
return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA;
|
return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA;
|
||||||
case wgpu::BlendFactor::SrcAlphaSaturated:
|
case wgpu::BlendFactor::SrcAlphaSaturated:
|
||||||
return VK_BLEND_FACTOR_SRC_ALPHA_SATURATE;
|
return VK_BLEND_FACTOR_SRC_ALPHA_SATURATE;
|
||||||
case wgpu::BlendFactor::BlendColor:
|
case wgpu::BlendFactor::Constant:
|
||||||
return VK_BLEND_FACTOR_CONSTANT_COLOR;
|
return VK_BLEND_FACTOR_CONSTANT_COLOR;
|
||||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
case wgpu::BlendFactor::OneMinusConstant:
|
||||||
return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR;
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ TEST_P(ColorStateTest, SrcBlendFactorOne) {
|
|||||||
CheckSrcBlendFactor(base, wgpu::BlendFactor::One, wgpu::BlendFactor::One, tests);
|
CheckSrcBlendFactor(base, wgpu::BlendFactor::One, wgpu::BlendFactor::One, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, SrcBlendFactorSrcColor) {
|
TEST_P(ColorStateTest, SrcBlendFactorSrc) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -381,10 +381,10 @@ TEST_P(ColorStateTest, SrcBlendFactorSrcColor) {
|
|||||||
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
|
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
|
||||||
return std::make_pair(TriangleSpec({{color}}), expected);
|
return std::make_pair(TriangleSpec({{color}}), expected);
|
||||||
});
|
});
|
||||||
CheckSrcBlendFactor(base, wgpu::BlendFactor::SrcColor, wgpu::BlendFactor::Zero, tests);
|
CheckSrcBlendFactor(base, wgpu::BlendFactor::Src, wgpu::BlendFactor::Zero, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, SrcBlendFactorOneMinusSrcColor) {
|
TEST_P(ColorStateTest, SrcBlendFactorOneMinusSrc) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -394,7 +394,7 @@ TEST_P(ColorStateTest, SrcBlendFactorOneMinusSrcColor) {
|
|||||||
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
|
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
|
||||||
return std::make_pair(TriangleSpec({{color}}), expected);
|
return std::make_pair(TriangleSpec({{color}}), expected);
|
||||||
});
|
});
|
||||||
CheckSrcBlendFactor(base, wgpu::BlendFactor::OneMinusSrcColor, wgpu::BlendFactor::Zero, tests);
|
CheckSrcBlendFactor(base, wgpu::BlendFactor::OneMinusSrc, wgpu::BlendFactor::Zero, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, SrcBlendFactorSrcAlpha) {
|
TEST_P(ColorStateTest, SrcBlendFactorSrcAlpha) {
|
||||||
@ -422,7 +422,7 @@ TEST_P(ColorStateTest, SrcBlendFactorOneMinusSrcAlpha) {
|
|||||||
wgpu::BlendFactor::OneMinusSrcAlpha, tests);
|
wgpu::BlendFactor::OneMinusSrcAlpha, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, SrcBlendFactorDstColor) {
|
TEST_P(ColorStateTest, SrcBlendFactorDst) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -432,10 +432,10 @@ TEST_P(ColorStateTest, SrcBlendFactorDstColor) {
|
|||||||
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
|
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
|
||||||
return std::make_pair(TriangleSpec({{color}}), expected);
|
return std::make_pair(TriangleSpec({{color}}), expected);
|
||||||
});
|
});
|
||||||
CheckSrcBlendFactor(base, wgpu::BlendFactor::DstColor, wgpu::BlendFactor::Zero, tests);
|
CheckSrcBlendFactor(base, wgpu::BlendFactor::Dst, wgpu::BlendFactor::Zero, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, SrcBlendFactorOneMinusDstColor) {
|
TEST_P(ColorStateTest, SrcBlendFactorOneMinusDst) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -445,7 +445,7 @@ TEST_P(ColorStateTest, SrcBlendFactorOneMinusDstColor) {
|
|||||||
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
|
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, fac);
|
||||||
return std::make_pair(TriangleSpec({{color}}), expected);
|
return std::make_pair(TriangleSpec({{color}}), expected);
|
||||||
});
|
});
|
||||||
CheckSrcBlendFactor(base, wgpu::BlendFactor::OneMinusDstColor, wgpu::BlendFactor::Zero, tests);
|
CheckSrcBlendFactor(base, wgpu::BlendFactor::OneMinusDst, wgpu::BlendFactor::Zero, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, SrcBlendFactorDstAlpha) {
|
TEST_P(ColorStateTest, SrcBlendFactorDstAlpha) {
|
||||||
@ -487,7 +487,7 @@ TEST_P(ColorStateTest, SrcBlendFactorSrcAlphaSaturated) {
|
|||||||
wgpu::BlendFactor::SrcAlphaSaturated, tests);
|
wgpu::BlendFactor::SrcAlphaSaturated, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, SrcBlendFactorBlendColor) {
|
TEST_P(ColorStateTest, SrcBlendFactorConstant) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(
|
std::transform(
|
||||||
@ -496,10 +496,10 @@ TEST_P(ColorStateTest, SrcBlendFactorBlendColor) {
|
|||||||
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, triangleSpec.blendFactor);
|
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, triangleSpec.blendFactor);
|
||||||
return std::make_pair(triangleSpec, expected);
|
return std::make_pair(triangleSpec, expected);
|
||||||
});
|
});
|
||||||
CheckSrcBlendFactor(base, wgpu::BlendFactor::BlendColor, wgpu::BlendFactor::BlendColor, tests);
|
CheckSrcBlendFactor(base, wgpu::BlendFactor::Constant, wgpu::BlendFactor::Constant, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, SrcBlendFactorOneMinusBlendColor) {
|
TEST_P(ColorStateTest, SrcBlendFactorOneMinusConstant) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -509,8 +509,8 @@ TEST_P(ColorStateTest, SrcBlendFactorOneMinusBlendColor) {
|
|||||||
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, f);
|
RGBA8 expected = base + mix(RGBA8(0, 0, 0, 0), color, f);
|
||||||
return std::make_pair(triangleSpec, expected);
|
return std::make_pair(triangleSpec, expected);
|
||||||
});
|
});
|
||||||
CheckSrcBlendFactor(base, wgpu::BlendFactor::OneMinusBlendColor,
|
CheckSrcBlendFactor(base, wgpu::BlendFactor::OneMinusConstant,
|
||||||
wgpu::BlendFactor::OneMinusBlendColor, tests);
|
wgpu::BlendFactor::OneMinusConstant, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following tests check that the Destination blend factor works
|
// The following tests check that the Destination blend factor works
|
||||||
@ -532,7 +532,7 @@ TEST_P(ColorStateTest, DstBlendFactorOne) {
|
|||||||
CheckDstBlendFactor(base, wgpu::BlendFactor::One, wgpu::BlendFactor::One, tests);
|
CheckDstBlendFactor(base, wgpu::BlendFactor::One, wgpu::BlendFactor::One, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, DstBlendFactorSrcColor) {
|
TEST_P(ColorStateTest, DstBlendFactorSrc) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -542,10 +542,10 @@ TEST_P(ColorStateTest, DstBlendFactorSrcColor) {
|
|||||||
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
|
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
|
||||||
return std::make_pair(TriangleSpec({{color}}), expected);
|
return std::make_pair(TriangleSpec({{color}}), expected);
|
||||||
});
|
});
|
||||||
CheckDstBlendFactor(base, wgpu::BlendFactor::SrcColor, wgpu::BlendFactor::Zero, tests);
|
CheckDstBlendFactor(base, wgpu::BlendFactor::Src, wgpu::BlendFactor::Zero, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, DstBlendFactorOneMinusSrcColor) {
|
TEST_P(ColorStateTest, DstBlendFactorOneMinusSrc) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -555,7 +555,7 @@ TEST_P(ColorStateTest, DstBlendFactorOneMinusSrcColor) {
|
|||||||
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
|
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
|
||||||
return std::make_pair(TriangleSpec({{color}}), expected);
|
return std::make_pair(TriangleSpec({{color}}), expected);
|
||||||
});
|
});
|
||||||
CheckDstBlendFactor(base, wgpu::BlendFactor::OneMinusSrcColor, wgpu::BlendFactor::Zero, tests);
|
CheckDstBlendFactor(base, wgpu::BlendFactor::OneMinusSrc, wgpu::BlendFactor::Zero, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, DstBlendFactorSrcAlpha) {
|
TEST_P(ColorStateTest, DstBlendFactorSrcAlpha) {
|
||||||
@ -583,7 +583,7 @@ TEST_P(ColorStateTest, DstBlendFactorOneMinusSrcAlpha) {
|
|||||||
wgpu::BlendFactor::OneMinusSrcAlpha, tests);
|
wgpu::BlendFactor::OneMinusSrcAlpha, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, DstBlendFactorDstColor) {
|
TEST_P(ColorStateTest, DstBlendFactorDst) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -593,10 +593,10 @@ TEST_P(ColorStateTest, DstBlendFactorDstColor) {
|
|||||||
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
|
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
|
||||||
return std::make_pair(TriangleSpec({{color}}), expected);
|
return std::make_pair(TriangleSpec({{color}}), expected);
|
||||||
});
|
});
|
||||||
CheckDstBlendFactor(base, wgpu::BlendFactor::DstColor, wgpu::BlendFactor::Zero, tests);
|
CheckDstBlendFactor(base, wgpu::BlendFactor::Dst, wgpu::BlendFactor::Zero, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, DstBlendFactorOneMinusDstColor) {
|
TEST_P(ColorStateTest, DstBlendFactorOneMinusDst) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -606,7 +606,7 @@ TEST_P(ColorStateTest, DstBlendFactorOneMinusDstColor) {
|
|||||||
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
|
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, fac);
|
||||||
return std::make_pair(TriangleSpec({{color}}), expected);
|
return std::make_pair(TriangleSpec({{color}}), expected);
|
||||||
});
|
});
|
||||||
CheckDstBlendFactor(base, wgpu::BlendFactor::OneMinusDstColor, wgpu::BlendFactor::Zero, tests);
|
CheckDstBlendFactor(base, wgpu::BlendFactor::OneMinusDst, wgpu::BlendFactor::Zero, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, DstBlendFactorDstAlpha) {
|
TEST_P(ColorStateTest, DstBlendFactorDstAlpha) {
|
||||||
@ -648,7 +648,7 @@ TEST_P(ColorStateTest, DstBlendFactorSrcAlphaSaturated) {
|
|||||||
wgpu::BlendFactor::SrcAlphaSaturated, tests);
|
wgpu::BlendFactor::SrcAlphaSaturated, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, DstBlendFactorBlendColor) {
|
TEST_P(ColorStateTest, DstBlendFactorConstant) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(
|
std::transform(
|
||||||
@ -657,10 +657,10 @@ TEST_P(ColorStateTest, DstBlendFactorBlendColor) {
|
|||||||
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, triangleSpec.blendFactor);
|
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, triangleSpec.blendFactor);
|
||||||
return std::make_pair(triangleSpec, expected);
|
return std::make_pair(triangleSpec, expected);
|
||||||
});
|
});
|
||||||
CheckDstBlendFactor(base, wgpu::BlendFactor::BlendColor, wgpu::BlendFactor::BlendColor, tests);
|
CheckDstBlendFactor(base, wgpu::BlendFactor::Constant, wgpu::BlendFactor::Constant, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(ColorStateTest, DstBlendFactorOneMinusBlendColor) {
|
TEST_P(ColorStateTest, DstBlendFactorOneMinusConstant) {
|
||||||
RGBA8 base(32, 64, 128, 192);
|
RGBA8 base(32, 64, 128, 192);
|
||||||
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
std::vector<std::pair<TriangleSpec, RGBA8>> tests;
|
||||||
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
std::transform(kColors.begin(), kColors.end(), std::back_inserter(tests),
|
||||||
@ -670,8 +670,8 @@ TEST_P(ColorStateTest, DstBlendFactorOneMinusBlendColor) {
|
|||||||
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, f);
|
RGBA8 expected = color + mix(RGBA8(0, 0, 0, 0), base, f);
|
||||||
return std::make_pair(triangleSpec, expected);
|
return std::make_pair(triangleSpec, expected);
|
||||||
});
|
});
|
||||||
CheckDstBlendFactor(base, wgpu::BlendFactor::OneMinusBlendColor,
|
CheckDstBlendFactor(base, wgpu::BlendFactor::OneMinusConstant,
|
||||||
wgpu::BlendFactor::OneMinusBlendColor, tests);
|
wgpu::BlendFactor::OneMinusConstant, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the color write mask works
|
// Check that the color write mask works
|
||||||
@ -931,7 +931,7 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
|
|||||||
|
|
||||||
wgpu::BlendComponent blendComponent;
|
wgpu::BlendComponent blendComponent;
|
||||||
blendComponent.operation = wgpu::BlendOperation::Add;
|
blendComponent.operation = wgpu::BlendOperation::Add;
|
||||||
blendComponent.srcFactor = wgpu::BlendFactor::BlendColor;
|
blendComponent.srcFactor = wgpu::BlendFactor::Constant;
|
||||||
blendComponent.dstFactor = wgpu::BlendFactor::One;
|
blendComponent.dstFactor = wgpu::BlendFactor::One;
|
||||||
|
|
||||||
wgpu::BlendState blend;
|
wgpu::BlendState blend;
|
||||||
|
@ -549,3 +549,102 @@ DAWN_INSTANTIATE_TEST(VertexFormatDeprecationTests,
|
|||||||
OpenGLBackend(),
|
OpenGLBackend(),
|
||||||
OpenGLESBackend(),
|
OpenGLESBackend(),
|
||||||
VulkanBackend());
|
VulkanBackend());
|
||||||
|
|
||||||
|
// 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::ComboRenderPipelineDescriptor2 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.CreateRenderPipeline2(&descriptor));
|
||||||
|
} else {
|
||||||
|
device.CreateRenderPipeline2(&descriptor);
|
||||||
|
}
|
||||||
|
descriptor.cBlends[0].color.srcFactor = wgpu::BlendFactor::One;
|
||||||
|
|
||||||
|
descriptor.cBlends[0].color.dstFactor = blendFactor;
|
||||||
|
if (deprecated) {
|
||||||
|
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline2(&descriptor));
|
||||||
|
} else {
|
||||||
|
device.CreateRenderPipeline2(&descriptor);
|
||||||
|
}
|
||||||
|
descriptor.cBlends[0].color.dstFactor = wgpu::BlendFactor::Zero;
|
||||||
|
|
||||||
|
descriptor.cBlends[0].alpha.srcFactor = blendFactor;
|
||||||
|
if (deprecated) {
|
||||||
|
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline2(&descriptor));
|
||||||
|
} else {
|
||||||
|
device.CreateRenderPipeline2(&descriptor);
|
||||||
|
}
|
||||||
|
descriptor.cBlends[0].alpha.srcFactor = wgpu::BlendFactor::One;
|
||||||
|
|
||||||
|
descriptor.cBlends[0].alpha.dstFactor = blendFactor;
|
||||||
|
if (deprecated) {
|
||||||
|
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline2(&descriptor));
|
||||||
|
} else {
|
||||||
|
device.CreateRenderPipeline2(&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…
x
Reference in New Issue
Block a user