Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: true
BreakAfterOpenBracketFunction: true
BreakAfterOpenBracketIf: true
BreakAfterOpenBracketBracedList: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignOperands: Align
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: Always
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBraces: Custom
BreakConstructorInitializers: AfterColon
BreakConstructorInitializersBeforeComma: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
IncludeCategories:
- Regex: '^<.*'
Priority: 1
- Regex: '^".*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 4
InsertNewlineAtEOF: true
NamespaceIndentation: All
SpaceAfterTemplateKeyword: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInParens: Custom
SpacesInParensOptions:
ExceptDoubleParentheses: true
InConditionalStatements: true
InCStyleCasts: true
InEmptyParentheses: true
Other: true
SpacesInSquareBrackets: true
TabWidth: 4
...
5 changes: 3 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = false
indent_style = tab
tab_width = 4
trim_trailing_whitespace = true
60 changes: 45 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: |
pacman-key --init
pacman -Syu --noconfirm
pacman -S --noconfirm git meson clang glslang libcap wlroots0.18 \
pacman -S --noconfirm --needed git meson clang glslang libcap wlroots0.18 \
sdl2 vulkan-headers libx11 libxmu libxcomposite libxrender libxres \
libxtst libxkbcommon libdrm libinput wayland-protocols benchmark \
xorg-xwayland pipewire cmake \
Expand All @@ -24,29 +24,59 @@ jobs:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Generate file list for formatting
id: files
run: |
FILES=$(git ls-files src | grep -v -E '(reshade|shaders|\.o$|\.bin$|\.a$|\.so$|\.dylib$)')
echo "formatted_files=$FILES" >> $GITHUB_OUTPUT
- name: Format code with clang-format
run: |
echo "${{ steps.files.outputs.formatted_files }}" | xargs -P $(nproc) -- clang-format -i --
- name: Commit formatted code
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
echo "${{ steps.files.outputs.formatted_files }}" | xargs -r git add --
git commit -m "chore: clang-format [skip ci]" || true
- name: Build with gcc
run: |
export CC=gcc CXX=g++
meson setup build-gcc/ -Dinput_emulation=disabled --werror --auto-features=enabled
ninja -C build-gcc/
meson setup -Dinput_emulation=disabled --werror --auto-features=enabled -- build-gcc
meson compile -C build-gcc
- name: Build with gcc (no vr)
run: |
export CC=gcc CXX=g++
meson setup build-gcc-novr/ -Dinput_emulation=disabled -Denable_openvr_support=false --werror --auto-features=enabled
ninja -C build-gcc-novr/
# - name: Build with clang
# run: |
# export CC=clang CXX=clang++
# meson setup build-clang/ -Dinput_emulation=disabled --werror --auto-features=enabled
# ninja -C build-clang/
- name: Run unit tests and collect coverage
meson setup -Dinput_emulation=disabled -Denable_openvr_support=false --werror --auto-features=enabled -- build-gcc-novr
meson compile -C build-gcc-novr
- name: Build with clang
run: |
export CC=clang CXX=clang++
meson setup -Dinput_emulation=disabled --werror --auto-features=enabled -- build-clang
meson compile -C build-clang
- name: Build with clang (no vr)
run: |
export CC=clang CXX=clang++
meson setup -Dinput_emulation=disabled -Denable_openvr_support=false --werror --auto-features=enabled -- build-clang-novr
meson compile -C build-clang-novr
- name: Run unit tests and collect coverage (gcc)
run: |
export CC=gcc CXX=g++
meson configure -Db_coverage=true build-gcc
meson test -C build-gcc --suite gamescope -v
gcovr -f src --xml -o coverage.xml -s build-gcc
- name: Upload coverage report
gcovr -f src --xml -o coverage-gcc.xml -s build-gcc
- name: Run unit tests and collect coverage (clang)
run: |
export CC=clang CXX=clang++
meson configure -Db_coverage=true build-clang
meson test -C build-clang --suite gamescope -v
gcovr -f src --xml -o coverage-clang.xml -s build-clang/ --gcov-executable="llvm-cov gcov"
- name: Upload coverage report (gcc)
uses: actions/upload-artifact@v7
with:
name: code coverage (gcc)
path: coverage-gcc.xml
- name: Upload coverage report (clang)
uses: actions/upload-artifact@v7
with:
name: code coverage
path: coverage.xml
name: code coverage (clang)
path: coverage-clang.xml
24 changes: 5 additions & 19 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
[submodule "subprojects/wlroots"]
path = subprojects/wlroots
url = https://github.com/Joshua-Ashton/wlroots.git
[submodule "subprojects/libliftoff"]
path = subprojects/libliftoff
url = https://gitlab.freedesktop.org/emersion/libliftoff.git
[submodule "subprojects/vkroots"]
path = subprojects/vkroots
url = https://github.com/Joshua-Ashton/vkroots
[submodule "subprojects/libdisplay-info"]
path = subprojects/libdisplay-info
url = https://gitlab.freedesktop.org/emersion/libdisplay-info
[submodule "subprojects/openvr"]
path = subprojects/openvr
url = https://github.com/ValveSoftware/openvr.git
[submodule "src/reshade"]
path = src/reshade
url = https://github.com/Joshua-Ashton/reshade
path = src/reshade
url = https://github.com/misyltoad/reshade/

