diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn index 409d847e47..c919a4f090 100644 --- a/src/dawn/native/BUILD.gn +++ b/src/dawn/native/BUILD.gn @@ -155,7 +155,13 @@ source_set("sources") { libs = [] data_deps = [] - configs += [ ":internal" ] + configs += [ + ":internal", + + # Enable -Wglobal-constructors here only, instead of in internal_config, + # because gtest and some other targets don't build with it. + "//build/config/compiler:wglobal_constructors", + ] # Dependencies that are needed to compile dawn native entry points in # FooBackend.cpp need to be public deps so they are propagated to the diff --git a/src/dawn/native/Format.h b/src/dawn/native/Format.h index b48e998f1d..8f750da25b 100644 --- a/src/dawn/native/Format.h +++ b/src/dawn/native/Format.h @@ -72,8 +72,8 @@ struct AspectInfo { TexelBlockInfo block; // TODO(crbug.com/dawn/367): Replace TextureComponentType with TextureSampleType, or make it // an internal Dawn enum. - wgpu::TextureComponentType baseType; - SampleTypeBit supportedSampleTypes; + wgpu::TextureComponentType baseType{}; + SampleTypeBit supportedSampleTypes{}; wgpu::TextureFormat format = wgpu::TextureFormat::Undefined; }; @@ -88,19 +88,19 @@ using FormatTable = ityp::array; // A wgpu::TextureFormat along with all the information about it necessary for validation. struct Format { - wgpu::TextureFormat format; + wgpu::TextureFormat format = wgpu::TextureFormat::Undefined; // TODO(crbug.com/dawn/1332): These members could be stored in a Format capability matrix. - bool isRenderable; - bool isCompressed; + bool isRenderable = false; + bool isCompressed = false; // A format can be known but not supported because it is part of a disabled extension. - bool isSupported; - bool supportsStorageUsage; - bool supportsMultisample; - bool supportsResolveTarget; - Aspect aspects; + bool isSupported = false; + bool supportsStorageUsage = false; + bool supportsMultisample = false; + bool supportsResolveTarget = false; + Aspect aspects{}; // Only used for renderable color formats, number of color channels. - uint8_t componentCount; + uint8_t componentCount = 0; bool IsColor() const; bool HasDepth() const; @@ -121,7 +121,7 @@ struct Format { // baseFormat represents the memory layout of the format. // If two formats has the same baseFormat, they could copy to and be viewed as the other // format. Currently two formats have the same baseFormat if they differ only in sRGB-ness. - wgpu::TextureFormat baseFormat; + wgpu::TextureFormat baseFormat = wgpu::TextureFormat::Undefined; // Returns true if the formats are copy compatible. // Currently means they differ only in sRGB-ness. @@ -136,7 +136,7 @@ struct Format { // only the first aspect info or aspectInfo[0] is valid. For depth-stencil, the first aspect // info is depth and the second aspect info is stencil. For multi-planar formats, // aspectInfo[i] is the ith plane. - std::array aspectInfo; + std::array aspectInfo{}; friend FormatTable BuildFormatTable(const DeviceBase* device); }; diff --git a/src/dawn/native/Texture.cpp b/src/dawn/native/Texture.cpp index 457e76d91e..0d750431ed 100644 --- a/src/dawn/native/Texture.cpp +++ b/src/dawn/native/Texture.cpp @@ -548,7 +548,7 @@ TextureBase::TextureBase(DeviceBase* device, TextureBase::~TextureBase() = default; -static Format kUnusedFormat; +static constexpr Format kUnusedFormat; TextureBase::TextureBase(DeviceBase* device, TextureState state) : ApiObjectBase(device, kLabelNotImplemented), mFormat(kUnusedFormat), mState(state) {