Fix more compilation warnings.
Bug: chromium:1064305 Change-Id: I3aac24f8179d2c9e5206dd4542ea2506f26755e9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19301 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Zhenyao Mo <zmo@google.com>
This commit is contained in:
parent
8619cbe237
commit
5b7292c8f8
|
@ -414,12 +414,12 @@ namespace dawn_wire {
|
|||
|
||||
// Macro to simplify error handling, similar to DAWN_TRY but for DeserializeResult.
|
||||
#define DESERIALIZE_TRY(EXPR) \
|
||||
{ \
|
||||
do { \
|
||||
DeserializeResult exprResult = EXPR; \
|
||||
if (exprResult != DeserializeResult::Success) { \
|
||||
return exprResult; \
|
||||
} \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
ObjectHandle::ObjectHandle() = default;
|
||||
ObjectHandle::ObjectHandle(ObjectId id, ObjectSerial serial) : id(id), serial(serial) {}
|
||||
|
|
|
@ -95,6 +95,12 @@ config("dawn_internal") {
|
|||
"-Wshadow-field",
|
||||
"-Wmissing-field-initializers",
|
||||
"-Wcstring-format-directive",
|
||||
"-Wtautological-unsigned-zero-compare",
|
||||
"-Wreturn-std-move-in-c++11",
|
||||
|
||||
# Turn on the following flag after removing the empty statement in
|
||||
# third_party/glm/glm/simd/common.h:106
|
||||
# "-Wextra-semi-stmt",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -143,13 +149,9 @@ if (is_win || is_linux || is_mac || is_fuchsia || is_android) {
|
|||
]
|
||||
|
||||
public_configs = [ ":dawn_internal" ]
|
||||
deps = [
|
||||
"${dawn_root}/src/dawn:dawn_headers",
|
||||
]
|
||||
deps = [ "${dawn_root}/src/dawn:dawn_headers" ]
|
||||
if (dawn_enable_vulkan) {
|
||||
public_deps = [
|
||||
"${dawn_root}/third_party/khronos:vulkan_headers",
|
||||
]
|
||||
public_deps = [ "${dawn_root}/third_party/khronos:vulkan_headers" ]
|
||||
}
|
||||
if (is_android) {
|
||||
libs = [ "log" ]
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace dawn_native {
|
|||
ResourceMemoryAllocation invalidAllocation = ResourceMemoryAllocation{};
|
||||
|
||||
if (allocationSize == 0) {
|
||||
return invalidAllocation;
|
||||
return std::move(invalidAllocation);
|
||||
}
|
||||
|
||||
// Round allocation size to nearest power-of-two.
|
||||
|
@ -50,13 +50,13 @@ namespace dawn_native {
|
|||
|
||||
// Allocation cannot exceed the memory size.
|
||||
if (allocationSize > mMemoryBlockSize) {
|
||||
return invalidAllocation;
|
||||
return std::move(invalidAllocation);
|
||||
}
|
||||
|
||||
// Attempt to sub-allocate a block of the requested size.
|
||||
const uint64_t blockOffset = mBuddyBlockAllocator.Allocate(allocationSize, alignment);
|
||||
if (blockOffset == BuddyAllocator::kInvalidOffset) {
|
||||
return invalidAllocation;
|
||||
return std::move(invalidAllocation);
|
||||
}
|
||||
|
||||
const uint64_t memoryIndex = GetMemoryIndex(blockOffset);
|
||||
|
|
|
@ -700,7 +700,7 @@ namespace dawn_native {
|
|||
SpirvCrossBaseTypeToFormatType(shaderFragmentOutputBaseType);
|
||||
if (formatType == Format::Type::Other) {
|
||||
return DAWN_VALIDATION_ERROR("Unexpected Fragment output type");
|
||||
};
|
||||
}
|
||||
mFragmentOutputFormatBaseTypes[location] = formatType;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
}
|
||||
|
||||
ASSERT(factory != nullptr);
|
||||
return factory;
|
||||
return std::move(factory);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
|
|
@ -395,7 +395,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
DAWN_TRY(CheckHRESULT(d3d11Texture.As(&dxgiKeyedMutex),
|
||||
"D3D12 QueryInterface ID3D11Texture2D to IDXGIKeyedMutex"));
|
||||
|
||||
return dxgiKeyedMutex;
|
||||
return std::move(dxgiKeyedMutex);
|
||||
}
|
||||
|
||||
void Device::ReleaseKeyedMutexForTexture(ComPtr<IDXGIKeyedMutex> dxgiKeyedMutex) {
|
||||
|
|
|
@ -39,10 +39,10 @@ namespace dawn_native { namespace d3d12 {
|
|||
class StagingDescriptorAllocator;
|
||||
|
||||
#define ASSERT_SUCCESS(hr) \
|
||||
{ \
|
||||
do { \
|
||||
HRESULT succeeded = hr; \
|
||||
ASSERT(SUCCEEDED(succeeded)); \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
// Definition of backend types
|
||||
class Device : public DeviceBase {
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
// Calling CreateHeap implicitly calls MakeResident on the new heap. We must track this to
|
||||
// avoid calling MakeResident a second time.
|
||||
mDevice->GetResidencyManager()->TrackResidentAllocation(ToBackend(heapBase.get()));
|
||||
return heapBase;
|
||||
return std::move(heapBase);
|
||||
}
|
||||
|
||||
void HeapAllocator::DeallocateResourceHeap(std::unique_ptr<ResourceHeapBase> heap) {
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
DAWN_TRY_ASSIGN(subAllocation,
|
||||
CreatePlacedResource(heapType, resourceDescriptor, initialUsage));
|
||||
if (subAllocation.GetInfo().mMethod != AllocationMethod::kInvalid) {
|
||||
return subAllocation;
|
||||
return std::move(subAllocation);
|
||||
}
|
||||
|
||||
// If sub-allocation fails, fall-back to direct allocation (committed resource).
|
||||
|
@ -170,7 +170,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
DAWN_TRY_ASSIGN(directAllocation,
|
||||
CreateCommittedResource(heapType, resourceDescriptor, initialUsage));
|
||||
|
||||
return directAllocation;
|
||||
return std::move(directAllocation);
|
||||
}
|
||||
|
||||
void ResourceAllocatorManager::Tick(Serial completedSerial) {
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
std::string result_string;
|
||||
DAWN_TRY(CheckSpvcSuccess(result.GetStringOutput(&result_string),
|
||||
"Unable to get HLSL shader text"));
|
||||
return result_string;
|
||||
return std::move(result_string);
|
||||
} else {
|
||||
return compiler->compile();
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ namespace dawn_native { namespace metal {
|
|||
if (!instance->ConsumedError(GetDevicePCIInfo(device, &ids))) {
|
||||
mPCIInfo.vendorId = ids.vendorId;
|
||||
mPCIInfo.deviceId = ids.deviceId;
|
||||
};
|
||||
}
|
||||
|
||||
#if defined(DAWN_PLATFORM_IOS)
|
||||
mAdapterType = wgpu::AdapterType::IntegratedGPU;
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace dawn_native { namespace vulkan {
|
|||
DAWN_TRY_ASSIGN(subAllocation,
|
||||
mAllocatorsPerType[memoryType]->AllocateMemory(requirements));
|
||||
if (subAllocation.GetInfo().mMethod != AllocationMethod::kInvalid) {
|
||||
return subAllocation;
|
||||
return std::move(subAllocation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,12 @@
|
|||
namespace dawn_native { namespace vulkan {
|
||||
|
||||
#define GET_GLOBAL_PROC(name) \
|
||||
do { \
|
||||
name = reinterpret_cast<decltype(name)>(GetInstanceProcAddr(nullptr, "vk" #name)); \
|
||||
if (name == nullptr) { \
|
||||
return DAWN_INTERNAL_ERROR(std::string("Couldn't get proc vk") + #name); \
|
||||
}
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
MaybeError VulkanFunctions::LoadGlobalProcs(const DynamicLib& vulkanLib) {
|
||||
if (!vulkanLib.GetProc(&GetInstanceProcAddr, "vkGetInstanceProcAddr")) {
|
||||
|
@ -42,10 +44,12 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
|
||||
#define GET_INSTANCE_PROC_BASE(name, procName) \
|
||||
do { \
|
||||
name = reinterpret_cast<decltype(name)>(GetInstanceProcAddr(instance, "vk" #procName)); \
|
||||
if (name == nullptr) { \
|
||||
return DAWN_INTERNAL_ERROR(std::string("Couldn't get proc vk") + #procName); \
|
||||
}
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define GET_INSTANCE_PROC(name) GET_INSTANCE_PROC_BASE(name, name)
|
||||
#define GET_INSTANCE_PROC_VENDOR(name, vendor) GET_INSTANCE_PROC_BASE(name, name##vendor)
|
||||
|
@ -145,10 +149,12 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
|
||||
#define GET_DEVICE_PROC(name) \
|
||||
do { \
|
||||
name = reinterpret_cast<decltype(name)>(GetDeviceProcAddr(device, "vk" #name)); \
|
||||
if (name == nullptr) { \
|
||||
return DAWN_INTERNAL_ERROR(std::string("Couldn't get proc vk") + #name); \
|
||||
}
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
MaybeError VulkanFunctions::LoadDeviceProcs(VkDevice device,
|
||||
const VulkanDeviceInfo& deviceInfo) {
|
||||
|
|
|
@ -196,7 +196,7 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
// TODO(cwallez@chromium:org): Each layer can expose additional extensions, query them?
|
||||
|
||||
return info;
|
||||
return std::move(info);
|
||||
}
|
||||
|
||||
ResultOrError<std::vector<VkPhysicalDevice>> GetPhysicalDevices(const Backend& backend) {
|
||||
|
@ -215,7 +215,7 @@ namespace dawn_native { namespace vulkan {
|
|||
vkFunctions.EnumeratePhysicalDevices(instance, &count, physicalDevices.data()),
|
||||
"vkEnumeratePhysicalDevices"));
|
||||
|
||||
return physicalDevices;
|
||||
return std::move(physicalDevices);
|
||||
}
|
||||
|
||||
ResultOrError<VulkanDeviceInfo> GatherDeviceInfo(const Adapter& adapter) {
|
||||
|
@ -321,7 +321,7 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
// TODO(cwallez@chromium.org): gather info about formats
|
||||
|
||||
return info;
|
||||
return std::move(info);
|
||||
}
|
||||
|
||||
ResultOrError<VulkanSurfaceInfo> GatherSurfaceInfo(const Adapter& adapter,
|
||||
|
@ -382,7 +382,7 @@ namespace dawn_native { namespace vulkan {
|
|||
"vkGetPhysicalDeviceSurfacePresentModesKHR"));
|
||||
}
|
||||
|
||||
return info;
|
||||
return std::move(info);
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::vulkan
|
||||
|
|
|
@ -689,13 +689,15 @@
|
|||
#define INTERNAL_TRACE_EVENT_ADD_SCOPED(platform, category, name, ...) \
|
||||
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, ::dawn_platform::TraceCategory::category) \
|
||||
dawn_platform::TraceEvent::TraceEndOnScopeClose INTERNALTRACEEVENTUID(profileScope); \
|
||||
do { \
|
||||
if (*INTERNALTRACEEVENTUID(catstatic)) { \
|
||||
dawn_platform::TraceEvent::addTraceEvent( \
|
||||
platform, TRACE_EVENT_PHASE_BEGIN, INTERNALTRACEEVENTUID(catstatic), name, \
|
||||
dawn_platform::TraceEvent::noEventId, TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \
|
||||
INTERNALTRACEEVENTUID(profileScope) \
|
||||
.initialize(platform, INTERNALTRACEEVENTUID(catstatic), name); \
|
||||
}
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Implementation detail: internal macro to create static category and add
|
||||
// event if the category is enabled.
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
StartExpectDeviceError(); \
|
||||
statement; \
|
||||
FlushWire(); \
|
||||
ASSERT_TRUE(EndExpectDeviceError());
|
||||
ASSERT_TRUE(EndExpectDeviceError())
|
||||
|
||||
struct RGBA8 {
|
||||
constexpr RGBA8() : RGBA8(0, 0, 0, 0) {
|
||||
|
@ -315,11 +315,13 @@ class DawnTestBase {
|
|||
|
||||
// Skip a test when the given condition is satisfied.
|
||||
#define DAWN_SKIP_TEST_IF(condition) \
|
||||
do { \
|
||||
if (condition) { \
|
||||
dawn::InfoLog() << "Test skipped: " #condition "."; \
|
||||
GTEST_SKIP(); \
|
||||
return; \
|
||||
}
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
template <typename Params = DawnTestParam>
|
||||
class DawnTestWithParams : public DawnTestBase, public ::testing::TestWithParam<Params> {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
#define EXPECT_LAZY_CLEAR(N, statement) \
|
||||
do { \
|
||||
if (UsesWire()) { \
|
||||
statement; \
|
||||
} else { \
|
||||
|
@ -26,7 +27,8 @@
|
|||
statement; \
|
||||
size_t lazyClearsAfter = dawn_native::GetLazyClearCountForTesting(device.Get()); \
|
||||
EXPECT_EQ(N, lazyClearsAfter - lazyClearsBefore); \
|
||||
}
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
class TextureZeroInitTest : public DawnTest {
|
||||
protected:
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define ASSERT_DEVICE_ERROR(statement) \
|
||||
StartExpectDeviceError(); \
|
||||
statement; \
|
||||
ASSERT_TRUE(EndExpectDeviceError());
|
||||
ASSERT_TRUE(EndExpectDeviceError())
|
||||
|
||||
class ValidationTest : public testing::Test {
|
||||
public:
|
||||
|
|
|
@ -194,7 +194,7 @@ TEST_P(D3D12ResidencyTests, OvercommitLargeResources) {
|
|||
TEST_P(D3D12ResidencyTests, AsyncMappedBufferRead) {
|
||||
// Dawn currently only manages LOCAL_MEMORY. Mappable buffers exist in NON_LOCAL_MEMORY on
|
||||
// discrete devices.
|
||||
DAWN_SKIP_TEST_IF(!IsUMA())
|
||||
DAWN_SKIP_TEST_IF(!IsUMA());
|
||||
|
||||
// Create a mappable buffer.
|
||||
wgpu::Buffer buffer = CreateBuffer(4, wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopyDst);
|
||||
|
@ -239,7 +239,7 @@ TEST_P(D3D12ResidencyTests, AsyncMappedBufferRead) {
|
|||
TEST_P(D3D12ResidencyTests, AsyncMappedBufferWrite) {
|
||||
// Dawn currently only manages LOCAL_MEMORY. Mappable buffers exist in NON_LOCAL_MEMORY on
|
||||
// discrete devices.
|
||||
DAWN_SKIP_TEST_IF(!IsUMA())
|
||||
DAWN_SKIP_TEST_IF(!IsUMA());
|
||||
|
||||
// Create a mappable buffer.
|
||||
wgpu::Buffer buffer = CreateBuffer(4, wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc);
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace utils {
|
|||
std::make_unique<wgpu::SurfaceDescriptorFromWindowsHWND>();
|
||||
desc->hwnd = glfwGetWin32Window(window);
|
||||
desc->hinstance = GetModuleHandle(nullptr);
|
||||
return desc;
|
||||
return std::move(desc);
|
||||
}
|
||||
#elif defined(DAWN_USE_X11)
|
||||
std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptorForTesting(
|
||||
|
@ -70,7 +70,7 @@ namespace utils {
|
|||
std::make_unique<wgpu::SurfaceDescriptorFromXlib>();
|
||||
desc->display = glfwGetX11Display();
|
||||
desc->window = glfwGetX11Window(window);
|
||||
return desc;
|
||||
return std::move(desc);
|
||||
}
|
||||
#elif defined(DAWN_ENABLE_BACKEND_METAL)
|
||||
// SetupWindowAndGetSurfaceDescriptorForTesting defined in GLFWUtils_metal.mm
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace utils {
|
|||
std::unique_ptr<wgpu::SurfaceDescriptorFromMetalLayer> desc =
|
||||
std::make_unique<wgpu::SurfaceDescriptorFromMetalLayer>();
|
||||
desc->layer = [view layer];
|
||||
return desc;
|
||||
return std::move(desc);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
Loading…
Reference in New Issue