Revert "amd/intel: use xrgb format, use drm prime 2"

This reverts commit 2f665e9d53.
This commit is contained in:
dec05eba 2023-04-11 00:27:34 +02:00
parent 2f665e9d53
commit cc7cf8197e
2 changed files with 43 additions and 30 deletions

View File

@ -245,35 +245,48 @@ static int gsr_capture_kms_vaapi_capture(gsr_capture *cap, AVFrame *frame) {
cap_kms->input_surface = 0; cap_kms->input_surface = 0;
} }
VADRMPRIMESurfaceDescriptor buf = {0}; uintptr_t dmabuf = cap_kms->dmabuf_fd;
buf.fourcc = VA_FOURCC_XRGB;
VASurfaceAttribExternalBuffers buf = {0};
buf.pixel_format = VA_FOURCC_BGRX; // VA_FOURCC_XRGB
buf.width = cap_kms->kms_size.x; buf.width = cap_kms->kms_size.x;
buf.height = cap_kms->kms_size.y; buf.height = cap_kms->kms_size.y;
buf.data_size = cap_kms->kms_size.y * cap_kms->pitch;
buf.num_planes = 1;
buf.pitches[0] = cap_kms->pitch;
buf.offsets[0] = cap_kms->offset;
buf.buffers = &dmabuf;
buf.num_buffers = 1;
buf.flags = 0;
buf.private_data = 0;
buf.num_objects = 0; VADRMFormatModifierList modifier_list = {0};
buf.objects[0].fd = cap_kms->dmabuf_fd; modifier_list.modifiers = &cap_kms->modifiers;
buf.objects[0].size = cap_kms->kms_size.y * cap_kms->pitch; modifier_list.num_modifiers = 1;
buf.objects[0].drm_format_modifier = cap_kms->modifiers;
buf.num_layers = 1; #define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME 0x20000000
buf.layers[0].drm_format = cap_kms->fourcc;
buf.layers[0].num_planes = 1;
buf.layers[0].object_index[0] = 0;
buf.layers[0].offset[0] = cap_kms->offset;
buf.layers[0].pitch[0] = cap_kms->pitch;
VASurfaceAttrib attribs[2] = {0}; VASurfaceAttrib attribs[3] = {0};
attribs[0].type = VASurfaceAttribMemoryType; attribs[0].type = VASurfaceAttribMemoryType;
attribs[0].flags = VA_SURFACE_ATTRIB_SETTABLE; attribs[0].flags = VA_SURFACE_ATTRIB_SETTABLE;
attribs[0].value.type = VAGenericValueTypeInteger; attribs[0].value.type = VAGenericValueTypeInteger;
attribs[0].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2; attribs[0].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; // TODO: prime1 instead?
attribs[1].type = VASurfaceAttribExternalBufferDescriptor; attribs[1].type = VASurfaceAttribExternalBufferDescriptor;
attribs[1].flags = VA_SURFACE_ATTRIB_SETTABLE; attribs[1].flags = VA_SURFACE_ATTRIB_SETTABLE;
attribs[1].value.type = VAGenericValueTypePointer; attribs[1].value.type = VAGenericValueTypePointer;
attribs[1].value.value.p = &buf; attribs[1].value.value.p = &buf;
int num_attribs = 2;
if(cap_kms->modifiers != DRM_FORMAT_MOD_INVALID) {
attribs[2].type = VASurfaceAttribDRMFormatModifiers;
attribs[2].flags = VA_SURFACE_ATTRIB_SETTABLE;
attribs[2].value.type = VAGenericValueTypePointer;
attribs[2].value.value.p = &modifier_list;
++num_attribs;
}
// TODO: Do we really need to create a new surface every frame? // TODO: Do we really need to create a new surface every frame?
VAStatus va_status = vaCreateSurfaces(cap_kms->va_dpy, VA_RT_FORMAT_RGB32, cap_kms->kms_size.x, cap_kms->kms_size.y, &cap_kms->input_surface, 1, attribs, 2); VAStatus va_status = vaCreateSurfaces(cap_kms->va_dpy, VA_RT_FORMAT_RGB32, cap_kms->kms_size.x, cap_kms->kms_size.y, &cap_kms->input_surface, 1, attribs, num_attribs);
if(va_status != VA_STATUS_SUCCESS) { if(va_status != VA_STATUS_SUCCESS) {
fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_capture: vaCreateSurfaces failed: %d\n", va_status); fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_capture: vaCreateSurfaces failed: %d\n", va_status);
cap_kms->should_stop = true; cap_kms->should_stop = true;

View File

@ -11,8 +11,6 @@
#include <libavutil/hwcontext_vaapi.h> #include <libavutil/hwcontext_vaapi.h>
#include <libavutil/frame.h> #include <libavutil/frame.h>
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <va/va.h>
#include <va/va_drmcommon.h>
typedef struct { typedef struct {
gsr_capture_xcomposite_vaapi_params params; gsr_capture_xcomposite_vaapi_params params;
@ -385,28 +383,30 @@ static void gsr_capture_xcomposite_vaapi_tick(gsr_capture *cap, AVCodecContext *
cap_xcomp->egl.eglDestroyImage(cap_xcomp->egl.egl_display, img); cap_xcomp->egl.eglDestroyImage(cap_xcomp->egl.egl_display, img);
VADRMPRIMESurfaceDescriptor buf = {0}; uintptr_t dmabuf = cap_xcomp->dmabuf_fd;
buf.fourcc = VA_FOURCC_XRGB;
VASurfaceAttribExternalBuffers buf = {0};
buf.pixel_format = VA_FOURCC_BGRX;
buf.width = xx; buf.width = xx;
buf.height = yy; buf.height = yy;
buf.data_size = yy * cap_xcomp->pitch;
buf.num_planes = 1;
buf.pitches[0] = cap_xcomp->pitch;
buf.offsets[0] = cap_xcomp->offset;
buf.buffers = &dmabuf;
buf.num_buffers = 1;
buf.flags = 0;
buf.private_data = 0;
buf.num_objects = 0; // TODO: Use VASurfaceAttribDRMFormatModifiers to set modifier if modifier is not INVALID
buf.objects[0].fd = cap_xcomp->dmabuf_fd;
buf.objects[0].size = yy * cap_xcomp->pitch;
buf.objects[0].drm_format_modifier = cap_xcomp->modifiers;
buf.num_layers = 1; #define VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME 0x20000000
buf.layers[0].drm_format = cap_xcomp->fourcc;
buf.layers[0].num_planes = 1;
buf.layers[0].object_index[0] = 0;
buf.layers[0].offset[0] = cap_xcomp->offset;
buf.layers[0].pitch[0] = cap_xcomp->pitch;
VASurfaceAttrib attribs[2] = {0}; VASurfaceAttrib attribs[2] = {0};
attribs[0].type = VASurfaceAttribMemoryType; attribs[0].type = VASurfaceAttribMemoryType;
attribs[0].flags = VA_SURFACE_ATTRIB_SETTABLE; attribs[0].flags = VA_SURFACE_ATTRIB_SETTABLE;
attribs[0].value.type = VAGenericValueTypeInteger; attribs[0].value.type = VAGenericValueTypeInteger;
attribs[0].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2; attribs[0].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; // TODO: prime1 instead?
attribs[1].type = VASurfaceAttribExternalBufferDescriptor; attribs[1].type = VASurfaceAttribExternalBufferDescriptor;
attribs[1].flags = VA_SURFACE_ATTRIB_SETTABLE; attribs[1].flags = VA_SURFACE_ATTRIB_SETTABLE;
attribs[1].value.type = VAGenericValueTypePointer; attribs[1].value.type = VAGenericValueTypePointer;