Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

Commit

Permalink
repo: Clang-format LVL source files using Google
Browse files Browse the repository at this point in the history
Switch clang-format standard from the LLVM style to the
Google style for more consistency.

Change-Id: I247c4abc275d7873a91522e1e234198adaa24033
  • Loading branch information
mark-lunarg committed Jan 26, 2017
1 parent ead2ba6 commit cc7c305
Show file tree
Hide file tree
Showing 80 changed files with 7,127 additions and 7,659 deletions.
8 changes: 3 additions & 5 deletions common/android_util.cpp
Expand Up @@ -31,8 +31,7 @@ char **get_args(struct android_app *app, const char *intent_extra_data_key, cons
std::vector<std::string> args;
JavaVM &vm = *app->activity->vm;
JNIEnv *p_env;
if (vm.AttachCurrentThread(&p_env, nullptr) != JNI_OK)
return nullptr;
if (vm.AttachCurrentThread(&p_env, nullptr) != JNI_OK) return nullptr;

JNIEnv &env = *p_env;
jobject activity = app->activity->clazz;
Expand Down Expand Up @@ -60,8 +59,7 @@ char **get_args(struct android_app *app, const char *intent_extra_data_key, cons
std::stringstream ss(args_str);
std::string arg;
while (std::getline(ss, arg, ' ')) {
if (!arg.empty())
args.push_back(arg);
if (!arg.empty()) args.push_back(arg);
}

// Convert our STL results to C friendly constructs
Expand All @@ -81,4 +79,4 @@ char **get_args(struct android_app *app, const char *intent_extra_data_key, cons
return vector;
}

} // extern "C"
} // extern "C"
3 changes: 1 addition & 2 deletions common/vulkan_wrapper.cpp
Expand Up @@ -23,8 +23,7 @@ extern "C" {

int InitVulkan(void) {
void *libvulkan = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
if (!libvulkan)
return 0;
if (!libvulkan) return 0;

// Vulkan supported, set function addresses
vkCreateInstance = reinterpret_cast<PFN_vkCreateInstance>(dlsym(libvulkan, "vkCreateInstance"));
Expand Down
2 changes: 1 addition & 1 deletion common/vulkan_wrapper.h
Expand Up @@ -235,4 +235,4 @@ extern PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin
}
#endif

#endif // VULKAN_WRAPPER_H
#endif // VULKAN_WRAPPER_H
67 changes: 32 additions & 35 deletions demos/cube.c
Expand Up @@ -37,7 +37,7 @@
#ifdef _WIN32
#pragma comment(linker, "/subsystem:windows")
#define APP_NAME_STR_LEN 80
#endif // _WIN32
#endif // _WIN32

#if defined(VK_USE_PLATFORM_MIR_KHR)
#warning "Cube does not have code for Mir at this time"
Expand Down Expand Up @@ -75,47 +75,45 @@

#ifdef _WIN32
bool in_callback = false;
#define ERR_EXIT(err_msg, err_class) \
do { \
if (!demo->suppress_popups) \
MessageBox(NULL, err_msg, err_class, MB_OK); \
exit(1); \
#define ERR_EXIT(err_msg, err_class) \
do { \
if (!demo->suppress_popups) MessageBox(NULL, err_msg, err_class, MB_OK); \
exit(1); \
} while (0)

#elif defined __ANDROID__
#include <android/log.h>
#define ERR_EXIT(err_msg, err_class) \
do { \
((void)__android_log_print(ANDROID_LOG_INFO, "Cube", err_msg)); \
exit(1); \
#define ERR_EXIT(err_msg, err_class) \
do { \
((void)__android_log_print(ANDROID_LOG_INFO, "Cube", err_msg)); \
exit(1); \
} while (0)
#else
#define ERR_EXIT(err_msg, err_class) \
do { \
printf(err_msg); \
fflush(stdout); \
exit(1); \
#define ERR_EXIT(err_msg, err_class) \
do { \
printf(err_msg); \
fflush(stdout); \
exit(1); \
} while (0)
#endif

#define GET_INSTANCE_PROC_ADDR(inst, entrypoint) \
{ \
demo->fp##entrypoint = (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \
if (demo->fp##entrypoint == NULL) { \
ERR_EXIT("vkGetInstanceProcAddr failed to find vk" #entrypoint, "vkGetInstanceProcAddr Failure"); \
} \
#define GET_INSTANCE_PROC_ADDR(inst, entrypoint) \
{ \
demo->fp##entrypoint = (PFN_vk##entrypoint)vkGetInstanceProcAddr(inst, "vk" #entrypoint); \
if (demo->fp##entrypoint == NULL) { \
ERR_EXIT("vkGetInstanceProcAddr failed to find vk" #entrypoint, "vkGetInstanceProcAddr Failure"); \
} \
}

static PFN_vkGetDeviceProcAddr g_gdpa = NULL;

#define GET_DEVICE_PROC_ADDR(dev, entrypoint) \
{ \
if (!g_gdpa) \
g_gdpa = (PFN_vkGetDeviceProcAddr)vkGetInstanceProcAddr(demo->inst, "vkGetDeviceProcAddr"); \
demo->fp##entrypoint = (PFN_vk##entrypoint)g_gdpa(dev, "vk" #entrypoint); \
if (demo->fp##entrypoint == NULL) { \
ERR_EXIT("vkGetDeviceProcAddr failed to find vk" #entrypoint, "vkGetDeviceProcAddr Failure"); \
} \
#define GET_DEVICE_PROC_ADDR(dev, entrypoint) \
{ \
if (!g_gdpa) g_gdpa = (PFN_vkGetDeviceProcAddr)vkGetInstanceProcAddr(demo->inst, "vkGetDeviceProcAddr"); \
demo->fp##entrypoint = (PFN_vk##entrypoint)g_gdpa(dev, "vk" #entrypoint); \
if (demo->fp##entrypoint == NULL) { \
ERR_EXIT("vkGetDeviceProcAddr failed to find vk" #entrypoint, "vkGetDeviceProcAddr Failure"); \
} \
}

/*
Expand Down Expand Up @@ -282,10 +280,10 @@ typedef struct {
struct demo {
#if defined(VK_USE_PLATFORM_WIN32_KHR)
#define APP_NAME_STR_LEN 80
HINSTANCE connection; // hInstance - Windows Instance
char name[APP_NAME_STR_LEN]; // Name to put on the window/icon
HWND window; // hWnd - window handle
POINT minsize; // minimum window size
HINSTANCE connection; // hInstance - Windows Instance
char name[APP_NAME_STR_LEN]; // Name to put on the window/icon
HWND window; // hWnd - window handle
POINT minsize; // minimum window size
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
Display *display;
Window xlib_window;
Expand Down Expand Up @@ -366,7 +364,7 @@ struct demo {
struct texture_object textures[DEMO_TEXTURE_COUNT];
struct texture_object staging_texture;

VkCommandBuffer cmd; // Buffer for initialization commands
VkCommandBuffer cmd; // Buffer for initialization commands
VkPipelineLayout pipeline_layout;
VkDescriptorSetLayout desc_layout;
VkPipelineCache pipelineCache;
Expand Down Expand Up @@ -403,7 +401,6 @@ struct demo {

VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, size_t location,
int32_t msgCode, const char *pLayerPrefix, const char *pMsg, void *pUserData) {

// clang-format off
char *message = (char *)malloc(strlen(pMsg) + 100);

Expand Down

0 comments on commit cc7c305

Please sign in to comment.