Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 1 | // Copyright 2018 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
Nicolas Capens | d689d1c | 2018-11-19 16:02:36 -0500 | [diff] [blame] | 15 | #include "VkDevice.hpp" |
| 16 | |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 17 | #include "VkConfig.hpp" |
Alexis Hetu | 048974f | 2019-02-15 15:28:37 -0500 | [diff] [blame] | 18 | #include "VkDescriptorSetLayout.hpp" |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 19 | #include "VkFence.hpp" |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 20 | #include "VkQueue.hpp" |
Ben Clayton | a4e06ca | 2019-12-03 12:38:14 +0000 | [diff] [blame] | 21 | #include "Debug/Context.hpp" |
| 22 | #include "Debug/Server.hpp" |
Alexis Hetu | 0da99f5 | 2019-02-27 12:54:52 -0500 | [diff] [blame] | 23 | #include "Device/Blitter.hpp" |
Ben Clayton | 25e06e0 | 2020-02-07 11:19:08 +0000 | [diff] [blame] | 24 | #include "System/Debug.hpp" |
Nicolas Capens | d689d1c | 2018-11-19 16:02:36 -0500 | [diff] [blame] | 25 | |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 26 | #include <chrono> |
| 27 | #include <climits> |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 28 | #include <new> // Must #include this to use "placement new" |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 29 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 30 | namespace { |
| 31 | |
| 32 | std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> now() |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 33 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 34 | return std::chrono::time_point_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now()); |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 35 | } |
| 36 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 37 | } // anonymous namespace |
| 38 | |
| 39 | namespace vk { |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 40 | |
Nicolas Capens | d53eeca | 2020-03-19 13:31:41 -0400 | [diff] [blame] | 41 | void Device::SamplingRoutineCache::updateSnapshot() |
Alexis Hetu | 3575550 | 2019-07-22 13:51:49 -0400 | [diff] [blame] | 42 | { |
Ben Clayton | 377573c | 2020-04-03 20:36:40 +0100 | [diff] [blame] | 43 | marl::lock lock(mutex); |
Nicolas Capens | 1c29477 | 2020-03-28 23:04:55 -0400 | [diff] [blame] | 44 | |
Ben Clayton | ac43aa7 | 2020-04-04 00:48:13 +0100 | [diff] [blame] | 45 | if(snapshotNeedsUpdate) |
| 46 | { |
| 47 | snapshot.clear(); |
| 48 | |
| 49 | for(auto it : cache) |
| 50 | { |
| 51 | snapshot[it.key()] = it.data(); |
| 52 | } |
| 53 | |
| 54 | snapshotNeedsUpdate = false; |
| 55 | } |
Alexis Hetu | 3575550 | 2019-07-22 13:51:49 -0400 | [diff] [blame] | 56 | } |
| 57 | |
Nicolas Capens | 73c4a0c | 2020-03-17 17:29:11 -0400 | [diff] [blame] | 58 | Device::SamplerIndexer::~SamplerIndexer() |
| 59 | { |
| 60 | ASSERT(map.empty()); |
| 61 | } |
| 62 | |
| 63 | uint32_t Device::SamplerIndexer::index(const SamplerState &samplerState) |
| 64 | { |
Ben Clayton | 377573c | 2020-04-03 20:36:40 +0100 | [diff] [blame] | 65 | marl::lock lock(mutex); |
Nicolas Capens | 73c4a0c | 2020-03-17 17:29:11 -0400 | [diff] [blame] | 66 | |
| 67 | auto it = map.find(samplerState); |
| 68 | |
| 69 | if(it != map.end()) |
| 70 | { |
| 71 | it->second.count++; |
| 72 | return it->second.id; |
| 73 | } |
| 74 | |
| 75 | nextID++; |
| 76 | |
| 77 | map.emplace(samplerState, Identifier{ nextID, 1 }); |
| 78 | |
| 79 | return nextID; |
| 80 | } |
| 81 | |
| 82 | void Device::SamplerIndexer::remove(const SamplerState &samplerState) |
| 83 | { |
Ben Clayton | 377573c | 2020-04-03 20:36:40 +0100 | [diff] [blame] | 84 | marl::lock lock(mutex); |
Nicolas Capens | 73c4a0c | 2020-03-17 17:29:11 -0400 | [diff] [blame] | 85 | |
| 86 | auto it = map.find(samplerState); |
| 87 | ASSERT(it != map.end()); |
| 88 | |
| 89 | auto count = --it->second.count; |
| 90 | if(count == 0) |
| 91 | { |
| 92 | map.erase(it); |
| 93 | } |
| 94 | } |
| 95 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 96 | Device::Device(const VkDeviceCreateInfo *pCreateInfo, void *mem, PhysicalDevice *physicalDevice, const VkPhysicalDeviceFeatures *enabledFeatures, const std::shared_ptr<marl::Scheduler> &scheduler) |
| 97 | : physicalDevice(physicalDevice) |
| 98 | , queues(reinterpret_cast<Queue *>(mem)) |
| 99 | , enabledExtensionCount(pCreateInfo->enabledExtensionCount) |
| 100 | , enabledFeatures(enabledFeatures ? *enabledFeatures : VkPhysicalDeviceFeatures{}) |
| 101 | , // "Setting pEnabledFeatures to NULL and not including a VkPhysicalDeviceFeatures2 in the pNext member of VkDeviceCreateInfo is equivalent to setting all members of the structure to VK_FALSE." |
| 102 | scheduler(scheduler) |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 103 | { |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 104 | for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++) |
| 105 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 106 | const VkDeviceQueueCreateInfo &queueCreateInfo = pCreateInfo->pQueueCreateInfos[i]; |
Alexis Hetu | e70c351 | 2018-10-17 13:18:04 -0400 | [diff] [blame] | 107 | queueCount += queueCreateInfo.queueCount; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | uint32_t queueID = 0; |
| 111 | for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++) |
| 112 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 113 | const VkDeviceQueueCreateInfo &queueCreateInfo = pCreateInfo->pQueueCreateInfos[i]; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 114 | |
| 115 | for(uint32_t j = 0; j < queueCreateInfo.queueCount; j++, queueID++) |
| 116 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 117 | new(&queues[queueID]) Queue(this, scheduler.get()); |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 118 | } |
| 119 | } |
Nicolas Capens | d689d1c | 2018-11-19 16:02:36 -0500 | [diff] [blame] | 120 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 121 | extensions = reinterpret_cast<ExtensionName *>(static_cast<uint8_t *>(mem) + (sizeof(Queue) * queueCount)); |
Alexis Hetu | 352791e | 2019-05-17 16:42:34 -0400 | [diff] [blame] | 122 | for(uint32_t i = 0; i < enabledExtensionCount; i++) |
| 123 | { |
| 124 | strncpy(extensions[i], pCreateInfo->ppEnabledExtensionNames[i], VK_MAX_EXTENSION_NAME_SIZE); |
| 125 | } |
| 126 | |
Nicolas Capens | d689d1c | 2018-11-19 16:02:36 -0500 | [diff] [blame] | 127 | if(pCreateInfo->enabledLayerCount) |
| 128 | { |
| 129 | // "The ppEnabledLayerNames and enabledLayerCount members of VkDeviceCreateInfo are deprecated and their values must be ignored by implementations." |
Nicolas Capens | 44bd43a | 2020-01-22 03:07:14 -0500 | [diff] [blame] | 130 | UNSUPPORTED("enabledLayerCount"); |
Nicolas Capens | d689d1c | 2018-11-19 16:02:36 -0500 | [diff] [blame] | 131 | } |
Alexis Hetu | 0da99f5 | 2019-02-27 12:54:52 -0500 | [diff] [blame] | 132 | |
Alexis Hetu | 1a9714a | 2019-04-12 11:48:12 -0400 | [diff] [blame] | 133 | // FIXME (b/119409619): use an allocator here so we can control all memory allocations |
Alexis Hetu | 6448bd6 | 2019-06-11 15:58:59 -0400 | [diff] [blame] | 134 | blitter.reset(new sw::Blitter()); |
Alexis Hetu | 3575550 | 2019-07-22 13:51:49 -0400 | [diff] [blame] | 135 | samplingRoutineCache.reset(new SamplingRoutineCache()); |
Nicolas Capens | 73c4a0c | 2020-03-17 17:29:11 -0400 | [diff] [blame] | 136 | samplerIndexer.reset(new SamplerIndexer()); |
Ben Clayton | a4e06ca | 2019-12-03 12:38:14 +0000 | [diff] [blame] | 137 | |
| 138 | #ifdef ENABLE_VK_DEBUGGER |
| 139 | static auto port = getenv("VK_DEBUGGER_PORT"); |
| 140 | if(port) |
| 141 | { |
| 142 | // Construct the debugger context and server - this may block for a |
| 143 | // debugger connection, allowing breakpoints to be set before they're |
| 144 | // executed. |
| 145 | debugger.context = vk::dbg::Context::create(); |
| 146 | debugger.server = vk::dbg::Server::create(debugger.context, atoi(port)); |
| 147 | } |
| 148 | #endif // ENABLE_VK_DEBUGGER |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 149 | } |
| 150 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 151 | void Device::destroy(const VkAllocationCallbacks *pAllocator) |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 152 | { |
Alexis Hetu | af3c102 | 2018-12-12 13:26:15 -0500 | [diff] [blame] | 153 | for(uint32_t i = 0; i < queueCount; i++) |
| 154 | { |
Ben Clayton | 7e0a036 | 2019-05-20 11:32:35 +0100 | [diff] [blame] | 155 | queues[i].~Queue(); |
Alexis Hetu | af3c102 | 2018-12-12 13:26:15 -0500 | [diff] [blame] | 156 | } |
| 157 | |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 158 | vk::deallocate(queues, pAllocator); |
| 159 | } |
| 160 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 161 | size_t Device::ComputeRequiredAllocationSize(const VkDeviceCreateInfo *pCreateInfo) |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 162 | { |
| 163 | uint32_t queueCount = 0; |
Nicolas Capens | 0c73680 | 2019-05-27 12:53:31 -0400 | [diff] [blame] | 164 | for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++) |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 165 | { |
Nicolas Capens | 0c73680 | 2019-05-27 12:53:31 -0400 | [diff] [blame] | 166 | queueCount += pCreateInfo->pQueueCreateInfos[i].queueCount; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 167 | } |
| 168 | |
Nicolas Capens | 0c73680 | 2019-05-27 12:53:31 -0400 | [diff] [blame] | 169 | return (sizeof(Queue) * queueCount) + (pCreateInfo->enabledExtensionCount * sizeof(ExtensionName)); |
Alexis Hetu | 352791e | 2019-05-17 16:42:34 -0400 | [diff] [blame] | 170 | } |
| 171 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 172 | bool Device::hasExtension(const char *extensionName) const |
Alexis Hetu | 352791e | 2019-05-17 16:42:34 -0400 | [diff] [blame] | 173 | { |
| 174 | for(uint32_t i = 0; i < enabledExtensionCount; i++) |
| 175 | { |
| 176 | if(strncmp(extensions[i], extensionName, VK_MAX_EXTENSION_NAME_SIZE) == 0) |
| 177 | { |
| 178 | return true; |
| 179 | } |
| 180 | } |
| 181 | return false; |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | VkQueue Device::getQueue(uint32_t queueFamilyIndex, uint32_t queueIndex) const |
| 185 | { |
| 186 | ASSERT(queueFamilyIndex == 0); |
| 187 | |
| 188 | return queues[queueIndex]; |
| 189 | } |
| 190 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 191 | VkResult Device::waitForFences(uint32_t fenceCount, const VkFence *pFences, VkBool32 waitAll, uint64_t timeout) |
Alexis Hetu | c4bd9df | 2018-12-07 11:28:40 -0500 | [diff] [blame] | 192 | { |
Ben Clayton | 6779e5e | 2019-05-20 11:07:58 +0100 | [diff] [blame] | 193 | using time_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>; |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 194 | const time_point start = now(); |
| 195 | const uint64_t max_timeout = (LLONG_MAX - start.time_since_epoch().count()); |
| 196 | bool infiniteTimeout = (timeout > max_timeout); |
| 197 | const time_point end_ns = start + std::chrono::nanoseconds(std::min(max_timeout, timeout)); |
Nicolas Capens | 85035be | 2019-06-05 13:54:18 -0400 | [diff] [blame] | 198 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 199 | if(waitAll != VK_FALSE) // All fences must be signaled |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 200 | { |
| 201 | for(uint32_t i = 0; i < fenceCount; i++) |
| 202 | { |
| 203 | if(timeout == 0) |
| 204 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 205 | if(Cast(pFences[i])->getStatus() != VK_SUCCESS) // At least one fence is not signaled |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 206 | { |
| 207 | return VK_TIMEOUT; |
| 208 | } |
| 209 | } |
| 210 | else if(infiniteTimeout) |
| 211 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 212 | if(Cast(pFences[i])->wait() != VK_SUCCESS) // At least one fence is not signaled |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 213 | { |
| 214 | return VK_TIMEOUT; |
| 215 | } |
| 216 | } |
| 217 | else |
| 218 | { |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 219 | if(Cast(pFences[i])->wait(end_ns) != VK_SUCCESS) // At least one fence is not signaled |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 220 | { |
| 221 | return VK_TIMEOUT; |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | return VK_SUCCESS; |
| 227 | } |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 228 | else // At least one fence must be signaled |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 229 | { |
Ben Clayton | 951d48d | 2019-11-13 21:46:59 +0000 | [diff] [blame] | 230 | marl::containers::vector<marl::Event, 8> events; |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 231 | for(uint32_t i = 0; i < fenceCount; i++) |
| 232 | { |
Ben Clayton | 951d48d | 2019-11-13 21:46:59 +0000 | [diff] [blame] | 233 | events.push_back(Cast(pFences[i])->getEvent()); |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 234 | } |
| 235 | |
Ben Clayton | 951d48d | 2019-11-13 21:46:59 +0000 | [diff] [blame] | 236 | auto any = marl::Event::any(events.begin(), events.end()); |
| 237 | |
| 238 | if(timeout == 0) |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 239 | { |
Ben Clayton | 951d48d | 2019-11-13 21:46:59 +0000 | [diff] [blame] | 240 | return any.isSignalled() ? VK_SUCCESS : VK_TIMEOUT; |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 241 | } |
Nicolas Capens | 81bc9d9 | 2019-12-16 15:05:57 -0500 | [diff] [blame] | 242 | else if(infiniteTimeout) |
Ben Clayton | 951d48d | 2019-11-13 21:46:59 +0000 | [diff] [blame] | 243 | { |
| 244 | any.wait(); |
| 245 | return VK_SUCCESS; |
| 246 | } |
| 247 | else |
| 248 | { |
| 249 | return any.wait_until(end_ns) ? VK_SUCCESS : VK_TIMEOUT; |
| 250 | } |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 251 | } |
Alexis Hetu | c4bd9df | 2018-12-07 11:28:40 -0500 | [diff] [blame] | 252 | } |
| 253 | |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 254 | VkResult Device::waitIdle() |
Ben Clayton | 00424c1 | 2019-03-17 17:29:30 +0000 | [diff] [blame] | 255 | { |
| 256 | for(uint32_t i = 0; i < queueCount; i++) |
| 257 | { |
| 258 | queues[i].waitIdle(); |
| 259 | } |
Alexis Hetu | e1f51b9 | 2019-04-23 15:34:34 -0400 | [diff] [blame] | 260 | |
| 261 | return VK_SUCCESS; |
Alexis Hetu | cda0cf9 | 2019-01-24 15:48:55 -0500 | [diff] [blame] | 262 | } |
| 263 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 264 | void Device::getDescriptorSetLayoutSupport(const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 265 | VkDescriptorSetLayoutSupport *pSupport) const |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 266 | { |
Chris Forbes | aee3c36 | 2019-11-22 12:09:45 -0800 | [diff] [blame] | 267 | // From Vulkan Spec 13.2.1 Descriptor Set Layout, in description of vkGetDescriptorSetLayoutSupport: |
| 268 | // "This command does not consider other limits such as maxPerStageDescriptor*, and so a descriptor |
| 269 | // set layout that is supported according to this command must still satisfy the pipeline layout limits |
| 270 | // such as maxPerStageDescriptor* in order to be used in a pipeline layout." |
| 271 | |
| 272 | // We have no "strange" limitations to enforce beyond the device limits, so we can safely always claim support. |
| 273 | pSupport->supported = VK_TRUE; |
Alexis Hetu | 9e4d040 | 2018-10-16 15:44:12 -0400 | [diff] [blame] | 274 | } |
| 275 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 276 | void Device::updateDescriptorSets(uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, |
| 277 | uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies) |
Alexis Hetu | 048974f | 2019-02-15 15:28:37 -0500 | [diff] [blame] | 278 | { |
| 279 | for(uint32_t i = 0; i < descriptorWriteCount; i++) |
| 280 | { |
Alexis Hetu | 6448bd6 | 2019-06-11 15:58:59 -0400 | [diff] [blame] | 281 | DescriptorSetLayout::WriteDescriptorSet(this, pDescriptorWrites[i]); |
Alexis Hetu | 048974f | 2019-02-15 15:28:37 -0500 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | for(uint32_t i = 0; i < descriptorCopyCount; i++) |
| 285 | { |
| 286 | DescriptorSetLayout::CopyDescriptorSet(pDescriptorCopies[i]); |
| 287 | } |
| 288 | } |
| 289 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 290 | void Device::getRequirements(VkMemoryDedicatedRequirements *requirements) const |
Alexis Hetu | 131a1ba | 2019-11-21 16:39:06 -0500 | [diff] [blame] | 291 | { |
| 292 | requirements->prefersDedicatedAllocation = VK_FALSE; |
| 293 | requirements->requiresDedicatedAllocation = VK_FALSE; |
| 294 | } |
| 295 | |
Ben Clayton | 2ed93ab | 2019-12-17 20:38:03 +0000 | [diff] [blame] | 296 | Device::SamplingRoutineCache *Device::getSamplingRoutineCache() const |
Alexis Hetu | 6448bd6 | 2019-06-11 15:58:59 -0400 | [diff] [blame] | 297 | { |
Alexis Hetu | 6448bd6 | 2019-06-11 15:58:59 -0400 | [diff] [blame] | 298 | return samplingRoutineCache.get(); |
| 299 | } |
| 300 | |
Nicolas Capens | d53eeca | 2020-03-19 13:31:41 -0400 | [diff] [blame] | 301 | void Device::updateSamplingRoutineSnapshotCache() |
Alexis Hetu | 3575550 | 2019-07-22 13:51:49 -0400 | [diff] [blame] | 302 | { |
Nicolas Capens | d53eeca | 2020-03-19 13:31:41 -0400 | [diff] [blame] | 303 | samplingRoutineCache->updateSnapshot(); |
Alexis Hetu | 3575550 | 2019-07-22 13:51:49 -0400 | [diff] [blame] | 304 | } |
| 305 | |
Nicolas Capens | 73c4a0c | 2020-03-17 17:29:11 -0400 | [diff] [blame] | 306 | uint32_t Device::indexSampler(const SamplerState &samplerState) |
| 307 | { |
| 308 | return samplerIndexer->index(samplerState); |
| 309 | } |
| 310 | |
| 311 | void Device::removeSampler(const SamplerState &samplerState) |
| 312 | { |
| 313 | samplerIndexer->remove(samplerState); |
| 314 | } |
| 315 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 316 | } // namespace vk |