mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-04 16:12:57 -10:00
Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f714f0e337 | ||
|
|
fe1d0522d5 | ||
|
|
2d61ac3020 | ||
|
|
6e32909fd8 | ||
|
|
7c37f4fc5c | ||
|
|
1677c54384 | ||
|
|
cb33cf49e1 | ||
|
|
454aa879df | ||
|
|
c38e916637 | ||
|
|
c55069ad92 | ||
|
|
7a353024f8 | ||
|
|
efeb3544fa | ||
|
|
eea896f6c5 | ||
|
|
f0e63f3731 | ||
|
|
af3ab1eb6e | ||
|
|
84610e82d1 |
No files matched your search
+109
-19
@@ -17,18 +17,14 @@
|
||||
#include "system/hvf_int.h"
|
||||
#include "hw/core/cpu.h"
|
||||
#include "hw/boards.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/visitor.h"
|
||||
#include "trace.h"
|
||||
|
||||
bool hvf_allowed;
|
||||
|
||||
struct mac_slot {
|
||||
int present;
|
||||
uint64_t size;
|
||||
uint64_t gpa_start;
|
||||
uint64_t gva;
|
||||
};
|
||||
|
||||
struct mac_slot mac_slots[32];
|
||||
/* Default num of memslots to be allocated when VM starts */
|
||||
#define HVF_MEMSLOTS_NUM_ALLOC_DEFAULT 32
|
||||
|
||||
const char *hvf_return_string(hv_return_t ret)
|
||||
{
|
||||
@@ -58,12 +54,60 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
|
||||
abort();
|
||||
}
|
||||
|
||||
static bool hvf_slots_grow(HVFState *state, unsigned int num_slots_new)
|
||||
{
|
||||
unsigned int i, cur = state->num_slots;
|
||||
hvf_slot *slots;
|
||||
hvf_mac_slot *mac_slots;
|
||||
|
||||
assert(num_slots_new > cur);
|
||||
if (cur == 0) {
|
||||
slots = g_new0(hvf_slot, num_slots_new);
|
||||
if (!slots) {
|
||||
return false;
|
||||
}
|
||||
mac_slots = g_new0(hvf_mac_slot, num_slots_new);
|
||||
if (!mac_slots) {
|
||||
g_free(slots);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
slots = g_renew(hvf_slot, state->slots, num_slots_new);
|
||||
if (!slots) {
|
||||
return false;
|
||||
}
|
||||
mac_slots = g_renew(hvf_mac_slot, state->mac_slots, num_slots_new);
|
||||
if (!mac_slots) {
|
||||
/* save allocated slots but not new size */
|
||||
state->slots = slots;
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* g_renew() doesn't initialize extended buffers, however hvf
|
||||
* memslots require fields to be zero-initialized. E.g. pointers,
|
||||
* memory_size field, etc.
|
||||
*/
|
||||
memset(&slots[cur], 0x0, sizeof(slots[0]) * (num_slots_new - cur));
|
||||
memset(&mac_slots[cur], 0x0, sizeof(mac_slots[0]) * (num_slots_new - cur));
|
||||
}
|
||||
|
||||
for (i = cur; i < num_slots_new; i++) {
|
||||
slots[i].slot_id = i;
|
||||
}
|
||||
|
||||
state->slots = slots;
|
||||
state->mac_slots = mac_slots;
|
||||
state->num_slots = num_slots_new;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags)
|
||||
{
|
||||
struct mac_slot *macslot;
|
||||
hvf_mac_slot *macslot;
|
||||
hv_return_t ret;
|
||||
|
||||
macslot = &mac_slots[slot->slot_id];
|
||||
macslot = &hvf_state->mac_slots[slot->slot_id];
|
||||
|
||||
if (macslot->present) {
|
||||
if (macslot->size != slot->size) {
|
||||
@@ -110,8 +154,20 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
|
||||
}
|
||||
}
|
||||
|
||||
if (hvf_state->ipa_granule_size) {
|
||||
page_size = hvf_state->ipa_granule_size;
|
||||
}
|
||||
|
||||
if (!QEMU_IS_ALIGNED(int128_get64(section->size), page_size) ||
|
||||
!QEMU_IS_ALIGNED(section->offset_within_address_space, page_size)) {
|
||||
if (add) {
|
||||
warn_report("Cannot add 0x%016llX:0x%016llX because it is not "
|
||||
"aligned to page size (0x%X)",
|
||||
section->offset_within_address_space,
|
||||
section->offset_within_address_space +
|
||||
int128_get64(section->size),
|
||||
(uint32_t)page_size);
|
||||
}
|
||||
/* Not page aligned, so we can not map as RAM */
|
||||
add = false;
|
||||
}
|
||||
@@ -160,8 +216,11 @@ static void hvf_set_phys_mem(MemoryRegionSection *section, bool add)
|
||||
}
|
||||
|
||||
if (x == hvf_state->num_slots) {
|
||||
error_report("No free slots");
|
||||
abort();
|
||||
if (!hvf_slots_grow(hvf_state, hvf_state->num_slots * 2)) {
|
||||
error_report("Cannot allocate any more slots");
|
||||
abort();
|
||||
}
|
||||
mem = &hvf_state->slots[x];
|
||||
}
|
||||
|
||||
mem->size = int128_get64(section->size);
|
||||
@@ -250,11 +309,11 @@ static MemoryListener hvf_memory_listener = {
|
||||
|
||||
static int hvf_accel_init(AccelState *as, MachineState *ms)
|
||||
{
|
||||
int x;
|
||||
hv_return_t ret;
|
||||
HVFState *s = HVF_STATE(as);
|
||||
int pa_range = 36;
|
||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
||||
bool success;
|
||||
|
||||
if (mc->hvf_get_physical_address_range) {
|
||||
pa_range = mc->hvf_get_physical_address_range(ms);
|
||||
@@ -263,7 +322,7 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
|
||||
}
|
||||
}
|
||||
|
||||
ret = hvf_arch_vm_create(ms, (uint32_t)pa_range);
|
||||
ret = hvf_arch_vm_create(ms, (uint32_t)pa_range, s->ipa_granule_size);
|
||||
if (ret == HV_DENIED) {
|
||||
error_report("Could not access HVF. Is the executable signed"
|
||||
" with com.apple.security.hypervisor entitlement?");
|
||||
@@ -271,11 +330,8 @@ static int hvf_accel_init(AccelState *as, MachineState *ms)
|
||||
}
|
||||
assert_hvf_ok(ret);
|
||||
|
||||
s->num_slots = ARRAY_SIZE(s->slots);
|
||||
for (x = 0; x < s->num_slots; ++x) {
|
||||
s->slots[x].size = 0;
|
||||
s->slots[x].slot_id = x;
|
||||
}
|
||||
success = hvf_slots_grow(s, HVF_MEMSLOTS_NUM_ALLOC_DEFAULT);
|
||||
assert(success);
|
||||
|
||||
QTAILQ_INIT(&s->hvf_sw_breakpoints);
|
||||
|
||||
@@ -290,6 +346,34 @@ static int hvf_gdbstub_sstep_flags(AccelState *as)
|
||||
return SSTEP_ENABLE | SSTEP_NOIRQ;
|
||||
}
|
||||
|
||||
static void hvf_get_ipa_granule_size(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque,
|
||||
Error **errp)
|
||||
{
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
uint32_t value = s->ipa_granule_size;
|
||||
|
||||
visit_type_uint32(v, name, &value, errp);
|
||||
}
|
||||
|
||||
static void hvf_set_ipa_granule_size(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque,
|
||||
Error **errp)
|
||||
{
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
uint32_t value;
|
||||
|
||||
if (!visit_type_uint32(v, name, &value, errp)) {
|
||||
return;
|
||||
}
|
||||
if (value & (value - 1)) {
|
||||
error_setg(errp, "ipa-granule-size must be a power of two.");
|
||||
return;
|
||||
}
|
||||
|
||||
s->ipa_granule_size = value;
|
||||
}
|
||||
|
||||
static void hvf_accel_class_init(ObjectClass *oc, const void *data)
|
||||
{
|
||||
AccelClass *ac = ACCEL_CLASS(oc);
|
||||
@@ -297,6 +381,12 @@ static void hvf_accel_class_init(ObjectClass *oc, const void *data)
|
||||
ac->init_machine = hvf_accel_init;
|
||||
ac->allowed = &hvf_allowed;
|
||||
ac->gdbstub_supported_sstep_flags = hvf_gdbstub_sstep_flags;
|
||||
|
||||
object_class_property_add(oc, "ipa-granule-size", "uint32",
|
||||
hvf_get_ipa_granule_size, hvf_set_ipa_granule_size,
|
||||
NULL, NULL);
|
||||
object_class_property_set_description(oc, "ipa-granule-size",
|
||||
"Size of a single guest page");
|
||||
}
|
||||
|
||||
static const TypeInfo hvf_accel_type = {
|
||||
|
||||
+104
-10
@@ -22,8 +22,11 @@
|
||||
|
||||
#include "ui/egl-helpers.h"
|
||||
|
||||
#define VIRGL_RENDERER_UNSTABLE_APIS
|
||||
#include <virglrenderer.h>
|
||||
|
||||
#define NATIVE_HANDLE_SUPPORT_VERSION (1)
|
||||
|
||||
struct virtio_gpu_virgl_resource {
|
||||
struct virtio_gpu_simple_resource base;
|
||||
MemoryRegion *mr;
|
||||
@@ -120,7 +123,7 @@ virtio_gpu_virgl_map_resource_blob(VirtIOGPU *g,
|
||||
vmr->g = g;
|
||||
|
||||
mr = &vmr->mr;
|
||||
memory_region_init_ram_ptr(mr, OBJECT(mr), "blob", size, data);
|
||||
memory_region_init_ram_ptr(mr, OBJECT(mr), NULL, size, data);
|
||||
memory_region_add_subregion(&b->hostmem, offset, mr);
|
||||
memory_region_set_enabled(mr, true);
|
||||
|
||||
@@ -186,7 +189,7 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g,
|
||||
/* memory region owns self res->mr object and frees it by itself */
|
||||
memory_region_set_enabled(mr, false);
|
||||
memory_region_del_subregion(&b->hostmem, mr);
|
||||
object_unparent(OBJECT(mr));
|
||||
object_unref(OBJECT(mr));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -420,15 +423,42 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
|
||||
|
||||
if (ss.resource_id && ss.r.width && ss.r.height) {
|
||||
struct virgl_renderer_resource_info info;
|
||||
void *d3d_tex2d = NULL;
|
||||
ScanoutTextureNative native = NO_NATIVE_TEXTURE;
|
||||
|
||||
#if VIRGL_VERSION_MAJOR >= 1
|
||||
struct virgl_renderer_resource_info_ext ext;
|
||||
memset(&ext, 0, sizeof(ext));
|
||||
ret = virgl_renderer_resource_get_info_ext(ss.resource_id, &ext);
|
||||
info = ext.base;
|
||||
d3d_tex2d = ext.d3d_tex2d;
|
||||
#else
|
||||
/* fallback to older version */
|
||||
native = (ScanoutTextureNative){
|
||||
.type = ext.d3d_tex2d ? SCANOUT_TEXTURE_NATIVE_TYPE_D3D :
|
||||
SCANOUT_TEXTURE_NATIVE_TYPE_NONE,
|
||||
.handle = ext.d3d_tex2d,
|
||||
};
|
||||
#if VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION >= NATIVE_HANDLE_SUPPORT_VERSION
|
||||
if (ext.version >= VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION) {
|
||||
switch (ext.native_type) {
|
||||
#ifdef CONFIG_METAL
|
||||
case VIRGL_NATIVE_HANDLE_METAL_TEXTURE: {
|
||||
native.type = SCANOUT_TEXTURE_NATIVE_TYPE_METAL;
|
||||
native.handle = ext.native_handle;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case VIRGL_NATIVE_HANDLE_NONE:
|
||||
case VIRGL_NATIVE_HANDLE_D3D_TEX2D: {
|
||||
/* already handled above */
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
/* ignore unsupported hint texture type */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else /* VIRGL_VERSION_MAJOR < 1 */
|
||||
memset(&info, 0, sizeof(info));
|
||||
ret = virgl_renderer_resource_get_info(ss.resource_id, &info);
|
||||
#endif
|
||||
@@ -447,7 +477,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
|
||||
info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP,
|
||||
info.width, info.height,
|
||||
ss.r.x, ss.r.y, ss.r.width, ss.r.height,
|
||||
d3d_tex2d);
|
||||
native, NULL);
|
||||
} else {
|
||||
dpy_gfx_replace_surface(
|
||||
g->parent_obj.scanout[ss.scanout_id].con, NULL);
|
||||
@@ -803,6 +833,59 @@ static void virgl_cmd_resource_unmap_blob(VirtIOGPU *g,
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(HAVE_VIRGL_RENDERER_NATIVE_SCANOUT)
|
||||
static void virgl_scanout_native_blob_cleanup(ScanoutTextureNative *native)
|
||||
{
|
||||
assert(native->type == SCANOUT_TEXTURE_NATIVE_TYPE_METAL);
|
||||
virgl_renderer_release_handle_for_scanout(VIRGL_NATIVE_HANDLE_METAL_TEXTURE,
|
||||
native->handle);
|
||||
}
|
||||
|
||||
static bool virgl_scanout_native_blob(VirtIOGPU *g,
|
||||
struct virtio_gpu_set_scanout_blob *ss)
|
||||
{
|
||||
struct virtio_gpu_scanout *scanout = &g->parent_obj.scanout[ss->scanout_id];
|
||||
enum virgl_renderer_native_handle_type type;
|
||||
virgl_renderer_native_handle handle;
|
||||
ScanoutTextureNative native;
|
||||
|
||||
type = virgl_renderer_create_handle_for_scanout(ss->resource_id,
|
||||
ss->width,
|
||||
ss->height,
|
||||
ss->format,
|
||||
ss->padding,
|
||||
ss->strides[0],
|
||||
ss->offsets[0],
|
||||
&handle);
|
||||
#ifdef CONFIG_METAL
|
||||
if (type == VIRGL_NATIVE_HANDLE_METAL_TEXTURE) {
|
||||
native = (ScanoutTextureNative){
|
||||
.type = SCANOUT_TEXTURE_NATIVE_TYPE_METAL,
|
||||
.handle = handle,
|
||||
};
|
||||
qemu_console_resize(scanout->con,
|
||||
ss->r.width, ss->r.height);
|
||||
dpy_gl_scanout_texture(
|
||||
scanout->con, 0,
|
||||
false,
|
||||
ss->width, ss->height,
|
||||
ss->r.x, ss->r.y, ss->r.width, ss->r.height,
|
||||
native, virgl_scanout_native_blob_cleanup);
|
||||
scanout->resource_id = ss->resource_id;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* don't leak memory if handle type is unknown */
|
||||
if (type != VIRGL_NATIVE_HANDLE_NONE) {
|
||||
virgl_renderer_release_handle_for_scanout(type, handle);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void virgl_cmd_set_scanout_blob(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
@@ -841,6 +924,12 @@ static void virgl_cmd_set_scanout_blob(VirtIOGPU *g,
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(HAVE_VIRGL_RENDERER_NATIVE_SCANOUT)
|
||||
if (virgl_scanout_native_blob(g, &ss)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
res = virtio_gpu_virgl_find_resource(g, ss.resource_id);
|
||||
if (!res) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "%s: resource does not exist %d\n",
|
||||
@@ -1151,14 +1240,19 @@ int virtio_gpu_virgl_init(VirtIOGPU *g)
|
||||
virtio_gpu_3d_cbs.get_egl_display = virgl_get_egl_display;
|
||||
}
|
||||
#endif
|
||||
#ifdef VIRGL_RENDERER_D3D11_SHARE_TEXTURE
|
||||
if (qemu_egl_angle_d3d) {
|
||||
if (qemu_egl_angle_native_device) {
|
||||
#if defined(VIRGL_RENDERER_NATIVE_SHARE_TEXTURE)
|
||||
flags |= VIRGL_RENDERER_NATIVE_SHARE_TEXTURE;
|
||||
#elif defined(VIRGL_RENDERER_D3D11_SHARE_TEXTURE) && defined(WIN32)
|
||||
flags |= VIRGL_RENDERER_D3D11_SHARE_TEXTURE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if VIRGL_VERSION_MAJOR >= 1
|
||||
if (virtio_gpu_venus_enabled(g->parent_obj.conf)) {
|
||||
flags |= VIRGL_RENDERER_VENUS | VIRGL_RENDERER_RENDER_SERVER;
|
||||
flags |= VIRGL_RENDERER_VENUS;
|
||||
#ifndef CONFIG_METAL /* Metal does not support render server */
|
||||
flags |= VIRGL_RENDERER_RENDER_SERVER;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1483,12 +1483,18 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
|
||||
{
|
||||
VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
|
||||
VirtIOGPU *g = VIRTIO_GPU(qdev);
|
||||
bool have_ext_memory;
|
||||
|
||||
if (virtio_gpu_blob_enabled(g->parent_obj.conf)) {
|
||||
#ifdef CONFIG_METAL
|
||||
have_ext_memory = virtio_gpu_venus_enabled(g->parent_obj.conf);
|
||||
#else
|
||||
have_ext_memory = virtio_gpu_have_udmabuf();
|
||||
#endif
|
||||
if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) &&
|
||||
!virtio_gpu_virgl_enabled(g->parent_obj.conf) &&
|
||||
!virtio_gpu_have_udmabuf()) {
|
||||
error_setg(errp, "need rutabaga or udmabuf for blob resources");
|
||||
!have_ext_memory) {
|
||||
error_setg(errp, "need rutabaga or ext memory for blob resources");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ typedef hv_vcpuid_t hvf_vcpuid;
|
||||
/* hvf_slot flags */
|
||||
#define HVF_SLOT_LOG (1 << 0)
|
||||
|
||||
/* Represent memory logically mapped by QEMU */
|
||||
typedef struct hvf_slot {
|
||||
uint64_t start;
|
||||
uint64_t size;
|
||||
@@ -36,6 +37,14 @@ typedef struct hvf_slot {
|
||||
MemoryRegion *region;
|
||||
} hvf_slot;
|
||||
|
||||
/* Represent memory currently mapped in HVF */
|
||||
typedef struct hvf_mac_slot {
|
||||
int present;
|
||||
uint64_t size;
|
||||
uint64_t gpa_start;
|
||||
uint64_t gva;
|
||||
} hvf_mac_slot;
|
||||
|
||||
typedef struct hvf_vcpu_caps {
|
||||
uint64_t vmx_cap_pinbased;
|
||||
uint64_t vmx_cap_procbased;
|
||||
@@ -48,11 +57,13 @@ typedef struct hvf_vcpu_caps {
|
||||
struct HVFState {
|
||||
AccelState parent_obj;
|
||||
|
||||
hvf_slot slots[32];
|
||||
hvf_slot *slots;
|
||||
hvf_mac_slot *mac_slots;
|
||||
int num_slots;
|
||||
|
||||
hvf_vcpu_caps *hvf_caps;
|
||||
uint64_t vtimer_offset;
|
||||
uint32_t ipa_granule_size;
|
||||
QTAILQ_HEAD(, hvf_sw_breakpoint) hvf_sw_breakpoints;
|
||||
};
|
||||
extern HVFState *hvf_state;
|
||||
@@ -72,7 +83,8 @@ void assert_hvf_ok_impl(hv_return_t ret, const char *file, unsigned int line,
|
||||
#define assert_hvf_ok(EX) assert_hvf_ok_impl((EX), __FILE__, __LINE__, #EX)
|
||||
const char *hvf_return_string(hv_return_t ret);
|
||||
int hvf_arch_init(void);
|
||||
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range);
|
||||
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range,
|
||||
uint32_t ipa_granule_size);
|
||||
hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t);
|
||||
void hvf_kick_vcpu_thread(CPUState *cpu);
|
||||
|
||||
|
||||
+25
-3
@@ -131,6 +131,26 @@ struct QemuConsoleClass {
|
||||
ObjectClass parent_class;
|
||||
};
|
||||
|
||||
typedef enum ScanoutTextureNativeType {
|
||||
SCANOUT_TEXTURE_NATIVE_TYPE_NONE,
|
||||
SCANOUT_TEXTURE_NATIVE_TYPE_D3D,
|
||||
SCANOUT_TEXTURE_NATIVE_TYPE_METAL,
|
||||
} ScanoutTextureNativeType;
|
||||
|
||||
typedef struct ScanoutTextureNative {
|
||||
ScanoutTextureNativeType type;
|
||||
void *handle;
|
||||
} ScanoutTextureNative;
|
||||
|
||||
#define NO_NATIVE_TEXTURE ((ScanoutTextureNative){ \
|
||||
.type = SCANOUT_TEXTURE_NATIVE_TYPE_NONE \
|
||||
})
|
||||
|
||||
/**
|
||||
* Cleanup callback function when ScanoutTexture is about to be destroyed
|
||||
*/
|
||||
typedef void (*ScanoutTextureCleanup)(ScanoutTextureNative *native);
|
||||
|
||||
typedef struct ScanoutTexture {
|
||||
uint32_t backing_id;
|
||||
bool backing_y_0_top;
|
||||
@@ -140,7 +160,8 @@ typedef struct ScanoutTexture {
|
||||
uint32_t y;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
void *d3d_tex2d;
|
||||
ScanoutTextureNative native;
|
||||
ScanoutTextureCleanup cb_cleanup;
|
||||
} ScanoutTexture;
|
||||
|
||||
typedef struct QemuUIInfo {
|
||||
@@ -245,7 +266,7 @@ typedef struct DisplayChangeListenerOps {
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d);
|
||||
ScanoutTextureNative native);
|
||||
/* optional (default to true if has dpy_gl_scanout_dmabuf) */
|
||||
bool (*dpy_has_dmabuf)(DisplayChangeListener *dcl);
|
||||
/* optional */
|
||||
@@ -329,7 +350,8 @@ void dpy_gl_scanout_texture(QemuConsole *con,
|
||||
uint32_t backing_id, bool backing_y_0_top,
|
||||
uint32_t backing_width, uint32_t backing_height,
|
||||
uint32_t x, uint32_t y, uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d);
|
||||
ScanoutTextureNative native,
|
||||
ScanoutTextureCleanup cb_cleanup);
|
||||
void dpy_gl_scanout_dmabuf(QemuConsole *con,
|
||||
QemuDmaBuf *dmabuf);
|
||||
void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
extern EGLDisplay *qemu_egl_display;
|
||||
extern EGLConfig qemu_egl_config;
|
||||
extern DisplayGLMode qemu_egl_mode;
|
||||
extern bool qemu_egl_angle_d3d;
|
||||
extern void *qemu_egl_angle_native_device;
|
||||
|
||||
typedef struct egl_fb {
|
||||
int width;
|
||||
@@ -59,7 +59,9 @@ void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf);
|
||||
|
||||
#endif
|
||||
|
||||
EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win);
|
||||
EGLSurface qemu_egl_init_surface(EGLContext ectx, EGLNativeWindowType win);
|
||||
|
||||
int qemu_egl_init_dpy_cocoa(DisplayGLMode mode);
|
||||
|
||||
#if defined(CONFIG_X11) || defined(CONFIG_GBM)
|
||||
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@
|
||||
#include "ui/clipboard.h"
|
||||
#include "ui/console.h"
|
||||
#include "ui/kbd-state.h"
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
#include "ui/egl-helpers.h"
|
||||
#include "ui/egl-context.h"
|
||||
#endif
|
||||
@@ -44,7 +44,7 @@ typedef struct VirtualGfxConsole {
|
||||
double preferred_scale;
|
||||
double scale_x;
|
||||
double scale_y;
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
QemuGLShader *gls;
|
||||
EGLContext ectx;
|
||||
EGLSurface esurface;
|
||||
@@ -178,7 +178,7 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d);
|
||||
ScanoutTextureNative native);
|
||||
void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
|
||||
QemuDmaBuf *dmabuf);
|
||||
void gd_egl_cursor_dmabuf(DisplayChangeListener *dcl,
|
||||
@@ -215,7 +215,7 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d);
|
||||
ScanoutTextureNative native);
|
||||
void gd_gl_area_scanout_disable(DisplayChangeListener *dcl);
|
||||
void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
|
||||
uint32_t x, uint32_t y, uint32_t w, uint32_t h);
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include "ui/kbd-state.h"
|
||||
#ifdef CONFIG_OPENGL
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
# include "ui/egl-helpers.h"
|
||||
#endif
|
||||
|
||||
@@ -45,7 +45,7 @@ struct sdl2_console {
|
||||
bool gui_keysym;
|
||||
SDL_GLContext winctx;
|
||||
QKbdState *kbd;
|
||||
#ifdef CONFIG_OPENGL
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
QemuGLShader *gls;
|
||||
egl_fb guest_fb;
|
||||
egl_fb win_fb;
|
||||
@@ -93,7 +93,7 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d);
|
||||
ScanoutTextureNative native);
|
||||
void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,
|
||||
uint32_t x, uint32_t y, uint32_t w, uint32_t h);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "ui/qemu-pixman.h"
|
||||
#include "ui/console.h"
|
||||
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_GBM)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL) && defined(CONFIG_GBM)
|
||||
# define HAVE_SPICE_GL 1
|
||||
# include "ui/egl-helpers.h"
|
||||
# include "ui/egl-context.h"
|
||||
|
||||
+14
-6
@@ -832,6 +832,7 @@ version_res = []
|
||||
coref = []
|
||||
iokit = []
|
||||
pvg = not_found
|
||||
metal = not_found
|
||||
emulator_link_args = []
|
||||
midl = not_found
|
||||
widl = not_found
|
||||
@@ -859,6 +860,7 @@ elif host_os == 'darwin'
|
||||
host_dsosuf = '.dylib'
|
||||
pvg = dependency('appleframeworks', modules: ['ParavirtualizedGraphics', 'Metal'],
|
||||
required: get_option('pvg'))
|
||||
metal = dependency('appleframeworks', modules: 'Metal', required: false)
|
||||
elif host_os == 'sunos'
|
||||
socket = [cc.find_library('socket'),
|
||||
cc.find_library('nsl'),
|
||||
@@ -1216,7 +1218,7 @@ if get_option('attr').allowed()
|
||||
endif
|
||||
|
||||
cocoa = dependency('appleframeworks',
|
||||
modules: ['Cocoa', 'CoreVideo', 'QuartzCore'],
|
||||
modules: ['Cocoa', 'CoreVideo', 'OpenGL', 'QuartzCore'],
|
||||
required: get_option('cocoa'))
|
||||
|
||||
vmnet = dependency('appleframeworks', modules: 'vmnet', required: get_option('vmnet'))
|
||||
@@ -1800,14 +1802,13 @@ if not get_option('coreaudio').auto() or (host_os == 'darwin' and have_system)
|
||||
required: get_option('coreaudio'))
|
||||
endif
|
||||
|
||||
egl = not_found
|
||||
opengl = not_found
|
||||
if not get_option('opengl').auto() or have_system or have_vhost_user_gpu
|
||||
epoxy = dependency('epoxy', method: 'pkg-config',
|
||||
opengl = dependency('epoxy', method: 'pkg-config',
|
||||
required: get_option('opengl'))
|
||||
if cc.has_header('epoxy/egl.h', dependencies: epoxy)
|
||||
opengl = epoxy
|
||||
elif get_option('opengl').enabled()
|
||||
error('epoxy/egl.h not found')
|
||||
if cc.has_header('epoxy/egl.h', dependencies: opengl)
|
||||
egl = opengl
|
||||
endif
|
||||
endif
|
||||
gbm = not_found
|
||||
@@ -2506,6 +2507,7 @@ if numa.found()
|
||||
cc.has_function('numa_has_preferred_many',
|
||||
dependencies: numa))
|
||||
endif
|
||||
config_host_data.set('CONFIG_EGL', egl.found())
|
||||
config_host_data.set('CONFIG_OPENGL', opengl.found())
|
||||
config_host_data.set('CONFIG_PLUGIN', get_option('plugins'))
|
||||
config_host_data.set('CONFIG_RBD', rbd.found())
|
||||
@@ -2547,6 +2549,11 @@ config_host_data.set('CONFIG_VNC', vnc.found())
|
||||
config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
|
||||
config_host_data.set('CONFIG_VNC_SASL', sasl.found())
|
||||
if virgl.found()
|
||||
config_host_data.set('HAVE_VIRGL_RENDERER_NATIVE_SCANOUT',
|
||||
cc.has_function('virgl_renderer_create_handle_for_scanout',
|
||||
args: '-DVIRGL_RENDERER_UNSTABLE_APIS',
|
||||
prefix: '#include <virglrenderer.h>',
|
||||
dependencies: virgl))
|
||||
config_host_data.set('VIRGL_VERSION_MAJOR', virgl.version().split('.')[0])
|
||||
endif
|
||||
config_host_data.set('CONFIG_VIRTFS', have_virtfs)
|
||||
@@ -2591,6 +2598,7 @@ if xen.found()
|
||||
('0' + xen_version[2]).substring(-2)
|
||||
config_host_data.set('CONFIG_XEN_CTRL_INTERFACE_VERSION', xen_ctrl_version)
|
||||
endif
|
||||
config_host_data.set('CONFIG_METAL', metal.found())
|
||||
config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
|
||||
config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
|
||||
config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
|
||||
|
||||
+3
-2
@@ -1521,7 +1521,8 @@
|
||||
{ 'name': 'none' },
|
||||
{ 'name': 'gtk', 'if': 'CONFIG_GTK' },
|
||||
{ 'name': 'sdl', 'if': 'CONFIG_SDL' },
|
||||
{ 'name': 'egl-headless', 'if': 'CONFIG_OPENGL' },
|
||||
{ 'name': 'egl-headless',
|
||||
'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_EGL'] } },
|
||||
{ 'name': 'curses', 'if': 'CONFIG_CURSES' },
|
||||
{ 'name': 'cocoa', 'if': 'CONFIG_COCOA' },
|
||||
{ 'name': 'spice-app', 'if': 'CONFIG_SPICE' },
|
||||
@@ -1561,7 +1562,7 @@
|
||||
'cocoa': { 'type': 'DisplayCocoa', 'if': 'CONFIG_COCOA' },
|
||||
'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' },
|
||||
'egl-headless': { 'type': 'DisplayEGLHeadless',
|
||||
'if': 'CONFIG_OPENGL' },
|
||||
'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_EGL'] } },
|
||||
'dbus': { 'type': 'DisplayDBus', 'if': 'CONFIG_DBUS_DISPLAY' },
|
||||
'sdl': { 'type': 'DisplaySDL', 'if': 'CONFIG_SDL' }
|
||||
}
|
||||
|
||||
+1
-1
@@ -2146,7 +2146,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
|
||||
" [,show-cursor=on|off][,left-command-key=on|off]\n"
|
||||
" [,full-screen=on|off][,zoom-to-fit=on|off]\n"
|
||||
#endif
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
"-display egl-headless[,rendernode=<file>]\n"
|
||||
#endif
|
||||
#if defined(CONFIG_DBUS_DISPLAY)
|
||||
|
||||
+67
-23
@@ -12,6 +12,9 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/log.h"
|
||||
#include <dlfcn.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#include "system/runstate.h"
|
||||
#include "system/hvf.h"
|
||||
@@ -880,7 +883,45 @@ void hvf_arch_vcpu_destroy(CPUState *cpu)
|
||||
assert_hvf_ok(ret);
|
||||
}
|
||||
|
||||
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)
|
||||
static hv_return_t hvf_set_ipa_granule(hv_vm_config_t config,
|
||||
uint32_t ipa_granule_size)
|
||||
{
|
||||
static hv_return_t (*set_ipa_granule)(hv_vm_config_t, uint32_t);
|
||||
uint64_t page_size = qemu_real_host_page_size();
|
||||
|
||||
/* macOS 26 introduces a public API for setting granule size */
|
||||
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && defined(MAC_OS_VERSION_26_0) && \
|
||||
MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0
|
||||
if (__builtin_available(macOS 26, *)) {
|
||||
hv_ipa_granule_t granule = HV_IPA_GRANULE_16KB;
|
||||
|
||||
if (ipa_granule_size == 4096) {
|
||||
granule = HV_IPA_GRANULE_4KB;
|
||||
} else if (ipa_granule_size != 16384) {
|
||||
error_report("Unsupported granule size: 0x%x", ipa_granule_size);
|
||||
return HV_UNSUPPORTED;
|
||||
}
|
||||
|
||||
return hv_vm_config_set_ipa_granule(config, granule);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* older macOS need to use a private API */
|
||||
if (!set_ipa_granule) {
|
||||
set_ipa_granule = dlsym(RTLD_NEXT, "_hv_vm_config_set_ipa_granule");
|
||||
}
|
||||
if (set_ipa_granule) {
|
||||
return set_ipa_granule(config, ipa_granule_size);
|
||||
} else if (ipa_granule_size != page_size) {
|
||||
error_report("Failed to find _hv_vm_config_set_ipa_granule");
|
||||
return HV_UNSUPPORTED;
|
||||
}
|
||||
|
||||
return HV_SUCCESS;
|
||||
}
|
||||
|
||||
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range,
|
||||
uint32_t ipa_granule_size)
|
||||
{
|
||||
hv_return_t ret;
|
||||
hv_vm_config_t config = hv_vm_config_create();
|
||||
@@ -891,6 +932,13 @@ hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)
|
||||
}
|
||||
chosen_ipa_bit_size = pa_range;
|
||||
|
||||
if (ipa_granule_size) {
|
||||
ret = hvf_set_ipa_granule(config, ipa_granule_size);
|
||||
if (ret != HV_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
ret = hv_vm_create(config);
|
||||
|
||||
cleanup:
|
||||
@@ -2029,34 +2077,30 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
|
||||
int ret;
|
||||
hv_return_t r;
|
||||
|
||||
if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
|
||||
hvf_inject_interrupts(cpu)) {
|
||||
return EXCP_INTERRUPT;
|
||||
}
|
||||
|
||||
if (cpu->halted) {
|
||||
return EXCP_HLT;
|
||||
}
|
||||
|
||||
flush_cpu_state(cpu);
|
||||
|
||||
do {
|
||||
if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
|
||||
hvf_inject_interrupts(cpu)) {
|
||||
return EXCP_INTERRUPT;
|
||||
}
|
||||
|
||||
bql_unlock();
|
||||
cpu_exec_start(cpu);
|
||||
r = hv_vcpu_run(cpu->accel->fd);
|
||||
cpu_exec_end(cpu);
|
||||
bql_lock();
|
||||
switch (r) {
|
||||
case HV_SUCCESS:
|
||||
ret = hvf_handle_vmexit(cpu, cpu->accel->exit);
|
||||
break;
|
||||
case HV_ILLEGAL_GUEST_STATE:
|
||||
trace_hvf_illegal_guest_state();
|
||||
/* fall through */
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
} while (ret == 0);
|
||||
bql_unlock();
|
||||
r = hv_vcpu_run(cpu->accel->fd);
|
||||
bql_lock();
|
||||
switch (r) {
|
||||
case HV_SUCCESS:
|
||||
ret = hvf_handle_vmexit(cpu, cpu->accel->exit);
|
||||
break;
|
||||
case HV_ILLEGAL_GUEST_STATE:
|
||||
trace_hvf_illegal_guest_state();
|
||||
/* fall through */
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -225,8 +225,16 @@ int hvf_arch_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range)
|
||||
hv_return_t hvf_arch_vm_create(MachineState *ms, uint32_t pa_range,
|
||||
uint32_t ipa_granule_size)
|
||||
{
|
||||
uint64_t page_size = qemu_real_host_page_size();
|
||||
|
||||
if (ipa_granule_size != 0 && ipa_granule_size != page_size) {
|
||||
error_report("Only supported IPA granule size: 0x%llx", page_size);
|
||||
return HV_UNSUPPORTED;
|
||||
}
|
||||
|
||||
return hv_vm_create(HV_VM_DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
+720
-279
File diff suppressed because it is too large.
Load diff
+53
-14
@@ -295,7 +295,7 @@ static void displaychangelistener_display_console(DisplayChangeListener *dcl,
|
||||
con->scanout.texture.y,
|
||||
con->scanout.texture.width,
|
||||
con->scanout.texture.height,
|
||||
con->scanout.texture.d3d_tex2d);
|
||||
con->scanout.texture.native);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,6 +808,41 @@ void dpy_gfx_update_full(QemuConsole *con)
|
||||
dpy_gfx_update(con, 0, 0, w, h);
|
||||
}
|
||||
|
||||
typedef struct ScanoutChange {
|
||||
ScanoutTextureNative native;
|
||||
ScanoutTextureCleanup cb_cleanup;
|
||||
} ScanoutChange;
|
||||
|
||||
#define SCANOUT_CHANGE_NONE ((ScanoutChange){ NO_NATIVE_TEXTURE })
|
||||
|
||||
static ScanoutChange dpy_change_scanout_kind(DisplayScanout *scanout,
|
||||
enum display_scanout kind)
|
||||
{
|
||||
ScanoutChange change = SCANOUT_CHANGE_NONE;
|
||||
|
||||
/**
|
||||
* We cannot cleanup until the resource is no longer in use, so we record it
|
||||
* You MUST call dpy_complete_scanout_change after all listeners are updated
|
||||
*/
|
||||
if (scanout->kind == SCANOUT_TEXTURE && scanout->texture.cb_cleanup) {
|
||||
change.native = scanout->texture.native;
|
||||
change.cb_cleanup = scanout->texture.cb_cleanup;
|
||||
}
|
||||
scanout->kind = kind;
|
||||
|
||||
return change;
|
||||
}
|
||||
|
||||
static void dpy_complete_scanout_change(ScanoutChange *change)
|
||||
{
|
||||
/**
|
||||
* If we previously have a texture and cleanup is required, we call it now
|
||||
*/
|
||||
if (change->native.type != SCANOUT_TEXTURE_NATIVE_TYPE_NONE && change->cb_cleanup) {
|
||||
change->cb_cleanup(&change->native);
|
||||
}
|
||||
}
|
||||
|
||||
void dpy_gfx_replace_surface(QemuConsole *con,
|
||||
DisplaySurface *surface)
|
||||
{
|
||||
@@ -818,6 +853,7 @@ void dpy_gfx_replace_surface(QemuConsole *con,
|
||||
DisplayChangeListener *dcl;
|
||||
int width;
|
||||
int height;
|
||||
ScanoutChange change = SCANOUT_CHANGE_NONE;
|
||||
|
||||
if (!surface) {
|
||||
if (old_surface) {
|
||||
@@ -833,7 +869,7 @@ void dpy_gfx_replace_surface(QemuConsole *con,
|
||||
|
||||
assert(old_surface != new_surface);
|
||||
|
||||
con->scanout.kind = SCANOUT_SURFACE;
|
||||
change = dpy_change_scanout_kind(&con->scanout, SCANOUT_SURFACE);
|
||||
con->surface = new_surface;
|
||||
dpy_gfx_create_texture(con, new_surface);
|
||||
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||
@@ -844,6 +880,7 @@ void dpy_gfx_replace_surface(QemuConsole *con,
|
||||
}
|
||||
dpy_gfx_destroy_texture(con, old_surface);
|
||||
qemu_free_displaysurface(old_surface);
|
||||
dpy_complete_scanout_change(&change);
|
||||
}
|
||||
|
||||
bool dpy_gfx_check_format(QemuConsole *con,
|
||||
@@ -1002,9 +1039,10 @@ void dpy_gl_scanout_disable(QemuConsole *con)
|
||||
{
|
||||
DisplayState *s = con->ds;
|
||||
DisplayChangeListener *dcl;
|
||||
ScanoutChange change = SCANOUT_CHANGE_NONE;
|
||||
|
||||
if (con->scanout.kind != SCANOUT_SURFACE) {
|
||||
con->scanout.kind = SCANOUT_NONE;
|
||||
change = dpy_change_scanout_kind(&con->scanout, SCANOUT_NONE);
|
||||
}
|
||||
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||
if (con != dcl->con) {
|
||||
@@ -1014,6 +1052,7 @@ void dpy_gl_scanout_disable(QemuConsole *con)
|
||||
dcl->ops->dpy_gl_scanout_disable(dcl);
|
||||
}
|
||||
}
|
||||
dpy_complete_scanout_change(&change);
|
||||
}
|
||||
|
||||
void dpy_gl_scanout_texture(QemuConsole *con,
|
||||
@@ -1023,15 +1062,17 @@ void dpy_gl_scanout_texture(QemuConsole *con,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t width, uint32_t height,
|
||||
void *d3d_tex2d)
|
||||
ScanoutTextureNative native,
|
||||
ScanoutTextureCleanup cb_cleanup)
|
||||
{
|
||||
DisplayState *s = con->ds;
|
||||
DisplayChangeListener *dcl;
|
||||
ScanoutChange change = SCANOUT_CHANGE_NONE;
|
||||
|
||||
con->scanout.kind = SCANOUT_TEXTURE;
|
||||
change = dpy_change_scanout_kind(&con->scanout, SCANOUT_TEXTURE);
|
||||
con->scanout.texture = (ScanoutTexture) {
|
||||
backing_id, backing_y_0_top, backing_width, backing_height,
|
||||
x, y, width, height, d3d_tex2d,
|
||||
x, y, width, height, native, cb_cleanup
|
||||
};
|
||||
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||
if (con != dcl->con) {
|
||||
@@ -1042,9 +1083,10 @@ void dpy_gl_scanout_texture(QemuConsole *con,
|
||||
backing_y_0_top,
|
||||
backing_width, backing_height,
|
||||
x, y, width, height,
|
||||
d3d_tex2d);
|
||||
native);
|
||||
}
|
||||
}
|
||||
dpy_complete_scanout_change(&change);
|
||||
}
|
||||
|
||||
void dpy_gl_scanout_dmabuf(QemuConsole *con,
|
||||
@@ -1052,8 +1094,9 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con,
|
||||
{
|
||||
DisplayState *s = con->ds;
|
||||
DisplayChangeListener *dcl;
|
||||
ScanoutChange change = SCANOUT_CHANGE_NONE;
|
||||
|
||||
con->scanout.kind = SCANOUT_DMABUF;
|
||||
change = dpy_change_scanout_kind(&con->scanout, SCANOUT_DMABUF);
|
||||
con->scanout.dmabuf = dmabuf;
|
||||
QLIST_FOREACH(dcl, &s->listeners, next) {
|
||||
if (con != dcl->con) {
|
||||
@@ -1063,6 +1106,7 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con,
|
||||
dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf);
|
||||
}
|
||||
}
|
||||
dpy_complete_scanout_change(&change);
|
||||
}
|
||||
|
||||
void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf,
|
||||
@@ -1487,12 +1531,7 @@ void qemu_console_resize(QemuConsole *s, int width, int height)
|
||||
|
||||
DisplaySurface *qemu_console_surface(QemuConsole *console)
|
||||
{
|
||||
switch (console->scanout.kind) {
|
||||
case SCANOUT_SURFACE:
|
||||
return console->surface;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
return console->surface;
|
||||
}
|
||||
|
||||
PixelFormat qemu_default_pixelformat(int bpp)
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ dbus_gl_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d)
|
||||
ScanoutTextureNative native)
|
||||
{
|
||||
DBusDisplayConsole *ddc = container_of(dcl, DBusDisplayConsole, dcl);
|
||||
|
||||
|
||||
+4
-4
@@ -587,7 +587,7 @@ static void dbus_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d)
|
||||
ScanoutTextureNative native)
|
||||
{
|
||||
trace_dbus_scanout_texture(tex_id, backing_y_0_top,
|
||||
backing_width, backing_height, x, y, w, h);
|
||||
@@ -618,8 +618,8 @@ static void dbus_scanout_texture(DisplayChangeListener *dcl,
|
||||
assert(surface_width(ddl->ds) == w);
|
||||
assert(surface_height(ddl->ds) == h);
|
||||
|
||||
if (d3d_tex2d) {
|
||||
dbus_scanout_share_d3d_texture(ddl, d3d_tex2d, backing_y_0_top,
|
||||
if (native.type == SCANOUT_TEXTURE_NATIVE_TYPE_D3D) {
|
||||
dbus_scanout_share_d3d_texture(ddl, native.handle, backing_y_0_top,
|
||||
backing_width, backing_height, x, y, w, h);
|
||||
} else {
|
||||
dbus_scanout_map(ddl);
|
||||
@@ -868,7 +868,7 @@ static void dbus_gl_gfx_switch(DisplayChangeListener *dcl,
|
||||
|
||||
/* TODO: lazy send dmabuf (there are unnecessary sent otherwise) */
|
||||
dbus_scanout_texture(&ddl->dcl, ddl->ds->texture, false,
|
||||
width, height, 0, 0, width, height, NULL);
|
||||
width, height, 0, 0, width, height, NO_NATIVE_TEXTURE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ static void egl_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d)
|
||||
ScanoutTextureNative native)
|
||||
{
|
||||
egl_dpy *edpy = container_of(dcl, egl_dpy, dcl);
|
||||
|
||||
@@ -97,7 +97,7 @@ static void egl_scanout_dmabuf(DisplayChangeListener *dcl,
|
||||
height = qemu_dmabuf_get_height(dmabuf);
|
||||
|
||||
egl_scanout_texture(dcl, texture, false, width, height, 0, 0,
|
||||
width, height, NULL);
|
||||
width, height, NO_NATIVE_TEXTURE);
|
||||
}
|
||||
|
||||
static void egl_cursor_dmabuf(DisplayChangeListener *dcl,
|
||||
|
||||
+102
-65
@@ -28,7 +28,7 @@
|
||||
EGLDisplay *qemu_egl_display;
|
||||
EGLConfig qemu_egl_config;
|
||||
DisplayGLMode qemu_egl_mode;
|
||||
bool qemu_egl_angle_d3d;
|
||||
void *qemu_egl_angle_native_device;
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
@@ -466,7 +466,7 @@ void egl_dmabuf_create_fence(QemuDmaBuf *dmabuf)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win)
|
||||
EGLSurface qemu_egl_init_surface(EGLContext ectx, EGLNativeWindowType win)
|
||||
{
|
||||
EGLSurface esurface;
|
||||
EGLBoolean b;
|
||||
@@ -490,6 +490,95 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static int qemu_egl_init_dpy(EGLDisplay dpy, DisplayGLMode mode)
|
||||
{
|
||||
static const EGLint conf_att_core[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 5,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_ALPHA_SIZE, 0,
|
||||
EGL_NONE,
|
||||
};
|
||||
static const EGLint conf_att_gles[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 5,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_ALPHA_SIZE, 0,
|
||||
EGL_NONE,
|
||||
};
|
||||
EGLint major, minor;
|
||||
EGLBoolean b;
|
||||
EGLint n;
|
||||
bool gles = (mode == DISPLAY_GL_MODE_ES);
|
||||
|
||||
qemu_egl_display = dpy;
|
||||
|
||||
b = eglInitialize(qemu_egl_display, &major, &minor);
|
||||
if (b == EGL_FALSE) {
|
||||
error_report("egl: eglInitialize failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
b = eglBindAPI(gles ? EGL_OPENGL_ES_API : EGL_OPENGL_API);
|
||||
if (b == EGL_FALSE) {
|
||||
error_report("egl: eglBindAPI failed (%s mode)",
|
||||
gles ? "gles" : "core");
|
||||
return -1;
|
||||
}
|
||||
|
||||
b = eglChooseConfig(qemu_egl_display,
|
||||
gles ? conf_att_gles : conf_att_core,
|
||||
&qemu_egl_config, 1, &n);
|
||||
if (b == EGL_FALSE || n != 1) {
|
||||
error_report("egl: eglChooseConfig failed (%s mode)",
|
||||
gles ? "gles" : "core");
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemu_egl_mode = gles ? DISPLAY_GL_MODE_ES : DISPLAY_GL_MODE_CORE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qemu_egl_init_dpy_cocoa(DisplayGLMode mode)
|
||||
{
|
||||
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (dpy == EGL_NO_DISPLAY) {
|
||||
error_report("egl: eglGetDisplay failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (qemu_egl_init_dpy(dpy, mode) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef EGL_METAL_DEVICE_ANGLE
|
||||
if (epoxy_has_egl_extension(qemu_egl_display, "EGL_EXT_device_query")) {
|
||||
EGLDeviceEXT device;
|
||||
void *metal_device;
|
||||
|
||||
if (!eglQueryDisplayAttribEXT(qemu_egl_display,
|
||||
EGL_DEVICE_EXT,
|
||||
(EGLAttrib *)&device)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!eglQueryDeviceAttribEXT(device,
|
||||
EGL_METAL_DEVICE_ANGLE,
|
||||
(EGLAttrib *)&metal_device)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
qemu_egl_angle_native_device = metal_device;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_X11) || defined(CONFIG_GBM) || defined(WIN32)
|
||||
|
||||
/*
|
||||
@@ -520,8 +609,9 @@ EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win)
|
||||
* platform extensions (EGL_KHR_platform_gbm and friends) yet it doesn't seem
|
||||
* like mesa will be able to advertise these (even though it can do EGL 1.5).
|
||||
*/
|
||||
static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
|
||||
EGLenum platform)
|
||||
static int qemu_egl_init_dpy_platform(EGLNativeDisplayType native,
|
||||
EGLenum platform,
|
||||
DisplayGLMode mode)
|
||||
{
|
||||
EGLDisplay dpy = EGL_NO_DISPLAY;
|
||||
|
||||
@@ -536,66 +626,13 @@ static EGLDisplay qemu_egl_get_display(EGLNativeDisplayType native,
|
||||
/* fallback */
|
||||
dpy = eglGetDisplay(native);
|
||||
}
|
||||
return dpy;
|
||||
}
|
||||
|
||||
static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
|
||||
EGLenum platform,
|
||||
DisplayGLMode mode)
|
||||
{
|
||||
static const EGLint conf_att_core[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 5,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_ALPHA_SIZE, 0,
|
||||
EGL_NONE,
|
||||
};
|
||||
static const EGLint conf_att_gles[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_RED_SIZE, 5,
|
||||
EGL_GREEN_SIZE, 5,
|
||||
EGL_BLUE_SIZE, 5,
|
||||
EGL_ALPHA_SIZE, 0,
|
||||
EGL_NONE,
|
||||
};
|
||||
EGLint major, minor;
|
||||
EGLBoolean b;
|
||||
EGLint n;
|
||||
bool gles = (mode == DISPLAY_GL_MODE_ES);
|
||||
|
||||
qemu_egl_display = qemu_egl_get_display(dpy, platform);
|
||||
if (qemu_egl_display == EGL_NO_DISPLAY) {
|
||||
error_report("egl: eglGetDisplay failed: %s", qemu_egl_get_error_string());
|
||||
if (dpy == EGL_NO_DISPLAY) {
|
||||
error_report("egl: eglGetDisplay failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
b = eglInitialize(qemu_egl_display, &major, &minor);
|
||||
if (b == EGL_FALSE) {
|
||||
error_report("egl: eglInitialize failed: %s", qemu_egl_get_error_string());
|
||||
return -1;
|
||||
}
|
||||
|
||||
b = eglBindAPI(gles ? EGL_OPENGL_ES_API : EGL_OPENGL_API);
|
||||
if (b == EGL_FALSE) {
|
||||
error_report("egl: eglBindAPI failed (%s mode): %s",
|
||||
gles ? "gles" : "core", qemu_egl_get_error_string());
|
||||
return -1;
|
||||
}
|
||||
|
||||
b = eglChooseConfig(qemu_egl_display,
|
||||
gles ? conf_att_gles : conf_att_core,
|
||||
&qemu_egl_config, 1, &n);
|
||||
if (b == EGL_FALSE || n != 1) {
|
||||
error_report("egl: eglChooseConfig failed (%s mode): %s",
|
||||
gles ? "gles" : "core", qemu_egl_get_error_string());
|
||||
return -1;
|
||||
}
|
||||
|
||||
qemu_egl_mode = gles ? DISPLAY_GL_MODE_ES : DISPLAY_GL_MODE_CORE;
|
||||
return 0;
|
||||
return qemu_egl_init_dpy(dpy, mode);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -604,18 +641,18 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy,
|
||||
int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode)
|
||||
{
|
||||
#ifdef EGL_KHR_platform_x11
|
||||
return qemu_egl_init_dpy(dpy, EGL_PLATFORM_X11_KHR, mode);
|
||||
return qemu_egl_init_dpy_platform(dpy, EGL_PLATFORM_X11_KHR, mode);
|
||||
#else
|
||||
return qemu_egl_init_dpy(dpy, 0, mode);
|
||||
return qemu_egl_init_dpy_platform(dpy, 0, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode)
|
||||
{
|
||||
#ifdef EGL_MESA_platform_gbm
|
||||
return qemu_egl_init_dpy(dpy, EGL_PLATFORM_GBM_MESA, mode);
|
||||
return qemu_egl_init_dpy_platform(dpy, EGL_PLATFORM_GBM_MESA, mode);
|
||||
#else
|
||||
return qemu_egl_init_dpy(dpy, 0, mode);
|
||||
return qemu_egl_init_dpy_platform(dpy, 0, mode);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -651,7 +688,7 @@ int qemu_egl_init_dpy_win32(EGLNativeDisplayType dpy, DisplayGLMode mode)
|
||||
}
|
||||
|
||||
trace_egl_init_d3d11_device(device);
|
||||
qemu_egl_angle_d3d = device != NULL;
|
||||
qemu_egl_angle_native_device = d3d11_device;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+3
-3
@@ -57,7 +57,7 @@ void gd_egl_init(VirtualConsole *vc)
|
||||
}
|
||||
|
||||
vc->gfx.ectx = qemu_egl_init_ctx();
|
||||
vc->gfx.esurface = qemu_egl_init_surface_x11
|
||||
vc->gfx.esurface = qemu_egl_init_surface
|
||||
(vc->gfx.ectx, (EGLNativeWindowType)x11_window);
|
||||
|
||||
assert(vc->gfx.esurface);
|
||||
@@ -239,7 +239,7 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_width, uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d)
|
||||
ScanoutTextureNative native)
|
||||
{
|
||||
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
|
||||
|
||||
@@ -290,7 +290,7 @@ void gd_egl_scanout_dmabuf(DisplayChangeListener *dcl,
|
||||
y0_top = qemu_dmabuf_get_y0_top(dmabuf);
|
||||
|
||||
gd_egl_scanout_texture(dcl, texture, y0_top, backing_width, backing_height,
|
||||
x, y, width, height, NULL);
|
||||
x, y, width, height, NO_NATIVE_TEXTURE);
|
||||
|
||||
if (qemu_dmabuf_get_allow_fences(dmabuf)) {
|
||||
vc->gfx.guest_fb.dmabuf = dmabuf;
|
||||
|
||||
+2
-2
@@ -306,7 +306,7 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d)
|
||||
ScanoutTextureNative native)
|
||||
{
|
||||
VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
|
||||
|
||||
@@ -374,7 +374,7 @@ void gd_gl_area_scanout_dmabuf(DisplayChangeListener *dcl,
|
||||
|
||||
gd_gl_area_scanout_texture(dcl, texture, y0_top,
|
||||
backing_width, backing_height,
|
||||
x, y, width, height, NULL);
|
||||
x, y, width, height, NO_NATIVE_TEXTURE);
|
||||
|
||||
if (qemu_dmabuf_get_allow_fences(dmabuf)) {
|
||||
vc->gfx.guest_fb.dmabuf = dmabuf;
|
||||
|
||||
@@ -342,7 +342,7 @@ static void gd_update_full_redraw(VirtualConsole *vc)
|
||||
int ww, wh;
|
||||
ww = gdk_window_get_width(gtk_widget_get_window(area));
|
||||
wh = gdk_window_get_height(gtk_widget_get_window(area));
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
if (vc->gfx.gls && gtk_use_gl_area) {
|
||||
gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));
|
||||
return;
|
||||
@@ -563,7 +563,7 @@ static const DisplayChangeListenerOps dcl_ops = {
|
||||
};
|
||||
|
||||
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
|
||||
static bool gd_has_dmabuf(DisplayChangeListener *dcl)
|
||||
{
|
||||
@@ -674,7 +674,7 @@ static const DisplayGLCtxOps egl_ctx_ops = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_OPENGL */
|
||||
#endif /* defined(CONFIG_OPENGL) && defined(CONFIG_EGL) */
|
||||
|
||||
/** QEMU Events **/
|
||||
|
||||
@@ -752,7 +752,7 @@ static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height)
|
||||
dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
|
||||
static gboolean gd_render_event(GtkGLArea *area, GdkGLContext *context,
|
||||
void *opaque)
|
||||
@@ -906,7 +906,7 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque)
|
||||
int ww_widget, wh_widget, ww_surface, wh_surface;
|
||||
int fbw, fbh;
|
||||
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
if (vc->gfx.gls) {
|
||||
if (gtk_use_gl_area) {
|
||||
/* invoke render callback please */
|
||||
@@ -1465,7 +1465,7 @@ static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event,
|
||||
vc->tab_item, vc->label);
|
||||
gtk_widget_destroy(vc->window);
|
||||
vc->window = NULL;
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
if (vc->gfx.esurface) {
|
||||
eglDestroySurface(qemu_egl_display, vc->gfx.esurface);
|
||||
vc->gfx.esurface = NULL;
|
||||
@@ -1504,7 +1504,7 @@ static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
|
||||
if (!vc->window) {
|
||||
gtk_widget_set_sensitive(vc->menu_item, false);
|
||||
vc->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
if (vc->gfx.esurface) {
|
||||
eglDestroySurface(qemu_egl_display, vc->gfx.esurface);
|
||||
vc->gfx.esurface = NULL;
|
||||
@@ -2116,7 +2116,7 @@ static void gd_connect_vc_gfx_signals(VirtualConsole *vc)
|
||||
{
|
||||
g_signal_connect(vc->gfx.drawing_area, "draw",
|
||||
G_CALLBACK(gd_draw_event), vc);
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
if (gtk_use_gl_area) {
|
||||
/* wire up GtkGlArea events */
|
||||
g_signal_connect(vc->gfx.drawing_area, "render",
|
||||
@@ -2232,7 +2232,7 @@ static GtkWidget *gd_create_menu_machine(GtkDisplayState *s)
|
||||
return machine_menu;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
static void gl_area_realize(GtkGLArea *area, VirtualConsole *vc)
|
||||
{
|
||||
gtk_gl_area_make_current(area);
|
||||
@@ -2271,7 +2271,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
|
||||
vc->gfx.scale_x = vc->gfx.preferred_scale;
|
||||
vc->gfx.scale_y = vc->gfx.preferred_scale;
|
||||
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
if (display_opengl) {
|
||||
if (gtk_use_gl_area) {
|
||||
vc->gfx.drawing_area = gtk_gl_area_new();
|
||||
@@ -2639,7 +2639,7 @@ static void early_gtk_display_init(DisplayOptions *opts)
|
||||
|
||||
assert(opts->type == DISPLAY_TYPE_GTK);
|
||||
if (opts->has_gl && opts->gl != DISPLAY_GL_MODE_OFF) {
|
||||
#if defined(CONFIG_OPENGL)
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
#if defined(GDK_WINDOWING_WAYLAND)
|
||||
if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
|
||||
gtk_use_gl_area = true;
|
||||
@@ -2682,6 +2682,6 @@ static void register_gtk(void)
|
||||
|
||||
type_init(register_gtk);
|
||||
|
||||
#ifdef CONFIG_OPENGL
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
module_dep("ui-opengl");
|
||||
#endif
|
||||
+8
-6
@@ -59,14 +59,16 @@ if opengl.found()
|
||||
opengl_ss = ss.source_set()
|
||||
opengl_ss.add(gbm, pixman)
|
||||
opengl_ss.add(when: [opengl],
|
||||
if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
|
||||
if_true: files('shader.c', 'console-gl.c'))
|
||||
opengl_ss.add(when: [egl, opengl],
|
||||
if_true: files('egl-helpers.c', 'egl-context.c'))
|
||||
ui_modules += {'opengl' : opengl_ss}
|
||||
endif
|
||||
|
||||
if opengl.found()
|
||||
egl_headless_ss = ss.source_set()
|
||||
egl_headless_ss.add(when: [opengl, pixman],
|
||||
if_true: [files('egl-headless.c'), gbm])
|
||||
egl_headless_ss.add(when: [egl, opengl, gbm, pixman],
|
||||
if_true: files('egl-headless.c'))
|
||||
ui_modules += {'egl-headless' : egl_headless_ss}
|
||||
endif
|
||||
|
||||
@@ -111,8 +113,8 @@ if gtk.found()
|
||||
gtk_ss.add(files('gtk-clipboard.c'))
|
||||
endif
|
||||
gtk_ss.add(when: x11, if_true: files('x_keymap.c'))
|
||||
gtk_ss.add(when: opengl, if_true: files('gtk-gl-area.c'))
|
||||
gtk_ss.add(when: [x11, opengl], if_true: files('gtk-egl.c'))
|
||||
gtk_ss.add(when: [egl, opengl], if_true: files('gtk-gl-area.c'))
|
||||
gtk_ss.add(when: [egl, x11, opengl], if_true: files('gtk-egl.c'))
|
||||
ui_modules += {'gtk' : gtk_ss}
|
||||
endif
|
||||
|
||||
@@ -123,7 +125,7 @@ if sdl.found()
|
||||
'sdl2-input.c',
|
||||
'sdl2.c',
|
||||
))
|
||||
sdl_ss.add(when: opengl, if_true: files('sdl2-gl.c'))
|
||||
sdl_ss.add(when: [egl, opengl], if_true: files('sdl2-gl.c'))
|
||||
sdl_ss.add(when: x11, if_true: files('x_keymap.c'))
|
||||
ui_modules += {'sdl' : sdl_ss}
|
||||
endif
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d)
|
||||
ScanoutTextureNative native)
|
||||
{
|
||||
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ void sdl2_window_create(struct sdl2_console *scon)
|
||||
if (scon->hidden) {
|
||||
flags |= SDL_WINDOW_HIDDEN;
|
||||
}
|
||||
#ifdef CONFIG_OPENGL
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
if (scon->opengl) {
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ void sdl2_window_resize(struct sdl2_console *scon)
|
||||
static void sdl2_redraw(struct sdl2_console *scon)
|
||||
{
|
||||
if (scon->opengl) {
|
||||
#ifdef CONFIG_OPENGL
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
sdl2_gl_redraw(scon);
|
||||
#endif
|
||||
} else {
|
||||
@@ -795,7 +795,7 @@ static const DisplayChangeListenerOps dcl_2d_ops = {
|
||||
.dpy_cursor_define = sdl_mouse_define,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_OPENGL
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
static const DisplayChangeListenerOps dcl_gl_ops = {
|
||||
.dpy_name = "sdl2-gl",
|
||||
.dpy_gfx_update = sdl2_gl_update,
|
||||
@@ -829,7 +829,7 @@ static void sdl2_display_early_init(DisplayOptions *o)
|
||||
{
|
||||
assert(o->type == DISPLAY_TYPE_SDL);
|
||||
if (o->has_gl && o->gl) {
|
||||
#ifdef CONFIG_OPENGL
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
display_opengl = 1;
|
||||
#endif
|
||||
}
|
||||
@@ -896,7 +896,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
|
||||
}
|
||||
sdl2_console[i].idx = i;
|
||||
sdl2_console[i].opts = o;
|
||||
#ifdef CONFIG_OPENGL
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
sdl2_console[i].opengl = display_opengl;
|
||||
sdl2_console[i].dcl.ops = display_opengl ? &dcl_gl_ops : &dcl_2d_ops;
|
||||
sdl2_console[i].dgc.ops = display_opengl ? &gl_ctx_ops : NULL;
|
||||
@@ -968,6 +968,6 @@ static void register_sdl1(void)
|
||||
|
||||
type_init(register_sdl1);
|
||||
|
||||
#ifdef CONFIG_OPENGL
|
||||
#if defined(CONFIG_OPENGL) && defined(CONFIG_EGL)
|
||||
module_dep("ui-opengl");
|
||||
#endif
|
||||
+10
-2
@@ -152,11 +152,19 @@ end:
|
||||
QemuGLShader *qemu_gl_init_shader(void)
|
||||
{
|
||||
QemuGLShader *gls = g_new0(QemuGLShader, 1);
|
||||
const char *header = epoxy_is_desktop_gl() ? "#version 140\n" : "#version 300 es\n";
|
||||
char vert_src[256];
|
||||
char frag_src[256];
|
||||
char *vert_src_body = stpcpy(vert_src, header);
|
||||
char *frag_src_body = stpcpy(frag_src, header);
|
||||
|
||||
strcpy(vert_src_body, texture_blit_vert_src);
|
||||
strcpy(frag_src_body, texture_blit_frag_src);
|
||||
gls->texture_blit_prog = qemu_gl_create_compile_link_program
|
||||
(texture_blit_vert_src, texture_blit_frag_src);
|
||||
(vert_src, frag_src);
|
||||
strcpy(vert_src_body, texture_blit_flip_vert_src);
|
||||
gls->texture_blit_flip_prog = qemu_gl_create_compile_link_program
|
||||
(texture_blit_flip_vert_src, texture_blit_frag_src);
|
||||
(vert_src, frag_src);
|
||||
if (!gls->texture_blit_prog || !gls->texture_blit_flip_prog) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 300 es
|
||||
|
||||
in vec2 in_position;
|
||||
out vec2 ex_tex_coord;
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 300 es
|
||||
|
||||
uniform sampler2D image;
|
||||
in mediump vec2 ex_tex_coord;
|
||||
out mediump vec4 out_frag_color;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#version 300 es
|
||||
|
||||
in vec2 in_position;
|
||||
out vec2 ex_tex_coord;
|
||||
|
||||
|
||||
+1
-1
@@ -1084,7 +1084,7 @@ static void qemu_spice_gl_scanout_texture(DisplayChangeListener *dcl,
|
||||
uint32_t backing_height,
|
||||
uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h,
|
||||
void *d3d_tex2d)
|
||||
ScanoutTextureNative native)
|
||||
{
|
||||
SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
|
||||
EGLint offset[DMABUF_MAX_PLANES], stride[DMABUF_MAX_PLANES], fourcc = 0;
|
||||
|
||||
Reference in new issue
Block a user