Skip to content

Commit 50961c6

Browse files
committed
WIP
1 parent 7e8bb63 commit 50961c6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

virtio-gpu-sw.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include "virtio-gpu.h"
77
#include "window.h"
88

9-
#define STRIDE_SIZE 4096
10-
119
extern const struct window_backend g_window;
1210

1311
static void virtio_gpu_resource_create_2d_handler(virtio_gpu_state_t *vgpu,
@@ -71,12 +69,16 @@ static void virtio_gpu_resource_create_2d_handler(virtio_gpu_state_t *vgpu,
7169
return;
7270
}
7371

72+
uint32_t bytes_per_pixel = bits_per_pixel / 8;
73+
7474
/* Set 2D resource */
7575
res_2d->width = request->width;
7676
res_2d->height = request->height;
7777
res_2d->format = request->format;
7878
res_2d->bits_per_pixel = bits_per_pixel;
79-
res_2d->stride = STRIDE_SIZE;
79+
/* Stride calculation must match guest (Linux kernel) which uses: pitch =
80+
* width * 4 See linux/drivers/gpu/drm/virtio/virtgpu_gem.c:74 */
81+
res_2d->stride = request->width * (bits_per_pixel / 8);
8082
res_2d->image = malloc(res_2d->stride * request->height);
8183

8284
/* Failed to create image buffer */

0 commit comments

Comments
 (0)