summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2019-10-29 10:47:05 +0000
committerFrediano Ziglio <freddy77@gmail.com>2021-06-14 11:54:09 +0100
commit8bec2c0b4d4ebbba6f02a245f1bbc8b634b0d08a (patch)
tree930c37e252daf04170d5ecf139f45805fe40d19c
parentf49dc2d62841ef09bcf573905dbd0ddfc0d2fed1 (diff)
SAVE attempt to make it work againvirgl-spice
-rw-r--r--server/dcc-send.cpp5
-rw-r--r--server/dcc.cpp20
-rw-r--r--server/display-channel.cpp8
-rw-r--r--server/egl.h3
-rw-r--r--server/red-qxl.cpp5
5 files changed, 37 insertions, 4 deletions
diff --git a/server/dcc-send.cpp b/server/dcc-send.cpp
index 6e64ed68..8f49b3fc 100644
--- a/server/dcc-send.cpp
+++ b/server/dcc-send.cpp
@@ -2090,8 +2090,10 @@ static void marshall_lossless_qxl_drawable(DisplayChannelClient *dcc,
}
}
-void image_extract_drm(SpiceImage *image)
+#undef image_extract_drm
+void image_extract_drm(SpiceImage *image, int line, const char *file)
{
+ printf("%s:%d: image_extract_drm called\n", file, line);
if (image->descriptor.type != SPICE_IMAGE_TYPE_DRM_PRIME) {
return;
}
@@ -2123,6 +2125,7 @@ void image_extract_drm(SpiceImage *image)
image->u.bitmap.palette = NULL;
image->u.bitmap.palette_id = 0;
}
+#define image_extract_drm(img) image_extract_drm(img, __LINE__, __FILE__);
void red_drawable_extract_drm(RedDrawable *red_drawable)
{
diff --git a/server/dcc.cpp b/server/dcc.cpp
index 6950a754..9c002cbe 100644
--- a/server/dcc.cpp
+++ b/server/dcc.cpp
@@ -24,6 +24,7 @@
#include "red-client.h"
#include "main-channel-client.h"
#include <spice-server-enums.h>
+#include "red-qxl.h"
#define DISPLAY_CLIENT_SHORT_TIMEOUT 15000000000ULL //nano
#define DISPLAY_FREE_LIST_DEFAULT_SIZE 128
@@ -503,6 +504,25 @@ RedPipeItemPtr dcc_gl_scanout_item_new(RedChannelClient *rcc, void *data, int nu
* video streaming */
if (!red_stream_is_plain_unix(rcc->get_stream()) ||
!rcc->test_remote_cap(SPICE_DISPLAY_CAP_GL_SCANOUT)) {
+ DisplayChannel *display = DCC_TO_DC(rcc);
+ if (!display->priv->surfaces[0].context.canvas) {
+ QXLInstance* qxl = display->priv->qxl;
+
+ uint32_t w = 0, h = 0;
+ SpiceMsgDisplayGlScanoutUnix *scanout = red_qxl_get_gl_scanout(qxl);
+ if (scanout != NULL) {
+ w = scanout->width;
+ h = scanout->height;
+ }
+ red_qxl_put_gl_scanout(qxl, scanout);
+ if (w != 0 && h != 0) {
+ display_channel_create_surface(display, 0, w, h,
+ w * 4, SPICE_SURFACE_FMT_32_xRGB,
+ NULL, true, true);
+ display_channel_set_monitors_config_to_primary(display);
+ }
+ printf("no way to send scanout\n");
+ }
return RedPipeItemPtr();
}
diff --git a/server/display-channel.cpp b/server/display-channel.cpp
index 6e167592..04508c5a 100644
--- a/server/display-channel.cpp
+++ b/server/display-channel.cpp
@@ -2358,7 +2358,7 @@ static gboolean display_channel_gl_handle_remote(DisplayChannel *display, uint32
RedChannelClient *rcc;
// check if all channel are remote
-// printf("entering...\n");
+ printf("entering...\n");
FOREACH_CLIENT(display, rcc) {
if (!red_stream_is_plain_unix(rcc->get_stream()) ||
!rcc->test_remote_cap(SPICE_DISPLAY_CAP_GL_SCANOUT)) {
@@ -2604,6 +2604,8 @@ void display_channel_set_image_compression(DisplayChannel *display,
display->priv->image_compression = image_compression;
}
+extern struct SpiceDrmPrimeContext global_egl_context;
+
/**
* Returns a RedDrawable with a bitmap image pointing to the data image
* we provide
@@ -2617,6 +2619,7 @@ static RedDrawable *get_dummy_drawable(DisplayChannel *display,
image->descriptor.width = w;
image->descriptor.height = h;
image->u.drm_prime = (SpiceDrmPrime){
+ .context = &global_egl_context,
.drm_dma_buf_fd = dup(scanout->drm_dma_buf_fd),
.width = w,
.height = h,
@@ -2625,6 +2628,7 @@ static RedDrawable *get_dummy_drawable(DisplayChannel *display,
.flags = scanout->flags,
};
+ printf("get_dummy_drawable called\n");
RedDrawable *red = spice_new0(RedDrawable, 1);
red->refs = 1;
display->priv->gl_dummy_count++;
@@ -2652,7 +2656,7 @@ static RedDrawable *get_dummy_gl_drawable(DisplayChannel *display)
if (scanout != NULL) {
spice_assert(scanout->drm_dma_buf_fd >= 0);
uint64_t time_scanout = spice_get_real_time_ns();
- uint64_t time_extracted = spice_get_real_time_ns();
+ uint64_t time_extracted = time_scanout;
red_drawable = get_dummy_drawable(display, scanout);
spice_assert(red_drawable);
red_drawable->time_scanout = time_scanout;
diff --git a/server/egl.h b/server/egl.h
index 995a75e6..566ad983 100644
--- a/server/egl.h
+++ b/server/egl.h
@@ -37,7 +37,8 @@ struct SpiceDrmPrimeContext {
/* Extract data from DRM prime and convert to normal bitmap.
* If image does not contain a DRM prime nothing is changed.
*/
-void image_extract_drm(SpiceImage *image);
+void image_extract_drm(SpiceImage *image, int line, const char *file);
+#define image_extract_drm(img) image_extract_drm(img, __LINE__, __FILE__);
/* Similar to image_extract_drm but handle images inside a RedDrawable */
void red_drawable_extract_drm(RedDrawable *red_drawable);
diff --git a/server/red-qxl.cpp b/server/red-qxl.cpp
index b3732422..b34ccc13 100644
--- a/server/red-qxl.cpp
+++ b/server/red-qxl.cpp
@@ -37,6 +37,7 @@
#include "display-limits.h"
#include "red-qxl.h"
+#include "egl.h"
#define MAX_MONITORS_COUNT 16
@@ -421,12 +422,16 @@ void red_qxl_put_gl_scanout(QXLInstance *qxl, SpiceMsgDisplayGlScanoutUnix *scan
}
}
+extern struct SpiceDrmPrimeContext global_egl_context;
+struct SpiceDrmPrimeContext global_egl_context;
+
SPICE_GNUC_VISIBLE
void spice_qxl_gl_setup(QXLInstance *qxl,
void *egl_display)
{
QXLState *qxl_state = qxl->st;
qxl_state->egl_display = egl_display;
+ global_egl_context.egl_display = egl_display;
}
SPICE_GNUC_VISIBLE