Files
Jason Macnak a43dfa9f3c Add gfxstream host logging lib
... to eventually replace the existing host-common/logging. This
is needed to break up the circular dependency between aemu-base and
aemu-host-common, so that we can move parts of aemu-base and
aemu-host-common into hardware/google/gfxstream, in order to make
Gfxstream a self contained library for building.

Hooks up the existing host-common/logging via the
RenderLibImpl::setLogger() call.

Bug: b/403363880

Test: cd hardware/google/gfxstream
      mma

Test: cd hardware/google/gfxstream
      mkdir build && cd build
      cmake .. -G Ninja
      ninja

Test: meson setup \
        -Ddefault_library=static \
        -Dgfxstream-build=host \
        build
      meson compile -C build

Test: cd <emu master dev repo>
      cd external/qemu
      python android/build/python/cmake.py --gfxstream

Test: cd <emu main next repo>
      prebuilts/bazel/linux-x86_64/bazel test \
      --platforms=@//build/bazel/platforms:linux_x64 \
     @gfxstream//...

Change-Id: Id52c6f756f85d0a5fb948601228234d7a84a14c2
2025-04-09 13:11:08 -07:00

68 lines
2.2 KiB
C++

// 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 expresso or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "BufferVk.h"
#include "VkCommonOperations.h"
namespace gfxstream {
namespace vk {
/*static*/
std::unique_ptr<BufferVk> BufferVk::create(VkEmulation& vkEmulation, uint32_t handle, uint64_t size,
bool vulkanOnly) {
if (!vkEmulation.setupVkBuffer(size, handle, vulkanOnly, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) {
GFXSTREAM_ERROR("Failed to create BufferVk:%d", handle);
return nullptr;
}
return std::unique_ptr<BufferVk>(new BufferVk(vkEmulation, handle));
}
BufferVk::BufferVk(VkEmulation& vkEmulation, uint32_t handle)
: mVkEmulation(vkEmulation), mHandle(handle) {}
BufferVk::~BufferVk() {
if (!mVkEmulation.teardownVkBuffer(mHandle)) {
GFXSTREAM_ERROR("Failed to destroy BufferVk:%d", mHandle);
}
}
void BufferVk::readToBytes(uint64_t offset, uint64_t size, void* outBytes) {
mVkEmulation.readBufferToBytes(mHandle, offset, size, outBytes);
}
bool BufferVk::updateFromBytes(uint64_t offset, uint64_t size, const void* bytes) {
return mVkEmulation.updateBufferFromBytes(mHandle, offset, size, bytes);
}
std::optional<BlobDescriptorInfo> BufferVk::exportBlob() {
auto dupHandleInfo = mVkEmulation.dupBufferExtMemoryHandle(mHandle);
if (!dupHandleInfo) {
return std::nullopt;
}
return BlobDescriptorInfo{
.descriptorInfo =
{
.descriptor = dupHandleInfo->toManagedDescriptor(),
.streamHandleType = dupHandleInfo->streamHandleType,
},
.caching = 0,
.vulkanInfoOpt = std::nullopt,
};
}
} // namespace vk
} // namespace gfxstream