Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
f12f7f6883 |
3 changed files with 74 additions and 30 deletions
21
.drone.yml
Normal file
21
.drone.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: archlinux:latest
|
||||||
|
commands:
|
||||||
|
- pacman -Syu --noconfirm --needed base-devel libvncserver libxkbcommon libdrm libva git cmake clang
|
||||||
|
- export CFLAGS="-pipe -fno-plt -fexceptions -fstack-clash-protection -fcf-protection -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security"
|
||||||
|
- CC=gcc cmake -B gcc-out
|
||||||
|
- cmake --build gcc-out
|
||||||
|
- CC=clang cmake -B clang-out
|
||||||
|
- cmake --build clang-out
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- dev
|
||||||
|
event:
|
||||||
|
exclude:
|
||||||
|
- pull_request
|
|
@ -1,27 +0,0 @@
|
||||||
name: Build with gcc + clang
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [dev]
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
if: "github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip ci]')"
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: archlinux:latest
|
|
||||||
env:
|
|
||||||
CFLAGS: "-pipe -fno-plt -fexceptions -fstack-clash-protection -fcf-protection -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security"
|
|
||||||
steps:
|
|
||||||
- name: Prepare dependencies
|
|
||||||
run: |
|
|
||||||
pacman -Syu --noconfirm --needed nodejs git \
|
|
||||||
base-devel libvncserver libxkbcommon libdrm libva cmake clang
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Build with gcc
|
|
||||||
run: |
|
|
||||||
CC=gcc cmake -B gcc-out
|
|
||||||
cmake --build gcc-out
|
|
||||||
- name: Build with clang
|
|
||||||
run: |
|
|
||||||
CC=clang cmake -B clang-out
|
|
||||||
cmake --build clang-out
|
|
54
drm.c
54
drm.c
|
@ -32,8 +32,57 @@
|
||||||
|
|
||||||
extern struct kmsvnc_data *kmsvnc;
|
extern struct kmsvnc_data *kmsvnc;
|
||||||
|
|
||||||
|
static int _rg16_clamp_flip(int x, int to) {
|
||||||
|
if (x < 0) return -x;
|
||||||
|
else if (x >= to) return to + to - x - 2;
|
||||||
|
else return x;
|
||||||
|
}
|
||||||
|
static void convert_bggr16le_to_rgba(const char *in, int width, int height, char *buff) {
|
||||||
|
if (unlikely(in == buff)) return;
|
||||||
|
#define RG16_BPP 2
|
||||||
|
#define RG16_GET_NBR_PIX(_x,_y) ( __builtin_bswap16(htons(*(uint16_t*)(in + RG16_BPP*(_rg16_clamp_flip((_x),width) + _rg16_clamp_flip((_y),height) * width)))) )
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
int i = x + y * width;
|
||||||
|
uint16_t v = __builtin_bswap16(htons(*(uint16_t*)(in + i * RG16_BPP)));
|
||||||
|
if ((x % 2) ^ (y % 2)) {
|
||||||
|
// g1,g2
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 1) = 0xff & (v >> 8);
|
||||||
|
uint32_t rb2 = RG16_GET_NBR_PIX(x-1, y) + RG16_GET_NBR_PIX(x+1, y);
|
||||||
|
uint32_t br2 = RG16_GET_NBR_PIX(x, y-1) + RG16_GET_NBR_PIX(x, y+1);
|
||||||
|
if (x % 2) {
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 0) = 0xff & (rb2 >> 9);
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 2) = 0xff & (br2 >> 9);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 2) = 0xff & (rb2 >> 9);
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 0) = 0xff & (br2 >> 9);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// r,b
|
||||||
|
uint32_t g4 = RG16_GET_NBR_PIX(x-1, y) + RG16_GET_NBR_PIX(x+1, y) + RG16_GET_NBR_PIX(x, y-1) + RG16_GET_NBR_PIX(x, y+1);
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 1) = 0xff & (g4 >> 10);
|
||||||
|
uint32_t br4 = RG16_GET_NBR_PIX(x-1, y-1) + RG16_GET_NBR_PIX(x-1, y+1) + RG16_GET_NBR_PIX(x+1, y-1) + RG16_GET_NBR_PIX(x+1, y+1);
|
||||||
|
if (x % 2) {
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 0) = 0xff & (v >> 8);
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 2) = 0xff & (br4 >> 10);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 2) = 0xff & (v >> 8);
|
||||||
|
*(uint8_t*)(buff + i * BYTES_PER_PIXEL + 0) = 0xff & (br4 >> 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int check_pixfmt_non_vaapi() {
|
static int check_pixfmt_non_vaapi() {
|
||||||
if (
|
if (kmsvnc->drm->mfb->pixel_format == KMSVNC_FOURCC_TO_INT('R', 'G', '1', '6'))
|
||||||
|
{
|
||||||
|
kmsvnc->drm->funcs->convert = convert_bggr16le_to_rgba;
|
||||||
|
}
|
||||||
|
else if (
|
||||||
kmsvnc->drm->mfb->pixel_format != KMSVNC_FOURCC_TO_INT('X', 'R', '2', '4') &&
|
kmsvnc->drm->mfb->pixel_format != KMSVNC_FOURCC_TO_INT('X', 'R', '2', '4') &&
|
||||||
kmsvnc->drm->mfb->pixel_format != KMSVNC_FOURCC_TO_INT('A', 'R', '2', '4')
|
kmsvnc->drm->mfb->pixel_format != KMSVNC_FOURCC_TO_INT('A', 'R', '2', '4')
|
||||||
)
|
)
|
||||||
|
@ -706,7 +755,8 @@ int drm_vendors() {
|
||||||
}
|
}
|
||||||
else if (strcmp(driver_name, "vmwgfx") == 0 ||
|
else if (strcmp(driver_name, "vmwgfx") == 0 ||
|
||||||
strcmp(driver_name, "vboxvideo") == 0 ||
|
strcmp(driver_name, "vboxvideo") == 0 ||
|
||||||
strcmp(driver_name, "virtio_gpu") == 0
|
strcmp(driver_name, "virtio_gpu") == 0 ||
|
||||||
|
strcmp(driver_name, "vc4") == 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (check_pixfmt_non_vaapi()) return 1;
|
if (check_pixfmt_non_vaapi()) return 1;
|
||||||
|
|
Loading…
Reference in a new issue