Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2016 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // RendererVk.cpp: |
| 7 | // Implements the class methods for RendererVk. |
| 8 | // |
| 9 | |
| 10 | #include "libANGLE/renderer/vulkan/RendererVk.h" |
| 11 | |
| 12 | #include "common/debug.h" |
| 13 | |
| 14 | namespace rx |
| 15 | { |
| 16 | |
Jamie Madill | 327ba85 | 2016-11-30 12:38:28 -0500 | [diff] [blame] | 17 | RendererVk::RendererVk() : mCapsInitialized(false), mInstance(nullptr) |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 18 | { |
| 19 | } |
| 20 | |
| 21 | RendererVk::~RendererVk() |
| 22 | { |
Jamie Madill | 327ba85 | 2016-11-30 12:38:28 -0500 | [diff] [blame] | 23 | vkDestroyInstance(mInstance, nullptr); |
| 24 | } |
| 25 | |
| 26 | vk::Error RendererVk::initialize() |
| 27 | { |
| 28 | VkApplicationInfo applicationInfo; |
| 29 | applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
| 30 | applicationInfo.pNext = nullptr; |
| 31 | applicationInfo.pApplicationName = "ANGLE"; |
| 32 | applicationInfo.applicationVersion = 1; |
| 33 | applicationInfo.pEngineName = "ANGLE"; |
| 34 | applicationInfo.engineVersion = 1; |
| 35 | applicationInfo.apiVersion = VK_API_VERSION_1_0; |
| 36 | |
| 37 | VkInstanceCreateInfo instanceInfo; |
| 38 | instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; |
| 39 | instanceInfo.pNext = nullptr; |
| 40 | instanceInfo.flags = 0; |
| 41 | instanceInfo.pApplicationInfo = &applicationInfo; |
| 42 | |
| 43 | // TODO(jmadill): Layers and extensions. |
| 44 | instanceInfo.enabledExtensionCount = 0; |
| 45 | instanceInfo.ppEnabledExtensionNames = nullptr; |
| 46 | instanceInfo.enabledLayerCount = 0; |
| 47 | instanceInfo.ppEnabledLayerNames = nullptr; |
| 48 | |
| 49 | ANGLE_VK_TRY(vkCreateInstance(&instanceInfo, nullptr, &mInstance)); |
| 50 | |
| 51 | return vk::NoError(); |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 52 | } |
| 53 | |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 54 | void RendererVk::ensureCapsInitialized() const |
| 55 | { |
| 56 | if (!mCapsInitialized) |
| 57 | { |
| 58 | generateCaps(&mNativeCaps, &mNativeTextureCaps, &mNativeExtensions, &mNativeLimitations); |
| 59 | mCapsInitialized = true; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | void RendererVk::generateCaps(gl::Caps * /*outCaps*/, |
| 64 | gl::TextureCapsMap * /*outTextureCaps*/, |
| 65 | gl::Extensions * /*outExtensions*/, |
| 66 | gl::Limitations * /* outLimitations */) const |
| 67 | { |
Jamie Madill | 327ba85 | 2016-11-30 12:38:28 -0500 | [diff] [blame] | 68 | // TODO(jmadill): Caps. |
Jamie Madill | acccc6c | 2016-05-03 17:22:10 -0400 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | const gl::Caps &RendererVk::getNativeCaps() const |
| 72 | { |
| 73 | ensureCapsInitialized(); |
| 74 | return mNativeCaps; |
| 75 | } |
| 76 | |
| 77 | const gl::TextureCapsMap &RendererVk::getNativeTextureCaps() const |
| 78 | { |
| 79 | ensureCapsInitialized(); |
| 80 | return mNativeTextureCaps; |
| 81 | } |
| 82 | |
| 83 | const gl::Extensions &RendererVk::getNativeExtensions() const |
| 84 | { |
| 85 | ensureCapsInitialized(); |
| 86 | return mNativeExtensions; |
| 87 | } |
| 88 | |
| 89 | const gl::Limitations &RendererVk::getNativeLimitations() const |
| 90 | { |
| 91 | ensureCapsInitialized(); |
| 92 | return mNativeLimitations; |
| 93 | } |
| 94 | |
Jamie Madill | 9e54b5a | 2016-05-25 12:57:39 -0400 | [diff] [blame] | 95 | } // namespace rx |