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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
/*
** Copyright (c) 2021, Arm Limited.
** Copyright (c) 2021 LunarG, Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and associated documentation files (the "Software"),
** to deal in the Software without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Software, and to permit persons to whom the
** Software is furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
** FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
** DEALINGS IN THE SOFTWARE.
*/
#include "application/headless_window.h"
#include "application/application.h"
#include <cassert>
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(application)
HeadlessWindow::HeadlessWindow(HeadlessContext* headless_context) : headless_context_(headless_context)
{
assert(headless_context_ != nullptr);
}
HeadlessWindow::~HeadlessWindow() {}
bool HeadlessWindow::Create(
const std::string& title, const int32_t xpos, const int32_t ypos, const uint32_t width, const uint32_t height)
{
GFXRECON_UNREFERENCED_PARAMETER(title);
GFXRECON_UNREFERENCED_PARAMETER(xpos);
GFXRECON_UNREFERENCED_PARAMETER(ypos);
GFXRECON_UNREFERENCED_PARAMETER(width);
GFXRECON_UNREFERENCED_PARAMETER(height);
return true;
}
bool HeadlessWindow::Destroy()
{
return true;
}
void HeadlessWindow::SetTitle(const std::string& title)
{
GFXRECON_UNREFERENCED_PARAMETER(title);
}
void HeadlessWindow::SetPosition(const int32_t x, const int32_t y)
{
GFXRECON_UNREFERENCED_PARAMETER(x);
GFXRECON_UNREFERENCED_PARAMETER(y);
}
void HeadlessWindow::SetSize(const uint32_t width, const uint32_t height)
{
GFXRECON_UNREFERENCED_PARAMETER(width);
GFXRECON_UNREFERENCED_PARAMETER(height);
}
void HeadlessWindow::SetSizePreTransform(const uint32_t width, const uint32_t height, const uint32_t pre_transform)
{
GFXRECON_UNREFERENCED_PARAMETER(width);
GFXRECON_UNREFERENCED_PARAMETER(height);
GFXRECON_UNREFERENCED_PARAMETER(pre_transform);
}
void HeadlessWindow::SetVisibility(bool show)
{
GFXRECON_UNREFERENCED_PARAMETER(show);
}
void HeadlessWindow::SetForeground() {}
bool HeadlessWindow::GetNativeHandle(HandleType type, void** handle)
{
GFXRECON_UNREFERENCED_PARAMETER(type);
GFXRECON_UNREFERENCED_PARAMETER(handle);
return false;
}
std::string HeadlessWindow::GetWsiExtension() const
{
return VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME;
}
VkResult HeadlessWindow::CreateSurface(const encode::InstanceTable* table,
VkInstance instance,
VkFlags flags,
VkSurfaceKHR* pSurface)
{
GFXRECON_UNREFERENCED_PARAMETER(flags);
if (table != nullptr)
{
VkHeadlessSurfaceCreateInfoEXT create_info{ VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT, nullptr, 0 };
return table->CreateHeadlessSurfaceEXT(instance, &create_info, nullptr, pSurface);
}
return VK_ERROR_INITIALIZATION_FAILED;
}
void HeadlessWindow::DestroySurface(const encode::InstanceTable* table, VkInstance instance, VkSurfaceKHR surface)
{
if (table != nullptr)
{
table->DestroySurfaceKHR(instance, surface, nullptr);
}
}
HeadlessWindowFactory::HeadlessWindowFactory(HeadlessContext* headless_context) : headless_context_(headless_context)
{
assert(headless_context_ != nullptr);
}
decode::Window*
HeadlessWindowFactory::Create(const int32_t x, const int32_t y, const uint32_t width, const uint32_t height)
{
assert(headless_context_);
decode::Window* window = new HeadlessWindow(headless_context_);
auto application = headless_context_->GetApplication();
assert(application);
window->Create(application->GetName(), x, y, width, height);
return window;
}
void HeadlessWindowFactory::Destroy(decode::Window* window)
{
if (window != nullptr)
{
window->Destroy();
delete window;
}
}
VkBool32 HeadlessWindowFactory::GetPhysicalDevicePresentationSupport(const encode::InstanceTable* table,
VkPhysicalDevice physical_device,
uint32_t queue_family_index)
{
GFXRECON_UNREFERENCED_PARAMETER(table);
GFXRECON_UNREFERENCED_PARAMETER(physical_device);
GFXRECON_UNREFERENCED_PARAMETER(queue_family_index);
return true;
}
GFXRECON_END_NAMESPACE(application)
GFXRECON_END_NAMESPACE(gfxrecon)
|