Enable -Wglobal-constructors for dawn/native
Eliminates a static initializer in kUnusedFormat (in Texture.cpp) by making dawn::native::Format constexpr-constructible. kUnusedFormat doesn't actually have to be constexpr to fix this, but it adds explicit enforcement that it's constexpr-constructible. Includes some extra initializers as a workaround for a bug in the old version of MSVC (14.26) that's on Kokoro. amaiorano figured out how to reproduce it locally, with a local install of VS2019 and this magic CMake incantation: $ cmake -G "Visual Studio 16 2019" -T v142,version=14.26 .. Bug: dawn:1405 Change-Id: Ic94324fc624fd720671dec35dcc5ea8ad77ee46d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89863 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
34d2d1ba02
commit
5eeef7c47f
|
@ -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
|
||||
|
|
|
@ -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<FormatIndex, Format, kKnownFormatCount>;
|
|||
|
||||
// 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, kMaxPlanesPerFormat> aspectInfo;
|
||||
std::array<AspectInfo, kMaxPlanesPerFormat> aspectInfo{};
|
||||
|
||||
friend FormatTable BuildFormatTable(const DeviceBase* device);
|
||||
};
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue