diff --git a/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpu.h b/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpu.h new file mode 100644 index 00000000000..357acd0e65e --- /dev/null +++ b/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpu.h @@ -0,0 +1,62 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "VirtGpu.h" + +class FuchsiaVirtGpuBlob : public std::enable_shared_from_this, + public VirtGpuBlob { + public: + FuchsiaVirtGpuBlob(int64_t deviceHandle, uint32_t blobHandle, uint32_t resourceHandle, + uint64_t size); + ~FuchsiaVirtGpuBlob(); + + uint32_t getResourceHandle(void) override; + uint32_t getBlobHandle(void) override; + int wait(void) override; + + int exportBlob(struct VirtGpuExternalHandle& handle) override; + int transferFromHost(uint32_t offset, uint32_t size) override; + int transferToHost(uint32_t offset, uint32_t size) override; + + VirtGpuBlobMappingPtr createMapping(void) override; +}; + +class FuchsiaVirtGpuBlobMapping : public VirtGpuBlobMapping { + public: + FuchsiaVirtGpuBlobMapping(VirtGpuBlobPtr blob, uint8_t* ptr, uint64_t size); + ~FuchsiaVirtGpuBlobMapping(void); + + uint8_t* asRawPtr(void) override; +}; + +class FuchsiaVirtGpuDevice : public VirtGpuDevice { + public: + FuchsiaVirtGpuDevice(enum VirtGpuCapset capset); + ~FuchsiaVirtGpuDevice(); + + int64_t getDeviceHandle(void) override; + + struct VirtGpuCaps getCaps(void) override; + + VirtGpuBlobPtr createBlob(const struct VirtGpuCreateBlob& blobCreate) override; + VirtGpuBlobPtr createPipeBlob(uint32_t size) override; + VirtGpuBlobPtr createPipeTexture2D(uint32_t width, uint32_t height, uint32_t format) override; + VirtGpuBlobPtr importBlob(const struct VirtGpuExternalHandle& handle) override; + + int execBuffer(struct VirtGpuExecBuffer& execbuffer, VirtGpuBlobPtr blob) override; +}; diff --git a/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpuBlob.cpp b/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpuBlob.cpp new file mode 100644 index 00000000000..a300f61625b --- /dev/null +++ b/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpuBlob.cpp @@ -0,0 +1,56 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "FuchsiaVirtGpu.h" + +FuchsiaVirtGpuBlob::FuchsiaVirtGpuBlob(int64_t deviceHandle, uint32_t blobHandle, + uint32_t resourceHandle, uint64_t size) {} + +FuchsiaVirtGpuBlob::~FuchsiaVirtGpuBlob(void) {} + +uint32_t FuchsiaVirtGpuBlob::getBlobHandle(void) { + ALOGE("%s: unimplemented", __func__); + return 0; +} + +uint32_t FuchsiaVirtGpuBlob::getResourceHandle(void) { + ALOGE("%s: unimplemented", __func__); + return 0; +} + +VirtGpuBlobMappingPtr FuchsiaVirtGpuBlob::createMapping(void) { + ALOGE("%s: unimplemented", __func__); + return nullptr; +} + +int FuchsiaVirtGpuBlob::wait() { return -1; } + +int FuchsiaVirtGpuBlob::exportBlob(struct VirtGpuExternalHandle& handle) { + ALOGE("%s: unimplemented", __func__); + return 0; +} + +int FuchsiaVirtGpuBlob::transferFromHost(uint32_t offset, uint32_t size) { + ALOGE("%s: unimplemented", __func__); + return 0; +} + +int FuchsiaVirtGpuBlob::transferToHost(uint32_t offset, uint32_t size) { + ALOGE("%s: unimplemented", __func__); + return 0; +} diff --git a/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpuBlobMapping.cpp b/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpuBlobMapping.cpp new file mode 100644 index 00000000000..9eb58dc3955 --- /dev/null +++ b/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpuBlobMapping.cpp @@ -0,0 +1,24 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "FuchsiaVirtGpu.h" + +FuchsiaVirtGpuBlobMapping::FuchsiaVirtGpuBlobMapping(VirtGpuBlobPtr blob, uint8_t* ptr, + uint64_t size) {} + +FuchsiaVirtGpuBlobMapping::~FuchsiaVirtGpuBlobMapping(void) {} + +uint8_t* FuchsiaVirtGpuBlobMapping::asRawPtr(void) { return nullptr; } diff --git a/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpuDevice.cpp b/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpuDevice.cpp new file mode 100644 index 00000000000..9f0c9ac7a09 --- /dev/null +++ b/src/gfxstream/guest/platform/fuchsia/FuchsiaVirtGpuDevice.cpp @@ -0,0 +1,65 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "FuchsiaVirtGpu.h" + +FuchsiaVirtGpuDevice::FuchsiaVirtGpuDevice(enum VirtGpuCapset capset) : VirtGpuDevice(capset) {} + +FuchsiaVirtGpuDevice::~FuchsiaVirtGpuDevice() {} + +int64_t FuchsiaVirtGpuDevice::getDeviceHandle(void) { + ALOGE("%s: unimplemented", __func__); + return 0; +} + +VirtGpuBlobPtr FuchsiaVirtGpuDevice::createPipeBlob(uint32_t size) { + ALOGE("%s: unimplemented", __func__); + return nullptr; +} + +VirtGpuBlobPtr FuchsiaVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob& blobCreate) { + ALOGE("%s: unimplemented", __func__); + return nullptr; +} + +VirtGpuBlobPtr FuchsiaVirtGpuDevice::createPipeTexture2D(uint32_t width, uint32_t height, + uint32_t format) { + ALOGE("%s: unimplemented", __func__); + return nullptr; +} + +VirtGpuBlobPtr FuchsiaVirtGpuDevice::importBlob(const struct VirtGpuExternalHandle& handle) { + ALOGE("%s: unimplemented", __func__); + return nullptr; +} + +int FuchsiaVirtGpuDevice::execBuffer(struct VirtGpuExecBuffer& execbuffer, VirtGpuBlobPtr blob) { + ALOGE("%s: unimplemented", __func__); + return 0; +} + +struct VirtGpuCaps FuchsiaVirtGpuDevice::getCaps(void) { return {}; } + +VirtGpuDevice* createPlatformVirtGpuDevice(enum VirtGpuCapset capset, int fd) { + // We don't handle the VirtioGpuPipeStream case. + if (fd >= 0) { + ALOGE("Fuchsia: fd not handled"); + abort(); + } + return new FuchsiaVirtGpuDevice(capset); +}