Perform initializations that can be done at Create Device time.
| 206 | |
| 207 | // Perform initializations that can be done at Create Device time. |
| 208 | void Validator::FinishDeviceSetup(const VkDeviceCreateInfo* pCreateInfo, const Location& loc) { |
| 209 | // GPU-AV not supported, exit early to prevent errors inside Validator::PostCallRecordCreateDevice |
| 210 | if (api_version < VK_API_VERSION_1_1) { |
| 211 | InternalError(device, loc, "GPU Shader Instrumentation requires Vulkan 1.1 or later."); |
| 212 | return; |
| 213 | } |
| 214 | |
| 215 | instrumentation_bindings_ = { |
| 216 | // DebugPrintf Output buffer |
| 217 | {glsl::kBindingInstDebugPrintf, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, |
| 218 | // Error output buffer |
| 219 | {glsl::kBindingInstErrorBuffer, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, |
| 220 | // Buffer holding output from GPU to do processing on the CPU |
| 221 | {glsl::kBindingInstPostProcess, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, |
| 222 | // Buffer holding input from CPU into the shader for descriptor indexing |
| 223 | {glsl::kBindingInstDescriptorIndexingOOB, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, |
| 224 | // Buffer holding input from CPU into the shader for descriptor heap |
| 225 | {glsl::kBindingInstDescriptorHeap, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, |
| 226 | // Buffer holding buffer device addresses |
| 227 | {glsl::kBindingInstBufferDeviceAddress, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, |
| 228 | // Buffer holding action command index in command buffer (a global buffer is used) |
| 229 | {glsl::kBindingInstActionIndex, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_ALL, nullptr}, |
| 230 | // Buffer holding a resource index from the per command buffer command resources list |
| 231 | {glsl::kBindingInstCmdResourceIndex, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_ALL, nullptr}, |
| 232 | // Commands errors counts buffer |
| 233 | {glsl::kBindingInstCmdErrorsCount, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_ALL, nullptr}, |
| 234 | // Vertex attribute fetch limits |
| 235 | {glsl::kBindingInstVertexAttributeFetchLimits, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT, nullptr}, |
| 236 | }; |
| 237 | assert(instrumentation_bindings_.size() == glsl::kTotalBindings); |
| 238 | |
| 239 | // TODO - Now that GPU-AV and DebugPrintf are merged, we should just have a single FinishDeviceSetup if possible (or at least |
| 240 | // better divide what belongs where as it is easy to mess) |
| 241 | GpuShaderInstrumentor::FinishDeviceSetup(pCreateInfo, loc); |
| 242 | // We might fail in parent class device creation if global requirements are not met |
| 243 | if (aborted_) { |
| 244 | return; |
| 245 | } |
| 246 | |
| 247 | // Need the device to be created before we can query features for settings |
| 248 | InitSettings(loc); |
| 249 | |
| 250 | VkResult result = UtilInitializeVma(instance, physical_device, device, &vma_allocator_); |
| 251 | if (result != VK_SUCCESS) { |
| 252 | InternalVmaError(device, result, "Could not initialize VMA"); |
| 253 | return; |
| 254 | } |
| 255 | |
| 256 | desc_set_manager_ = |
| 257 | std::make_unique<vko::DescriptorSetManager>(device, static_cast<uint32_t>(instrumentation_bindings_.size())); |
| 258 | |
| 259 | // If api version 1.1 or later, SetDeviceLoaderData will be in the loader |
| 260 | { |
| 261 | auto chain_info = GetChainInfo(pCreateInfo, VK_LOADER_DATA_CALLBACK); |
| 262 | assert(chain_info->u.pfnSetDeviceLoaderData); |
| 263 | vk_set_device_loader_data_ = chain_info->u.pfnSetDeviceLoaderData; |
| 264 | } |
| 265 |
nothing calls this directly
no test coverage detected