mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-02-28 12:40:33 +00:00
Refactor egl::surface_descriptor_t, removed obj_count and plane_indices
This commit is contained in:
parent
9dbf0df67d
commit
10ca72f934
@ -472,11 +472,17 @@ std::optional<rgb_t> import_source(display_t::pointer egl_display, const surface
|
|||||||
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
|
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
|
||||||
attribs[atti++] = xrgb.fourcc;
|
attribs[atti++] = xrgb.fourcc;
|
||||||
|
|
||||||
for(auto x = 0; x < xrgb.obj_count; ++x) {
|
for(auto x = 0; x < 4; ++x) {
|
||||||
auto plane_attr = get_plane(xrgb.plane_indices[x]);
|
auto fd = xrgb.fds[x];
|
||||||
|
|
||||||
|
if(fd < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto plane_attr = get_plane(x);
|
||||||
|
|
||||||
attribs[atti++] = plane_attr.fd;
|
attribs[atti++] = plane_attr.fd;
|
||||||
attribs[atti++] = xrgb.fds[x];
|
attribs[atti++] = fd;
|
||||||
attribs[atti++] = plane_attr.offset;
|
attribs[atti++] = plane_attr.offset;
|
||||||
attribs[atti++] = xrgb.offsets[x];
|
attribs[atti++] = xrgb.offsets[x];
|
||||||
attribs[atti++] = plane_attr.pitch;
|
attribs[atti++] = plane_attr.pitch;
|
||||||
|
@ -218,8 +218,6 @@ KITTY_USING_MOVE_T(ctx_t, (std::tuple<display_t::pointer, EGLContext>), , {
|
|||||||
});
|
});
|
||||||
|
|
||||||
struct surface_descriptor_t {
|
struct surface_descriptor_t {
|
||||||
int obj_count;
|
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int fds[4];
|
int fds[4];
|
||||||
@ -227,7 +225,6 @@ struct surface_descriptor_t {
|
|||||||
std::uint64_t modifier;
|
std::uint64_t modifier;
|
||||||
std::uint32_t pitches[4];
|
std::uint32_t pitches[4];
|
||||||
std::uint32_t offsets[4];
|
std::uint32_t offsets[4];
|
||||||
std::uint32_t plane_indices[4];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
display_t make_display(util::Either<gbm::gbm_t::pointer, wl_display *> native_display);
|
display_t make_display(util::Either<gbm::gbm_t::pointer, wl_display *> native_display);
|
||||||
@ -259,11 +256,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
std::for_each_n(sd.fds, sd.obj_count, [](int fd) {
|
for(auto x = 0; x < 4; ++x) {
|
||||||
close(fd);
|
if(sd.fds[x] >= 0) {
|
||||||
});
|
close(sd.fds[x]);
|
||||||
|
|
||||||
sd.obj_count = 0;
|
sd.fds[x] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
surface_descriptor_t sd;
|
surface_descriptor_t sd;
|
||||||
|
@ -574,37 +574,29 @@ public:
|
|||||||
return capture_e::error;
|
return capture_e::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto obj_count = 4;
|
|
||||||
|
|
||||||
int x = 0;
|
|
||||||
for(int y = 0; y < 4; ++y) {
|
for(int y = 0; y < 4; ++y) {
|
||||||
if(!fb->handles[y]) {
|
if(!fb->handles[y]) {
|
||||||
// It's not clear wheter there could still be valid handles left.
|
// It's not clear wheter there could still be valid handles left.
|
||||||
// So, continue anyway.
|
// So, continue anyway.
|
||||||
// TODO: Is this redundent?
|
// TODO: Is this redundent?
|
||||||
--obj_count;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
file[x] = card.handleFD(fb->handles[x]);
|
file[y] = card.handleFD(fb->handles[y]);
|
||||||
if(file[x].el < 0) {
|
if(file[y].el < 0) {
|
||||||
BOOST_LOG(error) << "Couldn't get primary file descriptor for Framebuffer ["sv << fb->fb_id << "]: "sv << strerror(errno);
|
BOOST_LOG(error) << "Couldn't get primary file descriptor for Framebuffer ["sv << fb->fb_id << "]: "sv << strerror(errno);
|
||||||
return capture_e::error;
|
return capture_e::error;
|
||||||
}
|
}
|
||||||
|
|
||||||
sd->fds[x] = file[x].el;
|
sd->fds[y] = file[y].el;
|
||||||
sd->offsets[x] = fb->offsets[y];
|
sd->offsets[y] = fb->offsets[y];
|
||||||
sd->pitches[x] = fb->pitches[y];
|
sd->pitches[y] = fb->pitches[y];
|
||||||
sd->plane_indices[x] = y;
|
|
||||||
|
|
||||||
++x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sd->width = fb->width;
|
sd->width = fb->width;
|
||||||
sd->height = fb->height;
|
sd->height = fb->height;
|
||||||
sd->modifier = fb->modifier;
|
sd->modifier = fb->modifier;
|
||||||
sd->fourcc = fb->pixel_format;
|
sd->fourcc = fb->pixel_format;
|
||||||
sd->obj_count = obj_count;
|
|
||||||
|
|
||||||
if(
|
if(
|
||||||
fb->width != img_width ||
|
fb->width != img_width ||
|
||||||
@ -775,8 +767,8 @@ public:
|
|||||||
img->data = nullptr;
|
img->data = nullptr;
|
||||||
img->pixel_pitch = 4;
|
img->pixel_pitch = 4;
|
||||||
|
|
||||||
img->sequence = 0;
|
img->sequence = 0;
|
||||||
img->sd.obj_count = 0;
|
std::fill_n(img->sd.fds, 4, -1);
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
@ -836,7 +828,7 @@ public:
|
|||||||
if(!cursor || !cursor_opt) {
|
if(!cursor || !cursor_opt) {
|
||||||
img_out_base->data = nullptr;
|
img_out_base->data = nullptr;
|
||||||
|
|
||||||
for(auto x = 0; x < img->sd.obj_count; ++x) {
|
for(auto x = 0; x < 4; ++x) {
|
||||||
fb_fd[x].release();
|
fb_fd[x].release();
|
||||||
}
|
}
|
||||||
return capture_e::ok;
|
return capture_e::ok;
|
||||||
@ -847,7 +839,7 @@ public:
|
|||||||
img->x -= offset_x;
|
img->x -= offset_x;
|
||||||
img->y -= offset_y;
|
img->y -= offset_y;
|
||||||
|
|
||||||
for(auto x = 0; x < img->sd.obj_count; ++x) {
|
for(auto x = 0; x < 4; ++x) {
|
||||||
fb_fd[x].release();
|
fb_fd[x].release();
|
||||||
}
|
}
|
||||||
return capture_e::ok;
|
return capture_e::ok;
|
||||||
|
@ -350,16 +350,14 @@ public:
|
|||||||
auto nv12_opt = egl::import_target(
|
auto nv12_opt = egl::import_target(
|
||||||
display.get(),
|
display.get(),
|
||||||
std::move(fds),
|
std::move(fds),
|
||||||
{ 1,
|
{ (int)prime.width,
|
||||||
(int)prime.width,
|
|
||||||
(int)prime.height,
|
(int)prime.height,
|
||||||
{ prime.objects[prime.layers[0].object_index[0]].fd, -1, -1, -1 },
|
{ prime.objects[prime.layers[0].object_index[0]].fd, -1, -1, -1 },
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
{ prime.layers[0].pitch[0] },
|
{ prime.layers[0].pitch[0] },
|
||||||
{ prime.layers[0].offset[0] } },
|
{ prime.layers[0].offset[0] } },
|
||||||
{ 1,
|
{ (int)prime.width / 2,
|
||||||
(int)prime.width / 2,
|
|
||||||
(int)prime.height / 2,
|
(int)prime.height / 2,
|
||||||
{ prime.objects[prime.layers[0].object_index[1]].fd, -1, -1, -1 },
|
{ prime.objects[prime.layers[0].object_index[1]].fd, -1, -1, -1 },
|
||||||
0,
|
0,
|
||||||
|
@ -17,6 +17,7 @@ using namespace std::literals;
|
|||||||
// Disable warning for converting incompatible functions
|
// Disable warning for converting incompatible functions
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||||
|
#pragma GCC diagnostic ignored "-Wpmf-conversions"
|
||||||
|
|
||||||
namespace wl {
|
namespace wl {
|
||||||
int display_t::init(const char *display_name) {
|
int display_t::init(const char *display_name) {
|
||||||
@ -164,11 +165,10 @@ void dmabuf_t::frame(
|
|||||||
std::uint32_t obj_count) {
|
std::uint32_t obj_count) {
|
||||||
auto next_frame = get_next_frame();
|
auto next_frame = get_next_frame();
|
||||||
|
|
||||||
next_frame->sd.fourcc = format;
|
next_frame->sd.fourcc = format;
|
||||||
next_frame->sd.width = width;
|
next_frame->sd.width = width;
|
||||||
next_frame->sd.height = height;
|
next_frame->sd.height = height;
|
||||||
next_frame->sd.modifier = (((std::uint64_t)high) << 32) | low;
|
next_frame->sd.modifier = (((std::uint64_t)high) << 32) | low;
|
||||||
next_frame->sd.obj_count = obj_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmabuf_t::object(
|
void dmabuf_t::object(
|
||||||
@ -181,10 +181,9 @@ void dmabuf_t::object(
|
|||||||
std::uint32_t plane_index) {
|
std::uint32_t plane_index) {
|
||||||
auto next_frame = get_next_frame();
|
auto next_frame = get_next_frame();
|
||||||
|
|
||||||
next_frame->sd.fds[index] = fd;
|
next_frame->sd.fds[plane_index] = fd;
|
||||||
next_frame->sd.pitches[index] = stride;
|
next_frame->sd.pitches[plane_index] = stride;
|
||||||
next_frame->sd.offsets[index] = offset;
|
next_frame->sd.offsets[plane_index] = offset;
|
||||||
next_frame->sd.plane_indices[index] = plane_index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dmabuf_t::ready(
|
void dmabuf_t::ready(
|
||||||
@ -212,12 +211,20 @@ void dmabuf_t::cancel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void frame_t::destroy() {
|
void frame_t::destroy() {
|
||||||
for(auto x = 0; x < sd.obj_count; ++x) {
|
for(auto x = 0; x < 4; ++x) {
|
||||||
close(sd.fds[x]);
|
if(sd.fds[x] >= 0) {
|
||||||
|
close(sd.fds[x]);
|
||||||
|
|
||||||
|
sd.fds[x] = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sd.obj_count = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
frame_t::frame_t() {
|
||||||
|
// File descriptors aren't open
|
||||||
|
std::fill_n(sd.fds, 4, -1);
|
||||||
|
};
|
||||||
|
|
||||||
std::vector<std::unique_ptr<monitor_t>> monitors(const char *display_name) {
|
std::vector<std::unique_ptr<monitor_t>> monitors(const char *display_name) {
|
||||||
display_t display;
|
display_t display;
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ using display_internal_t = util::safe_ptr<wl_display, wl_display_disconnect>;
|
|||||||
|
|
||||||
class frame_t {
|
class frame_t {
|
||||||
public:
|
public:
|
||||||
|
frame_t();
|
||||||
egl::surface_descriptor_t sd;
|
egl::surface_descriptor_t sd;
|
||||||
|
|
||||||
void destroy();
|
void destroy();
|
||||||
|
@ -263,7 +263,7 @@ public:
|
|||||||
img->sd = current_frame->sd;
|
img->sd = current_frame->sd;
|
||||||
|
|
||||||
// Prevent dmabuf from closing the file descriptors.
|
// Prevent dmabuf from closing the file descriptors.
|
||||||
current_frame->sd.obj_count = 0;
|
std::fill_n(current_frame->sd.fds, 4, -1);
|
||||||
|
|
||||||
return platf::capture_e::ok;
|
return platf::capture_e::ok;
|
||||||
}
|
}
|
||||||
@ -275,6 +275,9 @@ public:
|
|||||||
img->serial = std::numeric_limits<decltype(img->serial)>::max();
|
img->serial = std::numeric_limits<decltype(img->serial)>::max();
|
||||||
img->data = nullptr;
|
img->data = nullptr;
|
||||||
|
|
||||||
|
// File descriptors aren't open
|
||||||
|
std::fill_n(img->sd.fds, 4, -1);
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user