upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/address_guard_buffer.h
blob: 444d0250b0572c192ad5a07d397bad52c1ec93d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

// The address guard's page-table buffer (address_guard.h; docs/d3d12_vulkan.md, "Address guard"). Shaders translated
// with --address-guard read it through its device address on every D3D12 queue, so it is shared by all of the
// device's queue families, like the other buffers the device's queues all read.

#include "queue_families.h"

#include <cstdint>
#include <span>

namespace leonida::address_guard {

inline VkBufferCreateInfo table_buffer_info(VkDeviceSize bytes, std::span<const std::uint32_t> families) {
    VkBufferCreateInfo create{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO};
    create.size = bytes;
    create.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;
    create.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
    share_across_queue_families(create, families);
    return create;
}

}  // namespace leonida::address_guard