noobs 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COPYING +339 -0
- package/README.md +46 -0
- package/bin/64bit/obs.lib +0 -0
- package/binding.gyp +23 -0
- package/dist/bin/Qt6Core.dll +0 -0
- package/dist/bin/Qt6Gui.dll +0 -0
- package/dist/bin/Qt6Network.dll +0 -0
- package/dist/bin/Qt6Svg.dll +0 -0
- package/dist/bin/Qt6Widgets.dll +0 -0
- package/dist/bin/Qt6Xml.dll +0 -0
- package/dist/bin/avcodec-61.dll +0 -0
- package/dist/bin/avdevice-61.dll +0 -0
- package/dist/bin/avfilter-10.dll +0 -0
- package/dist/bin/avformat-61.dll +0 -0
- package/dist/bin/avutil-59.dll +0 -0
- package/dist/bin/datachannel.dll +0 -0
- package/dist/bin/libcurl.dll +0 -0
- package/dist/bin/libobs-d3d11.dll +0 -0
- package/dist/bin/libobs-opengl.dll +0 -0
- package/dist/bin/libobs-winrt.dll +0 -0
- package/dist/bin/librist.dll +0 -0
- package/dist/bin/libx264-164.dll +0 -0
- package/dist/bin/lua51.dll +0 -0
- package/dist/bin/obs-amf-test.exe +0 -0
- package/dist/bin/obs-ffmpeg-mux.exe +0 -0
- package/dist/bin/obs-frontend-api.dll +0 -0
- package/dist/bin/obs-scripting.dll +0 -0
- package/dist/bin/obs.dll +0 -0
- package/dist/bin/srt.dll +0 -0
- package/dist/bin/swresample-5.dll +0 -0
- package/dist/bin/swscale-8.dll +0 -0
- package/dist/bin/w32-pthreads.dll +0 -0
- package/dist/bin/zlib.dll +0 -0
- package/dist/effects/area.effect +250 -0
- package/dist/effects/bicubic_scale.effect +236 -0
- package/dist/effects/bilinear_lowres_scale.effect +123 -0
- package/dist/effects/color.effect +172 -0
- package/dist/effects/default.effect +254 -0
- package/dist/effects/default_rect.effect +84 -0
- package/dist/effects/deinterlace_base.effect +325 -0
- package/dist/effects/deinterlace_blend.effect +21 -0
- package/dist/effects/deinterlace_blend_2x.effect +21 -0
- package/dist/effects/deinterlace_discard.effect +21 -0
- package/dist/effects/deinterlace_discard_2x.effect +21 -0
- package/dist/effects/deinterlace_linear.effect +21 -0
- package/dist/effects/deinterlace_linear_2x.effect +21 -0
- package/dist/effects/deinterlace_yadif.effect +21 -0
- package/dist/effects/deinterlace_yadif_2x.effect +21 -0
- package/dist/effects/format_conversion.effect +1823 -0
- package/dist/effects/lanczos_scale.effect +292 -0
- package/dist/effects/opaque.effect +159 -0
- package/dist/effects/premultiplied_alpha.effect +38 -0
- package/dist/effects/repeat.effect +36 -0
- package/dist/effects/solid.effect +80 -0
- package/dist/noobs.node +0 -0
- package/dist/plugins/obs-ffmpeg.dll +0 -0
- package/dist/plugins/obs-x264.dll +0 -0
- package/dist/plugins/win-capture.dll +0 -0
- package/include/audio-monitoring/osx/mac-helpers.h +13 -0
- package/include/audio-monitoring/pulse/pulseaudio-wrapper.h +212 -0
- package/include/audio-monitoring/win32/wasapi-output.h +22 -0
- package/include/callback/calldata.h +195 -0
- package/include/callback/decl.h +61 -0
- package/include/callback/proc.h +52 -0
- package/include/callback/signal.h +73 -0
- package/include/graphics/axisang.h +65 -0
- package/include/graphics/bounds.h +108 -0
- package/include/graphics/device-exports.h +177 -0
- package/include/graphics/effect-parser.h +290 -0
- package/include/graphics/effect.h +190 -0
- package/include/graphics/graphics-internal.h +335 -0
- package/include/graphics/graphics.h +1024 -0
- package/include/graphics/half.h +100 -0
- package/include/graphics/image-file.h +124 -0
- package/include/graphics/input.h +34 -0
- package/include/graphics/libnsgif/libnsgif.h +142 -0
- package/include/graphics/math-defs.h +45 -0
- package/include/graphics/math-extra.h +61 -0
- package/include/graphics/matrix3.h +98 -0
- package/include/graphics/matrix4.h +102 -0
- package/include/graphics/plane.h +85 -0
- package/include/graphics/quat.h +170 -0
- package/include/graphics/shader-parser.h +273 -0
- package/include/graphics/srgb.h +177 -0
- package/include/graphics/vec2.h +148 -0
- package/include/graphics/vec3.h +224 -0
- package/include/graphics/vec4.h +241 -0
- package/include/media-io/audio-io.h +228 -0
- package/include/media-io/audio-math.h +43 -0
- package/include/media-io/audio-resampler.h +44 -0
- package/include/media-io/format-conversion.h +50 -0
- package/include/media-io/frame-rate.h +29 -0
- package/include/media-io/media-io-defs.h +20 -0
- package/include/media-io/media-remux.h +37 -0
- package/include/media-io/video-frame.h +64 -0
- package/include/media-io/video-io.h +338 -0
- package/include/media-io/video-scaler.h +43 -0
- package/include/obs-audio-controls.h +250 -0
- package/include/obs-av1.h +47 -0
- package/include/obs-avc.h +55 -0
- package/include/obs-config.h +52 -0
- package/include/obs-data.h +311 -0
- package/include/obs-defs.h +52 -0
- package/include/obs-encoder.h +361 -0
- package/include/obs-ffmpeg-compat.h +13 -0
- package/include/obs-hevc.h +81 -0
- package/include/obs-hotkey.h +271 -0
- package/include/obs-hotkeys.h +653 -0
- package/include/obs-interaction.h +56 -0
- package/include/obs-internal.h +1459 -0
- package/include/obs-missing-files.h +53 -0
- package/include/obs-module.h +181 -0
- package/include/obs-nal.h +37 -0
- package/include/obs-nix-platform.h +53 -0
- package/include/obs-nix-wayland.h +24 -0
- package/include/obs-nix-x11.h +22 -0
- package/include/obs-nix.h +42 -0
- package/include/obs-output.h +96 -0
- package/include/obs-properties.h +364 -0
- package/include/obs-scene.h +127 -0
- package/include/obs-service.h +115 -0
- package/include/obs-source.h +568 -0
- package/include/obs.h +2608 -0
- package/include/obsconfig.h +13 -0
- package/include/obsversion.h +5 -0
- package/include/util/apple/cfstring-utils.h +16 -0
- package/include/util/array-serializer.h +37 -0
- package/include/util/base.h +97 -0
- package/include/util/bitstream.h +28 -0
- package/include/util/bmem.h +94 -0
- package/include/util/buffered-file-serializer.h +32 -0
- package/include/util/c99defs.h +75 -0
- package/include/util/cf-lexer.h +199 -0
- package/include/util/cf-parser.h +281 -0
- package/include/util/circlebuf.h +319 -0
- package/include/util/config-file.h +103 -0
- package/include/util/crc32.h +29 -0
- package/include/util/curl/curl-helper.h +35 -0
- package/include/util/darray.h +606 -0
- package/include/util/deque.h +319 -0
- package/include/util/dstr.h +320 -0
- package/include/util/file-serializer.h +34 -0
- package/include/util/lexer.h +273 -0
- package/include/util/pipe.h +52 -0
- package/include/util/platform.h +223 -0
- package/include/util/profiler.h +97 -0
- package/include/util/serializer.h +158 -0
- package/include/util/simde/check.h +285 -0
- package/include/util/simde/debug-trap.h +117 -0
- package/include/util/simde/hedley.h +2123 -0
- package/include/util/simde/simde-align.h +481 -0
- package/include/util/simde/simde-arch.h +537 -0
- package/include/util/simde/simde-common.h +918 -0
- package/include/util/simde/simde-constify.h +925 -0
- package/include/util/simde/simde-detect-clang.h +114 -0
- package/include/util/simde/simde-diagnostic.h +447 -0
- package/include/util/simde/simde-features.h +550 -0
- package/include/util/simde/simde-math.h +1858 -0
- package/include/util/simde/x86/mmx.h +2456 -0
- package/include/util/simde/x86/sse.h +4479 -0
- package/include/util/simde/x86/sse2.h +7549 -0
- package/include/util/source-profiler.h +66 -0
- package/include/util/sse-intrin.h +32 -0
- package/include/util/task.h +22 -0
- package/include/util/text-lookup.h +45 -0
- package/include/util/threading-posix.h +77 -0
- package/include/util/threading-windows.h +142 -0
- package/include/util/threading.h +103 -0
- package/include/util/utf8.h +35 -0
- package/include/util/uthash.h +34 -0
- package/include/util/util_uint128.h +108 -0
- package/include/util/util_uint64.h +34 -0
- package/include/util/windows/device-enum.h +14 -0
- package/include/util/windows/obfuscate.h +16 -0
- package/include/util/windows/win-registry.h +37 -0
- package/include/util/windows/win-version.h +57 -0
- package/include/util/windows/window-helpers.h +47 -0
- package/index.d.ts +38 -0
- package/index.js +8 -0
- package/package.json +31 -0
- package/src/main.cpp +321 -0
- package/src/obs_interface.cpp +605 -0
- package/src/obs_interface.h +74 -0
- package/src/utils.cpp +80 -0
- package/src/utils.h +3 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 2 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
******************************************************************************/
|
|
17
|
+
|
|
18
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include "vec3.h"
|
|
21
|
+
#include "vec4.h"
|
|
22
|
+
#include "axisang.h"
|
|
23
|
+
|
|
24
|
+
/* 4x4 Matrix */
|
|
25
|
+
|
|
26
|
+
#ifdef __cplusplus
|
|
27
|
+
extern "C" {
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
struct matrix3;
|
|
31
|
+
|
|
32
|
+
struct matrix4 {
|
|
33
|
+
struct vec4 x, y, z, t;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
static inline void matrix4_copy(struct matrix4 *dst, const struct matrix4 *m)
|
|
37
|
+
{
|
|
38
|
+
dst->x.m = m->x.m;
|
|
39
|
+
dst->y.m = m->y.m;
|
|
40
|
+
dst->z.m = m->z.m;
|
|
41
|
+
dst->t.m = m->t.m;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static inline void matrix4_identity(struct matrix4 *dst)
|
|
45
|
+
{
|
|
46
|
+
vec4_zero(&dst->x);
|
|
47
|
+
vec4_zero(&dst->y);
|
|
48
|
+
vec4_zero(&dst->z);
|
|
49
|
+
vec4_zero(&dst->t);
|
|
50
|
+
dst->x.x = 1.0f;
|
|
51
|
+
dst->y.y = 1.0f;
|
|
52
|
+
dst->z.z = 1.0f;
|
|
53
|
+
dst->t.w = 1.0f;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
EXPORT void matrix4_from_matrix3(struct matrix4 *dst, const struct matrix3 *m);
|
|
57
|
+
EXPORT void matrix4_from_quat(struct matrix4 *dst, const struct quat *q);
|
|
58
|
+
EXPORT void matrix4_from_axisang(struct matrix4 *dst, const struct axisang *aa);
|
|
59
|
+
|
|
60
|
+
EXPORT void matrix4_mul(struct matrix4 *dst, const struct matrix4 *m1, const struct matrix4 *m2);
|
|
61
|
+
|
|
62
|
+
EXPORT float matrix4_determinant(const struct matrix4 *m);
|
|
63
|
+
|
|
64
|
+
EXPORT void matrix4_translate3v(struct matrix4 *dst, const struct matrix4 *m, const struct vec3 *v);
|
|
65
|
+
EXPORT void matrix4_translate4v(struct matrix4 *dst, const struct matrix4 *m, const struct vec4 *v);
|
|
66
|
+
EXPORT void matrix4_rotate(struct matrix4 *dst, const struct matrix4 *m, const struct quat *q);
|
|
67
|
+
EXPORT void matrix4_rotate_aa(struct matrix4 *dst, const struct matrix4 *m, const struct axisang *aa);
|
|
68
|
+
EXPORT void matrix4_scale(struct matrix4 *dst, const struct matrix4 *m, const struct vec3 *v);
|
|
69
|
+
EXPORT bool matrix4_inv(struct matrix4 *dst, const struct matrix4 *m);
|
|
70
|
+
EXPORT void matrix4_transpose(struct matrix4 *dst, const struct matrix4 *m);
|
|
71
|
+
|
|
72
|
+
EXPORT void matrix4_translate3v_i(struct matrix4 *dst, const struct vec3 *v, const struct matrix4 *m);
|
|
73
|
+
EXPORT void matrix4_translate4v_i(struct matrix4 *dst, const struct vec4 *v, const struct matrix4 *m);
|
|
74
|
+
EXPORT void matrix4_rotate_i(struct matrix4 *dst, const struct quat *q, const struct matrix4 *m);
|
|
75
|
+
EXPORT void matrix4_rotate_aa_i(struct matrix4 *dst, const struct axisang *aa, const struct matrix4 *m);
|
|
76
|
+
EXPORT void matrix4_scale_i(struct matrix4 *dst, const struct vec3 *v, const struct matrix4 *m);
|
|
77
|
+
|
|
78
|
+
static inline void matrix4_translate3f(struct matrix4 *dst, const struct matrix4 *m, float x, float y, float z)
|
|
79
|
+
{
|
|
80
|
+
struct vec3 v;
|
|
81
|
+
vec3_set(&v, x, y, z);
|
|
82
|
+
matrix4_translate3v(dst, m, &v);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static inline void matrix4_rotate_aa4f(struct matrix4 *dst, const struct matrix4 *m, float x, float y, float z,
|
|
86
|
+
float rot)
|
|
87
|
+
{
|
|
88
|
+
struct axisang aa;
|
|
89
|
+
axisang_set(&aa, x, y, z, rot);
|
|
90
|
+
matrix4_rotate_aa(dst, m, &aa);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static inline void matrix4_scale3f(struct matrix4 *dst, const struct matrix4 *m, float x, float y, float z)
|
|
94
|
+
{
|
|
95
|
+
struct vec3 v;
|
|
96
|
+
vec3_set(&v, x, y, z);
|
|
97
|
+
matrix4_scale(dst, m, &v);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#ifdef __cplusplus
|
|
101
|
+
}
|
|
102
|
+
#endif
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 2 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
******************************************************************************/
|
|
17
|
+
|
|
18
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include "math-defs.h"
|
|
21
|
+
#include "vec3.h"
|
|
22
|
+
|
|
23
|
+
#ifdef __cplusplus
|
|
24
|
+
extern "C" {
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
struct matrix3;
|
|
28
|
+
struct matrix4;
|
|
29
|
+
|
|
30
|
+
struct plane {
|
|
31
|
+
struct vec3 dir;
|
|
32
|
+
float dist;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
static inline void plane_copy(struct plane *dst, const struct plane *p)
|
|
36
|
+
{
|
|
37
|
+
vec3_copy(&dst->dir, &p->dir);
|
|
38
|
+
dst->dist = p->dist;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static inline void plane_set(struct plane *dst, const struct vec3 *dir, float dist)
|
|
42
|
+
{
|
|
43
|
+
vec3_copy(&dst->dir, dir);
|
|
44
|
+
dst->dist = dist;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static inline void plane_setf(struct plane *dst, float a, float b, float c, float d)
|
|
48
|
+
{
|
|
49
|
+
vec3_set(&dst->dir, a, b, c);
|
|
50
|
+
dst->dist = d;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
EXPORT void plane_from_tri(struct plane *dst, const struct vec3 *v1, const struct vec3 *v2, const struct vec3 *v3);
|
|
54
|
+
|
|
55
|
+
EXPORT void plane_transform(struct plane *dst, const struct plane *p, const struct matrix4 *m);
|
|
56
|
+
EXPORT void plane_transform3x4(struct plane *dst, const struct plane *p, const struct matrix3 *m);
|
|
57
|
+
|
|
58
|
+
EXPORT bool plane_intersection_ray(const struct plane *p, const struct vec3 *orig, const struct vec3 *dir, float *t);
|
|
59
|
+
EXPORT bool plane_intersection_line(const struct plane *p, const struct vec3 *v1, const struct vec3 *v2, float *t);
|
|
60
|
+
|
|
61
|
+
EXPORT bool plane_tri_inside(const struct plane *p, const struct vec3 *v1, const struct vec3 *v2, const struct vec3 *v3,
|
|
62
|
+
float precision);
|
|
63
|
+
|
|
64
|
+
EXPORT bool plane_line_inside(const struct plane *p, const struct vec3 *v1, const struct vec3 *v2, float precision);
|
|
65
|
+
|
|
66
|
+
static inline bool plane_close(const struct plane *p1, const struct plane *p2, float precision)
|
|
67
|
+
{
|
|
68
|
+
return vec3_close(&p1->dir, &p2->dir, precision) && close_float(p1->dist, p2->dist, precision);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static inline bool plane_coplanar(const struct plane *p1, const struct plane *p2, float precision)
|
|
72
|
+
{
|
|
73
|
+
float cos_angle = vec3_dot(&p1->dir, &p2->dir);
|
|
74
|
+
|
|
75
|
+
if (close_float(cos_angle, 1.0f, precision))
|
|
76
|
+
return close_float(p1->dist, p2->dist, precision);
|
|
77
|
+
else if (close_float(cos_angle, -1.0f, precision))
|
|
78
|
+
return close_float(-p1->dist, p2->dist, precision);
|
|
79
|
+
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#ifdef __cplusplus
|
|
84
|
+
}
|
|
85
|
+
#endif
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 2 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
******************************************************************************/
|
|
17
|
+
|
|
18
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include "../util/c99defs.h"
|
|
21
|
+
#include "math-defs.h"
|
|
22
|
+
#include "vec3.h"
|
|
23
|
+
|
|
24
|
+
#include "../util/sse-intrin.h"
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* Quaternion math
|
|
28
|
+
*
|
|
29
|
+
* Generally used to represent rotational data more than anything. Allows
|
|
30
|
+
* for efficient and correct rotational interpolation without suffering from
|
|
31
|
+
* things like gimbal lock.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
#ifdef __cplusplus
|
|
35
|
+
extern "C" {
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
struct matrix3;
|
|
39
|
+
struct matrix4;
|
|
40
|
+
struct axisang;
|
|
41
|
+
|
|
42
|
+
struct quat {
|
|
43
|
+
union {
|
|
44
|
+
struct {
|
|
45
|
+
float x, y, z, w;
|
|
46
|
+
};
|
|
47
|
+
float ptr[4];
|
|
48
|
+
__m128 m;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
static inline void quat_identity(struct quat *q)
|
|
53
|
+
{
|
|
54
|
+
q->m = _mm_setzero_ps();
|
|
55
|
+
q->w = 1.0f;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static inline void quat_set(struct quat *dst, float x, float y, float z, float w)
|
|
59
|
+
{
|
|
60
|
+
dst->m = _mm_set_ps(x, y, z, w);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static inline void quat_copy(struct quat *dst, const struct quat *q)
|
|
64
|
+
{
|
|
65
|
+
dst->m = q->m;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static inline void quat_add(struct quat *dst, const struct quat *q1, const struct quat *q2)
|
|
69
|
+
{
|
|
70
|
+
dst->m = _mm_add_ps(q1->m, q2->m);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static inline void quat_sub(struct quat *dst, const struct quat *q1, const struct quat *q2)
|
|
74
|
+
{
|
|
75
|
+
dst->m = _mm_sub_ps(q1->m, q2->m);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
EXPORT void quat_mul(struct quat *dst, const struct quat *q1, const struct quat *q2);
|
|
79
|
+
|
|
80
|
+
static inline void quat_addf(struct quat *dst, const struct quat *q, float f)
|
|
81
|
+
{
|
|
82
|
+
dst->m = _mm_add_ps(q->m, _mm_set1_ps(f));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static inline void quat_subf(struct quat *dst, const struct quat *q, float f)
|
|
86
|
+
{
|
|
87
|
+
dst->m = _mm_sub_ps(q->m, _mm_set1_ps(f));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static inline void quat_mulf(struct quat *dst, const struct quat *q, float f)
|
|
91
|
+
{
|
|
92
|
+
dst->m = _mm_mul_ps(q->m, _mm_set1_ps(f));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static inline void quat_divf(struct quat *dst, const struct quat *q, float f)
|
|
96
|
+
{
|
|
97
|
+
dst->m = _mm_div_ps(q->m, _mm_set1_ps(f));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static inline float quat_dot(const struct quat *q1, const struct quat *q2)
|
|
101
|
+
{
|
|
102
|
+
struct vec3 add;
|
|
103
|
+
__m128 mul = _mm_mul_ps(q1->m, q2->m);
|
|
104
|
+
add.m = _mm_add_ps(_mm_movehl_ps(mul, mul), mul);
|
|
105
|
+
add.m = _mm_add_ps(_mm_shuffle_ps(add.m, add.m, 0x55), add.m);
|
|
106
|
+
return add.x;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static inline void quat_inv(struct quat *dst, const struct quat *q)
|
|
110
|
+
{
|
|
111
|
+
dst->x = -q->x;
|
|
112
|
+
dst->y = -q->y;
|
|
113
|
+
dst->z = -q->z;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static inline void quat_neg(struct quat *dst, const struct quat *q)
|
|
117
|
+
{
|
|
118
|
+
dst->x = -q->x;
|
|
119
|
+
dst->y = -q->y;
|
|
120
|
+
dst->z = -q->z;
|
|
121
|
+
dst->w = -q->w;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static inline float quat_len(const struct quat *q)
|
|
125
|
+
{
|
|
126
|
+
float dot_val = quat_dot(q, q);
|
|
127
|
+
return (dot_val > 0.0f) ? sqrtf(dot_val) : 0.0f;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static inline float quat_dist(const struct quat *q1, const struct quat *q2)
|
|
131
|
+
{
|
|
132
|
+
struct quat temp;
|
|
133
|
+
float dot_val;
|
|
134
|
+
|
|
135
|
+
quat_sub(&temp, q1, q2);
|
|
136
|
+
dot_val = quat_dot(&temp, &temp);
|
|
137
|
+
return (dot_val > 0.0f) ? sqrtf(dot_val) : 0.0f;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static inline void quat_norm(struct quat *dst, const struct quat *q)
|
|
141
|
+
{
|
|
142
|
+
float dot_val = quat_dot(q, q);
|
|
143
|
+
dst->m = (dot_val > 0.0f) ? _mm_mul_ps(q->m, _mm_set1_ps(1.0f / sqrtf(dot_val))) : _mm_setzero_ps();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static inline bool quat_close(const struct quat *q1, const struct quat *q2, float epsilon)
|
|
147
|
+
{
|
|
148
|
+
struct quat test;
|
|
149
|
+
quat_sub(&test, q1, q2);
|
|
150
|
+
return test.x < epsilon && test.y < epsilon && test.z < epsilon && test.w < epsilon;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
EXPORT void quat_from_axisang(struct quat *dst, const struct axisang *aa);
|
|
154
|
+
EXPORT void quat_from_matrix3(struct quat *dst, const struct matrix3 *m);
|
|
155
|
+
EXPORT void quat_from_matrix4(struct quat *dst, const struct matrix4 *m);
|
|
156
|
+
|
|
157
|
+
EXPORT void quat_get_dir(struct vec3 *dst, const struct quat *q);
|
|
158
|
+
EXPORT void quat_set_look_dir(struct quat *dst, const struct vec3 *dir);
|
|
159
|
+
|
|
160
|
+
EXPORT void quat_log(struct quat *dst, const struct quat *q);
|
|
161
|
+
EXPORT void quat_exp(struct quat *dst, const struct quat *q);
|
|
162
|
+
|
|
163
|
+
EXPORT void quat_interpolate(struct quat *dst, const struct quat *q1, const struct quat *q2, float t);
|
|
164
|
+
EXPORT void quat_get_tangent(struct quat *dst, const struct quat *prev, const struct quat *q, const struct quat *next);
|
|
165
|
+
EXPORT void quat_interpolate_cubic(struct quat *dst, const struct quat *q1, const struct quat *q2,
|
|
166
|
+
const struct quat *m1, const struct quat *m2, float t);
|
|
167
|
+
|
|
168
|
+
#ifdef __cplusplus
|
|
169
|
+
}
|
|
170
|
+
#endif
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the GNU General Public License as published by
|
|
6
|
+
the Free Software Foundation, either version 2 of the License, or
|
|
7
|
+
(at your option) any later version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful,
|
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License
|
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
******************************************************************************/
|
|
17
|
+
|
|
18
|
+
#pragma once
|
|
19
|
+
|
|
20
|
+
#include "../util/cf-parser.h"
|
|
21
|
+
#include "graphics.h"
|
|
22
|
+
|
|
23
|
+
#ifdef __cplusplus
|
|
24
|
+
extern "C" {
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
EXPORT enum gs_shader_param_type get_shader_param_type(const char *type);
|
|
28
|
+
EXPORT enum gs_sample_filter get_sample_filter(const char *filter);
|
|
29
|
+
EXPORT enum gs_address_mode get_address_mode(const char *address_mode);
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* Shader Parser
|
|
33
|
+
*
|
|
34
|
+
* Parses a shader and extracts data such as shader constants, samplers,
|
|
35
|
+
* and vertex input information. Also allows the reformatting of shaders for
|
|
36
|
+
* different libraries. This is usually used only by graphics libraries,
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
enum shader_var_type {
|
|
40
|
+
SHADER_VAR_NONE,
|
|
41
|
+
SHADER_VAR_IN = SHADER_VAR_NONE,
|
|
42
|
+
SHADER_VAR_INOUT,
|
|
43
|
+
SHADER_VAR_OUT,
|
|
44
|
+
SHADER_VAR_UNIFORM,
|
|
45
|
+
SHADER_VAR_CONST
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
struct shader_var {
|
|
49
|
+
char *type;
|
|
50
|
+
char *name;
|
|
51
|
+
char *mapping;
|
|
52
|
+
enum shader_var_type var_type;
|
|
53
|
+
int array_count;
|
|
54
|
+
size_t gl_sampler_id; /* optional: used/parsed by GL */
|
|
55
|
+
|
|
56
|
+
DARRAY(uint8_t) default_val;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
static inline void shader_var_init(struct shader_var *sv)
|
|
60
|
+
{
|
|
61
|
+
memset(sv, 0, sizeof(struct shader_var));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static inline void shader_var_init_param(struct shader_var *sv, char *type, char *name, bool is_uniform, bool is_const)
|
|
65
|
+
{
|
|
66
|
+
if (is_uniform)
|
|
67
|
+
sv->var_type = SHADER_VAR_UNIFORM;
|
|
68
|
+
else if (is_const)
|
|
69
|
+
sv->var_type = SHADER_VAR_CONST;
|
|
70
|
+
else
|
|
71
|
+
sv->var_type = SHADER_VAR_NONE;
|
|
72
|
+
|
|
73
|
+
sv->type = type;
|
|
74
|
+
sv->name = name;
|
|
75
|
+
sv->mapping = NULL;
|
|
76
|
+
sv->array_count = 0;
|
|
77
|
+
sv->gl_sampler_id = (size_t)-1;
|
|
78
|
+
da_init(sv->default_val);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static inline void shader_var_free(struct shader_var *sv)
|
|
82
|
+
{
|
|
83
|
+
bfree(sv->type);
|
|
84
|
+
bfree(sv->name);
|
|
85
|
+
bfree(sv->mapping);
|
|
86
|
+
da_free(sv->default_val);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* ------------------------------------------------------------------------- */
|
|
90
|
+
|
|
91
|
+
struct shader_sampler {
|
|
92
|
+
char *name;
|
|
93
|
+
DARRAY(char *) states;
|
|
94
|
+
DARRAY(char *) values;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
static inline void shader_sampler_init(struct shader_sampler *ss)
|
|
98
|
+
{
|
|
99
|
+
memset(ss, 0, sizeof(struct shader_sampler));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static inline void shader_sampler_free(struct shader_sampler *ss)
|
|
103
|
+
{
|
|
104
|
+
size_t i;
|
|
105
|
+
for (i = 0; i < ss->states.num; i++)
|
|
106
|
+
bfree(ss->states.array[i]);
|
|
107
|
+
for (i = 0; i < ss->values.num; i++)
|
|
108
|
+
bfree(ss->values.array[i]);
|
|
109
|
+
|
|
110
|
+
bfree(ss->name);
|
|
111
|
+
da_free(ss->states);
|
|
112
|
+
da_free(ss->values);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
EXPORT void shader_sampler_convert(struct shader_sampler *ss, struct gs_sampler_info *info);
|
|
116
|
+
|
|
117
|
+
/* ------------------------------------------------------------------------- */
|
|
118
|
+
|
|
119
|
+
struct shader_struct {
|
|
120
|
+
char *name;
|
|
121
|
+
DARRAY(struct shader_var) vars;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
static inline void shader_struct_init(struct shader_struct *ss)
|
|
125
|
+
{
|
|
126
|
+
memset(ss, 0, sizeof(struct shader_struct));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static inline void shader_struct_free(struct shader_struct *ss)
|
|
130
|
+
{
|
|
131
|
+
size_t i;
|
|
132
|
+
|
|
133
|
+
for (i = 0; i < ss->vars.num; i++)
|
|
134
|
+
shader_var_free(ss->vars.array + i);
|
|
135
|
+
|
|
136
|
+
bfree(ss->name);
|
|
137
|
+
da_free(ss->vars);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* ------------------------------------------------------------------------- */
|
|
141
|
+
|
|
142
|
+
struct shader_func {
|
|
143
|
+
char *name;
|
|
144
|
+
char *return_type;
|
|
145
|
+
char *mapping;
|
|
146
|
+
DARRAY(struct shader_var) params;
|
|
147
|
+
|
|
148
|
+
struct cf_token *start, *end;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
static inline void shader_func_init(struct shader_func *sf, char *return_type, char *name)
|
|
152
|
+
{
|
|
153
|
+
da_init(sf->params);
|
|
154
|
+
|
|
155
|
+
sf->return_type = return_type;
|
|
156
|
+
sf->mapping = NULL;
|
|
157
|
+
sf->name = name;
|
|
158
|
+
sf->start = NULL;
|
|
159
|
+
sf->end = NULL;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static inline void shader_func_free(struct shader_func *sf)
|
|
163
|
+
{
|
|
164
|
+
size_t i;
|
|
165
|
+
|
|
166
|
+
for (i = 0; i < sf->params.num; i++)
|
|
167
|
+
shader_var_free(sf->params.array + i);
|
|
168
|
+
|
|
169
|
+
bfree(sf->name);
|
|
170
|
+
bfree(sf->return_type);
|
|
171
|
+
bfree(sf->mapping);
|
|
172
|
+
da_free(sf->params);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* ------------------------------------------------------------------------- */
|
|
176
|
+
|
|
177
|
+
struct shader_parser {
|
|
178
|
+
struct cf_parser cfp;
|
|
179
|
+
|
|
180
|
+
DARRAY(struct shader_var) params;
|
|
181
|
+
DARRAY(struct shader_struct) structs;
|
|
182
|
+
DARRAY(struct shader_sampler) samplers;
|
|
183
|
+
DARRAY(struct shader_func) funcs;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
static inline void shader_parser_init(struct shader_parser *sp)
|
|
187
|
+
{
|
|
188
|
+
cf_parser_init(&sp->cfp);
|
|
189
|
+
|
|
190
|
+
da_init(sp->params);
|
|
191
|
+
da_init(sp->structs);
|
|
192
|
+
da_init(sp->samplers);
|
|
193
|
+
da_init(sp->funcs);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static inline void shader_parser_free(struct shader_parser *sp)
|
|
197
|
+
{
|
|
198
|
+
size_t i;
|
|
199
|
+
|
|
200
|
+
for (i = 0; i < sp->params.num; i++)
|
|
201
|
+
shader_var_free(sp->params.array + i);
|
|
202
|
+
for (i = 0; i < sp->structs.num; i++)
|
|
203
|
+
shader_struct_free(sp->structs.array + i);
|
|
204
|
+
for (i = 0; i < sp->samplers.num; i++)
|
|
205
|
+
shader_sampler_free(sp->samplers.array + i);
|
|
206
|
+
for (i = 0; i < sp->funcs.num; i++)
|
|
207
|
+
shader_func_free(sp->funcs.array + i);
|
|
208
|
+
|
|
209
|
+
cf_parser_free(&sp->cfp);
|
|
210
|
+
da_free(sp->params);
|
|
211
|
+
da_free(sp->structs);
|
|
212
|
+
da_free(sp->samplers);
|
|
213
|
+
da_free(sp->funcs);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
EXPORT bool shader_parse(struct shader_parser *sp, const char *shader, const char *file);
|
|
217
|
+
|
|
218
|
+
static inline char *shader_parser_geterrors(struct shader_parser *sp)
|
|
219
|
+
{
|
|
220
|
+
return error_data_buildstring(&sp->cfp.error_list);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
static inline struct shader_var *shader_parser_getparam(struct shader_parser *sp, const char *param_name)
|
|
224
|
+
{
|
|
225
|
+
size_t i;
|
|
226
|
+
for (i = 0; i < sp->params.num; i++) {
|
|
227
|
+
struct shader_var *param = sp->params.array + i;
|
|
228
|
+
if (strcmp(param->name, param_name) == 0)
|
|
229
|
+
return param;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return NULL;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
static inline struct shader_struct *shader_parser_getstruct(struct shader_parser *sp, const char *struct_name)
|
|
236
|
+
{
|
|
237
|
+
size_t i;
|
|
238
|
+
for (i = 0; i < sp->structs.num; i++) {
|
|
239
|
+
struct shader_struct *st = sp->structs.array + i;
|
|
240
|
+
if (strcmp(st->name, struct_name) == 0)
|
|
241
|
+
return st;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return NULL;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
static inline struct shader_sampler *shader_parser_getsampler(struct shader_parser *sp, const char *sampler_name)
|
|
248
|
+
{
|
|
249
|
+
size_t i;
|
|
250
|
+
for (i = 0; i < sp->samplers.num; i++) {
|
|
251
|
+
struct shader_sampler *sampler = sp->samplers.array + i;
|
|
252
|
+
if (strcmp(sampler->name, sampler_name) == 0)
|
|
253
|
+
return sampler;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return NULL;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
static inline struct shader_func *shader_parser_getfunc(struct shader_parser *sp, const char *func_name)
|
|
260
|
+
{
|
|
261
|
+
size_t i;
|
|
262
|
+
for (i = 0; i < sp->funcs.num; i++) {
|
|
263
|
+
struct shader_func *func = sp->funcs.array + i;
|
|
264
|
+
if (strcmp(func->name, func_name) == 0)
|
|
265
|
+
return func;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return NULL;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
#ifdef __cplusplus
|
|
272
|
+
}
|
|
273
|
+
#endif
|