Determine storage buffer alignment dynamically

This commit is contained in:
Billy Laws
2022-12-31 23:01:55 +00:00
parent 12d80fe6c2
commit 35a46acbb1
5 changed files with 10 additions and 16 deletions

View File

@ -37,14 +37,12 @@ namespace skyline::gpu::interconnect {
u64 address;
u32 size;
};
static constexpr size_t MinAlignment{0x40};
auto ssbo{cbuf.Read<SsboDescriptor>(ctx.executor, desc.cbuf_offset)};
if (ssbo.size == 0)
return BufferBinding{ctx.gpu.megaBufferAllocator.Allocate(ctx.executor.cycle, PAGE_SIZE).buffer, 0, PAGE_SIZE};
size_t padding{ssbo.address & (MinAlignment - 1)};
cachedView.Update(ctx, ssbo.address - padding, util::AlignUp(ssbo.size + padding, MinAlignment));
size_t padding{ssbo.address & (ctx.gpu.traits.minimumStorageBufferAlignment - 1)};
cachedView.Update(ctx, ssbo.address - padding, util::AlignUp(ssbo.size + padding, ctx.gpu.traits.minimumStorageBufferAlignment));
auto view{cachedView.view};
ctx.executor.AttachBuffer(view);

View File

@ -210,6 +210,9 @@ namespace skyline::gpu {
for (u32 i{}; i < memoryProps.memoryProperties.memoryTypeCount; i++)
if ((memoryProps.memoryProperties.memoryTypes[i].propertyFlags & ReqMemFlags) == ReqMemFlags)
hostVisibleCoherentCachedMemoryType = i;
minimumStorageBufferAlignment = static_cast<u32>(deviceProperties2.get().properties.limits.minStorageBufferOffsetAlignment);
}
std::string TraitManager::Summary() {

View File

@ -51,6 +51,7 @@ namespace skyline::gpu {
bool supportsNullDescriptor{}; //!< If the device supports the null descriptor feature in the 'VK_EXT_robustness2' Vulkan extension
u32 subgroupSize{}; //!< Size of a subgroup on the host GPU
u32 hostVisibleCoherentCachedMemoryType{std::numeric_limits<u32>::max()};
u32 minimumStorageBufferAlignment{}; //!< Minimum alignment for storage buffers passed to shaders
std::bitset<7> bcnSupport{}; //!< Bitmask of BCn texture formats supported, it is ordered as BC1, BC2, BC3, BC4, BC5, BC6H and BC7
bool supportsAdrenoDirectMemoryImport{};