Hash :
29f148b0
Author :
Date :
2016-11-23T21:05:36
Support Vulkan on Linux as well as Windows. Refactor display and surface classes into Win32 and Linux parts and add Linux parts to gn and gyp builds. BUG=angleproject:1668 Change-Id: I2a7d29c35f4f42fa0035bd97938d3770f3627672 Reviewed-on: https://chromium-review.googlesource.com/412426 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// RendererVk.h:
// Defines the class interface for RendererVk.
//
#ifndef LIBANGLE_RENDERER_VULKAN_RENDERERVK_H_
#define LIBANGLE_RENDERER_VULKAN_RENDERERVK_H_
#include <memory>
#include <vulkan/vulkan.h>
#include "common/angleutils.h"
#include "libANGLE/Caps.h"
#include "libANGLE/renderer/vulkan/renderervk_utils.h"
namespace egl
{
class AttributeMap;
}
namespace rx
{
class GlslangWrapper;
namespace vk
{
struct Format;
}
class RendererVk : angle::NonCopyable
{
public:
RendererVk();
~RendererVk();
vk::Error initialize(const egl::AttributeMap &attribs, const char *wsiName);
std::string getVendorString() const;
std::string getRendererDescription() const;
VkInstance getInstance() const { return mInstance; }
VkPhysicalDevice getPhysicalDevice() const { return mPhysicalDevice; }
VkQueue getQueue() const { return mQueue; }
VkDevice getDevice() const { return mDevice; }
vk::ErrorOrResult<uint32_t> selectPresentQueueForSurface(VkSurfaceKHR surface);
// TODO(jmadill): Use ContextImpl for command buffers to enable threaded contexts.
vk::Error getStartedCommandBuffer(vk::CommandBuffer **commandBufferOut);
vk::Error submitCommandBuffer(vk::CommandBuffer *commandBuffer);
vk::Error submitAndFinishCommandBuffer(vk::CommandBuffer *commandBuffer);
vk::Error submitCommandsWithSync(vk::CommandBuffer *commandBuffer,
const vk::Semaphore &waitSemaphore,
const vk::Semaphore &signalSemaphore);
vk::Error finish();
const gl::Caps &getNativeCaps() const;
const gl::TextureCapsMap &getNativeTextureCaps() const;
const gl::Extensions &getNativeExtensions() const;
const gl::Limitations &getNativeLimitations() const;
vk::Error createStagingImage(TextureDimension dimension,
const vk::Format &format,
const gl::Extents &extent,
vk::StagingImage *imageOut);
GlslangWrapper *getGlslangWrapper();
Serial getCurrentQueueSerial() const;
template <typename T>
void enqueueGarbage(Serial serial, T &&object)
{
mGarbage.emplace_back(std::unique_ptr<vk::GarbageObject<T>>(
new vk::GarbageObject<T>(serial, std::move(object))));
}
template <typename T>
void enqueueGarbageOrDeleteNow(const ResourceVk &resouce, T &&object)
{
if (resouce.getDeleteSchedule(mLastCompletedQueueSerial) == DeleteSchedule::NOW)
{
object.destroy(mDevice);
}
else
{
enqueueGarbage(resouce.getStoredQueueSerial(), std::move(object));
}
}
private:
void ensureCapsInitialized() const;
void generateCaps(gl::Caps *outCaps,
gl::TextureCapsMap *outTextureCaps,
gl::Extensions *outExtensions,
gl::Limitations *outLimitations) const;
vk::Error submit(const VkSubmitInfo &submitInfo);
vk::Error submitFrame(const VkSubmitInfo &submitInfo);
vk::Error checkInFlightCommands();
void freeAllInFlightResources();
mutable bool mCapsInitialized;
mutable gl::Caps mNativeCaps;
mutable gl::TextureCapsMap mNativeTextureCaps;
mutable gl::Extensions mNativeExtensions;
mutable gl::Limitations mNativeLimitations;
vk::Error initializeDevice(uint32_t queueFamilyIndex);
VkInstance mInstance;
bool mEnableValidationLayers;
VkDebugReportCallbackEXT mDebugReportCallback;
VkPhysicalDevice mPhysicalDevice;
VkPhysicalDeviceProperties mPhysicalDeviceProperties;
std::vector<VkQueueFamilyProperties> mQueueFamilyProperties;
VkQueue mQueue;
uint32_t mCurrentQueueFamilyIndex;
VkDevice mDevice;
vk::CommandPool mCommandPool;
vk::CommandBuffer mCommandBuffer;
uint32_t mHostVisibleMemoryIndex;
GlslangWrapper *mGlslangWrapper;
Serial mCurrentQueueSerial;
Serial mLastCompletedQueueSerial;
std::vector<vk::CommandBufferAndSerial> mInFlightCommands;
std::vector<vk::FenceAndSerial> mInFlightFences;
std::vector<std::unique_ptr<vk::IGarbageObject>> mGarbage;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_RENDERERVK_H_