BUILD.gn: enable additional warnings.
Skia uses more warnings than Dawn, enable in Dawn directly so that
rolls of Dawn into Skia don't introduce warnings. These warnings
seem useful anyway.
Bug: chromium:1064305
Change-Id: I13dc776af84151131584a95caeee2cd21ae80fea
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18964
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/common/BUILD.gn b/src/common/BUILD.gn
index 321fa30..15954bc 100644
--- a/src/common/BUILD.gn
+++ b/src/common/BUILD.gn
@@ -86,6 +86,17 @@
# Only internal Dawn targets can use this config, this means only targets in
# this BUILD.gn file.
visibility = [ ":*" ]
+
+ # Enable more warnings that were found when using Dawn in other projects
+ if (is_clang) {
+ cflags = [
+ "-Wstrict-prototypes",
+ "-Winconsistent-missing-destructor-override",
+ "-Wshadow-field",
+ "-Wmissing-field-initializers",
+ "-Wcstring-format-directive",
+ ]
+ }
}
###############################################################################
diff --git a/src/dawn_native/RenderBundleEncoder.cpp b/src/dawn_native/RenderBundleEncoder.cpp
index 956fa8b..4970042 100644
--- a/src/dawn_native/RenderBundleEncoder.cpp
+++ b/src/dawn_native/RenderBundleEncoder.cpp
@@ -79,13 +79,14 @@
RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device,
const RenderBundleEncoderDescriptor* descriptor)
- : RenderEncoderBase(device, &mEncodingContext),
- mEncodingContext(device, this),
+ : RenderEncoderBase(device, &mBundleEncodingContext),
+ mBundleEncodingContext(device, this),
mAttachmentState(device->GetOrCreateAttachmentState(descriptor)) {
}
RenderBundleEncoder::RenderBundleEncoder(DeviceBase* device, ErrorTag errorTag)
- : RenderEncoderBase(device, &mEncodingContext, errorTag), mEncodingContext(device, this) {
+ : RenderEncoderBase(device, &mBundleEncodingContext, errorTag),
+ mBundleEncodingContext(device, this) {
}
// static
@@ -98,18 +99,19 @@
}
CommandIterator RenderBundleEncoder::AcquireCommands() {
- return mEncodingContext.AcquireCommands();
+ return mBundleEncodingContext.AcquireCommands();
}
RenderBundleBase* RenderBundleEncoder::Finish(const RenderBundleDescriptor* descriptor) {
PassResourceUsage usages = mUsageTracker.AcquireResourceUsage();
DeviceBase* device = GetDevice();
- // Even if mEncodingContext.Finish() validation fails, calling it will mutate the internal
- // state of the encoding context. Subsequent calls to encode commands will generate errors.
- if (device->ConsumedError(mEncodingContext.Finish()) ||
+ // Even if mBundleEncodingContext.Finish() validation fails, calling it will mutate the
+ // internal state of the encoding context. Subsequent calls to encode commands will generate
+ // errors.
+ if (device->ConsumedError(mBundleEncodingContext.Finish()) ||
(device->IsValidationEnabled() &&
- device->ConsumedError(ValidateFinish(mEncodingContext.GetIterator(), usages)))) {
+ device->ConsumedError(ValidateFinish(mBundleEncodingContext.GetIterator(), usages)))) {
return RenderBundleBase::MakeError(device);
}
diff --git a/src/dawn_native/RenderBundleEncoder.h b/src/dawn_native/RenderBundleEncoder.h
index 0581719..e6354ab 100644
--- a/src/dawn_native/RenderBundleEncoder.h
+++ b/src/dawn_native/RenderBundleEncoder.h
@@ -44,7 +44,7 @@
MaybeError ValidateFinish(CommandIterator* commands, const PassResourceUsage& usages) const;
- EncodingContext mEncodingContext;
+ EncodingContext mBundleEncodingContext;
Ref<AttachmentState> mAttachmentState;
};
} // namespace dawn_native
diff --git a/src/dawn_native/Toggles.cpp b/src/dawn_native/Toggles.cpp
index 8c3a130..eb6ecd7 100644
--- a/src/dawn_native/Toggles.cpp
+++ b/src/dawn_native/Toggles.cpp
@@ -88,7 +88,8 @@
"Enable residency management. This allows page-in and page-out of resource heaps in "
"GPU memory. This component improves overcommitted performance by keeping the most "
"recently used resources local to the GPU. Turning this component off can cause "
- "allocation failures when application memory exceeds physical device memory."}},
+ "allocation failures when application memory exceeds physical device memory.",
+ "https://crbug.com/dawn/193"}},
{Toggle::SkipValidation,
{"skip_validation", "Skip expensive validation of Dawn commands.",
"https://crbug.com/dawn/271"}},
@@ -111,18 +112,22 @@
{Toggle::MetalDisableSamplerCompare,
{"metal_disable_sampler_compare",
"Disables the use of sampler compare on Metal. This is unsupported before A9 "
- "processors."}},
+ "processors.",
+ "https://crbug.com/dawn/342"}},
{Toggle::DisableBaseVertex,
{"disable_base_vertex",
- "Disables the use of non-zero base vertex which is unsupported on some platforms."}},
+ "Disables the use of non-zero base vertex which is unsupported on some platforms.",
+ "https://crbug.com/dawn/343"}},
{Toggle::DisableBaseInstance,
{"disable_base_instance",
"Disables the use of non-zero base instance which is unsupported on some "
- "platforms."}},
+ "platforms.",
+ "https://crbug.com/dawn/343"}},
{Toggle::UseD3D12SmallShaderVisibleHeapForTesting,
{"use_d3d12_small_shader_visible_heap",
"Enable use of a small D3D12 shader visible heap, instead of using a large one by "
- "default. This setting is used to test bindgroup encoding."}},
+ "default. This setting is used to test bindgroup encoding.",
+ "https://crbug.com/dawn/155"}},
}};
} // anonymous namespace
diff --git a/src/dawn_native/d3d12/AdapterD3D12.h b/src/dawn_native/d3d12/AdapterD3D12.h
index 6c2d4f1..48345c1 100644
--- a/src/dawn_native/d3d12/AdapterD3D12.h
+++ b/src/dawn_native/d3d12/AdapterD3D12.h
@@ -27,7 +27,7 @@
class Adapter : public AdapterBase {
public:
Adapter(Backend* backend, ComPtr<IDXGIAdapter3> hardwareAdapter);
- virtual ~Adapter() = default;
+ ~Adapter() override = default;
const D3D12DeviceInfo& GetDeviceInfo() const;
IDXGIAdapter3* GetHardwareAdapter() const;
@@ -49,4 +49,4 @@
}} // namespace dawn_native::d3d12
-#endif // DAWNNATIVE_D3D12_ADAPTERD3D12_H_
\ No newline at end of file
+#endif // DAWNNATIVE_D3D12_ADAPTERD3D12_H_
diff --git a/src/dawn_native/d3d12/DeviceD3D12.h b/src/dawn_native/d3d12/DeviceD3D12.h
index 8f135fd..406ce39 100644
--- a/src/dawn_native/d3d12/DeviceD3D12.h
+++ b/src/dawn_native/d3d12/DeviceD3D12.h
@@ -46,7 +46,7 @@
class Device : public DeviceBase {
public:
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor);
- ~Device();
+ ~Device() override;
MaybeError Initialize();
diff --git a/src/dawn_native/d3d12/StagingBufferD3D12.h b/src/dawn_native/d3d12/StagingBufferD3D12.h
index 5bc32a2..291400d 100644
--- a/src/dawn_native/d3d12/StagingBufferD3D12.h
+++ b/src/dawn_native/d3d12/StagingBufferD3D12.h
@@ -27,7 +27,7 @@
class StagingBuffer : public StagingBufferBase {
public:
StagingBuffer(size_t size, Device* device);
- ~StagingBuffer();
+ ~StagingBuffer() override;
ID3D12Resource* GetResource() const;
diff --git a/src/dawn_native/metal/DeviceMTL.h b/src/dawn_native/metal/DeviceMTL.h
index cc23f7a..72aa55b 100644
--- a/src/dawn_native/metal/DeviceMTL.h
+++ b/src/dawn_native/metal/DeviceMTL.h
@@ -39,7 +39,7 @@
static ResultOrError<Device*> Create(AdapterBase* adapter,
id<MTLDevice> mtlDevice,
const DeviceDescriptor* descriptor);
- ~Device();
+ ~Device() override;
MaybeError Initialize();
diff --git a/src/dawn_native/metal/ShaderModuleMTL.mm b/src/dawn_native/metal/ShaderModuleMTL.mm
index 7d573fb..a06adcc 100644
--- a/src/dawn_native/metal/ShaderModuleMTL.mm
+++ b/src/dawn_native/metal/ShaderModuleMTL.mm
@@ -190,10 +190,10 @@
std::string result_str;
DAWN_TRY(CheckSpvcSuccess(result.GetStringOutput(&result_str),
"Unable to get MSL shader text"));
- mslSource = [NSString stringWithFormat:@"%s", result_str.c_str()];
+ mslSource = [[NSString alloc] initWithUTF8String:result_str.c_str()];
} else {
std::string msl = compiler->compile();
- mslSource = [NSString stringWithFormat:@"%s", msl.c_str()];
+ mslSource = [[NSString alloc] initWithUTF8String:msl.c_str()];
}
auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice();
NSError* error = nil;
@@ -216,7 +216,7 @@
functionName = "main0";
}
- NSString* name = [NSString stringWithFormat:@"%s", functionName];
+ NSString* name = [[NSString alloc] initWithUTF8String:functionName];
out->function = [library newFunctionWithName:name];
[library release];
}
diff --git a/src/dawn_native/metal/StagingBufferMTL.h b/src/dawn_native/metal/StagingBufferMTL.h
index e2d1ecc..7e9815b 100644
--- a/src/dawn_native/metal/StagingBufferMTL.h
+++ b/src/dawn_native/metal/StagingBufferMTL.h
@@ -26,7 +26,7 @@
class StagingBuffer : public StagingBufferBase {
public:
StagingBuffer(size_t size, Device* device);
- ~StagingBuffer();
+ ~StagingBuffer() override;
id<MTLBuffer> GetBufferHandle() const;
diff --git a/src/dawn_native/null/DeviceNull.h b/src/dawn_native/null/DeviceNull.h
index 8d85e8a..c14ffff 100644
--- a/src/dawn_native/null/DeviceNull.h
+++ b/src/dawn_native/null/DeviceNull.h
@@ -84,7 +84,7 @@
class Device : public DeviceBase {
public:
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor);
- ~Device();
+ ~Device() override;
MaybeError Initialize();
@@ -152,7 +152,7 @@
class Adapter : public AdapterBase {
public:
Adapter(InstanceBase* instance);
- virtual ~Adapter();
+ ~Adapter() override;
// Used for the tests that intend to use an adapter without all extensions enabled.
void SetSupportedExtensions(const std::vector<const char*>& requiredExtensions);
diff --git a/src/dawn_native/opengl/DeviceGL.h b/src/dawn_native/opengl/DeviceGL.h
index e18d046..f274993 100644
--- a/src/dawn_native/opengl/DeviceGL.h
+++ b/src/dawn_native/opengl/DeviceGL.h
@@ -37,7 +37,7 @@
static ResultOrError<Device*> Create(AdapterBase* adapter,
const DeviceDescriptor* descriptor,
const OpenGLFunctions& functions);
- ~Device();
+ ~Device() override;
MaybeError Initialize();
diff --git a/src/dawn_native/vulkan/AdapterVk.h b/src/dawn_native/vulkan/AdapterVk.h
index a4a3d53..67f77d9 100644
--- a/src/dawn_native/vulkan/AdapterVk.h
+++ b/src/dawn_native/vulkan/AdapterVk.h
@@ -27,7 +27,7 @@
class Adapter : public AdapterBase {
public:
Adapter(Backend* backend, VkPhysicalDevice physicalDevice);
- virtual ~Adapter() = default;
+ ~Adapter() override = default;
const VulkanDeviceInfo& GetDeviceInfo() const;
VkPhysicalDevice GetPhysicalDevice() const;
diff --git a/src/dawn_native/vulkan/DeviceVk.h b/src/dawn_native/vulkan/DeviceVk.h
index 66d50e7..40c0e3d 100644
--- a/src/dawn_native/vulkan/DeviceVk.h
+++ b/src/dawn_native/vulkan/DeviceVk.h
@@ -44,7 +44,7 @@
class Device : public DeviceBase {
public:
static ResultOrError<Device*> Create(Adapter* adapter, const DeviceDescriptor* descriptor);
- ~Device();
+ ~Device() override;
MaybeError Initialize();
diff --git a/src/dawn_native/vulkan/StagingBufferVk.h b/src/dawn_native/vulkan/StagingBufferVk.h
index 1106a27..50b773a 100644
--- a/src/dawn_native/vulkan/StagingBufferVk.h
+++ b/src/dawn_native/vulkan/StagingBufferVk.h
@@ -26,7 +26,7 @@
class StagingBuffer : public StagingBufferBase {
public:
StagingBuffer(size_t size, Device* device);
- ~StagingBuffer();
+ ~StagingBuffer() override;
VkBuffer GetBufferHandle() const;
diff --git a/src/dawn_native/vulkan/VulkanBackend.cpp b/src/dawn_native/vulkan/VulkanBackend.cpp
index f24d8ca..c1458a0 100644
--- a/src/dawn_native/vulkan/VulkanBackend.cpp
+++ b/src/dawn_native/vulkan/VulkanBackend.cpp
@@ -60,8 +60,8 @@
}
#ifdef DAWN_PLATFORM_LINUX
- ExternalImageDescriptorFD::ExternalImageDescriptorFD(ExternalImageDescriptorType type)
- : ExternalImageDescriptor(type) {
+ ExternalImageDescriptorFD::ExternalImageDescriptorFD(ExternalImageDescriptorType descType)
+ : ExternalImageDescriptor(descType) {
}
ExternalImageDescriptorOpaqueFD::ExternalImageDescriptorOpaqueFD()
diff --git a/src/dawn_wire/client/Device.cpp b/src/dawn_wire/client/Device.cpp
index 175617f..7d62b06 100644
--- a/src/dawn_wire/client/Device.cpp
+++ b/src/dawn_wire/client/Device.cpp
@@ -20,8 +20,8 @@
namespace dawn_wire { namespace client {
- Device::Device(Client* client, uint32_t refcount, uint32_t id)
- : ObjectBase(this, refcount, id), mClient(client) {
+ Device::Device(Client* client, uint32_t initialRefcount, uint32_t initialId)
+ : ObjectBase(this, initialRefcount, initialId), mClient(client) {
this->device = this;
}
diff --git a/src/include/dawn_wire/WireClient.h b/src/include/dawn_wire/WireClient.h
index 3b9d872..7c8ee40 100644
--- a/src/include/dawn_wire/WireClient.h
+++ b/src/include/dawn_wire/WireClient.h
@@ -42,7 +42,7 @@
class DAWN_WIRE_EXPORT WireClient : public CommandHandler {
public:
WireClient(const WireClientDescriptor& descriptor);
- ~WireClient();
+ ~WireClient() override;
static DawnProcTable GetProcs();
diff --git a/src/include/dawn_wire/WireServer.h b/src/include/dawn_wire/WireServer.h
index f965a04..b595721 100644
--- a/src/include/dawn_wire/WireServer.h
+++ b/src/include/dawn_wire/WireServer.h
@@ -38,7 +38,7 @@
class DAWN_WIRE_EXPORT WireServer : public CommandHandler {
public:
WireServer(const WireServerDescriptor& descriptor);
- ~WireServer();
+ ~WireServer() override;
const volatile char* HandleCommands(const volatile char* commands,
size_t size) override final;
diff --git a/src/tests/DawnTest.h b/src/tests/DawnTest.h
index 13bf44f..7cbe539 100644
--- a/src/tests/DawnTest.h
+++ b/src/tests/DawnTest.h
@@ -132,7 +132,7 @@
class DawnTestEnvironment : public testing::Environment {
public:
DawnTestEnvironment(int argc, char** argv);
- ~DawnTestEnvironment() = default;
+ ~DawnTestEnvironment() override = default;
static void SetEnvironment(DawnTestEnvironment* env);
diff --git a/src/tests/end2end/BindGroupTests.cpp b/src/tests/end2end/BindGroupTests.cpp
index ee8eb05..762d431 100644
--- a/src/tests/end2end/BindGroupTests.cpp
+++ b/src/tests/end2end/BindGroupTests.cpp
@@ -35,7 +35,6 @@
}
wgpu::PipelineLayout MakeBasicPipelineLayout(
- wgpu::Device device,
std::vector<wgpu::BindGroupLayout> bindingInitializer) const {
wgpu::PipelineLayoutDescriptor descriptor;
@@ -103,7 +102,7 @@
wgpu::ShaderModule vsModule = MakeSimpleVSModule();
wgpu::ShaderModule fsModule = MakeFSModule(bindingTypes);
- wgpu::PipelineLayout pipelineLayout = MakeBasicPipelineLayout(device, bindGroupLayouts);
+ wgpu::PipelineLayout pipelineLayout = MakeBasicPipelineLayout(bindGroupLayouts);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.layout = pipelineLayout;
diff --git a/src/tests/end2end/D3D12ResourceWrappingTests.cpp b/src/tests/end2end/D3D12ResourceWrappingTests.cpp
index 745edb7..a07e5ab 100644
--- a/src/tests/end2end/D3D12ResourceWrappingTests.cpp
+++ b/src/tests/end2end/D3D12ResourceWrappingTests.cpp
@@ -59,37 +59,37 @@
mD3d11Device = std::move(d3d11Device);
mD3d11DeviceContext = std::move(d3d11DeviceContext);
- dawnDescriptor.dimension = wgpu::TextureDimension::e2D;
- dawnDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
- dawnDescriptor.size = {kTestWidth, kTestHeight, 1};
- dawnDescriptor.sampleCount = 1;
- dawnDescriptor.arrayLayerCount = 1;
- dawnDescriptor.mipLevelCount = 1;
- dawnDescriptor.usage = wgpu::TextureUsage::Sampled | wgpu::TextureUsage::CopySrc |
- wgpu::TextureUsage::OutputAttachment |
- wgpu::TextureUsage::CopyDst;
+ baseDawnDescriptor.dimension = wgpu::TextureDimension::e2D;
+ baseDawnDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
+ baseDawnDescriptor.size = {kTestWidth, kTestHeight, 1};
+ baseDawnDescriptor.sampleCount = 1;
+ baseDawnDescriptor.arrayLayerCount = 1;
+ baseDawnDescriptor.mipLevelCount = 1;
+ baseDawnDescriptor.usage = wgpu::TextureUsage::Sampled | wgpu::TextureUsage::CopySrc |
+ wgpu::TextureUsage::OutputAttachment |
+ wgpu::TextureUsage::CopyDst;
- d3dDescriptor.Width = kTestWidth;
- d3dDescriptor.Height = kTestHeight;
- d3dDescriptor.MipLevels = 1;
- d3dDescriptor.ArraySize = 1;
- d3dDescriptor.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- d3dDescriptor.SampleDesc.Count = 1;
- d3dDescriptor.SampleDesc.Quality = 0;
- d3dDescriptor.Usage = D3D11_USAGE_DEFAULT;
- d3dDescriptor.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
- d3dDescriptor.CPUAccessFlags = 0;
- d3dDescriptor.MiscFlags =
+ baseD3dDescriptor.Width = kTestWidth;
+ baseD3dDescriptor.Height = kTestHeight;
+ baseD3dDescriptor.MipLevels = 1;
+ baseD3dDescriptor.ArraySize = 1;
+ baseD3dDescriptor.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ baseD3dDescriptor.SampleDesc.Count = 1;
+ baseD3dDescriptor.SampleDesc.Quality = 0;
+ baseD3dDescriptor.Usage = D3D11_USAGE_DEFAULT;
+ baseD3dDescriptor.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
+ baseD3dDescriptor.CPUAccessFlags = 0;
+ baseD3dDescriptor.MiscFlags =
D3D11_RESOURCE_MISC_SHARED_NTHANDLE | D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
}
protected:
- void WrapSharedHandle(const wgpu::TextureDescriptor* dawnDescriptor,
- const D3D11_TEXTURE2D_DESC* d3dDescriptor,
+ void WrapSharedHandle(const wgpu::TextureDescriptor* dawnDesc,
+ const D3D11_TEXTURE2D_DESC* baseD3dDescriptor,
wgpu::Texture* dawnTexture,
ID3D11Texture2D** d3d11TextureOut) const {
ComPtr<ID3D11Texture2D> d3d11Texture;
- HRESULT hr = mD3d11Device->CreateTexture2D(d3dDescriptor, nullptr, &d3d11Texture);
+ HRESULT hr = mD3d11Device->CreateTexture2D(baseD3dDescriptor, nullptr, &d3d11Texture);
ASSERT_EQ(hr, S_OK);
ComPtr<IDXGIResource1> dxgiResource;
@@ -104,7 +104,7 @@
dawn_native::d3d12::ExternalImageDescriptorDXGISharedHandle externDesc;
externDesc.cTextureDescriptor =
- reinterpret_cast<const WGPUTextureDescriptor*>(dawnDescriptor);
+ reinterpret_cast<const WGPUTextureDescriptor*>(dawnDesc);
externDesc.sharedHandle = sharedHandle;
externDesc.acquireMutexKey = 0;
WGPUTexture texture = dawn_native::d3d12::WrapSharedHandle(device.Get(), &externDesc);
@@ -123,8 +123,8 @@
ComPtr<ID3D11Device> mD3d11Device;
ComPtr<ID3D11DeviceContext> mD3d11DeviceContext;
- D3D11_TEXTURE2D_DESC d3dDescriptor;
- wgpu::TextureDescriptor dawnDescriptor;
+ D3D11_TEXTURE2D_DESC baseD3dDescriptor;
+ wgpu::TextureDescriptor baseDawnDescriptor;
};
} // anonymous namespace
@@ -140,7 +140,7 @@
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture);
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture);
ASSERT_NE(texture.Get(), nullptr);
}
@@ -150,11 +150,12 @@
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ChainedStruct chainedDescriptor;
- dawnDescriptor.nextInChain = &chainedDescriptor;
+ baseDawnDescriptor.nextInChain = &chainedDescriptor;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
+ ASSERT_DEVICE_ERROR(
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@@ -162,11 +163,12 @@
// Test an error occurs if the descriptor mip level count isn't 1
TEST_P(D3D12SharedHandleValidation, InvalidMipLevelCount) {
DAWN_SKIP_TEST_IF(UsesWire());
- dawnDescriptor.mipLevelCount = 2;
+ baseDawnDescriptor.mipLevelCount = 2;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
+ ASSERT_DEVICE_ERROR(
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@@ -174,11 +176,12 @@
// Test an error occurs if the descriptor array layer count isn't 1
TEST_P(D3D12SharedHandleValidation, InvalidArrayLayerCount) {
DAWN_SKIP_TEST_IF(UsesWire());
- dawnDescriptor.arrayLayerCount = 2;
+ baseDawnDescriptor.arrayLayerCount = 2;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
+ ASSERT_DEVICE_ERROR(
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@@ -186,11 +189,12 @@
// Test an error occurs if the descriptor sample count isn't 1
TEST_P(D3D12SharedHandleValidation, InvalidSampleCount) {
DAWN_SKIP_TEST_IF(UsesWire());
- dawnDescriptor.sampleCount = 4;
+ baseDawnDescriptor.sampleCount = 4;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
+ ASSERT_DEVICE_ERROR(
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@@ -198,11 +202,12 @@
// Test an error occurs if the descriptor width doesn't match the texture's
TEST_P(D3D12SharedHandleValidation, InvalidWidth) {
DAWN_SKIP_TEST_IF(UsesWire());
- dawnDescriptor.size.width = kTestWidth + 1;
+ baseDawnDescriptor.size.width = kTestWidth + 1;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
+ ASSERT_DEVICE_ERROR(
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@@ -210,11 +215,12 @@
// Test an error occurs if the descriptor height doesn't match the texture's
TEST_P(D3D12SharedHandleValidation, InvalidHeight) {
DAWN_SKIP_TEST_IF(UsesWire());
- dawnDescriptor.size.height = kTestHeight + 1;
+ baseDawnDescriptor.size.height = kTestHeight + 1;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
+ ASSERT_DEVICE_ERROR(
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@@ -222,11 +228,12 @@
// Test an error occurs if the descriptor format isn't compatible with the D3D12 Resource
TEST_P(D3D12SharedHandleValidation, InvalidFormat) {
DAWN_SKIP_TEST_IF(UsesWire());
- dawnDescriptor.format = wgpu::TextureFormat::R8Unorm;
+ baseDawnDescriptor.format = wgpu::TextureFormat::R8Unorm;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
+ ASSERT_DEVICE_ERROR(
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@@ -234,11 +241,12 @@
// Test an error occurs if the number of D3D mip levels is greater than 1.
TEST_P(D3D12SharedHandleValidation, InvalidNumD3DMipLevels) {
DAWN_SKIP_TEST_IF(UsesWire());
- d3dDescriptor.MipLevels = 2;
+ baseD3dDescriptor.MipLevels = 2;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
+ ASSERT_DEVICE_ERROR(
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@@ -246,11 +254,12 @@
// Test an error occurs if the number of array levels is greater than 1.
TEST_P(D3D12SharedHandleValidation, InvalidD3DArraySize) {
DAWN_SKIP_TEST_IF(UsesWire());
- d3dDescriptor.ArraySize = 2;
+ baseD3dDescriptor.ArraySize = 2;
wgpu::Texture texture;
ComPtr<ID3D11Texture2D> d3d11Texture;
- ASSERT_DEVICE_ERROR(WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture));
+ ASSERT_DEVICE_ERROR(
+ WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture));
ASSERT_EQ(texture.Get(), nullptr);
}
@@ -416,11 +425,11 @@
wgpu::Texture dawnSrcTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
- WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnSrcTexture, clearColor,
+ WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnSrcTexture, clearColor,
&d3d11Texture, &dxgiKeyedMutex);
// Create a texture on the device and copy the source texture to it.
- wgpu::Texture dawnCopyDestTexture = device.CreateTexture(&dawnDescriptor);
+ wgpu::Texture dawnCopyDestTexture = device.CreateTexture(&baseDawnDescriptor);
SimpleCopyTextureToTexture(dawnSrcTexture, dawnCopyDestTexture);
// Readback the destination texture and ensure it contains the colors we used
@@ -439,7 +448,7 @@
wgpu::Texture dawnTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
- WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnTexture, clearColor,
+ WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, clearColor,
&d3d11Texture, &dxgiKeyedMutex);
// Readback the destination texture and ensure it contains the colors we used
@@ -459,7 +468,7 @@
wgpu::Texture dawnTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
- WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnTexture, d3d11ClearColor,
+ WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, d3d11ClearColor,
&d3d11Texture, &dxgiKeyedMutex);
const wgpu::Color d3d12ClearColor{0.0f, 0.0f, 1.0f, 1.0f};
@@ -484,7 +493,7 @@
wgpu::Texture dawnTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
- WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnTexture, d3d11ClearColor,
+ WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, d3d11ClearColor,
&d3d11Texture, &dxgiKeyedMutex);
const wgpu::Color d3d12ClearColor1{0.0f, 0.0f, 1.0f, 1.0f};
@@ -511,7 +520,7 @@
wgpu::Texture dawnTexture;
ComPtr<ID3D11Texture2D> d3d11Texture;
ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex;
- WrapAndClearD3D11Texture(&dawnDescriptor, &d3dDescriptor, &dawnTexture, clearColor,
+ WrapAndClearD3D11Texture(&baseDawnDescriptor, &baseD3dDescriptor, &dawnTexture, clearColor,
&d3d11Texture, &dxgiKeyedMutex, false);
// Readback the destination texture and ensure it contains the colors we used
diff --git a/src/tests/perf_tests/DawnPerfTest.h b/src/tests/perf_tests/DawnPerfTest.h
index 64ef6dc..3e41ae0 100644
--- a/src/tests/perf_tests/DawnPerfTest.h
+++ b/src/tests/perf_tests/DawnPerfTest.h
@@ -28,7 +28,7 @@
class DawnPerfTestEnvironment : public DawnTestEnvironment {
public:
DawnPerfTestEnvironment(int argc, char** argv);
- ~DawnPerfTestEnvironment();
+ ~DawnPerfTestEnvironment() override;
void SetUp() override;
void TearDown() override;
diff --git a/src/tests/unittests/validation/ValidationTest.h b/src/tests/unittests/validation/ValidationTest.h
index 8994784..388606a 100644
--- a/src/tests/unittests/validation/ValidationTest.h
+++ b/src/tests/unittests/validation/ValidationTest.h
@@ -27,7 +27,7 @@
class ValidationTest : public testing::Test {
public:
ValidationTest();
- ~ValidationTest();
+ ~ValidationTest() override;
wgpu::Device CreateDeviceFromAdapter(dawn_native::Adapter adapter,
const std::vector<const char*>& requiredExtensions);
diff --git a/src/tests/unittests/wire/WireArgumentTests.cpp b/src/tests/unittests/wire/WireArgumentTests.cpp
index 1275bf4..dce4728 100644
--- a/src/tests/unittests/wire/WireArgumentTests.cpp
+++ b/src/tests/unittests/wire/WireArgumentTests.cpp
@@ -315,12 +315,12 @@
static constexpr int NUM_BINDINGS = 3;
WGPUBindGroupLayoutEntry bindings[NUM_BINDINGS]{
{0, WGPUShaderStage_Vertex, WGPUBindingType_Sampler, false, false,
- WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float},
+ WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float, WGPUTextureFormat_RGBA8Unorm},
{1, WGPUShaderStage_Vertex, WGPUBindingType_SampledTexture, false, false,
- WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float},
+ WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float, WGPUTextureFormat_RGBA8Unorm},
{2, static_cast<WGPUShaderStage>(WGPUShaderStage_Vertex | WGPUShaderStage_Fragment),
WGPUBindingType_UniformBuffer, false, false, WGPUTextureViewDimension_2D,
- WGPUTextureComponentType_Float},
+ WGPUTextureComponentType_Float, WGPUTextureFormat_RGBA8Unorm},
};
WGPUBindGroupLayoutDescriptor bglDescriptor = {};
bglDescriptor.bindingCount = NUM_BINDINGS;
diff --git a/src/tests/white_box/D3D12DescriptorHeapTests.cpp b/src/tests/white_box/D3D12DescriptorHeapTests.cpp
index eeb4412..665bddd 100644
--- a/src/tests/white_box/D3D12DescriptorHeapTests.cpp
+++ b/src/tests/white_box/D3D12DescriptorHeapTests.cpp
@@ -55,8 +55,7 @@
})");
}
- utils::BasicRenderPass MakeRenderPass(const wgpu::Device& device,
- uint32_t width,
+ utils::BasicRenderPass MakeRenderPass(uint32_t width,
uint32_t height,
wgpu::TextureFormat format) {
DAWN_ASSERT(width > 0 && height > 0);
@@ -291,7 +290,7 @@
dawn_native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting));
utils::BasicRenderPass renderPass =
- MakeRenderPass(device, kRTSize, kRTSize, wgpu::TextureFormat::R32Float);
+ MakeRenderPass(kRTSize, kRTSize, wgpu::TextureFormat::R32Float);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = mSimpleVSModule;
diff --git a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp
index 78f22cc..66de5f4 100644
--- a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp
+++ b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp
@@ -99,7 +99,7 @@
return gbmBo;
}
- wgpu::Texture WrapVulkanImage(wgpu::Device device,
+ wgpu::Texture WrapVulkanImage(wgpu::Device dawnDevice,
const wgpu::TextureDescriptor* textureDescriptor,
int memoryFd,
uint32_t stride,
@@ -117,7 +117,7 @@
descriptor.waitFDs = waitFDs;
WGPUTexture texture =
- dawn_native::vulkan::WrapVulkanImage(device.Get(), &descriptor);
+ dawn_native::vulkan::WrapVulkanImage(dawnDevice.Get(), &descriptor);
if (expectValid) {
EXPECT_NE(texture, nullptr) << "Failed to wrap image, are external memory / "
@@ -132,8 +132,8 @@
// Exports the signal from a wrapped texture and ignores it
// We have to export the signal before destroying the wrapped texture else it's an
// assertion failure
- void IgnoreSignalSemaphore(wgpu::Device device, wgpu::Texture wrappedTexture) {
- int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(device.Get(),
+ void IgnoreSignalSemaphore(wgpu::Device dawnDevice, wgpu::Texture wrappedTexture) {
+ int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(dawnDevice.Get(),
wrappedTexture.Get());
ASSERT_NE(fd, -1);
close(fd);
@@ -289,7 +289,9 @@
dawn_native::vulkan::Device* secondDeviceVk;
// Clear a texture on a given device
- void ClearImage(wgpu::Device device, wgpu::Texture wrappedTexture, wgpu::Color clearColor) {
+ void ClearImage(wgpu::Device dawnDevice,
+ wgpu::Texture wrappedTexture,
+ wgpu::Color clearColor) {
wgpu::TextureView wrappedView = wrappedTexture.CreateView();
// Submit a clear operation
@@ -297,19 +299,19 @@
renderPassDescriptor.cColorAttachments[0].clearColor = clearColor;
renderPassDescriptor.cColorAttachments[0].loadOp = wgpu::LoadOp::Clear;
- wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ wgpu::CommandEncoder encoder = dawnDevice.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDescriptor);
pass.EndPass();
wgpu::CommandBuffer commands = encoder.Finish();
- wgpu::Queue queue = device.CreateQueue();
+ wgpu::Queue queue = dawnDevice.CreateQueue();
queue.Submit(1, &commands);
}
// Submits a 1x1x1 copy from source to destination
- void SimpleCopyTextureToTexture(wgpu::Device device,
- wgpu::Queue queue,
+ void SimpleCopyTextureToTexture(wgpu::Device dawnDevice,
+ wgpu::Queue dawnQueue,
wgpu::Texture source,
wgpu::Texture destination) {
wgpu::TextureCopyView copySrc;
@@ -326,11 +328,11 @@
wgpu::Extent3D copySize = {1, 1, 1};
- wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ wgpu::CommandEncoder encoder = dawnDevice.CreateCommandEncoder();
encoder.CopyTextureToTexture(©Src, ©Dst, ©Size);
wgpu::CommandBuffer commands = encoder.Finish();
- queue.Submit(1, &commands);
+ dawnQueue.Submit(1, &commands);
}
};
diff --git a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp
index b376366..1e3bc75 100644
--- a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp
+++ b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp
@@ -152,7 +152,7 @@
}
// Wraps a vulkan image from external memory
- wgpu::Texture WrapVulkanImage(wgpu::Device device,
+ wgpu::Texture WrapVulkanImage(wgpu::Device dawnDevice,
const wgpu::TextureDescriptor* textureDescriptor,
int memoryFd,
VkDeviceSize allocationSize,
@@ -170,7 +170,7 @@
descriptor.waitFDs = waitFDs;
WGPUTexture texture =
- dawn_native::vulkan::WrapVulkanImage(device.Get(), &descriptor);
+ dawn_native::vulkan::WrapVulkanImage(dawnDevice.Get(), &descriptor);
if (expectValid) {
EXPECT_NE(texture, nullptr) << "Failed to wrap image, are external memory / "
@@ -185,8 +185,8 @@
// Exports the signal from a wrapped texture and ignores it
// We have to export the signal before destroying the wrapped texture else it's an
// assertion failure
- void IgnoreSignalSemaphore(wgpu::Device device, wgpu::Texture wrappedTexture) {
- int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(device.Get(),
+ void IgnoreSignalSemaphore(wgpu::Device dawnDevice, wgpu::Texture wrappedTexture) {
+ int fd = dawn_native::vulkan::ExportSignalSemaphoreOpaqueFD(dawnDevice.Get(),
wrappedTexture.Get());
ASSERT_NE(fd, -1);
close(fd);
@@ -407,26 +407,28 @@
int defaultFd;
// Clear a texture on a given device
- void ClearImage(wgpu::Device device, wgpu::Texture wrappedTexture, wgpu::Color clearColor) {
+ void ClearImage(wgpu::Device dawnDevice,
+ wgpu::Texture wrappedTexture,
+ wgpu::Color clearColor) {
wgpu::TextureView wrappedView = wrappedTexture.CreateView();
// Submit a clear operation
utils::ComboRenderPassDescriptor renderPassDescriptor({wrappedView}, {});
renderPassDescriptor.cColorAttachments[0].clearColor = clearColor;
- wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ wgpu::CommandEncoder encoder = dawnDevice.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDescriptor);
pass.EndPass();
wgpu::CommandBuffer commands = encoder.Finish();
- wgpu::Queue queue = device.CreateQueue();
+ wgpu::Queue queue = dawnDevice.CreateQueue();
queue.Submit(1, &commands);
}
// Submits a 1x1x1 copy from source to destination
- void SimpleCopyTextureToTexture(wgpu::Device device,
- wgpu::Queue queue,
+ void SimpleCopyTextureToTexture(wgpu::Device dawnDevice,
+ wgpu::Queue dawnQueue,
wgpu::Texture source,
wgpu::Texture destination) {
wgpu::TextureCopyView copySrc;
@@ -443,11 +445,11 @@
wgpu::Extent3D copySize = {1, 1, 1};
- wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+ wgpu::CommandEncoder encoder = dawnDevice.CreateCommandEncoder();
encoder.CopyTextureToTexture(©Src, ©Dst, ©Size);
wgpu::CommandBuffer commands = encoder.Finish();
- queue.Submit(1, &commands);
+ dawnQueue.Submit(1, &commands);
}
};