mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 22:08:26 +02:00
Rename VirtGpuBlob -> VirtGpuResource
... as this is more generic and "VirglBlob" is not actually a blob.
find . -type f -name "*.cpp" -print0 | \
xargs -0 sed -i '' -e 's/VirtGpuBlob/VirtGpuResource/g'
find . -type f -name "*.h" -print0 | \
xargs -0 sed -i '' -e 's/VirtGpuBlob/VirtGpuResource/g'
find . -type f -name "*.cpp" -print0 | \
xargs -0 sed -i '' -e 's/createVirglBlob/createResource/g'
find . -type f -name "*.h" -print0 | \
xargs -0 sed -i '' -e 's/createVirglBlob/createResource/g'
Reviewed-by: Aaron Ruby <aruby@blackberry.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
parent
d9518399dc
commit
d0a61f5813
17 changed files with 123 additions and 118 deletions
|
|
@ -76,8 +76,8 @@ bool virtgpu_address_space_ping(address_space_handle_t, struct address_space_pin
|
|||
|
||||
AddressSpaceStream* createVirtioGpuAddressSpaceStream(enum VirtGpuCapset capset,
|
||||
HealthMonitor<>* healthMonitor) {
|
||||
VirtGpuBlobPtr pipe, blob;
|
||||
VirtGpuBlobMappingPtr pipeMapping, blobMapping;
|
||||
VirtGpuResourcePtr pipe, blob;
|
||||
VirtGpuResourceMappingPtr pipeMapping, blobMapping;
|
||||
struct VirtGpuExecBuffer exec = {};
|
||||
struct VirtGpuCreateBlob blobCreate = {};
|
||||
struct gfxstreamContextCreate contextCreate = {};
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@ public:
|
|||
virtual int writeFullyAsync(const void *buf, size_t len);
|
||||
virtual const unsigned char *commitBufferAndReadFully(size_t size, void *buf, size_t len);
|
||||
|
||||
void setMapping(VirtGpuBlobMappingPtr mapping) {
|
||||
m_mapping = mapping;
|
||||
}
|
||||
void setMapping(VirtGpuResourceMappingPtr mapping) { m_mapping = mapping; }
|
||||
|
||||
void setResourceId(uint32_t id) {
|
||||
m_resourceId = id;
|
||||
|
|
@ -68,7 +66,7 @@ private:
|
|||
void backoff();
|
||||
void resetBackoff();
|
||||
|
||||
VirtGpuBlobMappingPtr m_mapping = nullptr;
|
||||
VirtGpuResourceMappingPtr m_mapping = nullptr;
|
||||
struct address_space_ops m_ops;
|
||||
|
||||
unsigned char* m_tmpBuf;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ std::optional<uint32_t> DrmToVirglFormat(uint32_t drmFormat) {
|
|||
} // namespace
|
||||
|
||||
EmulatedAHardwareBuffer::EmulatedAHardwareBuffer(uint32_t width, uint32_t height,
|
||||
VirtGpuBlobPtr resource)
|
||||
VirtGpuResourcePtr resource)
|
||||
: mRefCount(1), mWidth(width), mHeight(height), mResource(resource) {}
|
||||
|
||||
EmulatedAHardwareBuffer::~EmulatedAHardwareBuffer() {}
|
||||
|
|
@ -196,7 +196,7 @@ AHardwareBuffer* EmulatedGralloc::allocate(uint32_t width, uint32_t height, uint
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto resource = device->createVirglBlob(width, height, *virglFormat);
|
||||
auto resource = device->createResource(width, height, *virglFormat);
|
||||
if (!resource) {
|
||||
ALOGE("Failed to allocate: failed to create virtio resource.");
|
||||
return nullptr;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ using EGLClientBuffer = void*;
|
|||
|
||||
class EmulatedAHardwareBuffer {
|
||||
public:
|
||||
EmulatedAHardwareBuffer(uint32_t width, uint32_t height, VirtGpuBlobPtr resource);
|
||||
EmulatedAHardwareBuffer(uint32_t width, uint32_t height, VirtGpuResourcePtr resource);
|
||||
|
||||
~EmulatedAHardwareBuffer();
|
||||
|
||||
|
|
@ -56,8 +56,8 @@ class EmulatedAHardwareBuffer {
|
|||
uint32_t mRefCount;
|
||||
uint32_t mWidth;
|
||||
uint32_t mHeight;
|
||||
VirtGpuBlobPtr mResource;
|
||||
std::optional<VirtGpuBlobMappingPtr> mMapped;
|
||||
VirtGpuResourcePtr mResource;
|
||||
std::optional<VirtGpuResourceMappingPtr> mMapped;
|
||||
};
|
||||
|
||||
class EmulatedGralloc : public Gralloc {
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@
|
|||
|
||||
#include "VirtGpu.h"
|
||||
|
||||
class FuchsiaVirtGpuBlob : public std::enable_shared_from_this<FuchsiaVirtGpuBlob>,
|
||||
public VirtGpuBlob {
|
||||
class FuchsiaVirtGpuResource : public std::enable_shared_from_this<FuchsiaVirtGpuResource>,
|
||||
public VirtGpuResource {
|
||||
public:
|
||||
FuchsiaVirtGpuBlob(int64_t deviceHandle, uint32_t blobHandle, uint32_t resourceHandle,
|
||||
uint64_t size);
|
||||
~FuchsiaVirtGpuBlob();
|
||||
FuchsiaVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle, uint32_t resourceHandle,
|
||||
uint64_t size);
|
||||
~FuchsiaVirtGpuResource();
|
||||
|
||||
uint32_t getResourceHandle() const override;
|
||||
uint32_t getBlobHandle() const override;
|
||||
|
|
@ -35,13 +35,13 @@ class FuchsiaVirtGpuBlob : public std::enable_shared_from_this<FuchsiaVirtGpuBlo
|
|||
int transferFromHost(uint32_t offset, uint32_t size) override;
|
||||
int transferToHost(uint32_t offset, uint32_t size) override;
|
||||
|
||||
VirtGpuBlobMappingPtr createMapping(void) override;
|
||||
VirtGpuResourceMappingPtr createMapping(void) override;
|
||||
};
|
||||
|
||||
class FuchsiaVirtGpuBlobMapping : public VirtGpuBlobMapping {
|
||||
class FuchsiaVirtGpuResourceMapping : public VirtGpuResourceMapping {
|
||||
public:
|
||||
FuchsiaVirtGpuBlobMapping(VirtGpuBlobPtr blob, uint8_t* ptr, uint64_t size);
|
||||
~FuchsiaVirtGpuBlobMapping(void);
|
||||
FuchsiaVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr, uint64_t size);
|
||||
~FuchsiaVirtGpuResourceMapping(void);
|
||||
|
||||
uint8_t* asRawPtr(void) override;
|
||||
};
|
||||
|
|
@ -55,11 +55,11 @@ class FuchsiaVirtGpuDevice : public VirtGpuDevice {
|
|||
|
||||
struct VirtGpuCaps getCaps(void) override;
|
||||
|
||||
VirtGpuBlobPtr createBlob(const struct VirtGpuCreateBlob& blobCreate) override;
|
||||
VirtGpuBlobPtr createVirglBlob(uint32_t width, uint32_t height, uint32_t format) override;
|
||||
VirtGpuBlobPtr importBlob(const struct VirtGpuExternalHandle& handle) override;
|
||||
VirtGpuResourcePtr createBlob(const struct VirtGpuCreateBlob& blobCreate) override;
|
||||
VirtGpuResourcePtr createResource(uint32_t width, uint32_t height, uint32_t format) override;
|
||||
VirtGpuResourcePtr importBlob(const struct VirtGpuExternalHandle& handle) override;
|
||||
|
||||
int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuBlob* blob) override;
|
||||
int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuResource* blob) override;
|
||||
|
||||
private:
|
||||
magma_device_t device_;
|
||||
|
|
|
|||
|
|
@ -18,39 +18,39 @@
|
|||
|
||||
#include "FuchsiaVirtGpu.h"
|
||||
|
||||
FuchsiaVirtGpuBlob::FuchsiaVirtGpuBlob(int64_t deviceHandle, uint32_t blobHandle,
|
||||
uint32_t resourceHandle, uint64_t size) {}
|
||||
FuchsiaVirtGpuResource::FuchsiaVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle,
|
||||
uint32_t resourceHandle, uint64_t size) {}
|
||||
|
||||
FuchsiaVirtGpuBlob::~FuchsiaVirtGpuBlob(void) {}
|
||||
FuchsiaVirtGpuResource::~FuchsiaVirtGpuResource(void) {}
|
||||
|
||||
uint32_t FuchsiaVirtGpuBlob::getBlobHandle() const {
|
||||
uint32_t FuchsiaVirtGpuResource::getBlobHandle() const {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t FuchsiaVirtGpuBlob::getResourceHandle() const {
|
||||
uint32_t FuchsiaVirtGpuResource::getResourceHandle() const {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VirtGpuBlobMappingPtr FuchsiaVirtGpuBlob::createMapping(void) {
|
||||
VirtGpuResourceMappingPtr FuchsiaVirtGpuResource::createMapping(void) {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int FuchsiaVirtGpuBlob::wait() { return -1; }
|
||||
int FuchsiaVirtGpuResource::wait() { return -1; }
|
||||
|
||||
int FuchsiaVirtGpuBlob::exportBlob(struct VirtGpuExternalHandle& handle) {
|
||||
int FuchsiaVirtGpuResource::exportBlob(struct VirtGpuExternalHandle& handle) {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FuchsiaVirtGpuBlob::transferFromHost(uint32_t offset, uint32_t size) {
|
||||
int FuchsiaVirtGpuResource::transferFromHost(uint32_t offset, uint32_t size) {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FuchsiaVirtGpuBlob::transferToHost(uint32_t offset, uint32_t size) {
|
||||
int FuchsiaVirtGpuResource::transferToHost(uint32_t offset, uint32_t size) {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
#include "FuchsiaVirtGpu.h"
|
||||
|
||||
FuchsiaVirtGpuBlobMapping::FuchsiaVirtGpuBlobMapping(VirtGpuBlobPtr blob, uint8_t* ptr,
|
||||
uint64_t size) {}
|
||||
FuchsiaVirtGpuResourceMapping::FuchsiaVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr,
|
||||
uint64_t size) {}
|
||||
|
||||
FuchsiaVirtGpuBlobMapping::~FuchsiaVirtGpuBlobMapping(void) {}
|
||||
FuchsiaVirtGpuResourceMapping::~FuchsiaVirtGpuResourceMapping(void) {}
|
||||
|
||||
uint8_t* FuchsiaVirtGpuBlobMapping::asRawPtr(void) { return nullptr; }
|
||||
uint8_t* FuchsiaVirtGpuResourceMapping::asRawPtr(void) { return nullptr; }
|
||||
|
|
|
|||
|
|
@ -32,24 +32,24 @@ FuchsiaVirtGpuDevice::~FuchsiaVirtGpuDevice() { magma_device_release(device_); }
|
|||
|
||||
int64_t FuchsiaVirtGpuDevice::getDeviceHandle(void) { return device_; }
|
||||
|
||||
VirtGpuBlobPtr FuchsiaVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob& blobCreate) {
|
||||
VirtGpuResourcePtr FuchsiaVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob& blobCreate) {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
VirtGpuBlobPtr FuchsiaVirtGpuDevice::createVirglBlob(uint32_t width, uint32_t height,
|
||||
uint32_t virglFormat) {
|
||||
VirtGpuResourcePtr FuchsiaVirtGpuDevice::createResource(uint32_t width, uint32_t height,
|
||||
uint32_t virglFormat) {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
VirtGpuBlobPtr FuchsiaVirtGpuDevice::importBlob(const struct VirtGpuExternalHandle& handle) {
|
||||
VirtGpuResourcePtr FuchsiaVirtGpuDevice::importBlob(const struct VirtGpuExternalHandle& handle) {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int FuchsiaVirtGpuDevice::execBuffer(struct VirtGpuExecBuffer& execbuffer,
|
||||
const VirtGpuBlob* blob) {
|
||||
const VirtGpuResource* blob) {
|
||||
ALOGE("%s: unimplemented", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#define VIRGL_BIND_RENDER_TARGET (1 << 1)
|
||||
#define VIRGL_BIND_CUSTOM (1 << 17)
|
||||
#define VIRGL_BIND_LINEAR (1 << 22)
|
||||
|
||||
#define PIPE_BUFFER 0
|
||||
#define PIPE_TEXTURE_2D 2
|
||||
|
||||
|
|
@ -78,14 +80,14 @@ enum VirtGpuHandleType {
|
|||
kFenceHandleZircon = 0x0080,
|
||||
};
|
||||
|
||||
enum VirtGpuBlobFlags : uint32_t {
|
||||
enum VirtGpuResourceFlags : uint32_t {
|
||||
kBlobFlagMappable = 0x0001,
|
||||
kBlobFlagShareable = 0x0002,
|
||||
kBlobFlagCrossDevice = 0x0004,
|
||||
kBlobFlagCreateGuestHandle = 0x0008,
|
||||
};
|
||||
|
||||
enum VirtGpuBlobMem {
|
||||
enum VirtGpuResourceMem {
|
||||
kBlobMemGuest = 0x0001,
|
||||
kBlobMemHost3d = 0x0002,
|
||||
kBlobMemHost3dGuest = 0x0003,
|
||||
|
|
@ -112,8 +114,8 @@ struct VirtGpuParam {
|
|||
|
||||
struct VirtGpuCreateBlob {
|
||||
uint64_t size;
|
||||
enum VirtGpuBlobFlags flags;
|
||||
enum VirtGpuBlobMem blobMem;
|
||||
enum VirtGpuResourceFlags flags;
|
||||
enum VirtGpuResourceMem blobMem;
|
||||
uint64_t blobId;
|
||||
};
|
||||
|
||||
|
|
@ -125,20 +127,20 @@ struct VirtGpuCaps {
|
|||
struct composerCapset composerCapset;
|
||||
};
|
||||
|
||||
class VirtGpuBlobMapping;
|
||||
class VirtGpuBlob;
|
||||
using VirtGpuBlobPtr = std::shared_ptr<VirtGpuBlob>;
|
||||
using VirtGpuBlobMappingPtr = std::shared_ptr<VirtGpuBlobMapping>;
|
||||
class VirtGpuResourceMapping;
|
||||
class VirtGpuResource;
|
||||
using VirtGpuResourcePtr = std::shared_ptr<VirtGpuResource>;
|
||||
using VirtGpuResourceMappingPtr = std::shared_ptr<VirtGpuResourceMapping>;
|
||||
|
||||
class VirtGpuBlob {
|
||||
public:
|
||||
virtual ~VirtGpuBlob() {}
|
||||
class VirtGpuResource {
|
||||
public:
|
||||
virtual ~VirtGpuResource() {}
|
||||
|
||||
virtual uint32_t getResourceHandle() const = 0;
|
||||
virtual uint32_t getBlobHandle() const = 0;
|
||||
virtual int wait() = 0;
|
||||
|
||||
virtual VirtGpuBlobMappingPtr createMapping(void) = 0;
|
||||
virtual VirtGpuResourceMappingPtr createMapping(void) = 0;
|
||||
virtual int exportBlob(struct VirtGpuExternalHandle& handle) = 0;
|
||||
|
||||
virtual int transferFromHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) = 0;
|
||||
|
|
@ -152,9 +154,9 @@ class VirtGpuBlob {
|
|||
}
|
||||
};
|
||||
|
||||
class VirtGpuBlobMapping {
|
||||
public:
|
||||
virtual ~VirtGpuBlobMapping(void) {}
|
||||
class VirtGpuResourceMapping {
|
||||
public:
|
||||
virtual ~VirtGpuResourceMapping(void) {}
|
||||
|
||||
virtual uint8_t* asRawPtr(void) = 0;
|
||||
};
|
||||
|
|
@ -175,11 +177,12 @@ class VirtGpuDevice {
|
|||
|
||||
virtual struct VirtGpuCaps getCaps(void) = 0;
|
||||
|
||||
virtual VirtGpuBlobPtr createBlob(const struct VirtGpuCreateBlob& blobCreate) = 0;
|
||||
virtual VirtGpuBlobPtr createVirglBlob(uint32_t width, uint32_t height, uint32_t virglFormat) = 0;
|
||||
virtual VirtGpuBlobPtr importBlob(const struct VirtGpuExternalHandle& handle) = 0;
|
||||
virtual VirtGpuResourcePtr createBlob(const struct VirtGpuCreateBlob& blobCreate) = 0;
|
||||
virtual VirtGpuResourcePtr createResource(uint32_t width, uint32_t height,
|
||||
uint32_t virglFormat) = 0;
|
||||
virtual VirtGpuResourcePtr importBlob(const struct VirtGpuExternalHandle& handle) = 0;
|
||||
|
||||
virtual int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuBlob* blob) = 0;
|
||||
virtual int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuResource* blob) = 0;
|
||||
|
||||
private:
|
||||
enum VirtGpuCapset mCapset;
|
||||
|
|
@ -190,9 +193,9 @@ VirtGpuDevice* createPlatformVirtGpuDevice(enum VirtGpuCapset capset = kCapsetNo
|
|||
// HACK: We can use gfxstream::guest::EnumFlags, but we'll have to do more guest
|
||||
// refactorings to figure out our end goal. We can either depend more on base or
|
||||
// try to transition to something else (b:202552093) [atleast for guests].
|
||||
constexpr enum VirtGpuBlobFlags operator |(const enum VirtGpuBlobFlags self,
|
||||
const enum VirtGpuBlobFlags other) {
|
||||
return (enum VirtGpuBlobFlags)(uint32_t(self) | uint32_t(other));
|
||||
constexpr enum VirtGpuResourceFlags operator|(const enum VirtGpuResourceFlags self,
|
||||
const enum VirtGpuResourceFlags other) {
|
||||
return (enum VirtGpuResourceFlags)(uint32_t(self) | uint32_t(other));
|
||||
}
|
||||
|
||||
constexpr enum VirtGpuExecBufferFlags operator |(const enum VirtGpuExecBufferFlags self,
|
||||
|
|
|
|||
|
|
@ -18,17 +18,18 @@
|
|||
|
||||
#include "VirtGpu.h"
|
||||
|
||||
class LinuxVirtGpuBlob : public std::enable_shared_from_this<LinuxVirtGpuBlob>, public VirtGpuBlob {
|
||||
class LinuxVirtGpuResource : public std::enable_shared_from_this<LinuxVirtGpuResource>,
|
||||
public VirtGpuResource {
|
||||
public:
|
||||
LinuxVirtGpuBlob(int64_t deviceHandle, uint32_t blobHandle, uint32_t resourceHandle,
|
||||
uint64_t size);
|
||||
~LinuxVirtGpuBlob();
|
||||
LinuxVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle, uint32_t resourceHandle,
|
||||
uint64_t size);
|
||||
~LinuxVirtGpuResource();
|
||||
|
||||
uint32_t getResourceHandle() const override;
|
||||
uint32_t getBlobHandle() const override;
|
||||
int wait() override;
|
||||
|
||||
VirtGpuBlobMappingPtr createMapping(void) 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;
|
||||
|
|
@ -44,15 +45,15 @@ class LinuxVirtGpuBlob : public std::enable_shared_from_this<LinuxVirtGpuBlob>,
|
|||
uint64_t mSize;
|
||||
};
|
||||
|
||||
class LinuxVirtGpuBlobMapping : public VirtGpuBlobMapping {
|
||||
class LinuxVirtGpuResourceMapping : public VirtGpuResourceMapping {
|
||||
public:
|
||||
LinuxVirtGpuBlobMapping(VirtGpuBlobPtr blob, uint8_t* ptr, uint64_t size);
|
||||
~LinuxVirtGpuBlobMapping(void);
|
||||
LinuxVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr, uint64_t size);
|
||||
~LinuxVirtGpuResourceMapping(void);
|
||||
|
||||
uint8_t* asRawPtr(void) override;
|
||||
|
||||
private:
|
||||
VirtGpuBlobPtr mBlob;
|
||||
VirtGpuResourcePtr mBlob;
|
||||
uint8_t* mPtr;
|
||||
uint64_t mSize;
|
||||
};
|
||||
|
|
@ -66,11 +67,12 @@ class LinuxVirtGpuDevice : public VirtGpuDevice {
|
|||
|
||||
virtual struct VirtGpuCaps getCaps(void);
|
||||
|
||||
VirtGpuBlobPtr createBlob(const struct VirtGpuCreateBlob& blobCreate) override;
|
||||
VirtGpuBlobPtr createVirglBlob(uint32_t width, uint32_t height, uint32_t virglFormat) override;
|
||||
VirtGpuResourcePtr createBlob(const struct VirtGpuCreateBlob& blobCreate) override;
|
||||
VirtGpuResourcePtr createResource(uint32_t width, uint32_t height,
|
||||
uint32_t virglFormat) override;
|
||||
|
||||
virtual VirtGpuBlobPtr importBlob(const struct VirtGpuExternalHandle& handle);
|
||||
virtual int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuBlob* blob);
|
||||
virtual VirtGpuResourcePtr importBlob(const struct VirtGpuExternalHandle& handle);
|
||||
virtual int execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuResource* blob);
|
||||
|
||||
private:
|
||||
int64_t mDeviceHandle;
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@
|
|||
#include "LinuxVirtGpu.h"
|
||||
#include "virtgpu_drm.h"
|
||||
|
||||
LinuxVirtGpuBlob::LinuxVirtGpuBlob(int64_t deviceHandle, uint32_t blobHandle,
|
||||
uint32_t resourceHandle, uint64_t size)
|
||||
LinuxVirtGpuResource::LinuxVirtGpuResource(int64_t deviceHandle, uint32_t blobHandle,
|
||||
uint32_t resourceHandle, uint64_t size)
|
||||
: mDeviceHandle(deviceHandle),
|
||||
mBlobHandle(blobHandle),
|
||||
mResourceHandle(resourceHandle),
|
||||
mSize(size) {}
|
||||
|
||||
LinuxVirtGpuBlob::~LinuxVirtGpuBlob() {
|
||||
LinuxVirtGpuResource::~LinuxVirtGpuResource() {
|
||||
struct drm_gem_close gem_close {
|
||||
.handle = mBlobHandle, .pad = 0,
|
||||
};
|
||||
|
|
@ -45,11 +45,11 @@ LinuxVirtGpuBlob::~LinuxVirtGpuBlob() {
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t LinuxVirtGpuBlob::getBlobHandle() const { return mBlobHandle; }
|
||||
uint32_t LinuxVirtGpuResource::getBlobHandle() const { return mBlobHandle; }
|
||||
|
||||
uint32_t LinuxVirtGpuBlob::getResourceHandle() const { return mResourceHandle; }
|
||||
uint32_t LinuxVirtGpuResource::getResourceHandle() const { return mResourceHandle; }
|
||||
|
||||
VirtGpuBlobMappingPtr LinuxVirtGpuBlob::createMapping() {
|
||||
VirtGpuResourceMappingPtr LinuxVirtGpuResource::createMapping() {
|
||||
int ret;
|
||||
struct drm_virtgpu_map map {
|
||||
.handle = mBlobHandle, .pad = 0,
|
||||
|
|
@ -69,10 +69,10 @@ VirtGpuBlobMappingPtr LinuxVirtGpuBlob::createMapping() {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<LinuxVirtGpuBlobMapping>(shared_from_this(), ptr, mSize);
|
||||
return std::make_shared<LinuxVirtGpuResourceMapping>(shared_from_this(), ptr, mSize);
|
||||
}
|
||||
|
||||
int LinuxVirtGpuBlob::exportBlob(struct VirtGpuExternalHandle& handle) {
|
||||
int LinuxVirtGpuResource::exportBlob(struct VirtGpuExternalHandle& handle) {
|
||||
int ret, fd;
|
||||
|
||||
uint32_t flags = DRM_CLOEXEC;
|
||||
|
|
@ -87,7 +87,7 @@ int LinuxVirtGpuBlob::exportBlob(struct VirtGpuExternalHandle& handle) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LinuxVirtGpuBlob::wait() {
|
||||
int LinuxVirtGpuResource::wait() {
|
||||
int ret;
|
||||
struct drm_virtgpu_3d_wait wait_3d = {0};
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ int LinuxVirtGpuBlob::wait() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LinuxVirtGpuBlob::transferToHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
int LinuxVirtGpuResource::transferToHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
int ret;
|
||||
struct drm_virtgpu_3d_transfer_to_host xfer = {0};
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ int LinuxVirtGpuBlob::transferToHost(uint32_t x, uint32_t y, uint32_t w, uint32_
|
|||
return 0;
|
||||
}
|
||||
|
||||
int LinuxVirtGpuBlob::transferFromHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
int LinuxVirtGpuResource::transferFromHost(uint32_t x, uint32_t y, uint32_t w, uint32_t h) {
|
||||
int ret;
|
||||
struct drm_virtgpu_3d_transfer_from_host xfer = {0};
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@
|
|||
|
||||
#include "LinuxVirtGpu.h"
|
||||
|
||||
LinuxVirtGpuBlobMapping::LinuxVirtGpuBlobMapping(VirtGpuBlobPtr blob, uint8_t* ptr, uint64_t size)
|
||||
LinuxVirtGpuResourceMapping::LinuxVirtGpuResourceMapping(VirtGpuResourcePtr blob, uint8_t* ptr,
|
||||
uint64_t size)
|
||||
: mBlob(blob), mPtr(ptr), mSize(size) {}
|
||||
|
||||
LinuxVirtGpuBlobMapping::~LinuxVirtGpuBlobMapping(void) { munmap(mPtr, mSize); }
|
||||
LinuxVirtGpuResourceMapping::~LinuxVirtGpuResourceMapping(void) { munmap(mPtr, mSize); }
|
||||
|
||||
uint8_t* LinuxVirtGpuBlobMapping::asRawPtr(void) { return mPtr; }
|
||||
uint8_t* LinuxVirtGpuResourceMapping::asRawPtr(void) { return mPtr; }
|
||||
|
|
|
|||
|
|
@ -149,8 +149,8 @@ struct VirtGpuCaps LinuxVirtGpuDevice::getCaps(void) { return mCaps; }
|
|||
|
||||
int64_t LinuxVirtGpuDevice::getDeviceHandle(void) { return mDeviceHandle; }
|
||||
|
||||
VirtGpuBlobPtr LinuxVirtGpuDevice::createVirglBlob(uint32_t width, uint32_t height,
|
||||
uint32_t virglFormat) {
|
||||
VirtGpuResourcePtr LinuxVirtGpuDevice::createResource(uint32_t width, uint32_t height,
|
||||
uint32_t virglFormat) {
|
||||
uint32_t target = 0;
|
||||
uint32_t bind = 0;
|
||||
uint32_t bpp = 0;
|
||||
|
|
@ -192,11 +192,11 @@ VirtGpuBlobPtr LinuxVirtGpuDevice::createVirglBlob(uint32_t width, uint32_t heig
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<LinuxVirtGpuBlob>(mDeviceHandle, create.bo_handle, create.res_handle,
|
||||
static_cast<uint64_t>(create.size));
|
||||
return std::make_shared<LinuxVirtGpuResource>(
|
||||
mDeviceHandle, create.bo_handle, create.res_handle, static_cast<uint64_t>(create.size));
|
||||
}
|
||||
|
||||
VirtGpuBlobPtr LinuxVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob& blobCreate) {
|
||||
VirtGpuResourcePtr LinuxVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob& blobCreate) {
|
||||
int ret;
|
||||
struct drm_virtgpu_resource_create_blob create = {0};
|
||||
|
||||
|
|
@ -211,11 +211,11 @@ VirtGpuBlobPtr LinuxVirtGpuDevice::createBlob(const struct VirtGpuCreateBlob& bl
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<LinuxVirtGpuBlob>(mDeviceHandle, create.bo_handle, create.res_handle,
|
||||
blobCreate.size);
|
||||
return std::make_shared<LinuxVirtGpuResource>(mDeviceHandle, create.bo_handle,
|
||||
create.res_handle, blobCreate.size);
|
||||
}
|
||||
|
||||
VirtGpuBlobPtr LinuxVirtGpuDevice::importBlob(const struct VirtGpuExternalHandle& handle) {
|
||||
VirtGpuResourcePtr LinuxVirtGpuDevice::importBlob(const struct VirtGpuExternalHandle& handle) {
|
||||
struct drm_virtgpu_resource_info info = {0};
|
||||
uint32_t blobHandle;
|
||||
int ret;
|
||||
|
|
@ -234,11 +234,12 @@ VirtGpuBlobPtr LinuxVirtGpuDevice::importBlob(const struct VirtGpuExternalHandle
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_shared<LinuxVirtGpuBlob>(mDeviceHandle, blobHandle, info.res_handle,
|
||||
static_cast<uint64_t>(info.size));
|
||||
return std::make_shared<LinuxVirtGpuResource>(mDeviceHandle, blobHandle, info.res_handle,
|
||||
static_cast<uint64_t>(info.size));
|
||||
}
|
||||
|
||||
int LinuxVirtGpuDevice::execBuffer(struct VirtGpuExecBuffer& execbuffer, const VirtGpuBlob* blob) {
|
||||
int LinuxVirtGpuDevice::execBuffer(struct VirtGpuExecBuffer& execbuffer,
|
||||
const VirtGpuResource* blob) {
|
||||
int ret;
|
||||
struct drm_virtgpu_execbuffer exec = {0};
|
||||
uint32_t blobHandle;
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ bool isHostVisible(const VkPhysicalDeviceMemoryProperties* memoryProps, uint32_t
|
|||
return memoryProps->memoryTypes[index].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
}
|
||||
|
||||
CoherentMemory::CoherentMemory(VirtGpuBlobMappingPtr blobMapping, uint64_t size, VkDevice device,
|
||||
VkDeviceMemory memory)
|
||||
CoherentMemory::CoherentMemory(VirtGpuResourceMappingPtr blobMapping, uint64_t size,
|
||||
VkDevice device, VkDeviceMemory memory)
|
||||
: mSize(size), mBlobMapping(blobMapping), mDevice(device), mMemory(memory) {
|
||||
mAllocator =
|
||||
std::make_unique<gfxstream::guest::SubAllocator>(blobMapping->asRawPtr(), mSize, 4096);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ using SubAllocatorPtr = std::unique_ptr<gfxstream::guest::SubAllocator>;
|
|||
|
||||
class CoherentMemory {
|
||||
public:
|
||||
CoherentMemory(VirtGpuBlobMappingPtr blobMapping, uint64_t size, VkDevice device,
|
||||
CoherentMemory(VirtGpuResourceMappingPtr blobMapping, uint64_t size, VkDevice device,
|
||||
VkDeviceMemory memory);
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
|
|
@ -61,7 +61,7 @@ class CoherentMemory {
|
|||
void operator=(CoherentMemory const&);
|
||||
|
||||
uint64_t mSize;
|
||||
VirtGpuBlobMappingPtr mBlobMapping = nullptr;
|
||||
VirtGpuResourceMappingPtr mBlobMapping = nullptr;
|
||||
GoldfishAddressSpaceBlockPtr mBlock = nullptr;
|
||||
VkDevice mDevice;
|
||||
VkDeviceMemory mMemory;
|
||||
|
|
|
|||
|
|
@ -1342,7 +1342,7 @@ void ResourceTracker::setDeviceMemoryInfo(VkDevice device, VkDeviceMemory memory
|
|||
VkDeviceSize allocationSize, uint8_t* ptr,
|
||||
uint32_t memoryTypeIndex, AHardwareBuffer* ahw,
|
||||
bool imported, zx_handle_t vmoHandle,
|
||||
VirtGpuBlobPtr blobPtr) {
|
||||
VirtGpuResourcePtr blobPtr) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
auto& info = info_VkDeviceMemory[memory];
|
||||
|
||||
|
|
@ -2953,7 +2953,7 @@ CoherentMemoryPtr ResourceTracker::createCoherentMemory(
|
|||
return coherentMemory;
|
||||
}
|
||||
|
||||
VirtGpuBlobMappingPtr mapping = blob->createMapping();
|
||||
VirtGpuResourceMappingPtr mapping = blob->createMapping();
|
||||
if (!mapping) {
|
||||
ALOGE("Failed to create coherent memory: failed to create blob mapping.");
|
||||
res = VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
|
|
@ -2979,7 +2979,7 @@ VkResult ResourceTracker::allocateCoherentMemory(VkDevice device,
|
|||
VkMemoryAllocateFlagsInfo allocFlagsInfo;
|
||||
VkMemoryOpaqueCaptureAddressAllocateInfo opaqueCaptureAddressAllocInfo;
|
||||
VkCreateBlobGOOGLE createBlobInfo;
|
||||
VirtGpuBlobPtr guestBlob = nullptr;
|
||||
VirtGpuResourcePtr guestBlob = nullptr;
|
||||
|
||||
memset(&createBlobInfo, 0, sizeof(struct VkCreateBlobGOOGLE));
|
||||
createBlobInfo.sType = VK_STRUCTURE_TYPE_CREATE_BLOB_GOOGLE;
|
||||
|
|
@ -3741,7 +3741,7 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
|||
}
|
||||
#endif
|
||||
|
||||
VirtGpuBlobPtr colorBufferBlob = nullptr;
|
||||
VirtGpuResourcePtr colorBufferBlob = nullptr;
|
||||
#if defined(__linux__) && !defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
if (exportDmabuf) {
|
||||
VirtGpuDevice* instance = VirtGpuDevice::getInstance();
|
||||
|
|
@ -3776,8 +3776,8 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
|||
imageCreateInfo.format);
|
||||
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
}
|
||||
colorBufferBlob = instance->createVirglBlob(imageCreateInfo.extent.width,
|
||||
imageCreateInfo.extent.height, virglFormat);
|
||||
colorBufferBlob = instance->createResource(imageCreateInfo.extent.width,
|
||||
imageCreateInfo.extent.height, virglFormat);
|
||||
if (!colorBufferBlob) {
|
||||
ALOGE("%s: Failed to create colorBuffer resource for Image memory\n", __func__);
|
||||
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
|
|
@ -3798,8 +3798,8 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
|||
const auto& bufferInfo = it->second;
|
||||
bufferCreateInfo = bufferInfo.createInfo;
|
||||
}
|
||||
colorBufferBlob = instance->createVirglBlob(bufferCreateInfo.size / 4, 1,
|
||||
VIRGL_FORMAT_R8G8B8A8_UNORM);
|
||||
colorBufferBlob =
|
||||
instance->createResource(bufferCreateInfo.size / 4, 1, VIRGL_FORMAT_R8G8B8A8_UNORM);
|
||||
if (!colorBufferBlob) {
|
||||
ALOGE("%s: Failed to create colorBuffer resource for Buffer memory\n", __func__);
|
||||
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
|
|
@ -3952,7 +3952,7 @@ VkResult ResourceTracker::on_vkMapMemory(void* context, VkResult host_result, Vk
|
|||
|
||||
if (info.blobId && !info.coherentMemory && !mCaps.params[kParamCreateGuestHandle]) {
|
||||
VkEncoder* enc = (VkEncoder*)context;
|
||||
VirtGpuBlobMappingPtr mapping;
|
||||
VirtGpuResourceMappingPtr mapping;
|
||||
VirtGpuDevice* instance = VirtGpuDevice::getInstance();
|
||||
|
||||
uint64_t offset;
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ class ResourceTracker {
|
|||
|
||||
void setDeviceMemoryInfo(VkDevice device, VkDeviceMemory memory, VkDeviceSize allocationSize,
|
||||
uint8_t* ptr, uint32_t memoryTypeIndex, AHardwareBuffer* ahw,
|
||||
bool imported, zx_handle_t vmoHandle, VirtGpuBlobPtr blobPtr);
|
||||
bool imported, zx_handle_t vmoHandle, VirtGpuResourcePtr blobPtr);
|
||||
|
||||
void setImageInfo(VkImage image, VkDevice device, const VkImageCreateInfo* pCreateInfo);
|
||||
|
||||
|
|
@ -748,7 +748,7 @@ class ResourceTracker {
|
|||
GoldfishAddressSpaceBlockPtr goldfishBlock = nullptr;
|
||||
#endif // defined(__ANDROID__)
|
||||
CoherentMemoryPtr coherentMemory = nullptr;
|
||||
VirtGpuBlobPtr blobPtr = nullptr;
|
||||
VirtGpuResourcePtr blobPtr = nullptr;
|
||||
};
|
||||
|
||||
struct VkCommandBuffer_Info {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue