aurora: Support BM_SUBTRACT, fix alpha blend op

This commit is contained in:
Luke Street 2022-03-19 21:40:48 -04:00
parent 9bcb06d92a
commit a42769627c
1 changed files with 21 additions and 5 deletions

View File

@ -283,15 +283,31 @@ static inline wgpu::CompareFunction to_compare_function(GX::Compare func) {
static inline wgpu::BlendState to_blend_state(GX::BlendMode mode, GX::BlendFactor srcFac, GX::BlendFactor dstFac, static inline wgpu::BlendState to_blend_state(GX::BlendMode mode, GX::BlendFactor srcFac, GX::BlendFactor dstFac,
std::optional<float> dstAlpha) { std::optional<float> dstAlpha) {
if (mode != GX::BM_BLEND) { wgpu::BlendComponent colorBlendComponent;
Log.report(logvisor::Fatal, FMT_STRING("How to {}?"), mode); switch (mode) {
} case GX::BM_BLEND:
const auto colorBlendComponent = wgpu::BlendComponent{ colorBlendComponent = {
.operation = wgpu::BlendOperation::Add, .operation = wgpu::BlendOperation::Add,
.srcFactor = to_blend_factor(srcFac), .srcFactor = to_blend_factor(srcFac),
.dstFactor = to_blend_factor(dstFac), .dstFactor = to_blend_factor(dstFac),
};
break;
case GX::BM_SUBTRACT:
colorBlendComponent = {
.operation = wgpu::BlendOperation::Subtract,
.srcFactor = wgpu::BlendFactor::Src,
.dstFactor = wgpu::BlendFactor::Dst,
};
break;
default:
Log.report(logvisor::Fatal, FMT_STRING("How to {}?"), mode);
unreachable();
}
wgpu::BlendComponent alphaBlendComponent{
.operation = wgpu::BlendOperation::Add,
.srcFactor = wgpu::BlendFactor::Zero,
.dstFactor = wgpu::BlendFactor::One,
}; };
auto alphaBlendComponent = colorBlendComponent;
if (dstAlpha) { if (dstAlpha) {
alphaBlendComponent = wgpu::BlendComponent{ alphaBlendComponent = wgpu::BlendComponent{
.operation = wgpu::BlendOperation::Add, .operation = wgpu::BlendOperation::Add,