From 7119a0278da3ae1044a0dcaaf979a2b5294a10ee Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Wed, 8 Apr 2020 16:04:32 +0000 Subject: [PATCH] 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 Reviewed-by: Austin Eng --- src/common/BUILD.gn | 11 ++ src/dawn_native/RenderBundleEncoder.cpp | 18 +-- src/dawn_native/RenderBundleEncoder.h | 2 +- src/dawn_native/Toggles.cpp | 15 ++- src/dawn_native/d3d12/AdapterD3D12.h | 4 +- src/dawn_native/d3d12/DeviceD3D12.h | 2 +- src/dawn_native/d3d12/StagingBufferD3D12.h | 2 +- src/dawn_native/metal/DeviceMTL.h | 2 +- src/dawn_native/metal/ShaderModuleMTL.mm | 6 +- src/dawn_native/metal/StagingBufferMTL.h | 2 +- src/dawn_native/null/DeviceNull.h | 4 +- src/dawn_native/opengl/DeviceGL.h | 2 +- src/dawn_native/vulkan/AdapterVk.h | 2 +- src/dawn_native/vulkan/DeviceVk.h | 2 +- src/dawn_native/vulkan/StagingBufferVk.h | 2 +- src/dawn_native/vulkan/VulkanBackend.cpp | 4 +- src/dawn_wire/client/Device.cpp | 4 +- src/include/dawn_wire/WireClient.h | 2 +- src/include/dawn_wire/WireServer.h | 2 +- src/tests/DawnTest.h | 2 +- src/tests/end2end/BindGroupTests.cpp | 3 +- .../end2end/D3D12ResourceWrappingTests.cpp | 111 ++++++++++-------- src/tests/perf_tests/DawnPerfTest.h | 2 +- .../unittests/validation/ValidationTest.h | 2 +- .../unittests/wire/WireArgumentTests.cpp | 6 +- .../white_box/D3D12DescriptorHeapTests.cpp | 5 +- .../VulkanImageWrappingTestsDmaBuf.cpp | 24 ++-- .../VulkanImageWrappingTestsOpaqueFD.cpp | 24 ++-- 28 files changed, 148 insertions(+), 119 deletions(-) diff --git a/src/common/BUILD.gn b/src/common/BUILD.gn index 321fa3097d..15954bcdb4 100644 --- a/src/common/BUILD.gn +++ b/src/common/BUILD.gn @@ -86,6 +86,17 @@ config("dawn_internal") { # 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 956fa8b3a2..49700429f3 100644 --- a/src/dawn_native/RenderBundleEncoder.cpp +++ b/src/dawn_native/RenderBundleEncoder.cpp @@ -79,13 +79,14 @@ namespace dawn_native { 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 @@ namespace dawn_native { } 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 0581719f1d..e6354ab042 100644 --- a/src/dawn_native/RenderBundleEncoder.h +++ b/src/dawn_native/RenderBundleEncoder.h @@ -44,7 +44,7 @@ namespace dawn_native { MaybeError ValidateFinish(CommandIterator* commands, const PassResourceUsage& usages) const; - EncodingContext mEncodingContext; + EncodingContext mBundleEncodingContext; Ref mAttachmentState; }; } // namespace dawn_native diff --git a/src/dawn_native/Toggles.cpp b/src/dawn_native/Toggles.cpp index 8c3a130b07..eb6ecd7bf7 100644 --- a/src/dawn_native/Toggles.cpp +++ b/src/dawn_native/Toggles.cpp @@ -88,7 +88,8 @@ namespace dawn_native { "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 @@ namespace dawn_native { {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 6c2d4f149f..48345c1100 100644 --- a/src/dawn_native/d3d12/AdapterD3D12.h +++ b/src/dawn_native/d3d12/AdapterD3D12.h @@ -27,7 +27,7 @@ namespace dawn_native { namespace d3d12 { class Adapter : public AdapterBase { public: Adapter(Backend* backend, ComPtr hardwareAdapter); - virtual ~Adapter() = default; + ~Adapter() override = default; const D3D12DeviceInfo& GetDeviceInfo() const; IDXGIAdapter3* GetHardwareAdapter() const; @@ -49,4 +49,4 @@ namespace dawn_native { namespace d3d12 { }} // 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 8f135fd853..406ce3960d 100644 --- a/src/dawn_native/d3d12/DeviceD3D12.h +++ b/src/dawn_native/d3d12/DeviceD3D12.h @@ -46,7 +46,7 @@ namespace dawn_native { namespace d3d12 { class Device : public DeviceBase { public: static ResultOrError 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 5bc32a26e2..291400d996 100644 --- a/src/dawn_native/d3d12/StagingBufferD3D12.h +++ b/src/dawn_native/d3d12/StagingBufferD3D12.h @@ -27,7 +27,7 @@ namespace dawn_native { namespace d3d12 { 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 cc23f7a0e1..72aa55bd77 100644 --- a/src/dawn_native/metal/DeviceMTL.h +++ b/src/dawn_native/metal/DeviceMTL.h @@ -39,7 +39,7 @@ namespace dawn_native { namespace metal { static ResultOrError Create(AdapterBase* adapter, id 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 7d573fb200..a06adccbbb 100644 --- a/src/dawn_native/metal/ShaderModuleMTL.mm +++ b/src/dawn_native/metal/ShaderModuleMTL.mm @@ -190,10 +190,10 @@ namespace dawn_native { namespace metal { 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 @@ namespace dawn_native { namespace metal { 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 e2d1ecc100..7e9815b491 100644 --- a/src/dawn_native/metal/StagingBufferMTL.h +++ b/src/dawn_native/metal/StagingBufferMTL.h @@ -26,7 +26,7 @@ namespace dawn_native { namespace metal { class StagingBuffer : public StagingBufferBase { public: StagingBuffer(size_t size, Device* device); - ~StagingBuffer(); + ~StagingBuffer() override; id GetBufferHandle() const; diff --git a/src/dawn_native/null/DeviceNull.h b/src/dawn_native/null/DeviceNull.h index 8d85e8a32d..c14ffffa89 100644 --- a/src/dawn_native/null/DeviceNull.h +++ b/src/dawn_native/null/DeviceNull.h @@ -84,7 +84,7 @@ namespace dawn_native { namespace null { class Device : public DeviceBase { public: static ResultOrError Create(Adapter* adapter, const DeviceDescriptor* descriptor); - ~Device(); + ~Device() override; MaybeError Initialize(); @@ -152,7 +152,7 @@ namespace dawn_native { namespace null { 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& requiredExtensions); diff --git a/src/dawn_native/opengl/DeviceGL.h b/src/dawn_native/opengl/DeviceGL.h index e18d046da3..f2749932e1 100644 --- a/src/dawn_native/opengl/DeviceGL.h +++ b/src/dawn_native/opengl/DeviceGL.h @@ -37,7 +37,7 @@ namespace dawn_native { namespace opengl { static ResultOrError 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 a4a3d53b61..67f77d9c7a 100644 --- a/src/dawn_native/vulkan/AdapterVk.h +++ b/src/dawn_native/vulkan/AdapterVk.h @@ -27,7 +27,7 @@ namespace dawn_native { namespace vulkan { 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 66d50e7e74..40c0e3de27 100644 --- a/src/dawn_native/vulkan/DeviceVk.h +++ b/src/dawn_native/vulkan/DeviceVk.h @@ -44,7 +44,7 @@ namespace dawn_native { namespace vulkan { class Device : public DeviceBase { public: static ResultOrError 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 1106a2723d..50b773a0da 100644 --- a/src/dawn_native/vulkan/StagingBufferVk.h +++ b/src/dawn_native/vulkan/StagingBufferVk.h @@ -26,7 +26,7 @@ namespace dawn_native { namespace vulkan { 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 f24d8ca75f..c1458a00fc 100644 --- a/src/dawn_native/vulkan/VulkanBackend.cpp +++ b/src/dawn_native/vulkan/VulkanBackend.cpp @@ -60,8 +60,8 @@ namespace dawn_native { namespace vulkan { } #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 175617fa96..7d62b06e98 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 3b9d8725cf..7c8ee408c6 100644 --- a/src/include/dawn_wire/WireClient.h +++ b/src/include/dawn_wire/WireClient.h @@ -42,7 +42,7 @@ namespace dawn_wire { 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 f965a0469f..b59572180a 100644 --- a/src/include/dawn_wire/WireServer.h +++ b/src/include/dawn_wire/WireServer.h @@ -38,7 +38,7 @@ namespace dawn_wire { 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 13bf44fd28..7cbe5398a7 100644 --- a/src/tests/DawnTest.h +++ b/src/tests/DawnTest.h @@ -132,7 +132,7 @@ void InitDawnEnd2EndTestEnvironment(int argc, char** argv); 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 ee8eb052f7..762d4318a9 100644 --- a/src/tests/end2end/BindGroupTests.cpp +++ b/src/tests/end2end/BindGroupTests.cpp @@ -35,7 +35,6 @@ protected: } wgpu::PipelineLayout MakeBasicPipelineLayout( - wgpu::Device device, std::vector bindingInitializer) const { wgpu::PipelineLayoutDescriptor descriptor; @@ -103,7 +102,7 @@ protected: 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 745edb7de8..a07e5ab29a 100644 --- a/src/tests/end2end/D3D12ResourceWrappingTests.cpp +++ b/src/tests/end2end/D3D12ResourceWrappingTests.cpp @@ -59,37 +59,37 @@ namespace { 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 d3d11Texture; - HRESULT hr = mD3d11Device->CreateTexture2D(d3dDescriptor, nullptr, &d3d11Texture); + HRESULT hr = mD3d11Device->CreateTexture2D(baseD3dDescriptor, nullptr, &d3d11Texture); ASSERT_EQ(hr, S_OK); ComPtr dxgiResource; @@ -104,7 +104,7 @@ namespace { dawn_native::d3d12::ExternalImageDescriptorDXGISharedHandle externDesc; externDesc.cTextureDescriptor = - reinterpret_cast(dawnDescriptor); + reinterpret_cast(dawnDesc); externDesc.sharedHandle = sharedHandle; externDesc.acquireMutexKey = 0; WGPUTexture texture = dawn_native::d3d12::WrapSharedHandle(device.Get(), &externDesc); @@ -123,8 +123,8 @@ namespace { ComPtr mD3d11Device; ComPtr mD3d11DeviceContext; - D3D11_TEXTURE2D_DESC d3dDescriptor; - wgpu::TextureDescriptor dawnDescriptor; + D3D11_TEXTURE2D_DESC baseD3dDescriptor; + wgpu::TextureDescriptor baseDawnDescriptor; }; } // anonymous namespace @@ -140,7 +140,7 @@ TEST_P(D3D12SharedHandleValidation, Success) { wgpu::Texture texture; ComPtr d3d11Texture; - WrapSharedHandle(&dawnDescriptor, &d3dDescriptor, &texture, &d3d11Texture); + WrapSharedHandle(&baseDawnDescriptor, &baseD3dDescriptor, &texture, &d3d11Texture); ASSERT_NE(texture.Get(), nullptr); } @@ -150,11 +150,12 @@ TEST_P(D3D12SharedHandleValidation, InvalidTextureDescriptor) { DAWN_SKIP_TEST_IF(UsesWire()); wgpu::ChainedStruct chainedDescriptor; - dawnDescriptor.nextInChain = &chainedDescriptor; + baseDawnDescriptor.nextInChain = &chainedDescriptor; wgpu::Texture texture; ComPtr 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_P(D3D12SharedHandleValidation, InvalidTextureDescriptor) { // 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 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_P(D3D12SharedHandleValidation, InvalidMipLevelCount) { // 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 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_P(D3D12SharedHandleValidation, InvalidArrayLayerCount) { // 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 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_P(D3D12SharedHandleValidation, InvalidSampleCount) { // 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 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_P(D3D12SharedHandleValidation, InvalidWidth) { // 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 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_P(D3D12SharedHandleValidation, InvalidHeight) { // 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 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_P(D3D12SharedHandleValidation, InvalidFormat) { // 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 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_P(D3D12SharedHandleValidation, InvalidNumD3DMipLevels) { // 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 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 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11CopyAndReadbackInD3D12) { wgpu::Texture dawnSrcTexture; ComPtr d3d11Texture; ComPtr 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 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D11ReadbackInD3D12) { wgpu::Texture dawnTexture; ComPtr d3d11Texture; ComPtr 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 @@ TEST_P(D3D12SharedHandleUsageTests, ClearInD3D12ReadbackInD3D11) { wgpu::Texture dawnTexture; ComPtr d3d11Texture; ComPtr 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 @@ TEST_P(D3D12SharedHandleUsageTests, ClearTwiceInD3D12ReadbackInD3D11) { wgpu::Texture dawnTexture; ComPtr d3d11Texture; ComPtr 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 @@ TEST_P(D3D12SharedHandleUsageTests, UnclearedTextureIsCleared) { wgpu::Texture dawnTexture; ComPtr d3d11Texture; ComPtr 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 64ef6dc647..3e41ae0b26 100644 --- a/src/tests/perf_tests/DawnPerfTest.h +++ b/src/tests/perf_tests/DawnPerfTest.h @@ -28,7 +28,7 @@ void InitDawnPerfTestEnvironment(int argc, char** argv); 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 8994784546..388606a2d9 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& requiredExtensions); diff --git a/src/tests/unittests/wire/WireArgumentTests.cpp b/src/tests/unittests/wire/WireArgumentTests.cpp index 1275bf4698..dce472808f 100644 --- a/src/tests/unittests/wire/WireArgumentTests.cpp +++ b/src/tests/unittests/wire/WireArgumentTests.cpp @@ -315,12 +315,12 @@ TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) { 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_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 eeb4412326..665bddd3fb 100644 --- a/src/tests/white_box/D3D12DescriptorHeapTests.cpp +++ b/src/tests/white_box/D3D12DescriptorHeapTests.cpp @@ -55,8 +55,7 @@ class D3D12DescriptorHeapTests : public DawnTest { })"); } - 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 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) { 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 78f22cc136..66de5f4382 100644 --- a/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp +++ b/src/tests/white_box/VulkanImageWrappingTestsDmaBuf.cpp @@ -99,7 +99,7 @@ namespace dawn_native { namespace vulkan { 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 @@ namespace dawn_native { namespace vulkan { 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 @@ namespace dawn_native { namespace vulkan { // 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 @@ namespace dawn_native { namespace vulkan { 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 @@ namespace dawn_native { namespace vulkan { 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 @@ namespace dawn_native { namespace vulkan { 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 b376366bf6..1e3bc75310 100644 --- a/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp +++ b/src/tests/white_box/VulkanImageWrappingTestsOpaqueFD.cpp @@ -152,7 +152,7 @@ namespace dawn_native { namespace vulkan { } // 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 @@ namespace dawn_native { namespace vulkan { 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 @@ namespace dawn_native { namespace vulkan { // 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 @@ namespace dawn_native { namespace vulkan { 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 @@ namespace dawn_native { namespace vulkan { 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); } };