nvnflinger/gpu: implement applet capture

This commit is contained in:
Liam
2024-01-26 16:10:21 -05:00
parent 962c82540c
commit 0cb413c3d3
19 changed files with 288 additions and 55 deletions
@@ -34,7 +34,7 @@ GLuint Layer::ConfigureDraw(std::array<GLfloat, 3 * 2>& out_matrix,
std::array<ScreenRectVertex, 4>& out_vertices,
ProgramManager& program_manager,
const Tegra::FramebufferConfig& framebuffer,
const Layout::FramebufferLayout& layout) {
const Layout::FramebufferLayout& layout, bool invert_y) {
FramebufferTextureInfo info = PrepareRenderTarget(framebuffer);
auto crop = Tegra::NormalizeCrop(framebuffer, info.width, info.height);
GLuint texture = info.display_texture;
@@ -83,10 +83,15 @@ GLuint Layer::ConfigureDraw(std::array<GLfloat, 3 * 2>& out_matrix,
const auto w = screen.GetWidth();
const auto h = screen.GetHeight();
out_vertices[0] = ScreenRectVertex(x, y, crop.left, crop.top);
out_vertices[1] = ScreenRectVertex(x + w, y, crop.right, crop.top);
out_vertices[2] = ScreenRectVertex(x, y + h, crop.left, crop.bottom);
out_vertices[3] = ScreenRectVertex(x + w, y + h, crop.right, crop.bottom);
const auto left = crop.left;
const auto right = crop.right;
const auto top = invert_y ? crop.bottom : crop.top;
const auto bottom = invert_y ? crop.top : crop.bottom;
out_vertices[0] = ScreenRectVertex(x, y, left, top);
out_vertices[1] = ScreenRectVertex(x + w, y, right, top);
out_vertices[2] = ScreenRectVertex(x, y + h, left, bottom);
out_vertices[3] = ScreenRectVertex(x + w, y + h, right, bottom);
return texture;
}
@@ -51,7 +51,7 @@ public:
std::array<ScreenRectVertex, 4>& out_vertices,
ProgramManager& program_manager,
const Tegra::FramebufferConfig& framebuffer,
const Layout::FramebufferLayout& layout);
const Layout::FramebufferLayout& layout, bool invert_y);
private:
/// Loads framebuffer from emulated memory into the active OpenGL texture.
@@ -37,7 +37,7 @@ WindowAdaptPass::~WindowAdaptPass() = default;
void WindowAdaptPass::DrawToFramebuffer(ProgramManager& program_manager, std::list<Layer>& layers,
std::span<const Tegra::FramebufferConfig> framebuffers,
const Layout::FramebufferLayout& layout) {
const Layout::FramebufferLayout& layout, bool invert_y) {
GLint old_read_fb;
GLint old_draw_fb;
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &old_read_fb);
@@ -51,7 +51,7 @@ void WindowAdaptPass::DrawToFramebuffer(ProgramManager& program_manager, std::li
auto layer_it = layers.begin();
for (size_t i = 0; i < layer_count; i++) {
textures[i] = layer_it->ConfigureDraw(matrices[i], vertices[i], program_manager,
framebuffers[i], layout);
framebuffers[i], layout, invert_y);
layer_it++;
}
@@ -31,7 +31,7 @@ public:
void DrawToFramebuffer(ProgramManager& program_manager, std::list<Layer>& layers,
std::span<const Tegra::FramebufferConfig> framebuffers,
const Layout::FramebufferLayout& layout);
const Layout::FramebufferLayout& layout, bool invert_y);
private:
const Device& device;