blob: 808eabd27c6b69623296aa2e84f38085ffc8757d [file] [log] [blame]
Jamie Madill9e54b5a2016-05-25 12:57:39 -04001//
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
14namespace rx
15{
16
Jamie Madill327ba852016-11-30 12:38:28 -050017RendererVk::RendererVk() : mCapsInitialized(false), mInstance(nullptr)
Jamie Madill9e54b5a2016-05-25 12:57:39 -040018{
19}
20
21RendererVk::~RendererVk()
22{
Jamie Madill327ba852016-11-30 12:38:28 -050023 vkDestroyInstance(mInstance, nullptr);
24}
25
26vk::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 Madill9e54b5a2016-05-25 12:57:39 -040052}
53
Jamie Madillacccc6c2016-05-03 17:22:10 -040054void RendererVk::ensureCapsInitialized() const
55{
56 if (!mCapsInitialized)
57 {
58 generateCaps(&mNativeCaps, &mNativeTextureCaps, &mNativeExtensions, &mNativeLimitations);
59 mCapsInitialized = true;
60 }
61}
62
63void RendererVk::generateCaps(gl::Caps * /*outCaps*/,
64 gl::TextureCapsMap * /*outTextureCaps*/,
65 gl::Extensions * /*outExtensions*/,
66 gl::Limitations * /* outLimitations */) const
67{
Jamie Madill327ba852016-11-30 12:38:28 -050068 // TODO(jmadill): Caps.
Jamie Madillacccc6c2016-05-03 17:22:10 -040069}
70
71const gl::Caps &RendererVk::getNativeCaps() const
72{
73 ensureCapsInitialized();
74 return mNativeCaps;
75}
76
77const gl::TextureCapsMap &RendererVk::getNativeTextureCaps() const
78{
79 ensureCapsInitialized();
80 return mNativeTextureCaps;
81}
82
83const gl::Extensions &RendererVk::getNativeExtensions() const
84{
85 ensureCapsInitialized();
86 return mNativeExtensions;
87}
88
89const gl::Limitations &RendererVk::getNativeLimitations() const
90{
91 ensureCapsInitialized();
92 return mNativeLimitations;
93}
94
Jamie Madill9e54b5a2016-05-25 12:57:39 -040095} // namespace rx