Repository: google/filament
File: filament/backend/src/webgpu/WebGPUPipelineCreation.cpp (C++)

Code before:
        case PrimitiveType::LINE_STRIP:
            return wgpu::PrimitiveTopology::LineStrip;
        case PrimitiveType::TRIANGLES:
            return wgpu::PrimitiveTopology::TriangleList;
        case PrimitiveType::TRIANGLE_STRIP:
            return wgpu::PrimitiveTopology::TriangleStrip;
    }
}

constexpr wgpu::CullMode toWebGPU(CullingMode cullMode) {
    switch (cullMode) {
        case CullingMode::NONE:
            return wgpu::CullMode::None;
        case CullingMode::FRONT:
            return wgpu::CullMode::Front;
        case CullingMode::BACK:
            return wgpu::CullMode::Back;
        case CullingMode::FRONT_AND_BACK:
            // no WegGPU equivalent of front and back
            FILAMENT_CHECK_POSTCONDITION(false)
                    << "WebGPU does not support CullingMode::FRONT_AND_BACK";
            return wgpu::CullMode::Undefined;
    }
}

constexpr wgpu::CompareFunction toWebGPU(SamplerCompareFunc compareFunction) {
    switch (compareFunction) {
        case SamplerCompareFunc::LE:
            return wgpu::CompareFunction::LessEqual;
        case SamplerCompareFunc::GE:
            return wgpu::CompareFunction::GreaterEqual;
        case SamplerCompareFunc::L:
            return wgpu::CompareFunction::Less;
        case SamplerCompareFunc::G:
            return wgpu::CompareFunction::Greater;
        case SamplerCompareFunc::E:
            return wgpu::CompareFunction::Equal;
        case SamplerCompareFunc::NE:
            return wgpu::CompareFunction::NotEqual;
        case SamplerCompareFunc::A:
            return wgpu::CompareFunction::Always;
        case SamplerCompareFunc::N:
            return wgpu::CompareFunction::Never;
    }
}

constexpr wgpu::StencilOperation toWebGPU(StencilOperation stencilOp) {
    switch (stencilOp) {
        case StencilOperation::KEEP:
            return wgpu::StencilOperation::Keep;
        case StencilOperation::ZERO:

Review comment (suggestion):
nit: can this be `constexpr`? `[[nodiscard]]` (toWebGPU functions below could be too, but fine if we do that here or later )

Code after:
        case PrimitiveType::LINE_STRIP:
            return wgpu::PrimitiveTopology::LineStrip;
        case PrimitiveType::TRIANGLES:
            return wgpu::PrimitiveTopology::TriangleList;
        case PrimitiveType::TRIANGLE_STRIP:
            return wgpu::PrimitiveTopology::TriangleStrip;
    }
}

constexpr wgpu::CullMode toWebGPU(CullingMode cullMode) {
    switch (cullMode) {
        case CullingMode::NONE:
            return wgpu::CullMode::None;
        case CullingMode::FRONT:
            return wgpu::CullMode::Front;
        case CullingMode::BACK:
            return wgpu::CullMode::Back;
        case CullingMode::FRONT_AND_BACK:
            // no WegGPU equivalent of front and back
            FILAMENT_CHECK_POSTCONDITION(false)
                    << "WebGPU does not support CullingMode::FRONT_AND_BACK";
            return wgpu::CullMode::Undefined;
    }
}

bool hasStencilAspect(wgpu::TextureFormat format) {
    switch (format) {
        case wgpu::TextureFormat::Stencil8:
        case wgpu::TextureFormat::Depth24PlusStencil8:
        case wgpu::TextureFormat::Depth32FloatStencil8:
            return true;
        default:
            return false;
    }
}

constexpr wgpu::CompareFunction toWebGPU(SamplerCompareFunc compareFunction) {
    switch (compareFunction) {
        case SamplerCompareFunc::LE:
            return wgpu::CompareFunction::LessEqual;
        case SamplerCompareFunc::GE:
            return wgpu::CompareFunction::GreaterEqual;
        case SamplerCompareFunc::L:
            return wgpu::CompareFunction::Less;
        case SamplerCompareFunc::G:
            return wgpu::CompareFunction::Greater;
        case SamplerCompareFunc::E:
            return wgpu::CompareFunction::Equal;
        case SamplerCompareFunc::NE:
            return wgpu::CompareFunction::NotEqual;
        case SamplerCompareFunc::A: