Fixing pointer up and downcasting

This commit is contained in:
HOEGLER Stefan
2020-03-09 19:22:21 +01:00
parent f232cffe30
commit 80b57f5134
3 changed files with 26 additions and 2 deletions
@@ -42,5 +42,18 @@ void Seele::VulkanPipelineLayout::create()
for (size_t i = 0; i < descriptorSetLayouts.size(); ++i) for (size_t i = 0; i < descriptorSetLayouts.size(); ++i)
{ {
PVulkanDescriptorLayout layout = descriptorSetLayouts[i].cast<VulkanDescriptorLayout>(); PVulkanDescriptorLayout layout = descriptorSetLayouts[i].cast<VulkanDescriptorLayout>();
layout->create();
vulkanDescriptorLayouts[i] = layout->getHandle();
} }
VkPipelineLayoutCreateInfo createInfo =
init::PipelineLayoutCreateInfo(vulkanDescriptorLayouts.data(), vulkanDescriptorLayouts.size());
Array<VkPushConstantRange> vkPushConstants(pushConstants.size());
for (size_t i = 0; i < pushConstants.size(); i++)
{
vkPushConstants[i].offset = pushConstants[i].offset;
vkPushConstants[i].size = pushConstants[i].size;
vkPushConstants[i].stageFlags = pushConstants[i].stageFlags;
}
createInfo.pushConstantRangeCount = vkPushConstants.size();
createInfo.pPushConstantRanges = vkPushConstants.data();
} }
+1 -1
View File
@@ -111,7 +111,7 @@ namespace Seele
{ {
return RefPtr<F>(); return RefPtr<F>();
} }
RefObject<F>* newObject = static_cast<RefObject<F>*>(object); RefObject<F>* newObject = (RefObject<F>*)object;
RefPtr<F> result(newObject); RefPtr<F> result(newObject);
return result; return result;
} }
+12 -1
View File
@@ -12,8 +12,9 @@ struct TestStruct
: data(10) : data(10)
{ {
} }
~TestStruct() virtual ~TestStruct()
{ {
data = 15;
} }
uint32 data; uint32 data;
}; };
@@ -33,7 +34,16 @@ BOOST_AUTO_TEST_CASE(basic_refcount)
struct DerivedStruct : public TestStruct struct DerivedStruct : public TestStruct
{ {
DerivedStruct()
:data2(20)
{
}
~DerivedStruct()
{
data2 = 30;
}
uint32 data2;
}; };
BOOST_AUTO_TEST_CASE(inheritance_cast) BOOST_AUTO_TEST_CASE(inheritance_cast)
@@ -46,6 +56,7 @@ BOOST_AUTO_TEST_CASE(inheritance_cast)
backCast = base.cast<DerivedStruct>(); backCast = base.cast<DerivedStruct>();
} }
BOOST_REQUIRE_EQUAL(backCast->data, 10); BOOST_REQUIRE_EQUAL(backCast->data, 10);
BOOST_REQUIRE_EQUAL(backCast->data2, 20);
} }
BOOST_AUTO_TEST_CASE(unique_ptr) BOOST_AUTO_TEST_CASE(unique_ptr)