diff --git a/src/Magnum/Vk/Memory.cpp b/src/Magnum/Vk/Memory.cpp index 843a05555..62d38fb59 100644 --- a/src/Magnum/Vk/Memory.cpp +++ b/src/Magnum/Vk/Memory.cpp @@ -102,7 +102,7 @@ Memory& Memory::operator=(Memory&& other) noexcept { Containers::Array Memory::map(const UnsignedLong offset, const UnsignedLong size) { void* data; MAGNUM_VK_INTERNAL_ASSERT_SUCCESS((**_device).MapMemory(*_device, _handle, offset, size, {}, &data)); - return Containers::Array{static_cast(data), size, MemoryMapDeleter{(**_device).UnmapMemory, *_device, _handle}}; + return Containers::Array{static_cast(data), std::size_t(size), MemoryMapDeleter{(**_device).UnmapMemory, *_device, _handle}}; } Containers::Array Memory::map() { @@ -117,7 +117,7 @@ Containers::Array Memory::mapRead(const UnsignedLo the order of operations is unspecified and the deleter could be queried after release() got called */ const MemoryMapDeleter deleter = out.deleter(); - return Containers::Array{out.release(), size, deleter}; + return Containers::Array{out.release(), std::size_t(size), deleter}; } Containers::Array Memory::mapRead() { diff --git a/src/Magnum/Vk/Test/BufferTest.cpp b/src/Magnum/Vk/Test/BufferTest.cpp index 1a95326b3..95c63da81 100644 --- a/src/Magnum/Vk/Test/BufferTest.cpp +++ b/src/Magnum/Vk/Test/BufferTest.cpp @@ -221,8 +221,10 @@ void BufferTest::bufferCopyConvertDisallowed() { } void BufferTest::copyBufferInfoConstruct() { - auto a = reinterpret_cast(0xdead); - auto b = reinterpret_cast(0xcafe); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + auto a = reinterpret_cast(reinterpret_cast(0xdead)); + auto b = reinterpret_cast(reinterpret_cast(0xcafe)); CopyBufferInfo info{a, b, { {3, 0, 0}, diff --git a/src/Magnum/Vk/Test/DescriptorSetLayoutTest.cpp b/src/Magnum/Vk/Test/DescriptorSetLayoutTest.cpp index db9aa3af9..1c0f3ced7 100644 --- a/src/Magnum/Vk/Test/DescriptorSetLayoutTest.cpp +++ b/src/Magnum/Vk/Test/DescriptorSetLayoutTest.cpp @@ -109,14 +109,16 @@ void DescriptorSetLayoutTest::bindingConstructFlags() { } void DescriptorSetLayoutTest::bindingConstructImmutableSamplers() { - DescriptorSetLayoutBinding binding{15, DescriptorType::SampledImage, {reinterpret_cast(0xdead), reinterpret_cast(0xbeef), reinterpret_cast(0xcafe)}, ShaderStage::Fragment, DescriptorSetLayoutBinding::Flag::UpdateAfterBind}; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + DescriptorSetLayoutBinding binding{15, DescriptorType::SampledImage, {reinterpret_cast(reinterpret_cast(0xdead)), reinterpret_cast(reinterpret_cast(0xbeef)), reinterpret_cast(reinterpret_cast(0xcafe))}, ShaderStage::Fragment, DescriptorSetLayoutBinding::Flag::UpdateAfterBind}; CORRADE_COMPARE(binding->binding, 15); CORRADE_COMPARE(binding->descriptorType, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE); CORRADE_COMPARE(binding->descriptorCount, 3); CORRADE_VERIFY(binding->pImmutableSamplers); - CORRADE_COMPARE(binding->pImmutableSamplers[0], reinterpret_cast(0xdead)); - CORRADE_COMPARE(binding->pImmutableSamplers[1], reinterpret_cast(0xbeef)); - CORRADE_COMPARE(binding->pImmutableSamplers[2], reinterpret_cast(0xcafe)); + CORRADE_COMPARE(binding->pImmutableSamplers[0], reinterpret_cast(reinterpret_cast(0xdead))); + CORRADE_COMPARE(binding->pImmutableSamplers[1], reinterpret_cast(reinterpret_cast(0xbeef))); + CORRADE_COMPARE(binding->pImmutableSamplers[2], reinterpret_cast(reinterpret_cast(0xcafe))); CORRADE_COMPARE(binding->stageFlags, VK_SHADER_STAGE_FRAGMENT_BIT); CORRADE_COMPARE(binding.flags(), VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT); } @@ -150,16 +152,18 @@ void DescriptorSetLayoutTest::bindingConstructCopy() { } void DescriptorSetLayoutTest::bindingConstructMove() { - DescriptorSetLayoutBinding a{15, DescriptorType::SampledImage, {reinterpret_cast(0xdead), reinterpret_cast(0xbeef), reinterpret_cast(0xcafe)}, ShaderStage::Fragment, DescriptorSetLayoutBinding::Flag::UpdateAfterBind}; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + DescriptorSetLayoutBinding a{15, DescriptorType::SampledImage, {reinterpret_cast(reinterpret_cast(0xdead)), reinterpret_cast(reinterpret_cast(0xbeef)), reinterpret_cast(reinterpret_cast(0xcafe))}, ShaderStage::Fragment, DescriptorSetLayoutBinding::Flag::UpdateAfterBind}; CORRADE_COMPARE(a->descriptorCount, 3); CORRADE_VERIFY(a->pImmutableSamplers); - CORRADE_COMPARE(a->pImmutableSamplers[1], reinterpret_cast(0xbeef)); + CORRADE_COMPARE(a->pImmutableSamplers[1], reinterpret_cast(reinterpret_cast(0xbeef))); DescriptorSetLayoutBinding b = std::move(a); CORRADE_VERIFY(!a->pImmutableSamplers); CORRADE_COMPARE(b->descriptorCount, 3); CORRADE_VERIFY(b->pImmutableSamplers); - CORRADE_COMPARE(b->pImmutableSamplers[1], reinterpret_cast(0xbeef)); + CORRADE_COMPARE(b->pImmutableSamplers[1], reinterpret_cast(reinterpret_cast(0xbeef))); CORRADE_COMPARE(b.flags(), VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT); DescriptorSetLayoutBinding c{3, {}}; @@ -167,7 +171,7 @@ void DescriptorSetLayoutTest::bindingConstructMove() { CORRADE_VERIFY(!b->pImmutableSamplers); CORRADE_COMPARE(c->descriptorCount, 3); CORRADE_VERIFY(c->pImmutableSamplers); - CORRADE_COMPARE(c->pImmutableSamplers[1], reinterpret_cast(0xbeef)); + CORRADE_COMPARE(c->pImmutableSamplers[1], reinterpret_cast(reinterpret_cast(0xbeef))); CORRADE_COMPARE(c.flags(), VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT); } @@ -212,12 +216,14 @@ void DescriptorSetLayoutTest::createInfoConstructBindingFlags() { } void DescriptorSetLayoutTest::createInfoConstructBindingImmutableSamplers() { - DescriptorSetLayoutBinding binding{3, DescriptorType::Sampler, {reinterpret_cast(0xdead), reinterpret_cast(0xbeef)}}; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + DescriptorSetLayoutBinding binding{3, DescriptorType::Sampler, {reinterpret_cast(reinterpret_cast(0xdead)), reinterpret_cast(reinterpret_cast(0xbeef))}}; DescriptorSetLayoutCreateInfo info{{ {{7, DescriptorType::UniformBuffer}}, binding, - {{12, DescriptorType::CombinedImageSampler, {reinterpret_cast(0xcafe)}}}, + {{12, DescriptorType::CombinedImageSampler, {reinterpret_cast(reinterpret_cast(0xcafe))}}}, }}; CORRADE_COMPARE(info->bindingCount, 3); CORRADE_VERIFY(info->pBindings); @@ -233,14 +239,14 @@ void DescriptorSetLayoutTest::createInfoConstructBindingImmutableSamplers() { CORRADE_VERIFY(info->pBindings[1].pImmutableSamplers); /* The samplers should get copied, not referenced */ CORRADE_VERIFY(info->pBindings[1].pImmutableSamplers != binding->pImmutableSamplers); - CORRADE_COMPARE(info->pBindings[1].pImmutableSamplers[0], reinterpret_cast(0xdead)); - CORRADE_COMPARE(info->pBindings[1].pImmutableSamplers[1], reinterpret_cast(0xbeef)); + CORRADE_COMPARE(info->pBindings[1].pImmutableSamplers[0], reinterpret_cast(reinterpret_cast(0xdead))); + CORRADE_COMPARE(info->pBindings[1].pImmutableSamplers[1], reinterpret_cast(reinterpret_cast(0xbeef))); CORRADE_COMPARE(info->pBindings[2].binding, 12); CORRADE_COMPARE(info->pBindings[2].descriptorType, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER); CORRADE_COMPARE(info->pBindings[2].descriptorCount, 1); CORRADE_VERIFY(info->pBindings[2].pImmutableSamplers); - CORRADE_COMPARE(info->pBindings[2].pImmutableSamplers[0], reinterpret_cast(0xcafe)); + CORRADE_COMPARE(info->pBindings[2].pImmutableSamplers[0], reinterpret_cast(reinterpret_cast(0xcafe))); CORRADE_VERIFY(!info->pNext); } diff --git a/src/Magnum/Vk/Test/FramebufferTest.cpp b/src/Magnum/Vk/Test/FramebufferTest.cpp index 279fa3c42..b225cc6c3 100644 --- a/src/Magnum/Vk/Test/FramebufferTest.cpp +++ b/src/Magnum/Vk/Test/FramebufferTest.cpp @@ -61,42 +61,46 @@ FramebufferTest::FramebufferTest() { } void FramebufferTest::createInfoConstruct() { + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ Device device{NoCreate}; - auto renderPass = reinterpret_cast(0xdeadbeef); - auto a = ImageView::wrap(device, reinterpret_cast(0xcafe1), {}); - auto b = ImageView::wrap(device, reinterpret_cast(0xcafe2), {}); - auto c = ImageView::wrap(device, reinterpret_cast(0xcafe3), {}); + auto renderPass = reinterpret_cast(reinterpret_cast(0xdeadbeef)); + auto a = ImageView::wrap(device, reinterpret_cast(reinterpret_cast(0xcafe1)), {}); + auto b = ImageView::wrap(device, reinterpret_cast(reinterpret_cast(0xcafe2)), {}); + auto c = ImageView::wrap(device, reinterpret_cast(reinterpret_cast(0xcafe3)), {}); /** @todo use a real flag once it exists */ FramebufferCreateInfo info{renderPass, {a, b, c}, {256, 512}, FramebufferCreateInfo::Flag(0xbadda9)}; CORRADE_COMPARE(info->flags, 0xbadda9); - CORRADE_COMPARE(info->renderPass, reinterpret_cast(0xdeadbeef)); + CORRADE_COMPARE(info->renderPass, reinterpret_cast(reinterpret_cast(0xdeadbeef))); CORRADE_COMPARE(info->attachmentCount, 3); CORRADE_VERIFY(info->pAttachments); - CORRADE_COMPARE(info->pAttachments[0], reinterpret_cast(0xcafe1)); - CORRADE_COMPARE(info->pAttachments[1], reinterpret_cast(0xcafe2)); - CORRADE_COMPARE(info->pAttachments[2], reinterpret_cast(0xcafe3)); + CORRADE_COMPARE(info->pAttachments[0], reinterpret_cast(reinterpret_cast(0xcafe1))); + CORRADE_COMPARE(info->pAttachments[1], reinterpret_cast(reinterpret_cast(0xcafe2))); + CORRADE_COMPARE(info->pAttachments[2], reinterpret_cast(reinterpret_cast(0xcafe3))); CORRADE_COMPARE(info->width, 256); CORRADE_COMPARE(info->height, 512); CORRADE_COMPARE(info->layers, 1); } void FramebufferTest::createInfoConstructLayered() { + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ Device device{NoCreate}; - auto renderPass = reinterpret_cast(0xdeadbeef); - auto a = ImageView::wrap(device, reinterpret_cast(0xcafe1), {}); - auto b = ImageView::wrap(device, reinterpret_cast(0xcafe2), {}); - auto c = ImageView::wrap(device, reinterpret_cast(0xcafe3), {}); + auto renderPass = reinterpret_cast(reinterpret_cast(0xdeadbeef)); + auto a = ImageView::wrap(device, reinterpret_cast(reinterpret_cast(0xcafe1)), {}); + auto b = ImageView::wrap(device, reinterpret_cast(reinterpret_cast(0xcafe2)), {}); + auto c = ImageView::wrap(device, reinterpret_cast(reinterpret_cast(0xcafe3)), {}); /** @todo use a real flag once it exists */ FramebufferCreateInfo info{renderPass, {a, b, c}, {256, 512, 5}, FramebufferCreateInfo::Flag(0xbadda9)}; CORRADE_COMPARE(info->flags, 0xbadda9); - CORRADE_COMPARE(info->renderPass, reinterpret_cast(0xdeadbeef)); + CORRADE_COMPARE(info->renderPass, reinterpret_cast(reinterpret_cast(0xdeadbeef))); CORRADE_COMPARE(info->attachmentCount, 3); CORRADE_VERIFY(info->pAttachments); - CORRADE_COMPARE(info->pAttachments[0], reinterpret_cast(0xcafe1)); - CORRADE_COMPARE(info->pAttachments[1], reinterpret_cast(0xcafe2)); - CORRADE_COMPARE(info->pAttachments[2], reinterpret_cast(0xcafe3)); + CORRADE_COMPARE(info->pAttachments[0], reinterpret_cast(reinterpret_cast(0xcafe1))); + CORRADE_COMPARE(info->pAttachments[1], reinterpret_cast(reinterpret_cast(0xcafe2))); + CORRADE_COMPARE(info->pAttachments[2], reinterpret_cast(reinterpret_cast(0xcafe3))); CORRADE_COMPARE(info->width, 256); CORRADE_COMPARE(info->height, 512); CORRADE_COMPARE(info->layers, 5); @@ -128,28 +132,30 @@ void FramebufferTest::createInfoConstructCopy() { } void FramebufferTest::createInfoConstructMove() { + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ Device device{NoCreate}; - auto renderPass = reinterpret_cast(0xdeadbeef); - auto view = ImageView::wrap(device, reinterpret_cast(0xcafe), {}); + auto renderPass = reinterpret_cast(reinterpret_cast(0xdeadbeef)); + auto view = ImageView::wrap(device, reinterpret_cast(reinterpret_cast(0xcafe)), {}); FramebufferCreateInfo a{renderPass, {view}, {256, 512}}; FramebufferCreateInfo b = std::move(a); CORRADE_COMPARE(a->attachmentCount, 0); CORRADE_VERIFY(!a->pAttachments); - CORRADE_COMPARE(b->renderPass, reinterpret_cast(0xdeadbeef)); + CORRADE_COMPARE(b->renderPass, reinterpret_cast(reinterpret_cast(0xdeadbeef))); CORRADE_COMPARE(b->attachmentCount, 1); CORRADE_VERIFY(b->pAttachments); - CORRADE_COMPARE(b->pAttachments[0], reinterpret_cast(0xcafe)); + CORRADE_COMPARE(b->pAttachments[0], reinterpret_cast(reinterpret_cast(0xcafe))); FramebufferCreateInfo c{VkFramebufferCreateInfo{}}; c = std::move(b); CORRADE_COMPARE(b->attachmentCount, 0); CORRADE_VERIFY(!b->pAttachments); - CORRADE_COMPARE(c->renderPass, reinterpret_cast(0xdeadbeef)); + CORRADE_COMPARE(c->renderPass, reinterpret_cast(reinterpret_cast(0xdeadbeef))); CORRADE_COMPARE(c->attachmentCount, 1); CORRADE_VERIFY(c->pAttachments); - CORRADE_COMPARE(c->pAttachments[0], reinterpret_cast(0xcafe)); + CORRADE_COMPARE(c->pAttachments[0], reinterpret_cast(reinterpret_cast(0xcafe))); CORRADE_VERIFY(std::is_nothrow_move_constructible::value); CORRADE_VERIFY(std::is_nothrow_move_assignable::value); diff --git a/src/Magnum/Vk/Test/ImageTest.cpp b/src/Magnum/Vk/Test/ImageTest.cpp index 1013fcf0a..ebc955dc7 100644 --- a/src/Magnum/Vk/Test/ImageTest.cpp +++ b/src/Magnum/Vk/Test/ImageTest.cpp @@ -485,8 +485,10 @@ void ImageTest::imageCopyConvertDisallowed() { } void ImageTest::copyImageInfoConstruct() { - auto a = reinterpret_cast(0xdead); - auto b = reinterpret_cast(0xcafe); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + auto a = reinterpret_cast(reinterpret_cast(0xdead)); + auto b = reinterpret_cast(reinterpret_cast(0xcafe)); CopyImageInfo info{a, ImageLayout::Preinitialized, b, ImageLayout::General, { {ImageAspect::Color, 3, 0, 0, {}, 0, 0, 0, {}, {}}, @@ -720,8 +722,10 @@ void ImageTest::bufferImageCopyConvertDisallowed() { } void ImageTest::copyBufferToImageInfoConstruct() { - auto a = reinterpret_cast(0xdead); - auto b = reinterpret_cast(0xcafe); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + auto a = reinterpret_cast(reinterpret_cast(0xdead)); + auto b = reinterpret_cast(reinterpret_cast(0xcafe)); CopyBufferToImageInfo info{a, b, ImageLayout::TransferDestination, { BufferImageCopy1D{5, ImageAspect::Color, 0, {}}, @@ -773,8 +777,10 @@ void ImageTest::copyBufferToImageInfoConvertToVk() { } void ImageTest::copyImageToBufferInfoConstruct() { - auto a = reinterpret_cast(0xcafe); - auto b = reinterpret_cast(0xdead); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + auto a = reinterpret_cast(reinterpret_cast(0xcafe)); + auto b = reinterpret_cast(reinterpret_cast(0xdead)); CopyImageToBufferInfo info{a, ImageLayout::TransferSource, b, { BufferImageCopy1D{5, ImageAspect::Color, 0, {}}, diff --git a/src/Magnum/Vk/Test/ImageViewTest.cpp b/src/Magnum/Vk/Test/ImageViewTest.cpp index 257397cdc..e2d238ebb 100644 --- a/src/Magnum/Vk/Test/ImageViewTest.cpp +++ b/src/Magnum/Vk/Test/ImageViewTest.cpp @@ -107,7 +107,9 @@ ImageViewTest::ImageViewTest() { &ImageViewTest::constructCopy}); } -const VkImage imageHandle{reinterpret_cast(0xdeadbeef)}; +/* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ +const VkImage imageHandle{reinterpret_cast(reinterpret_cast(0xdeadbeef))}; template void ImageViewTest::createInfoConstruct() { /** @todo use a real flag once it exists */ diff --git a/src/Magnum/Vk/Test/MeshTest.cpp b/src/Magnum/Vk/Test/MeshTest.cpp index 0734c0995..4a4bce6f2 100644 --- a/src/Magnum/Vk/Test/MeshTest.cpp +++ b/src/Magnum/Vk/Test/MeshTest.cpp @@ -184,9 +184,11 @@ void MeshTest::addVertexBuffer() { 0, 0 }), TestSuite::Compare::Container); - mesh.addVertexBuffer(5, reinterpret_cast(0xdead), 15); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + mesh.addVertexBuffer(5, reinterpret_cast(reinterpret_cast(0xdead)), 15); CORRADE_COMPARE_AS(mesh.vertexBuffers(), Containers::arrayView({ - VkBuffer{}, reinterpret_cast(0xdead) + VkBuffer{}, reinterpret_cast(reinterpret_cast(0xdead)) }), TestSuite::Compare::Container); CORRADE_COMPARE_AS(mesh.vertexBufferOffsets(), Containers::arrayView({ 0, 15 @@ -195,9 +197,10 @@ void MeshTest::addVertexBuffer() { 0, 3 }), TestSuite::Compare::Container); - mesh.addVertexBuffer(1, reinterpret_cast(0xbeef), 37); + mesh.addVertexBuffer(1, reinterpret_cast(reinterpret_cast(0xbeef)), 37); CORRADE_COMPARE_AS(mesh.vertexBuffers(), Containers::arrayView({ - reinterpret_cast(0xbeef), reinterpret_cast(0xdead) + reinterpret_cast(reinterpret_cast(0xbeef)), + reinterpret_cast(reinterpret_cast(0xdead)) }), TestSuite::Compare::Container); CORRADE_COMPARE_AS(mesh.vertexBufferOffsets(), Containers::arrayView({ 37, 15 @@ -213,16 +216,19 @@ void MeshTest::addVertexBufferOwned() { .addInstancedBinding(5, 3) }; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ Device device{NoCreate}; - Buffer a = Buffer::wrap(device, reinterpret_cast(0xdead)); - Buffer b = Buffer::wrap(device, reinterpret_cast(0xbeef)); + Buffer a = Buffer::wrap(device, reinterpret_cast(reinterpret_cast(0xdead))); + Buffer b = Buffer::wrap(device, reinterpret_cast(reinterpret_cast(0xbeef))); mesh.addVertexBuffer(5, std::move(a), 15) .addVertexBuffer(1, std::move(b), 37); CORRADE_VERIFY(!a.handle()); CORRADE_VERIFY(!b.handle()); CORRADE_COMPARE_AS(mesh.vertexBuffers(), Containers::arrayView({ - reinterpret_cast(0xbeef), reinterpret_cast(0xdead) + reinterpret_cast(reinterpret_cast(0xbeef)), + reinterpret_cast(reinterpret_cast(0xdead)) }), TestSuite::Compare::Container); CORRADE_COMPARE_AS(mesh.vertexBufferOffsets(), Containers::arrayView({ 37, 15 @@ -257,9 +263,11 @@ template void MeshTest::setIndexBuffer() { Mesh mesh{MeshLayout{MeshPrimitive::Triangles}}; CORRADE_VERIFY(!mesh.isIndexed()); - mesh.setIndexBuffer(reinterpret_cast(0xdead), 15, T::UnsignedByte); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + mesh.setIndexBuffer(reinterpret_cast(reinterpret_cast(0xdead)), 15, T::UnsignedByte); CORRADE_VERIFY(mesh.isIndexed()); - CORRADE_COMPARE(mesh.indexBuffer(), reinterpret_cast(0xdead)); + CORRADE_COMPARE(mesh.indexBuffer(), reinterpret_cast(reinterpret_cast(0xdead))); CORRADE_COMPARE(mesh.indexBufferOffset(), 15); CORRADE_COMPARE(mesh.indexType(), MeshIndexType::UnsignedByte); } @@ -267,14 +275,16 @@ template void MeshTest::setIndexBuffer() { template void MeshTest::setIndexBufferOwned() { setTestCaseTemplateName(IndexTypeTraits::name()); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ Device device{NoCreate}; - Buffer a = Buffer::wrap(device, reinterpret_cast(0xdead)); + Buffer a = Buffer::wrap(device, reinterpret_cast(reinterpret_cast(0xdead))); Mesh mesh{MeshLayout{MeshPrimitive::Triangles}}; mesh.setIndexBuffer(std::move(a), 15, T::UnsignedByte); CORRADE_VERIFY(!a.handle()); CORRADE_VERIFY(mesh.isIndexed()); - CORRADE_COMPARE(mesh.indexBuffer(), reinterpret_cast(0xdead)); + CORRADE_COMPARE(mesh.indexBuffer(), reinterpret_cast(reinterpret_cast(0xdead))); CORRADE_COMPARE(mesh.indexBufferOffset(), 15); CORRADE_COMPARE(mesh.indexType(), MeshIndexType::UnsignedByte); } diff --git a/src/Magnum/Vk/Test/PipelineLayoutTest.cpp b/src/Magnum/Vk/Test/PipelineLayoutTest.cpp index 62344f245..4c5cfbc1a 100644 --- a/src/Magnum/Vk/Test/PipelineLayoutTest.cpp +++ b/src/Magnum/Vk/Test/PipelineLayoutTest.cpp @@ -64,15 +64,17 @@ void PipelineLayoutTest::createInfoConstruct() { } void PipelineLayoutTest::createInfoConstructDescriptorSetLayouts() { - VkDescriptorSetLayout layouts[]{reinterpret_cast(0xdead), reinterpret_cast(0xbeef)}; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + VkDescriptorSetLayout layouts[]{reinterpret_cast(reinterpret_cast(0xdead)), reinterpret_cast(reinterpret_cast(0xbeef))}; PipelineLayoutCreateInfo info{layouts}; CORRADE_COMPARE(info->setLayoutCount, 2); CORRADE_VERIFY(info->pSetLayouts); /* The contents should be copied */ CORRADE_VERIFY(info->pSetLayouts != layouts); - CORRADE_COMPARE(info->pSetLayouts[0], reinterpret_cast(0xdead)); - CORRADE_COMPARE(info->pSetLayouts[1], reinterpret_cast(0xbeef)); + CORRADE_COMPARE(info->pSetLayouts[0], reinterpret_cast(reinterpret_cast(0xdead))); + CORRADE_COMPARE(info->pSetLayouts[1], reinterpret_cast(reinterpret_cast(0xbeef))); } void PipelineLayoutTest::createInfoConstructNoInit() { @@ -101,7 +103,9 @@ void PipelineLayoutTest::createInfoConstructCopy() { } void PipelineLayoutTest::createInfoConstructMove() { - PipelineLayoutCreateInfo a{reinterpret_cast(0xdead), reinterpret_cast(0xbeef)}; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + PipelineLayoutCreateInfo a{reinterpret_cast(reinterpret_cast(0xdead)), reinterpret_cast(reinterpret_cast(0xbeef))}; CORRADE_COMPARE(a->setLayoutCount, 2); CORRADE_VERIFY(a->pSetLayouts); @@ -110,7 +114,7 @@ void PipelineLayoutTest::createInfoConstructMove() { CORRADE_VERIFY(!a->pSetLayouts); CORRADE_COMPARE(b->setLayoutCount, 2); CORRADE_VERIFY(b->pSetLayouts); - CORRADE_COMPARE(b->pSetLayouts[1], reinterpret_cast(0xbeef)); + CORRADE_COMPARE(b->pSetLayouts[1], reinterpret_cast(reinterpret_cast(0xbeef))); PipelineLayoutCreateInfo c; c = std::move(b); @@ -118,7 +122,7 @@ void PipelineLayoutTest::createInfoConstructMove() { CORRADE_VERIFY(!b->pSetLayouts); CORRADE_COMPARE(c->setLayoutCount, 2); CORRADE_VERIFY(c->pSetLayouts); - CORRADE_COMPARE(c->pSetLayouts[1], reinterpret_cast(0xbeef)); + CORRADE_COMPARE(c->pSetLayouts[1], reinterpret_cast(reinterpret_cast(0xbeef))); } void PipelineLayoutTest::constructNoCreate() { diff --git a/src/Magnum/Vk/Test/PipelineTest.cpp b/src/Magnum/Vk/Test/PipelineTest.cpp index 920826140..68981927f 100644 --- a/src/Magnum/Vk/Test/PipelineTest.cpp +++ b/src/Magnum/Vk/Test/PipelineTest.cpp @@ -189,7 +189,9 @@ void PipelineTest::rasterizationCreateInfoConstruct() { MeshLayout meshLayout{MeshPrimitive::Triangles}; - RasterizationPipelineCreateInfo info{shaderSet, meshLayout, reinterpret_cast(0xdead), reinterpret_cast(0xbeef), 15, 3, RasterizationPipelineCreateInfo::Flag::DisableOptimization|RasterizationPipelineCreateInfo::Flag::AllowDerivatives}; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + RasterizationPipelineCreateInfo info{shaderSet, meshLayout, reinterpret_cast(reinterpret_cast(0xdead)), reinterpret_cast(reinterpret_cast(0xbeef)), 15, 3, RasterizationPipelineCreateInfo::Flag::DisableOptimization|RasterizationPipelineCreateInfo::Flag::AllowDerivatives}; CORRADE_COMPARE(info->flags, VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT|VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT); CORRADE_COMPARE(info->stageCount, 2); CORRADE_COMPARE(info->pStages, shaderSet.stages()); @@ -213,8 +215,8 @@ void PipelineTest::rasterizationCreateInfoConstruct() { CORRADE_COMPARE(info->pColorBlendState->pAttachments[i].colorWriteMask, VK_COLOR_COMPONENT_R_BIT|VK_COLOR_COMPONENT_G_BIT|VK_COLOR_COMPONENT_B_BIT|VK_COLOR_COMPONENT_A_BIT); } CORRADE_VERIFY(!info->pDynamicState); - CORRADE_COMPARE(info->layout, reinterpret_cast(0xdead)); - CORRADE_COMPARE(info->renderPass, reinterpret_cast(0xbeef)); + CORRADE_COMPARE(info->layout, reinterpret_cast(reinterpret_cast(0xdead))); + CORRADE_COMPARE(info->renderPass, reinterpret_cast(reinterpret_cast(0xbeef))); CORRADE_COMPARE(info->subpass, 15); } @@ -540,14 +542,16 @@ void PipelineTest::computeCreateInfoConstruct() { ShaderSet shaderSet; Containers::StringView name = "dead"_s; /* Yes, I know Fragment is wrong, it's just for testing */ - shaderSet.addShader(ShaderStage::Fragment, reinterpret_cast(0xbeef), name); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + shaderSet.addShader(ShaderStage::Fragment, reinterpret_cast(reinterpret_cast(0xbeef)), name); - ComputePipelineCreateInfo info{shaderSet, reinterpret_cast(0xdead), ComputePipelineCreateInfo::Flag::DisableOptimization|ComputePipelineCreateInfo::Flag::AllowDerivatives}; + ComputePipelineCreateInfo info{shaderSet, reinterpret_cast(reinterpret_cast(0xdead)), ComputePipelineCreateInfo::Flag::DisableOptimization|ComputePipelineCreateInfo::Flag::AllowDerivatives}; CORRADE_COMPARE(info->flags, VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT|VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT); CORRADE_COMPARE(info->stage.stage, VK_SHADER_STAGE_FRAGMENT_BIT); - CORRADE_COMPARE(info->stage.module, reinterpret_cast(0xbeef)); + CORRADE_COMPARE(info->stage.module, reinterpret_cast(reinterpret_cast(0xbeef))); CORRADE_COMPARE(info->stage.pName, name.data()); - CORRADE_COMPARE(info->layout, reinterpret_cast(0xdead)); + CORRADE_COMPARE(info->layout, reinterpret_cast(reinterpret_cast(0xdead))); } void PipelineTest::computeCreateInfoConstructOwnedEntrypoint() { @@ -637,10 +641,12 @@ void PipelineTest::memoryBarrierConstructFromVk() { } void PipelineTest::bufferMemoryBarrierConstruct() { - BufferMemoryBarrier barrier{Access::ColorAttachmentWrite|Access::DepthStencilAttachmentWrite, Access::TransferRead, reinterpret_cast(0xdead), 3, 5}; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + BufferMemoryBarrier barrier{Access::ColorAttachmentWrite|Access::DepthStencilAttachmentWrite, Access::TransferRead, reinterpret_cast(reinterpret_cast(0xdead)), 3, 5}; CORRADE_COMPARE(barrier->srcAccessMask, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT|VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT); CORRADE_COMPARE(barrier->dstAccessMask, VK_ACCESS_TRANSFER_READ_BIT); - CORRADE_COMPARE(barrier->buffer, reinterpret_cast(0xdead)); + CORRADE_COMPARE(barrier->buffer, reinterpret_cast(reinterpret_cast(0xdead))); CORRADE_COMPARE(barrier->offset, 3); CORRADE_COMPARE(barrier->size, 5); } @@ -666,12 +672,14 @@ void PipelineTest::bufferMemoryBarrierConstructFromVk() { } void PipelineTest::imageMemoryBarrierConstruct() { - ImageMemoryBarrier barrier{Access::ColorAttachmentWrite|Access::DepthStencilAttachmentWrite, Access::TransferRead, ImageLayout::Preinitialized, ImageLayout::TransferSource, reinterpret_cast(0xdead), ImageAspect::Color|ImageAspect::Depth, 3, 5, 7, 9}; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + ImageMemoryBarrier barrier{Access::ColorAttachmentWrite|Access::DepthStencilAttachmentWrite, Access::TransferRead, ImageLayout::Preinitialized, ImageLayout::TransferSource, reinterpret_cast(reinterpret_cast(0xdead)), ImageAspect::Color|ImageAspect::Depth, 3, 5, 7, 9}; CORRADE_COMPARE(barrier->srcAccessMask, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT|VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT); CORRADE_COMPARE(barrier->dstAccessMask, VK_ACCESS_TRANSFER_READ_BIT); CORRADE_COMPARE(barrier->oldLayout, VK_IMAGE_LAYOUT_PREINITIALIZED); CORRADE_COMPARE(barrier->newLayout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); - CORRADE_COMPARE(barrier->image, reinterpret_cast(0xdead)); + CORRADE_COMPARE(barrier->image, reinterpret_cast(reinterpret_cast(0xdead))); CORRADE_COMPARE(barrier->subresourceRange.aspectMask, VK_IMAGE_ASPECT_COLOR_BIT|VK_IMAGE_ASPECT_DEPTH_BIT); CORRADE_COMPARE(barrier->subresourceRange.baseMipLevel, 7); CORRADE_COMPARE(barrier->subresourceRange.levelCount, 9); @@ -680,8 +688,10 @@ void PipelineTest::imageMemoryBarrierConstruct() { } void PipelineTest::imageMemoryBarrierConstructImplicitAspect() { + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ Device device{NoCreate}; - Image image = Image::wrap(device, reinterpret_cast(0xdead), PixelFormat::Depth24UnormStencil8UI); + Image image = Image::wrap(device, reinterpret_cast(reinterpret_cast(0xdead)), PixelFormat::Depth24UnormStencil8UI); ImageMemoryBarrier barrier{ Access::ColorAttachmentRead, Access::TransferWrite, @@ -691,7 +701,7 @@ void PipelineTest::imageMemoryBarrierConstructImplicitAspect() { CORRADE_COMPARE(barrier->dstAccessMask, VK_ACCESS_TRANSFER_WRITE_BIT); CORRADE_COMPARE(barrier->oldLayout, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); CORRADE_COMPARE(barrier->newLayout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - CORRADE_COMPARE(barrier->image, reinterpret_cast(0xdead)); + CORRADE_COMPARE(barrier->image, reinterpret_cast(reinterpret_cast(0xdead))); CORRADE_COMPARE(barrier->subresourceRange.aspectMask, VK_IMAGE_ASPECT_DEPTH_BIT|VK_IMAGE_ASPECT_STENCIL_BIT); CORRADE_COMPARE(barrier->subresourceRange.baseMipLevel, 7); CORRADE_COMPARE(barrier->subresourceRange.levelCount, 9); diff --git a/src/Magnum/Vk/Test/QueueTest.cpp b/src/Magnum/Vk/Test/QueueTest.cpp index 3147db1c8..793b117a6 100644 --- a/src/Magnum/Vk/Test/QueueTest.cpp +++ b/src/Magnum/Vk/Test/QueueTest.cpp @@ -128,15 +128,17 @@ void QueueTest::submitInfoConstructNoInit() { void QueueTest::submitInfoConstructCommandBuffers() { SubmitInfo info; + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ info.setCommandBuffers({ - reinterpret_cast(0xbadbeef), - reinterpret_cast(0xcafecafe) + reinterpret_cast(reinterpret_cast(0xbadbeef)), + reinterpret_cast(reinterpret_cast(0xcafecafe)) }); CORRADE_COMPARE(info->commandBufferCount, 2); CORRADE_VERIFY(info->pCommandBuffers); - CORRADE_COMPARE(info->pCommandBuffers[0], reinterpret_cast(0xbadbeef)); - CORRADE_COMPARE(info->pCommandBuffers[1], reinterpret_cast(0xcafecafe)); + CORRADE_COMPARE(info->pCommandBuffers[0], reinterpret_cast(reinterpret_cast(0xbadbeef))); + CORRADE_COMPARE(info->pCommandBuffers[1], reinterpret_cast(reinterpret_cast(0xcafecafe))); } void QueueTest::submitInfoConstructFromVk() { @@ -153,15 +155,17 @@ void QueueTest::submitInfoConstructCopy() { } void QueueTest::submitInfoConstructMove() { + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ SubmitInfo a; - a.setCommandBuffers({{}, reinterpret_cast(0xcafecafe)}); + a.setCommandBuffers({{}, reinterpret_cast(reinterpret_cast(0xcafecafe))}); SubmitInfo b = std::move(a); CORRADE_COMPARE(a->commandBufferCount, 0); CORRADE_VERIFY(!a->pCommandBuffers); CORRADE_COMPARE(b->commandBufferCount, 2); CORRADE_VERIFY(b->pCommandBuffers); - CORRADE_COMPARE(b->pCommandBuffers[1], reinterpret_cast(0xcafecafe)); + CORRADE_COMPARE(b->pCommandBuffers[1], reinterpret_cast(reinterpret_cast(0xcafecafe))); SubmitInfo c{VkSubmitInfo{}}; c = std::move(b); @@ -169,7 +173,7 @@ void QueueTest::submitInfoConstructMove() { CORRADE_VERIFY(!b->pCommandBuffers); CORRADE_COMPARE(c->commandBufferCount, 2); CORRADE_VERIFY(c->pCommandBuffers); - CORRADE_COMPARE(c->pCommandBuffers[1], reinterpret_cast(0xcafecafe)); + CORRADE_COMPARE(c->pCommandBuffers[1], reinterpret_cast(reinterpret_cast(0xcafecafe))); } }}}} diff --git a/src/Magnum/Vk/Test/RenderPassTest.cpp b/src/Magnum/Vk/Test/RenderPassTest.cpp index 653d8a854..26c9352d2 100644 --- a/src/Magnum/Vk/Test/RenderPassTest.cpp +++ b/src/Magnum/Vk/Test/RenderPassTest.cpp @@ -1130,8 +1130,10 @@ void RenderPassTest::constructCopy() { } void RenderPassTest::beginInfoConstruct() { - auto renderPass = reinterpret_cast(0xbadbeef); - auto framebuffer = reinterpret_cast(0xdeadcafe); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + auto renderPass = reinterpret_cast(reinterpret_cast(0xbadbeef)); + auto framebuffer = reinterpret_cast(reinterpret_cast(0xdeadcafe)); RenderPassBeginInfo info{renderPass, framebuffer, Range2Di{{3, 7}, {15, 78}}}; CORRADE_COMPARE(info->renderPass, renderPass); @@ -1142,9 +1144,11 @@ void RenderPassTest::beginInfoConstruct() { } void RenderPassTest::beginInfoConstructImplicitSize() { - auto renderPass = reinterpret_cast(0xbadbeef); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + auto renderPass = reinterpret_cast(reinterpret_cast(0xbadbeef)); Device device{NoCreate}; - auto framebuffer = Framebuffer::wrap(device, reinterpret_cast(0xdeadcafe), {256, 384, 16}); + auto framebuffer = Framebuffer::wrap(device, reinterpret_cast(reinterpret_cast(0xdeadcafe)), {256, 384, 16}); RenderPassBeginInfo info{renderPass, framebuffer}; CORRADE_COMPARE(info->renderPass, renderPass); diff --git a/src/Magnum/Vk/Test/ShaderSetTest.cpp b/src/Magnum/Vk/Test/ShaderSetTest.cpp index f838007ce..bd8afd057 100644 --- a/src/Magnum/Vk/Test/ShaderSetTest.cpp +++ b/src/Magnum/Vk/Test/ShaderSetTest.cpp @@ -111,7 +111,10 @@ void ShaderSetTest::constructMove() { { ShaderSet a; - a.addShader(ShaderStage::Geometry, reinterpret_cast(0xdeadbeef), "main!"_s.except(1), { + /* The double reinterpret_cast is needed because the handle is an + uint64_t instead of a pointer on 32-bit builds and only this works + on both */ + a.addShader(ShaderStage::Geometry, reinterpret_cast(reinterpret_cast(0xdeadbeef)), "main!"_s.except(1), { {42, 1.15f} }); CORRADE_COMPARE(a.stages().size(), 1); @@ -153,10 +156,12 @@ void ShaderSetTest::constructMove() { void ShaderSetTest::addShader() { ShaderSet set; Containers::StringView entrypoint = "enterHere"_s; - set.addShader(ShaderStage::Geometry, reinterpret_cast(0xdeadbeef), entrypoint); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + set.addShader(ShaderStage::Geometry, reinterpret_cast(reinterpret_cast(0xdeadbeef)), entrypoint); CORRADE_COMPARE(set.stages().size(), 1); CORRADE_COMPARE(set.stages()[0].stage, VK_SHADER_STAGE_GEOMETRY_BIT); - CORRADE_COMPARE(set.stages()[0].module, reinterpret_cast(0xdeadbeef)); + CORRADE_COMPARE(set.stages()[0].module, reinterpret_cast(reinterpret_cast(0xdeadbeef))); /* The name should not be copied if it's null-terminated and global */ CORRADE_COMPARE(set.stages()[0].pName, entrypoint.data()); CORRADE_VERIFY(!set.stages()[0].pSpecializationInfo); @@ -272,7 +277,9 @@ void ShaderSetTest::addShaderSpecializationsReallocation() { void ShaderSetTest::addShaderOwnershipTransfer() { Device device{NoCreate}; - auto shader = Shader::wrap(device, reinterpret_cast(0xdeadbeef)); + /* The double reinterpret_cast is needed because the handle is an uint64_t + instead of a pointer on 32-bit builds and only this works on both */ + auto shader = Shader::wrap(device, reinterpret_cast(reinterpret_cast(0xdeadbeef))); ShaderSet set; set.addShader(ShaderStage::RayAnyHit, std::move(shader), "main"_s, { @@ -281,7 +288,7 @@ void ShaderSetTest::addShaderOwnershipTransfer() { CORRADE_COMPARE(set.stages()[0].stage, VK_SHADER_STAGE_ANY_HIT_BIT_KHR); CORRADE_COMPARE(set.stages()[0].pName, "main"_s); - CORRADE_COMPARE(set.stages()[0].module, reinterpret_cast(0xdeadbeef)); + CORRADE_COMPARE(set.stages()[0].module, reinterpret_cast(reinterpret_cast(0xdeadbeef))); CORRADE_VERIFY(set.stages()[0].pSpecializationInfo); CORRADE_COMPARE(set.stages()[0].pSpecializationInfo->mapEntryCount, 1); CORRADE_VERIFY(set.stages()[0].pSpecializationInfo->pMapEntries);