Skip to content

Commit 8b5cf96

Browse files
jorgep31415facebook-github-bot
authored andcommitted
Fix VK_NULL_HANDLE comparison style (#5733)
Summary: Pull Request resolved: #5733 `VK_NULL_HANDLE` is a constant and should hence be the right hand side of the expression. Fixing the expressions where it's on the left hand side. ghstack-source-id: 245169615 exported-using-ghexport Reviewed By: nathanaelsee Differential Revision: D63560116 fbshipit-source-id: a0b03202245988c7c072002c26e430f80436992b
1 parent b4a6148 commit 8b5cf96

File tree

14 files changed

+22
-22
lines changed

14 files changed

+22
-22
lines changed

backends/vulkan/runtime/vk_api/Command.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ CommandPool::CommandPool(
247247
}
248248

249249
CommandPool::~CommandPool() {
250-
if (VK_NULL_HANDLE == pool_) {
250+
if (pool_ == VK_NULL_HANDLE) {
251251
return;
252252
}
253253
vkDestroyCommandPool(device_, pool_, nullptr);

backends/vulkan/runtime/vk_api/Command.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CommandBuffer final {
9999
VkCommandBuffer get_submit_handle(const bool final_use = false);
100100

101101
inline operator bool() const {
102-
return VK_NULL_HANDLE != handle_;
102+
return handle_ != VK_NULL_HANDLE;
103103
}
104104
};
105105

backends/vulkan/runtime/vk_api/Descriptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ DescriptorPool::DescriptorPool(
261261
}
262262

263263
DescriptorPool::~DescriptorPool() {
264-
if (VK_NULL_HANDLE == pool_) {
264+
if (pool_ == VK_NULL_HANDLE) {
265265
return;
266266
}
267267
vkDestroyDescriptorPool(device_, pool_, nullptr);

backends/vulkan/runtime/vk_api/Device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
8484
DeviceHandle::DeviceHandle(VkDevice device) : handle(device) {}
8585

8686
DeviceHandle::~DeviceHandle() {
87-
if (VK_NULL_HANDLE == handle) {
87+
if (handle == VK_NULL_HANDLE) {
8888
return;
8989
}
9090
vkDestroyDevice(handle, nullptr);

backends/vulkan/runtime/vk_api/Fence.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ VulkanFence& VulkanFence::operator=(VulkanFence&& other) noexcept {
4444
}
4545

4646
VulkanFence::~VulkanFence() {
47-
if (VK_NULL_HANDLE == handle_) {
47+
if (handle_ == VK_NULL_HANDLE) {
4848
return;
4949
}
5050
vkDestroyFence(device_, handle_, nullptr);

backends/vulkan/runtime/vk_api/Fence.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class VulkanFence final {
6262
}
6363

6464
operator bool() const {
65-
return (VK_NULL_HANDLE != handle_);
65+
return (handle_ != VK_NULL_HANDLE);
6666
}
6767
};
6868

backends/vulkan/runtime/vk_api/Pipeline.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ PipelineLayout::PipelineLayout(PipelineLayout&& other) noexcept
228228
}
229229

230230
PipelineLayout::~PipelineLayout() {
231-
if (VK_NULL_HANDLE == handle_) {
231+
if (handle_ == VK_NULL_HANDLE) {
232232
return;
233233
}
234234
vkDestroyPipelineLayout(device_, handle_, nullptr);
@@ -300,7 +300,7 @@ ComputePipeline::ComputePipeline(ComputePipeline&& other) noexcept
300300
}
301301

302302
ComputePipeline::~ComputePipeline() {
303-
if (VK_NULL_HANDLE == handle_) {
303+
if (handle_ == VK_NULL_HANDLE) {
304304
return;
305305
}
306306
vkDestroyPipeline(device_, handle_, nullptr);
@@ -402,7 +402,7 @@ ComputePipelineCache::ComputePipelineCache(
402402
ComputePipelineCache::~ComputePipelineCache() {
403403
purge();
404404

405-
if (VK_NULL_HANDLE == pipeline_cache_) {
405+
if (pipeline_cache_ == VK_NULL_HANDLE) {
406406
return;
407407
}
408408

backends/vulkan/runtime/vk_api/QueryPool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ constexpr int64_t kDefaultNsPerTick = 52; // lround(52.08f);
3030
} // namespace
3131

3232
#define EARLY_RETURN_IF_UNINITIALIZED() \
33-
if (VK_NULL_HANDLE == querypool_) { \
33+
if (querypool_ == VK_NULL_HANDLE) { \
3434
return; \
3535
}
3636

@@ -178,7 +178,7 @@ std::string stringize(const VkExtent3D& extents) {
178178
}
179179
std::vector<std::tuple<std::string, uint32_t, uint64_t, uint64_t>>
180180
QueryPool::get_shader_timestamp_data() {
181-
if (VK_NULL_HANDLE == querypool_) {
181+
if (querypool_ == VK_NULL_HANDLE) {
182182
return {};
183183
}
184184
std::lock_guard<std::mutex> lock(mutex_);

backends/vulkan/runtime/vk_api/Runtime.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ VkInstance create_instance(const RuntimeConfig& config) {
134134

135135
std::vector<Runtime::DeviceMapping> create_physical_devices(
136136
VkInstance instance) {
137-
if (VK_NULL_HANDLE == instance) {
137+
if (instance == VK_NULL_HANDLE) {
138138
return std::vector<Runtime::DeviceMapping>();
139139
}
140140

@@ -176,7 +176,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL debug_report_callback_fn(
176176
VkDebugReportCallbackEXT create_debug_report_callback(
177177
VkInstance instance,
178178
const RuntimeConfig config) {
179-
if (VK_NULL_HANDLE == instance || !config.enable_validation_messages) {
179+
if (instance == VK_NULL_HANDLE || !config.enable_validation_messages) {
180180
return VkDebugReportCallbackEXT{};
181181
}
182182

@@ -296,7 +296,7 @@ Runtime::Runtime(const RuntimeConfig config)
296296
}
297297

298298
Runtime::~Runtime() {
299-
if (VK_NULL_HANDLE == instance_) {
299+
if (instance_ == VK_NULL_HANDLE) {
300300
return;
301301
}
302302

backends/vulkan/runtime/vk_api/Shader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ ShaderLayout::ShaderLayout(ShaderLayout&& other) noexcept
8383
}
8484

8585
ShaderLayout::~ShaderLayout() {
86-
if (VK_NULL_HANDLE == handle_) {
86+
if (handle_ == VK_NULL_HANDLE) {
8787
return;
8888
}
8989
vkDestroyDescriptorSetLayout(device_, handle_, nullptr);
@@ -128,7 +128,7 @@ ShaderModule::ShaderModule(ShaderModule&& other) noexcept
128128
}
129129

130130
ShaderModule::~ShaderModule() {
131-
if (VK_NULL_HANDLE == handle_) {
131+
if (handle_ == VK_NULL_HANDLE) {
132132
return;
133133
}
134134
vkDestroyShaderModule(device_, handle_, nullptr);

backends/vulkan/runtime/vk_api/memory/Allocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Allocation::~Allocation() {
6565
// Do not destroy the VmaAllocation if this class instance is a copy of some
6666
// other class instance, since this means that this class instance does not
6767
// have ownership of the underlying resource.
68-
if (VK_NULL_HANDLE != allocation && !is_copy_) {
68+
if (allocation != VK_NULL_HANDLE && !is_copy_) {
6969
vmaFreeMemory(allocator, allocation);
7070
}
7171
}

backends/vulkan/runtime/vk_api/memory/Allocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Allocator::Allocator(Allocator&& other) noexcept
5252
}
5353

5454
Allocator::~Allocator() {
55-
if (VK_NULL_HANDLE == allocator_) {
55+
if (allocator_ == VK_NULL_HANDLE) {
5656
return;
5757
}
5858
vmaDestroyAllocator(allocator_);

backends/vulkan/runtime/vk_api/memory/Buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ VulkanBuffer::~VulkanBuffer() {
122122
// Do not destroy the VkBuffer if this class instance is a copy of another
123123
// class instance, since this means that this class instance does not have
124124
// ownership of the underlying resource.
125-
if (VK_NULL_HANDLE != handle_ && !is_copy_) {
125+
if (handle_ != VK_NULL_HANDLE && !is_copy_) {
126126
if (owns_memory_) {
127127
vmaDestroyBuffer(allocator_, handle_, memory_.allocation);
128128
} else {

backends/vulkan/runtime/vk_api/memory/Image.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ImageSampler::ImageSampler(ImageSampler&& other) noexcept
5757
}
5858

5959
ImageSampler::~ImageSampler() {
60-
if (VK_NULL_HANDLE == handle_) {
60+
if (handle_ == VK_NULL_HANDLE) {
6161
return;
6262
}
6363
vkDestroySampler(device_, handle_, nullptr);
@@ -232,11 +232,11 @@ VulkanImage::~VulkanImage() {
232232
return;
233233
}
234234

235-
if (VK_NULL_HANDLE != handles_.image_view) {
235+
if (handles_.image_view != VK_NULL_HANDLE) {
236236
vkDestroyImageView(this->device(), handles_.image_view, nullptr);
237237
}
238238

239-
if (VK_NULL_HANDLE != handles_.image) {
239+
if (handles_.image != VK_NULL_HANDLE) {
240240
if (owns_memory_) {
241241
vmaDestroyImage(allocator_, handles_.image, memory_.allocation);
242242
} else {

0 commit comments

Comments
 (0)