mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
Gfxstream: Initial mingw "compilable" Windows version of mesa/gfxstream
Initial "compilable" version of mesa/gfxstream on Windows. For now it is achieved through "#if !DETECT_OS_WINDOWS" directives hence it is NOT functional. The compilation works with mingw only and the compilation is tested in a windows host. This commit is intended to only pass the compilation process without errors. Also created stub code for a future windows implementation. Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32795>
This commit is contained in:
parent
f4eb6fde8f
commit
9ab62e6452
15 changed files with 274 additions and 8 deletions
|
|
@ -592,7 +592,7 @@ if with_dri
|
|||
endif
|
||||
|
||||
dep_dxheaders = null_dep
|
||||
if with_gallium_d3d12 or with_microsoft_clc or with_microsoft_vk
|
||||
if with_gallium_d3d12 or with_microsoft_clc or with_microsoft_vk or with_gfxstream_vk and host_machine.system() == 'windows'
|
||||
dep_dxheaders = dependency('directx-headers', required : false)
|
||||
if not dep_dxheaders.found()
|
||||
dep_dxheaders = dependency('DirectX-Headers',
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ class IOStream;
|
|||
// required extensions, but the approach will be to
|
||||
// implement them completely on the guest side.
|
||||
#undef VK_KHR_android_surface
|
||||
#if defined(LINUX_GUEST_BUILD) || defined(__Fuchsia__)
|
||||
#if defined(LINUX_GUEST_BUILD) || DETECT_OS_FUCHSIA || DETECT_OS_WINDOWS
|
||||
#undef VK_ANDROID_native_buffer
|
||||
#endif
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -5,11 +5,14 @@ inc_goldfish_address_space = include_directories('include')
|
|||
|
||||
files_lib_goldfish_address_space = files(
|
||||
'AddressSpaceStream.cpp',
|
||||
'GoldfishAddressSpaceStream.cpp',
|
||||
'VirtioGpuAddressSpaceStream.cpp',
|
||||
'goldfish_address_space.cpp',
|
||||
)
|
||||
|
||||
if host_machine.system() == 'android'
|
||||
files_lib_goldfish_address_space += files('GoldfishAddressSpaceStream.cpp')
|
||||
files_lib_goldfish_address_space += files('goldfish_address_space.cpp')
|
||||
endif
|
||||
|
||||
lib_goldfish_address_space = static_library(
|
||||
'goldfish_address_space',
|
||||
files_lib_goldfish_address_space,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ GfxStreamConnectionManager::~GfxStreamConnectionManager() {}
|
|||
|
||||
bool GfxStreamConnectionManager::initialize() {
|
||||
switch (mTransportType) {
|
||||
#ifdef GFXSTREAM_ENABLE_GUEST_GOLDFISH
|
||||
case GFXSTREAM_TRANSPORT_ADDRESS_SPACE: {
|
||||
mStream = createGoldfishAddressSpaceStream(STREAM_BUFFER_SIZE);
|
||||
if (!mStream) {
|
||||
|
|
@ -38,6 +39,7 @@ bool GfxStreamConnectionManager::initialize() {
|
|||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case GFXSTREAM_TRANSPORT_QEMU_PIPE: {
|
||||
mStream = new QemuPipeStream(STREAM_BUFFER_SIZE);
|
||||
if (mStream->connect() < 0) {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,13 @@
|
|||
#include "VirtioGpuPipeStream.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "util/detect_os.h"
|
||||
#if DETECT_OS_LINUX
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,11 @@ endif
|
|||
gfxstream_guest_args = []
|
||||
|
||||
# Our internal guest build
|
||||
gfxstream_guest_args += '-DLINUX_GUEST_BUILD'
|
||||
if host_machine.system() == 'windows'
|
||||
gfxstream_guest_args += '-DWINDOWS_GUEST_BUILD'
|
||||
else
|
||||
gfxstream_guest_args += '-DLINUX_GUEST_BUILD'
|
||||
endif
|
||||
# Include the gfxstream private VkStructureType definitions
|
||||
gfxstream_guest_args += '-DVK_GFXSTREAM_STRUCTURE_TYPE_EXT'
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,16 @@
|
|||
inc_platform_virtgpu = include_directories('include')
|
||||
|
||||
subdir('kumquat')
|
||||
subdir('linux')
|
||||
|
||||
libplatform_virtgpu = [libplatform_virtgpu_kumquat]
|
||||
|
||||
if system_has_kms_drm
|
||||
subdir('linux')
|
||||
libplatform_virtgpu += libplatform_virtgpu_linux
|
||||
elif host_machine.system() == 'windows'
|
||||
subdir('windows')
|
||||
libplatform_virtgpu += libplatform_virtgpu_windows
|
||||
endif
|
||||
|
||||
files_libplatform_virtgpu = files(
|
||||
'VirtGpu.cpp',
|
||||
|
|
@ -15,5 +24,5 @@ libplatform_virtgpu = static_library(
|
|||
files_libplatform_virtgpu,
|
||||
cpp_args: gfxstream_guest_args,
|
||||
include_directories: [inc_platform_virtgpu, inc_src],
|
||||
link_with: [libplatform_virtgpu_kumquat, libplatform_virtgpu_linux]
|
||||
link_with: libplatform_virtgpu
|
||||
)
|
||||
|
|
|
|||
30
src/gfxstream/guest/platform/windows/WindowsSync.cpp
Normal file
30
src/gfxstream/guest/platform/windows/WindowsSync.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright 2025 Mesa3D authors
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "WindowsSync.h"
|
||||
|
||||
namespace gfxstream {
|
||||
|
||||
WindowsSyncHelper::WindowsSyncHelper() {}
|
||||
|
||||
int WindowsSyncHelper::wait(int syncFd, int timeoutMilliseconds) {
|
||||
return -1; // stub constant
|
||||
}
|
||||
|
||||
void WindowsSyncHelper::debugPrint(int syncFd) {}
|
||||
|
||||
int WindowsSyncHelper::dup(int syncFd) {
|
||||
return -1; // stub constant
|
||||
}
|
||||
|
||||
int WindowsSyncHelper::close(int syncFd) {
|
||||
return -1; // stub constant
|
||||
}
|
||||
|
||||
SyncHelper* osCreateSyncHelper() {
|
||||
return nullptr; // stub constant
|
||||
}
|
||||
|
||||
} // namespace gfxstream
|
||||
25
src/gfxstream/guest/platform/windows/WindowsSync.h
Normal file
25
src/gfxstream/guest/platform/windows/WindowsSync.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright 2025 Mesa3D authors
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Sync.h"
|
||||
|
||||
namespace gfxstream {
|
||||
|
||||
class WindowsSyncHelper : public SyncHelper {
|
||||
public:
|
||||
WindowsSyncHelper();
|
||||
|
||||
int wait(int syncFd, int timeoutMilliseconds) override;
|
||||
|
||||
void debugPrint(int syncFd) override;
|
||||
|
||||
int dup(int syncFd) override;
|
||||
|
||||
int close(int syncFd) override;
|
||||
};
|
||||
|
||||
} // namespace gfxstream
|
||||
72
src/gfxstream/guest/platform/windows/WindowsVirtGPU.h
Normal file
72
src/gfxstream/guest/platform/windows/WindowsVirtGPU.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright 2025 Mesa3D authors
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VirtGpu.h"
|
||||
|
||||
class WindowsVirtGpuResource : public std::enable_shared_from_this<WindowsVirtGpuResource>,
|
||||
public VirtGpuResource {
|
||||
public:
|
||||
WindowsVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle, uint32_t resourceHandle,
|
||||
uint64_t size);
|
||||
~WindowsVirtGpuResource();
|
||||
|
||||
void intoRaw() override;
|
||||
uint32_t getResourceHandle() const override;
|
||||
uint32_t getBlobHandle() const override;
|
||||
uint64_t getSize() const override;
|
||||
int wait() override;
|
||||
|
||||
VirtGpuResourceMappingPtr createMapping(void) override;
|
||||
int exportBlob(struct VirtGpuExternalHandle& handle) override;
|
||||
|
||||
int transferFromHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) override;
|
||||
int transferToHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) override;
|
||||
|
||||
private:
|
||||
// Not owned. Really should use a ScopedFD for this, but doesn't matter since we have a
|
||||
// singleton deviceimplemenentation anyways.
|
||||
int64_t mDeviceHandle;
|
||||
|
||||
uint32_t mBlobHandle;
|
||||
uint32_t mResourceHandle;
|
||||
uint64_t mSize;
|
||||
};
|
||||
|
||||
class WindowsVirtGpuResourceMapping : public VirtGpuResourceMapping {
|
||||
public:
|
||||
WindowsVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr, uint64_t size);
|
||||
~WindowsVirtGpuResourceMapping(void);
|
||||
|
||||
uint8_t* asRawPtr(void) override;
|
||||
|
||||
private:
|
||||
VirtGpuResourcePtr mBlob;
|
||||
uint8_t* mPtr;
|
||||
uint64_t mSize;
|
||||
};
|
||||
|
||||
class WindowsVirtGpuDevice : public VirtGpuDevice {
|
||||
public:
|
||||
WindowsVirtGpuDevice(enum VirtGpuCapset capset, int fd = -1);
|
||||
virtual ~WindowsVirtGpuDevice();
|
||||
|
||||
virtual int64_t getDeviceHandle(void);
|
||||
|
||||
virtual struct VirtGpuCaps getCaps(void);
|
||||
|
||||
VirtGpuResourcePtr createBlob(const struct VirtGpuCreateBlob& blobCreate) override;
|
||||
VirtGpuResourcePtr createResource(uint32_t width, uint32_t height, uint32_t stride,
|
||||
uint32_t size, uint32_t virglFormat, uint32_t target,
|
||||
uint32_t bind) override;
|
||||
|
||||
virtual VirtGpuResourcePtr importBlob(const struct VirtGpuExternalHandle& handle);
|
||||
virtual int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuResource* blob);
|
||||
|
||||
private:
|
||||
int64_t mDeviceHandle;
|
||||
struct VirtGpuCaps mCaps;
|
||||
};
|
||||
46
src/gfxstream/guest/platform/windows/WindowsVirtGpuBlob.cpp
Normal file
46
src/gfxstream/guest/platform/windows/WindowsVirtGpuBlob.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2025 Mesa3D authors
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "WindowsVirtGpu.h"
|
||||
|
||||
WindowsVirtGpuResource::WindowsVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle,
|
||||
uint32_t resourceHandle, uint64_t size)
|
||||
: mDeviceHandle(deviceHandle),
|
||||
mBlobHandle(blobHandle),
|
||||
mResourceHandle(resourceHandle),
|
||||
mSize(size) {}
|
||||
|
||||
WindowsVirtGpuResource::~WindowsVirtGpuResource() {}
|
||||
|
||||
void WindowsVirtGpuResource::intoRaw() {
|
||||
mBlobHandle = INVALID_DESCRIPTOR;
|
||||
mResourceHandle = INVALID_DESCRIPTOR;
|
||||
}
|
||||
|
||||
uint32_t WindowsVirtGpuResource::getBlobHandle() const { return mBlobHandle; }
|
||||
|
||||
uint32_t WindowsVirtGpuResource::getResourceHandle() const { return mResourceHandle; }
|
||||
|
||||
uint64_t WindowsVirtGpuResource::getSize() const { return mSize; }
|
||||
|
||||
VirtGpuResourceMappingPtr WindowsVirtGpuResource::createMapping() {
|
||||
return nullptr; // stub constant
|
||||
}
|
||||
|
||||
int WindowsVirtGpuResource::exportBlob(struct VirtGpuExternalHandle& handle) {
|
||||
return 0; // stub constant
|
||||
}
|
||||
|
||||
int WindowsVirtGpuResource::wait() {
|
||||
return 0; // stub constant
|
||||
}
|
||||
|
||||
int WindowsVirtGpuResource::transferToHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
return 0; // stub constant
|
||||
}
|
||||
|
||||
int WindowsVirtGpuResource::transferFromHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
return 0; // stub constant
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright 2025 Mesa3D authors
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "WindowsVirtGpu.h"
|
||||
|
||||
WindowsVirtGpuResourceMapping::WindowsVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr,
|
||||
uint64_t size)
|
||||
: mBlob(blob), mPtr(ptr), mSize(size) {}
|
||||
|
||||
WindowsVirtGpuResourceMapping::~WindowsVirtGpuResourceMapping(void) {}
|
||||
|
||||
uint8_t* WindowsVirtGpuResourceMapping::asRawPtr(void) { return mPtr; }
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2025 Mesa3D authors
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "WindowsVirtGpu.h"
|
||||
|
||||
WindowsVirtGpuDevice::WindowsVirtGpuDevice(enum VirtGpuCapset capset, int32_t descriptor)
|
||||
: VirtGpuDevice(capset) {}
|
||||
|
||||
WindowsVirtGpuDevice::~WindowsVirtGpuDevice() {}
|
||||
|
||||
struct VirtGpuCaps WindowsVirtGpuDevice::getCaps(void) { return mCaps; }
|
||||
|
||||
int64_t WindowsVirtGpuDevice::getDeviceHandle(void) { return mDeviceHandle; }
|
||||
|
||||
VirtGpuResourcePtr WindowsVirtGpuDevice::createResource(uint32_t width, uint32_t height,
|
||||
uint32_t stride, uint32_t size,
|
||||
uint32_t virglFormat, uint32_t target,
|
||||
uint32_t bind) {
|
||||
return nullptr; // stub constant
|
||||
}
|
||||
|
||||
VirtGpuResourcePtr WindowsVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob& blobCreate) {
|
||||
return nullptr; // stub constant
|
||||
}
|
||||
|
||||
VirtGpuResourcePtr WindowsVirtGpuDevice::importBlob(const struct VirtGpuExternalHandle& handle) {
|
||||
return nullptr; // stub constant
|
||||
}
|
||||
|
||||
int WindowsVirtGpuDevice::execBuffer(struct VirtGpuExecBuffer& execbuffer,
|
||||
const VirtGpuResource* blob) {
|
||||
return 0; // stub constant
|
||||
}
|
||||
|
||||
VirtGpuDevice* osCreateVirtGpuDevice(enum VirtGpuCapset capset, int32_t descriptor) {
|
||||
return nullptr; // stub constant
|
||||
}
|
||||
16
src/gfxstream/guest/platform/windows/meson.build
Normal file
16
src/gfxstream/guest/platform/windows/meson.build
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Copyright 2025 Mesa3D authors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
files_libplatform_virtgpu_windows = files(
|
||||
'WindowsVirtGpuDevice.cpp',
|
||||
'WindowsVirtGpuBlobMapping.cpp',
|
||||
'WindowsVirtGpuBlob.cpp',
|
||||
'WindowsSync.cpp',
|
||||
)
|
||||
|
||||
libplatform_virtgpu_windows = static_library(
|
||||
'platform_virtgpu_windows',
|
||||
files_libplatform_virtgpu_windows,
|
||||
cpp_args: gfxstream_guest_args,
|
||||
include_directories: [inc_platform_virtgpu, inc_src, inc_include],
|
||||
)
|
||||
|
|
@ -4269,6 +4269,7 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
|||
} else {
|
||||
return VK_ERROR_VALIDATION_FAILED_EXT;
|
||||
}
|
||||
return VK_ERROR_VALIDATION_FAILED_EXT; // stub constant
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6746,6 +6747,7 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
|
|||
|
||||
// Host doesn't support DRM format modifiers, try emulating.
|
||||
if (drmFmtMod) {
|
||||
|
||||
if (drmFmtMod->drmFormatModifier == DRM_FORMAT_MOD_LINEAR) {
|
||||
localImageFormatInfo.tiling = VK_IMAGE_TILING_LINEAR;
|
||||
pImageFormatInfo = &localImageFormatInfo;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue