webgpu: fix logging
This commit is contained in:
@@ -21,50 +21,27 @@
|
||||
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
#include <utils/Panic.h>
|
||||
#include <utils/ostream.h>
|
||||
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
#include <dawn/webgpu_cpp_print.h>
|
||||
#endif
|
||||
#include <webgpu/webgpu_cpp.h>
|
||||
|
||||
#include <cstdint>
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
#include <sstream>
|
||||
#endif
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
/**
|
||||
* Reusable set of convenience functions for strings -- generally string views, literals, &
|
||||
* streaming -- used in the WebGPU backend
|
||||
* strings -- used in the WebGPU backend
|
||||
*/
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
/**
|
||||
* Convenience template to print WGPU types (which don't support Filament's utils::io::ostream)
|
||||
* @tparam WebGPUPrintable e.g. wgpu::FeatureName type
|
||||
* @param out stream to print to
|
||||
* @param printable the instance to print
|
||||
* @return the stream printed to
|
||||
*
|
||||
* Example usage (because including the template operator override itself does not compile):
|
||||
* #if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
* utils::io::ostream& operator<<(utils::io::ostream& out,
|
||||
* const wgpu::FeatureName featureName) noexcept {
|
||||
* return streamInsertWebGPUPrintable(out, featureName);
|
||||
* }
|
||||
* #endif
|
||||
*/
|
||||
template<typename WebGPUPrintable>
|
||||
utils::io::ostream& streamInsertWebGPUPrintable(utils::io::ostream& out,
|
||||
const WebGPUPrintable printable) {
|
||||
std::stringstream printableStream;
|
||||
printableStream << printable;
|
||||
out << printableStream.str();
|
||||
return out;
|
||||
[[nodiscard]] inline std::string webGPUPrintableToString(const WebGPUPrintable printable) {
|
||||
std::stringstream out;
|
||||
out << printable;
|
||||
return out.str();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -115,46 +92,17 @@ utils::io::ostream& streamInsertWebGPUPrintable(utils::io::ostream& out,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience template to print wgpu::RequestAdapterOptions
|
||||
* @tparam STREAM_TYPE useful namely for streaming to either an utils::io::ostream OR
|
||||
* utils::details::PanicStream, but also for any kind of stream
|
||||
* @param out stream to print to
|
||||
* @param options instance to be printed
|
||||
* @return stream printed to
|
||||
*
|
||||
* Example usage (because including the template operator override itself does not compile):
|
||||
* template<typename STREAM_TYPE>
|
||||
* STREAM_TYPE& operator<<(STREAM_TYPE& out, wgpu::RequestAdapterOptions const& options) noexcept {
|
||||
* return streamInsertRequestAdapterOptions(out, options);
|
||||
* }
|
||||
*/
|
||||
template<typename STREAM_TYPE>
|
||||
STREAM_TYPE& streamInsertRequestAdapterOptions(STREAM_TYPE& out,
|
||||
wgpu::RequestAdapterOptions const& options) noexcept {
|
||||
[[nodiscard]] inline std::string adapterOptionsToString(
|
||||
wgpu::RequestAdapterOptions const& options) {
|
||||
std::stringstream out;
|
||||
out << "power preference " << powerPreferenceToString(options.powerPreference)
|
||||
<< " force fallback adapter " << bool(options.forceFallbackAdapter) << " backend type "
|
||||
<< backendTypeToString(options.backendType);
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience template to print wgpu::AdapterInfo
|
||||
* @tparam STREAM_TYPE useful namely for streaming to either an utils::io::ostream OR
|
||||
* utils::details::PanicStream, but also for any kind of stream
|
||||
* @param out stream to print to
|
||||
* @param options instance to be printed
|
||||
* @return stream printed to
|
||||
*
|
||||
* Example usage (because including the template operator override itself does not compile):
|
||||
* template<typename STREAM_TYPE>
|
||||
* STREAM_TYPE& operator<<(STREAM_TYPE& out, wgpu::AdapterInfo const& info) noexcept {
|
||||
* return streamInsertRequestAdapterInfo(out, info);
|
||||
* }
|
||||
*/
|
||||
template<class STREAM_TYPE>
|
||||
STREAM_TYPE& streamInsertRequestAdapterInfo(STREAM_TYPE& out,
|
||||
wgpu::AdapterInfo const& info) noexcept {
|
||||
[[nodiscard]] std::string adapterInfoToString(wgpu::AdapterInfo const& info) {
|
||||
std::stringstream out;
|
||||
out << "vendor (" << info.vendorID << ") '" << info.vendor
|
||||
<< "' device (" << info.deviceID << ") '" << info.device
|
||||
<< "' adapter " << adapterTypeToString(info.adapterType)
|
||||
@@ -162,7 +110,7 @@ STREAM_TYPE& streamInsertRequestAdapterInfo(STREAM_TYPE& out,
|
||||
<< " architecture '" << info.architecture
|
||||
<< "' subgroupMinSize " << info.subgroupMinSize
|
||||
<< " subgroupMaxSize " << info.subgroupMaxSize;
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr std::string_view deviceLostReasonToString(
|
||||
@@ -175,7 +123,7 @@ STREAM_TYPE& streamInsertRequestAdapterInfo(STREAM_TYPE& out,
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr std::string_view filamentShaderStageToString(ShaderStage stage) {
|
||||
[[nodiscard]] constexpr std::string_view filamentShaderStageToString(const ShaderStage stage) {
|
||||
switch (stage) {
|
||||
case ShaderStage::VERTEX: return "vertex";
|
||||
case ShaderStage::FRAGMENT: return "fragment";
|
||||
|
||||
@@ -24,43 +24,25 @@
|
||||
#include "backend/DriverEnums.h"
|
||||
|
||||
#include <utils/Panic.h>
|
||||
#include <utils/ostream.h>
|
||||
|
||||
#include <webgpu/webgpu_cpp.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
namespace {
|
||||
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out, const wgpu::TextureFormat format) noexcept {
|
||||
return filament::backend::streamInsertWebGPUPrintable(out, format);
|
||||
}
|
||||
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out,
|
||||
const wgpu::TextureUsage textureUsage) noexcept {
|
||||
return filament::backend::streamInsertWebGPUPrintable(out, textureUsage);
|
||||
}
|
||||
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out,
|
||||
const wgpu::PresentMode presentMode) noexcept {
|
||||
return filament::backend::streamInsertWebGPUPrintable(out, presentMode);
|
||||
}
|
||||
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out,
|
||||
const wgpu::CompositeAlphaMode alphaMode) noexcept {
|
||||
return filament::backend::streamInsertWebGPUPrintable(out, alphaMode);
|
||||
}
|
||||
|
||||
void printSurfaceCapabilitiesDetails(wgpu::SurfaceCapabilities const& capabilities) {
|
||||
FWGPU_LOGI << "WebGPU surface capabilities:";
|
||||
FWGPU_LOGI << " surface usages: " << capabilities.usages;
|
||||
FWGPU_LOGI << " surface usages: " << webGPUPrintableToString(capabilities.usages);
|
||||
FWGPU_LOGI << " surface formats (" << capabilities.formatCount << "):";
|
||||
if (capabilities.formatCount > 0 && capabilities.formats != nullptr) {
|
||||
std::for_each(capabilities.formats, capabilities.formats + capabilities.formatCount,
|
||||
[](wgpu::TextureFormat const format) {
|
||||
FWGPU_LOGI << " " << format;
|
||||
FWGPU_LOGI << " " << webGPUPrintableToString(format);
|
||||
});
|
||||
}
|
||||
FWGPU_LOGI << " surface present modes (" << capabilities.presentModeCount << "):";
|
||||
@@ -68,7 +50,7 @@ void printSurfaceCapabilitiesDetails(wgpu::SurfaceCapabilities const& capabiliti
|
||||
std::for_each(capabilities.presentModes,
|
||||
capabilities.presentModes + capabilities.presentModeCount,
|
||||
[](wgpu::PresentMode const presentMode) {
|
||||
FWGPU_LOGI << " " << presentMode;
|
||||
FWGPU_LOGI << " " << webGPUPrintableToString(presentMode);
|
||||
});
|
||||
}
|
||||
FWGPU_LOGI << " surface alpha modes (" << capabilities.alphaModeCount << "):";
|
||||
@@ -76,7 +58,7 @@ void printSurfaceCapabilitiesDetails(wgpu::SurfaceCapabilities const& capabiliti
|
||||
std::for_each(capabilities.alphaModes,
|
||||
capabilities.alphaModes + capabilities.alphaModeCount,
|
||||
[](wgpu::CompositeAlphaMode const alphaMode) {
|
||||
FWGPU_LOGI << " " << alphaMode;
|
||||
FWGPU_LOGI << " " << webGPUPrintableToString(alphaMode);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -84,20 +66,20 @@ void printSurfaceCapabilitiesDetails(wgpu::SurfaceCapabilities const& capabiliti
|
||||
void printSurfaceConfiguration(wgpu::SurfaceConfiguration const& config,
|
||||
wgpu::TextureFormat depthFormat) {
|
||||
FWGPU_LOGI << "WebGPU surface configuration:";
|
||||
FWGPU_LOGI << " surface format: " << config.format;
|
||||
FWGPU_LOGI << " surface usage: " << config.usage;
|
||||
FWGPU_LOGI << " surface format: " << webGPUPrintableToString(config.format);
|
||||
FWGPU_LOGI << " surface usage: " << webGPUPrintableToString(config.usage);
|
||||
FWGPU_LOGI << " surface view formats (" << config.viewFormatCount << "):";
|
||||
if (config.viewFormatCount > 0 && config.viewFormats != nullptr) {
|
||||
std::for_each(config.viewFormats, config.viewFormats + config.viewFormatCount,
|
||||
[](wgpu::TextureFormat const viewFormat) {
|
||||
FWGPU_LOGI << " " << viewFormat;
|
||||
FWGPU_LOGI << " " << webGPUPrintableToString(viewFormat);
|
||||
});
|
||||
}
|
||||
FWGPU_LOGI << " surface alpha mode: " << config.alphaMode;
|
||||
FWGPU_LOGI << " surface alpha mode: " << webGPUPrintableToString(config.alphaMode);
|
||||
FWGPU_LOGI << " surface width: " << config.width;
|
||||
FWGPU_LOGI << " surface height: " << config.height;
|
||||
FWGPU_LOGI << " surface present mode: " << config.presentMode;
|
||||
FWGPU_LOGI << "WebGPU selected depth format: " << depthFormat;
|
||||
FWGPU_LOGI << " surface present mode: " << webGPUPrintableToString(config.presentMode);
|
||||
FWGPU_LOGI << "WebGPU selected depth format: " << webGPUPrintableToString(depthFormat);
|
||||
}
|
||||
#endif// FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
|
||||
@@ -257,8 +239,6 @@ void initConfig(wgpu::SurfaceConfiguration& config, wgpu::Device const& device,
|
||||
|
||||
}// namespace
|
||||
|
||||
namespace filament::backend {
|
||||
|
||||
WebGPUSwapChain::WebGPUSwapChain(wgpu::Surface&& surface, wgpu::Extent2D const& surfaceSize,
|
||||
wgpu::Adapter const& adapter, wgpu::Device const& device, uint64_t flags)
|
||||
: mDevice(device),
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <utils/BitmaskEnum.h>
|
||||
#include <utils/Panic.h>
|
||||
#include <utils/debug.h>
|
||||
#include <utils/ostream.h>
|
||||
|
||||
#include <webgpu/webgpu_cpp.h>
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
@@ -343,8 +342,7 @@ WebGPUTexture::WebGPUTexture(const SamplerType samplerType, const uint8_t levels
|
||||
std::stringstream textureFormatStream;
|
||||
textureFormatStream << mWebGPUFormat;
|
||||
FWGPU_LOGD << "Texture '" << textureDescriptor.label << "' has view format "
|
||||
<< viewFormatStream.str() << " and texture format " << textureFormatStream.str()
|
||||
<< utils::io::endl;
|
||||
<< viewFormatStream.str() << " and texture format " << textureFormatStream.str();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -470,51 +468,43 @@ wgpu::TextureFormat WebGPUTexture::fToWGPUTextureFormat(TextureFormat const& fFo
|
||||
// No direct mapping in wgpu. Could potentially map to RGBA8Unorm
|
||||
// and discard the alpha and lower precision.
|
||||
FWGPU_LOGW << "Requested Filament texture format RGB565 but getting "
|
||||
"wgpu::TextureFormat::Undefined (no direct mapping in wgpu)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::Undefined (no direct mapping in wgpu)";
|
||||
return wgpu::TextureFormat::Undefined;
|
||||
case TextureFormat::RGB9_E5: return wgpu::TextureFormat::RGB9E5Ufloat;
|
||||
case TextureFormat::RGB5_A1:
|
||||
// No direct mapping in wgpu. Could potentially map to RGBA8Unorm
|
||||
// and handle the packing/unpacking in shaders.
|
||||
FWGPU_LOGW << "Requested Filament texture format RGB5_A1 but getting "
|
||||
"wgpu::TextureFormat::Undefined (no direct mapping in wgpu)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::Undefined (no direct mapping in wgpu)";
|
||||
return wgpu::TextureFormat::Undefined;
|
||||
case TextureFormat::RGBA4:
|
||||
// No direct mapping in wgpu. Could potentially map to RGBA8Unorm
|
||||
// and handle the packing/unpacking in shaders.
|
||||
FWGPU_LOGW << "Requested Filament texture format RGBA4 but getting "
|
||||
"wgpu::TextureFormat::Undefined (no direct mapping in wgpu)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::Undefined (no direct mapping in wgpu)";
|
||||
return wgpu::TextureFormat::Undefined;
|
||||
case TextureFormat::RGB8:
|
||||
FWGPU_LOGW << "Requested Filament texture format RGB8 but getting "
|
||||
"wgpu::TextureFormat::RGBA8Unorm (no direct sRGB equivalent in wgpu "
|
||||
"without alpha)"
|
||||
<< utils::io::endl;
|
||||
"without alpha)";
|
||||
return wgpu::TextureFormat::RGBA8Unorm;
|
||||
case TextureFormat::SRGB8:
|
||||
FWGPU_LOGW << "Requested Filament texture format SRGB8 but getting "
|
||||
"wgpu::TextureFormat::RGBA8UnormSrgb (no direct sRGB equivalent in wgpu "
|
||||
"without alpha)"
|
||||
<< utils::io::endl;
|
||||
"without alpha)";
|
||||
return wgpu::TextureFormat::RGBA8UnormSrgb;
|
||||
case TextureFormat::RGB8_SNORM:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament texture format RGB8_SNORM but getting "
|
||||
"wgpu::TextureFormat::RGBA8Snorm (no direct mapping in wgpu without alpha)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::RGBA8Snorm (no direct mapping in wgpu without alpha)";
|
||||
return wgpu::TextureFormat::RGBA8Snorm;
|
||||
case TextureFormat::RGB8UI:
|
||||
FWGPU_LOGW << "Requested Filament texture format RGB8UI but getting "
|
||||
"wgpu::TextureFormat::RGBA8Uint (no direct mapping in wgpu without alpha)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::RGBA8Uint (no direct mapping in wgpu without alpha)";
|
||||
return wgpu::TextureFormat::RGBA8Uint;
|
||||
case TextureFormat::RGB8I:
|
||||
FWGPU_LOGW << "Requested Filament texture format RGB8I but getting "
|
||||
"wgpu::TextureFormat::RGBA8Sint (no direct mapping in wgpu without alpha)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::RGBA8Sint (no direct mapping in wgpu without alpha)";
|
||||
return wgpu::TextureFormat::RGBA8Sint;
|
||||
case TextureFormat::R11F_G11F_B10F: return wgpu::TextureFormat::RG11B10Ufloat;
|
||||
case TextureFormat::UNUSED: return wgpu::TextureFormat::Undefined;
|
||||
@@ -522,38 +512,32 @@ wgpu::TextureFormat WebGPUTexture::fToWGPUTextureFormat(TextureFormat const& fFo
|
||||
case TextureFormat::RGB16F:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament texture format RGB16F but getting "
|
||||
"wgpu::TextureFormat::RGBA16Float (no direct mapping in wgpu without alpha)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::RGBA16Float (no direct mapping in wgpu without alpha)";
|
||||
return wgpu::TextureFormat::RGBA16Float;
|
||||
case TextureFormat::RGB16UI:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament texture format RGB16UI but getting "
|
||||
"wgpu::TextureFormat::RGBA16Uint (no direct mapping in wgpu without alpha)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::RGBA16Uint (no direct mapping in wgpu without alpha)";
|
||||
return wgpu::TextureFormat::RGBA16Uint;
|
||||
case TextureFormat::RGB16I:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament texture format RGB16I but getting "
|
||||
"wgpu::TextureFormat::RGBA16Sint (no direct mapping in wgpu without alpha)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::RGBA16Sint (no direct mapping in wgpu without alpha)";
|
||||
return wgpu::TextureFormat::RGBA16Sint;
|
||||
case TextureFormat::RGB32F:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament texture format RGB32F but getting "
|
||||
"wgpu::TextureFormat::RGBA32Float (no direct mapping in wgpu without alpha)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::RGBA32Float (no direct mapping in wgpu without alpha)";
|
||||
return wgpu::TextureFormat::RGBA32Float;
|
||||
case TextureFormat::RGB32UI:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament texture format RGB32UI but getting "
|
||||
"wgpu::TextureFormat::RGBA32Uint (no direct mapping in wgpu without alpha)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::RGBA32Uint (no direct mapping in wgpu without alpha)";
|
||||
return wgpu::TextureFormat::RGBA32Uint;
|
||||
case TextureFormat::RGB32I:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament texture format RGB32I but getting "
|
||||
"wgpu::TextureFormat::RGBA32Sint (no direct mapping in wgpu without alpha)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::TextureFormat::RGBA32Sint (no direct mapping in wgpu without alpha)";
|
||||
return wgpu::TextureFormat::RGBA32Sint;
|
||||
case TextureFormat::DXT1_RGB: return wgpu::TextureFormat::BC1RGBAUnorm;
|
||||
case TextureFormat::DXT1_RGBA: return wgpu::TextureFormat::BC1RGBAUnorm;
|
||||
@@ -573,7 +557,7 @@ wgpu::TextureView WebGPUTexture::makeTextureView(const uint8_t& baseLevel,
|
||||
if (baseLevel > 0 && !mSupportsMultipleMipLevels) {
|
||||
FWGPU_LOGW << "Trying to make a texture view into a level ("
|
||||
<< static_cast<uint32_t>(baseLevel)
|
||||
<< ") for which we cannot generate mip levels." << utils::io::endl;
|
||||
<< ") for which we cannot generate mip levels.";
|
||||
}
|
||||
#endif
|
||||
const wgpu::TextureViewDescriptor textureViewDescriptor{
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <backend/DriverEnums.h>
|
||||
|
||||
#include <utils/Panic.h>
|
||||
#include <utils/ostream.h>
|
||||
|
||||
#include <webgpu/webgpu_cpp.h>
|
||||
|
||||
@@ -57,26 +56,22 @@ namespace {
|
||||
case ElementType::BYTE3:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament vertex format BYTE3 (normalized) but getting "
|
||||
"wgpu::VertexFormat::Snorm8x4 (no direct mapping in wgpu for x3 byte)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Snorm8x4 (no direct mapping in wgpu for x3 byte)";
|
||||
return VertexFormat::Snorm8x4; // NOT MINSPEC
|
||||
case ElementType::UBYTE3:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament vertex format UBYTE3 (normalized) but getting "
|
||||
"wgpu::VertexFormat::Unorm8x4 (no direct mapping in wgpu for x3 byte)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Unorm8x4 (no direct mapping in wgpu for x3 byte)";
|
||||
return VertexFormat::Unorm8x4; // NOT MINSPEC
|
||||
case ElementType::SHORT3:
|
||||
FWGPU_LOGW << "Requested Filament vertex format SHORT3 (normalized) but getting "
|
||||
"wgpu::VertexFormat::Snorm16x4 (no direct mapping in wgpu for x3 "
|
||||
"half/short)"
|
||||
<< utils::io::endl;
|
||||
"half/short)";
|
||||
return VertexFormat::Snorm16x4; // NOT MINSPEC
|
||||
case ElementType::USHORT3:
|
||||
FWGPU_LOGW << "Requested Filament vertex format USHORT3 (normalized) but getting "
|
||||
"wgpu::VertexFormat::Unorm16x4 (no direct mapping in wgpu for x3 "
|
||||
"half/short)"
|
||||
<< utils::io::endl;
|
||||
"half/short)";
|
||||
return VertexFormat::Unorm16x4; // NOT MINSPEC
|
||||
// Four Component Types
|
||||
case ElementType::BYTE4: return VertexFormat::Snorm8x4;
|
||||
@@ -97,26 +92,22 @@ namespace {
|
||||
case ElementType::BYTE:
|
||||
if (integer) return VertexFormat::Sint8;
|
||||
FWGPU_LOGW << "Requested Filament vertex format BYTE (float) but getting "
|
||||
"wgpu::VertexFormat::Float16 (no direct mapping in wgpu for 8 bit float)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16 (no direct mapping in wgpu for 8 bit float)";
|
||||
return wgpu::VertexFormat::Float16;
|
||||
case ElementType::UBYTE:
|
||||
if (integer) return VertexFormat::Uint8;
|
||||
FWGPU_LOGW << "Requested Filament vertex format UBYTE (float) but getting "
|
||||
"wgpu::VertexFormat::Float16 (no direct mapping in wgpu for 8 bit float)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16 (no direct mapping in wgpu for 8 bit float)";
|
||||
return VertexFormat::Float16;
|
||||
case ElementType::SHORT:
|
||||
if (integer) return VertexFormat::Sint16;
|
||||
FWGPU_LOGW << "Requested Filament vertex format SHORT (float) and getting "
|
||||
"wgpu::VertexFormat::Float16 (potential loss of precision?)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16 (potential loss of precision?)";
|
||||
return VertexFormat ::Float16;
|
||||
case ElementType::USHORT:
|
||||
if (integer) return VertexFormat::Uint16;
|
||||
FWGPU_LOGW << "Requested Filament vertex format USHORT (float) and getting "
|
||||
"wgpu::VertexFormat::Float16 (potential loss of precision?)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16 (potential loss of precision?)";
|
||||
return VertexFormat::Float16;
|
||||
case ElementType::HALF: return VertexFormat::Float16;
|
||||
case ElementType::INT: return VertexFormat::Sint32;
|
||||
@@ -127,58 +118,49 @@ namespace {
|
||||
if (integer) return VertexFormat::Sint8x2;
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament vertex format BYTE2 (float) but getting "
|
||||
"wgpu::VertexFormat::Float16x2 (no direct mapping in wgpu for 8 bit float)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16x2 (no direct mapping in wgpu for 8 bit float)";
|
||||
return VertexFormat::Float16x2;
|
||||
case ElementType::UBYTE2:
|
||||
if (integer) return VertexFormat::Uint8x2;
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament vertex format UBYTE2 (float) but getting "
|
||||
"wgpu::VertexFormat::Float16x2 (no direct mapping in wgpu for 8 bit float)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16x2 (no direct mapping in wgpu for 8 bit float)";
|
||||
return VertexFormat::Float16x2;
|
||||
case ElementType::SHORT2:
|
||||
if (integer) return VertexFormat::Sint16x2;
|
||||
FWGPU_LOGW << "Requested Filament vertex format SHORT2 (float) but getting "
|
||||
"wgpu::VertexFormat::Float16x2 (potential loss of precision?)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16x2 (potential loss of precision?)";
|
||||
return VertexFormat::Float16x2;
|
||||
case ElementType::USHORT2:
|
||||
if (integer) return VertexFormat::Uint16x2;
|
||||
FWGPU_LOGW << "Requested Filament vertex format USHORT2 (float) but getting "
|
||||
"wgpu::VertexFormat::Float16x2 (potential loss of precision?)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16x2 (potential loss of precision?)";
|
||||
return VertexFormat::Float16x2;
|
||||
case ElementType::HALF2: return VertexFormat::Float16x2;
|
||||
case ElementType::FLOAT2: return VertexFormat::Float32x2;
|
||||
// Three Component Types
|
||||
case ElementType::BYTE3:
|
||||
FWGPU_LOGW << "Requested Filament vertex format BYTE3 but getting "
|
||||
"wgpu::VertexFormat::Sint8x4 (no direct mapping in wgpu for x3 byte)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Sint8x4 (no direct mapping in wgpu for x3 byte)";
|
||||
return VertexFormat::Sint8x4; // NOT MINSPEC
|
||||
case ElementType::UBYTE3:
|
||||
FWGPU_LOGW << "Requested Filament vertex format UBYTE3 but getting "
|
||||
"wgpu::VertexFormat::Uint8x4 (no direct mapping in wgpu for x3 byte)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Uint8x4 (no direct mapping in wgpu for x3 byte)";
|
||||
return VertexFormat::Uint8x4; // NOT MINSPEC
|
||||
case ElementType::SHORT3:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament vertex format SHORT3 but getting "
|
||||
"wgpu::VertexFormat::Sint16x4 (no direct mapping in wgpu for x3 half/short)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Sint16x4 (no direct mapping in wgpu for x3 half/short)";
|
||||
return VertexFormat::Sint16x4; // NOT MINSPEC
|
||||
case ElementType::USHORT3:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament vertex format USHORT3 but getting "
|
||||
"wgpu::VertexFormat::Uint16x4 (no direct mapping in wgpu for x3 half/short)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Uint16x4 (no direct mapping in wgpu for x3 half/short)";
|
||||
return VertexFormat::Uint16x4; // NOT MINSPEC
|
||||
case ElementType::HALF3:
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament vertex format HALF3 but getting "
|
||||
"wgpu::VertexFormat::Float16x4 (no direct mapping in wgpu for x3 half/short)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16x4 (no direct mapping in wgpu for x3 half/short)";
|
||||
return VertexFormat::Float16x4; // NOT MINSPEC
|
||||
case ElementType::FLOAT3: return VertexFormat::Float32x3;
|
||||
// Four Component Types
|
||||
@@ -186,27 +168,23 @@ namespace {
|
||||
if (integer) return VertexFormat::Sint8x4;
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament vertex format BYTE4 (float) but getting "
|
||||
"wgpu::VertexFormat::Float16x4 (no direct mapping in wgpu for 8 bit float)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16x4 (no direct mapping in wgpu for 8 bit float)";
|
||||
return VertexFormat::Float16x4;
|
||||
case ElementType::UBYTE4:
|
||||
if (integer) return VertexFormat::Uint8x4;
|
||||
FWGPU_LOGW
|
||||
<< "Requested Filament vertex format UBYTE4 (float) but getting "
|
||||
"wgpu::VertexFormat::Float16x4 (no direct mapping in wgpu for 8 bit float)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16x4 (no direct mapping in wgpu for 8 bit float)";
|
||||
return VertexFormat::Float16x4;
|
||||
case ElementType::SHORT4:
|
||||
if (integer) return VertexFormat::Sint16x4;
|
||||
FWGPU_LOGW << "Requested Filament vertex format SHORT4 (float) but getting "
|
||||
"wgpu::VertexFormat::Float16x4 (potential loss of precision?)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16x4 (potential loss of precision?)";
|
||||
return VertexFormat::Float16x4;
|
||||
case ElementType::USHORT4:
|
||||
if (integer) return VertexFormat::Uint16x4;
|
||||
FWGPU_LOGW << "Requested Filament vertex format USHORT4 (float) but getting "
|
||||
"wgpu::VertexFormat::Float16x4 (potential loss of precision?)"
|
||||
<< utils::io::endl;
|
||||
"wgpu::VertexFormat::Float16x4 (potential loss of precision?)";
|
||||
return VertexFormat::Float16x4;
|
||||
case ElementType::HALF4: return VertexFormat::Float16x4;
|
||||
case ElementType::FLOAT4: return VertexFormat::Float32x4;
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <backend/Platform.h>
|
||||
#include <utils/Hash.h>
|
||||
#include <utils/Panic.h>
|
||||
#include <utils/ostream.h>
|
||||
|
||||
#include <dawn/webgpu_cpp_print.h>
|
||||
#include <webgpu/webgpu_cpp.h>
|
||||
@@ -39,6 +38,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
#endif
|
||||
@@ -117,28 +117,6 @@ constexpr void forEachLimitToValidate(std::function<bool(LimitToValidate const)>
|
||||
}
|
||||
}
|
||||
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out,
|
||||
const wgpu::WGSLLanguageFeatureName languageFeatureName) noexcept {
|
||||
return streamInsertWebGPUPrintable(out, languageFeatureName);
|
||||
}
|
||||
|
||||
utils::io::ostream& operator<<(utils::io::ostream& out,
|
||||
const wgpu::FeatureName featureName) noexcept {
|
||||
return streamInsertWebGPUPrintable(out, featureName);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename STREAM_TYPE>
|
||||
STREAM_TYPE& operator<<(STREAM_TYPE& out, wgpu::RequestAdapterOptions const& options) noexcept {
|
||||
return streamInsertRequestAdapterOptions(out, options);
|
||||
}
|
||||
|
||||
template<class STREAM_TYPE>
|
||||
STREAM_TYPE& operator<<(STREAM_TYPE& out, wgpu::AdapterInfo const& info) noexcept {
|
||||
return streamInsertRequestAdapterInfo(out, info);
|
||||
}
|
||||
|
||||
constexpr bool isDefined(uint32_t limit) { return limit < wgpu::kLimitU32Undefined; }
|
||||
|
||||
[[maybe_unused]] constexpr bool isDefined(uint64_t limit) {
|
||||
@@ -259,7 +237,7 @@ void printInstanceDetails(wgpu::Instance const& instance) {
|
||||
supportedWGSLLanguageFeatures.features +
|
||||
supportedWGSLLanguageFeatures.featureCount,
|
||||
[](wgpu::WGSLLanguageFeatureName const featureName) {
|
||||
FWGPU_LOGI << " " << featureName;
|
||||
FWGPU_LOGI << " " << webGPUPrintableToString(featureName);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -299,23 +277,22 @@ void printInstanceDetails(wgpu::Instance const& instance) {
|
||||
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
void printLimit(std::string_view name, const std::variant<uint32_t, uint64_t> value) {
|
||||
FWGPU_LOGI << " " << name.data() << ": ";
|
||||
static constexpr std::string_view indent = " ";
|
||||
bool undefined = true;
|
||||
if (std::holds_alternative<uint32_t>(value)) {
|
||||
if (std::get<uint32_t>(value) != WGPU_LIMIT_U32_UNDEFINED) {
|
||||
undefined = false;
|
||||
FWGPU_LOGI << std::get<uint32_t>(value);
|
||||
FWGPU_LOGI << indent << name.data() << ": " << std::get<uint32_t>(value);
|
||||
}
|
||||
} else if (std::holds_alternative<uint64_t>(value)) {
|
||||
if (std::get<uint64_t>(value) != WGPU_LIMIT_U64_UNDEFINED) {
|
||||
undefined = false;
|
||||
FWGPU_LOGI << std::get<uint64_t>(value);
|
||||
FWGPU_LOGI << indent << name.data() << ": " << std::get<uint64_t>(value);
|
||||
}
|
||||
}
|
||||
if (undefined) {
|
||||
FWGPU_LOGI << "UNDEFINED";
|
||||
FWGPU_LOGI << indent << name.data() << ": UNDEFINED";
|
||||
}
|
||||
FWGPU_LOGI << "";
|
||||
}
|
||||
#endif// FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
|
||||
@@ -393,16 +370,16 @@ struct AdapterDetails final {
|
||||
}
|
||||
};
|
||||
|
||||
template<class STREAM_TYPE>
|
||||
STREAM_TYPE& operator<<(STREAM_TYPE& out, AdapterDetails const& details) noexcept {
|
||||
out << details.info
|
||||
[[nodiscard]] std::string toString(AdapterDetails const& details) {
|
||||
std::stringstream out;
|
||||
out << adapterInfoToString(details.info)
|
||||
<< " power preference " << powerPreferenceToString(details.powerPreference);
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
void printAdapterDetails(AdapterDetails const& details) {
|
||||
FWGPU_LOGI << "Selected WebGPU adapter info: " << details;
|
||||
FWGPU_LOGI << "Selected WebGPU adapter info: " << toString(details);
|
||||
wgpu::SupportedFeatures supportedFeatures{};
|
||||
details.adapter.GetFeatures(&supportedFeatures);
|
||||
FWGPU_LOGI << "WebGPU adapter supported features (" << supportedFeatures.featureCount
|
||||
@@ -411,7 +388,7 @@ void printAdapterDetails(AdapterDetails const& details) {
|
||||
std::for_each(supportedFeatures.features,
|
||||
supportedFeatures.features + supportedFeatures.featureCount,
|
||||
[](wgpu::FeatureName const featureName) {
|
||||
FWGPU_LOGI << " " << featureName;
|
||||
FWGPU_LOGI << " " << webGPUPrintableToString(featureName);
|
||||
});
|
||||
}
|
||||
wgpu::Limits supportedLimits{};
|
||||
@@ -444,12 +421,12 @@ struct AdapterDetailsHash final {
|
||||
return details.adapter.HasFeature(featureName);
|
||||
})) {
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
FWGPU_LOGI << "WebGPU adapter " << details
|
||||
FWGPU_LOGI << "WebGPU adapter " << toString(details)
|
||||
<< " does not have the minimum required features.";
|
||||
FWGPU_LOGI << "Missing required feature(s): ";
|
||||
for (wgpu::FeatureName const& requiredFeature: REQUIRED_FEATURES) {
|
||||
if (!details.adapter.HasFeature(requiredFeature)) {
|
||||
FWGPU_LOGI << requiredFeature;
|
||||
FWGPU_LOGI << webGPUPrintableToString(requiredFeature);
|
||||
}
|
||||
}
|
||||
FWGPU_LOGI << "";
|
||||
@@ -458,10 +435,10 @@ struct AdapterDetailsHash final {
|
||||
}
|
||||
wgpu::Limits supportedLimits {};
|
||||
FILAMENT_CHECK_POSTCONDITION(details.adapter.GetLimits(&supportedLimits))
|
||||
<< "Failed to get limits for WebGPU adapter: " << details;
|
||||
<< "Failed to get limits for WebGPU adapter: " << toString(details);
|
||||
if (!satisfiesLimits(supportedLimits)) {
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
FWGPU_LOGI << " (for WebGPU adapter " << details << ")";
|
||||
FWGPU_LOGI << " (for WebGPU adapter " << toString(details) << ")";
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@@ -487,14 +464,15 @@ struct AdapterDetailsHash final {
|
||||
status != wgpu::RequestAdapterStatus::CallbackCancelled)
|
||||
<< "Failed to request a WebGPU adapter due to the request callback "
|
||||
"being cancelled? Options: "
|
||||
<< options << " " << message.data;
|
||||
<< adapterOptionsToString(options) << " " << message.data;
|
||||
FILAMENT_CHECK_POSTCONDITION(status != wgpu::RequestAdapterStatus::Error)
|
||||
<< "Failed to request a WebGPU adapter due to an error. Options: "
|
||||
<< options << " Error: " << message.data;
|
||||
<< adapterOptionsToString(options) << " Error: " << message.data;
|
||||
if (status == wgpu::RequestAdapterStatus::Success) {
|
||||
AdapterDetails details = AdapterDetails(readyAdapter);
|
||||
FILAMENT_CHECK_POSTCONDITION(readyAdapter.GetInfo(&details.info))
|
||||
<< "Failed to get info for adapter (options: " << options << ")";
|
||||
<< "Failed to get info for adapter (options: "
|
||||
<< adapterOptionsToString(options) << ")";
|
||||
const std::lock_guard<std::mutex> lock(adaptersMutex);
|
||||
compatibleAdapters.emplace(std::move(details.info), details.powerPreference,
|
||||
std::move(details.adapter));
|
||||
@@ -509,9 +487,11 @@ struct AdapterDetailsHash final {
|
||||
wgpu::Future& future = futures[i];
|
||||
wgpu::WaitStatus status = instance.WaitAny(future, REQUEST_ADAPTER_TIMEOUT_NANOSECONDS);
|
||||
FILAMENT_CHECK_POSTCONDITION(status != wgpu::WaitStatus::TimedOut)
|
||||
<< "Timed out requesting a WebGPU adapter with options " << options;
|
||||
<< "Timed out requesting a WebGPU adapter with options "
|
||||
<< adapterOptionsToString(options);
|
||||
FILAMENT_CHECK_POSTCONDITION(status != wgpu::WaitStatus::Error)
|
||||
<< "Failed to request a WebGPU adapter with options " << options
|
||||
<< "Failed to request a WebGPU adapter with options "
|
||||
<< adapterOptionsToString(options)
|
||||
<< " due to an error (as request was made synchronous)";
|
||||
assert_invariant(status == wgpu::WaitStatus::Success);
|
||||
}
|
||||
@@ -519,7 +499,7 @@ struct AdapterDetailsHash final {
|
||||
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
|
||||
FWGPU_LOGI << compatibleAdapters.size() << " WebGPU adapter(s) found:";
|
||||
for (auto& details: compatibleAdapters) {
|
||||
FWGPU_LOGI << " WebGPU adapter: " << details;
|
||||
FWGPU_LOGI << " WebGPU adapter: " << toString(details);
|
||||
}
|
||||
#endif
|
||||
return compatibleAdapters;
|
||||
@@ -586,7 +566,7 @@ void printDeviceDetails(wgpu::Device const& device) {
|
||||
std::for_each(supportedFeatures.features,
|
||||
supportedFeatures.features + supportedFeatures.featureCount,
|
||||
[](wgpu::FeatureName const featureName) {
|
||||
FWGPU_LOGI << " " << featureName;
|
||||
FWGPU_LOGI << " " << webGPUPrintableToString(featureName);
|
||||
});
|
||||
}
|
||||
wgpu::Limits supportedLimits{};
|
||||
|
||||
Reference in New Issue
Block a user