[submodule "thirdparty/SPIRV-Headers"]
path = thirdparty/SPIRV-Headers
url = https://github.com/KhronosGroup/SPIRV-Headers/
path = thirdparty/SPIRV-Headers
url = https://github.com/KhronosGroup/SPIRV-Headers/
131 changes: 65 additions & 66 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,112 +1,111 @@
project(
'gamescope',
'c',
'cpp',
meson_version: '>=0.58.0',
default_options: [
'cpp_std=c++20',
'warning_level=2',
'force_fallback_for=wlroots,libliftoff,vkroots',
],
'gamescope',
'c',
'cpp',
license : 'BSD-2-Clause',
meson_version : '>=0.58.0',
default_options : [
'cpp_std=c++20',
'warning_level=2',
'force_fallback_for=wlroots,libliftoff,vkroots',
],
)

fallbacks = get_option('force_fallback_for')
if not (fallbacks.contains('wlroots') and fallbacks.contains('libliftoff') and fallbacks.contains('vkroots'))
error('!!!"force_fallback_for" is missing entries!!!\n\tPlease do not remove entries from force_fallback_for if you are packaging the project.\n\tWe pull in these projects at specific commits/forks/builds for a reason.\n\tIf you are not packaging, remove this line to continue.')
error('!!!"force_fallback_for" is missing entries!!!\n\tPlease do not remove entries from force_fallback_for if you are packaging the project.\n\tWe pull in these projects at specific commits/forks/builds for a reason.\n\tIf you are not packaging, remove this line to continue.')
endif

add_project_arguments([
'-DWLR_USE_UNSTABLE',
], language: 'cpp')
'-DWLR_USE_UNSTABLE',
], language : 'cpp')

cppc = meson.get_compiler('cpp')

data_dir = get_option('datadir')
prefix = get_option('prefix')
lib_dir = get_option('libdir')

add_project_arguments(cppc.get_supported_arguments([
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
'-Wno-c99-designator',
'-Wno-invalid-offsetof',
'-Wno-unused-const-variable',
'-Wno-volatile', # glm warning
'-Wno-deprecated-volatile',
'-Wno-ignored-qualifiers', # reshade warning
'-Wno-missing-braces',
]), language: 'cpp')

add_project_arguments(cppc.get_supported_arguments([
'-fno-exceptions',
'-ffast-math',
]), language: 'cpp')

pipewire_dep = dependency('libpipewire-0.3', required: get_option('pipewire'))
add_project_arguments(
cppc.get_supported_arguments(
[
'-Wno-unused-parameter',
'-Wno-unused-result',
'-Wno-missing-field-initializers',
'-Wno-c99-designator',
'-Wno-invalid-offsetof',
'-Wno-unused-const-variable',
'-Wno-volatile', # glm warning
'-Wno-deprecated-volatile',
'-Wno-ignored-qualifiers', # reshade warning
'-Wno-missing-braces',
]
),
language : 'cpp'
)

add_project_arguments(
cppc.get_supported_arguments(
[
'-fno-exceptions',
'-ffast-math',
]
),
language : 'cpp'
)

pipewire_dep = dependency('libpipewire-0.3', required : get_option('pipewire'))
librt_dep = cppc.find_library('rt', required : get_option('pipewire'))
hwdata_dep = dependency('hwdata', required : false)

dep_x11 = dependency('x11')
dep_wayland = dependency('wayland-client')
vulkan_dep = dependency('vulkan')

glm_proj = subproject('glm')
glm_dep = glm_proj.get_variable('glm_dep')
stb_proj = subproject('stb')
stb_dep = stb_proj.get_variable('stb_dep')
dep_x11 = dependency('x11', fallback : 'x11')
dep_wayland = dependency('wayland-client', fallback : 'wayland-client')
vulkan_dep = dependency('vulkan', fallback : 'vulkan')
glm_dep = dependency('glm', fallback : 'glm')
stb_dep = dependency('stb', fallback : 'stb')
vkroots_dep = dependency('vkroots', fallback : 'vkroots')

