Make clang-format-all.sh git aware

clang-format-all.sh will modify every file in the repository that isn't properly formatted. However, if you only care about the formatting of the files touched in a CL, this is over-zealous. So the default behavior is to only modify a file list derived from git's current set of files. You can still use the script to format the entire repo with -a or --all. clang-format has been run on all files in the repository to bring them up-to-date with the latest format. Bug: b/187094215 Change-Id: I2753c83e00d36817eddb0d8e641100240a2e8e23 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/54048Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Commit-Queue: Sean Risser <srisser@google.com> Tested-by: 's avatarSean Risser <srisser@google.com>
parent 37cb6a5d
...@@ -264,7 +264,7 @@ namespace sw { ...@@ -264,7 +264,7 @@ namespace sw {
unsigned int Clipper::ComputeClipFlags(const float4 &v, bool depthClipEnable) unsigned int Clipper::ComputeClipFlags(const float4 &v, bool depthClipEnable)
{ {
int depthClipFlags = ((v.z > v.w) ? CLIP_FAR : 0) | int depthClipFlags = ((v.z > v.w) ? CLIP_FAR : 0) |
((v.z < 0) ? CLIP_NEAR : 0); ((v.z < 0) ? CLIP_NEAR : 0);
return ((v.x > v.w) ? CLIP_RIGHT : 0) | return ((v.x > v.w) ? CLIP_RIGHT : 0) |
((v.y > v.w) ? CLIP_TOP : 0) | ((v.y > v.w) ? CLIP_TOP : 0) |
((v.x < -v.w) ? CLIP_LEFT : 0) | ((v.x < -v.w) ? CLIP_LEFT : 0) |
......
...@@ -717,7 +717,7 @@ void SpirvShader::Fence(spv::MemorySemanticsMask semantics) const ...@@ -717,7 +717,7 @@ void SpirvShader::Fence(spv::MemorySemanticsMask semantics) const
{ {
if(semantics == spv::MemorySemanticsMaskNone) if(semantics == spv::MemorySemanticsMaskNone)
{ {
return; //no-op return; // no-op
} }
rr::Fence(MemoryOrder(semantics)); rr::Fence(MemoryOrder(semantics));
} }
......
...@@ -93,7 +93,7 @@ private: ...@@ -93,7 +93,7 @@ private:
LRUCache &operator=(const LRUCache &) = delete; LRUCache &operator=(const LRUCache &) = delete;
LRUCache &operator=(LRUCache &&) = delete; LRUCache &operator=(LRUCache &&) = delete;
//Keyed holds a key. See find() for more information. // Keyed holds a key. See find() for more information.
struct Keyed struct Keyed
{ {
Key key = {}; Key key = {};
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
} }
VkSemaphoreType getSemaphoreType() const; VkSemaphoreType getSemaphoreType() const;
//static size_t ComputeRequiredAllocationSize(const VkSemaphoreCreateInfo *pCreateInfo); // static size_t ComputeRequiredAllocationSize(const VkSemaphoreCreateInfo *pCreateInfo);
protected: protected:
VkSemaphoreType type; VkSemaphoreType type;
......
...@@ -365,7 +365,7 @@ static const ExtensionProperties deviceExtensionProperties[] = { ...@@ -365,7 +365,7 @@ static const ExtensionProperties deviceExtensionProperties[] = {
{ { VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME, VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION } }, { { VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME, VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION } },
{ { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION } }, { { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION } },
{ { VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME, VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION } }, { { VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME, VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION } },
{ { VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION} }, { { VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION } },
// Only 1.1 core version of this is supported. The extension has additional requirements // Only 1.1 core version of this is supported. The extension has additional requirements
//{{ VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION }}, //{{ VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION }},
{ { VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME, VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION } }, { { VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME, VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION } },
......
...@@ -47,4 +47,4 @@ private: ...@@ -47,4 +47,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_DIRECTFBSURFACEEXT_HPP #endif // SWIFTSHADER_DIRECTFBSURFACEEXT_HPP
...@@ -60,4 +60,4 @@ private: ...@@ -60,4 +60,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_DISPLAYSURFACEKHR_HPP #endif // SWIFTSHADER_DISPLAYSURFACEKHR_HPP
...@@ -34,4 +34,4 @@ public: ...@@ -34,4 +34,4 @@ public:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_HEADLESSSURFACEKHR_HPP #endif // SWIFTSHADER_HEADLESSSURFACEKHR_HPP
...@@ -65,4 +65,4 @@ public: ...@@ -65,4 +65,4 @@ public:
#endif #endif
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_METALSURFACE_HPP #endif // SWIFTSHADER_METALSURFACE_HPP
...@@ -109,4 +109,4 @@ static inline SurfaceKHR *Cast(VkSurfaceKHR object) ...@@ -109,4 +109,4 @@ static inline SurfaceKHR *Cast(VkSurfaceKHR object)
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_VKSURFACEKHR_HPP_ #endif // SWIFTSHADER_VKSURFACEKHR_HPP_
...@@ -63,4 +63,4 @@ static inline SwapchainKHR *Cast(VkSwapchainKHR object) ...@@ -63,4 +63,4 @@ static inline SwapchainKHR *Cast(VkSwapchainKHR object)
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_VKSWAPCHAINKHR_HPP #endif // SWIFTSHADER_VKSWAPCHAINKHR_HPP
...@@ -54,4 +54,4 @@ private: ...@@ -54,4 +54,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_WAYLANDSURFACEKHR_HPP #endif // SWIFTSHADER_WAYLANDSURFACEKHR_HPP
...@@ -60,4 +60,4 @@ private: ...@@ -60,4 +60,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_WIN32SURFACEKHR_HPP #endif // SWIFTSHADER_WIN32SURFACEKHR_HPP
...@@ -49,4 +49,4 @@ private: ...@@ -49,4 +49,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_XCBSURFACEKHR_HPP #endif // SWIFTSHADER_XCBSURFACEKHR_HPP
...@@ -49,4 +49,4 @@ private: ...@@ -49,4 +49,4 @@ private:
}; };
} // namespace vk } // namespace vk
#endif //SWIFTSHADER_XLIBSURFACEKHR_HPP #endif // SWIFTSHADER_XLIBSURFACEKHR_HPP
#! /usr/bin/env sh
SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="$( cd "${SRC_DIR}/.." >/dev/null 2>&1 && pwd )" ROOT_DIR="$( cd "${SRC_DIR}/.." >/dev/null 2>&1 && pwd )"
TESTS_DIR="$( cd "${ROOT_DIR}/tests" >/dev/null 2>&1 && pwd )" TESTS_DIR="$( cd "${ROOT_DIR}/tests" >/dev/null 2>&1 && pwd )"
...@@ -5,10 +7,45 @@ TESTS_DIR="$( cd "${ROOT_DIR}/tests" >/dev/null 2>&1 && pwd )" ...@@ -5,10 +7,45 @@ TESTS_DIR="$( cd "${ROOT_DIR}/tests" >/dev/null 2>&1 && pwd )"
CLANG_FORMAT=${CLANG_FORMAT:-clang-format} CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
${CLANG_FORMAT} --version ${CLANG_FORMAT} --version
for DIR in "${SRC_DIR}/Device" "${SRC_DIR}/Pipeline" "${SRC_DIR}/Reactor" "${SRC_DIR}/System" "${SRC_DIR}/Vulkan" "${SRC_DIR}/WSI" "${TESTS_DIR}" show_help()
{
# Tells cat to stop reading file when EOF is detected
cat << EOF
Usage: ./clang-format-all.sh [-ah]
Format files in the SwiftShader repository
-h, --help Display this message and exit
-a, --all Format all files (default is to format only files active in a git CL)
EOF
# cat finishes printing
}
while [[ $# -gt 0 ]]
do do
# Double clang-format, as it seems that one pass isn't always enough case $1 in
find ${DIR} -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.inl" | xargs ${CLANG_FORMAT} -i -style=file -a|--all)
find ${DIR} -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.inl" | xargs ${CLANG_FORMAT} -i -style=file all=1
shift
;;
-h|--help)
show_help
exit 0
;;
esac
done done
if [[ $all -eq 1 ]]
then
for DIR in "${SRC_DIR}/Device" "${SRC_DIR}/Pipeline" "${SRC_DIR}/Reactor" "${SRC_DIR}/System" "${SRC_DIR}/Vulkan" "${SRC_DIR}/WSI" "${TESTS_DIR}"
do
# Double clang-format, as it seems that one pass isn't always enough
find ${DIR} -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.inl" | xargs ${CLANG_FORMAT} -i -style=file
find ${DIR} -iname "*.hpp" -o -iname "*.cpp" -o -iname "*.inl" | xargs ${CLANG_FORMAT} -i -style=file
done
else
BASEDIR=$(git rev-parse --show-toplevel)
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -v '\.sh')
for FILE in $FILES
do
${CLANG_FORMAT} -i -style=file "$BASEDIR/$FILE"
done
fi
...@@ -637,7 +637,7 @@ TEST(ReactorUnitTests, StoreBeforeIndirectStore) ...@@ -637,7 +637,7 @@ TEST(ReactorUnitTests, StoreBeforeIndirectStore)
{ {
FunctionT<int(int)> function; FunctionT<int(int)> function;
{ {
//Int b = function.Arg<0>(); // Int b = function.Arg<0>();
Int b; Int b;
Pointer<Int> p = &b; Pointer<Int> p = &b;
......
...@@ -115,70 +115,70 @@ TEST_F(BasicTest, Version) ...@@ -115,70 +115,70 @@ TEST_F(BasicTest, Version)
/* /*
TEST_F(BasicTest, UnsupportedDeviceExtension_DISABLED) TEST_F(BasicTest, UnsupportedDeviceExtension_DISABLED)
{ {
uint32_t apiVersion = 0; uint32_t apiVersion = 0;
VkResult result = driver.vkEnumerateInstanceVersion(&apiVersion); VkResult result = driver.vkEnumerateInstanceVersion(&apiVersion);
const VkInstanceCreateInfo createInfo = { const VkInstanceCreateInfo createInfo = {
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
nullptr, // pNext nullptr, // pNext
0, // flags 0, // flags
nullptr, // pApplicationInfo nullptr, // pApplicationInfo
0, // enabledLayerCount 0, // enabledLayerCount
nullptr, // ppEnabledLayerNames nullptr, // ppEnabledLayerNames
0, // enabledExtensionCount 0, // enabledExtensionCount
nullptr, // ppEnabledExtensionNames nullptr, // ppEnabledExtensionNames
}; };
VkInstance instance = VK_NULL_HANDLE; VkInstance instance = VK_NULL_HANDLE;
result = driver.vkCreateInstance(&createInfo, nullptr, &instance); result = driver.vkCreateInstance(&createInfo, nullptr, &instance);
EXPECT_EQ(result, VK_SUCCESS); EXPECT_EQ(result, VK_SUCCESS);
ASSERT_TRUE(driver.resolve(instance)); ASSERT_TRUE(driver.resolve(instance));
VkBaseInStructure unsupportedExt = { VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT, nullptr }; VkBaseInStructure unsupportedExt = { VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT, nullptr };
// Gather all physical devices // Gather all physical devices
std::vector<VkPhysicalDevice> physicalDevices; std::vector<VkPhysicalDevice> physicalDevices;
result = Device::GetPhysicalDevices(&driver, instance, physicalDevices); result = Device::GetPhysicalDevices(&driver, instance, physicalDevices);
EXPECT_EQ(result, VK_SUCCESS); EXPECT_EQ(result, VK_SUCCESS);
// Inspect each physical device's queue families for compute support. // Inspect each physical device's queue families for compute support.
for(auto physicalDevice : physicalDevices) for(auto physicalDevice : physicalDevices)
{ {
int queueFamilyIndex = Device::GetComputeQueueFamilyIndex(&driver, physicalDevice); int queueFamilyIndex = Device::GetComputeQueueFamilyIndex(&driver, physicalDevice);
if(queueFamilyIndex < 0) if(queueFamilyIndex < 0)
{ {
continue; continue;
} }
const float queuePrioritory = 1.0f; const float queuePrioritory = 1.0f;
const VkDeviceQueueCreateInfo deviceQueueCreateInfo = { const VkDeviceQueueCreateInfo deviceQueueCreateInfo = {
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType
nullptr, // pNext nullptr, // pNext
0, // flags 0, // flags
(uint32_t)queueFamilyIndex, // queueFamilyIndex (uint32_t)queueFamilyIndex, // queueFamilyIndex
1, // queueCount 1, // queueCount
&queuePrioritory, // pQueuePriorities &queuePrioritory, // pQueuePriorities
}; };
const VkDeviceCreateInfo deviceCreateInfo = { const VkDeviceCreateInfo deviceCreateInfo = {
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
&unsupportedExt, // pNext &unsupportedExt, // pNext
0, // flags 0, // flags
1, // queueCreateInfoCount 1, // queueCreateInfoCount
&deviceQueueCreateInfo, // pQueueCreateInfos &deviceQueueCreateInfo, // pQueueCreateInfos
0, // enabledLayerCount 0, // enabledLayerCount
nullptr, // ppEnabledLayerNames nullptr, // ppEnabledLayerNames
0, // enabledExtensionCount 0, // enabledExtensionCount
nullptr, // ppEnabledExtensionNames nullptr, // ppEnabledExtensionNames
nullptr, // pEnabledFeatures nullptr, // pEnabledFeatures
}; };
VkDevice device; VkDevice device;
result = driver.vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &device); result = driver.vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &device);
EXPECT_EQ(result, VK_SUCCESS); EXPECT_EQ(result, VK_SUCCESS);
driver.vkDestroyDevice(device, nullptr); driver.vkDestroyDevice(device, nullptr);
} }
driver.vkDestroyInstance(instance, nullptr); driver.vkDestroyInstance(instance, nullptr);
} }
*/ */
...@@ -29,7 +29,7 @@ Buffer::Buffer(vk::Device device, vk::DeviceSize size, vk::BufferUsageFlags usag ...@@ -29,7 +29,7 @@ Buffer::Buffer(vk::Device device, vk::DeviceSize size, vk::BufferUsageFlags usag
vk::MemoryAllocateInfo allocInfo{}; vk::MemoryAllocateInfo allocInfo{};
allocInfo.allocationSize = memRequirements.size; allocInfo.allocationSize = memRequirements.size;
allocInfo.memoryTypeIndex = 0; //TODO: getMemoryTypeIndex(memRequirements.memoryTypeBits, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent); allocInfo.memoryTypeIndex = 0; // TODO: getMemoryTypeIndex(memRequirements.memoryTypeBits, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent);
bufferMemory = device.allocateMemory(allocInfo); bufferMemory = device.allocateMemory(allocInfo);
device.bindBufferMemory(buffer, bufferMemory, 0); device.bindBufferMemory(buffer, bufferMemory, 0);
......
...@@ -282,7 +282,7 @@ void VulkanTester::initialize() ...@@ -282,7 +282,7 @@ void VulkanTester::initialize()
return strcmp(layer, lp.layerName) == 0; return strcmp(layer, lp.layerName) == 0;
}) != layerProperties.end()) }) != layerProperties.end())
{ {
//std::cout << "Enabled layer: " << layer << std::endl; // std::cout << "Enabled layer: " << layer << std::endl;
layers.push_back(layer); layers.push_back(layer);
} }
}; };
...@@ -318,7 +318,7 @@ void VulkanTester::initialize() ...@@ -318,7 +318,7 @@ void VulkanTester::initialize()
VkDebugUtilsMessageTypeFlagsEXT messageTypes, VkDebugUtilsMessageTypeFlagsEXT messageTypes,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) -> VkBool32 { void *pUserData) -> VkBool32 {
//assert(false); // assert(false);
std::cerr << "[DebugInfoCallback] " << pCallbackData->pMessage << std::endl; std::cerr << "[DebugInfoCallback] " << pCallbackData->pMessage << std::endl;
return VK_FALSE; return VK_FALSE;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment