/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
ffi::WGPUCompareFunction ConvertCompareFunction( const dom::GPUCompareFunction& aCompare) { // Value of 0 = Undefined is reserved on the C side for "null" semantics. return ffi::WGPUCompareFunction(UnderlyingValue(aCompare) + 1);
}
ffi::WGPUTextureFormat ConvertTextureFormat( const dom::GPUTextureFormat& aFormat) {
ffi::WGPUTextureFormat result = {ffi::WGPUTextureFormat_Sentinel}; switch (aFormat) { case dom::GPUTextureFormat::R8unorm:
result.tag = ffi::WGPUTextureFormat_R8Unorm; break; case dom::GPUTextureFormat::R8snorm:
result.tag = ffi::WGPUTextureFormat_R8Snorm; break; case dom::GPUTextureFormat::R8uint:
result.tag = ffi::WGPUTextureFormat_R8Uint; break; case dom::GPUTextureFormat::R8sint:
result.tag = ffi::WGPUTextureFormat_R8Sint; break; case dom::GPUTextureFormat::R16uint:
result.tag = ffi::WGPUTextureFormat_R16Uint; break; case dom::GPUTextureFormat::R16sint:
result.tag = ffi::WGPUTextureFormat_R16Sint; break; case dom::GPUTextureFormat::R16float:
result.tag = ffi::WGPUTextureFormat_R16Float; break; case dom::GPUTextureFormat::Rg8unorm:
result.tag = ffi::WGPUTextureFormat_Rg8Unorm; break; case dom::GPUTextureFormat::Rg8snorm:
result.tag = ffi::WGPUTextureFormat_Rg8Snorm; break; case dom::GPUTextureFormat::Rg8uint:
result.tag = ffi::WGPUTextureFormat_Rg8Uint; break; case dom::GPUTextureFormat::Rg8sint:
result.tag = ffi::WGPUTextureFormat_Rg8Sint; break; case dom::GPUTextureFormat::R32uint:
result.tag = ffi::WGPUTextureFormat_R32Uint; break; case dom::GPUTextureFormat::R32sint:
result.tag = ffi::WGPUTextureFormat_R32Sint; break; case dom::GPUTextureFormat::R32float:
result.tag = ffi::WGPUTextureFormat_R32Float; break; case dom::GPUTextureFormat::Rg16uint:
result.tag = ffi::WGPUTextureFormat_Rg16Uint; break; case dom::GPUTextureFormat::Rg16sint:
result.tag = ffi::WGPUTextureFormat_Rg16Sint; break; case dom::GPUTextureFormat::Rg16float:
result.tag = ffi::WGPUTextureFormat_Rg16Float; break; case dom::GPUTextureFormat::Rgba8unorm:
result.tag = ffi::WGPUTextureFormat_Rgba8Unorm; break; case dom::GPUTextureFormat::Rgba8unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Rgba8UnormSrgb; break; case dom::GPUTextureFormat::Rgba8snorm:
result.tag = ffi::WGPUTextureFormat_Rgba8Snorm; break; case dom::GPUTextureFormat::Rgba8uint:
result.tag = ffi::WGPUTextureFormat_Rgba8Uint; break; case dom::GPUTextureFormat::Rgba8sint:
result.tag = ffi::WGPUTextureFormat_Rgba8Sint; break; case dom::GPUTextureFormat::Bgra8unorm:
result.tag = ffi::WGPUTextureFormat_Bgra8Unorm; break; case dom::GPUTextureFormat::Bgra8unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Bgra8UnormSrgb; break; case dom::GPUTextureFormat::Rgb9e5ufloat:
result.tag = ffi::WGPUTextureFormat_Rgb9e5Ufloat; break; case dom::GPUTextureFormat::Rgb10a2unorm:
result.tag = ffi::WGPUTextureFormat_Rgb10a2Unorm; break; case dom::GPUTextureFormat::Rg11b10ufloat:
result.tag = ffi::WGPUTextureFormat_Rg11b10Ufloat; break; case dom::GPUTextureFormat::Rg32uint:
result.tag = ffi::WGPUTextureFormat_Rg32Uint; break; case dom::GPUTextureFormat::Rg32sint:
result.tag = ffi::WGPUTextureFormat_Rg32Sint; break; case dom::GPUTextureFormat::Rg32float:
result.tag = ffi::WGPUTextureFormat_Rg32Float; break; case dom::GPUTextureFormat::Rgba16uint:
result.tag = ffi::WGPUTextureFormat_Rgba16Uint; break; case dom::GPUTextureFormat::Rgba16sint:
result.tag = ffi::WGPUTextureFormat_Rgba16Sint; break; case dom::GPUTextureFormat::Rgba16float:
result.tag = ffi::WGPUTextureFormat_Rgba16Float; break; case dom::GPUTextureFormat::Rgba32uint:
result.tag = ffi::WGPUTextureFormat_Rgba32Uint; break; case dom::GPUTextureFormat::Rgba32sint:
result.tag = ffi::WGPUTextureFormat_Rgba32Sint; break; case dom::GPUTextureFormat::Rgba32float:
result.tag = ffi::WGPUTextureFormat_Rgba32Float; break; case dom::GPUTextureFormat::Depth32float:
result.tag = ffi::WGPUTextureFormat_Depth32Float; break; case dom::GPUTextureFormat::Bc1_rgba_unorm:
result.tag = ffi::WGPUTextureFormat_Bc1RgbaUnorm; break; case dom::GPUTextureFormat::Bc1_rgba_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Bc1RgbaUnormSrgb; break; case dom::GPUTextureFormat::Bc4_r_unorm:
result.tag = ffi::WGPUTextureFormat_Bc4RUnorm; break; case dom::GPUTextureFormat::Bc4_r_snorm:
result.tag = ffi::WGPUTextureFormat_Bc4RSnorm; break; case dom::GPUTextureFormat::Bc2_rgba_unorm:
result.tag = ffi::WGPUTextureFormat_Bc2RgbaUnorm; break; case dom::GPUTextureFormat::Bc2_rgba_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Bc2RgbaUnormSrgb; break; case dom::GPUTextureFormat::Bc3_rgba_unorm:
result.tag = ffi::WGPUTextureFormat_Bc3RgbaUnorm; break; case dom::GPUTextureFormat::Bc3_rgba_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Bc3RgbaUnormSrgb; break; case dom::GPUTextureFormat::Bc5_rg_unorm:
result.tag = ffi::WGPUTextureFormat_Bc5RgUnorm; break; case dom::GPUTextureFormat::Bc5_rg_snorm:
result.tag = ffi::WGPUTextureFormat_Bc5RgSnorm; break; case dom::GPUTextureFormat::Bc6h_rgb_ufloat:
result.tag = ffi::WGPUTextureFormat_Bc6hRgbUfloat; break; case dom::GPUTextureFormat::Bc6h_rgb_float:
result.tag = ffi::WGPUTextureFormat_Bc6hRgbFloat; break; case dom::GPUTextureFormat::Bc7_rgba_unorm:
result.tag = ffi::WGPUTextureFormat_Bc7RgbaUnorm; break; case dom::GPUTextureFormat::Bc7_rgba_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Bc7RgbaUnormSrgb; break; case dom::GPUTextureFormat::Stencil8:
result.tag = ffi::WGPUTextureFormat_Stencil8; break; case dom::GPUTextureFormat::Depth16unorm:
result.tag = ffi::WGPUTextureFormat_Depth16Unorm; break; case dom::GPUTextureFormat::Depth24plus:
result.tag = ffi::WGPUTextureFormat_Depth24Plus; break; case dom::GPUTextureFormat::Depth24plus_stencil8:
result.tag = ffi::WGPUTextureFormat_Depth24PlusStencil8; break; case dom::GPUTextureFormat::Depth32float_stencil8:
result.tag = ffi::WGPUTextureFormat_Depth32FloatStencil8; break; case dom::GPUTextureFormat::Astc_4x4_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B4x4;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_4x4_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B4x4;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_5x4_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B5x4;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_5x4_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B5x4;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_5x5_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B5x5;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_5x5_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B5x5;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_6x5_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B6x5;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_6x5_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B6x5;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_6x6_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B6x6;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_6x6_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B6x6;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_8x5_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B8x5;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_8x5_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B8x5;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_8x6_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B8x6;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_8x6_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B8x6;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_8x8_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B8x8;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_8x8_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B8x8;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_10x5_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B10x5;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_10x5_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B10x5;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_10x6_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B10x6;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_10x6_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B10x6;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_10x8_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B10x8;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_10x8_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B10x8;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_10x10_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B10x10;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_10x10_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B10x10;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_12x10_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B12x10;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_12x10_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B12x10;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Astc_12x12_unorm:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B12x12;
result.astc.channel = ffi::WGPUAstcChannel_Unorm; break; case dom::GPUTextureFormat::Astc_12x12_unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Astc;
result.astc.block = ffi::WGPUAstcBlock_B12x12;
result.astc.channel = ffi::WGPUAstcChannel_UnormSrgb; break; case dom::GPUTextureFormat::Etc2_rgb8unorm:
result.tag = ffi::WGPUTextureFormat_Etc2Rgb8Unorm; break; case dom::GPUTextureFormat::Etc2_rgb8unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Etc2Rgb8UnormSrgb; break; case dom::GPUTextureFormat::Etc2_rgb8a1unorm:
result.tag = ffi::WGPUTextureFormat_Etc2Rgb8A1Unorm; break; case dom::GPUTextureFormat::Etc2_rgb8a1unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Etc2Rgb8A1UnormSrgb; break; case dom::GPUTextureFormat::Etc2_rgba8unorm:
result.tag = ffi::WGPUTextureFormat_Etc2Rgba8Unorm; break; case dom::GPUTextureFormat::Etc2_rgba8unorm_srgb:
result.tag = ffi::WGPUTextureFormat_Etc2Rgb8UnormSrgb; break; case dom::GPUTextureFormat::Eac_r11unorm:
result.tag = ffi::WGPUTextureFormat_EacR11Unorm; break; case dom::GPUTextureFormat::Eac_r11snorm:
result.tag = ffi::WGPUTextureFormat_EacR11Snorm; break; case dom::GPUTextureFormat::Eac_rg11unorm:
result.tag = ffi::WGPUTextureFormat_EacRg11Unorm; break; case dom::GPUTextureFormat::Eac_rg11snorm:
result.tag = ffi::WGPUTextureFormat_EacRg11Snorm; break; case dom::GPUTextureFormat::Rgb10a2uint:
result.tag = ffi::WGPUTextureFormat_Rgb10a2Uint; break;
}
// Clang will check for us that the switch above is exhaustive, // but not if we add a 'default' case. So, check this here.
MOZ_RELEASE_ASSERT(result.tag != ffi::WGPUTextureFormat_Sentinel, "unexpected texture format enum");
return result;
}
ffi::WGPUVertexFormat ConvertVertexFormat(const dom::GPUVertexFormat& aFormat) {
ffi::WGPUVertexFormat result = ffi::WGPUVertexFormat_Sentinel; switch (aFormat) { case dom::GPUVertexFormat::Uint8:
result = ffi::WGPUVertexFormat_Uint8; break; case dom::GPUVertexFormat::Uint8x2:
result = ffi::WGPUVertexFormat_Uint8x2; break; case dom::GPUVertexFormat::Uint8x4:
result = ffi::WGPUVertexFormat_Uint8x4; break; case dom::GPUVertexFormat::Sint8:
result = ffi::WGPUVertexFormat_Sint8; break; case dom::GPUVertexFormat::Sint8x2:
result = ffi::WGPUVertexFormat_Sint8x2; break; case dom::GPUVertexFormat::Sint8x4:
result = ffi::WGPUVertexFormat_Sint8x4; break; case dom::GPUVertexFormat::Unorm8:
result = ffi::WGPUVertexFormat_Unorm8; break; case dom::GPUVertexFormat::Unorm8x2:
result = ffi::WGPUVertexFormat_Unorm8x2; break; case dom::GPUVertexFormat::Unorm8x4:
result = ffi::WGPUVertexFormat_Unorm8x4; break; case dom::GPUVertexFormat::Snorm8:
result = ffi::WGPUVertexFormat_Snorm8; break; case dom::GPUVertexFormat::Snorm8x2:
result = ffi::WGPUVertexFormat_Snorm8x2; break; case dom::GPUVertexFormat::Snorm8x4:
result = ffi::WGPUVertexFormat_Snorm8x4; break; case dom::GPUVertexFormat::Uint16:
result = ffi::WGPUVertexFormat_Uint16; break; case dom::GPUVertexFormat::Uint16x2:
result = ffi::WGPUVertexFormat_Uint16x2; break; case dom::GPUVertexFormat::Uint16x4:
result = ffi::WGPUVertexFormat_Uint16x4; break; case dom::GPUVertexFormat::Sint16:
result = ffi::WGPUVertexFormat_Sint16; break; case dom::GPUVertexFormat::Sint16x2:
result = ffi::WGPUVertexFormat_Sint16x2; break; case dom::GPUVertexFormat::Sint16x4:
result = ffi::WGPUVertexFormat_Sint16x4; break; case dom::GPUVertexFormat::Unorm16:
result = ffi::WGPUVertexFormat_Unorm16; break; case dom::GPUVertexFormat::Unorm16x2:
result = ffi::WGPUVertexFormat_Unorm16x2; break; case dom::GPUVertexFormat::Unorm16x4:
result = ffi::WGPUVertexFormat_Unorm16x4; break; case dom::GPUVertexFormat::Snorm16:
result = ffi::WGPUVertexFormat_Snorm16; break; case dom::GPUVertexFormat::Snorm16x2:
result = ffi::WGPUVertexFormat_Snorm16x2; break; case dom::GPUVertexFormat::Snorm16x4:
result = ffi::WGPUVertexFormat_Snorm16x4; break; case dom::GPUVertexFormat::Float16:
result = ffi::WGPUVertexFormat_Float16; break; case dom::GPUVertexFormat::Float16x2:
result = ffi::WGPUVertexFormat_Float16x2; break; case dom::GPUVertexFormat::Float16x4:
result = ffi::WGPUVertexFormat_Float16x4; break; case dom::GPUVertexFormat::Float32:
result = ffi::WGPUVertexFormat_Float32; break; case dom::GPUVertexFormat::Float32x2:
result = ffi::WGPUVertexFormat_Float32x2; break; case dom::GPUVertexFormat::Float32x3:
result = ffi::WGPUVertexFormat_Float32x3; break; case dom::GPUVertexFormat::Float32x4:
result = ffi::WGPUVertexFormat_Float32x4; break; case dom::GPUVertexFormat::Uint32:
result = ffi::WGPUVertexFormat_Uint32; break; case dom::GPUVertexFormat::Uint32x2:
result = ffi::WGPUVertexFormat_Uint32x2; break; case dom::GPUVertexFormat::Uint32x3:
result = ffi::WGPUVertexFormat_Uint32x3; break; case dom::GPUVertexFormat::Uint32x4:
result = ffi::WGPUVertexFormat_Uint32x4; break; case dom::GPUVertexFormat::Sint32:
result = ffi::WGPUVertexFormat_Sint32; break; case dom::GPUVertexFormat::Sint32x2:
result = ffi::WGPUVertexFormat_Sint32x2; break; case dom::GPUVertexFormat::Sint32x3:
result = ffi::WGPUVertexFormat_Sint32x3; break; case dom::GPUVertexFormat::Sint32x4:
result = ffi::WGPUVertexFormat_Sint32x4; break; case dom::GPUVertexFormat::Unorm10_10_10_2:
result = ffi::WGPUVertexFormat_Unorm10_10_10_2; break; case dom::GPUVertexFormat::Unorm8x4_bgra:
result = ffi::WGPUVertexFormat_Unorm8x4Bgra; break;
}
// Clang will check for us that the switch above is exhaustive, // but not if we add a 'default' case. So, check this here.
MOZ_RELEASE_ASSERT(result != ffi::WGPUVertexFormat_Sentinel, "unexpected texture format enum");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.