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 {
unsigned int Clipper::ComputeClipFlags(const float4 &v, bool depthClipEnable)
{
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) |
((v.y > v.w) ? CLIP_TOP : 0) |
((v.x < -v.w) ? CLIP_LEFT : 0) |
......
......@@ -717,7 +717,7 @@ void SpirvShader::Fence(spv::MemorySemanticsMask semantics) const
{
if(semantics == spv::MemorySemanticsMaskNone)
{
return; //no-op
return; // no-op
}
rr::Fence(MemoryOrder(semantics));
}
......
......@@ -93,7 +93,7 @@ private:
LRUCache &operator=(const 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
{
Key key = {};
......
......@@ -50,7 +50,7 @@ public:
}
VkSemaphoreType getSemaphoreType() const;
//static size_t ComputeRequiredAllocationSize(const VkSemaphoreCreateInfo *pCreateInfo);
// static size_t ComputeRequiredAllocationSize(const VkSemaphoreCreateInfo *pCreateInfo);
protected:
VkSemaphoreType type;
......
......@@ -365,7 +365,7 @@ static const ExtensionProperties deviceExtensionProperties[] = {
{ { 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_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
//{{ 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 } },
......
......@@ -47,4 +47,4 @@ private:
};
} // namespace vk
#endif //SWIFTSHADER_DIRECTFBSURFACEEXT_HPP
#endif // SWIFTSHADER_DIRECTFBSURFACEEXT_HPP
......@@ -60,4 +60,4 @@ private:
};
} // namespace vk
#endif //SWIFTSHADER_DISPLAYSURFACEKHR_HPP
#endif // SWIFTSHADER_DISPLAYSURFACEKHR_HPP
......@@ -34,4 +34,4 @@ public:
};
} // namespace vk
#endif //SWIFTSHADER_HEADLESSSURFACEKHR_HPP
#endif // SWIFTSHADER_HEADLESSSURFACEKHR_HPP
......@@ -65,4 +65,4 @@ public:
#endif
} // namespace vk
#endif //SWIFTSHADER_METALSURFACE_HPP
#endif // SWIFTSHADER_METALSURFACE_HPP
......@@ -109,4 +109,4 @@ static inline SurfaceKHR *Cast(VkSurfaceKHR object)
} // namespace vk
#endif //SWIFTSHADER_VKSURFACEKHR_HPP_
#endif // SWIFTSHADER_VKSURFACEKHR_HPP_
......@@ -63,4 +63,4 @@ static inline SwapchainKHR *Cast(VkSwapchainKHR object)
} // namespace vk
#endif //SWIFTSHADER_VKSWAPCHAINKHR_HPP
#endif // SWIFTSHADER_VKSWAPCHAINKHR_HPP
......@@ -54,4 +54,4 @@ private:
};
} // namespace vk
#endif //SWIFTSHADER_WAYLANDSURFACEKHR_HPP
#endif // SWIFTSHADER_WAYLANDSURFACEKHR_HPP
......@@ -60,4 +60,4 @@ private:
};
} // namespace vk
#endif //SWIFTSHADER_WIN32SURFACEKHR_HPP
#endif // SWIFTSHADER_WIN32SURFACEKHR_HPP
......@@ -49,4 +49,4 @@ private:
};
} // namespace vk
#endif //SWIFTSHADER_XCBSURFACEKHR_HPP
#endif // SWIFTSHADER_XCBSURFACEKHR_HPP
......@@ -49,4 +49,4 @@ private:
};
} // 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 )"
ROOT_DIR="$( cd "${SRC_DIR}/.." >/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 )"
CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
${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
# 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
case $1 in
-a|--all)
all=1
shift
;;
-h|--help)
show_help
exit 0
;;
esac
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)
{
FunctionT<int(int)> function;
{
//Int b = function.Arg<0>();
// Int b = function.Arg<0>();
Int b;
Pointer<Int> p = &b;
......
......@@ -115,70 +115,70 @@ TEST_F(BasicTest, Version)
/*
TEST_F(BasicTest, UnsupportedDeviceExtension_DISABLED)
{
uint32_t apiVersion = 0;
VkResult result = driver.vkEnumerateInstanceVersion(&apiVersion);
const VkInstanceCreateInfo createInfo = {
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
nullptr, // pNext
0, // flags
nullptr, // pApplicationInfo
0, // enabledLayerCount
nullptr, // ppEnabledLayerNames
0, // enabledExtensionCount
nullptr, // ppEnabledExtensionNames
};
VkInstance instance = VK_NULL_HANDLE;
result = driver.vkCreateInstance(&createInfo, nullptr, &instance);
EXPECT_EQ(result, VK_SUCCESS);
ASSERT_TRUE(driver.resolve(instance));
VkBaseInStructure unsupportedExt = { VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT, nullptr };
// Gather all physical devices
std::vector<VkPhysicalDevice> physicalDevices;
result = Device::GetPhysicalDevices(&driver, instance, physicalDevices);
EXPECT_EQ(result, VK_SUCCESS);
// Inspect each physical device's queue families for compute support.
for(auto physicalDevice : physicalDevices)
{
int queueFamilyIndex = Device::GetComputeQueueFamilyIndex(&driver, physicalDevice);
if(queueFamilyIndex < 0)
{
continue;
}
const float queuePrioritory = 1.0f;
const VkDeviceQueueCreateInfo deviceQueueCreateInfo = {
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType
nullptr, // pNext
0, // flags
(uint32_t)queueFamilyIndex, // queueFamilyIndex
1, // queueCount
&queuePrioritory, // pQueuePriorities
};
const VkDeviceCreateInfo deviceCreateInfo = {
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
&unsupportedExt, // pNext
0, // flags
1, // queueCreateInfoCount
&deviceQueueCreateInfo, // pQueueCreateInfos
0, // enabledLayerCount
nullptr, // ppEnabledLayerNames
0, // enabledExtensionCount
nullptr, // ppEnabledExtensionNames
nullptr, // pEnabledFeatures
};
VkDevice device;
result = driver.vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &device);
EXPECT_EQ(result, VK_SUCCESS);
driver.vkDestroyDevice(device, nullptr);
}
driver.vkDestroyInstance(instance, nullptr);
uint32_t apiVersion = 0;
VkResult result = driver.vkEnumerateInstanceVersion(&apiVersion);
const VkInstanceCreateInfo createInfo = {
VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // sType
nullptr, // pNext
0, // flags
nullptr, // pApplicationInfo
0, // enabledLayerCount
nullptr, // ppEnabledLayerNames
0, // enabledExtensionCount
nullptr, // ppEnabledExtensionNames
};
VkInstance instance = VK_NULL_HANDLE;
result = driver.vkCreateInstance(&createInfo, nullptr, &instance);
EXPECT_EQ(result, VK_SUCCESS);
ASSERT_TRUE(driver.resolve(instance));
VkBaseInStructure unsupportedExt = { VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT, nullptr };
// Gather all physical devices
std::vector<VkPhysicalDevice> physicalDevices;
result = Device::GetPhysicalDevices(&driver, instance, physicalDevices);
EXPECT_EQ(result, VK_SUCCESS);
// Inspect each physical device's queue families for compute support.
for(auto physicalDevice : physicalDevices)
{
int queueFamilyIndex = Device::GetComputeQueueFamilyIndex(&driver, physicalDevice);
if(queueFamilyIndex < 0)
{
continue;
}
const float queuePrioritory = 1.0f;
const VkDeviceQueueCreateInfo deviceQueueCreateInfo = {
VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // sType
nullptr, // pNext
0, // flags
(uint32_t)queueFamilyIndex, // queueFamilyIndex
1, // queueCount
&queuePrioritory, // pQueuePriorities
};
const VkDeviceCreateInfo deviceCreateInfo = {
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
&unsupportedExt, // pNext
0, // flags
1, // queueCreateInfoCount
&deviceQueueCreateInfo, // pQueueCreateInfos
0, // enabledLayerCount
nullptr, // ppEnabledLayerNames
0, // enabledExtensionCount
nullptr, // ppEnabledExtensionNames
nullptr, // pEnabledFeatures
};
VkDevice device;
result = driver.vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &device);
EXPECT_EQ(result, VK_SUCCESS);
driver.vkDestroyDevice(device, nullptr);
}
driver.vkDestroyInstance(instance, nullptr);
}
*/
......@@ -29,7 +29,7 @@ Buffer::Buffer(vk::Device device, vk::DeviceSize size, vk::BufferUsageFlags usag
vk::MemoryAllocateInfo allocInfo{};
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);
device.bindBufferMemory(buffer, bufferMemory, 0);
......
......@@ -282,7 +282,7 @@ void VulkanTester::initialize()
return strcmp(layer, lp.layerName) == 0;
}) != layerProperties.end())
{
//std::cout << "Enabled layer: " << layer << std::endl;
// std::cout << "Enabled layer: " << layer << std::endl;
layers.push_back(layer);
}
};
......@@ -318,7 +318,7 @@ void VulkanTester::initialize()
VkDebugUtilsMessageTypeFlagsEXT messageTypes,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) -> VkBool32 {
//assert(false);
// assert(false);
std::cerr << "[DebugInfoCallback] " << pCallbackData->pMessage << std::endl;
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