| 4908 | } |
| 4909 | |
| 4910 | void StagingScratchBufferVK::create(uint32_t _size, uint32_t _count, VkBufferUsageFlags usage, uint32_t _align) |
| 4911 | { |
| 4912 | const VkAllocationCallbacks* allocatorCb = s_renderVK->m_allocatorCb; |
| 4913 | const VkDevice device = s_renderVK->m_device; |
| 4914 | |
| 4915 | const uint32_t entrySize = bx::strideAlign(_size, _align); |
| 4916 | const uint32_t chunkSize = entrySize * _count; |
| 4917 | |
| 4918 | VkBufferCreateInfo bci; |
| 4919 | bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4920 | bci.pNext = NULL; |
| 4921 | bci.flags = 0; |
| 4922 | bci.size = chunkSize; |
| 4923 | bci.usage = usage; |
| 4924 | bci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 4925 | bci.queueFamilyIndexCount = 0; |
| 4926 | bci.pQueueFamilyIndices = NULL; |
| 4927 | |
| 4928 | VK_CHECK(vkCreateBuffer( |
| 4929 | device |
| 4930 | , &bci |
| 4931 | , allocatorCb |
| 4932 | , &m_buffer |
| 4933 | ) ); |
| 4934 | |
| 4935 | VkMemoryRequirements mr; |
| 4936 | vkGetBufferMemoryRequirements( |
| 4937 | device |
| 4938 | , m_buffer |
| 4939 | , &mr |
| 4940 | ); |
| 4941 | |
| 4942 | VkMemoryPropertyFlags flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; |
| 4943 | VkResult result = s_renderVK->allocateMemory(&mr, flags, &m_deviceMem, true); |
| 4944 | |
| 4945 | if (VK_SUCCESS != result) |
| 4946 | { |
| 4947 | flags &= ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; |
| 4948 | VK_CHECK(s_renderVK->allocateMemory(&mr, flags, &m_deviceMem, true) ); |
| 4949 | } |
| 4950 | |
| 4951 | m_size = (uint32_t)mr.size; |
| 4952 | m_chunkPos = 0; |
| 4953 | m_align = _align; |
| 4954 | |
| 4955 | VK_CHECK(vkBindBufferMemory(device, m_buffer, m_deviceMem.mem, m_deviceMem.offset) ); |
| 4956 | |
| 4957 | VK_CHECK(vkMapMemory(device, m_deviceMem.mem, m_deviceMem.offset, m_size, 0, (void**)&m_data) ); |
| 4958 | } |
| 4959 | |
| 4960 | void StagingScratchBufferVK::createUniform(uint32_t _size, uint32_t _count) |
| 4961 | { |
no test coverage detected