tests: Clean up some MSVC++ compiler warnings
Known issues running tests on Windows:
- Compiler warnings from gtest that we haven’t spent the time to figure out
- Tests don’t run in place - you need to have them in the same directory with vulkan.dll,
gtest.dll, and if MSVC++ is not installed, the MSVC++ runtime dlls. If you want to use
the --compare-images option to vk_render_tests, you will need the “golden”
folder with golden images.
- vk_layer_validation_tests will fail unless you specify VK_LAYER_NAMES as Validation
in the registry or environment. You will also need to specify VK_LAYERS_PATH to point
to the layer dlls. The mismatched type validation test will fail regardless as the
check it is testing for did not make it into the SDK branch
- Known issue of parameter checker for CreateDepthStencilView expecting msaaResolveSubresource
to be valid even if msaa isn’t active
- Problem with runtime assert or hang in shader tracker - for now just remove the
shader checker files from your VK_LAYERS_PATH location.
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 3866f4e..6e2b4c9 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -10,8 +10,8 @@
message(FATAL_ERROR "Missing ImageMagick library: sudo apt-get install libmagickwand-dev\nor http://www.imagemagick.org/script/binary-releases.php for Windows")
endif()
-if(MSVC)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DVK_PROTOTYPES /wd4267")
+if(WIN32)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES /wd4267")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES -Wno-sign-compare")
endif()
@@ -59,20 +59,17 @@
${ImageMagick_INCLUDE_DIRS}
)
-add_definitions(
- -DMAGICKCORE_QUANTUM_DEPTH=16
- -DMAGICKCORE_HDRI_ENABLE=0
- )
-
-# extra setup for out-of-tree builds
-if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
- add_custom_target(binary-dir-symlinks ALL
- COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/golden
- COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh
- COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests_with_layers.sh
- COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/layer_test_suite.py
- VERBATIM
- )
+if (NOT WIN32)
+ # extra setup for out-of-tree builds
+ if (NOT (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR))
+ add_custom_target(binary-dir-symlinks ALL
+ COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/golden
+ COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests.sh
+ COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/run_all_tests_with_layers.sh
+ COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/layer_test_suite.py
+ VERBATIM
+ )
+ endif()
endif()
add_executable(vkbase init.cpp ${COMMON_CPP})
diff --git a/tests/blit_tests.cpp b/tests/blit_tests.cpp
index d3159f2..59f04fe 100644
--- a/tests/blit_tests.cpp
+++ b/tests/blit_tests.cpp
@@ -1200,16 +1200,16 @@
// TODO support all formats
switch (format) {
case VK_FORMAT_R8G8B8A8_UNORM:
- raw.push_back(color[0] * 255.0f);
- raw.push_back(color[1] * 255.0f);
- raw.push_back(color[2] * 255.0f);
- raw.push_back(color[3] * 255.0f);
+ raw.push_back((uint8_t)(color[0] * 255.0f));
+ raw.push_back((uint8_t)(color[1] * 255.0f));
+ raw.push_back((uint8_t)(color[2] * 255.0f));
+ raw.push_back((uint8_t)(color[3] * 255.0f));
break;
case VK_FORMAT_B8G8R8A8_UNORM:
- raw.push_back(color[2] * 255.0f);
- raw.push_back(color[1] * 255.0f);
- raw.push_back(color[0] * 255.0f);
- raw.push_back(color[3] * 255.0f);
+ raw.push_back((uint8_t)(color[2] * 255.0f));
+ raw.push_back((uint8_t)(color[1] * 255.0f));
+ raw.push_back((uint8_t)(color[0] * 255.0f));
+ raw.push_back((uint8_t)(color[3] * 255.0f));
break;
default:
break;
@@ -1425,7 +1425,7 @@
case VK_FORMAT_D16_UNORM:
case VK_FORMAT_D16_UNORM_S8_UINT:
{
- const uint16_t unorm = depth * 65535.0f;
+ const uint16_t unorm = (uint16_t)(depth * 65535.0f);
raw.push_back(unorm & 0xff);
raw.push_back(unorm >> 8);
}
diff --git a/tests/render_tests.cpp b/tests/render_tests.cpp
index b7472e9..911fded 100644
--- a/tests/render_tests.cpp
+++ b/tests/render_tests.cpp
@@ -1831,7 +1831,7 @@
ASSERT_NO_FATAL_FAILURE(InitState());
ASSERT_NO_FATAL_FAILURE(InitViewport());
- m_depthStencil->Init(m_device, m_width, m_height);
+ m_depthStencil->Init(m_device, (int32_t)m_width, (int32_t)m_height);
VkConstantBufferObj meshBuffer(m_device,sizeof(g_vb_solid_face_colors_Data)/sizeof(g_vb_solid_face_colors_Data[0]),
sizeof(g_vb_solid_face_colors_Data[0]), g_vb_solid_face_colors_Data);
@@ -2604,7 +2604,7 @@
ASSERT_NO_FATAL_FAILURE(InitState());
ASSERT_NO_FATAL_FAILURE(InitViewport());
- m_depthStencil->Init(m_device, m_width, m_height);
+ m_depthStencil->Init(m_device, (int32_t)m_width, (int32_t)m_height);
VkConstantBufferObj meshBuffer(m_device, num_verts,
sizeof(g_vb_texture_Data[0]), g_vb_texture_Data);
diff --git a/tests/vkrenderframework.cpp b/tests/vkrenderframework.cpp
index 071e117..bbdf20e 100644
--- a/tests/vkrenderframework.cpp
+++ b/tests/vkrenderframework.cpp
@@ -179,8 +179,8 @@
viewport.height = 1.f * height;
viewport.minDepth = 0.f;
viewport.maxDepth = 1.f;
- scissor.extent.width = width;
- scissor.extent.height = height;
+ scissor.extent.width = (int32_t) width;
+ scissor.extent.height = (int32_t) height;
scissor.offset.x = 0;
scissor.offset.y = 0;
viewportCreate.pViewports = &viewport;
@@ -232,11 +232,11 @@
ASSERT_VK_SUCCESS(err);
if (props.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
- img->init(m_width, m_height, m_render_target_fmt,
+ img->init((uint32_t)m_width, (uint32_t)m_height, m_render_target_fmt,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_LINEAR);
}
else if (props.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) {
- img->init(m_width, m_height, m_render_target_fmt,
+ img->init((uint32_t)m_width, (uint32_t)m_height, m_render_target_fmt,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL);
}
else {
@@ -267,8 +267,8 @@
VkRenderPassCreateInfo rp_info = {};
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
- rp_info.renderArea.extent.width = m_width;
- rp_info.renderArea.extent.height = m_height;
+ rp_info.renderArea.extent.width = (uint32_t) m_width;
+ rp_info.renderArea.extent.height = (uint32_t) m_height;
rp_info.colorAttachmentCount = m_renderTargets.size();
rp_info.pColorFormats = &m_render_target_fmt;
@@ -741,7 +741,7 @@
samplerCreateInfo.addressV = VK_TEX_ADDRESS_WRAP;
samplerCreateInfo.addressW = VK_TEX_ADDRESS_WRAP;
samplerCreateInfo.mipLodBias = 0.0;
- samplerCreateInfo.maxAnisotropy = 0.0;
+ samplerCreateInfo.maxAnisotropy = 0;
samplerCreateInfo.compareOp = VK_COMPARE_OP_NEVER;
samplerCreateInfo.minLod = 0.0;
samplerCreateInfo.maxLod = 0.0;
diff --git a/tests/vktestbinding.cpp b/tests/vktestbinding.cpp
index 78aaef1..618f185 100644
--- a/tests/vktestbinding.cpp
+++ b/tests/vktestbinding.cpp
@@ -418,10 +418,10 @@
&data_size, queue_props);
EXPECT(err == VK_SUCCESS);
- for (int i = 0; i < queue_node_count; i++) {
+ for (uint32_t i = 0; i < queue_node_count; i++) {
VkQueue queue;
- for (int j = 0; j < queue_props[i].queueCount; j++) {
+ for (uint32_t j = 0; j < queue_props[i].queueCount; j++) {
// TODO: Need to add support for separate MEMMGR and work queues, including synchronization
err = vkGetDeviceQueue(obj(), i, j, &queue);
EXPECT(err == VK_SUCCESS);
diff --git a/tests/vktestframework.cpp b/tests/vktestframework.cpp
index 24b76a6..85e56fb 100644
--- a/tests/vktestframework.cpp
+++ b/tests/vktestframework.cpp
@@ -91,8 +91,8 @@
bool m_quit;
bool m_pause;
- uint32_t m_width;
- uint32_t m_height;
+ int m_width;
+ int m_height;
std::list<VkTestImageRecord>::iterator m_display_image;
@@ -236,7 +236,7 @@
{
string filename;
VkResult err;
- int x, y;
+ uint32_t x, y;
VkImageObj displayImage(image->device());
VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
@@ -319,14 +319,14 @@
magick_wand_1=NewMagickWand();
sprintf(testimage,"%s.ppm",basename);
status=MagickReadImage(magick_wand_1,testimage);
- ASSERT_TRUE(status) << "Unable to open file: " << testimage;
+ ASSERT_EQ(status, MagickTrue) << "Unable to open file: " << testimage;
MagickWandGenesis();
magick_wand_2=NewMagickWand();
sprintf(golden,"%s/%s.ppm",golddir,basename);
status=MagickReadImage(magick_wand_2,golden);
- ASSERT_TRUE(status) << "Unable to open file: " << golden;
+ ASSERT_EQ(status, MagickTrue) << "Unable to open file: " << golden;
compare_wand=MagickCompareImages(magick_wand_1,magick_wand_2, MeanAbsoluteErrorMetric, &differenz);
if (differenz != 0.0)