Skip to content

Commit f8ba11f

Browse files
Some cleanup in preparetion for more aliasing work
1 parent b7bed33 commit f8ba11f

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

scripts/struct.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,10 @@ def struct_impl_read(r, selected = None):
7979
accessor = '%s* sptr' % name
8080
special = ''
8181
if name == 'VkDeviceCreateInfo': special = ', VkPhysicalDevice physicalDevice'
82-
elif 'VkBindBufferMemoryInfo' in name or 'VkBindImageMemoryInfo' in name: special = ', VkDevice device'
8382
print('static void read_%s(lava_file_reader& reader, %s%s)' % (name, accessor, special), file=r)
8483
print('{', file=r)
8584
if v.attrib.get('alias'):
8685
if 'VkDeviceCreateInfo' in name: special = ', physicalDevice'
87-
elif 'VkBindBufferMemoryInfo' in name or 'VkBindImageMemoryInfo' in name: special = ', device'
8886
print('\tread_%s(reader, sptr%s);' % (v.attrib.get('alias'), special), file=r)
8987
else:
9088
z.target(r)

scripts/util.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ def print_struct(self, mytype, varname, owner, size = None):
449449
elif 'vkCmdPushDescriptorSet' in self.funcname and mytype == 'VkWriteDescriptorSet' and not self.read: accessor += ', true'
450450
elif mytype == 'VkWriteDescriptorSet' and not self.read: accessor += ', false'
451451
elif mytype == 'VkDeviceCreateInfo' and self.read: accessor += ', physicalDevice'
452-
elif ('VkBindImageMemoryInfo' in mytype or 'VkBindBufferMemoryInfo' in mytype) and self.read: accessor += ', device'
453452

454453
if self.funcname[0] == 'V' and mytype in deconst_struct and not self.read: # we cannot modify passed in memory when writing
455454
if size:
@@ -721,11 +720,11 @@ def print_load(self, name, owner): # called for each parameter
721720
z.do('const VkImageTiling tiling = static_cast<VkImageTiling>(reader.read_uint32_t()); // fetch tiling property especially added')
722721
z.do('const VkDeviceSize min_size = static_cast<VkDeviceSize>(reader.read_uint64_t()); // fetch padded memory size')
723722
z.do('trackedimage& image_data = VkImage_index.at(image_index);')
724-
z.do('suballoc_location loc = reader.parent->allocator.add_image(reader.thread_index(), device, %s, image_index, special_flags, tiling, min_size);' % varname)
723+
z.do('suballoc_location loc = reader.parent->allocator.add_image(reader.thread_index(), reader.device, %s, image_index, special_flags, tiling, min_size);' % varname)
725724
elif self.funcname in ['vkBindBufferMemory', 'VkBindBufferMemoryInfo', 'VkBindBufferMemoryInfoKHR'] and self.name == 'buffer':
726725
z.do('const VkMemoryPropertyFlags special_flags = static_cast<VkMemoryPropertyFlags>(reader.read_uint32_t()); // fetch memory flags especially added')
727726
z.do('trackedbuffer& buffer_data = VkBuffer_index.at(buffer_index);')
728-
z.do('suballoc_location loc = reader.parent->allocator.add_buffer(reader.thread_index(), device, %s, buffer_index, special_flags, buffer_data);' % varname)
727+
z.do('suballoc_location loc = reader.parent->allocator.add_buffer(reader.thread_index(), reader.device, %s, special_flags, buffer_data);' % varname)
729728

730729
if self.funcname in ['vkBindImageMemory', 'vkBindBufferMemory', 'VkBindBufferMemoryInfo', 'VkBindBufferMemoryInfoKHR', 'VkBindImageMemoryInfoKHR', 'VkBindImageMemoryInfo']:
731730
if self.name == 'memory':

src/lavatube.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ struct trackedobject : trackable
172172
int source = 0; // code line that is the last source for us to be scanned, only for debugging
173173
/// Do we alias another object in memory? if we alias 1-to-1, both point to each other, otherwise only the child points to
174174
/// the parent object.
175-
uint32_t alias_type = VK_OBJECT_TYPE_UNKNOWN;
175+
VkObjectType alias_type = VK_OBJECT_TYPE_UNKNOWN;
176176
uint32_t alias_index = UINT32_MAX;
177177
VkDeviceAddress device_address = 0;
178178

src/suballocator.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct suballocation
2424
{
2525
VkImage image;
2626
VkBuffer buffer;
27+
VkTensorARM tensor;
2728
} handle;
2829
VkDeviceSize size = 0;
2930
VkDeviceSize offset = 0;
@@ -406,21 +407,18 @@ void suballocator::virtualswap_images(VkDevice device, const std::vector<VkImage
406407
}
407408
}
408409

409-
suballoc_location suballocator::add_buffer(uint16_t tid, VkDevice device, VkBuffer buffer, uint32_t buffer_index, VkMemoryPropertyFlags mempropflags, const trackedbuffer& buffer_data)
410+
suballoc_location suballocator::add_buffer(uint16_t tid, VkDevice device, VkBuffer buffer, VkMemoryPropertyFlags mempropflags, const trackedbuffer& buffer_data)
410411
{
411412
const VkBufferUsageFlags buffer_flags = buffer_data.usage;
412413
if ((mempropflags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) || (mempropflags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT))
413414
{
414415
mempropflags &= ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; // do not require this bit in these cases
415416
}
416-
VkMemoryRequirements2 req = {};
417-
req.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
418-
VkMemoryDedicatedRequirements dedicated = {};
419-
dedicated.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS;
417+
VkMemoryRequirements2 req = { VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2, nullptr };
418+
VkMemoryDedicatedRequirements dedicated = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS, nullptr };
420419
if (use_dedicated_allocation() && priv->run)
421420
{
422-
VkBufferMemoryRequirementsInfo2 info = {};
423-
info.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2;
421+
VkBufferMemoryRequirementsInfo2 info = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2, nullptr };
424422
info.buffer = buffer;
425423
req.pNext = &dedicated;
426424
wrap_vkGetBufferMemoryRequirements2(device, &info, &req);
@@ -441,7 +439,7 @@ suballoc_location suballocator::add_buffer(uint16_t tid, VkDevice device, VkBuff
441439
s.handle.buffer = buffer;
442440
s.size = req.memoryRequirements.size;
443441
s.offset = 0;
444-
s.index = buffer_index;
442+
s.index = buffer_data.index;
445443
s.alignment = req.memoryRequirements.alignment;
446444
VkMemoryAllocateFlags allocflags = 0;
447445
if (buffer_flags & VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) { dedicated.prefersDedicatedAllocation = VK_TRUE; allocflags |= VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR; }

src/suballocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct suballocator
3232
suballoc_location add_image(uint16_t tid, VkDevice device, VkImage image, uint32_t image_index, VkMemoryPropertyFlags flags, VkImageTiling tiling, VkDeviceSize min_size);
3333

3434
/// Add a buffer to our memory pools. See above.
35-
suballoc_location add_buffer(uint16_t tid, VkDevice device, VkBuffer buffer, uint32_t buffer_index, VkMemoryPropertyFlags memory_flags, const trackedbuffer& buffer_data);
35+
suballoc_location add_buffer(uint16_t tid, VkDevice device, VkBuffer buffer, VkMemoryPropertyFlags memory_flags, const trackedbuffer& buffer_data);
3636

3737
/// Delete an image from our memory pools. Thread safe because the internal data structure is preallocated and never resized,
3838
/// and deleted entries are never reused.

0 commit comments

Comments
 (0)