if get_option('enable_openvr_support')
openvr_dep = dependency('openvr', version: '>= 2.7', required : false)
if not openvr_dep.found()
cmake = import('cmake')
openvr_var = cmake.subproject_options()
openvr_var.add_cmake_defines({'USE_LIBCXX': false,
#HACK: remove me when openvr supports CMake 4.0
'CMAKE_POLICY_VERSION_MINIMUM': '3.5'})
#ENDHACK
openvr_var.set_override_option('warning_level', '0')
openvr_proj = cmake.subproject('openvr', options : openvr_var)
openvr_dep = openvr_proj.dependency('openvr_api')
endif
openvr_dep = dependency('openvr', fallback : 'openvr')
else
# null dep
openvr_dep = dependency('', required : false)
# null dep
openvr_dep = dependency('', required : false)
endif

add_project_arguments(
'-DHAVE_PIPEWIRE=@0@'.format(pipewire_dep.found().to_int()),
'-DHAVE_OPENVR=@0@'.format(openvr_dep.found().to_int()),
'-DSCRIPT_DIR="@0@"'.format(prefix / data_dir / 'gamescope/scripts'),
language: 'cpp',
'-DHAVE_PIPEWIRE=@0@'.format(pipewire_dep.found().to_int()),
'-DHAVE_OPENVR=@0@'.format(openvr_dep.found().to_int()),
'-DSCRIPT_DIR="@0@"'.format(prefix / data_dir / 'gamescope/scripts'),
language : 'cpp',
)

if hwdata_dep.found()
add_project_arguments(
'-DHWDATA_PNP_IDS="@0@"'.format(hwdata_dep.get_variable('pkgdatadir') / 'pnp.ids'),
language: 'cpp',
)
add_project_arguments(
'-DHWDATA_PNP_IDS="@0@"'.format(hwdata_dep.get_variable('pkgdatadir') / 'pnp.ids'),
language : 'cpp',
)
else
warning('Building without hwdata pnp id support.')
warning('Building without hwdata pnp id support.')
endif

# Vulkan headers are installed separately from the loader (which ships the
# pkg-config file)
if not cppc.check_header('vulkan/vulkan.h', dependencies: vulkan_dep)
error('Missing vulkan-headers')
if not cppc.check_header('vulkan/vulkan.h', dependencies : vulkan_dep)
error('Missing vulkan-headers')
endif

subdir('protocol')

if get_option('enable_gamescope_wsi_layer')
subdir('layer')
subdir('layer')
endif

if get_option('enable_gamescope')
subdir('src')
subdir('src')
endif

if get_option('enable_tests')
subdir('tests')
subdir('tests')
endif


Expand Down
22 changes: 11 additions & 11 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
option('pipewire', type: 'feature', description: 'Screen capture via PipeWire')
option('rt_cap', type: 'feature', description: 'Support for creating real-time threads + compute queues')
option('drm_backend', type: 'feature', description: 'DRM Atomic Backend')
option('sdl2_backend', type: 'feature', description: 'SDL2 Window Backend')
option('avif_screenshots', type: 'feature', description: 'Support for saving .AVIF HDR screenshots')
option('input_emulation' , type: 'feature', description: 'Support for XTest/Input Emulation with libei')
option('enable_gamescope', type : 'boolean', value : true, description: 'Build Gamescope executable')
option('enable_gamescope_wsi_layer', type : 'boolean', value : true, description: 'Build Gamescope layer')
option('enable_openvr_support', type : 'boolean', value : true, description: 'OpenVR Integrations')
option('enable_tests', type : 'boolean', value : true, description: 'Build unit tests')
option('benchmark', type: 'feature', description: 'Benchmark tools')
option('pipewire', type : 'feature', description : 'Screen capture via PipeWire')
option('rt_cap', type : 'feature', description : 'Support for creating real-time threads + compute queues')
option('drm_backend', type : 'feature', description : 'DRM Atomic Backend')
option('sdl2_backend', type : 'feature', description : 'SDL2 Window Backend')
option('avif_screenshots', type : 'feature', description : 'Support for saving .AVIF HDR screenshots')
option('input_emulation' , type : 'feature', description : 'Support for XTest/Input Emulation with libei')
option('enable_gamescope', type : 'boolean', value : true, description : 'Build Gamescope executable')
option('enable_gamescope_wsi_layer', type : 'boolean', value : true, description : 'Build Gamescope layer')
option('enable_openvr_support', type : 'boolean', value : true, description : 'OpenVR Integrations')
option('enable_tests', type : 'boolean', value : true, description : 'Build unit tests')
option('benchmark', type : 'feature', description : 'Benchmark tools')
Loading