diff options
| author | Mark Young <Mark Young> | 2016-01-06 14:26:04 -0700 |
|---|---|---|
| committer | Mark Young <marky@lunarg.com> | 2016-01-07 09:45:05 -0700 |
| commit | 418b9d1241b482696ae352fbd1e15895a44d85f8 (patch) | |
| tree | 9749f3f0049b9fd8178c6867503b9c0abdfb2fff | |
| parent | a9857f7c0a6ace5696ffc3921c0e963faca5050e (diff) | |
| download | usermoji-418b9d1241b482696ae352fbd1e15895a44d85f8.tar.xz | |
Fixes: Fixed Visual Studio warnings during compilation.
Changes to properly detect proper Visual Studio and fix build warnings.
| -rw-r--r-- | demos/cube.c | 65 | ||||
| -rwxr-xr-x | include/vulkan/vk_sdk_platform.h | 4 | ||||
| -rw-r--r-- | layers/draw_state.cpp | 2 | ||||
| -rw-r--r-- | layers/mem_tracker.cpp | 18 |
4 files changed, 68 insertions, 21 deletions
diff --git a/demos/cube.c b/demos/cube.c index 332cd808..f1202cbc 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -2644,12 +2644,8 @@ static void demo_init(struct demo *demo, int argc, char **argv) #ifdef _WIN32 -extern int __getmainargs( - int * _Argc, - char *** _Argv, - char *** _Env, - int _DoWildCard, - int * new_mode); +// Include header required for parsing the command line options. +#include <shellapi.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -2657,15 +2653,61 @@ int WINAPI WinMain(HINSTANCE hInstance, int nCmdShow) { MSG msg; // message - bool done; // flag saying when app is complete + bool done; // flag saying when app is complete int argc; char** argv; - char** env; - int new_mode = 0; - __getmainargs(&argc,&argv,&env,0,&new_mode); + // Use the CommandLine functions to get the command line arguments. Unfortunately, Microsoft outputs + // this information as wide characters for Unicode, and we simply want the Ascii version to be compatible + // with the non-Windows side. So, we have to convert the information to Ascii character strings. + LPWSTR* commandLineArgs = CommandLineToArgvW(GetCommandLineW(), &argc); + if (NULL == commandLineArgs) + { + argc = 0; + } + + if (argc > 0) + { + argv = (char**)malloc(sizeof(char*) * argc); + if (argv == NULL) + { + argc = 0; + } + else + { + for (int iii = 0; iii < argc; iii++) + { + size_t wideCharLen = wcslen(commandLineArgs[iii]); + size_t numConverted = 0; + + argv[iii] = (char*)malloc(sizeof(char) * (wideCharLen + 1)); + if (argv[iii] != NULL) + { + wcstombs_s(&numConverted, argv[iii], wideCharLen + 1, commandLineArgs[iii], wideCharLen + 1); + } + } + } + } + else + { + argv = NULL; + } demo_init(&demo, argc, argv); + + // Free up the items we had to allocate for the command line arguments. + if (argc > 0 && argv != NULL) + { + for (int iii = 0; iii < argc; iii++) + { + if (argv[iii] != NULL) + { + free(argv[iii]); + } + } + free(argv); + } + demo.connection = hInstance; strncpy(demo.name, "cube", APP_NAME_STR_LEN); demo_create_window(&demo); @@ -2674,7 +2716,8 @@ int WINAPI WinMain(HINSTANCE hInstance, demo_prepare(&demo); done = false; //initialize loop condition variable - /* main message loop*/ + + // main message loop while(!done) { PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); diff --git a/include/vulkan/vk_sdk_platform.h b/include/vulkan/vk_sdk_platform.h index d5e31a83..34b50169 100755 --- a/include/vulkan/vk_sdk_platform.h +++ b/include/vulkan/vk_sdk_platform.h @@ -35,12 +35,16 @@ # define inline __inline # endif // __cplusplus +#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) // C99: // Microsoft didn't implement C99 in Visual Studio; but started adding it with // VS2013. However, VS2013 still didn't have snprintf(). The following is a // work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the // "CMakeLists.txt" file). +// NOTE: This is fixed in Visual Studio 2015. #define snprintf _snprintf +#endif + #define strdup _strdup #endif // _WIN32 diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index 04997cad..46215e86 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -4259,7 +4259,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers( pCB->lastVtxBinding = firstBinding + bindingCount - 1; updateResourceTracking(pCB, firstBinding, bindingCount, pBuffers); } else { - skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBindVertexBuffer()"); + skipCall |= report_error_no_cb_begin(dev_data, commandBuffer, "vkCmdBindVertexBuffer()"); } if (VK_FALSE == skipCall) dev_data->device_dispatch_table->CmdBindVertexBuffers(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets); diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp index b88d9ce1..03038a9d 100644 --- a/layers/mem_tracker.cpp +++ b/layers/mem_tracker.cpp @@ -466,7 +466,7 @@ add_mem_obj_info( my_data->memObjMap[mem].valid = false; } -static bool validate_memory_is_valid(layer_data *my_data, VkDeviceMemory mem, VkImage image = VK_NULL_HANDLE) { +static VkBool32 validate_memory_is_valid(layer_data *my_data, VkDeviceMemory mem, VkImage image = VK_NULL_HANDLE) { if (mem == MEMTRACKER_SWAP_CHAIN_IMAGE_KEY) { MT_OBJ_BINDING_INFO* pBindInfo = get_object_binding_info(my_data, reinterpret_cast<uint64_t>(image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT); if (pBindInfo && !pBindInfo->valid) { @@ -2325,8 +2325,8 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers( const VkDeviceSize *pOffsets) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); - bool skip_call = false; - for (int i = 0; i < bindingCount; ++i) { + VkBool32 skip_call = false; + for (uint32_t i = 0; i < bindingCount; ++i) { VkDeviceMemory mem; skip_call |= get_mem_binding_from_object(my_data, commandBuffer, reinterpret_cast<uint64_t>(pBuffers[i]), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, &mem); @@ -2345,7 +2345,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer( { layer_data *my_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map); VkDeviceMemory mem; - bool skip_call = get_mem_binding_from_object(my_data, commandBuffer, reinterpret_cast<uint64_t>(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, &mem); + VkBool32 skip_call = get_mem_binding_from_object(my_data, commandBuffer, reinterpret_cast<uint64_t>(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, &mem); skip_call |= validate_memory_is_valid(my_data, mem); // TODO : Somewhere need to verify that IBs have correct usage state flagged if (!skip_call) @@ -2875,9 +2875,9 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR( { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; layer_data *my_data = get_my_data_ptr(get_dispatch_key(queue), layer_data_map); - bool skip_call = false; + VkBool32 skip_call = false; VkDeviceMemory mem; - for (int i = 0; i < pPresentInfo->swapchainCount; ++i) { + for (uint32_t i = 0; i < pPresentInfo->swapchainCount; ++i) { MT_SWAP_CHAIN_INFO *pInfo = my_data->swapchainMap[pPresentInfo->pSwapchains[i]]; VkImage image = pInfo->images[pPresentInfo->pImageIndices[i]]; skip_call |= get_mem_binding_from_object(my_data, queue, reinterpret_cast<uint64_t>(image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, &mem); @@ -2928,7 +2928,7 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer( { layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); VkResult result = my_data->device_dispatch_table->CreateFramebuffer(device, pCreateInfo, pAllocator, pFramebuffer); - for (int i = 0; i < pCreateInfo->attachmentCount; ++i) { + for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) { VkImageView view = pCreateInfo->pAttachments[i]; loader_platform_thread_lock_mutex(&globalLock); auto view_data = my_data->imageViewMap.find(view); @@ -2970,7 +2970,7 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass( { layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); VkResult result = my_data->device_dispatch_table->CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass); - for (int i = 0; i < pCreateInfo->attachmentCount; ++i) { + for (uint32_t i = 0; i < pCreateInfo->attachmentCount; ++i) { VkAttachmentDescription desc = pCreateInfo->pAttachments[i]; MT_PASS_ATTACHMENT_INFO pass_info; pass_info.load_op = desc.loadOp; @@ -3016,7 +3016,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass( VkSubpassContents contents) { layer_data *my_data = get_my_data_ptr(get_dispatch_key(cmdBuffer), layer_data_map); - bool skip_call = false; + VkBool32 skip_call = false; if (pRenderPassBegin) { loader_platform_thread_lock_mutex(&globalLock); auto pass_data = my_data->passMap.find(pRenderPassBegin->renderPass); |
