mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-01-16 16:52:28 +00:00
Compare commits
33 Commits
B6-rc1
...
dmabuf-tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4b4a37b2b | ||
|
|
bbc9204bfe | ||
|
|
894b8b0c22 | ||
|
|
91b0cba145 | ||
|
|
2f48798db9 | ||
|
|
254b370bbf | ||
|
|
86efc47505 | ||
|
|
b559d6b9bc | ||
|
|
48cd0c3789 | ||
|
|
6f8e6f9a19 | ||
|
|
188f25c6bf | ||
|
|
8619f787b9 | ||
|
|
60ac03ebaf | ||
|
|
e1ebde3cd2 | ||
|
|
f519904c38 | ||
|
|
fa6f1abaac | ||
|
|
875242fe15 | ||
|
|
20b5957999 | ||
|
|
f0cb9d1167 | ||
|
|
6cd88a70ad | ||
|
|
697bbcd6d4 | ||
|
|
ecca5720a9 | ||
|
|
50e856f823 | ||
|
|
6359bb9acd | ||
|
|
938011fce6 | ||
|
|
d09a10299e | ||
|
|
8e706636d3 | ||
|
|
352cd2fafe | ||
|
|
081a0a419d | ||
|
|
7e42e6cdce | ||
|
|
d857b2a36e | ||
|
|
ba64a2d400 | ||
|
|
9d8bc46812 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -10,3 +10,6 @@
|
||||
[submodule "repos/wayland-protocols"]
|
||||
path = repos/wayland-protocols
|
||||
url = https://gitlab.freedesktop.org/wayland/wayland-protocols.git
|
||||
[submodule "repos/nanosvg"]
|
||||
path = repos/nanosvg
|
||||
url = https://github.com/memononen/nanosvg.git
|
||||
|
||||
2
AUTHORS
2
AUTHORS
@@ -9,7 +9,7 @@ arcnmx <arcnmx@users.noreply.github.com> (arcnmx)
|
||||
TheCakeIsNaOH <TheCakeIsNaOH@gmail.com> (TheCakeIsNaOH)
|
||||
NamoDev <namodev@users.noreply.github.com> (NamoDev)
|
||||
feltcat <58396817+feltcat@users.noreply.github.com> (feltcat)
|
||||
Ali Abdel-Qader <abdelqaderali@protonmail.com>
|
||||
Ali Abdel-Qader <abdelqaderali@protonmail.com> (thrifty-txt)
|
||||
Jack Karamanian <karamanian.jack@gmail.com>
|
||||
Mikko Rasa <tdb@tdb.fi> (DataBeaver)
|
||||
Omar Pakker <Omar007@users.noreply.github.com> (Omar007)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "common/debug.h"
|
||||
#include "common/stringutils.h"
|
||||
#include "common/util.h"
|
||||
#include "common/option.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -129,6 +130,29 @@ static void pipewire_onPlaybackDrained(void * userdata)
|
||||
pw_thread_loop_unlock(pw.thread);
|
||||
}
|
||||
|
||||
static struct Option pipewire_options[] =
|
||||
{
|
||||
{
|
||||
.module = "pipewire",
|
||||
.name = "outDevice",
|
||||
.description = "The default playback device to use",
|
||||
.type = OPTION_TYPE_STRING
|
||||
},
|
||||
{
|
||||
.module = "pipewire",
|
||||
.name = "recDevice",
|
||||
.description = "The default record device to use",
|
||||
.type = OPTION_TYPE_STRING
|
||||
},
|
||||
|
||||
{0}
|
||||
};
|
||||
|
||||
static void pipewire_earlyInit(void)
|
||||
{
|
||||
option_register(pipewire_options);
|
||||
}
|
||||
|
||||
static bool pipewire_init(void)
|
||||
{
|
||||
pw_init(NULL, NULL);
|
||||
@@ -221,9 +245,8 @@ static void pipewire_playbackSetup(int channels, int sampleRate,
|
||||
pw.playback.pullFn = pullFn;
|
||||
|
||||
pw_thread_loop_lock(pw.thread);
|
||||
pw.playback.stream = pw_stream_new_simple(
|
||||
pw.loop,
|
||||
"Looking Glass",
|
||||
|
||||
struct pw_properties * props =
|
||||
pw_properties_new(
|
||||
PW_KEY_NODE_NAME , "Looking Glass",
|
||||
PW_KEY_MEDIA_TYPE , "Audio",
|
||||
@@ -231,7 +254,22 @@ static void pipewire_playbackSetup(int channels, int sampleRate,
|
||||
PW_KEY_MEDIA_ROLE , "Music",
|
||||
PW_KEY_NODE_LATENCY , requestedNodeLatency,
|
||||
NULL
|
||||
),
|
||||
);
|
||||
|
||||
const char * device = option_get_string("pipewire", "outDevice");
|
||||
if (device)
|
||||
{
|
||||
#ifdef PW_KEY_TARGET_OBJECT
|
||||
pw_properties_set(props, PW_KEY_TARGET_OBJECT, device);
|
||||
#else
|
||||
pw_properties_set(props, PW_KEY_NODE_TARGET, device);
|
||||
#endif
|
||||
}
|
||||
|
||||
pw.playback.stream = pw_stream_new_simple(
|
||||
pw.loop,
|
||||
"Looking Glass",
|
||||
props,
|
||||
&events,
|
||||
NULL
|
||||
);
|
||||
@@ -449,17 +487,30 @@ static void pipewire_recordStart(int channels, int sampleRate,
|
||||
pw.record.stride = sizeof(uint16_t) * channels;
|
||||
pw.record.pushFn = pushFn;
|
||||
|
||||
pw_thread_loop_lock(pw.thread);
|
||||
pw.record.stream = pw_stream_new_simple(
|
||||
pw.loop,
|
||||
"Looking Glass",
|
||||
struct pw_properties * props =
|
||||
pw_properties_new(
|
||||
PW_KEY_NODE_NAME , "Looking Glass",
|
||||
PW_KEY_MEDIA_TYPE , "Audio",
|
||||
PW_KEY_MEDIA_CATEGORY, "Capture",
|
||||
PW_KEY_MEDIA_ROLE , "Music",
|
||||
NULL
|
||||
),
|
||||
);
|
||||
|
||||
const char * device = option_get_string("pipewire", "recDevice");
|
||||
if (device)
|
||||
{
|
||||
#ifdef PW_KEY_TARGET_OBJECT
|
||||
pw_properties_set(props, PW_KEY_TARGET_OBJECT, device);
|
||||
#else
|
||||
pw_properties_set(props, PW_KEY_NODE_TARGET, device);
|
||||
#endif
|
||||
}
|
||||
|
||||
pw_thread_loop_lock(pw.thread);
|
||||
pw.record.stream = pw_stream_new_simple(
|
||||
pw.loop,
|
||||
"Looking Glass",
|
||||
props,
|
||||
&events,
|
||||
NULL
|
||||
);
|
||||
@@ -543,9 +594,10 @@ static void pipewire_free(void)
|
||||
|
||||
struct LG_AudioDevOps LGAD_PipeWire =
|
||||
{
|
||||
.name = "PipeWire",
|
||||
.init = pipewire_init,
|
||||
.free = pipewire_free,
|
||||
.name = "PipeWire",
|
||||
.earlyInit = pipewire_earlyInit,
|
||||
.init = pipewire_init,
|
||||
.free = pipewire_free,
|
||||
.playback =
|
||||
{
|
||||
.setup = pipewire_playbackSetup,
|
||||
|
||||
@@ -65,15 +65,30 @@ static const struct xdg_surface_listener xdgSurfaceListener = {
|
||||
static void xdgToplevelConfigure(void * data, struct xdg_toplevel * xdgToplevel,
|
||||
int32_t width, int32_t height, struct wl_array * states)
|
||||
{
|
||||
wlWm.width = width;
|
||||
wlWm.height = height;
|
||||
wlWm.width = width;
|
||||
wlWm.height = height;
|
||||
wlWm.fullscreen = false;
|
||||
wlWm.floating = true;
|
||||
|
||||
enum xdg_toplevel_state * state;
|
||||
wl_array_for_each(state, states)
|
||||
{
|
||||
if (*state == XDG_TOPLEVEL_STATE_FULLSCREEN)
|
||||
switch (*state)
|
||||
{
|
||||
case XDG_TOPLEVEL_STATE_FULLSCREEN:
|
||||
wlWm.fullscreen = true;
|
||||
// fallthrough
|
||||
case XDG_TOPLEVEL_STATE_MAXIMIZED:
|
||||
case XDG_TOPLEVEL_STATE_TILED_LEFT:
|
||||
case XDG_TOPLEVEL_STATE_TILED_RIGHT:
|
||||
case XDG_TOPLEVEL_STATE_TILED_TOP:
|
||||
case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
|
||||
wlWm.floating = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,5 +171,14 @@ void waylandMinimize(void)
|
||||
|
||||
void waylandShellResize(int w, int h)
|
||||
{
|
||||
//TODO: Implement resize for XDG.
|
||||
if (!wlWm.floating)
|
||||
return;
|
||||
|
||||
wlWm.width = w;
|
||||
wlWm.height = h;
|
||||
xdg_surface_set_window_geometry(wlWm.xdgSurface, 0, 0, w, h);
|
||||
|
||||
wlWm.needsResize = true;
|
||||
app_invalidateWindow(true);
|
||||
waylandStopWaitFrame();
|
||||
}
|
||||
|
||||
@@ -71,12 +71,16 @@ static bool waylandProbe(void)
|
||||
static bool waylandInit(const LG_DSInitParams params)
|
||||
{
|
||||
memset(&wlWm, 0, sizeof(wlWm));
|
||||
|
||||
wlWm.display = wl_display_connect(NULL);
|
||||
if (!wlWm.display)
|
||||
return false;
|
||||
|
||||
wl_list_init(&wlWm.surfaceOutputs);
|
||||
|
||||
wlWm.warpSupport = option_get_bool("wayland", "warpSupport");
|
||||
wlWm.useFractionalScale = option_get_bool("wayland", "fractionScale");
|
||||
|
||||
wlWm.display = wl_display_connect(NULL);
|
||||
wlWm.width = params.w;
|
||||
wlWm.height = params.h;
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@ struct WaylandDSState
|
||||
bool fractionalScale;
|
||||
bool needsResize;
|
||||
bool fullscreen;
|
||||
bool floating;
|
||||
uint32_t resizeSerial;
|
||||
bool configured;
|
||||
bool warpSupport;
|
||||
|
||||
@@ -103,7 +103,7 @@ bool x11CBEventThread(const XEvent xe)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool x11CBInit()
|
||||
bool x11CBInit(void)
|
||||
{
|
||||
x11cb.aCurSelection = BadValue;
|
||||
for(int i = 0; i < LG_CLIPBOARD_DATA_NONE; ++i)
|
||||
|
||||
@@ -242,12 +242,31 @@ out:
|
||||
return;
|
||||
}
|
||||
|
||||
static int x11ErrorHandler(Display * display, XErrorEvent * error)
|
||||
{
|
||||
char errorText[1024];
|
||||
XGetErrorText(display, error->error_code, errorText, sizeof(errorText));
|
||||
|
||||
DEBUG_ERROR("X11 Error: %s", errorText);
|
||||
DEBUG_PRINT_BACKTRACE();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int x11IOErrorHandler(Display * display)
|
||||
{
|
||||
DEBUG_FATAL("Fatal X11 IO Error");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool x11Init(const LG_DSInitParams params)
|
||||
{
|
||||
XIDeviceInfo *devinfo;
|
||||
int count;
|
||||
int event, error;
|
||||
|
||||
XSetErrorHandler(x11ErrorHandler);
|
||||
XSetIOErrorHandler(x11IOErrorHandler);
|
||||
|
||||
memset(&x11, 0, sizeof(x11));
|
||||
x11.xValuator = -1;
|
||||
x11.yValuator = -1;
|
||||
@@ -1152,6 +1171,46 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
app_updateCursorPos(xie->event_x, xie->event_y);
|
||||
app_handleEnterEvent(false);
|
||||
x11.entered = false;
|
||||
|
||||
/**
|
||||
* Because there is a race with the pointer ungrab the enter event for the
|
||||
* next window is sometimes sent with the mode NotifyUngrab, unfortunatly
|
||||
* some window managers such as i3 will ignore these which breaks focus
|
||||
* follows mouse mode. To correct this we generate and send a normal
|
||||
* EnterNotify event.
|
||||
*/
|
||||
int root_x, root_y, win_x, win_y;
|
||||
Window root_win, child_win;
|
||||
unsigned int mask;
|
||||
XQueryPointer(x11.display, DefaultRootWindow(x11.display), &root_win,
|
||||
&child_win, &root_x, &root_y, &win_x, &win_y, &mask);
|
||||
|
||||
int target_x, target_y;
|
||||
Window target_root;
|
||||
XTranslateCoordinates(x11.display, DefaultRootWindow(x11.display),
|
||||
child_win, root_x, root_y, &target_x, &target_y, &target_root);
|
||||
|
||||
XEvent event;
|
||||
memset(&event, 0, sizeof(event));
|
||||
event.type = EnterNotify;
|
||||
event.xcrossing.serial = 0;
|
||||
event.xcrossing.send_event = True;
|
||||
event.xcrossing.display = x11.display;
|
||||
event.xcrossing.window = child_win;
|
||||
event.xcrossing.root = root_win;
|
||||
event.xcrossing.subwindow = child_win;
|
||||
event.xcrossing.time = CurrentTime;
|
||||
event.xcrossing.mode = NotifyNormal;
|
||||
event.xcrossing.detail = NotifyNonlinear;
|
||||
event.xcrossing.same_screen = True;
|
||||
event.xcrossing.focus = False;
|
||||
event.xcrossing.x = target_x;
|
||||
event.xcrossing.y = target_y;
|
||||
event.xcrossing.x_root = root_x;
|
||||
event.xcrossing.y_root = root_y;
|
||||
|
||||
XSendEvent(x11.display, child_win, True, EnterWindowMask, &event);
|
||||
XFlush(x11.display);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ static bool cursorTexInit(struct CursorTex * t,
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(t->shader,
|
||||
vertex_code, vertex_size, fragment_code, fragment_size))
|
||||
vertex_code, vertex_size, fragment_code, fragment_size, false))
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the cursor shader");
|
||||
return false;
|
||||
|
||||
@@ -76,7 +76,8 @@ bool egl_damageInit(EGL_Damage ** damage)
|
||||
|
||||
if (!egl_shaderCompile((*damage)->shader,
|
||||
b_shader_damage_vert, b_shader_damage_vert_size,
|
||||
b_shader_damage_frag, b_shader_damage_frag_size))
|
||||
b_shader_damage_frag, b_shader_damage_frag_size,
|
||||
false))
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the damage shader");
|
||||
return false;
|
||||
|
||||
@@ -46,6 +46,7 @@ struct DesktopShader
|
||||
EGL_Shader * shader;
|
||||
GLint uTransform;
|
||||
GLint uDesktopSize;
|
||||
GLint uSamplerType;
|
||||
GLint uScaleAlgo;
|
||||
GLint uNVGain;
|
||||
GLint uCBMode;
|
||||
@@ -57,7 +58,7 @@ struct EGL_Desktop
|
||||
EGLDisplay * display;
|
||||
|
||||
EGL_Texture * texture;
|
||||
struct DesktopShader shader;
|
||||
struct DesktopShader dmaShader, shader;
|
||||
EGL_DesktopRects * mesh;
|
||||
CountedBuffer * matrix;
|
||||
|
||||
@@ -92,7 +93,8 @@ void toggleNV(int key, void * opaque);
|
||||
static bool egl_initDesktopShader(
|
||||
struct DesktopShader * shader,
|
||||
const char * vertex_code , size_t vertex_size,
|
||||
const char * fragment_code, size_t fragment_size
|
||||
const char * fragment_code, size_t fragment_size,
|
||||
bool useDMA
|
||||
)
|
||||
{
|
||||
if (!egl_shaderInit(&shader->shader))
|
||||
@@ -100,7 +102,8 @@ static bool egl_initDesktopShader(
|
||||
|
||||
if (!egl_shaderCompile(shader->shader,
|
||||
vertex_code , vertex_size,
|
||||
fragment_code, fragment_size))
|
||||
fragment_code, fragment_size,
|
||||
useDMA))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -135,15 +138,6 @@ bool egl_desktopInit(EGL * egl, EGL_Desktop ** desktop_, EGLDisplay * display,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!egl_initDesktopShader(
|
||||
&desktop->shader,
|
||||
b_shader_desktop_vert , b_shader_desktop_vert_size,
|
||||
b_shader_desktop_rgb_frag, b_shader_desktop_rgb_frag_size))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the generic desktop shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!egl_desktopRectsInit(&desktop->mesh, maxRects))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the desktop mesh");
|
||||
@@ -157,6 +151,27 @@ bool egl_desktopInit(EGL * egl, EGL_Desktop ** desktop_, EGLDisplay * display,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!egl_initDesktopShader(
|
||||
&desktop->shader,
|
||||
b_shader_desktop_vert , b_shader_desktop_vert_size,
|
||||
b_shader_desktop_rgb_frag, b_shader_desktop_rgb_frag_size,
|
||||
false))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the desktop shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (useDMA)
|
||||
if (!egl_initDesktopShader(
|
||||
&desktop->dmaShader,
|
||||
b_shader_desktop_vert , b_shader_desktop_vert_size,
|
||||
b_shader_desktop_rgb_frag, b_shader_desktop_rgb_frag_size,
|
||||
true))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the desktop DMA shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
app_registerKeybind(0, 'N', toggleNV, desktop,
|
||||
"Toggle night vision mode");
|
||||
|
||||
@@ -205,11 +220,12 @@ void egl_desktopFree(EGL_Desktop ** desktop)
|
||||
if (!*desktop)
|
||||
return;
|
||||
|
||||
egl_textureFree (&(*desktop)->texture );
|
||||
egl_textureFree (&(*desktop)->spiceTexture );
|
||||
egl_shaderFree (&(*desktop)->shader.shader);
|
||||
egl_desktopRectsFree(&(*desktop)->mesh );
|
||||
countedBufferRelease(&(*desktop)->matrix );
|
||||
egl_textureFree (&(*desktop)->texture );
|
||||
egl_textureFree (&(*desktop)->spiceTexture );
|
||||
egl_shaderFree (&(*desktop)->shader .shader);
|
||||
egl_shaderFree (&(*desktop)->dmaShader.shader);
|
||||
egl_desktopRectsFree(&(*desktop)->mesh );
|
||||
countedBufferRelease(&(*desktop)->matrix );
|
||||
|
||||
egl_postProcessFree(&(*desktop)->pp);
|
||||
|
||||
@@ -399,18 +415,17 @@ bool egl_desktopRender(EGL_Desktop * desktop, unsigned int outputWidth,
|
||||
if (atomic_exchange(&desktop->processFrame, false) ||
|
||||
egl_postProcessConfigModified(desktop->pp))
|
||||
egl_postProcessRun(desktop->pp, tex, desktop->mesh,
|
||||
width, height, outputWidth, outputHeight);
|
||||
width, height, outputWidth, outputHeight, desktop->useDMA);
|
||||
|
||||
unsigned int finalSizeX, finalSizeY;
|
||||
GLuint texture = egl_postProcessGetOutput(desktop->pp,
|
||||
EGL_Texture * texture = egl_postProcessGetOutput(desktop->pp,
|
||||
&finalSizeX, &finalSizeY);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
egl_resetViewport(desktop->egl);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glBindSampler(0, tex->sampler);
|
||||
egl_textureBind(texture);
|
||||
|
||||
if (finalSizeX > width || finalSizeY > height)
|
||||
scaleType = EGL_DESKTOP_DOWNSCALE;
|
||||
@@ -435,7 +450,10 @@ bool egl_desktopRender(EGL_Desktop * desktop, unsigned int outputWidth,
|
||||
scaleAlgo = desktop->scaleAlgo;
|
||||
}
|
||||
|
||||
const struct DesktopShader * shader = &desktop->shader;
|
||||
const struct DesktopShader * shader =
|
||||
desktop->useDMA && texture == desktop->texture ?
|
||||
&desktop->dmaShader : &desktop->shader;
|
||||
|
||||
EGL_Uniform uniforms[] =
|
||||
{
|
||||
{
|
||||
|
||||
@@ -68,9 +68,11 @@ typedef struct EGL_FilterOps
|
||||
/* reads filter state from options */
|
||||
void (*loadState)(EGL_Filter * filter);
|
||||
|
||||
/* set the input format of the filter */
|
||||
/* set the input format of the filter
|
||||
* useDMA will be true if the texture provided needs to use samplerExternalOES
|
||||
*/
|
||||
bool (*setup)(EGL_Filter * filter, enum EGL_PixelFormat pixFmt,
|
||||
unsigned int width, unsigned int height);
|
||||
unsigned int width, unsigned int height, bool useDMA);
|
||||
|
||||
/* set the output resolution hint for the filter
|
||||
* this is optional and only a hint */
|
||||
@@ -87,8 +89,8 @@ typedef struct EGL_FilterOps
|
||||
|
||||
/* runs the filter on the provided texture
|
||||
* returns the processed texture as the output */
|
||||
GLuint (*run)(EGL_Filter * filter, EGL_FilterRects * rects,
|
||||
GLuint texture);
|
||||
EGL_Texture * (*run)(EGL_Filter * filter, EGL_FilterRects * rects,
|
||||
EGL_Texture * texture);
|
||||
|
||||
/* called when the filter output is no loger needed so it can release memory
|
||||
* this is optional */
|
||||
@@ -133,9 +135,10 @@ static inline void egl_filterLoadState(EGL_Filter * filter)
|
||||
}
|
||||
|
||||
static inline bool egl_filterSetup(EGL_Filter * filter,
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height)
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height,
|
||||
bool useDMA)
|
||||
{
|
||||
return filter->ops.setup(filter, pixFmt, width, height);
|
||||
return filter->ops.setup(filter, pixFmt, width, height, useDMA);
|
||||
}
|
||||
|
||||
static inline void egl_filterSetOutputResHint(EGL_Filter * filter,
|
||||
@@ -156,8 +159,8 @@ static inline bool egl_filterPrepare(EGL_Filter * filter)
|
||||
return filter->ops.prepare(filter);
|
||||
}
|
||||
|
||||
static inline GLuint egl_filterRun(EGL_Filter * filter,
|
||||
EGL_FilterRects * rects, GLuint texture)
|
||||
static inline EGL_Texture * egl_filterRun(EGL_Filter * filter,
|
||||
EGL_FilterRects * rects, EGL_Texture * texture)
|
||||
{
|
||||
return filter->ops.run(filter, rects, texture);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ typedef struct EGL_FilterDownscale
|
||||
EGL_Shader * lanczos2;
|
||||
|
||||
DownscaleFilter filter;
|
||||
int useDMA;
|
||||
enum EGL_PixelFormat pixFmt;
|
||||
unsigned int width, height;
|
||||
float pixelSize;
|
||||
@@ -157,55 +158,26 @@ static bool egl_filterDownscaleInit(EGL_Filter ** filter)
|
||||
return false;
|
||||
}
|
||||
|
||||
this->useDMA = -1;
|
||||
|
||||
if (!egl_shaderInit(&this->nearest))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the shader");
|
||||
goto error_this;
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(this->nearest,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_downscale_frag, b_shader_downscale_frag_size)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
goto error_shader;
|
||||
}
|
||||
|
||||
if (!egl_shaderInit(&this->linear))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the shader");
|
||||
goto error_this;
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(this->linear,
|
||||
b_shader_basic_vert, b_shader_basic_vert_size,
|
||||
b_shader_downscale_linear_frag, b_shader_downscale_linear_frag_size)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
goto error_shader;
|
||||
}
|
||||
|
||||
if (!egl_shaderInit(&this->lanczos2))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the shader");
|
||||
goto error_this;
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(this->lanczos2,
|
||||
b_shader_basic_vert, b_shader_basic_vert_size,
|
||||
b_shader_downscale_lanczos2_frag, b_shader_downscale_lanczos2_frag_size)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
goto error_shader;
|
||||
}
|
||||
|
||||
this->uNearest.type = EGL_UNIFORM_TYPE_3F;
|
||||
this->uNearest.location =
|
||||
egl_shaderGetUniform(this->nearest, "uConfig");
|
||||
|
||||
if (!egl_framebufferInit(&this->fb))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the framebuffer");
|
||||
@@ -326,7 +298,8 @@ static bool egl_filterDownscaleImguiConfig(EGL_Filter * filter)
|
||||
}
|
||||
|
||||
static bool egl_filterDownscaleSetup(EGL_Filter * filter,
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height)
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height,
|
||||
bool useDMA)
|
||||
{
|
||||
EGL_FilterDownscale * this = UPCAST(EGL_FilterDownscale, filter);
|
||||
|
||||
@@ -336,6 +309,48 @@ static bool egl_filterDownscaleSetup(EGL_Filter * filter,
|
||||
if (!this->enable)
|
||||
return false;
|
||||
|
||||
if (this->useDMA != useDMA)
|
||||
{
|
||||
if (!egl_shaderCompile(this->nearest,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_downscale_frag,
|
||||
b_shader_downscale_frag_size,
|
||||
useDMA)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(this->linear,
|
||||
b_shader_basic_vert, b_shader_basic_vert_size,
|
||||
b_shader_downscale_linear_frag,
|
||||
b_shader_downscale_linear_frag_size,
|
||||
useDMA)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(this->lanczos2,
|
||||
b_shader_basic_vert, b_shader_basic_vert_size,
|
||||
b_shader_downscale_lanczos2_frag,
|
||||
b_shader_downscale_lanczos2_frag_size,
|
||||
useDMA)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
this->uNearest.type = EGL_UNIFORM_TYPE_3F;
|
||||
this->uNearest.location =
|
||||
egl_shaderGetUniform(this->nearest, "uConfig");
|
||||
|
||||
this->useDMA = useDMA;
|
||||
}
|
||||
|
||||
if (this->prepared &&
|
||||
pixFmt == this->pixFmt &&
|
||||
this->width == width &&
|
||||
@@ -385,15 +400,15 @@ static bool egl_filterDownscalePrepare(EGL_Filter * filter)
|
||||
return true;
|
||||
}
|
||||
|
||||
static GLuint egl_filterDownscaleRun(EGL_Filter * filter,
|
||||
EGL_FilterRects * rects, GLuint texture)
|
||||
static EGL_Texture * egl_filterDownscaleRun(EGL_Filter * filter,
|
||||
EGL_FilterRects * rects, EGL_Texture * texture)
|
||||
{
|
||||
EGL_FilterDownscale * this = UPCAST(EGL_FilterDownscale, filter);
|
||||
|
||||
egl_framebufferBind(this->fb);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
egl_textureBind(texture);
|
||||
|
||||
EGL_Shader * shader;
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef struct EGL_FilterFFXCAS
|
||||
EGL_Shader * shader;
|
||||
bool enable;
|
||||
|
||||
int useDMA;
|
||||
enum EGL_PixelFormat pixFmt;
|
||||
unsigned int width, height;
|
||||
float sharpness;
|
||||
@@ -106,21 +107,14 @@ static bool egl_filterFFXCASInit(EGL_Filter ** filter)
|
||||
return false;
|
||||
}
|
||||
|
||||
this->useDMA = -1;
|
||||
|
||||
if (!egl_shaderInit(&this->shader))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the shader");
|
||||
goto error_this;
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(this->shader,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_ffx_cas_frag, b_shader_ffx_cas_frag_size)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
goto error_shader;
|
||||
}
|
||||
|
||||
this->consts = countedBufferNew(8 * sizeof(GLuint));
|
||||
if (!this->consts)
|
||||
{
|
||||
@@ -128,12 +122,6 @@ static bool egl_filterFFXCASInit(EGL_Filter ** filter)
|
||||
goto error_shader;
|
||||
}
|
||||
|
||||
egl_shaderSetUniforms(this->shader, &(EGL_Uniform) {
|
||||
.type = EGL_UNIFORM_TYPE_4UIV,
|
||||
.location = egl_shaderGetUniform(this->shader, "uConsts"),
|
||||
.v = this->consts,
|
||||
}, 1);
|
||||
|
||||
egl_filterFFXCASLoadState(&this->base);
|
||||
|
||||
if (!egl_framebufferInit(&this->fb))
|
||||
@@ -220,13 +208,35 @@ static bool egl_filterFFXCASImguiConfig(EGL_Filter * filter)
|
||||
}
|
||||
|
||||
static bool egl_filterFFXCASSetup(EGL_Filter * filter,
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height)
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height,
|
||||
bool useDMA)
|
||||
{
|
||||
EGL_FilterFFXCAS * this = UPCAST(EGL_FilterFFXCAS, filter);
|
||||
|
||||
if (!this->enable)
|
||||
return false;
|
||||
|
||||
if (this->useDMA != useDMA)
|
||||
{
|
||||
if (!egl_shaderCompile(this->shader,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_ffx_cas_frag, b_shader_ffx_cas_frag_size,
|
||||
useDMA)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
egl_shaderSetUniforms(this->shader, &(EGL_Uniform) {
|
||||
.type = EGL_UNIFORM_TYPE_4UIV,
|
||||
.location = egl_shaderGetUniform(this->shader, "uConsts"),
|
||||
.v = this->consts,
|
||||
}, 1);
|
||||
|
||||
this->useDMA = useDMA;
|
||||
}
|
||||
|
||||
if (pixFmt == this->pixFmt && this->width == width && this->height == height)
|
||||
return true;
|
||||
|
||||
@@ -262,15 +272,15 @@ static bool egl_filterFFXCASPrepare(EGL_Filter * filter)
|
||||
return true;
|
||||
}
|
||||
|
||||
static GLuint egl_filterFFXCASRun(EGL_Filter * filter,
|
||||
EGL_FilterRects * rects, GLuint texture)
|
||||
static EGL_Texture * egl_filterFFXCASRun(EGL_Filter * filter,
|
||||
EGL_FilterRects * rects, EGL_Texture * texture)
|
||||
{
|
||||
EGL_FilterFFXCAS * this = UPCAST(EGL_FilterFFXCAS, filter);
|
||||
|
||||
egl_framebufferBind(this->fb);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
egl_textureBind(texture);
|
||||
glBindSampler(0, this->sampler);
|
||||
|
||||
egl_shaderUse(this->shader);
|
||||
|
||||
@@ -42,6 +42,7 @@ typedef struct EGL_FilterFFXFSR1
|
||||
CountedBuffer * consts;
|
||||
EGL_Uniform easuUniform[2], rcasUniform;
|
||||
|
||||
int useDMA;
|
||||
enum EGL_PixelFormat pixFmt;
|
||||
unsigned int width, height;
|
||||
unsigned int inWidth, inHeight;
|
||||
@@ -109,6 +110,8 @@ static bool egl_filterFFXFSR1Init(EGL_Filter ** filter)
|
||||
return false;
|
||||
}
|
||||
|
||||
this->useDMA = -1;
|
||||
|
||||
if (!egl_shaderInit(&this->easu))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the Easu shader");
|
||||
@@ -121,18 +124,10 @@ static bool egl_filterFFXFSR1Init(EGL_Filter ** filter)
|
||||
goto error_esau;
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(this->easu,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_ffx_fsr1_easu_frag, b_shader_ffx_fsr1_easu_frag_size)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the Easu shader");
|
||||
goto error_rcas;
|
||||
}
|
||||
|
||||
if (!egl_shaderCompile(this->rcas,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_ffx_fsr1_rcas_frag, b_shader_ffx_fsr1_rcas_frag_size)
|
||||
b_shader_ffx_fsr1_rcas_frag, b_shader_ffx_fsr1_rcas_frag_size,
|
||||
false)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the Rcas shader");
|
||||
@@ -148,14 +143,6 @@ static bool egl_filterFFXFSR1Init(EGL_Filter ** filter)
|
||||
|
||||
egl_filterFFXFSR1LoadState(&this->base);
|
||||
|
||||
this->easuUniform[0].type = EGL_UNIFORM_TYPE_4UIV;
|
||||
this->easuUniform[0].location =
|
||||
egl_shaderGetUniform(this->easu, "uConsts");
|
||||
this->easuUniform[0].v = this->consts;
|
||||
this->easuUniform[1].type = EGL_UNIFORM_TYPE_2F;
|
||||
this->easuUniform[1].location =
|
||||
egl_shaderGetUniform(this->easu, "uOutRes");
|
||||
|
||||
this->rcasUniform.type = EGL_UNIFORM_TYPE_4UI;
|
||||
this->rcasUniform.location = egl_shaderGetUniform(this->rcas, "uConsts");
|
||||
rcasUpdateUniform(this);
|
||||
@@ -335,13 +322,37 @@ static void egl_filterFFXFSR1SetOutputResHint(EGL_Filter * filter,
|
||||
}
|
||||
|
||||
static bool egl_filterFFXFSR1Setup(EGL_Filter * filter,
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height)
|
||||
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height,
|
||||
bool useDMA)
|
||||
{
|
||||
EGL_FilterFFXFSR1 * this = UPCAST(EGL_FilterFFXFSR1, filter);
|
||||
|
||||
if (!this->enable)
|
||||
return false;
|
||||
|
||||
if (this->useDMA != useDMA)
|
||||
{
|
||||
if (!egl_shaderCompile(this->easu,
|
||||
b_shader_basic_vert , b_shader_basic_vert_size,
|
||||
b_shader_ffx_fsr1_easu_frag, b_shader_ffx_fsr1_easu_frag_size,
|
||||
useDMA)
|
||||
)
|
||||
{
|
||||
DEBUG_ERROR("Failed to compile the Easu shader");
|
||||
return false;
|
||||
}
|
||||
|
||||
this->easuUniform[0].type = EGL_UNIFORM_TYPE_4UIV;
|
||||
this->easuUniform[0].location =
|
||||
egl_shaderGetUniform(this->easu, "uConsts");
|
||||
this->easuUniform[0].v = this->consts;
|
||||
this->easuUniform[1].type = EGL_UNIFORM_TYPE_2F;
|
||||
this->easuUniform[1].location =
|
||||
egl_shaderGetUniform(this->easu, "uOutRes");
|
||||
|
||||
this->useDMA = useDMA;
|
||||
}
|
||||
|
||||
this->active = this->width > width && this->height > height;
|
||||
if (!this->active)
|
||||
return false;
|
||||
@@ -395,15 +406,15 @@ static bool egl_filterFFXFSR1Prepare(EGL_Filter * filter)
|
||||
return true;
|
||||
}
|
||||
|
||||
static GLuint egl_filterFFXFSR1Run(EGL_Filter * filter,
|
||||
EGL_FilterRects * rects, GLuint texture)
|
||||
static EGL_Texture * egl_filterFFXFSR1Run(EGL_Filter * filter,
|
||||
EGL_FilterRects * rects, EGL_Texture * texture)
|
||||
{
|
||||
EGL_FilterFFXFSR1 * this = UPCAST(EGL_FilterFFXFSR1, filter);
|
||||
|
||||
// pass 1, Easu
|
||||
egl_framebufferBind(this->easuFb);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
egl_textureBind(texture);
|
||||
glBindSampler(0, this->sampler);
|
||||
egl_shaderUse(this->easu);
|
||||
egl_filterRectsRender(this->easu, rects);
|
||||
@@ -412,7 +423,7 @@ static GLuint egl_filterFFXFSR1Run(EGL_Filter * filter,
|
||||
// pass 2, Rcas
|
||||
egl_framebufferBind(this->rcasFb);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
egl_textureBind(texture);
|
||||
glBindSampler(0, this->sampler);
|
||||
egl_shaderUse(this->rcas);
|
||||
egl_filterRectsRender(this->rcas, rects);
|
||||
|
||||
@@ -100,9 +100,7 @@ void egl_framebufferBind(EGL_Framebuffer * this)
|
||||
glViewport(0, 0, this->tex->format.width, this->tex->format.height);
|
||||
}
|
||||
|
||||
GLuint egl_framebufferGetTexture(EGL_Framebuffer * this)
|
||||
EGL_Texture * egl_framebufferGetTexture(EGL_Framebuffer * this)
|
||||
{
|
||||
GLuint output;
|
||||
egl_textureGet(this->tex, &output, NULL, NULL);
|
||||
return output;
|
||||
return this->tex;
|
||||
}
|
||||
|
||||
@@ -32,4 +32,4 @@ bool egl_framebufferSetup(EGL_Framebuffer * this, enum EGL_PixelFormat pixFmt,
|
||||
|
||||
void egl_framebufferBind(EGL_Framebuffer * this);
|
||||
|
||||
GLuint egl_framebufferGetTexture(EGL_Framebuffer * this);
|
||||
EGL_Texture * egl_framebufferGetTexture(EGL_Framebuffer * this);
|
||||
|
||||
@@ -10,4 +10,4 @@ function process(line, second) {
|
||||
}
|
||||
}
|
||||
|
||||
{ process($0, $2) }
|
||||
{ process($0, $2) } END { print "\0"; }
|
||||
|
||||
@@ -49,7 +49,7 @@ static const EGL_FilterOps * EGL_Filters[] =
|
||||
struct EGL_PostProcess
|
||||
{
|
||||
Vector filters;
|
||||
GLuint output;
|
||||
EGL_Texture * output;
|
||||
unsigned int outputX, outputY;
|
||||
_Atomic(bool) modified;
|
||||
|
||||
@@ -606,7 +606,7 @@ bool egl_postProcessConfigModified(EGL_PostProcess * this)
|
||||
|
||||
bool egl_postProcessRun(EGL_PostProcess * this, EGL_Texture * tex,
|
||||
EGL_DesktopRects * rects, int desktopWidth, int desktopHeight,
|
||||
unsigned int targetX, unsigned int targetY)
|
||||
unsigned int targetX, unsigned int targetY, bool useDMA)
|
||||
{
|
||||
if (targetX == 0 && targetY == 0)
|
||||
DEBUG_FATAL("targetX || targetY == 0");
|
||||
@@ -614,8 +614,9 @@ bool egl_postProcessRun(EGL_PostProcess * this, EGL_Texture * tex,
|
||||
EGL_Filter * lastFilter = NULL;
|
||||
unsigned int sizeX, sizeY;
|
||||
|
||||
GLuint texture;
|
||||
if (egl_textureGet(tex, &texture, &sizeX, &sizeY) != EGL_TEX_STATUS_OK)
|
||||
//TODO: clean this up
|
||||
GLuint _unused;
|
||||
if (egl_textureGet(tex, &_unused, &sizeX, &sizeY) != EGL_TEX_STATUS_OK)
|
||||
return false;
|
||||
|
||||
if (atomic_exchange(&this->modified, false))
|
||||
@@ -636,11 +637,12 @@ bool egl_postProcessRun(EGL_PostProcess * this, EGL_Texture * tex,
|
||||
};
|
||||
|
||||
EGL_Filter * filter;
|
||||
EGL_Texture * texture = tex;
|
||||
vector_forEach(filter, &this->filters)
|
||||
{
|
||||
egl_filterSetOutputResHint(filter, targetX, targetY);
|
||||
|
||||
if (!egl_filterSetup(filter, tex->format.pixFmt, sizeX, sizeY) ||
|
||||
if (!egl_filterSetup(filter, tex->format.pixFmt, sizeX, sizeY, useDMA) ||
|
||||
!egl_filterPrepare(filter))
|
||||
continue;
|
||||
|
||||
@@ -651,6 +653,9 @@ bool egl_postProcessRun(EGL_PostProcess * this, EGL_Texture * tex,
|
||||
egl_filterRelease(lastFilter);
|
||||
|
||||
lastFilter = filter;
|
||||
|
||||
// the first filter to run will convert to a normal texture
|
||||
useDMA = false;
|
||||
}
|
||||
|
||||
this->output = texture;
|
||||
@@ -659,7 +664,7 @@ bool egl_postProcessRun(EGL_PostProcess * this, EGL_Texture * tex,
|
||||
return true;
|
||||
}
|
||||
|
||||
GLuint egl_postProcessGetOutput(EGL_PostProcess * this,
|
||||
EGL_Texture * egl_postProcessGetOutput(EGL_PostProcess * this,
|
||||
unsigned int * outputX, unsigned int * outputY)
|
||||
{
|
||||
*outputX = this->outputX;
|
||||
|
||||
@@ -41,7 +41,7 @@ bool egl_postProcessConfigModified(EGL_PostProcess * this);
|
||||
* targetX/Y is the final target output dimension hint if scalers are present */
|
||||
bool egl_postProcessRun(EGL_PostProcess * this, EGL_Texture * tex,
|
||||
EGL_DesktopRects * rects, int desktopWidth, int desktopHeight,
|
||||
unsigned int targetX, unsigned int targetY);
|
||||
unsigned int targetX, unsigned int targetY, bool useDMA);
|
||||
|
||||
GLuint egl_postProcessGetOutput(EGL_PostProcess * this,
|
||||
EGL_Texture * egl_postProcessGetOutput(EGL_PostProcess * this,
|
||||
unsigned int * outputX, unsigned int * outputY);
|
||||
|
||||
@@ -64,7 +64,8 @@ void egl_shaderFree(EGL_Shader ** shader)
|
||||
*shader = NULL;
|
||||
}
|
||||
|
||||
bool egl_shaderLoad(EGL_Shader * this, const char * vertex_file, const char * fragment_file)
|
||||
bool egl_shaderLoad(EGL_Shader * this,
|
||||
const char * vertex_file, const char * fragment_file, bool useDMA)
|
||||
{
|
||||
char * vertex_code, * fragment_code;
|
||||
size_t vertex_size, fragment_size;
|
||||
@@ -86,13 +87,16 @@ bool egl_shaderLoad(EGL_Shader * this, const char * vertex_file, const char * fr
|
||||
|
||||
DEBUG_INFO("Loaded fragment shader: %s", fragment_file);
|
||||
|
||||
bool ret = egl_shaderCompile(this, vertex_code, vertex_size, fragment_code, fragment_size);
|
||||
bool ret = egl_shaderCompile(this,
|
||||
vertex_code, vertex_size, fragment_code, fragment_size,
|
||||
useDMA);
|
||||
|
||||
free(vertex_code);
|
||||
free(fragment_code);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool egl_shaderCompile(EGL_Shader * this, const char * vertex_code,
|
||||
static bool shaderCompile(EGL_Shader * this, const char * vertex_code,
|
||||
size_t vertex_size, const char * fragment_code, size_t fragment_size)
|
||||
{
|
||||
if (this->hasShader)
|
||||
@@ -204,6 +208,64 @@ bool egl_shaderCompile(EGL_Shader * this, const char * vertex_code,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool egl_shaderCompile(EGL_Shader * this, const char * vertex_code,
|
||||
size_t vertex_size, const char * fragment_code, size_t fragment_size,
|
||||
bool useDMA)
|
||||
{
|
||||
if (useDMA)
|
||||
{
|
||||
const char * search = "sampler2D";
|
||||
const char * replace = "samplerExternalOES";
|
||||
|
||||
const char * src = fragment_code;
|
||||
int instances = 0;
|
||||
while((src = strstr(src, search)))
|
||||
{
|
||||
++instances;
|
||||
src += strlen(search);
|
||||
}
|
||||
|
||||
const int diff = (strlen(replace) - strlen(search)) * instances;
|
||||
char * newCode = malloc(fragment_size + diff);
|
||||
if (!newCode)
|
||||
{
|
||||
DEBUG_ERROR("Out of memory");
|
||||
return false;
|
||||
}
|
||||
|
||||
src = fragment_code;
|
||||
char * dst = newCode;
|
||||
for(int i = 0; i < instances; ++i)
|
||||
{
|
||||
const char * pos = strstr(src, search);
|
||||
const int offset = pos - src;
|
||||
|
||||
memcpy(dst, src, offset);
|
||||
dst += offset;
|
||||
src = pos + strlen(search);
|
||||
|
||||
memcpy(dst, replace, strlen(replace));
|
||||
dst += strlen(replace);
|
||||
}
|
||||
|
||||
const int final = fragment_size - (src - fragment_code);
|
||||
memcpy(dst, src, final);
|
||||
dst[final] = 0;
|
||||
|
||||
bool result = shaderCompile(
|
||||
this,
|
||||
vertex_code, vertex_size,
|
||||
newCode , fragment_size + diff);
|
||||
|
||||
free(newCode);
|
||||
return result;
|
||||
}
|
||||
|
||||
return shaderCompile(this,
|
||||
vertex_code , vertex_size,
|
||||
fragment_code, fragment_size);
|
||||
}
|
||||
|
||||
void egl_shaderSetUniforms(EGL_Shader * this, EGL_Uniform * uniforms, int count)
|
||||
{
|
||||
egl_shaderFreeUniforms(this);
|
||||
|
||||
@@ -97,10 +97,11 @@ bool egl_shaderInit(EGL_Shader ** shader);
|
||||
void egl_shaderFree(EGL_Shader ** shader);
|
||||
|
||||
bool egl_shaderLoad(EGL_Shader * model, const char * vertex_file,
|
||||
const char * fragment_file);
|
||||
const char * fragment_file, bool useDMA);
|
||||
|
||||
bool egl_shaderCompile(EGL_Shader * model, const char * vertex_code,
|
||||
size_t vertex_size, const char * fragment_code, size_t fragment_size);
|
||||
size_t vertex_size, const char * fragment_code, size_t fragment_size,
|
||||
bool useDMA);
|
||||
|
||||
void egl_shaderSetUniforms(EGL_Shader * shader, EGL_Uniform * uniforms,
|
||||
int count);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
layout(location = 0) in vec2 vertex;
|
||||
out vec2 fragCoord;
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
#if __VERSION__ == 300
|
||||
vec4 textureGather(sampler2D tex, vec2 uv, int comp)
|
||||
{
|
||||
vec4 c0 = textureOffset(tex, uv, ivec2(0,1));
|
||||
vec4 c1 = textureOffset(tex, uv, ivec2(1,1));
|
||||
vec4 c2 = textureOffset(tex, uv, ivec2(1,0));
|
||||
vec4 c3 = textureOffset(tex, uv, ivec2(0,0));
|
||||
vec2 res = vec2(textureSize(tex, 0));
|
||||
ivec2 p = ivec2((uv * res) - 0.5f);
|
||||
|
||||
// NOTE: we can't use texelFecthOffset because sampler2D may actually be samplerExternalOES
|
||||
vec4 c0 = texelFetch(tex, p+ivec2(0,1), 0);
|
||||
vec4 c1 = texelFetch(tex, p+ivec2(1,1), 0);
|
||||
vec4 c2 = texelFetch(tex, p+ivec2(1,0), 0);
|
||||
vec4 c3 = texelFetch(tex, p+ivec2(0,0), 0);
|
||||
|
||||
return vec4(c0[comp], c1[comp], c2[comp],c3[comp]);
|
||||
}
|
||||
#elif __VERSION__ < 300
|
||||
vec4 textureGather(sampler2D tex, vec2 uv, int comp)
|
||||
{
|
||||
vec4 c3 = texture2D(tex, uv);
|
||||
vec4 c3 = texture(tex, uv);
|
||||
return vec4(c3[comp], c3[comp], c3[comp],c3[comp]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
layout(location = 0) in vec3 vertexPosition_modelspace;
|
||||
layout(location = 1) in vec2 vertexUV;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 color;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
#include "color_blind.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
layout(location = 0) in vec2 vertex;
|
||||
out vec2 uv;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
|
||||
precision highp float;
|
||||
|
||||
#define EGL_SCALE_AUTO 0
|
||||
#define EGL_SCALE_NEAREST 1
|
||||
@@ -23,13 +25,17 @@ void main()
|
||||
switch (scaleAlgo)
|
||||
{
|
||||
case EGL_SCALE_NEAREST:
|
||||
{
|
||||
vec2 ts = vec2(textureSize(sampler1, 0));
|
||||
color = texelFetch(sampler1, ivec2(uv * ts), 0);
|
||||
break;
|
||||
}
|
||||
|
||||
case EGL_SCALE_LINEAR:
|
||||
{
|
||||
color = texture(sampler1, uv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cbMode > 0)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
|
||||
precision highp float;
|
||||
|
||||
in vec2 fragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D sampler1;
|
||||
uniform vec3 uConfig;
|
||||
|
||||
void main()
|
||||
@@ -13,7 +15,7 @@ void main()
|
||||
float vOffset = uConfig.y;
|
||||
float hOffset = uConfig.z;
|
||||
|
||||
vec2 inRes = vec2(textureSize(texture, 0));
|
||||
vec2 inRes = vec2(textureSize(sampler1, 0));
|
||||
ivec2 point = ivec2(
|
||||
(floor((fragCoord * inRes) / pixelSize) * pixelSize) +
|
||||
pixelSize / 2.0f
|
||||
@@ -22,5 +24,5 @@ void main()
|
||||
point.x += int(pixelSize * hOffset);
|
||||
point.y += int(pixelSize * vOffset);
|
||||
|
||||
fragColor = texelFetch(texture, point, 0);
|
||||
fragColor = texelFetch(sampler1, point, 0);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
|
||||
precision highp float;
|
||||
|
||||
#define PI 3.141592653589793
|
||||
|
||||
in vec2 fragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D sampler1;
|
||||
float sinc(float x)
|
||||
{
|
||||
return x == 0.0 ? 1.0 : sin(x * PI) / (x * PI);
|
||||
@@ -24,7 +26,7 @@ float lanczos(vec2 v)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 size = vec2(textureSize(texture, 0));
|
||||
vec2 size = vec2(textureSize(sampler1, 0));
|
||||
vec2 pos = fragCoord * size;
|
||||
vec2 invSize = 1.0 / size;
|
||||
vec2 uvc = floor(pos) + vec2(0.5, 0.5);
|
||||
@@ -54,7 +56,7 @@ void main()
|
||||
|
||||
vec3 color = vec3(0.0);
|
||||
for (int i = 0; i < 9; ++i)
|
||||
color += texture2D(texture, uvs[i] * invSize).rgb * factors[i];
|
||||
color += texture(sampler1, uvs[i] * invSize).rgb * factors[i];
|
||||
|
||||
fragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
|
||||
precision highp float;
|
||||
|
||||
in vec2 fragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D sampler1;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragColor = texture2D(texture, fragCoord);
|
||||
fragColor = texture(sampler1, fragCoord);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
|
||||
precision highp float;
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
in vec2 fragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D sampler1;
|
||||
uniform uvec4 uConsts[2];
|
||||
|
||||
#define A_GPU 1
|
||||
@@ -16,7 +18,7 @@ uniform uvec4 uConsts[2];
|
||||
|
||||
vec3 imageLoad(ivec2 point)
|
||||
{
|
||||
return texelFetch(texture, point, 0).rgb;
|
||||
return texelFetch(sampler1, point, 0).rgb;
|
||||
}
|
||||
|
||||
AF3 CasLoad(ASU2 p)
|
||||
@@ -30,7 +32,7 @@ void CasInput(inout AF1 r,inout AF1 g,inout AF1 b) {}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 res = vec2(textureSize(texture, 0));
|
||||
vec2 res = vec2(textureSize(sampler1, 0));
|
||||
uvec2 point = uvec2(fragCoord * res);
|
||||
|
||||
CasFilter(
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
#extension GL_OES_EGL_image_external_essl3 : enable
|
||||
|
||||
precision highp float;
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
in vec2 fragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D sampler1;
|
||||
uniform vec2 uOutRes;
|
||||
uniform uvec4 uConsts[4];
|
||||
|
||||
@@ -18,20 +20,9 @@ uniform uvec4 uConsts[4];
|
||||
|
||||
#define FSR_EASU_F 1
|
||||
|
||||
vec4 _textureGather(sampler2D tex, vec2 uv, int comp)
|
||||
{
|
||||
vec2 res = vec2(textureSize(tex, 0));
|
||||
ivec2 p = ivec2((uv * res) - 0.5f);
|
||||
vec4 c0 = texelFetchOffset(tex, p, 0, ivec2(0,1));
|
||||
vec4 c1 = texelFetchOffset(tex, p, 0, ivec2(1,1));
|
||||
vec4 c2 = texelFetchOffset(tex, p, 0, ivec2(1,0));
|
||||
vec4 c3 = texelFetchOffset(tex, p, 0, ivec2(0,0));
|
||||
return vec4(c0[comp], c1[comp], c2[comp],c3[comp]);
|
||||
}
|
||||
|
||||
AF4 FsrEasuRF(AF2 p){return AF4(_textureGather(texture, p, 0));}
|
||||
AF4 FsrEasuGF(AF2 p){return AF4(_textureGather(texture, p, 1));}
|
||||
AF4 FsrEasuBF(AF2 p){return AF4(_textureGather(texture, p, 2));}
|
||||
AF4 FsrEasuRF(AF2 p){return AF4(textureGather(sampler1, p, 0));}
|
||||
AF4 FsrEasuGF(AF2 p){return AF4(textureGather(sampler1, p, 1));}
|
||||
AF4 FsrEasuBF(AF2 p){return AF4(textureGather(sampler1, p, 2));}
|
||||
|
||||
#include "ffx_fsr1.h"
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#version 300 es
|
||||
precision mediump float;
|
||||
precision highp float;
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
in vec2 fragCoord;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D sampler1;
|
||||
uniform uvec4 uConsts;
|
||||
|
||||
#define A_GPU 1
|
||||
@@ -15,7 +15,7 @@ uniform uvec4 uConsts;
|
||||
|
||||
#include "ffx_a.h"
|
||||
|
||||
AF4 FsrRcasLoadF(ASU2 p) { return texelFetch(texture, ASU2(p), 0); }
|
||||
AF4 FsrRcasLoadF(ASU2 p) { return texelFetch(sampler1, ASU2(p), 0); }
|
||||
void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {}
|
||||
|
||||
#define FSR_RCAS_F 1
|
||||
@@ -24,7 +24,7 @@ void FsrRcasInputF(inout AF1 r, inout AF1 g, inout AF1 b) {}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 inRes = vec2(textureSize(texture, 0));
|
||||
vec2 inRes = vec2(textureSize(sampler1, 0));
|
||||
uvec2 point = uvec2(fragCoord * (inRes + 0.5f));
|
||||
|
||||
FsrRcasF(fragColor.r, fragColor.g, fragColor.b, point, uConsts);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "shader.h"
|
||||
#include "common/framebuffer.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/array.h"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
@@ -76,6 +77,7 @@ bool egl_textureInit(EGL_Texture ** texture_, EGLDisplay * display,
|
||||
glSamplerParameteri(this->sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glSamplerParameteri(this->sampler, GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE);
|
||||
glSamplerParameteri(this->sampler, GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -203,14 +205,7 @@ enum EGL_TexStatus egl_textureProcess(EGL_Texture * this)
|
||||
|
||||
enum EGL_TexStatus egl_textureBind(EGL_Texture * this)
|
||||
{
|
||||
GLuint tex;
|
||||
EGL_TexStatus status;
|
||||
|
||||
if ((status = this->ops.get(this, &tex)) != EGL_TEX_STATUS_OK)
|
||||
return status;
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glBindSampler(0, this->sampler);
|
||||
return EGL_TEX_STATUS_OK;
|
||||
return this->ops.bind(this);
|
||||
}
|
||||
|
||||
@@ -93,6 +93,9 @@ typedef struct EGL_TextureOps
|
||||
|
||||
/* get the texture for use */
|
||||
enum EGL_TexStatus (*get)(EGL_Texture * texture, GLuint * tex);
|
||||
|
||||
/* bind the texture for use */
|
||||
enum EGL_TexStatus (*bind)(EGL_Texture * texture);
|
||||
}
|
||||
EGL_TextureOps;
|
||||
|
||||
|
||||
@@ -292,6 +292,19 @@ EGL_TexStatus egl_texBufferStreamGet(EGL_Texture * texture, GLuint * tex)
|
||||
return EGL_TEX_STATUS_OK;
|
||||
}
|
||||
|
||||
EGL_TexStatus egl_texBufferBind(EGL_Texture * texture)
|
||||
{
|
||||
GLuint tex;
|
||||
EGL_TexStatus status;
|
||||
|
||||
if ((status = texture->ops.get(texture, &tex)) != EGL_TEX_STATUS_OK)
|
||||
return status;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
return EGL_TEX_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
const EGL_TextureOps EGL_TextureBuffer =
|
||||
{
|
||||
.init = egl_texBufferInit,
|
||||
@@ -299,7 +312,8 @@ const EGL_TextureOps EGL_TextureBuffer =
|
||||
.setup = egl_texBufferSetup,
|
||||
.update = egl_texBufferUpdate,
|
||||
.process = egl_texBufferProcess,
|
||||
.get = egl_texBufferGet
|
||||
.get = egl_texBufferGet,
|
||||
.bind = egl_texBufferBind
|
||||
};
|
||||
|
||||
const EGL_TextureOps EGL_TextureBufferStream =
|
||||
@@ -309,5 +323,6 @@ const EGL_TextureOps EGL_TextureBufferStream =
|
||||
.setup = egl_texBufferStreamSetup,
|
||||
.update = egl_texBufferStreamUpdate,
|
||||
.process = egl_texBufferStreamProcess,
|
||||
.get = egl_texBufferStreamGet
|
||||
.get = egl_texBufferStreamGet,
|
||||
.bind = egl_texBufferBind
|
||||
};
|
||||
|
||||
@@ -48,6 +48,7 @@ void egl_texBufferFree(EGL_Texture * texture_);
|
||||
bool egl_texBufferSetup(EGL_Texture * texture_, const EGL_TexSetup * setup);
|
||||
EGL_TexStatus egl_texBufferProcess(EGL_Texture * texture_);
|
||||
EGL_TexStatus egl_texBufferGet(EGL_Texture * texture_, GLuint * tex);
|
||||
EGL_TexStatus egl_texBufferBind(EGL_Texture * texture_);
|
||||
|
||||
bool egl_texBufferStreamInit(EGL_Texture ** texture_, EGL_TexType type,
|
||||
EGLDisplay * display);
|
||||
|
||||
@@ -46,12 +46,26 @@ EGL_TextureOps EGL_TextureDMABUF;
|
||||
|
||||
// internal functions
|
||||
|
||||
static void egl_texDMABUFCleanup(TexDMABUF * this)
|
||||
static void egl_texDMABUFCleanup(EGL_Texture * texture)
|
||||
{
|
||||
TextureBuffer * parent = UPCAST(TextureBuffer, texture);
|
||||
TexDMABUF * this = UPCAST(TexDMABUF , parent);
|
||||
|
||||
struct FdImage * image;
|
||||
vector_forEachRef(image, &this->images)
|
||||
g_egl_dynProcs.eglDestroyImage(this->display, image->image);
|
||||
vector_clear(&this->images);
|
||||
|
||||
egl_texUtilFreeBuffers(parent->buf, parent->texCount);
|
||||
|
||||
if (parent->tex[0])
|
||||
glDeleteTextures(parent->texCount, parent->tex);
|
||||
|
||||
if (parent->sync)
|
||||
{
|
||||
glDeleteSync(parent->sync);
|
||||
parent->sync = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// dmabuf functions
|
||||
@@ -92,7 +106,7 @@ static void egl_texDMABUFFree(EGL_Texture * texture)
|
||||
TextureBuffer * parent = UPCAST(TextureBuffer, texture);
|
||||
TexDMABUF * this = UPCAST(TexDMABUF , parent);
|
||||
|
||||
egl_texDMABUFCleanup(this);
|
||||
egl_texDMABUFCleanup(texture);
|
||||
vector_destroy(&this->images);
|
||||
|
||||
egl_texBufferFree(&parent->base);
|
||||
@@ -102,11 +116,27 @@ static void egl_texDMABUFFree(EGL_Texture * texture)
|
||||
static bool egl_texDMABUFSetup(EGL_Texture * texture, const EGL_TexSetup * setup)
|
||||
{
|
||||
TextureBuffer * parent = UPCAST(TextureBuffer, texture);
|
||||
TexDMABUF * this = UPCAST(TexDMABUF , parent);
|
||||
|
||||
egl_texDMABUFCleanup(this);
|
||||
egl_texDMABUFCleanup(texture);
|
||||
|
||||
return egl_texBufferSetup(&parent->base, setup);
|
||||
glGenTextures(parent->texCount, parent->tex);
|
||||
for(int i = 0; i < parent->texCount; ++i)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_EXTERNAL_OES, parent->tex[i]);
|
||||
glTexImage2D(GL_TEXTURE_EXTERNAL_OES,
|
||||
0,
|
||||
texture->format.intFormat,
|
||||
texture->format.width,
|
||||
texture->format.height,
|
||||
0,
|
||||
texture->format.format,
|
||||
texture->format.dataType,
|
||||
NULL);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
|
||||
parent->rIndex = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool egl_texDMABUFUpdate(EGL_Texture * texture,
|
||||
@@ -173,8 +203,8 @@ static bool egl_texDMABUFUpdate(EGL_Texture * texture,
|
||||
|
||||
INTERLOCKED_SECTION(parent->copyLock,
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, parent->tex[parent->bufIndex]);
|
||||
g_egl_dynProcs.glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
|
||||
glBindTexture(GL_TEXTURE_EXTERNAL_OES, parent->tex[parent->bufIndex]);
|
||||
g_egl_dynProcs.glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, image);
|
||||
|
||||
if (parent->sync)
|
||||
glDeleteSync(parent->sync);
|
||||
@@ -238,6 +268,18 @@ static EGL_TexStatus egl_texDMABUFGet(EGL_Texture * texture, GLuint * tex)
|
||||
return EGL_TEX_STATUS_OK;
|
||||
}
|
||||
|
||||
static EGL_TexStatus egl_texDMABUFBind(EGL_Texture * texture)
|
||||
{
|
||||
GLuint tex;
|
||||
EGL_TexStatus status;
|
||||
|
||||
if ((status = egl_texDMABUFGet(texture, &tex)) != EGL_TEX_STATUS_OK)
|
||||
return status;
|
||||
|
||||
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
|
||||
return EGL_TEX_STATUS_OK;
|
||||
}
|
||||
|
||||
EGL_TextureOps EGL_TextureDMABUF =
|
||||
{
|
||||
.init = egl_texDMABUFInit,
|
||||
@@ -245,5 +287,6 @@ EGL_TextureOps EGL_TextureDMABUF =
|
||||
.setup = egl_texDMABUFSetup,
|
||||
.update = egl_texDMABUFUpdate,
|
||||
.process = egl_texDMABUFProcess,
|
||||
.get = egl_texDMABUFGet
|
||||
.get = egl_texDMABUFGet,
|
||||
.bind = egl_texDMABUFBind
|
||||
};
|
||||
|
||||
@@ -147,5 +147,6 @@ EGL_TextureOps EGL_TextureFrameBuffer =
|
||||
.setup = egl_texFBSetup,
|
||||
.update = egl_texFBUpdate,
|
||||
.process = egl_texBufferStreamProcess,
|
||||
.get = egl_texBufferStreamGet
|
||||
.get = egl_texBufferStreamGet,
|
||||
.bind = egl_texBufferBind
|
||||
};
|
||||
|
||||
@@ -458,7 +458,7 @@ void app_handleMouseRelative(double normx, double normy,
|
||||
// cursor warp support. Instead, we attempt a best-effort emulation which works
|
||||
// with a 1:1 mouse movement patch applied in the guest. For anything fancy, use
|
||||
// capture mode.
|
||||
void app_handleMouseBasic()
|
||||
void app_handleMouseBasic(void)
|
||||
{
|
||||
/* do not pass mouse events to the guest if we do not have focus */
|
||||
if (!g_cursor.guest.valid || !g_state.haveSrcSize || !g_state.focused ||
|
||||
@@ -495,7 +495,7 @@ void app_handleMouseBasic()
|
||||
DEBUG_ERROR("failed to send mouse motion message");
|
||||
}
|
||||
|
||||
void app_resyncMouseBasic()
|
||||
void app_resyncMouseBasic(void)
|
||||
{
|
||||
if (!g_cursor.guest.valid)
|
||||
return;
|
||||
|
||||
@@ -525,12 +525,15 @@ void audio_playbackData(uint8_t * data, size_t size)
|
||||
}
|
||||
|
||||
/* Determine the target latency. This is made up of the maximum audio device
|
||||
* period (plus a little extra to absorb timing jitter) and a configurable
|
||||
* period (or the current actual period, if larger than the expected maximum),
|
||||
* plus a little extra to absorb timing jitter, and a configurable
|
||||
* additional buffer period. The default is set high enough to absorb typical
|
||||
* timing jitter from qemu. */
|
||||
int configLatencyMs = max(g_params.audioBufferLatency, 0);
|
||||
int maxPeriodFrames =
|
||||
max(audio.playback.deviceMaxPeriodFrames, spiceData->devPeriodFrames);
|
||||
double targetLatencyFrames =
|
||||
audio.playback.deviceMaxPeriodFrames * 1.1 +
|
||||
maxPeriodFrames * 1.1 +
|
||||
configLatencyMs * audio.playback.sampleRate / 1000.0;
|
||||
|
||||
/* If the device is currently at a lower period size than its maximum (which
|
||||
|
||||
@@ -170,7 +170,7 @@ void keybind_spiceRegister(void)
|
||||
"Spice keyboard & mouse toggle");
|
||||
|
||||
app_registerKeybind(KEY_INSERT, 0, bind_mouseSens, (void *) true ,
|
||||
"Increase mouse sensitivity 0, in capture mode");
|
||||
"Increase mouse sensitivity in capture mode");
|
||||
app_registerKeybind(KEY_DELETE, 0, bind_mouseSens, (void *) false,
|
||||
"Descrease mouse sensitivity in capture mode");
|
||||
|
||||
|
||||
@@ -1433,7 +1433,8 @@ restart:
|
||||
initialSpiceEnable = 0;
|
||||
}
|
||||
|
||||
status = lgmpClientSessionInit(g_state.lgmp, &udataSize, (uint8_t **)&udata);
|
||||
status = lgmpClientSessionInit(g_state.lgmp, &udataSize, (uint8_t **)&udata,
|
||||
NULL);
|
||||
switch(status)
|
||||
{
|
||||
case LGMP_OK:
|
||||
@@ -1442,21 +1443,19 @@ restart:
|
||||
|
||||
case LGMP_ERR_INVALID_VERSION:
|
||||
{
|
||||
reportBadVersion();
|
||||
msgs[msgsCount++] = app_msgBox(
|
||||
"Incompatible LGMP Version",
|
||||
"The host application is not compatible with this client.\n"
|
||||
"Please download and install the matching version."
|
||||
);
|
||||
if (waitCount++ == 0)
|
||||
{
|
||||
reportBadVersion();
|
||||
msgs[msgsCount++] = app_msgBox(
|
||||
"Incompatible LGMP Version",
|
||||
"The host application is not compatible with this client.\n"
|
||||
"Please download and install the matching version."
|
||||
);
|
||||
|
||||
DEBUG_INFO("Waiting for you to upgrade the host application");
|
||||
while (g_state.state == APP_STATE_RUNNING &&
|
||||
lgmpClientSessionInit(g_state.lgmp, &udataSize, (uint8_t **)&udata) != LGMP_OK)
|
||||
g_state.ds->wait(1000);
|
||||
|
||||
if (g_state.state != APP_STATE_RUNNING)
|
||||
return -1;
|
||||
DEBUG_INFO("Waiting for you to upgrade the host application");
|
||||
}
|
||||
|
||||
g_state.ds->wait(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1815,6 +1814,10 @@ int main(int argc, char * argv[])
|
||||
for(unsigned int i = 0; i < LG_DISPLAYSERVER_COUNT; ++i)
|
||||
LG_DisplayServers[i]->setup();
|
||||
|
||||
for(unsigned int i = 0; i < LG_AUDIODEV_COUNT; ++i)
|
||||
if (LG_AudioDevs[i]->earlyInit)
|
||||
LG_AudioDevs[i]->earlyInit();
|
||||
|
||||
if (!config_load(argc, argv))
|
||||
return -1;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "dynamic/displayservers.h"
|
||||
#include "dynamic/renderers.h"
|
||||
#include "dynamic/audiodev.h"
|
||||
|
||||
#include "common/thread.h"
|
||||
#include "common/types.h"
|
||||
|
||||
@@ -3,7 +3,8 @@ if (EXISTS "${PROJECT_TOP}/.git" AND (
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/LGMP/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/PureSpice/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/cimgui/imgui/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/wayland-protocols/.git")
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/wayland-protocols/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/nanosvg/.git")
|
||||
))
|
||||
message(FATAL_ERROR "Submodules are not initialized. Run\n\tgit submodule update --init --recursive")
|
||||
endif()
|
||||
|
||||
@@ -316,43 +316,55 @@ static bool nvfbc_init(void)
|
||||
}
|
||||
|
||||
int adapterIndex = option_get_int("nvfbc", "adapterIndex");
|
||||
// NOTE: Calling this on hardware that doesn't support NvFBC such as GeForce
|
||||
// causes a substantial performance pentalty even if it fails! As such we only
|
||||
// attempt NvFBC as a last resort, or if configured via the app:capture
|
||||
// option.
|
||||
if (adapterIndex < 0)
|
||||
|
||||
bool created = false;
|
||||
for(int retry = 0; retry < 2; ++retry)
|
||||
{
|
||||
IDirect3D9 * d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
int adapterCount = IDirect3D9_GetAdapterCount(d3d);
|
||||
for(int i = 0; i < adapterCount; ++i)
|
||||
{
|
||||
D3DADAPTER_IDENTIFIER9 ident;
|
||||
IDirect3D9_GetAdapterIdentifier(d3d, i, 0, &ident);
|
||||
if (ident.VendorId != 0x10DE)
|
||||
continue;
|
||||
|
||||
if (NvFBCToSysCreate(i, privData, privDataLen, &this->nvfbc,
|
||||
&this->maxWidth, &this->maxHeight))
|
||||
{
|
||||
adapterIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
IDirect3D9_Release(d3d);
|
||||
|
||||
// NOTE: Calling this on hardware that doesn't support NvFBC such as GeForce
|
||||
// causes a substantial performance pentalty even if it fails! As such we only
|
||||
// attempt NvFBC as a last resort, or if configured via the app:capture
|
||||
// option.
|
||||
if (adapterIndex < 0)
|
||||
{
|
||||
free(privData);
|
||||
return false;
|
||||
IDirect3D9 * d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
int adapterCount = IDirect3D9_GetAdapterCount(d3d);
|
||||
for(int i = 0; i < adapterCount; ++i)
|
||||
{
|
||||
D3DADAPTER_IDENTIFIER9 ident;
|
||||
IDirect3D9_GetAdapterIdentifier(d3d, i, 0, &ident);
|
||||
if (ident.VendorId != 0x10DE)
|
||||
continue;
|
||||
|
||||
if (NvFBCToSysCreate(i, privData, privDataLen, &this->nvfbc,
|
||||
&this->maxWidth, &this->maxHeight))
|
||||
{
|
||||
adapterIndex = i;
|
||||
created = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
IDirect3D9_Release(d3d);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
|
||||
else
|
||||
{
|
||||
free(privData);
|
||||
return false;
|
||||
if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
|
||||
continue;
|
||||
created = true;
|
||||
}
|
||||
|
||||
if (created)
|
||||
break;
|
||||
|
||||
//1000ms delay before retry
|
||||
nsleep(1000000000);
|
||||
}
|
||||
|
||||
if (!created)
|
||||
{
|
||||
free(privData);
|
||||
return false;
|
||||
}
|
||||
|
||||
int diffRes = option_get_int("nvfbc", "diffRes");
|
||||
enum DiffMapBlockSize blockSize;
|
||||
NvFBCGetDiffMapBlockSize(diffRes, &blockSize, &this->diffShift, privData, privDataLen);
|
||||
|
||||
@@ -526,7 +526,13 @@ bool app_init(void)
|
||||
|
||||
// redirect stderr to a file
|
||||
if (logFile && strcmp(logFile, "stderr") != 0)
|
||||
freopen(logFile, "a", stderr);
|
||||
{
|
||||
DEBUG_INFO("Logs will be written to: %s", logFile);
|
||||
DEBUG_INFO("Please see there for any further information");
|
||||
|
||||
if (!freopen(logFile, "a", stderr))
|
||||
DEBUG_WARN("Failed to open log file, will log to stderr");
|
||||
}
|
||||
|
||||
// always flush stderr
|
||||
setbuf(stderr, NULL);
|
||||
|
||||
@@ -719,6 +719,9 @@ int app_main(int argc, char * argv[])
|
||||
if (!installCrashHandler(os_getExecutable()))
|
||||
DEBUG_WARN("Failed to install the crash handler");
|
||||
|
||||
// make sure rng is actually seeded for LGMP
|
||||
srand((unsigned)time(NULL));
|
||||
|
||||
app.state = APP_STATE_RUNNING;
|
||||
ivshmemOptionsInit();
|
||||
|
||||
@@ -745,7 +748,7 @@ int app_main(int argc, char * argv[])
|
||||
if (option_load(configFile))
|
||||
DEBUG_INFO("Configuration file loaded");
|
||||
else
|
||||
DEBUG_INFO("Configuration file not found or invalid");
|
||||
DEBUG_INFO("Configuration file not found or invalid, continuing anyway...");
|
||||
|
||||
// parse the command line arguments
|
||||
if (!option_parse(argc, argv))
|
||||
@@ -855,9 +858,9 @@ int app_main(int argc, char * argv[])
|
||||
{
|
||||
DEBUG_INFO("Performing LGMP reinitialization");
|
||||
lgmpShutdown();
|
||||
app.state = APP_STATE_RUNNING;
|
||||
if (!lgmpSetup(&shmDev))
|
||||
goto fail_lgmp;
|
||||
app.state = APP_STATE_RUNNING;
|
||||
}
|
||||
|
||||
if (app.state == APP_STATE_IDLE)
|
||||
@@ -898,19 +901,20 @@ int app_main(int argc, char * argv[])
|
||||
LG_UNLOCK(app.pointerLock);
|
||||
}
|
||||
|
||||
const uint64_t now = microtime();
|
||||
const uint64_t delta = now - previousFrameTime;
|
||||
const uint64_t delta = microtime() - previousFrameTime;
|
||||
if (delta < throttleUs)
|
||||
{
|
||||
nsleep((throttleUs - delta) * 1000);
|
||||
previousFrameTime = microtime();
|
||||
const uint64_t us = throttleUs - delta;
|
||||
// only delay if the time is reasonable
|
||||
if (us > 1000)
|
||||
nsleep(us * 1000);
|
||||
}
|
||||
else
|
||||
previousFrameTime = now;
|
||||
|
||||
const uint64_t captureStart = microtime();
|
||||
switch(iface->capture())
|
||||
{
|
||||
case CAPTURE_RESULT_OK:
|
||||
previousFrameTime = captureStart;
|
||||
break;
|
||||
|
||||
case CAPTURE_RESULT_TIMEOUT:
|
||||
|
||||
@@ -124,7 +124,8 @@ err:
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
static void unmap_kvmfrbuf(struct dma_buf_attachment * at, struct sg_table * sg, enum dma_data_direction direction)
|
||||
static void unmap_kvmfrbuf(struct dma_buf_attachment * at, struct sg_table * sg,
|
||||
enum dma_data_direction direction)
|
||||
{
|
||||
dma_unmap_sg(at->dev, sg->sgl, sg->nents, direction);
|
||||
sg_free_table(sg);
|
||||
@@ -144,7 +145,8 @@ static int mmap_kvmfrbuf(struct dma_buf * buf, struct vm_area_struct * vma)
|
||||
unsigned long size = vma->vm_end - vma->vm_start;
|
||||
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
|
||||
|
||||
if ((offset + size > (kbuf->pagecount << PAGE_SHIFT)) || (offset + size < offset))
|
||||
if ((offset + size > (kbuf->pagecount << PAGE_SHIFT))
|
||||
|| (offset + size < offset))
|
||||
return -EINVAL;
|
||||
|
||||
if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0)
|
||||
@@ -158,7 +160,8 @@ static int mmap_kvmfrbuf(struct dma_buf * buf, struct vm_area_struct * vma)
|
||||
return 0;
|
||||
|
||||
case KVMFR_TYPE_STATIC:
|
||||
return remap_vmalloc_range(vma, kbuf->kdev->addr + kbuf->offset, vma->vm_pgoff);
|
||||
return remap_vmalloc_range(vma, kbuf->kdev->addr + kbuf->offset,
|
||||
vma->vm_pgoff);
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
@@ -173,7 +176,8 @@ static const struct dma_buf_ops kvmfrbuf_ops =
|
||||
.mmap = mmap_kvmfrbuf
|
||||
};
|
||||
|
||||
static long kvmfr_dmabuf_create(struct kvmfr_dev * kdev, struct file * filp, unsigned long arg)
|
||||
static long kvmfr_dmabuf_create(struct kvmfr_dev * kdev, struct file * filp,
|
||||
unsigned long arg)
|
||||
{
|
||||
struct kvmfr_dmabuf_create create;
|
||||
DEFINE_DMA_BUF_EXPORT_INFO(exp_kdev);
|
||||
@@ -194,7 +198,8 @@ static long kvmfr_dmabuf_create(struct kvmfr_dev * kdev, struct file * filp, uns
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((create.offset + create.size > kdev->size) || (create.offset + create.size < create.offset))
|
||||
if ((create.offset + create.size > kdev->size) ||
|
||||
(create.offset + create.size < create.offset))
|
||||
return -EINVAL;
|
||||
|
||||
kbuf = kzalloc(sizeof(struct kvmfrbuf), GFP_KERNEL);
|
||||
@@ -204,7 +209,8 @@ static long kvmfr_dmabuf_create(struct kvmfr_dev * kdev, struct file * filp, uns
|
||||
kbuf->kdev = kdev;
|
||||
kbuf->pagecount = create.size >> PAGE_SHIFT;
|
||||
kbuf->offset = create.offset;
|
||||
kbuf->pages = kmalloc_array(kbuf->pagecount, sizeof(*kbuf->pages), GFP_KERNEL);
|
||||
kbuf->pages = kmalloc_array(kbuf->pagecount, sizeof(*kbuf->pages),
|
||||
GFP_KERNEL);
|
||||
if (!kbuf->pages)
|
||||
{
|
||||
ret = -ENOMEM;
|
||||
@@ -244,7 +250,8 @@ static long kvmfr_dmabuf_create(struct kvmfr_dev * kdev, struct file * filp, uns
|
||||
goto err;
|
||||
}
|
||||
|
||||
printk("kvmfr_dmabuf_create: offset: %llu, size: %llu\n", create.offset, create.size);
|
||||
printk("kvmfr_dmabuf_create with size %llu offset: %llu",
|
||||
create.size, create.offset);
|
||||
return dma_buf_fd(buf, create.flags & KVMFR_DMABUF_FLAG_CLOEXEC ? O_CLOEXEC : 0);
|
||||
|
||||
err:
|
||||
@@ -253,7 +260,8 @@ err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long device_ioctl(struct file * filp, unsigned int ioctl, unsigned long arg)
|
||||
static long device_ioctl(struct file * filp, unsigned int ioctl,
|
||||
unsigned long arg)
|
||||
{
|
||||
struct kvmfr_dev * kdev;
|
||||
long ret;
|
||||
@@ -359,7 +367,8 @@ static int kvmfr_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
||||
mutex_unlock(&minor_lock);
|
||||
|
||||
kdev->devNo = MKDEV(kvmfr->major, kdev->minor);
|
||||
kdev->pDev = device_create(kvmfr->pClass, NULL, kdev->devNo, NULL, KVMFR_DEV_NAME "%d", kdev->minor);
|
||||
kdev->pDev = device_create(kvmfr->pClass, NULL, kdev->devNo, NULL,
|
||||
KVMFR_DEV_NAME "%d", kdev->minor);
|
||||
if (IS_ERR(kdev->pDev))
|
||||
goto out_unminor;
|
||||
|
||||
@@ -451,7 +460,9 @@ static int create_static_device_unlocked(int size_mb)
|
||||
kdev->addr = vmalloc_user(kdev->size);
|
||||
if (!kdev->addr)
|
||||
{
|
||||
printk(KERN_ERR "kvmfr: failed to allocate memory for static device: %d MiB\n", size_mb);
|
||||
printk(
|
||||
KERN_ERR "kvmfr: failed to allocate memory for static device: %d MiB\n",
|
||||
size_mb);
|
||||
ret = -ENOMEM;
|
||||
goto out_free;
|
||||
}
|
||||
@@ -461,7 +472,8 @@ static int create_static_device_unlocked(int size_mb)
|
||||
goto out_release;
|
||||
|
||||
kdev->devNo = MKDEV(kvmfr->major, kdev->minor);
|
||||
kdev->pDev = device_create(kvmfr->pClass, NULL, kdev->devNo, NULL, KVMFR_DEV_NAME "%d", kdev->minor);
|
||||
kdev->pDev = device_create(kvmfr->pClass, NULL, kdev->devNo, NULL,
|
||||
KVMFR_DEV_NAME "%d", kdev->minor);
|
||||
if (IS_ERR(kdev->pDev))
|
||||
goto out_unminor;
|
||||
|
||||
|
||||
4
obs/lg.c
4
obs/lg.c
@@ -156,7 +156,7 @@ static void deinit(LGPlugin * this)
|
||||
case STATE_STOPPING:
|
||||
case STATE_RESTARTING:
|
||||
this->state = STATE_STOPPING;
|
||||
createThreads(this);
|
||||
waitThreads(this);
|
||||
this->state = STATE_STOPPED;
|
||||
/* fallthrough */
|
||||
|
||||
@@ -421,7 +421,7 @@ static void lgUpdate(void * data, obs_data_t * settings)
|
||||
|
||||
usleep(200000);
|
||||
|
||||
if (lgmpClientSessionInit(this->lgmp, &udataSize, (uint8_t **)&udata)
|
||||
if (lgmpClientSessionInit(this->lgmp, &udataSize, (uint8_t **)&udata, NULL)
|
||||
!= LGMP_OK)
|
||||
return;
|
||||
|
||||
|
||||
Submodule repos/LGMP updated: bb3a212256...1b170ad8d7
1
repos/nanosvg
Submodule
1
repos/nanosvg
Submodule
Submodule repos/nanosvg added at 64d59e4d53
31
repos/nanosvg/.gitignore
vendored
31
repos/nanosvg/.gitignore
vendored
@@ -1,31 +0,0 @@
|
||||
## Compiled source #
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.so
|
||||
test
|
||||
|
||||
## Logs and databases #
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
## OS generated files #
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
## Build dir
|
||||
build/*
|
||||
|
||||
## Stuff in example
|
||||
example/_*
|
||||
|
||||
## xcode specific
|
||||
*xcuserdata*
|
||||
@@ -1,18 +0,0 @@
|
||||
Copyright (c) 2013-14 Mikko Mononen memon@inside.org
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user