Browse Source

Vk: don't use VK_STRUCTURE_TYPE_APPLICATION_INFO for sType in tests.

The problem is that, of all structure type enums, this one is 0, and
thus doesn't check for accidentally zeroed-out memory.
pull/491/head
Vladimír Vondruš 5 years ago
parent
commit
349dc77322
  1. 8
      src/Magnum/Vk/Test/MemoryTest.cpp
  2. 24
      src/Magnum/Vk/Test/RenderPassTest.cpp

8
src/Magnum/Vk/Test/MemoryTest.cpp

@ -77,9 +77,9 @@ MemoryTest::MemoryTest() {
void MemoryTest::requirementsConstructNoInit() { void MemoryTest::requirementsConstructNoInit() {
MemoryRequirements requirements{NoInit}; MemoryRequirements requirements{NoInit};
requirements->sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; requirements->sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
new(&requirements) MemoryRequirements{NoInit}; new(&requirements) MemoryRequirements{NoInit};
CORRADE_COMPARE(requirements->sType, VK_STRUCTURE_TYPE_APPLICATION_INFO); CORRADE_COMPARE(requirements->sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
CORRADE_VERIFY((std::is_nothrow_constructible<MemoryRequirements, NoInitT>::value)); CORRADE_VERIFY((std::is_nothrow_constructible<MemoryRequirements, NoInitT>::value));
@ -89,10 +89,10 @@ void MemoryTest::requirementsConstructNoInit() {
void MemoryTest::requirementsConstructFromVk() { void MemoryTest::requirementsConstructFromVk() {
VkMemoryRequirements2 vkRequirements; VkMemoryRequirements2 vkRequirements;
vkRequirements.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; vkRequirements.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
MemoryRequirements requirements{vkRequirements}; MemoryRequirements requirements{vkRequirements};
CORRADE_COMPARE(requirements->sType, VK_STRUCTURE_TYPE_APPLICATION_INFO); CORRADE_COMPARE(requirements->sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
} }
void MemoryTest::requirementsAlignedSize() { void MemoryTest::requirementsAlignedSize() {

24
src/Magnum/Vk/Test/RenderPassTest.cpp

@ -283,9 +283,9 @@ void RenderPassTest::attachmentDescriptionConstructImplicitLoadStoreLayout() {
void RenderPassTest::attachmentDescriptionConstructNoInit() { void RenderPassTest::attachmentDescriptionConstructNoInit() {
AttachmentDescription description{NoInit}; AttachmentDescription description{NoInit};
description->sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; description->sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
new(&description) AttachmentDescription{NoInit}; new(&description) AttachmentDescription{NoInit};
CORRADE_COMPARE(description->sType, VK_STRUCTURE_TYPE_APPLICATION_INFO); CORRADE_COMPARE(description->sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
CORRADE_VERIFY((std::is_nothrow_constructible<AttachmentDescription, NoInitT>::value)); CORRADE_VERIFY((std::is_nothrow_constructible<AttachmentDescription, NoInitT>::value));
@ -354,9 +354,9 @@ void RenderPassTest::attachmentReferenceConstructUnused() {
void RenderPassTest::attachmentReferenceConstructNoInit() { void RenderPassTest::attachmentReferenceConstructNoInit() {
AttachmentReference reference{NoInit}; AttachmentReference reference{NoInit};
reference->sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; reference->sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
new(&reference) AttachmentReference{NoInit}; new(&reference) AttachmentReference{NoInit};
CORRADE_COMPARE(reference->sType, VK_STRUCTURE_TYPE_APPLICATION_INFO); CORRADE_COMPARE(reference->sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
CORRADE_VERIFY((std::is_nothrow_constructible<AttachmentReference, NoInitT>::value)); CORRADE_VERIFY((std::is_nothrow_constructible<AttachmentReference, NoInitT>::value));
@ -402,9 +402,9 @@ void RenderPassTest::subpassDescriptionConstruct() {
void RenderPassTest::subpassDescriptionConstructNoInit() { void RenderPassTest::subpassDescriptionConstructNoInit() {
SubpassDescription description{NoInit}; SubpassDescription description{NoInit};
description->sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; description->sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
new(&description) SubpassDescription{NoInit}; new(&description) SubpassDescription{NoInit};
CORRADE_COMPARE(description->sType, VK_STRUCTURE_TYPE_APPLICATION_INFO); CORRADE_COMPARE(description->sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
CORRADE_VERIFY((std::is_nothrow_constructible<SubpassDescription, NoInitT>::value)); CORRADE_VERIFY((std::is_nothrow_constructible<SubpassDescription, NoInitT>::value));
@ -691,9 +691,9 @@ void RenderPassTest::subpassDescriptionRvalue() {
void RenderPassTest::subpassDependencyConstructNoInit() { void RenderPassTest::subpassDependencyConstructNoInit() {
SubpassDependency dependency{NoInit}; SubpassDependency dependency{NoInit};
dependency->sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; dependency->sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
new(&dependency) SubpassDependency{NoInit}; new(&dependency) SubpassDependency{NoInit};
CORRADE_COMPARE(dependency->sType, VK_STRUCTURE_TYPE_APPLICATION_INFO); CORRADE_COMPARE(dependency->sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
CORRADE_VERIFY((std::is_nothrow_constructible<SubpassDependency, NoInitT>::value)); CORRADE_VERIFY((std::is_nothrow_constructible<SubpassDependency, NoInitT>::value));
@ -744,9 +744,9 @@ void RenderPassTest::createInfoConstruct() {
void RenderPassTest::createInfoConstructNoInit() { void RenderPassTest::createInfoConstructNoInit() {
RenderPassCreateInfo info{NoInit}; RenderPassCreateInfo info{NoInit};
info->sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; info->sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
new(&info) RenderPassCreateInfo{NoInit}; new(&info) RenderPassCreateInfo{NoInit};
CORRADE_COMPARE(info->sType, VK_STRUCTURE_TYPE_APPLICATION_INFO); CORRADE_COMPARE(info->sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
CORRADE_VERIFY((std::is_nothrow_constructible<RenderPassCreateInfo, NoInitT>::value)); CORRADE_VERIFY((std::is_nothrow_constructible<RenderPassCreateInfo, NoInitT>::value));
@ -798,7 +798,7 @@ void RenderPassTest::createInfoConstructDependencies() {
RenderPassCreateInfo info; RenderPassCreateInfo info;
/** @todo update once we have a real API */ /** @todo update once we have a real API */
VkSubpassDependency2 a{}; VkSubpassDependency2 a{};
a.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; a.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
VkSubpassDependency2 b{}; VkSubpassDependency2 b{};
b.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; b.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
info.setDependencies({ info.setDependencies({
@ -807,7 +807,7 @@ void RenderPassTest::createInfoConstructDependencies() {
}); });
CORRADE_COMPARE(info->dependencyCount, 2); CORRADE_COMPARE(info->dependencyCount, 2);
CORRADE_VERIFY(info->pDependencies); CORRADE_VERIFY(info->pDependencies);
CORRADE_COMPARE(info->pDependencies[0].sType, VK_STRUCTURE_TYPE_APPLICATION_INFO); CORRADE_COMPARE(info->pDependencies[0].sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
CORRADE_COMPARE(info->pDependencies[1].sType, VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO); CORRADE_COMPARE(info->pDependencies[1].sType, VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
} }

Loading…
Cancel
Save