Compare commits
161
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcdb3eddcc | ||
|
|
057634d069 | ||
|
|
eb5eb4a33d | ||
|
|
df145a9649 | ||
|
|
b8618dd405 | ||
|
|
ddb497e815 | ||
|
|
6a42180dbf | ||
|
|
223a3dc461 | ||
|
|
13373ef501 | ||
|
|
a7de0d9a3e | ||
|
|
7f3ae3d574 | ||
|
|
80f82acdf8 | ||
|
|
78146bb14c | ||
|
|
c61f97dbce | ||
|
|
c823f837c0 | ||
|
|
f8252fcc91 | ||
|
|
98ed8b98b1 | ||
|
|
5f5a73a8f6 | ||
|
|
50be2a7e56 | ||
|
|
4fdbac7207 | ||
|
|
8199076878 | ||
|
|
c49de41ef3 | ||
|
|
ad5681c45b | ||
|
|
daf76f1ff6 | ||
|
|
cdff4b2bb5 | ||
|
|
d3a1a97db8 | ||
|
|
962464629d | ||
|
|
3291c2e560 | ||
|
|
b797a84b5d | ||
|
|
45b0460019 | ||
|
|
5d0919855e | ||
|
|
6d2d283954 | ||
|
|
49db06b604 | ||
|
|
85012b6074 | ||
|
|
14271c72f3 | ||
|
|
d73922e407 | ||
|
|
c8d23a5f01 | ||
|
|
4d8c8cdeda | ||
|
|
148d8c4995 | ||
|
|
4ae517e24e | ||
|
|
1fd4703907 | ||
|
|
024221d448 | ||
|
|
bfe046b60f | ||
|
|
1bfa90cb1f | ||
|
|
0c2e3308a5 | ||
|
|
11fc77b704 | ||
|
|
28af0d58c6 | ||
|
|
bca544448f | ||
|
|
badbf8da4e | ||
|
|
b140291cd0 | ||
|
|
70b12c1b1b | ||
|
|
2bbd74b4b6 | ||
|
|
add176e538 | ||
|
|
86384afbcf | ||
|
|
328f833d51 | ||
|
|
a002a6313e | ||
|
|
4fc5405f16 | ||
|
|
16d9f7316f | ||
|
|
95977f41b7 | ||
|
|
3302162ede | ||
|
|
29f857fed6 | ||
|
|
492ed877ea | ||
|
|
b1959ecf23 | ||
|
|
928454cbfe | ||
|
|
36b306a36c | ||
|
|
92570af7d3 | ||
|
|
5a9050aea3 | ||
|
|
3d9f4c3328 | ||
|
|
04ceb2d4a0 | ||
|
|
e6987e2452 | ||
|
|
4cd6df1997 | ||
|
|
9163913305 | ||
|
|
b3f4ba0725 | ||
|
|
354bda8dde | ||
|
|
8ccbfdf368 | ||
|
|
19b646849c | ||
|
|
48a83d69cc | ||
|
|
ec682cc794 | ||
|
|
d2d655b41f | ||
|
|
d6021b7d89 | ||
|
|
8dcb6db823 | ||
|
|
d0cfcf10bb | ||
|
|
dd791f6838 | ||
|
|
988714beb9 | ||
|
|
78756540cb | ||
|
|
205b5c9f44 | ||
|
|
bca30aafed | ||
|
|
840d5c16d2 | ||
|
|
25b9a686b0 | ||
|
|
54c2f2c3f7 | ||
|
|
b9cf5f08db | ||
|
|
c7a36fa3c9 | ||
|
|
73ca5f53e7 | ||
|
|
2be2fb4918 | ||
|
|
fec1dd4a8b | ||
|
|
2a3a8f736c | ||
|
|
d3aff13aa3 | ||
|
|
54fb312a2c | ||
|
|
20aa0ad1c5 | ||
|
|
ff667d35f2 | ||
|
|
ff9599fb7e | ||
|
|
0448f20394 | ||
|
|
db07924104 | ||
|
|
e60acdc477 | ||
|
|
d69f658835 | ||
|
|
3eb9328d3e | ||
|
|
a8589a8422 | ||
|
|
0bdaaf6c76 | ||
|
|
390197d3aa | ||
|
|
9fafba49dc | ||
|
|
5d47efe7fb | ||
|
|
824234accc | ||
|
|
6519158ae5 | ||
|
|
00718d60d2 | ||
|
|
18c2e179ee | ||
|
|
21ae008fc2 | ||
|
|
97a8bb44e6 | ||
|
|
5d33fce898 | ||
|
|
bb5df96f69 | ||
|
|
12b97944f3 | ||
|
|
0f17fbe1ca | ||
|
|
c3480ca99c | ||
|
|
936d94c2ee | ||
|
|
6cb55ebd46 | ||
|
|
482c5130eb | ||
|
|
066bcc5204 | ||
|
|
21baa27bea | ||
|
|
93fd4a1c80 | ||
|
|
7135779599 | ||
|
|
62c151d044 | ||
|
|
11d38fc23b | ||
|
|
d027f0ae6e | ||
|
|
44290c204e | ||
|
|
0b69860af6 | ||
|
|
e7a1ae0ea5 | ||
|
|
7af36d6c40 | ||
|
|
d1ae1163dd | ||
|
|
b2cf5729b4 | ||
|
|
11b8dd76db | ||
|
|
56507a6122 | ||
|
|
8d4324cba2 | ||
|
|
35408a2126 | ||
|
|
e5b9dfd181 | ||
|
|
e8a5d07e5e | ||
|
|
8c1daf0caf | ||
|
|
ad2b211f75 | ||
|
|
414ae344af | ||
|
|
71af2c020c | ||
|
|
e755f50072 | ||
|
|
a0b8275e9c | ||
|
|
ea362839b1 | ||
|
|
e7dd5d841b | ||
|
|
5594d03da0 | ||
|
|
f2ae66b64f | ||
|
|
393d99338f | ||
|
|
4d88280931 | ||
|
|
e8cc359b5e | ||
|
|
3b4a198655 | ||
|
|
03dd1520a3 | ||
|
|
a6fd74fa3b | ||
|
|
03b36bac94 |
No files matched your search
@@ -20,7 +20,6 @@ class AppleArch(Enum):
|
||||
class MsvcArch(Enum):
|
||||
X86 = "x86"
|
||||
X64 = "x64"
|
||||
Arm32 = "arm"
|
||||
Arm64 = "arm64"
|
||||
|
||||
|
||||
@@ -31,7 +30,9 @@ class JobOs(Enum):
|
||||
Ubuntu22_04 = "ubuntu-22.04"
|
||||
Ubuntu24_04 = "ubuntu-24.04"
|
||||
Ubuntu24_04_arm = "ubuntu-24.04-arm"
|
||||
Macos13 = "macos-13"
|
||||
Macos14 = "macos-14" # macOS Sonoma (2023)
|
||||
Macos15 = "macos-15" # macOS Sequoia (2024)
|
||||
Macos26 = "macos-26" # macOS Tahoe (2025)
|
||||
|
||||
|
||||
class SdlPlatform(Enum):
|
||||
@@ -109,7 +110,6 @@ JOB_SPECS = {
|
||||
"msvc-x86": JobSpec(name="Windows (MSVC, x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x86", msvc_arch=MsvcArch.X86, msvc_project="VisualC/SDL.sln", ),
|
||||
"msvc-clang-x64": JobSpec(name="Windows (MSVC, clang-cl x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x64", msvc_arch=MsvcArch.X64, clang_cl=True, ),
|
||||
"msvc-clang-x86": JobSpec(name="Windows (MSVC, clang-cl x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x86", msvc_arch=MsvcArch.X86, clang_cl=True, ),
|
||||
"msvc-arm32": JobSpec(name="Windows (MSVC, ARM)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm32", msvc_arch=MsvcArch.Arm32, ),
|
||||
"msvc-arm64": JobSpec(name="Windows (MSVC, ARM64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm64", msvc_arch=MsvcArch.Arm64, ),
|
||||
"msvc-gdk-x64": JobSpec(name="GDK (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-GDK", msvc_arch=MsvcArch.X64, msvc_project="VisualC-GDK/SDL.sln", gdk=True, no_cmake=True, ),
|
||||
"ubuntu-22.04": JobSpec(name="Ubuntu 22.04", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04", ),
|
||||
@@ -117,7 +117,7 @@ JOB_SPECS = {
|
||||
"steamrt-sniper": JobSpec(name="Steam Linux Runtime (Sniper)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Linux, artifact="SDL-slrsniper", container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:beta", ),
|
||||
"ubuntu-intel-icx": JobSpec(name="Ubuntu 22.04 (Intel oneAPI)", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04-oneapi", intel=IntelCompiler.Icx, ),
|
||||
"ubuntu-intel-icc": JobSpec(name="Ubuntu 22.04 (Intel Compiler)", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04-icc", intel=IntelCompiler.Icc, ),
|
||||
"macos-framework-x64": JobSpec(name="MacOS (Framework) (x64)", os=JobOs.Macos13, platform=SdlPlatform.MacOS, artifact="SDL-macos-framework", apple_framework=True, apple_archs={AppleArch.Aarch64, AppleArch.X86_64, }, xcode=True, ),
|
||||
"macos-framework-x64": JobSpec(name="MacOS (Framework) (x64)", os=JobOs.Macos14, platform=SdlPlatform.MacOS, artifact="SDL-macos-framework", apple_framework=True, apple_archs={AppleArch.Aarch64, AppleArch.X86_64, }, xcode=True, ),
|
||||
"macos-framework-arm64": JobSpec(name="MacOS (Framework) (arm64)", os=JobOs.MacosLatest, platform=SdlPlatform.MacOS, artifact=None, apple_framework=True, apple_archs={AppleArch.Aarch64, AppleArch.X86_64, }, ),
|
||||
"macos-gnu-arm64": JobSpec(name="MacOS (GNU prefix)", os=JobOs.MacosLatest, platform=SdlPlatform.MacOS, artifact="SDL-macos-arm64-gnu", apple_framework=False, apple_archs={AppleArch.Aarch64, }, ),
|
||||
"ios": JobSpec(name="iOS (CMake & xcode)", os=JobOs.MacosLatest, platform=SdlPlatform.Ios, artifact="SDL-ios-arm64", xcode=True, ),
|
||||
@@ -409,10 +409,6 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
job.msvc_vcvars_arch = "x64_x86"
|
||||
case MsvcArch.X64:
|
||||
job.msvc_vcvars_arch = "x64"
|
||||
case MsvcArch.Arm32:
|
||||
job.msvc_vcvars_arch = "x64_arm"
|
||||
job.msvc_vcvars_sdk = "10.0.22621.0" # 10.0.26100.0 dropped ARM32 um and ucrt libraries
|
||||
job.run_tests = False
|
||||
case MsvcArch.Arm64:
|
||||
job.msvc_vcvars_arch = "x64_arm64"
|
||||
job.run_tests = False
|
||||
@@ -520,9 +516,10 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
job.ccache = True
|
||||
job.apt_packages = []
|
||||
job.brew_packages.extend((
|
||||
"ccache",
|
||||
"ninja",
|
||||
))
|
||||
if job.ccache:
|
||||
job.brew_packages.append("ccache")
|
||||
if job.clang_tidy:
|
||||
job.brew_packages.append("llvm")
|
||||
if spec.xcode:
|
||||
@@ -736,7 +733,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
match spec.platform:
|
||||
case SdlPlatform.FreeBSD:
|
||||
job.cpactions_os = "freebsd"
|
||||
job.cpactions_version = "14.2"
|
||||
job.cpactions_version = "14.3"
|
||||
job.cpactions_arch = "x86-64"
|
||||
job.cpactions_setup_cmd = "sudo pkg update"
|
||||
job.cpactions_install_cmd = "sudo pkg install -y cmake ninja pkgconf libXcursor libXext libXinerama libXi libXfixes libXrandr libXScrnSaver libXxf86vm wayland wayland-protocols libxkbcommon mesa-libs libglvnd evdev-proto libinotify alsa-lib jackit pipewire pulseaudio sndio dbus zh-fcitx ibus libudev-devd"
|
||||
@@ -752,10 +749,10 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
job.cpactions_install_cmd = "sudo -E pkgin -y install cmake dbus pkgconf ninja-build pulseaudio libxkbcommon wayland wayland-protocols libinotify libusb1"
|
||||
case SdlPlatform.OpenBSD:
|
||||
job.cpactions_os = "openbsd"
|
||||
job.cpactions_version = "7.4"
|
||||
job.cpactions_version = "7.7"
|
||||
job.cpactions_arch = "x86-64"
|
||||
job.cpactions_setup_cmd = "sudo pkg_add -u"
|
||||
job.cpactions_install_cmd = "sudo pkg_add cmake ninja pkgconf wayland wayland-protocols xwayland libxkbcommon libinotify pulseaudio dbus ibus"
|
||||
job.cpactions_install_cmd = "sudo pkg_add cmake ninja pkgconf wayland wayland-protocols libxkbcommon libinotify pulseaudio dbus ibus"
|
||||
case _:
|
||||
raise ValueError(f"Unsupported platform={spec.platform}")
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
if: ${{ matrix.platform.android-ndk }}
|
||||
id: setup-ndk
|
||||
with:
|
||||
local-cache: true
|
||||
local-cache: false
|
||||
ndk-version: r28c
|
||||
- name: 'Configure Android NDK variables'
|
||||
if: ${{ matrix.platform.android-ndk }}
|
||||
@@ -321,7 +321,7 @@ jobs:
|
||||
- name: 'Build (cross-platform-actions, BSD)'
|
||||
id: cpactions
|
||||
if: ${{ matrix.platform.cpactions }}
|
||||
uses: cross-platform-actions/action@v0.27.0
|
||||
uses: cross-platform-actions/action@v0.29.0
|
||||
with:
|
||||
operating_system: '${{ matrix.platform.cpactions-os }}'
|
||||
architecture: '${{ matrix.platform.cpactions-arch }}'
|
||||
|
||||
@@ -95,9 +95,17 @@ jobs:
|
||||
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
|
||||
- name: 'CMake (configure + build + tests + examples)'
|
||||
run: |
|
||||
set -e
|
||||
cmake -S ${{ steps.tar.outputs.path }} -B /tmp/build -DSDL_TEST_LIBRARY=TRUE -DSDL_TESTS=TRUE -DSDL_EXAMPLES=TRUE
|
||||
cmake --build /tmp/build --verbose
|
||||
ctest --test-dir /tmp/build --no-tests=error --output-on-failure
|
||||
- name: 'Verify SDL_REVISION contains SDL-'
|
||||
run: |
|
||||
set -e
|
||||
if test "x$(strings /tmp/build/libSDL3.so.0 | grep SDL- | wc -l)" != x1; then
|
||||
echo "SDL- string not found: must be present in SDL_REVISION"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dmg:
|
||||
needs: [src]
|
||||
@@ -204,10 +212,22 @@ jobs:
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
|
||||
-DCMAKE_SYSTEM_NAME=iOS \
|
||||
-DCMAKE_OSX_ARCHITECTURES="arm64" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
-Werror=dev \
|
||||
-B build_ios
|
||||
cmake --build build_ios --config Release --verbose
|
||||
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
|
||||
-DTEST_FULL=FALSE \
|
||||
-DTEST_STATIC=FALSE \
|
||||
-DTEST_TEST=FALSE \
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/ios-arm64" \
|
||||
-DCMAKE_SYSTEM_NAME=iOS \
|
||||
-DCMAKE_OSX_ARCHITECTURES="arm64" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
-Werror=dev \
|
||||
-B build_ios2
|
||||
cmake --build build_ios2 --config Release --verbose
|
||||
- name: 'CMake (configure + build) tvOS'
|
||||
run: |
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
|
||||
@@ -217,10 +237,22 @@ jobs:
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}" \
|
||||
-DCMAKE_SYSTEM_NAME=tvOS \
|
||||
-DCMAKE_OSX_ARCHITECTURES="arm64" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
-Werror=dev \
|
||||
-B build_tvos
|
||||
cmake --build build_tvos --config Release --verbose
|
||||
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
|
||||
-DTEST_FULL=FALSE \
|
||||
-DTEST_STATIC=FALSE \
|
||||
-DTEST_TEST=FALSE \
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/tvos-arm64" \
|
||||
-DCMAKE_SYSTEM_NAME=tvOS \
|
||||
-DCMAKE_OSX_ARCHITECTURES="arm64" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
-Werror=dev \
|
||||
-B build_tvos2
|
||||
cmake --build build_tvos2 --config Release --verbose
|
||||
- name: 'CMake (configure + build) iOS simulator'
|
||||
run: |
|
||||
sysroot=$(xcodebuild -version -sdk iphonesimulator Path)
|
||||
@@ -237,6 +269,19 @@ jobs:
|
||||
-Werror=dev \
|
||||
-B build_ios_simulator
|
||||
cmake --build build_ios_simulator --config Release --verbose
|
||||
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
|
||||
-DTEST_FULL=FALSE \
|
||||
-DTEST_STATIC=FALSE \
|
||||
-DTEST_TEST=FALSE \
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/ios-arm64_x86_64-simulator" \
|
||||
-DCMAKE_SYSTEM_NAME=iOS \
|
||||
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
|
||||
-DCMAKE_OSX_SYSROOT="${sysroot}" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
-Werror=dev \
|
||||
-B build_ios_simulator2
|
||||
cmake --build build_ios_simulator2 --config Release --verbose
|
||||
- name: 'CMake (configure + build) tvOS simulator'
|
||||
run: |
|
||||
sysroot=$(xcodebuild -version -sdk appletvsimulator Path)
|
||||
@@ -254,6 +299,19 @@ jobs:
|
||||
-B build_tvos_simulator
|
||||
cmake --build build_tvos_simulator --config Release --verbose
|
||||
|
||||
cmake -S "${{ steps.src.outputs.path }}/cmake/test" \
|
||||
-DTEST_FULL=FALSE \
|
||||
-DTEST_STATIC=FALSE \
|
||||
-DTEST_TEST=FALSE \
|
||||
-DCMAKE_PREFIX_PATH="${{ steps.mount.outputs.mount_point }}/SDL3.xcframework/tvos-arm64_x86_64-simulator" \
|
||||
-DCMAKE_SYSTEM_NAME=tvOS \
|
||||
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
|
||||
-DCMAKE_OSX_SYSROOT="${sysroot}" \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \
|
||||
-Werror=dev \
|
||||
-B build_tvos_simulator2
|
||||
cmake --build build_tvos_simulator2 --config Release --verbose
|
||||
|
||||
msvc:
|
||||
needs: [src]
|
||||
runs-on: windows-2025
|
||||
@@ -532,9 +590,10 @@ jobs:
|
||||
with:
|
||||
sparse-checkout: 'build-scripts/build-release.py'
|
||||
- name: 'Setup Android NDK'
|
||||
id: setup-ndk
|
||||
uses: nttld/setup-ndk@v1
|
||||
with:
|
||||
local-cache: true
|
||||
local-cache: false
|
||||
ndk-version: r28c
|
||||
- name: 'Setup Java JDK'
|
||||
uses: actions/setup-java@v4
|
||||
@@ -561,6 +620,8 @@ jobs:
|
||||
run: |
|
||||
python build-scripts/build-release.py \
|
||||
--actions android \
|
||||
--android-api 21 \
|
||||
--android-ndk-home "${{ steps.setup-ndk.outputs.ndk-path }}" \
|
||||
--commit ${{ inputs.commit }} \
|
||||
--root "${{ steps.tar.outputs.path }}" \
|
||||
--github \
|
||||
@@ -607,8 +668,14 @@ jobs:
|
||||
python "${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}.aar" -o /tmp/SDL3-android
|
||||
echo "prefix=/tmp/SDL3-android" >>$GITHUB_OUTPUT
|
||||
echo "sdl3-aar=/tmp/${{ needs.src.outputs.project }}-${{ needs.src.outputs.version }}.aar" >>$GITHUB_OUTPUT
|
||||
- name: 'Verify alignment of libSDL3.so (arm64-v8a/x86_64)'
|
||||
run: |
|
||||
set -e
|
||||
${{ steps.src.outputs.path }}/build-scripts/check_elf_alignment.sh ${{ steps.sdk.outputs.prefix }}/lib/arm64-v8a/libSDL3.so
|
||||
${{ steps.src.outputs.path }}/build-scripts/check_elf_alignment.sh ${{ steps.sdk.outputs.prefix }}/lib/x86_64/libSDL3.so
|
||||
- name: 'CMake (configure + build) x86, x64, arm32, arm64'
|
||||
run: |
|
||||
set -e
|
||||
android_abis="x86 x86_64 armeabi-v7a arm64-v8a"
|
||||
for android_abi in ${android_abis}; do
|
||||
echo "Configuring ${android_abi}..."
|
||||
|
||||
+54
-35
@@ -5,7 +5,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
endif()
|
||||
|
||||
# See docs/release_checklist.md
|
||||
project(SDL3 LANGUAGES C VERSION "3.2.22")
|
||||
project(SDL3 LANGUAGES C VERSION "3.2.29")
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||
set(SDL3_MAINPROJECT ON)
|
||||
@@ -79,6 +79,12 @@ include("${SDL3_SOURCE_DIR}/cmake/PreseedEmscriptenCache.cmake")
|
||||
|
||||
SDL_DetectCompiler()
|
||||
SDL_DetectTargetCPUArchitectures(SDL_CPUS)
|
||||
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES _num_arches)
|
||||
if(_num_arches GREATER 1)
|
||||
set(APPLE_MULTIARCH TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Increment this if there is an incompatible change - but if that happens,
|
||||
# we should rename the library from SDL3 to SDL4, at which point this would
|
||||
@@ -350,7 +356,7 @@ dep_option(SDL_WASAPI "Use the Windows WASAPI audio driver" ON "WIN
|
||||
dep_option(SDL_RENDER_D3D "Enable the Direct3D 9 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
|
||||
dep_option(SDL_RENDER_D3D11 "Enable the Direct3D 11 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
|
||||
dep_option(SDL_RENDER_D3D12 "Enable the Direct3D 12 render driver" ON "SDL_RENDER;SDL_DIRECTX" OFF)
|
||||
dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_RENDER;${APPLE}" OFF)
|
||||
dep_option(SDL_RENDER_METAL "Enable the Metal render driver" ON "SDL_RENDER;APPLE" OFF)
|
||||
dep_option(SDL_RENDER_GPU "Enable the SDL_GPU render driver" ON "SDL_RENDER;SDL_GPU" OFF)
|
||||
dep_option(SDL_VIVANTE "Use Vivante EGL video driver" ON "${UNIX_SYS};SDL_CPU_ARM32" OFF)
|
||||
dep_option(SDL_VULKAN "Enable Vulkan support" ON "SDL_VIDEO;ANDROID OR APPLE OR LINUX OR FREEBSD OR WINDOWS" OFF)
|
||||
@@ -658,7 +664,7 @@ if(SDL_ASSEMBLY)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " -mmmx")
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
check_x86_source_compiles([==[
|
||||
#include <mmintrin.h>
|
||||
void ints_add(int *dest, int *a, int *b, unsigned size) {
|
||||
for (; size >= 2; size -= 2, dest += 2, a += 2, b += 2) {
|
||||
@@ -668,7 +674,7 @@ if(SDL_ASSEMBLY)
|
||||
int main(int argc, char *argv[]) {
|
||||
ints_add((int*)0, (int*)0, (int*)0, 0);
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_MMX)
|
||||
}]==] COMPILER_SUPPORTS_MMX)
|
||||
cmake_pop_check_state()
|
||||
if(COMPILER_SUPPORTS_MMX)
|
||||
set(HAVE_MMX TRUE)
|
||||
@@ -679,7 +685,7 @@ if(SDL_ASSEMBLY)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse")
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
check_x86_source_compiles([==[
|
||||
#include <xmmintrin.h>
|
||||
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||
@@ -689,7 +695,7 @@ if(SDL_ASSEMBLY)
|
||||
int main(int argc, char **argv) {
|
||||
floats_add((float*)0, (float*)0, (float*)0, 0);
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_SSE)
|
||||
}]==] COMPILER_SUPPORTS_SSE)
|
||||
cmake_pop_check_state()
|
||||
if(COMPILER_SUPPORTS_SSE)
|
||||
set(HAVE_SSE TRUE)
|
||||
@@ -700,7 +706,7 @@ if(SDL_ASSEMBLY)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse2")
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
check_x86_source_compiles([==[
|
||||
#include <emmintrin.h>
|
||||
void doubles_add(double *dest, double *a, double *b, unsigned size) {
|
||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||
@@ -710,7 +716,7 @@ if(SDL_ASSEMBLY)
|
||||
int main(int argc, char **argv) {
|
||||
doubles_add((double*)0, (double*)0, (double*)0, 0);
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_SSE2)
|
||||
}]==] COMPILER_SUPPORTS_SSE2)
|
||||
cmake_pop_check_state()
|
||||
if(COMPILER_SUPPORTS_SSE2)
|
||||
set(HAVE_SSE2 TRUE)
|
||||
@@ -721,7 +727,7 @@ if(SDL_ASSEMBLY)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse3")
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
check_x86_source_compiles([==[
|
||||
#include <pmmintrin.h>
|
||||
void ints_add(int *dest, int *a, int *b, unsigned size) {
|
||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||
@@ -731,7 +737,7 @@ if(SDL_ASSEMBLY)
|
||||
int main(int argc, char **argv) {
|
||||
ints_add((int*)0, (int*)0, (int*)0, 0);
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_SSE3)
|
||||
}]==] COMPILER_SUPPORTS_SSE3)
|
||||
cmake_pop_check_state()
|
||||
if(COMPILER_SUPPORTS_SSE3)
|
||||
set(HAVE_SSE3 TRUE)
|
||||
@@ -742,7 +748,7 @@ if(SDL_ASSEMBLY)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.1")
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
check_x86_source_compiles([==[
|
||||
#include <smmintrin.h>
|
||||
void ints_mul(int *dest, int *a, int *b, unsigned size) {
|
||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||
@@ -752,7 +758,7 @@ if(SDL_ASSEMBLY)
|
||||
int main(int argc, char **argv) {
|
||||
ints_mul((int*)0, (int*)0, (int*)0, 0);
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_SSE4_1)
|
||||
}]==] COMPILER_SUPPORTS_SSE4_1)
|
||||
cmake_pop_check_state()
|
||||
if(COMPILER_SUPPORTS_SSE4_1)
|
||||
set(HAVE_SSE4_1 TRUE)
|
||||
@@ -763,14 +769,14 @@ if(SDL_ASSEMBLY)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " -msse4.2")
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
check_x86_source_compiles([==[
|
||||
#include <nmmintrin.h>
|
||||
__m128i bitmask;
|
||||
char data[16];
|
||||
int main(int argc, char **argv) {
|
||||
bitmask = _mm_cmpgt_epi64(_mm_set1_epi64x(0), _mm_loadu_si128((void*)data));
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_SSE4_2)
|
||||
}]==] COMPILER_SUPPORTS_SSE4_2)
|
||||
cmake_pop_check_state()
|
||||
if(COMPILER_SUPPORTS_SSE4_2)
|
||||
set(HAVE_SSE4_2 TRUE)
|
||||
@@ -781,7 +787,7 @@ if(SDL_ASSEMBLY)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx")
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
check_x86_source_compiles([==[
|
||||
#include <immintrin.h>
|
||||
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
||||
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
|
||||
@@ -791,7 +797,7 @@ if(SDL_ASSEMBLY)
|
||||
int main(int argc, char **argv) {
|
||||
floats_add((float*)0, (float*)0, (float*)0, 0);
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_AVX)
|
||||
}]==] COMPILER_SUPPORTS_AVX)
|
||||
cmake_pop_check_state()
|
||||
if(COMPILER_SUPPORTS_AVX)
|
||||
set(HAVE_AVX TRUE)
|
||||
@@ -802,7 +808,7 @@ if(SDL_ASSEMBLY)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx2")
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
check_x86_source_compiles([==[
|
||||
#include <immintrin.h>
|
||||
void ints_add(int *dest, int *a, int *b, unsigned size) {
|
||||
for (; size >= 8; size -= 8, dest += 8, a += 8, b += 8) {
|
||||
@@ -812,7 +818,7 @@ if(SDL_ASSEMBLY)
|
||||
int main(int argc, char **argv) {
|
||||
ints_add((int*)0, (int*)0, (int*)0, 0);
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_AVX2)
|
||||
}]==] COMPILER_SUPPORTS_AVX2)
|
||||
cmake_pop_check_state()
|
||||
if(COMPILER_SUPPORTS_AVX2)
|
||||
set(HAVE_AVX2 TRUE)
|
||||
@@ -823,7 +829,7 @@ if(SDL_ASSEMBLY)
|
||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " -mavx512f")
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
check_x86_source_compiles([==[
|
||||
#include <immintrin.h>
|
||||
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
||||
for (; size >= 16; size -= 16, dest += 16, a += 16, b += 16) {
|
||||
@@ -833,7 +839,7 @@ if(SDL_ASSEMBLY)
|
||||
int main(int argc, char **argv) {
|
||||
floats_add((float*)0, (float*)0, (float*)0, 0);
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_AVX512F)
|
||||
}]==] COMPILER_SUPPORTS_AVX512F)
|
||||
cmake_pop_check_state()
|
||||
if(COMPILER_SUPPORTS_AVX512F)
|
||||
set(HAVE_AVX512F TRUE)
|
||||
@@ -841,18 +847,17 @@ if(SDL_ASSEMBLY)
|
||||
endif()
|
||||
|
||||
if(SDL_ARMNEON)
|
||||
check_c_source_compiles("
|
||||
#include <arm_neon.h>
|
||||
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||
vst1q_f32(dest, vaddq_f32(vld1q_f32(a), vld1q_f32(b)));
|
||||
}
|
||||
check_arm_source_compiles([==[
|
||||
#include <arm_neon.h>
|
||||
void floats_add(float *dest, float *a, float *b, unsigned size) {
|
||||
for (; size >= 4; size -= 4, dest += 4, a += 4, b += 4) {
|
||||
vst1q_f32(dest, vaddq_f32(vld1q_f32(a), vld1q_f32(b)));
|
||||
}
|
||||
int main(int argc, char *argv[]) {
|
||||
floats_add((float*)0, (float*)0, (float*)0, 0);
|
||||
return 0;
|
||||
}" COMPILER_SUPPORTS_ARMNEON)
|
||||
|
||||
}
|
||||
int main(int argc, char *argv[]) {
|
||||
floats_add((float*)0, (float*)0, (float*)0, 0);
|
||||
return 0;
|
||||
}]==] COMPILER_SUPPORTS_ARMNEON)
|
||||
if(COMPILER_SUPPORTS_ARMNEON)
|
||||
set(HAVE_ARMNEON TRUE)
|
||||
endif()
|
||||
@@ -893,7 +898,17 @@ if(SDL_ASSEMBLY)
|
||||
cmake_pop_check_state()
|
||||
|
||||
if(COMPILER_SUPPORTS_LSX AND HAVE_LSXINTRIN_H)
|
||||
set_property(SOURCE "${SDL3_SOURCE_DIR}/src/video/yuv2rgb/yuv_rgb_lsx.c" APPEND PROPERTY COMPILE_OPTIONS "-mlsx")
|
||||
set_property(SOURCE
|
||||
"${SDL3_SOURCE_DIR}/src/video/yuv2rgb/yuv_rgb_lsx.c"
|
||||
"${SDL3_SOURCE_DIR}/src/video/SDL_blit_A.c"
|
||||
"${SDL3_SOURCE_DIR}/src/video/SDL_fillrect.c"
|
||||
APPEND PROPERTY COMPILE_OPTIONS "-mlsx")
|
||||
|
||||
set_property(SOURCE
|
||||
"${SDL3_SOURCE_DIR}/src/video/yuv2rgb/yuv_rgb_lsx.c"
|
||||
"${SDL3_SOURCE_DIR}/src/video/SDL_blit_A.c"
|
||||
"${SDL3_SOURCE_DIR}/src/video/SDL_fillrect.c"
|
||||
PROPERTY SKIP_PRECOMPILE_HEADERS 1)
|
||||
set(HAVE_LSX TRUE)
|
||||
endif()
|
||||
endif()
|
||||
@@ -1484,6 +1499,9 @@ if(ANDROID)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(TARGET SDL3-static)
|
||||
target_link_options(SDL3-static INTERFACE "-Wl,-u,JNI_OnLoad")
|
||||
endif()
|
||||
|
||||
elseif(EMSCRIPTEN)
|
||||
# Hide noisy warnings that intend to aid mostly during initial stages of porting a new
|
||||
@@ -1909,7 +1927,7 @@ elseif(WINDOWS)
|
||||
target_compile_options(SDL_uclibc PRIVATE $<$<COMPILE_LANGUAGE:C,CXX>:/GS-> $<$<COMPILE_LANGUAGE:C,CXX>:/Gs1048576>)
|
||||
if(SDL_CPU_X86)
|
||||
target_compile_options(SDL3-shared PRIVATE "/arch:SSE")
|
||||
target_compile_options(SDL3-SDL_uclibc PRIVATE "/arch:SSE")
|
||||
target_compile_options(SDL_uclibc PRIVATE "/arch:SSE")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -3148,14 +3166,15 @@ endforeach()
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/REVISION.txt")
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/REVISION.txt" revisions)
|
||||
list(GET revisions 0 revisions_0)
|
||||
string(STRIP "${revisions_0}" SDL_REVISION)
|
||||
string(STRIP "${revisions_0}" revisions_0_stripped)
|
||||
set(SDL_REVISION "SDL-${revisions_0_stripped}")
|
||||
else()
|
||||
set(SDL_REVISION "" CACHE STRING "Custom SDL revision (only used when REVISION.txt does not exist)")
|
||||
endif()
|
||||
if(NOT SDL_REVISION)
|
||||
# If SDL_REVISION is not overrided, use git to describe
|
||||
git_describe(SDL_REVISION_GIT)
|
||||
set(SDL_REVISION "SDL3-${SDL3_VERSION}-${SDL_REVISION_GIT}")
|
||||
set(SDL_REVISION "SDL-${SDL3_VERSION}-${SDL_REVISION_GIT}")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${SDL3_BINARY_DIR}/include-revision/SDL3")
|
||||
|
||||
@@ -781,7 +781,6 @@
|
||||
<ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
|
||||
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
|
||||
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_render.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_render_unsupported.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
|
||||
|
||||
@@ -108,7 +108,6 @@
|
||||
<ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
|
||||
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
|
||||
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_render.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_render_unsupported.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
|
||||
|
||||
@@ -627,7 +627,6 @@
|
||||
<ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.c" />
|
||||
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
|
||||
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_render.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_render_unsupported.c" />
|
||||
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
|
||||
|
||||
@@ -1460,7 +1460,6 @@
|
||||
<ClCompile Include="..\..\src\sensor\windows\SDL_windowssensor.c">
|
||||
<Filter>sensor\windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\render\SDL_d3dmath.c">
|
||||
<Filter>render</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\render\SDL_render.c">
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
|
||||
This is a list of major changes in SDL's version history.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
3.2.22:
|
||||
---------------------------------------------------------------------------
|
||||
* SDL_HINT_JOYSTICK_WGI is disabled by default
|
||||
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
3.2.16:
|
||||
---------------------------------------------------------------------------
|
||||
* SDL_HINT_JOYSTICK_RAWINPUT is disabled by default
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
3.2.10:
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.2.22</string>
|
||||
<string>3.2.29</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>SDLX</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>3.2.22</string>
|
||||
<string>3.2.29</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -292,7 +292,6 @@
|
||||
A7D8BA2523E2514400DCD162 /* SDL_drawpoint.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A8FC23E2514000DCD162 /* SDL_drawpoint.c */; };
|
||||
A7D8BA2B23E2514400DCD162 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A8FD23E2514000DCD162 /* SDL_blendfillrect.c */; };
|
||||
A7D8BA3123E2514400DCD162 /* SDL_rotate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A8FE23E2514000DCD162 /* SDL_rotate.h */; };
|
||||
A7D8BA3723E2514400DCD162 /* SDL_d3dmath.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A8FF23E2514000DCD162 /* SDL_d3dmath.c */; };
|
||||
A7D8BA4923E2514400DCD162 /* SDL_render_gles2.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A90423E2514000DCD162 /* SDL_render_gles2.c */; };
|
||||
A7D8BA4F23E2514400DCD162 /* SDL_shaders_gles2.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A90523E2514000DCD162 /* SDL_shaders_gles2.h */; };
|
||||
A7D8BA5523E2514400DCD162 /* SDL_gles2funcs.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A90623E2514000DCD162 /* SDL_gles2funcs.h */; };
|
||||
@@ -869,7 +868,6 @@
|
||||
A7D8A8FC23E2514000DCD162 /* SDL_drawpoint.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_drawpoint.c; sourceTree = "<group>"; };
|
||||
A7D8A8FD23E2514000DCD162 /* SDL_blendfillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blendfillrect.c; sourceTree = "<group>"; };
|
||||
A7D8A8FE23E2514000DCD162 /* SDL_rotate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rotate.h; sourceTree = "<group>"; };
|
||||
A7D8A8FF23E2514000DCD162 /* SDL_d3dmath.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_d3dmath.c; sourceTree = "<group>"; };
|
||||
A7D8A90423E2514000DCD162 /* SDL_render_gles2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render_gles2.c; sourceTree = "<group>"; };
|
||||
A7D8A90523E2514000DCD162 /* SDL_shaders_gles2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_shaders_gles2.h; sourceTree = "<group>"; };
|
||||
A7D8A90623E2514000DCD162 /* SDL_gles2funcs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_gles2funcs.h; sourceTree = "<group>"; };
|
||||
@@ -2135,7 +2133,6 @@
|
||||
A7D8A90C23E2514000DCD162 /* opengl */,
|
||||
A7D8A90323E2514000DCD162 /* opengles2 */,
|
||||
A7D8A8EF23E2514000DCD162 /* software */,
|
||||
A7D8A8FF23E2514000DCD162 /* SDL_d3dmath.c */,
|
||||
A7D8A8DC23E2514000DCD162 /* SDL_d3dmath.h */,
|
||||
A7D8A8DB23E2514000DCD162 /* SDL_render.c */,
|
||||
E4F7981D2AD8D86A00669F54 /* SDL_render_unsupported.c */,
|
||||
@@ -2833,7 +2830,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "# Build an xcframework with both device and simulator files for all platforms.\n# Adapted from an answer in\n# https://developer.apple.com/forums/thread/666335?answerId=685927022#685927022\n\nif [ \"$XCODE_VERSION_ACTUAL\" -lt 1100 ]\nthen\n echo \"error: Building an xcframework requires Xcode 11 minimum.\"\n exit 1\nfi\n\nFRAMEWORK_NAME=\"SDL3\"\nPROJECT_NAME=\"SDL\"\nSCHEME=\"SDL3\"\n\nMACOS_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-macosx.xcarchive\"\nIOS_SIMULATOR_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphonesimulator.xcarchive\"\nIOS_DEVICE_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphoneos.xcarchive\"\nTVOS_SIMULATOR_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-appletvsimulator.xcarchive\"\nTVOS_DEVICE_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-appletvos.xcarchive\"\n\nOUTPUT_DIR=\"./build/\"\n\n# macOS\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${MACOS_ARCHIVE_PATH} \\\n -destination 'generic/platform=macOS,name=Any Mac' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n \n# iOS simulator\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${IOS_SIMULATOR_ARCHIVE_PATH} \\\n -destination 'generic/platform=iOS Simulator' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# iOS device\nxcodebuild archive \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${IOS_DEVICE_ARCHIVE_PATH} \\\n -destination 'generic/platform=iOS' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# tvOS simulator\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${TVOS_SIMULATOR_ARCHIVE_PATH} \\\n -destination 'generic/platform=tvOS Simulator' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# tvOS device\nxcodebuild archive \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${TVOS_DEVICE_ARCHIVE_PATH} \\\n -destination 'generic/platform=tvOS' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# Clean-up any existing instance of this xcframework from the Products directory\nrm -rf \"${OUTPUT_DIR}${FRAMEWORK_NAME}.xcframework\"\n\n# Create final xcframework\nxcodebuild -create-xcframework \\\n -framework \"${MACOS_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -framework \"${IOS_DEVICE_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -framework \"${IOS_SIMULATOR_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -framework \"${TVOS_DEVICE_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -framework \"${TVOS_SIMULATOR_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -output ${OUTPUT_DIR}/${FRAMEWORK_NAME}.xcframework\n\n# Ensure git doesn't pick up on our Products folder. \nrm -rf ${OUTPUT_DIR}/.gitignore\necho \"*\" >> ${OUTPUT_DIR}/.gitignore\n";
|
||||
shellScript = "# Build an xcframework with both device and simulator files for all platforms.\n# Adapted from an answer in\n# https://developer.apple.com/forums/thread/666335?answerId=685927022#685927022\n\nif [ \"$XCODE_VERSION_ACTUAL\" -lt 1100 ]\nthen\n echo \"error: Building an xcframework requires Xcode 11 minimum.\"\n exit 1\nfi\n\nFRAMEWORK_NAME=\"SDL3\"\nPROJECT_NAME=\"SDL\"\nSCHEME=\"SDL3\"\n\nMACOS_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-macosx.xcarchive\"\nIOS_SIMULATOR_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphonesimulator.xcarchive\"\nIOS_DEVICE_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-iphoneos.xcarchive\"\nTVOS_SIMULATOR_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-appletvsimulator.xcarchive\"\nTVOS_DEVICE_ARCHIVE_PATH=\"${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}-appletvos.xcarchive\"\n\nOUTPUT_DIR=\"./build/\"\n\n# macOS\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${MACOS_ARCHIVE_PATH} \\\n -destination 'generic/platform=macOS,name=Any Mac' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n \n# iOS simulator\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${IOS_SIMULATOR_ARCHIVE_PATH} \\\n -destination 'generic/platform=iOS Simulator' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# iOS device\nxcodebuild archive \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${IOS_DEVICE_ARCHIVE_PATH} \\\n -destination 'generic/platform=iOS' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# tvOS simulator\nxcodebuild archive \\\n ONLY_ACTIVE_ARCH=NO \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${TVOS_SIMULATOR_ARCHIVE_PATH} \\\n -destination 'generic/platform=tvOS Simulator' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# tvOS device\nxcodebuild archive \\\n -scheme \"${SCHEME}\" \\\n -project \"${PROJECT_NAME}.xcodeproj\" \\\n -archivePath ${TVOS_DEVICE_ARCHIVE_PATH} \\\n -destination 'generic/platform=tvOS' \\\n BUILD_LIBRARY_FOR_DISTRIBUTION=YES \\\n SKIP_INSTALL=NO || exit $?\n\n# Clean-up any existing instance of this xcframework from the Products directory\nrm -rf \"${OUTPUT_DIR}${FRAMEWORK_NAME}.xcframework\"\n\n# Create final xcframework\nxcodebuild -create-xcframework \\\n -framework \"${MACOS_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${MACOS_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -framework \"${IOS_DEVICE_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${IOS_DEVICE_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -framework \"${IOS_SIMULATOR_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${IOS_SIMULATOR_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -framework \"${TVOS_DEVICE_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${TVOS_DEVICE_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -framework \"${TVOS_SIMULATOR_ARCHIVE_PATH}\"/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework \\\n -debug-symbols \"${TVOS_SIMULATOR_ARCHIVE_PATH}\"/dSYMs/$FRAMEWORK_NAME.framework.dSYM \\\n -output ${OUTPUT_DIR}/${FRAMEWORK_NAME}.xcframework\n\n# Ensure git doesn't pick up on our Products folder. \nrm -rf ${OUTPUT_DIR}/.gitignore\necho \"*\" >> ${OUTPUT_DIR}/.gitignore\n";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
@@ -2903,7 +2900,6 @@
|
||||
A7D8BBE723E2574800DCD162 /* SDL_uikitviewcontroller.m in Sources */,
|
||||
A7D8ADF223E2514100DCD162 /* SDL_blit_A.c in Sources */,
|
||||
A7D8BBDD23E2574800DCD162 /* SDL_uikitmodes.m in Sources */,
|
||||
A7D8BA3723E2514400DCD162 /* SDL_d3dmath.c in Sources */,
|
||||
F3A9AE9C2C8A13C100AAC390 /* SDL_pipeline_gpu.c in Sources */,
|
||||
75E0915A241EA924004729E1 /* SDL_virtualjoystick.c in Sources */,
|
||||
F338A11A2D1B37E4007CDFDF /* SDL_tray.c in Sources */,
|
||||
@@ -3086,7 +3082,7 @@
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
DEPLOYMENT_POSTPROCESSING = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 201.22.0;
|
||||
DYLIB_CURRENT_VERSION = 201.29.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_ALTIVEC_EXTENSIONS = YES;
|
||||
@@ -3121,7 +3117,7 @@
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
MARKETING_VERSION = 3.2.22;
|
||||
MARKETING_VERSION = 3.2.29;
|
||||
OTHER_LDFLAGS = "$(CONFIG_FRAMEWORK_LDFLAGS)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3;
|
||||
PRODUCT_NAME = SDL3;
|
||||
@@ -3138,6 +3134,8 @@
|
||||
baseConfigurationReference = F3F7BE3B2CBD79D200C984AF /* config.xcconfig */;
|
||||
buildSettings = {
|
||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
|
||||
OTHER_LDFLAGS = "-liconv";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
};
|
||||
@@ -3150,7 +3148,7 @@
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 201.22.0;
|
||||
DYLIB_CURRENT_VERSION = 201.29.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
@@ -3182,7 +3180,7 @@
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
MARKETING_VERSION = 3.2.22;
|
||||
MARKETING_VERSION = 3.2.29;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_LDFLAGS = "$(CONFIG_FRAMEWORK_LDFLAGS)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL3;
|
||||
@@ -3200,6 +3198,8 @@
|
||||
baseConfigurationReference = F3F7BE3B2CBD79D200C984AF /* config.xcconfig */;
|
||||
buildSettings = {
|
||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
|
||||
OTHER_LDFLAGS = "-liconv";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Title SDL 3.2.22
|
||||
Title SDL 3.2.29
|
||||
Version 1
|
||||
Description SDL Library for macOS (http://www.libsdl.org)
|
||||
DefaultLocation /Library/Frameworks
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# SDL3 CMake configuration file:
|
||||
# This file is meant to be placed in Resources/CMake of a SDL3 framework
|
||||
# This file is meant to be placed in Resources/CMake of a SDL3 framework for macOS,
|
||||
# or in the CMake directory of a SDL3 framework for iOS / tvOS / visionOS.
|
||||
|
||||
# INTERFACE_LINK_OPTIONS needs CMake 3.12
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.12...4.0)
|
||||
|
||||
include(FeatureSummary)
|
||||
set_package_properties(SDL3 PROPERTIES
|
||||
@@ -31,16 +32,31 @@ endmacro()
|
||||
|
||||
set(SDL3_FOUND TRUE)
|
||||
|
||||
# Compute the installation prefix relative to this file.
|
||||
set(_sdl3_framework_path "${CMAKE_CURRENT_LIST_DIR}") # > /SDL3.framework/Resources/CMake/
|
||||
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" REALPATH) # > /SDL3.framework/Versions/Current/Resources/CMake
|
||||
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" REALPATH) # > /SDL3.framework/Versions/A/Resources/CMake/
|
||||
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH) # > /SDL3.framework/Versions/A/Resources/
|
||||
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH) # > /SDL3.framework/Versions/A/
|
||||
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH) # > /SDL3.framework/Versions/
|
||||
get_filename_component(_sdl3_framework_path "${_sdl3_framework_path}" PATH) # > /SDL3.framework/
|
||||
get_filename_component(_sdl3_framework_parent_path "${_sdl3_framework_path}" PATH) # > /
|
||||
# Compute the installation prefix relative to this file:
|
||||
# search upwards for the .framework directory
|
||||
set(_current_path "${CMAKE_CURRENT_LIST_DIR}")
|
||||
get_filename_component(_current_path "${_current_path}" REALPATH)
|
||||
set(_sdl3_framework_path "")
|
||||
|
||||
while(NOT _sdl3_framework_path)
|
||||
if(IS_DIRECTORY "${_current_path}" AND "${_current_path}" MATCHES "/SDL3\\.framework$")
|
||||
set(_sdl3_framework_path "${_current_path}")
|
||||
break()
|
||||
endif()
|
||||
get_filename_component(_next_current_path "${_current_path}" DIRECTORY)
|
||||
if("${_current_path}" STREQUAL "${_next_current_path}")
|
||||
break()
|
||||
endif()
|
||||
set(_current_path "${_next_current_path}")
|
||||
endwhile()
|
||||
unset(_current_path)
|
||||
unset(_next_current_path)
|
||||
|
||||
if(NOT _sdl3_framework_path)
|
||||
message(FATAL_ERROR "Could not find SDL3.framework root from ${CMAKE_CURRENT_LIST_DIR}")
|
||||
endif()
|
||||
|
||||
get_filename_component(_sdl3_framework_parent_path "${_sdl3_framework_path}" PATH)
|
||||
|
||||
# All targets are created, even when some might not be requested though COMPONENTS.
|
||||
# This is done for compatibility with CMake generated SDL3-target.cmake files.
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
# based on the files generated by CMake's write_basic_package_version_file
|
||||
|
||||
# SDL CMake version configuration file:
|
||||
# This file is meant to be placed in Resources/CMake of a SDL3 framework
|
||||
# This file is meant to be placed in Resources/CMake of a SDL3 framework for macOS,
|
||||
# or in the CMake directory of a SDL3 framework for iOS / tvOS / visionOS.
|
||||
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
cmake_minimum_required(VERSION 3.12...4.0)
|
||||
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
|
||||
message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the Resources/CMake directory of SDL2.framework")
|
||||
# Find SDL_version.h
|
||||
set(_sdl_version_h_path "")
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
|
||||
set(_sdl_version_h_path "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h")
|
||||
elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../Headers/SDL_version.h")
|
||||
set(_sdl_version_h_path "${CMAKE_CURRENT_LIST_DIR}/../Headers/SDL_version.h")
|
||||
endif()
|
||||
|
||||
if(NOT _sdl_version_h_path)
|
||||
message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the Resources/CMake directory or the CMake directory of SDL3.framework.")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/../../Headers/SDL_version.h" _sdl_version_h)
|
||||
file(READ "${_sdl_version_h_path}" _sdl_version_h)
|
||||
string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_version_h}")
|
||||
set(_sdl_major "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}")
|
||||
@@ -21,9 +31,12 @@ if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re)
|
||||
set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}")
|
||||
else()
|
||||
message(AUTHOR_WARNING "Could not extract version from SDL_version.h.")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
unset(_sdl_version_h)
|
||||
unset(_sdl_version_h_path)
|
||||
unset(_sdl_major_re)
|
||||
unset(_sdl_major)
|
||||
unset(_sdl_minor_re)
|
||||
|
||||
@@ -16,6 +16,7 @@ set(_sdl3_version_h "${_sdl3_framework}/Headers/SDL_version.h")
|
||||
|
||||
if(NOT EXISTS "${_sdl3_version_h}")
|
||||
message(AUTHOR_WARNING "Cannot not find ${_sdl3_framework}. This script is meant to be placed in share/cmake/SDL3, next to SDL3.xcframework")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -36,6 +37,7 @@ if(_sdl_major_re AND _sdl_minor_re AND _sdl_micro_re)
|
||||
set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_micro}")
|
||||
else()
|
||||
message(AUTHOR_WARNING "Could not extract version from SDL_version.h.")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
private static final String TAG = "SDL";
|
||||
private static final int SDL_MAJOR_VERSION = 3;
|
||||
private static final int SDL_MINOR_VERSION = 2;
|
||||
private static final int SDL_MICRO_VERSION = 22;
|
||||
private static final int SDL_MICRO_VERSION = 29;
|
||||
/*
|
||||
// Display InputType.SOURCE/CLASS of events and devices
|
||||
//
|
||||
@@ -1128,6 +1128,11 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
int orientation_landscape = -1;
|
||||
int orientation_portrait = -1;
|
||||
|
||||
if (w <= 1 || h <= 1) {
|
||||
// Invalid width/height, ignore this request
|
||||
return;
|
||||
}
|
||||
|
||||
/* If set, hint "explicitly controls which UI orientations are allowed". */
|
||||
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
|
||||
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE;
|
||||
@@ -2196,7 +2201,11 @@ class SDLClipboardHandler implements
|
||||
}
|
||||
|
||||
public boolean clipboardHasText() {
|
||||
return mClipMgr.hasPrimaryClip();
|
||||
if (Build.VERSION.SDK_INT >= 28 /* Android 9 (P) */) {
|
||||
return mClipMgr.hasPrimaryClip();
|
||||
} else {
|
||||
return mClipMgr.hasText();
|
||||
}
|
||||
}
|
||||
|
||||
public String clipboardGetText() {
|
||||
@@ -2214,10 +2223,19 @@ class SDLClipboardHandler implements
|
||||
}
|
||||
|
||||
public void clipboardSetText(String string) {
|
||||
mClipMgr.removePrimaryClipChangedListener(this);
|
||||
ClipData clip = ClipData.newPlainText(null, string);
|
||||
mClipMgr.setPrimaryClip(clip);
|
||||
mClipMgr.addPrimaryClipChangedListener(this);
|
||||
mClipMgr.removePrimaryClipChangedListener(this);
|
||||
if (string.isEmpty()) {
|
||||
if (Build.VERSION.SDK_INT >= 28 /* Android 9 (P) */) {
|
||||
mClipMgr.clearPrimaryClip();
|
||||
} else {
|
||||
ClipData clip = ClipData.newPlainText(null, "");
|
||||
mClipMgr.setPrimaryClip(clip);
|
||||
}
|
||||
} else {
|
||||
ClipData clip = ClipData.newPlainText(null, string);
|
||||
mClipMgr.setPrimaryClip(clip);
|
||||
}
|
||||
mClipMgr.addPrimaryClipChangedListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.view.Display;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.PointerIcon;
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
@@ -362,6 +363,16 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent android internal NullPointerException (https://github.com/libsdl-org/SDL/issues/13306)
|
||||
@Override
|
||||
public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
|
||||
try {
|
||||
return super.onResolvePointerIcon(event, pointerIndex);
|
||||
} catch (NullPointerException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Captured pointer events for API 26.
|
||||
public boolean onCapturedPointerEvent(MotionEvent event)
|
||||
{
|
||||
|
||||
@@ -1028,6 +1028,7 @@ class Releaser:
|
||||
# NDK 21e does not support -ffile-prefix-map
|
||||
# f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
|
||||
# f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
|
||||
f"-DANDROID_USE_LEGACY_TOOLCHAIN=0",
|
||||
f"-DCMAKE_EXE_LINKER_FLAGS={extra_link_options}",
|
||||
f"-DCMAKE_SHARED_LINKER_FLAGS={extra_link_options}",
|
||||
f"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file}",
|
||||
@@ -1126,8 +1127,7 @@ class Releaser:
|
||||
for dep, depinfo in self.release_info.get("dependencies", {}).items():
|
||||
startswith = depinfo["startswith"]
|
||||
dep_repo = depinfo["repo"]
|
||||
# FIXME: dropped "--exclude-pre-releases"
|
||||
dep_string_data = self.executer.check_output(["gh", "-R", dep_repo, "release", "list", "--exclude-drafts", "--json", "name,createdAt,tagName", "--jq", f'[.[]|select(.name|startswith("{startswith}"))]|max_by(.createdAt)']).strip()
|
||||
dep_string_data = self.executer.check_output(["gh", "-R", dep_repo, "release", "list", "--exclude-drafts", "--exclude-pre-releases", "--json", "name,createdAt,tagName", "--jq", f'[.[]|select(.name|startswith("{startswith}"))]|max_by(.createdAt)']).strip()
|
||||
dep_data = json.loads(dep_string_data)
|
||||
dep_tag = dep_data["tagName"]
|
||||
dep_version = dep_data["name"]
|
||||
@@ -1517,7 +1517,7 @@ def main(argv=None) -> int:
|
||||
if args.android_home is None or not Path(args.android_home).is_dir():
|
||||
parser.error("Invalid $ANDROID_HOME or --android-home: must be a directory containing the Android SDK")
|
||||
if args.android_ndk_home is None or not Path(args.android_ndk_home).is_dir():
|
||||
parser.error("Invalid $ANDROID_NDK_HOME or --android_ndk_home: must be a directory containing the Android NDK")
|
||||
parser.error("Invalid $ANDROID_NDK_HOME or --android-ndk-home: must be a directory containing the Android NDK")
|
||||
if args.android_api is None:
|
||||
with section_printer.group("Detect Android APIS"):
|
||||
args.android_api = releaser._detect_android_api(android_home=args.android_home)
|
||||
|
||||
@@ -33,9 +33,9 @@
|
||||
#cmakedefine SDL_VENDOR_INFO "@SDL_VENDOR_INFO@"
|
||||
|
||||
#if defined(SDL_VENDOR_INFO)
|
||||
#define SDL_REVISION "@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
|
||||
#define SDL_REVISION "SDL-@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
|
||||
#else
|
||||
#define SDL_REVISION "@<@PROJECT_REVISION@>@"
|
||||
#define SDL_REVISION "SDL-@<@PROJECT_REVISION@>@"
|
||||
#endif
|
||||
|
||||
#endif /* SDL_revision_h_ */
|
||||
@@ -48,9 +48,9 @@
|
||||
*/
|
||||
#define SDL_REVISION "Some arbitrary string decided at SDL build time"
|
||||
#elif defined(SDL_VENDOR_INFO)
|
||||
#define SDL_REVISION "@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
|
||||
#define SDL_REVISION "SDL-@<@PROJECT_REVISION@>@ (" SDL_VENDOR_INFO ")"
|
||||
#else
|
||||
#define SDL_REVISION "@<@PROJECT_REVISION@>@"
|
||||
#define SDL_REVISION "SDL-@<@PROJECT_REVISION@>@"
|
||||
#endif
|
||||
|
||||
#endif /* SDL_revision_h_ */
|
||||
@@ -1,16 +1,21 @@
|
||||
# Helper for Find modules
|
||||
|
||||
function(get_flags_from_pkg_config _library _pc_prefix _out_prefix)
|
||||
if("${_library}" MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$")
|
||||
set(_cflags ${_pc_prefix}_STATIC_CFLAGS_OTHER)
|
||||
set(_link_libraries ${_pc_prefix}_STATIC_LIBRARIES)
|
||||
set(_link_options ${_pc_prefix}_STATIC_LDFLAGS_OTHER)
|
||||
set(_library_dirs ${_pc_prefix}_STATIC_LIBRARY_DIRS)
|
||||
if(MINGW)
|
||||
set(re_shared_suffix ".dll.a$")
|
||||
else()
|
||||
set(re_shared_suffix "${CMAKE_SHARED_LIBRARY_SUFFIX}$")
|
||||
endif()
|
||||
if("${_library}" MATCHES "${re_shared_suffix}")
|
||||
set(_cflags ${_pc_prefix}_CFLAGS_OTHER)
|
||||
set(_link_libraries ${_pc_prefix}_LIBRARIES)
|
||||
set(_link_options ${_pc_prefix}_LDFLAGS_OTHER)
|
||||
set(_library_dirs ${_pc_prefix}_LIBRARY_DIRS)
|
||||
else()
|
||||
set(_cflags ${_pc_prefix}_STATIC_CFLAGS_OTHER)
|
||||
set(_link_libraries ${_pc_prefix}_STATIC_LIBRARIES)
|
||||
set(_link_options ${_pc_prefix}_STATIC_LDFLAGS_OTHER)
|
||||
set(_library_dirs ${_pc_prefix}_STATIC_LIBRARY_DIRS)
|
||||
endif()
|
||||
|
||||
# The *_LIBRARIES lists always start with the library itself
|
||||
|
||||
@@ -160,3 +160,63 @@ function(SDL_AddCommonCompilerFlags TARGET)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(check_x86_source_compiles BODY VAR)
|
||||
if(ARGN)
|
||||
message(FATAL_ERROR "Unknown arguments: ${ARGN}")
|
||||
endif()
|
||||
if(APPLE_MULTIARCH AND (SDL_CPU_X86 OR SDL_CPU_X64))
|
||||
set(test_conditional 1)
|
||||
else()
|
||||
set(test_conditional 0)
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
#if ${test_conditional}
|
||||
# if defined(__i386__) || defined(__x86_64__)
|
||||
# define test_enabled 1
|
||||
# else
|
||||
# define test_enabled 0 /* feign success in Apple multi-arch configs */
|
||||
# endif
|
||||
#else /* test normally */
|
||||
# define test_enabled 1
|
||||
#endif
|
||||
#if test_enabled
|
||||
${BODY}
|
||||
#else
|
||||
int main(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return 0;
|
||||
}
|
||||
#endif" ${VAR})
|
||||
endfunction()
|
||||
|
||||
function(check_arm_source_compiles BODY VAR)
|
||||
if(ARGN)
|
||||
message(FATAL_ERROR "Unknown arguments: ${ARGN}")
|
||||
endif()
|
||||
if(APPLE_MULTIARCH AND (SDL_CPU_ARM32 OR SDL_CPU_ARM64))
|
||||
set(test_conditional 1)
|
||||
else()
|
||||
set(test_conditional 0)
|
||||
endif()
|
||||
check_c_source_compiles("
|
||||
#if ${test_conditional}
|
||||
# if defined(__arm__) || defined(__aarch64__)
|
||||
# define test_enabled 1
|
||||
# else
|
||||
# define test_enabled 0 /* feign success in Apple multi-arch configs */
|
||||
# endif
|
||||
#else /* test normally */
|
||||
# define test_enabled 1
|
||||
#endif
|
||||
#if test_enabled
|
||||
${BODY}
|
||||
#else
|
||||
int main(int argc, char *argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return 0;
|
||||
}
|
||||
#endif" ${VAR})
|
||||
endfunction()
|
||||
+3
-3
@@ -4,15 +4,15 @@ function(SDL_DetectTargetCPUArchitectures DETECTED_ARCHS)
|
||||
|
||||
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
||||
foreach(known_arch IN LISTS known_archs)
|
||||
set(SDL_CPU_${known_arch} "0")
|
||||
set(SDL_CPU_${known_arch} "0" PARENT_SCOPE)
|
||||
endforeach()
|
||||
set(detected_archs)
|
||||
foreach(osx_arch IN LISTS CMAKE_OSX_ARCHITECTURES)
|
||||
if(osx_arch STREQUAL "x86_64")
|
||||
set(SDL_CPU_X64 "1")
|
||||
set(SDL_CPU_X64 "1" PARENT_SCOPE)
|
||||
list(APPEND detected_archs "X64")
|
||||
elseif(osx_arch STREQUAL "arm64")
|
||||
set(SDL_CPU_ARM64 "1")
|
||||
set(SDL_CPU_ARM64 "1" PARENT_SCOPE)
|
||||
list(APPEND detected_archs "ARM64")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -131,7 +131,7 @@ function(sdl_compile_options)
|
||||
target_compile_options(SDL3-static ${visibility} ${escaped_opts})
|
||||
endif()
|
||||
if(NOT ARGS_NO_EXPORT AND (ARGS_PUBLIC OR ARGS_INTERFACE))
|
||||
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_COMPILE_OPTIONS "${ARGS_UNPARSED_ARGUMENTS}")
|
||||
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${ARGS_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Main include header for the SDL library, version 3.2.22
|
||||
* Main include header for the SDL library, version 3.2.29
|
||||
*
|
||||
* It is almost always best to include just this one header instead of
|
||||
* picking out individual headers included here. There are exceptions to
|
||||
|
||||
@@ -198,11 +198,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void);
|
||||
* \param mime_type the requested mime-type.
|
||||
* \param size a pointer filled in with the length of the returned data.
|
||||
* \returns a pointer to the data for the provided mime-type. Returning NULL
|
||||
* or setting the length to 0 will cause no data to be sent to the
|
||||
* "receiver". It is up to the receiver to handle this. Essentially
|
||||
* returning no data is more or less undefined behavior and may cause
|
||||
* breakage in receiving applications. The returned data will not be
|
||||
* freed, so it needs to be retained and dealt with internally.
|
||||
* or setting the length to 0 will cause zero length data to be sent
|
||||
* to the "receiver", which should be able to handle this. The
|
||||
* returned data will not be freed, so it needs to be retained and
|
||||
* dealt with internally.
|
||||
*
|
||||
* \since This function is available since SDL 3.2.0.
|
||||
*
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
|
||||
so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
|
||||
#ifdef __clang__
|
||||
#if defined(__clang__) && !SDL_HAS_BUILTIN(_m_prefetch)
|
||||
#ifndef __PRFCHWINTRIN_H
|
||||
#define __PRFCHWINTRIN_H
|
||||
static __inline__ void __attribute__((__always_inline__, __nodebug__))
|
||||
|
||||
@@ -1043,7 +1043,7 @@ typedef union SDL_Event
|
||||
} SDL_Event;
|
||||
|
||||
/* Make sure we haven't broken binary compatibility */
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NULL)->padding));
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof((SDL_static_cast(SDL_Event *, NULL))->padding));
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
@@ -2126,8 +2126,8 @@ extern "C" {
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
*
|
||||
* - "0": WGI is not used.
|
||||
* - "1": WGI is used. (default)
|
||||
* - "0": WGI is not used. (default)
|
||||
* - "1": WGI is used.
|
||||
*
|
||||
* This hint should be set before SDL is initialized.
|
||||
*
|
||||
|
||||
@@ -280,12 +280,14 @@ _m_prefetch(void *__P)
|
||||
* \sa SDL_TARGETING
|
||||
*/
|
||||
#define SDL_HAS_TARGET_ATTRIBS
|
||||
|
||||
#elif defined(__loongarch64) && defined(__GNUC__) && (__GNUC__ >= 15)
|
||||
/* LoongArch requires GCC 15+ for target attribute support */
|
||||
# define SDL_HAS_TARGET_ATTRIBS
|
||||
#elif defined(__clang__) && defined(__has_attribute)
|
||||
# if __has_attribute(target)
|
||||
# define SDL_HAS_TARGET_ATTRIBS
|
||||
# endif
|
||||
#elif defined(__GNUC__) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */
|
||||
#elif defined(__GNUC__) && !defined(__loongarch64) && (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) /* gcc >= 4.9 */
|
||||
# define SDL_HAS_TARGET_ATTRIBS
|
||||
#elif defined(__ICC) && __ICC >= 1600
|
||||
# define SDL_HAS_TARGET_ATTRIBS
|
||||
|
||||
@@ -360,7 +360,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mut
|
||||
* \sa SDL_LockMutex
|
||||
* \sa SDL_UnlockMutex
|
||||
*/
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(0, mutex);
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(true, mutex);
|
||||
|
||||
/**
|
||||
* Unlock the mutex.
|
||||
@@ -559,7 +559,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SD
|
||||
* \sa SDL_TryLockRWLockForWriting
|
||||
* \sa SDL_UnlockRWLock
|
||||
*/
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(0, rwlock);
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE_SHARED(true, rwlock);
|
||||
|
||||
/**
|
||||
* Try to lock a read/write lock _for writing_ without blocking.
|
||||
@@ -589,7 +589,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock)
|
||||
* \sa SDL_TryLockRWLockForReading
|
||||
* \sa SDL_UnlockRWLock
|
||||
*/
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(0, rwlock);
|
||||
extern SDL_DECLSPEC bool SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_TRY_ACQUIRE(true, rwlock);
|
||||
|
||||
/**
|
||||
* Unlock the read/write lock.
|
||||
|
||||
@@ -125,10 +125,10 @@ typedef struct SDL_FRect
|
||||
*/
|
||||
SDL_FORCE_INLINE void SDL_RectToFRect(const SDL_Rect *rect, SDL_FRect *frect)
|
||||
{
|
||||
frect->x = (float)rect->x;
|
||||
frect->y = (float)rect->y;
|
||||
frect->w = (float)rect->w;
|
||||
frect->h = (float)rect->h;
|
||||
frect->x = SDL_static_cast(float, rect->x);
|
||||
frect->y = SDL_static_cast(float, rect->y);
|
||||
frect->w = SDL_static_cast(float, rect->w);
|
||||
frect->h = SDL_static_cast(float, rect->h);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1164,7 +1164,7 @@ typedef struct SDL_alignment_test
|
||||
void *b;
|
||||
} SDL_alignment_test;
|
||||
SDL_COMPILE_TIME_ASSERT(struct_alignment, sizeof(SDL_alignment_test) == (2 * sizeof(void *)));
|
||||
SDL_COMPILE_TIME_ASSERT(two_s_complement, (int)~(int)0 == (int)(-1));
|
||||
SDL_COMPILE_TIME_ASSERT(two_s_complement, SDL_static_cast(int, ~SDL_static_cast(int, 0)) == SDL_static_cast(int, -1));
|
||||
#endif /* DOXYGEN_SHOULD_IGNORE_THIS */
|
||||
/** \endcond */
|
||||
|
||||
@@ -5921,7 +5921,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
|
||||
*
|
||||
* \since This macro is available since SDL 3.2.0.
|
||||
*/
|
||||
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_ucs2(S) SDL_reinterpret_cast(Uint16 *, SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1))
|
||||
|
||||
/**
|
||||
* Convert a UTF-8 string to UCS-4.
|
||||
@@ -5935,7 +5935,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
|
||||
*
|
||||
* \since This macro is available since SDL 3.2.0.
|
||||
*/
|
||||
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
|
||||
#define SDL_iconv_utf8_ucs4(S) SDL_reinterpret_cast(Uint32 *, SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1))
|
||||
|
||||
/**
|
||||
* Convert a wchar_t string to UTF-8.
|
||||
@@ -5949,7 +5949,7 @@ extern SDL_DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode,
|
||||
*
|
||||
* \since This macro is available since SDL 3.2.0.
|
||||
*/
|
||||
#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t))
|
||||
#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", SDL_reinterpret_cast(const char *, S), (SDL_wcslen(S)+1)*sizeof(wchar_t))
|
||||
|
||||
|
||||
/* force builds using Clang's static analysis tools to use literal C runtime
|
||||
|
||||
@@ -62,7 +62,7 @@ extern "C" {
|
||||
*
|
||||
* \since This macro is available since SDL 3.2.0.
|
||||
*/
|
||||
#define SDL_MICRO_VERSION 22
|
||||
#define SDL_MICRO_VERSION 29
|
||||
|
||||
/**
|
||||
* This macro turns the version numbers into a numeric value.
|
||||
|
||||
+14
-8
@@ -597,15 +597,21 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_S
|
||||
}
|
||||
|
||||
// If message truncated, allocate and re-render
|
||||
if (len >= sizeof(stack_buf) && SDL_size_add_check_overflow(len, 1, &len_plus_term)) {
|
||||
// Allocate exactly what we need, including the zero-terminator
|
||||
message = (char *)SDL_malloc(len_plus_term);
|
||||
if (!message) {
|
||||
return;
|
||||
if (len >= sizeof(stack_buf)) {
|
||||
if (SDL_size_add_check_overflow(len, 1, &len_plus_term)) {
|
||||
// Allocate exactly what we need, including the zero-terminator
|
||||
message = (char *)SDL_malloc(len_plus_term);
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
va_copy(aq, ap);
|
||||
len = SDL_vsnprintf(message, len_plus_term, fmt, aq);
|
||||
va_end(aq);
|
||||
} else {
|
||||
// Allocation would overflow, use truncated message
|
||||
message = stack_buf;
|
||||
len = sizeof(stack_buf);
|
||||
}
|
||||
va_copy(aq, ap);
|
||||
len = SDL_vsnprintf(message, len_plus_term, fmt, aq);
|
||||
va_end(aq);
|
||||
} else {
|
||||
message = stack_buf;
|
||||
}
|
||||
|
||||
@@ -1254,7 +1254,11 @@ void SDL_PlaybackAudioThreadShutdown(SDL_AudioDevice *device)
|
||||
const int frames = device->buffer_size / SDL_AUDIO_FRAMESIZE(device->spec);
|
||||
// Wait for the audio to drain if device didn't die.
|
||||
if (!SDL_GetAtomicInt(&device->zombie)) {
|
||||
SDL_Delay(((frames * 1000) / device->spec.freq) * 2);
|
||||
int delay = ((frames * 1000) / device->spec.freq) * 2;
|
||||
if (delay > 100) {
|
||||
delay = 100;
|
||||
}
|
||||
SDL_Delay(delay);
|
||||
}
|
||||
current_audio.impl.ThreadDeinit(device);
|
||||
SDL_AudioThreadFinalize(device);
|
||||
|
||||
@@ -1775,6 +1775,7 @@ static bool WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uin
|
||||
int result;
|
||||
Uint32 chunkcount = 0;
|
||||
Uint32 chunkcountlimit = 10000;
|
||||
const Sint64 flen = SDL_GetIOSize(src); // this might be -1 if the IOStream can't determine the total size.
|
||||
const char *hint;
|
||||
Sint64 RIFFstart, RIFFend, lastchunkpos;
|
||||
bool RIFFlengthknown = false;
|
||||
@@ -1883,6 +1884,14 @@ static bool WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uin
|
||||
fmtchunk = *chunk;
|
||||
}
|
||||
} else if (chunk->fourcc == DATA) {
|
||||
/* If the data chunk is bigger than the file, it might be corrupt
|
||||
or the file is truncated. Try to recover by clamping the file
|
||||
size. This also means a malicious file can't allocate 4 gigabytes
|
||||
for the chunks without actually supplying a 4 gigabyte file. */
|
||||
if ((flen > 0) && ((chunk->position + chunk->length) > flen)) {
|
||||
chunk->length = (Uint32) (flen - chunk->position);
|
||||
}
|
||||
|
||||
/* Only use the first data chunk. Handling the wavl list madness
|
||||
* may require a different approach.
|
||||
*/
|
||||
|
||||
@@ -461,8 +461,6 @@ static void ALSA_CloseDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
if (device->hidden) {
|
||||
if (device->hidden->pcm) {
|
||||
// Wait for the submitted audio to drain. ALSA_snd_pcm_drop() can hang, so don't use that.
|
||||
SDL_Delay(((device->sample_frames * 1000) / device->spec.freq) * 2);
|
||||
ALSA_snd_pcm_close(device->hidden->pcm);
|
||||
}
|
||||
SDL_free(device->hidden->mixbuf);
|
||||
|
||||
@@ -595,6 +595,71 @@ static void PulseStreamStateChangeCallback(pa_stream *stream, void *userdata)
|
||||
PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); // just signal any waiting code, it can look up the details.
|
||||
}
|
||||
|
||||
// Channel maps that match the order in SDL_Audio.h
|
||||
static const pa_channel_position_t Pulse_map_1[] = { PA_CHANNEL_POSITION_MONO };
|
||||
static const pa_channel_position_t Pulse_map_2[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT };
|
||||
|
||||
static const pa_channel_position_t Pulse_map_3[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
PA_CHANNEL_POSITION_LFE };
|
||||
|
||||
static const pa_channel_position_t Pulse_map_4[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT };
|
||||
|
||||
static const pa_channel_position_t Pulse_map_5[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
PA_CHANNEL_POSITION_LFE,
|
||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT };
|
||||
|
||||
static const pa_channel_position_t Pulse_map_6[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE,
|
||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT };
|
||||
|
||||
static const pa_channel_position_t Pulse_map_7[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE,
|
||||
PA_CHANNEL_POSITION_REAR_CENTER,
|
||||
PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT };
|
||||
|
||||
static const pa_channel_position_t Pulse_map_8[] = { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
|
||||
PA_CHANNEL_POSITION_FRONT_CENTER, PA_CHANNEL_POSITION_LFE,
|
||||
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
|
||||
PA_CHANNEL_POSITION_SIDE_LEFT, PA_CHANNEL_POSITION_SIDE_RIGHT };
|
||||
|
||||
#define COPY_CHANNEL_MAP(c) SDL_memcpy(pacmap->map, Pulse_map_##c, sizeof(Pulse_map_##c))
|
||||
|
||||
static void PulseCreateChannelMap(pa_channel_map *pacmap, uint8_t channels)
|
||||
{
|
||||
SDL_assert(channels <= PA_CHANNELS_MAX);
|
||||
|
||||
pacmap->channels = channels;
|
||||
|
||||
switch (channels) {
|
||||
case 1:
|
||||
COPY_CHANNEL_MAP(1);
|
||||
break;
|
||||
case 2:
|
||||
COPY_CHANNEL_MAP(2);
|
||||
break;
|
||||
case 3:
|
||||
COPY_CHANNEL_MAP(3);
|
||||
break;
|
||||
case 4:
|
||||
COPY_CHANNEL_MAP(4);
|
||||
break;
|
||||
case 5:
|
||||
COPY_CHANNEL_MAP(5);
|
||||
break;
|
||||
case 6:
|
||||
COPY_CHANNEL_MAP(6);
|
||||
break;
|
||||
case 7:
|
||||
COPY_CHANNEL_MAP(7);
|
||||
break;
|
||||
case 8:
|
||||
COPY_CHANNEL_MAP(8);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static bool PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
const bool recording = device->recording;
|
||||
@@ -683,9 +748,8 @@ static bool PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
|
||||
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
|
||||
|
||||
const char *name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME);
|
||||
// The SDL ALSA output hints us that we use Windows' channel mapping
|
||||
// https://bugzilla.libsdl.org/show_bug.cgi?id=110
|
||||
PULSEAUDIO_pa_channel_map_init_auto(&pacmap, device->spec.channels, PA_CHANNEL_MAP_WAVEEX);
|
||||
|
||||
PulseCreateChannelMap(&pacmap, device->spec.channels);
|
||||
|
||||
h->stream = PULSEAUDIO_pa_stream_new(
|
||||
pulseaudio_context,
|
||||
|
||||
@@ -570,7 +570,7 @@ static bool V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
|
||||
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (xioctl(fd, VIDIOC_G_PARM, &setfps) == 0) {
|
||||
if ( (setfps.parm.capture.timeperframe.denominator != spec->framerate_numerator) ||
|
||||
(setfps.parm.capture.timeperframe.numerator = spec->framerate_denominator) ) {
|
||||
(setfps.parm.capture.timeperframe.numerator != spec->framerate_denominator) ) {
|
||||
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
setfps.parm.capture.timeperframe.numerator = spec->framerate_denominator;
|
||||
setfps.parm.capture.timeperframe.denominator = spec->framerate_numerator;
|
||||
@@ -796,7 +796,7 @@ static void MaybeAddDevice(const char *path)
|
||||
const int stepw = (int) frmsizeenum.stepwise.step_width;
|
||||
const int steph = (int) frmsizeenum.stepwise.step_height;
|
||||
for (int w = minw; w <= maxw; w += stepw) {
|
||||
for (int h = minh; w <= maxh; w += steph) {
|
||||
for (int h = minh; h <= maxh; h += steph) {
|
||||
#if DEBUG_CAMERA
|
||||
SDL_Log("CAMERA: * Has %s size %dx%d", (frmsizeenum.type == V4L2_FRMSIZE_TYPE_STEPWISE) ? "stepwise" : "continuous", w, h);
|
||||
#endif
|
||||
|
||||
@@ -207,7 +207,6 @@ Sint32 JNI_OnLoad(void *vm, void *reserved)
|
||||
{
|
||||
(void)vm;
|
||||
(void)reserved;
|
||||
SDL_Unsupported();
|
||||
return -1; // JNI_ERR
|
||||
return 0x00010004; // JNI_VERSION_1_4
|
||||
}
|
||||
#endif
|
||||
@@ -1729,18 +1729,24 @@ static bool Android_JNI_ExceptionOccurred(bool silent)
|
||||
exceptionName = (jstring)(*env)->CallObjectMethod(env, exceptionClass, mid);
|
||||
exceptionNameUTF8 = (*env)->GetStringUTFChars(env, exceptionName, 0);
|
||||
|
||||
(*env)->DeleteLocalRef(env, classClass);
|
||||
|
||||
mid = (*env)->GetMethodID(env, exceptionClass, "getMessage", "()Ljava/lang/String;");
|
||||
exceptionMessage = (jstring)(*env)->CallObjectMethod(env, exception, mid);
|
||||
|
||||
(*env)->DeleteLocalRef(env, exceptionClass);
|
||||
|
||||
if (exceptionMessage != NULL) {
|
||||
const char *exceptionMessageUTF8 = (*env)->GetStringUTFChars(env, exceptionMessage, 0);
|
||||
SDL_SetError("%s: %s", exceptionNameUTF8, exceptionMessageUTF8);
|
||||
(*env)->ReleaseStringUTFChars(env, exceptionMessage, exceptionMessageUTF8);
|
||||
(*env)->DeleteLocalRef(env, exceptionMessage);
|
||||
} else {
|
||||
SDL_SetError("%s", exceptionNameUTF8);
|
||||
}
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, exceptionName, exceptionNameUTF8);
|
||||
(*env)->DeleteLocalRef(env, exceptionName);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -2164,7 +2170,7 @@ bool Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *b
|
||||
mid = (*env)->GetMethodID(env, clazz,
|
||||
"messageboxShowMessageBox", "(ILjava/lang/String;Ljava/lang/String;[I[I[Ljava/lang/String;[I)I");
|
||||
*buttonID = (*env)->CallIntMethod(env, context, mid,
|
||||
messageboxdata->flags,
|
||||
(jint)messageboxdata->flags,
|
||||
title,
|
||||
message,
|
||||
button_flags,
|
||||
@@ -2418,7 +2424,7 @@ const char *SDL_GetAndroidCachePath(void)
|
||||
// fileObj = context.getExternalFilesDir();
|
||||
mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context),
|
||||
"getCacheDir", "()Ljava/io/File;");
|
||||
fileObject = (*env)->CallObjectMethod(env, context, mid, NULL);
|
||||
fileObject = (*env)->CallObjectMethod(env, context, mid);
|
||||
if (!fileObject) {
|
||||
SDL_SetError("Couldn't get cache directory");
|
||||
LocalReferenceHolder_Cleanup(&refs);
|
||||
@@ -2768,6 +2774,7 @@ bool Android_JNI_OpenFileDialog(
|
||||
if (filters) {
|
||||
jclass stringClass = (*env)->FindClass(env, "java/lang/String");
|
||||
filtersArray = (*env)->NewObjectArray(env, nfilters, stringClass, NULL);
|
||||
(*env)->DeleteLocalRef(env, stringClass);
|
||||
|
||||
// Convert to string
|
||||
for (int i = 0; i < nfilters; i++) {
|
||||
|
||||
@@ -270,6 +270,24 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
|
||||
return result;
|
||||
#endif
|
||||
|
||||
BOOL WIN_IsWine(void)
|
||||
{
|
||||
static bool checked;
|
||||
static bool is_wine;
|
||||
|
||||
if (!checked) {
|
||||
HMODULE ntdll = LoadLibrary(TEXT("ntdll.dll"));
|
||||
if (ntdll) {
|
||||
if (GetProcAddress(ntdll, "wine_get_version") != NULL) {
|
||||
is_wine = true;
|
||||
}
|
||||
FreeLibrary(ntdll);
|
||||
}
|
||||
checked = true;
|
||||
}
|
||||
return is_wine;
|
||||
}
|
||||
|
||||
// this is the oldest thing we run on (and we may lose support for this in SDL3 at any time!),
|
||||
// so there's no "OrGreater" as that would always be TRUE. The other functions are here to
|
||||
// ask "can we support a specific feature?" but this function is here to ask "do we need to do
|
||||
|
||||
@@ -133,6 +133,9 @@ extern void WIN_CoUninitialize(void);
|
||||
extern HRESULT WIN_RoInitialize(void);
|
||||
extern void WIN_RoUninitialize(void);
|
||||
|
||||
// Returns true if we're running on Wine
|
||||
extern BOOL WIN_IsWine(void);
|
||||
|
||||
// Returns true if we're running on Windows XP (any service pack). DOES NOT CHECK XP "OR GREATER"!
|
||||
extern BOOL WIN_IsWindowsXP(void);
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,2,22,0
|
||||
PRODUCTVERSION 3,2,22,0
|
||||
FILEVERSION 3,2,29,0
|
||||
PRODUCTVERSION 3,2,29,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS 0x40004L
|
||||
@@ -23,12 +23,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "SDL\0"
|
||||
VALUE "FileVersion", "3, 2, 22, 0\0"
|
||||
VALUE "FileVersion", "3, 2, 29, 0\0"
|
||||
VALUE "InternalName", "SDL\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2025 Sam Lantinga\0"
|
||||
VALUE "OriginalFilename", "SDL3.dll\0"
|
||||
VALUE "ProductName", "Simple DirectMedia Layer\0"
|
||||
VALUE "ProductVersion", "3, 2, 22, 0\0"
|
||||
VALUE "ProductVersion", "3, 2, 29, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -1108,7 +1108,8 @@ static int SDL_PeepEventsInternal(SDL_Event *events, int numevents, SDL_EventAct
|
||||
if (action == SDL_ADDEVENT) {
|
||||
if (!events) {
|
||||
SDL_UnlockMutex(SDL_EventQ.lock);
|
||||
return SDL_InvalidParamError("events");
|
||||
SDL_InvalidParamError("events");
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < numevents; ++i) {
|
||||
used += SDL_AddEvent(&events[i]);
|
||||
@@ -1646,6 +1647,8 @@ bool SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS)
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
for (;;) {
|
||||
SDL_PumpEventsInternal(true);
|
||||
|
||||
if (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_EVENT_FIRST, SDL_EVENT_LAST) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+12
-12
@@ -333,6 +333,18 @@ bool SDL_SetKeyboardFocus(SDL_Window *window)
|
||||
}
|
||||
}
|
||||
|
||||
// See if the current window has lost focus
|
||||
if (keyboard->focus && keyboard->focus != window) {
|
||||
SDL_SendWindowEvent(keyboard->focus, SDL_EVENT_WINDOW_FOCUS_LOST, 0, 0);
|
||||
|
||||
// Ensures IME compositions are committed
|
||||
if (SDL_TextInputActive(keyboard->focus)) {
|
||||
if (video && video->StopTextInput) {
|
||||
video->StopTextInput(video, keyboard->focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (keyboard->focus && !window) {
|
||||
// We won't get anymore keyboard messages, so reset keyboard state
|
||||
SDL_ResetKeyboard();
|
||||
@@ -351,18 +363,6 @@ bool SDL_SetKeyboardFocus(SDL_Window *window)
|
||||
}
|
||||
}
|
||||
|
||||
// See if the current window has lost focus
|
||||
if (keyboard->focus && keyboard->focus != window) {
|
||||
SDL_SendWindowEvent(keyboard->focus, SDL_EVENT_WINDOW_FOCUS_LOST, 0, 0);
|
||||
|
||||
// Ensures IME compositions are committed
|
||||
if (SDL_TextInputActive(keyboard->focus)) {
|
||||
if (video && video->StopTextInput) {
|
||||
video->StopTextInput(video, keyboard->focus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keyboard->focus = window;
|
||||
|
||||
if (keyboard->focus) {
|
||||
|
||||
@@ -46,8 +46,10 @@ static bool send_foregrounding_pending = false;
|
||||
|
||||
static void SDL_HandleSIG(int sig)
|
||||
{
|
||||
// Reset the signal handler
|
||||
#ifndef HAVE_SIGACTION
|
||||
// Reset the signal handler if it was installed with signal()
|
||||
(void)signal(sig, SDL_HandleSIG);
|
||||
#endif
|
||||
|
||||
// Send a quit event next time the event loop pumps.
|
||||
// We can't send it in signal handler; SDL_malloc() might be interrupted!
|
||||
|
||||
@@ -77,9 +77,6 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
|
||||
}
|
||||
SDL_assert(SDL_ObjectValid(window, SDL_OBJECT_TYPE_WINDOW));
|
||||
|
||||
if (window->is_destroying && windowevent != SDL_EVENT_WINDOW_DESTROYED) {
|
||||
return false;
|
||||
}
|
||||
switch (windowevent) {
|
||||
case SDL_EVENT_WINDOW_SHOWN:
|
||||
if (!(window->flags & SDL_WINDOW_HIDDEN)) {
|
||||
@@ -212,6 +209,10 @@ bool SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, int data
|
||||
break;
|
||||
}
|
||||
|
||||
if (window->is_destroying && windowevent != SDL_EVENT_WINDOW_DESTROYED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Post the event, if desired
|
||||
SDL_Event event;
|
||||
event.type = windowevent;
|
||||
|
||||
@@ -61,6 +61,10 @@
|
||||
return; \
|
||||
}
|
||||
|
||||
#if 0
|
||||
// The below validation is too aggressive, since there are advanced situations
|
||||
// where this is legal. This is being temporarily disabled for further review.
|
||||
// See: https://github.com/libsdl-org/SDL/issues/13871
|
||||
#define CHECK_SAMPLER_TEXTURES \
|
||||
RenderPass *rp = (RenderPass *)render_pass; \
|
||||
for (Uint32 color_target_index = 0; color_target_index < rp->num_color_targets; color_target_index += 1) { \
|
||||
@@ -92,6 +96,10 @@
|
||||
SDL_assert_release(!"Texture cannot be simultaneously bound as a depth stencil target and a storage texture!"); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define CHECK_SAMPLER_TEXTURES
|
||||
#define CHECK_STORAGE_TEXTURES
|
||||
#endif
|
||||
|
||||
#define CHECK_GRAPHICS_PIPELINE_BOUND \
|
||||
if (!((RenderPass *)render_pass)->graphics_pipeline) { \
|
||||
@@ -1312,6 +1320,12 @@ SDL_GPUBuffer *SDL_CreateGPUBuffer(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (device->debug_mode) {
|
||||
if (createinfo->size < 4) {
|
||||
SDL_assert_release(!"Cannot create a buffer with size less than 4 bytes!");
|
||||
}
|
||||
}
|
||||
|
||||
const char *debugName = SDL_GetStringProperty(createinfo->props, SDL_PROP_GPU_BUFFER_CREATE_NAME_STRING, NULL);
|
||||
|
||||
return device->CreateBuffer(
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#define UNIFORM_BUFFER_SIZE 32768
|
||||
#define MAX_VERTEX_BUFFERS 16
|
||||
#define MAX_VERTEX_ATTRIBUTES 16
|
||||
#define MAX_COLOR_TARGET_BINDINGS 4
|
||||
#define MAX_COLOR_TARGET_BINDINGS 8
|
||||
#define MAX_PRESENT_COUNT 16
|
||||
#define MAX_FRAMES_IN_FLIGHT 3
|
||||
|
||||
|
||||
@@ -876,7 +876,7 @@ struct D3D12Renderer
|
||||
SDL_SharedObject *d3d12_dll;
|
||||
ID3D12Device *device;
|
||||
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE D3D12SerializeRootSignature_func;
|
||||
const char *semantic;
|
||||
char *semantic;
|
||||
SDL_iconv_t iconv;
|
||||
|
||||
ID3D12CommandQueue *commandQueue;
|
||||
@@ -991,6 +991,10 @@ struct D3D12CommandBuffer
|
||||
// Set at acquire time
|
||||
D3D12DescriptorHeap *gpuDescriptorHeaps[D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER + 1];
|
||||
|
||||
D3D12DescriptorHeap **usedDescriptorHeaps;
|
||||
Uint32 usedDescriptorHeapCount;
|
||||
Uint32 usedDescriptorHeapCapacity;
|
||||
|
||||
D3D12UniformBuffer **usedUniformBuffers;
|
||||
Uint32 usedUniformBufferCount;
|
||||
Uint32 usedUniformBufferCapacity;
|
||||
@@ -1588,6 +1592,7 @@ static void D3D12_INTERNAL_DestroyCommandBuffer(D3D12CommandBuffer *commandBuffe
|
||||
SDL_free(commandBuffer->usedSamplers);
|
||||
SDL_free(commandBuffer->usedGraphicsPipelines);
|
||||
SDL_free(commandBuffer->usedComputePipelines);
|
||||
SDL_free(commandBuffer->usedDescriptorHeaps);
|
||||
SDL_free(commandBuffer->usedUniformBuffers);
|
||||
SDL_free(commandBuffer->textureDownloads);
|
||||
SDL_free(commandBuffer);
|
||||
@@ -1734,6 +1739,7 @@ static void D3D12_INTERNAL_DestroyRenderer(D3D12Renderer *renderer)
|
||||
SDL_DestroyMutex(renderer->windowLock);
|
||||
SDL_DestroyMutex(renderer->fenceLock);
|
||||
SDL_DestroyMutex(renderer->disposeLock);
|
||||
SDL_free(renderer->semantic);
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
@@ -2284,6 +2290,28 @@ static bool D3D12_INTERNAL_ExpandStagingDescriptorPool(
|
||||
return true;
|
||||
}
|
||||
|
||||
static void D3D12_INTERNAL_TrackGPUDescriptorHeap(
|
||||
D3D12CommandBuffer *commandBuffer,
|
||||
D3D12DescriptorHeap *descriptorHeap)
|
||||
{
|
||||
Uint32 i;
|
||||
for (i = 0; i < commandBuffer->usedDescriptorHeapCount; i += 1) {
|
||||
if (commandBuffer->usedDescriptorHeaps[i] == descriptorHeap) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (commandBuffer->usedDescriptorHeapCount == commandBuffer->usedDescriptorHeapCapacity) {
|
||||
commandBuffer->usedDescriptorHeapCapacity += 1;
|
||||
commandBuffer->usedDescriptorHeaps = (D3D12DescriptorHeap **)SDL_realloc(
|
||||
commandBuffer->usedDescriptorHeaps,
|
||||
commandBuffer->usedDescriptorHeapCapacity * sizeof(D3D12DescriptorHeap *));
|
||||
}
|
||||
|
||||
commandBuffer->usedDescriptorHeaps[commandBuffer->usedDescriptorHeapCount] = descriptorHeap;
|
||||
commandBuffer->usedDescriptorHeapCount += 1;
|
||||
}
|
||||
|
||||
static D3D12DescriptorHeap *D3D12_INTERNAL_AcquireGPUDescriptorHeapFromPool(
|
||||
D3D12CommandBuffer *commandBuffer,
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE descriptorHeapType)
|
||||
@@ -2305,6 +2333,7 @@ static D3D12DescriptorHeap *D3D12_INTERNAL_AcquireGPUDescriptorHeapFromPool(
|
||||
}
|
||||
SDL_UnlockMutex(pool->lock);
|
||||
|
||||
D3D12_INTERNAL_TrackGPUDescriptorHeap(commandBuffer, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -5855,6 +5884,7 @@ static void D3D12_UploadToTexture(
|
||||
Uint32 alignedRowPitch;
|
||||
Uint32 rowsPerSlice = source->rows_per_layer;
|
||||
Uint32 bytesPerSlice;
|
||||
Uint32 alignedBytesPerSlice;
|
||||
bool needsRealignment;
|
||||
bool needsPlacementCopy;
|
||||
|
||||
@@ -5892,10 +5922,13 @@ static void D3D12_UploadToTexture(
|
||||
|
||||
bytesPerSlice = rowsPerSlice * rowPitch;
|
||||
|
||||
alignedRowPitch = D3D12_INTERNAL_Align(rowPitch, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
|
||||
alignedRowPitch = BytesPerRow(destination->w, textureContainer->header.info.format);
|
||||
alignedRowPitch = D3D12_INTERNAL_Align(alignedRowPitch, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
|
||||
needsRealignment = rowsPerSlice != destination->h || rowPitch != alignedRowPitch;
|
||||
needsPlacementCopy = source->offset % D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT != 0;
|
||||
|
||||
alignedBytesPerSlice = alignedRowPitch * destination->h;
|
||||
|
||||
sourceLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||
sourceLocation.PlacedFootprint.Footprint.Format = SDLToD3D12_TextureFormat[textureContainer->header.info.format];
|
||||
sourceLocation.PlacedFootprint.Footprint.RowPitch = alignedRowPitch;
|
||||
@@ -5920,22 +5953,25 @@ static void D3D12_UploadToTexture(
|
||||
|
||||
for (Uint32 sliceIndex = 0; sliceIndex < destination->d; sliceIndex += 1) {
|
||||
// copy row count minus one to avoid overread
|
||||
for (Uint32 rowIndex = 0; rowIndex < rowsPerSlice - 1; rowIndex += 1) {
|
||||
for (Uint32 rowIndex = 0; rowIndex < destination->h - 1; rowIndex += 1) {
|
||||
|
||||
SDL_memcpy(
|
||||
temporaryBuffer->mapPointer + (sliceIndex * rowsPerSlice) + (rowIndex * alignedRowPitch),
|
||||
temporaryBuffer->mapPointer + (sliceIndex * alignedBytesPerSlice) + (rowIndex * alignedRowPitch),
|
||||
transferBufferContainer->activeBuffer->mapPointer + source->offset + (sliceIndex * bytesPerSlice) + (rowIndex * rowPitch),
|
||||
alignedRowPitch);
|
||||
|
||||
}
|
||||
Uint32 offset = source->offset + (sliceIndex * bytesPerSlice) + ((rowsPerSlice - 1) * rowPitch);
|
||||
Uint32 offset = source->offset + (sliceIndex * bytesPerSlice) + ((destination->h - 1) * rowPitch);
|
||||
|
||||
SDL_memcpy(
|
||||
temporaryBuffer->mapPointer + (sliceIndex * rowsPerSlice) + ((rowsPerSlice - 1) * alignedRowPitch),
|
||||
temporaryBuffer->mapPointer + (sliceIndex * alignedBytesPerSlice) + ((destination->h - 1) * alignedRowPitch),
|
||||
transferBufferContainer->activeBuffer->mapPointer + offset,
|
||||
SDL_min(alignedRowPitch, transferBufferContainer->size - offset));
|
||||
|
||||
sourceLocation.PlacedFootprint.Footprint.Width = destination->w;
|
||||
sourceLocation.PlacedFootprint.Footprint.Height = rowsPerSlice;
|
||||
sourceLocation.PlacedFootprint.Footprint.Height = destination->h;
|
||||
sourceLocation.PlacedFootprint.Footprint.Depth = 1;
|
||||
sourceLocation.PlacedFootprint.Offset = (sliceIndex * bytesPerSlice);
|
||||
sourceLocation.PlacedFootprint.Offset = (sliceIndex * alignedBytesPerSlice);
|
||||
|
||||
ID3D12GraphicsCommandList_CopyTextureRegion(
|
||||
d3d12CommandBuffer->graphicsCommandList,
|
||||
@@ -5972,7 +6008,7 @@ static void D3D12_UploadToTexture(
|
||||
sourceLocation.PlacedFootprint.Offset = 0;
|
||||
sourceLocation.PlacedFootprint.Footprint.Width = destination->w;
|
||||
sourceLocation.PlacedFootprint.Footprint.Height = destination->h;
|
||||
sourceLocation.PlacedFootprint.Footprint.Depth = 1;
|
||||
sourceLocation.PlacedFootprint.Footprint.Depth = destination->d;
|
||||
|
||||
ID3D12GraphicsCommandList_CopyTextureRegion(
|
||||
d3d12CommandBuffer->graphicsCommandList,
|
||||
@@ -7280,6 +7316,11 @@ static bool D3D12_INTERNAL_AllocateCommandBuffer(
|
||||
commandBuffer->usedComputePipelines = (D3D12ComputePipeline **)SDL_calloc(
|
||||
commandBuffer->usedComputePipelineCapacity, sizeof(D3D12ComputePipeline *));
|
||||
|
||||
commandBuffer->usedDescriptorHeapCapacity = 4;
|
||||
commandBuffer->usedDescriptorHeapCount = 0;
|
||||
commandBuffer->usedDescriptorHeaps = (D3D12DescriptorHeap **)SDL_calloc(
|
||||
commandBuffer->usedDescriptorHeapCapacity, sizeof(D3D12DescriptorHeap *));
|
||||
|
||||
commandBuffer->usedUniformBufferCapacity = 4;
|
||||
commandBuffer->usedUniformBufferCount = 0;
|
||||
commandBuffer->usedUniformBuffers = (D3D12UniformBuffer **)SDL_calloc(
|
||||
@@ -7701,13 +7742,13 @@ static bool D3D12_INTERNAL_CleanCommandBuffer(
|
||||
NULL);
|
||||
CHECK_D3D12_ERROR_AND_RETURN("Could not reset command list", false);
|
||||
|
||||
// Return descriptor heaps to pool
|
||||
D3D12_INTERNAL_ReturnGPUDescriptorHeapToPool(
|
||||
renderer,
|
||||
commandBuffer->gpuDescriptorHeaps[D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV]);
|
||||
D3D12_INTERNAL_ReturnGPUDescriptorHeapToPool(
|
||||
renderer,
|
||||
commandBuffer->gpuDescriptorHeaps[D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER]);
|
||||
// Return descriptor heaps to pool, pools own their own locks
|
||||
for (i = 0; i < commandBuffer->usedDescriptorHeapCount; i += 1) {
|
||||
D3D12_INTERNAL_ReturnGPUDescriptorHeapToPool(
|
||||
renderer,
|
||||
commandBuffer->usedDescriptorHeaps[i]);
|
||||
}
|
||||
commandBuffer->usedDescriptorHeapCount = 0;
|
||||
|
||||
commandBuffer->gpuDescriptorHeaps[D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV] = NULL;
|
||||
commandBuffer->gpuDescriptorHeaps[D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER] = NULL;
|
||||
@@ -9179,7 +9220,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
|
||||
renderer->debug_mode = debugMode;
|
||||
renderer->allowedFramesInFlight = 2;
|
||||
|
||||
renderer->semantic = SDL_GetStringProperty(props, SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING, "TEXCOORD");
|
||||
renderer->semantic = SDL_strdup(SDL_GetStringProperty(props, SDL_PROP_GPU_DEVICE_CREATE_D3D12_SEMANTIC_NAME_STRING, "TEXCOORD"));
|
||||
|
||||
// Blit resources
|
||||
D3D12_INTERNAL_InitBlitResources(renderer);
|
||||
|
||||
@@ -1778,7 +1778,8 @@ static void METAL_UploadToTexture(
|
||||
copyFromBuffer:bufferContainer->activeBuffer->handle
|
||||
sourceOffset:source->offset
|
||||
sourceBytesPerRow:BytesPerRow(destination->w, textureContainer->header.info.format)
|
||||
sourceBytesPerImage:SDL_CalculateGPUTextureFormatSize(textureContainer->header.info.format, destination->w, destination->h, destination->d)
|
||||
// sourceBytesPerImage expects the stride between 2D images (slices) of a 3D texture, not the size of the entire region
|
||||
sourceBytesPerImage:SDL_CalculateGPUTextureFormatSize(textureContainer->header.info.format, destination->w, destination->h, 1)
|
||||
sourceSize:MTLSizeMake(destination->w, destination->h, destination->d)
|
||||
toTexture:metalTexture->handle
|
||||
destinationSlice:destination->layer
|
||||
|
||||
@@ -1143,6 +1143,7 @@ struct VulkanRenderer
|
||||
VulkanExtensions supports;
|
||||
bool supportsDebugUtils;
|
||||
bool supportsColorspace;
|
||||
bool supportsPhysicalDeviceProperties2;
|
||||
bool supportsFillModeNonSolid;
|
||||
bool supportsMultiDrawIndirect;
|
||||
|
||||
@@ -5892,7 +5893,10 @@ static VulkanTexture *VULKAN_INTERNAL_CreateTexture(
|
||||
VULKAN_TEXTURE_USAGE_MODE_UNINITIALIZED,
|
||||
texture);
|
||||
VULKAN_INTERNAL_TrackTexture(barrierCommandBuffer, texture);
|
||||
VULKAN_Submit((SDL_GPUCommandBuffer *)barrierCommandBuffer);
|
||||
if (!VULKAN_Submit((SDL_GPUCommandBuffer *)barrierCommandBuffer)) {
|
||||
VULKAN_INTERNAL_DestroyTexture(renderer, texture);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return texture;
|
||||
@@ -7165,6 +7169,8 @@ static VkRenderPass VULKAN_INTERNAL_FetchRenderPass(
|
||||
key.sampleCount = VK_SAMPLE_COUNT_1_BIT;
|
||||
if (numColorTargets > 0) {
|
||||
key.sampleCount = SDLToVK_SampleCount[((VulkanTextureContainer *)colorTargetInfos[0].texture)->header.info.sample_count];
|
||||
} else if (numColorTargets == 0 && depthStencilTargetInfo != NULL) {
|
||||
key.sampleCount = SDLToVK_SampleCount[((VulkanTextureContainer *)depthStencilTargetInfo->texture)->header.info.sample_count];
|
||||
}
|
||||
|
||||
key.numColorTargets = numColorTargets;
|
||||
@@ -7909,15 +7915,17 @@ static void VULKAN_BeginRenderPass(
|
||||
|
||||
clearValues = SDL_stack_alloc(VkClearValue, clearCount);
|
||||
|
||||
for (i = 0; i < totalColorAttachmentCount; i += 1) {
|
||||
clearValues[i].color.float32[0] = colorTargetInfos[i].clear_color.r;
|
||||
clearValues[i].color.float32[1] = colorTargetInfos[i].clear_color.g;
|
||||
clearValues[i].color.float32[2] = colorTargetInfos[i].clear_color.b;
|
||||
clearValues[i].color.float32[3] = colorTargetInfos[i].clear_color.a;
|
||||
int clearIndex = 0;
|
||||
for (i = 0; i < numColorTargets; i += 1) {
|
||||
clearValues[clearIndex].color.float32[0] = colorTargetInfos[i].clear_color.r;
|
||||
clearValues[clearIndex].color.float32[1] = colorTargetInfos[i].clear_color.g;
|
||||
clearValues[clearIndex].color.float32[2] = colorTargetInfos[i].clear_color.b;
|
||||
clearValues[clearIndex].color.float32[3] = colorTargetInfos[i].clear_color.a;
|
||||
clearIndex += 1;
|
||||
|
||||
if (colorTargetInfos[i].store_op == SDL_GPU_STOREOP_RESOLVE || colorTargetInfos[i].store_op == SDL_GPU_STOREOP_RESOLVE_AND_STORE) {
|
||||
// Skip over the resolve texture, we're not clearing it
|
||||
i += 1;
|
||||
clearIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9520,7 +9528,8 @@ static SDL_GPUCommandBuffer *VULKAN_AcquireCommandBuffer(
|
||||
VulkanCommandBuffer *commandBuffer =
|
||||
VULKAN_INTERNAL_GetInactiveCommandBufferFromPool(renderer, threadID);
|
||||
|
||||
commandBuffer->descriptorSetCache = VULKAN_INTERNAL_AcquireDescriptorSetCache(renderer);
|
||||
DescriptorSetCache *descriptorSetCache =
|
||||
VULKAN_INTERNAL_AcquireDescriptorSetCache(renderer);
|
||||
|
||||
SDL_UnlockMutex(renderer->acquireCommandBufferLock);
|
||||
|
||||
@@ -9528,6 +9537,8 @@ static SDL_GPUCommandBuffer *VULKAN_AcquireCommandBuffer(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
commandBuffer->descriptorSetCache = descriptorSetCache;
|
||||
|
||||
// Reset state
|
||||
|
||||
commandBuffer->currentComputePipeline = NULL;
|
||||
@@ -9679,6 +9690,13 @@ static bool VULKAN_INTERNAL_OnWindowResize(void *userdata, SDL_Event *e)
|
||||
data->swapchainCreateHeight = e->window.data2;
|
||||
}
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
if (e->type == SDL_EVENT_DID_ENTER_BACKGROUND) {
|
||||
data = VULKAN_INTERNAL_FetchWindowData(w);
|
||||
data->needsSwapchainRecreate = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10658,7 +10676,13 @@ static bool VULKAN_Submit(
|
||||
presentData->windowData->inFlightFences[presentData->windowData->frameCounter] = (SDL_GPUFence*)vulkanCommandBuffer->inFlightFence;
|
||||
(void)SDL_AtomicIncRef(&vulkanCommandBuffer->inFlightFence->referenceCount);
|
||||
|
||||
if (presentResult == VK_SUBOPTIMAL_KHR || presentResult == VK_ERROR_OUT_OF_DATE_KHR) {
|
||||
// On the Android platform, VK_SUBOPTIMAL_KHR is returned whenever the device is rotated. We'll just ignore this for now.
|
||||
#ifndef SDL_PLATFORM_ANDROID
|
||||
if (presentResult == VK_SUBOPTIMAL_KHR) {
|
||||
presentData->windowData->needsSwapchainRecreate = true;
|
||||
}
|
||||
#endif
|
||||
if (presentResult == VK_ERROR_OUT_OF_DATE_KHR) {
|
||||
presentData->windowData->needsSwapchainRecreate = true;
|
||||
}
|
||||
} else {
|
||||
@@ -10763,8 +10787,6 @@ static bool VULKAN_INTERNAL_DefragmentMemory(
|
||||
VulkanMemoryUsedRegion *currentRegion = allocation->usedRegions[i];
|
||||
|
||||
if (currentRegion->isBuffer && !currentRegion->vulkanBuffer->markedForDestroy) {
|
||||
currentRegion->vulkanBuffer->usage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
|
||||
VulkanBuffer *newBuffer = VULKAN_INTERNAL_CreateBuffer(
|
||||
renderer,
|
||||
currentRegion->vulkanBuffer->size,
|
||||
@@ -11036,7 +11058,8 @@ static Uint8 VULKAN_INTERNAL_CheckInstanceExtensions(
|
||||
const char **requiredExtensions,
|
||||
Uint32 requiredExtensionsLength,
|
||||
bool *supportsDebugUtils,
|
||||
bool *supportsColorspace)
|
||||
bool *supportsColorspace,
|
||||
bool *supportsPhysicalDeviceProperties2)
|
||||
{
|
||||
Uint32 extensionCount, i;
|
||||
VkExtensionProperties *availableExtensions;
|
||||
@@ -11075,6 +11098,12 @@ static Uint8 VULKAN_INTERNAL_CheckInstanceExtensions(
|
||||
availableExtensions,
|
||||
extensionCount);
|
||||
|
||||
// Only needed for KHR_driver_properties!
|
||||
*supportsPhysicalDeviceProperties2 = SupportsInstanceExtension(
|
||||
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
|
||||
availableExtensions,
|
||||
extensionCount);
|
||||
|
||||
SDL_free(availableExtensions);
|
||||
return allExtensionsSupported;
|
||||
}
|
||||
@@ -11185,10 +11214,6 @@ static Uint8 VULKAN_INTERNAL_CreateInstance(VulkanRenderer *renderer)
|
||||
instanceExtensionCount + 4);
|
||||
SDL_memcpy((void *)instanceExtensionNames, originalInstanceExtensionNames, instanceExtensionCount * sizeof(const char *));
|
||||
|
||||
// Core since 1.1
|
||||
instanceExtensionNames[instanceExtensionCount++] =
|
||||
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME;
|
||||
|
||||
#ifdef SDL_PLATFORM_APPLE
|
||||
instanceExtensionNames[instanceExtensionCount++] =
|
||||
VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME;
|
||||
@@ -11199,7 +11224,8 @@ static Uint8 VULKAN_INTERNAL_CreateInstance(VulkanRenderer *renderer)
|
||||
instanceExtensionNames,
|
||||
instanceExtensionCount,
|
||||
&renderer->supportsDebugUtils,
|
||||
&renderer->supportsColorspace)) {
|
||||
&renderer->supportsColorspace,
|
||||
&renderer->supportsPhysicalDeviceProperties2)) {
|
||||
SDL_stack_free((char *)instanceExtensionNames);
|
||||
SET_STRING_ERROR_AND_RETURN("Required Vulkan instance extensions not supported", false);
|
||||
}
|
||||
@@ -11221,6 +11247,12 @@ static Uint8 VULKAN_INTERNAL_CreateInstance(VulkanRenderer *renderer)
|
||||
VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME;
|
||||
}
|
||||
|
||||
if (renderer->supportsPhysicalDeviceProperties2) {
|
||||
// Append KHR_physical_device_properties2 extension
|
||||
instanceExtensionNames[instanceExtensionCount++] =
|
||||
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME;
|
||||
}
|
||||
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||
createInfo.pNext = NULL;
|
||||
createInfo.flags = createFlags;
|
||||
@@ -11763,7 +11795,7 @@ static SDL_GPUDevice *VULKAN_CreateDevice(bool debugMode, bool preferLowPower, S
|
||||
}
|
||||
|
||||
// FIXME: just move this into this function
|
||||
result = (SDL_GPUDevice *)SDL_malloc(sizeof(SDL_GPUDevice));
|
||||
result = (SDL_GPUDevice *)SDL_calloc(1, sizeof(SDL_GPUDevice));
|
||||
ASSIGN_DRIVER(VULKAN)
|
||||
|
||||
result->driverData = (SDL_GPURenderer *)renderer;
|
||||
|
||||
@@ -671,6 +671,8 @@ static void fill_device_info_usage(struct hid_device_info *cur_dev, libusb_devic
|
||||
|
||||
cur_dev->usage_page = page;
|
||||
cur_dev->usage = usage;
|
||||
|
||||
free(hid_report_descriptor);
|
||||
}
|
||||
|
||||
#ifdef INVASIVE_GET_USAGE
|
||||
|
||||
@@ -1399,6 +1399,11 @@ int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char
|
||||
}
|
||||
}
|
||||
if (!res) {
|
||||
if (GetLastError() == ERROR_OPERATION_ABORTED) {
|
||||
/* The read request was issued on another thread.
|
||||
This is harmless, so just ignore it. */
|
||||
return 0;
|
||||
}
|
||||
register_winapi_error(dev, L"hid_read_timeout/GetOverlappedResult");
|
||||
}
|
||||
|
||||
|
||||
@@ -455,7 +455,8 @@ static bool SDLCALL fd_flush(void *userdata, SDL_IOStatus *status)
|
||||
result = SDL_fdatasync(iodata->fd);
|
||||
} while (result < 0 && errno == EINTR);
|
||||
|
||||
if (result < 0) {
|
||||
// We get EINVAL when flushing a pipe, just make that a no-op
|
||||
if (result < 0 && errno != EINVAL) {
|
||||
return SDL_SetError("Error flushing datastream: %s", strerror(errno));
|
||||
}
|
||||
return true;
|
||||
|
||||
+74
-37
@@ -32,10 +32,11 @@
|
||||
#include "hidapi/SDL_hidapi_nintendo.h"
|
||||
#include "../events/SDL_events_c.h"
|
||||
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
#ifdef SDL_PLATFORM_WIN32
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
|
||||
// Many gamepads turn the center button into an instantaneous button press
|
||||
#define SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS 250
|
||||
|
||||
@@ -149,6 +150,51 @@ static SDL_vidpid_list SDL_ignored_gamepads = {
|
||||
false
|
||||
};
|
||||
|
||||
/*
|
||||
List of words in gamepad names that indicate that the gamepad should not be detected.
|
||||
See also `initial_blacklist_devices` in SDL_joystick.c
|
||||
*/
|
||||
|
||||
enum SDL_GamepadBlacklistWordsPosition {
|
||||
GAMEPAD_BLACKLIST_BEGIN,
|
||||
GAMEPAD_BLACKLIST_END,
|
||||
GAMEPAD_BLACKLIST_ANYWHERE,
|
||||
};
|
||||
|
||||
struct SDL_GamepadBlacklistWords {
|
||||
const char* str;
|
||||
enum SDL_GamepadBlacklistWordsPosition pos;
|
||||
};
|
||||
|
||||
static const struct SDL_GamepadBlacklistWords SDL_gamepad_blacklist_words[] = {
|
||||
#ifdef SDL_PLATFORM_LINUX
|
||||
{" Motion Sensors", GAMEPAD_BLACKLIST_END}, // Don't treat the PS3 and PS4 motion controls as a separate gamepad
|
||||
{" IMU", GAMEPAD_BLACKLIST_END}, // Don't treat the Nintendo IMU as a separate gamepad
|
||||
{" Touchpad", GAMEPAD_BLACKLIST_END}, // "Sony Interactive Entertainment DualSense Wireless Controller Touchpad"
|
||||
|
||||
// Don't treat the Wii extension controls as a separate gamepad
|
||||
{" Accelerometer", GAMEPAD_BLACKLIST_END},
|
||||
{" IR", GAMEPAD_BLACKLIST_END},
|
||||
{" Motion Plus", GAMEPAD_BLACKLIST_END},
|
||||
{" Nunchuk", GAMEPAD_BLACKLIST_END},
|
||||
#endif
|
||||
|
||||
// The Google Pixel fingerprint sensor, as well as other fingerprint sensors, reports itself as a joystick
|
||||
{"uinput-", GAMEPAD_BLACKLIST_BEGIN},
|
||||
|
||||
{"Synaptics ", GAMEPAD_BLACKLIST_ANYWHERE}, // "Synaptics TM2768-001", "SynPS/2 Synaptics TouchPad"
|
||||
{"Trackpad", GAMEPAD_BLACKLIST_ANYWHERE},
|
||||
{"Clickpad", GAMEPAD_BLACKLIST_ANYWHERE},
|
||||
// "PG-90215 Keyboard", "Usb Keyboard Usb Keyboard Consumer Control", "Framework Laptop 16 Keyboard Module - ISO System Control"
|
||||
{" Keyboard", GAMEPAD_BLACKLIST_ANYWHERE},
|
||||
{" Laptop ", GAMEPAD_BLACKLIST_ANYWHERE}, // "Framework Laptop 16 Numpad Module System Control"
|
||||
{"Mouse ", GAMEPAD_BLACKLIST_BEGIN}, // "Mouse passthrough"
|
||||
{" Pen", GAMEPAD_BLACKLIST_END}, // "Wacom One by Wacom S Pen"
|
||||
{" Finger", GAMEPAD_BLACKLIST_END}, // "Wacom HID 495F Finger"
|
||||
{" LED ", GAMEPAD_BLACKLIST_ANYWHERE}, // "ASRock LED Controller"
|
||||
{" Thelio ", GAMEPAD_BLACKLIST_ANYWHERE}, // "System76 Thelio Io 2"
|
||||
};
|
||||
|
||||
static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char *mappingString, bool *existing, SDL_GamepadMappingPriority priority);
|
||||
static void SDL_PrivateLoadButtonMapping(SDL_Gamepad *gamepad, GamepadMapping_t *pGamepadMapping);
|
||||
static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id, bool create_mapping);
|
||||
@@ -777,7 +823,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
|
||||
|
||||
if (SDL_IsJoystickSteamController(vendor, product)) {
|
||||
// Steam controllers have 2 back paddle buttons
|
||||
SDL_strlcat(mapping_string, "paddle1:b12,paddle2:b11,", sizeof(mapping_string));
|
||||
SDL_strlcat(mapping_string, "paddle1:b11,paddle2:b12,", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickNintendoSwitchPro(vendor, product) ||
|
||||
SDL_IsJoystickNintendoSwitchProInputOnly(vendor, product)) {
|
||||
// Nintendo Switch Pro controllers have a screenshot button
|
||||
@@ -1729,17 +1775,6 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char *
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
mapping = SDL_PrivateGetGamepadMappingForGUID(guid, false);
|
||||
#ifdef SDL_PLATFORM_LINUX
|
||||
if (!mapping && name) {
|
||||
if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) {
|
||||
// The Linux driver xpad.c maps the wireless dpad to buttons
|
||||
bool existing;
|
||||
mapping = SDL_PrivateAddMappingForGUID(guid,
|
||||
"none,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
&existing, SDL_GAMEPAD_MAPPING_PRIORITY_DEFAULT);
|
||||
}
|
||||
}
|
||||
#endif // SDL_PLATFORM_LINUX
|
||||
|
||||
return mapping;
|
||||
}
|
||||
@@ -2665,35 +2700,37 @@ bool SDL_IsGamepad(SDL_JoystickID instance_id)
|
||||
*/
|
||||
bool SDL_ShouldIgnoreGamepad(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
|
||||
{
|
||||
#ifdef SDL_PLATFORM_LINUX
|
||||
if (SDL_endswith(name, " Motion Sensors")) {
|
||||
// Don't treat the PS3 and PS4 motion controls as a separate gamepad
|
||||
return true;
|
||||
}
|
||||
if (SDL_strncmp(name, "Nintendo ", 9) == 0 && SDL_strstr(name, " IMU") != NULL) {
|
||||
// Don't treat the Nintendo IMU as a separate gamepad
|
||||
return true;
|
||||
}
|
||||
if (SDL_endswith(name, " Accelerometer") ||
|
||||
SDL_endswith(name, " IR") ||
|
||||
SDL_endswith(name, " Motion Plus") ||
|
||||
SDL_endswith(name, " Nunchuk")) {
|
||||
// Don't treat the Wii extension controls as a separate gamepad
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
int i;
|
||||
for (i = 0; i < SDL_arraysize(SDL_gamepad_blacklist_words); i++) {
|
||||
const struct SDL_GamepadBlacklistWords *blacklist_word = &SDL_gamepad_blacklist_words[i];
|
||||
|
||||
if (name && SDL_startswith(name, "uinput-")) {
|
||||
// The Google Pixel fingerprint sensor, as well as other fingerprint sensors, reports itself as a joystick
|
||||
return true;
|
||||
switch (blacklist_word->pos) {
|
||||
case GAMEPAD_BLACKLIST_BEGIN:
|
||||
if (SDL_startswith(name, blacklist_word->str)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case GAMEPAD_BLACKLIST_END:
|
||||
if (SDL_endswith(name, blacklist_word->str)) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case GAMEPAD_BLACKLIST_ANYWHERE:
|
||||
if (SDL_strstr(name, blacklist_word->str) != NULL) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SDL_PLATFORM_WIN32
|
||||
if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", false) &&
|
||||
SDL_GetHintBoolean("STEAM_COMPAT_PROTON", false)) {
|
||||
// We are launched by Steam and running under Proton
|
||||
WIN_IsWine()) {
|
||||
// We are launched by Steam and running under Proton or Wine
|
||||
// We can't tell whether this controller is a Steam Virtual Gamepad,
|
||||
// so assume that Proton is doing the appropriate filtering of controllers
|
||||
// so assume that is doing the appropriate filtering of controllers
|
||||
// and anything we see here is fine to use.
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -339,6 +339,7 @@ static const char *s_GamepadMappings[] = {
|
||||
"03000000172700004431000000000000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,",
|
||||
"03000000c0160000e105000000000000,Xin-Mo Dual Arcade,crc:2246,a:b1,b:b2,back:b9,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,rightshoulder:b4,righttrigger:b5,start:b8,x:b0,y:b3,", /* Ultimate Atari Fight Stick */
|
||||
"03000000790000004f18000000000000,ZD-T Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,",
|
||||
"03000000073500000400000000000000,ZENAIM ARCADE CONTROLLER,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"03000000120c0000101e000000000000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"03000000d81d00000f00000000000000,iBUFFALO BSGP1204 Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
|
||||
"03000000d81d00001000000000000000,iBUFFALO BSGP1204P Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
|
||||
@@ -481,6 +482,7 @@ static const char *s_GamepadMappings[] = {
|
||||
"030000005e040000fd02000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
|
||||
"03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,",
|
||||
"03000000c0160000e105000000040000,Xin-Mo Dual Arcade,crc:82d5,a:b2,b:b4,back:b18,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,rightshoulder:b8,righttrigger:b10,start:b16,x:b0,y:b6,", /* Ultimate Atari Fight Stick */
|
||||
"03000000073500000400000000010000,ZENAIM ARCADE CONTROLLER,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"03000000120c0000101e000000010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"03000000830500006020000000010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
@@ -502,6 +504,7 @@ static const char *s_GamepadMappings[] = {
|
||||
"06000000c82d00000020000006010000,8BitDo Pro 2 Wired Controller for Xbox,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"03000000c82d00000660000011010000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000c82d00000660000000010000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"03000000c82d00000960000011010000,8BitDo Pro 3,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,paddle1:b17,paddle2:b16,paddle3:b2,paddle4:b5,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000c82d00000061000000010000,8BitDo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000102800000900000000010000,8BitDo SFC30 Gamepad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
"05000000c82d00003028000000010000,8BitDo SFC30 Gamepad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
|
||||
@@ -537,7 +540,6 @@ static const char *s_GamepadMappings[] = {
|
||||
"03000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a2,righty:a3,start:b8,x:b2,y:b3,",
|
||||
"05000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,",
|
||||
"05000000503200000210000000000000128804098,Atari Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b2,",
|
||||
"030000005e0400008e02000047010000,Atari Xbox 360 Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"03000000c62400001b89000011010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
|
||||
"03000000d62000002a79000011010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"03000000120c0000f70e000011010000,Brook Universal Fighting Board,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:,lefty:,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:,righty:,start:b9,x:b0,y:b3,",
|
||||
@@ -627,8 +629,6 @@ static const char *s_GamepadMappings[] = {
|
||||
"03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
|
||||
"03000000780000000600000010010000,Microntek USB Joystick,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,",
|
||||
"030000005e0400000e00000000010000,Microsoft SideWinder,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b7,start:b8,x:b3,y:b4,",
|
||||
"030000005e0400008e02000004010000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e0400008e02000062230000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e040000d102000001010000,Microsoft X-Box One pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e0400008502000000010000,Microsoft X-Box pad (Japan),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,",
|
||||
@@ -743,8 +743,6 @@ static const char *s_GamepadMappings[] = {
|
||||
"03000000f025000021c1000010010000,ShanWan Gioteck PS3 Wired Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
|
||||
"03000000632500002305000010010000,ShanWan USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
|
||||
"03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,",
|
||||
"030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,",
|
||||
"03000000de2800000112000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:+a5,dpleft:-a4,dpright:+a4,dpup:-a5,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,paddle1:b15,paddle2:b16,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a3,start:b11,x:b4,y:b5,",
|
||||
"03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,",
|
||||
@@ -781,20 +779,14 @@ static const char *s_GamepadMappings[] = {
|
||||
"030000006f0e00000702000011010000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"030000000d0f0000ab01000011010000,Wireless HORIPAD For Steam,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc2:b2,misc3:b16,misc4:b17,paddle1:b19,paddle2:b18,paddle3:b15,paddle4:b5,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
|
||||
"050000000d0f00009601000091000000,Wireless HORIPAD For Steam,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc2:b2,misc3:b16,misc4:b17,paddle1:b19,paddle2:b18,paddle3:b15,paddle4:b5,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
|
||||
"030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e040000a102000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
|
||||
"0000000058626f782033363020576900,Xbox 360 Wireless Controller,a:b0,b:b1,back:b14,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,guide:b7,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,",
|
||||
"030000005e040000a102000014010000,Xbox 360 Wireless Receiver (XBOX),a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,",
|
||||
"050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
|
||||
"050000005e040000fd02000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,",
|
||||
"05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,",
|
||||
"03000000c0160000e105000010010000,Xin-Mo Dual Arcade,crc:82d5,a:b1,b:b2,back:b9,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,rightshoulder:b4,righttrigger:b5,start:b8,x:b0,y:b3,", /* Ultimate Atari Fight Stick */
|
||||
"03000000073500000400000011010000,ZENAIM ARCADE CONTROLLER,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,",
|
||||
"03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"03000000120c0000101e000011010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"03000000120c0000182e000011010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
|
||||
@@ -273,11 +273,16 @@ static Uint32 initial_blacklist_devices[] = {
|
||||
MAKE_VIDPID(0x04d9, 0x8009), // OBINLB USB-HID Keyboard (Anne Pro II)
|
||||
MAKE_VIDPID(0x04d9, 0xa292), // OBINLB USB-HID Keyboard (Anne Pro II)
|
||||
MAKE_VIDPID(0x04d9, 0xa293), // OBINLB USB-HID Keyboard (Anne Pro II)
|
||||
MAKE_VIDPID(0x04f2, 0xa13c), // HP Deluxe Webcam KQ246AA
|
||||
MAKE_VIDPID(0x1532, 0x0266), // Razer Huntsman V2 Analog, non-functional DInput device
|
||||
MAKE_VIDPID(0x1532, 0x0282), // Razer Huntsman Mini Analog, non-functional DInput device
|
||||
MAKE_VIDPID(0x26ce, 0x01a2), // ASRock LED Controller
|
||||
MAKE_VIDPID(0x20d6, 0x0002), // PowerA Enhanced Wireless Controller for Nintendo Switch (charging port only)
|
||||
MAKE_VIDPID(0x31e3, 0x1310), // Wooting 60HE (ARM)
|
||||
MAKE_VIDPID(0x3297, 0x1969), // Moonlander MK1 Keyboard
|
||||
MAKE_VIDPID(0x3434, 0x0211), // Keychron K1 Pro System Control
|
||||
MAKE_VIDPID(0x3434, 0x0353), // Keychron V5 System Control
|
||||
MAKE_VIDPID(0x3434, 0xd030), // Keychron Link
|
||||
};
|
||||
static SDL_vidpid_list blacklist_devices = {
|
||||
SDL_HINT_JOYSTICK_BLACKLIST_DEVICES, 0, 0, NULL,
|
||||
@@ -2499,7 +2504,7 @@ void SDL_UpdateJoysticks(void)
|
||||
Uint64 now;
|
||||
SDL_Joystick *joystick;
|
||||
|
||||
if (!SDL_WasInit(SDL_INIT_JOYSTICK)) {
|
||||
if (!SDL_joysticks_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#include "SDL_joystick_c.h"
|
||||
#include "SDL_steam_virtual_gamepad.h"
|
||||
|
||||
#ifdef SDL_PLATFORM_LINUX
|
||||
#include "../core/unix/SDL_appid.h"
|
||||
#endif
|
||||
#ifdef SDL_PLATFORM_WIN32
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
#else
|
||||
@@ -134,6 +137,15 @@ void SDL_InitSteamVirtualGamepadInfo(void)
|
||||
|
||||
file = SDL_GetHint(SDL_HINT_STEAM_VIRTUAL_GAMEPAD_INFO_FILE);
|
||||
if (file && *file) {
|
||||
#ifdef SDL_PLATFORM_LINUX
|
||||
// Older versions of Wine will blacklist the Steam Virtual Gamepad if
|
||||
// it appears to have the real controller's VID/PID, so ignore this.
|
||||
const char *exe = SDL_GetExeName();
|
||||
if (exe && SDL_strcmp(exe, "wine64-preloader") == 0) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "Wine launched by Steam, ignoring %s", SDL_HINT_STEAM_VIRTUAL_GAMEPAD_INFO_FILE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
SDL_steam_virtual_gamepad_info_file = SDL_strdup(file);
|
||||
}
|
||||
SDL_UpdateSteamVirtualGamepadInfo();
|
||||
|
||||
@@ -300,8 +300,14 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
|
||||
* struct, and ARC doesn't work with structs. */
|
||||
device->controller = (__bridge GCController *)CFBridgingRetain(controller);
|
||||
|
||||
if (controller.vendorName) {
|
||||
name = controller.vendorName.UTF8String;
|
||||
if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
|
||||
if (controller.productCategory) {
|
||||
name = controller.productCategory.UTF8String;
|
||||
}
|
||||
} else {
|
||||
if (controller.vendorName) {
|
||||
name = controller.vendorName.UTF8String;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
|
||||
@@ -435,7 +435,8 @@ static const ControllerDescription_t arrControllers[] = {
|
||||
{ MAKE_CONTROLLER_ID( 0x24c6, 0x592a ), k_eControllerType_XBoxOneController, NULL }, // BDA XB1 Spectra Pro
|
||||
{ MAKE_CONTROLLER_ID( 0x24c6, 0x791a ), k_eControllerType_XBoxOneController, NULL }, // PowerA Fusion Fight Pad
|
||||
{ MAKE_CONTROLLER_ID( 0x2dc8, 0x2002 ), k_eControllerType_XBoxOneController, NULL }, // 8BitDo Ultimate Wired Controller for Xbox
|
||||
{ MAKE_CONTROLLER_ID( 0x2dc8, 0x3106 ), k_eControllerType_XBoxOneController, NULL }, // 8Bitdo Ultimate Wired Controller. Windows, Android, Switch.
|
||||
{ MAKE_CONTROLLER_ID( 0x2dc8, 0x3106 ), k_eControllerType_XBoxOneController, NULL }, // 8BitDo Ultimate Wired Controller. Windows, Android, Switch.
|
||||
{ MAKE_CONTROLLER_ID( 0x2dc8, 0x310a ), k_eControllerType_XBoxOneController, NULL }, // 8BitDo Ultimate 2C Wireless Controller
|
||||
{ MAKE_CONTROLLER_ID( 0x2e24, 0x0652 ), k_eControllerType_XBoxOneController, NULL }, // Hyperkin Duke
|
||||
{ MAKE_CONTROLLER_ID( 0x2e24, 0x1618 ), k_eControllerType_XBoxOneController, NULL }, // Hyperkin Duke
|
||||
{ MAKE_CONTROLLER_ID( 0x2e24, 0x1688 ), k_eControllerType_XBoxOneController, NULL }, // Hyperkin X91
|
||||
|
||||
@@ -251,6 +251,7 @@ typedef struct
|
||||
Uint64 last_packet;
|
||||
int player_index;
|
||||
bool player_lights;
|
||||
bool enhanced_rumble;
|
||||
Uint8 rumble_left;
|
||||
Uint8 rumble_right;
|
||||
bool color_set;
|
||||
@@ -432,6 +433,14 @@ static bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
if (device->vendor_id == USB_VENDOR_SONY) {
|
||||
if (device->product_id == USB_PRODUCT_SONY_DS5_EDGE ||
|
||||
ctx->firmware_version == 0 || // Assume that it's updated firmware over Bluetooth
|
||||
ctx->firmware_version >= 0x0224) {
|
||||
ctx->enhanced_rumble = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the device capabilities
|
||||
if (device->vendor_id == USB_VENDOR_SONY) {
|
||||
ctx->sensors_supported = true;
|
||||
@@ -684,17 +693,17 @@ static bool HIDAPI_DriverPS5_UpdateEffects(SDL_DriverPS5_Context *ctx, int effec
|
||||
|
||||
if (ctx->vibration_supported) {
|
||||
if (ctx->rumble_left || ctx->rumble_right) {
|
||||
if (ctx->firmware_version < 0x0224) {
|
||||
if (ctx->enhanced_rumble) {
|
||||
effects.ucEnableBits3 |= 0x04; // Enable improved rumble emulation on 2.24 firmware and newer
|
||||
|
||||
effects.ucRumbleLeft = ctx->rumble_left;
|
||||
effects.ucRumbleRight = ctx->rumble_right;
|
||||
} else {
|
||||
effects.ucEnableBits1 |= 0x01; // Enable rumble emulation
|
||||
|
||||
// Shift to reduce effective rumble strength to match Xbox controllers
|
||||
effects.ucRumbleLeft = ctx->rumble_left >> 1;
|
||||
effects.ucRumbleRight = ctx->rumble_right >> 1;
|
||||
} else {
|
||||
effects.ucEnableBits3 |= 0x04; // Enable improved rumble emulation on 2.24 firmware and newer
|
||||
|
||||
effects.ucRumbleLeft = ctx->rumble_left;
|
||||
effects.ucRumbleRight = ctx->rumble_right;
|
||||
}
|
||||
effects.ucEnableBits1 |= 0x02; // Disable audio haptics
|
||||
} else {
|
||||
@@ -1038,6 +1047,9 @@ static bool HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *c
|
||||
if (!ctx->enhanced_mode) {
|
||||
if (application_usage) {
|
||||
HIDAPI_DriverPS5_UpdateEnhancedModeOnApplicationUsage(ctx);
|
||||
|
||||
// Wait briefly before sending additional effects
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
if (!ctx->enhanced_mode) {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#ifdef SDL_THREAD_SAFETY_ANALYSIS
|
||||
extern SDL_Mutex *SDL_HIDAPI_rumble_lock;
|
||||
#endif
|
||||
bool SDL_HIDAPI_LockRumble(void) SDL_TRY_ACQUIRE(0, SDL_HIDAPI_rumble_lock);
|
||||
bool SDL_HIDAPI_LockRumble(void) SDL_TRY_ACQUIRE(true, SDL_HIDAPI_rumble_lock);
|
||||
bool SDL_HIDAPI_GetPendingRumbleLocked(SDL_HIDAPI_Device *device, Uint8 **data, int **size, int *maximum_size);
|
||||
int SDL_HIDAPI_SendRumbleAndUnlock(SDL_HIDAPI_Device *device, const Uint8 *data, int size) SDL_RELEASE(SDL_HIDAPI_rumble_lock);
|
||||
typedef void (*SDL_HIDAPI_RumbleSentCallback)(void *userdata);
|
||||
|
||||
@@ -706,13 +706,6 @@ static void RotatePad(int *pX, int *pY, float flAngleInRad)
|
||||
*pX = (int)(SDL_cosf(flAngleInRad) * origX - SDL_sinf(flAngleInRad) * origY);
|
||||
*pY = (int)(SDL_sinf(flAngleInRad) * origX + SDL_cosf(flAngleInRad) * origY);
|
||||
}
|
||||
static void RotatePadShort(short *pX, short *pY, float flAngleInRad)
|
||||
{
|
||||
int origX = *pX, origY = *pY;
|
||||
|
||||
*pX = (short)(SDL_cosf(flAngleInRad) * origX - SDL_sinf(flAngleInRad) * origY);
|
||||
*pY = (short)(SDL_sinf(flAngleInRad) * origX + SDL_cosf(flAngleInRad) * origY);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Format the first part of the state packet
|
||||
@@ -836,9 +829,16 @@ static void FormatStatePacketUntilGyro(SteamControllerStateInternal_t *pState, V
|
||||
//---------------------------------------------------------------------------
|
||||
static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, SteamControllerStateInternal_t *pState)
|
||||
{
|
||||
const float flRotationAngle = 0.261799f;
|
||||
int nLeftPadX;
|
||||
int nLeftPadY;
|
||||
int nRightPadX;
|
||||
int nRightPadY;
|
||||
int nPadOffset;
|
||||
uint32_t ucOptionDataMask;
|
||||
|
||||
// 15 degrees in rad
|
||||
const float flRotationAngle = 0.261799f;
|
||||
|
||||
pState->unPacketNum++;
|
||||
ucOptionDataMask = (*pData++ & 0xF0);
|
||||
ucOptionDataMask |= (uint32_t)(*pData++) << 8;
|
||||
@@ -867,7 +867,6 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||
}
|
||||
if (ucOptionDataMask & k_EBLELeftTrackpadChunk) {
|
||||
int nLength = sizeof(pState->sLeftPadX) + sizeof(pState->sLeftPadY);
|
||||
int nPadOffset;
|
||||
SDL_memcpy(&pState->sLeftPadX, pData, nLength);
|
||||
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK) {
|
||||
nPadOffset = 1000;
|
||||
@@ -875,14 +874,15 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||
nPadOffset = 0;
|
||||
}
|
||||
|
||||
RotatePadShort(&pState->sLeftPadX, &pState->sLeftPadY, -flRotationAngle);
|
||||
pState->sLeftPadX = (short)clamp(pState->sLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sLeftPadY = (short)clamp(pState->sLeftPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
nLeftPadX = pState->sLeftPadX;
|
||||
nLeftPadY = pState->sLeftPadY;
|
||||
RotatePad(&nLeftPadX, &nLeftPadY, -flRotationAngle);
|
||||
pState->sLeftPadX = (short)clamp(nLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sLeftPadY = (short)clamp(nLeftPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pData += nLength;
|
||||
}
|
||||
if (ucOptionDataMask & k_EBLERightTrackpadChunk) {
|
||||
int nLength = sizeof(pState->sRightPadX) + sizeof(pState->sRightPadY);
|
||||
int nPadOffset = 0;
|
||||
|
||||
SDL_memcpy(&pState->sRightPadX, pData, nLength);
|
||||
|
||||
@@ -892,9 +892,11 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||
nPadOffset = 0;
|
||||
}
|
||||
|
||||
RotatePadShort(&pState->sRightPadX, &pState->sRightPadY, flRotationAngle);
|
||||
pState->sRightPadX = (short)clamp(pState->sRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sRightPadY = (short)clamp(pState->sRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
nRightPadX = pState->sRightPadX;
|
||||
nRightPadY = pState->sRightPadY;
|
||||
RotatePad(&nRightPadX, &nRightPadY, flRotationAngle);
|
||||
pState->sRightPadX = (short)clamp(nRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sRightPadY = (short)clamp(nRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pData += nLength;
|
||||
}
|
||||
if (ucOptionDataMask & k_EBLEIMUAccelChunk) {
|
||||
@@ -1038,6 +1040,11 @@ static bool HIDAPI_DriverSteam_IsSupportedDevice(SDL_HIDAPI_Device *device, cons
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!device) {
|
||||
// Might be supported by this driver, enumerate and find out
|
||||
return true;
|
||||
}
|
||||
|
||||
if (device->is_bluetooth) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -159,20 +159,21 @@ typedef struct
|
||||
Uint8 ucVibrationCode;
|
||||
} SwitchControllerStatePacket_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Sint16 sAccelX;
|
||||
Sint16 sAccelY;
|
||||
Sint16 sAccelZ;
|
||||
|
||||
Sint16 sGyroX;
|
||||
Sint16 sGyroY;
|
||||
Sint16 sGyroZ;
|
||||
} SwitchControllerIMUState_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SwitchControllerStatePacket_t controllerState;
|
||||
|
||||
struct
|
||||
{
|
||||
Sint16 sAccelX;
|
||||
Sint16 sAccelY;
|
||||
Sint16 sAccelZ;
|
||||
|
||||
Sint16 sGyroX;
|
||||
Sint16 sGyroY;
|
||||
Sint16 sGyroZ;
|
||||
} imuState[3];
|
||||
SwitchControllerIMUState_t imuState[3];
|
||||
} SwitchStatePacket_t;
|
||||
|
||||
typedef struct
|
||||
@@ -388,7 +389,7 @@ static int WriteOutput(SDL_DriverSwitch_Context *ctx, const Uint8 *data, int siz
|
||||
#endif // SWITCH_SYNCHRONOUS_WRITES
|
||||
}
|
||||
|
||||
static SwitchSubcommandInputPacket_t *ReadSubcommandReply(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs expectedID)
|
||||
static SwitchSubcommandInputPacket_t *ReadSubcommandReply(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs expectedID, const Uint8 *pBuf, Uint8 ucLen)
|
||||
{
|
||||
// Average response time for messages is ~30ms
|
||||
Uint64 endTicks = SDL_GetTicks() + 100;
|
||||
@@ -398,9 +399,17 @@ static SwitchSubcommandInputPacket_t *ReadSubcommandReply(SDL_DriverSwitch_Conte
|
||||
if (nRead > 0) {
|
||||
if (ctx->m_rgucReadBuffer[0] == k_eSwitchInputReportIDs_SubcommandReply) {
|
||||
SwitchSubcommandInputPacket_t *reply = (SwitchSubcommandInputPacket_t *)&ctx->m_rgucReadBuffer[1];
|
||||
if (reply->ucSubcommandID == expectedID && (reply->ucSubcommandAck & 0x80)) {
|
||||
return reply;
|
||||
if (reply->ucSubcommandID != expectedID || !(reply->ucSubcommandAck & 0x80)) {
|
||||
continue;
|
||||
}
|
||||
if (reply->ucSubcommandID == k_eSwitchSubcommandIDs_SPIFlashRead) {
|
||||
SDL_assert(ucLen == sizeof(reply->spiReadData.opData));
|
||||
if (SDL_memcmp(&reply->spiReadData.opData, pBuf, ucLen) != 0) {
|
||||
// This was a reply for another SPI read command
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
} else {
|
||||
SDL_Delay(1);
|
||||
@@ -487,7 +496,7 @@ static bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs
|
||||
continue;
|
||||
}
|
||||
|
||||
reply = ReadSubcommandReply(ctx, ucCommandID);
|
||||
reply = ReadSubcommandReply(ctx, ucCommandID, pBuf, ucLen);
|
||||
}
|
||||
|
||||
if (ppReply) {
|
||||
@@ -2589,9 +2598,14 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C
|
||||
SDL_SendJoystickPowerInfo(joystick, state, percent);
|
||||
|
||||
if (ctx->m_bReportSensors) {
|
||||
bool bHasSensorData = (packet->imuState[0].sAccelZ != 0 ||
|
||||
packet->imuState[0].sAccelY != 0 ||
|
||||
packet->imuState[0].sAccelX != 0);
|
||||
// Need to copy the imuState to an aligned variable
|
||||
SwitchControllerIMUState_t imuState[3];
|
||||
SDL_assert(sizeof(imuState) == sizeof(packet->imuState));
|
||||
SDL_memcpy(imuState, packet->imuState, sizeof(imuState));
|
||||
|
||||
bool bHasSensorData = (imuState[0].sAccelZ != 0 ||
|
||||
imuState[0].sAccelY != 0 ||
|
||||
imuState[0].sAccelX != 0);
|
||||
if (bHasSensorData) {
|
||||
const Uint32 IMU_UPDATE_RATE_SAMPLE_FREQUENCY = 1000;
|
||||
Uint64 sensor_timestamp[3];
|
||||
@@ -2620,37 +2634,37 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C
|
||||
|
||||
if (!ctx->device->parent ||
|
||||
ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) {
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO, sensor_timestamp[0], &packet->imuState[2].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL, sensor_timestamp[0], &packet->imuState[2].sAccelX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO, sensor_timestamp[0], &imuState[2].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL, sensor_timestamp[0], &imuState[2].sAccelX);
|
||||
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO, sensor_timestamp[1], &packet->imuState[1].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL, sensor_timestamp[1], &packet->imuState[1].sAccelX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO, sensor_timestamp[1], &imuState[1].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL, sensor_timestamp[1], &imuState[1].sAccelX);
|
||||
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO, sensor_timestamp[2], &packet->imuState[0].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL, sensor_timestamp[2], &packet->imuState[0].sAccelX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO, sensor_timestamp[2], &imuState[0].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL, sensor_timestamp[2], &imuState[0].sAccelX);
|
||||
}
|
||||
|
||||
if (ctx->device->parent &&
|
||||
ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft) {
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_L, sensor_timestamp[0], &packet->imuState[2].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_L, sensor_timestamp[0], &packet->imuState[2].sAccelX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_L, sensor_timestamp[0], &imuState[2].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_L, sensor_timestamp[0], &imuState[2].sAccelX);
|
||||
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_L, sensor_timestamp[1], &packet->imuState[1].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_L, sensor_timestamp[1], &packet->imuState[1].sAccelX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_L, sensor_timestamp[1], &imuState[1].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_L, sensor_timestamp[1], &imuState[1].sAccelX);
|
||||
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_L, sensor_timestamp[2], &packet->imuState[0].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_L, sensor_timestamp[2], &packet->imuState[0].sAccelX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_L, sensor_timestamp[2], &imuState[0].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_L, sensor_timestamp[2], &imuState[0].sAccelX);
|
||||
}
|
||||
if (ctx->device->parent &&
|
||||
ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) {
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_R, sensor_timestamp[0], &packet->imuState[2].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_R, sensor_timestamp[0], &packet->imuState[2].sAccelX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_R, sensor_timestamp[0], &imuState[2].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_R, sensor_timestamp[0], &imuState[2].sAccelX);
|
||||
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_R, sensor_timestamp[1], &packet->imuState[1].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_R, sensor_timestamp[1], &packet->imuState[1].sAccelX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_R, sensor_timestamp[1], &imuState[1].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_R, sensor_timestamp[1], &imuState[1].sAccelX);
|
||||
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_R, sensor_timestamp[2], &packet->imuState[0].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_R, sensor_timestamp[2], &packet->imuState[0].sAccelX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_GYRO_R, sensor_timestamp[2], &imuState[0].sGyroX);
|
||||
SendSensorUpdate(timestamp, joystick, ctx, SDL_SENSOR_ACCEL_R, sensor_timestamp[2], &imuState[0].sAccelX);
|
||||
}
|
||||
|
||||
} else if (ctx->m_bHasSensorData) {
|
||||
|
||||
@@ -150,6 +150,8 @@ typedef struct SDL_joylist_item
|
||||
{
|
||||
SDL_JoystickID device_instance;
|
||||
char *path; // "/dev/input/event2" or whatever
|
||||
Uint16 vendor;
|
||||
Uint16 product;
|
||||
char *name; // "SideWinder 3D Pro" or whatever
|
||||
SDL_GUID guid;
|
||||
dev_t devnum;
|
||||
@@ -486,6 +488,8 @@ static void MaybeAddDevice(const char *path)
|
||||
item->devnum = sb.st_rdev;
|
||||
item->steam_virtual_gamepad_slot = -1;
|
||||
item->path = SDL_strdup(path);
|
||||
item->vendor = vendor;
|
||||
item->product = product;
|
||||
item->name = name;
|
||||
item->guid = guid;
|
||||
|
||||
@@ -1844,6 +1848,20 @@ static void PollAllValues(Uint64 timestamp, SDL_Joystick *joystick)
|
||||
// Joyballs are relative input, so there's no poll state. Events only!
|
||||
}
|
||||
|
||||
static void CorrectSensorData(struct joystick_hwdata *hwdata, float *values, float *data)
|
||||
{
|
||||
if (hwdata->item->vendor == USB_VENDOR_NINTENDO) {
|
||||
// The Nintendo driver uses a different axis order than SDL
|
||||
data[0] = -values[1];
|
||||
data[1] = values[2];
|
||||
data[2] = -values[0];
|
||||
} else {
|
||||
data[0] = values[0];
|
||||
data[1] = values[1];
|
||||
data[2] = values[2];
|
||||
}
|
||||
}
|
||||
|
||||
static void PollAllSensors(Uint64 timestamp, SDL_Joystick *joystick)
|
||||
{
|
||||
struct input_absinfo absinfo;
|
||||
@@ -1854,27 +1872,31 @@ static void PollAllSensors(Uint64 timestamp, SDL_Joystick *joystick)
|
||||
SDL_assert(joystick->hwdata->fd_sensor >= 0);
|
||||
|
||||
if (joystick->hwdata->has_gyro) {
|
||||
float data[3] = {0.0f, 0.0f, 0.0f};
|
||||
float values[3] = {0.0f, 0.0f, 0.0f};
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (ioctl(joystick->hwdata->fd_sensor, EVIOCGABS(ABS_RX + i), &absinfo) >= 0) {
|
||||
data[i] = absinfo.value * (SDL_PI_F / 180.f) / joystick->hwdata->gyro_scale[i];
|
||||
values[i] = absinfo.value * (SDL_PI_F / 180.f) / joystick->hwdata->gyro_scale[i];
|
||||
#ifdef DEBUG_INPUT_EVENTS
|
||||
SDL_Log("Joystick : Re-read Gyro (axis %d) val= %f", i, data[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
float data[3];
|
||||
CorrectSensorData(joystick->hwdata, values, data);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, SDL_US_TO_NS(joystick->hwdata->sensor_tick), data, 3);
|
||||
}
|
||||
if (joystick->hwdata->has_accelerometer) {
|
||||
float data[3] = {0.0f, 0.0f, 0.0f};
|
||||
float values[3] = {0.0f, 0.0f, 0.0f};
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (ioctl(joystick->hwdata->fd_sensor, EVIOCGABS(ABS_X + i), &absinfo) >= 0) {
|
||||
data[i] = absinfo.value * SDL_STANDARD_GRAVITY / joystick->hwdata->accelerometer_scale[i];
|
||||
values[i] = absinfo.value * SDL_STANDARD_GRAVITY / joystick->hwdata->accelerometer_scale[i];
|
||||
#ifdef DEBUG_INPUT_EVENTS
|
||||
SDL_Log("Joystick : Re-read Accelerometer (axis %d) val= %f", i, data[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
float data[3];
|
||||
CorrectSensorData(joystick->hwdata, values, data);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL, SDL_US_TO_NS(joystick->hwdata->sensor_tick), data, 3);
|
||||
}
|
||||
}
|
||||
@@ -2058,12 +2080,15 @@ static void HandleInputEvents(SDL_Joystick *joystick)
|
||||
PollAllSensors(SDL_GetTicksNS(), joystick); // try to sync up to current state now
|
||||
} else {
|
||||
Uint64 timestamp = SDL_EVDEV_GetEventTimestamp(event);
|
||||
float data[3];
|
||||
CorrectSensorData(joystick->hwdata, joystick->hwdata->gyro_data, data);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO,
|
||||
SDL_US_TO_NS(joystick->hwdata->sensor_tick),
|
||||
joystick->hwdata->gyro_data, 3);
|
||||
data, 3);
|
||||
CorrectSensorData(joystick->hwdata, joystick->hwdata->accel_data, data);
|
||||
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_ACCEL,
|
||||
SDL_US_TO_NS(joystick->hwdata->sensor_tick),
|
||||
joystick->hwdata->accel_data, 3);
|
||||
data, 3);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -69,6 +69,7 @@ typedef PCWSTR(WINAPI *WindowsGetStringRawBuffer_t)(HSTRING string, UINT32 *leng
|
||||
|
||||
static struct
|
||||
{
|
||||
bool ro_initialized;
|
||||
CoIncrementMTAUsage_t CoIncrementMTAUsage;
|
||||
RoGetActivationFactory_t RoGetActivationFactory;
|
||||
WindowsCreateStringReference_t WindowsCreateStringReference;
|
||||
@@ -585,13 +586,14 @@ static bool WGI_JoystickInit(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_WGI, true)) {
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_WGI, false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (FAILED(WIN_RoInitialize())) {
|
||||
return SDL_SetError("RoInitialize() failed");
|
||||
}
|
||||
wgi.ro_initialized = true;
|
||||
|
||||
#define RESOLVE(x) wgi.x = (x##_t)WIN_LoadComBaseFunction(#x); if (!wgi.x) return WIN_SetError("GetProcAddress failed for " #x);
|
||||
RESOLVE(CoIncrementMTAUsage);
|
||||
@@ -1002,7 +1004,9 @@ static void WGI_JoystickQuit(void)
|
||||
__x_ABI_CWindows_CGaming_CInput_CIRawGameControllerStatics_Release(wgi.controller_statics);
|
||||
}
|
||||
|
||||
WIN_RoUninitialize();
|
||||
if (wgi.ro_initialized) {
|
||||
WIN_RoUninitialize();
|
||||
}
|
||||
|
||||
SDL_zero(wgi);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,17 @@ static SDLIosMainCallbacksDisplayLink *globalDisplayLink;
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(appIteration:)];
|
||||
// Enable high refresh rates on iOS
|
||||
// To enable this on phones, you should add the following line to Info.plist:
|
||||
// <key>CADisableMinimumFrameDurationOnPhone</key> <true/>
|
||||
// If main callbacks are used then this CADisplayLink will affect framerate, not one in SDL_uikitviewcontroller.
|
||||
if (@available(iOS 15.0, tvOS 15.0, *)) {
|
||||
const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(SDL_GetPrimaryDisplay());
|
||||
if (mode && mode->refresh_rate > 60.0f) {
|
||||
int frame_rate = (int)mode->refresh_rate;
|
||||
self.displayLink.preferredFrameRateRange = CAFrameRateRangeMake((frame_rate * 2) / 3, frame_rate, frame_rate);
|
||||
}
|
||||
}
|
||||
[self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
||||
}
|
||||
return self;
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.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.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#if defined(SDL_VIDEO_RENDER_D3D) || \
|
||||
defined(SDL_VIDEO_RENDER_D3D11) || \
|
||||
defined(SDL_VIDEO_RENDER_D3D12) || \
|
||||
defined(SDL_VIDEO_RENDER_VULKAN)
|
||||
|
||||
#include "SDL_d3dmath.h"
|
||||
|
||||
// Direct3D matrix math functions
|
||||
|
||||
Float4X4 MatrixIdentity(void)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = 1.0f;
|
||||
m.v._22 = 1.0f;
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2)
|
||||
{
|
||||
Float4X4 m;
|
||||
m.v._11 = M1.v._11 * M2.v._11 + M1.v._12 * M2.v._21 + M1.v._13 * M2.v._31 + M1.v._14 * M2.v._41;
|
||||
m.v._12 = M1.v._11 * M2.v._12 + M1.v._12 * M2.v._22 + M1.v._13 * M2.v._32 + M1.v._14 * M2.v._42;
|
||||
m.v._13 = M1.v._11 * M2.v._13 + M1.v._12 * M2.v._23 + M1.v._13 * M2.v._33 + M1.v._14 * M2.v._43;
|
||||
m.v._14 = M1.v._11 * M2.v._14 + M1.v._12 * M2.v._24 + M1.v._13 * M2.v._34 + M1.v._14 * M2.v._44;
|
||||
m.v._21 = M1.v._21 * M2.v._11 + M1.v._22 * M2.v._21 + M1.v._23 * M2.v._31 + M1.v._24 * M2.v._41;
|
||||
m.v._22 = M1.v._21 * M2.v._12 + M1.v._22 * M2.v._22 + M1.v._23 * M2.v._32 + M1.v._24 * M2.v._42;
|
||||
m.v._23 = M1.v._21 * M2.v._13 + M1.v._22 * M2.v._23 + M1.v._23 * M2.v._33 + M1.v._24 * M2.v._43;
|
||||
m.v._24 = M1.v._21 * M2.v._14 + M1.v._22 * M2.v._24 + M1.v._23 * M2.v._34 + M1.v._24 * M2.v._44;
|
||||
m.v._31 = M1.v._31 * M2.v._11 + M1.v._32 * M2.v._21 + M1.v._33 * M2.v._31 + M1.v._34 * M2.v._41;
|
||||
m.v._32 = M1.v._31 * M2.v._12 + M1.v._32 * M2.v._22 + M1.v._33 * M2.v._32 + M1.v._34 * M2.v._42;
|
||||
m.v._33 = M1.v._31 * M2.v._13 + M1.v._32 * M2.v._23 + M1.v._33 * M2.v._33 + M1.v._34 * M2.v._43;
|
||||
m.v._34 = M1.v._31 * M2.v._14 + M1.v._32 * M2.v._24 + M1.v._33 * M2.v._34 + M1.v._34 * M2.v._44;
|
||||
m.v._41 = M1.v._41 * M2.v._11 + M1.v._42 * M2.v._21 + M1.v._43 * M2.v._31 + M1.v._44 * M2.v._41;
|
||||
m.v._42 = M1.v._41 * M2.v._12 + M1.v._42 * M2.v._22 + M1.v._43 * M2.v._32 + M1.v._44 * M2.v._42;
|
||||
m.v._43 = M1.v._41 * M2.v._13 + M1.v._42 * M2.v._23 + M1.v._43 * M2.v._33 + M1.v._44 * M2.v._43;
|
||||
m.v._44 = M1.v._41 * M2.v._14 + M1.v._42 * M2.v._24 + M1.v._43 * M2.v._34 + M1.v._44 * M2.v._44;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixScaling(float x, float y, float z)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = x;
|
||||
m.v._22 = y;
|
||||
m.v._33 = z;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixTranslation(float x, float y, float z)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = 1.0f;
|
||||
m.v._22 = 1.0f;
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
m.v._41 = x;
|
||||
m.v._42 = y;
|
||||
m.v._43 = z;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixRotationX(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = 1.0f;
|
||||
m.v._22 = cosR;
|
||||
m.v._23 = sinR;
|
||||
m.v._32 = -sinR;
|
||||
m.v._33 = cosR;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixRotationY(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = cosR;
|
||||
m.v._13 = -sinR;
|
||||
m.v._22 = 1.0f;
|
||||
m.v._31 = sinR;
|
||||
m.v._33 = cosR;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixRotationZ(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = cosR;
|
||||
m.v._12 = sinR;
|
||||
m.v._21 = -sinR;
|
||||
m.v._22 = cosR;
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
#endif // SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12 || SDL_VIDEO_RENDER_VULKAN
|
||||
+102
-7
@@ -69,13 +69,108 @@ typedef struct
|
||||
};
|
||||
} Float4X4;
|
||||
|
||||
extern Float4X4 MatrixIdentity(void);
|
||||
extern Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
|
||||
extern Float4X4 MatrixScaling(float x, float y, float z);
|
||||
extern Float4X4 MatrixTranslation(float x, float y, float z);
|
||||
extern Float4X4 MatrixRotationX(float r);
|
||||
extern Float4X4 MatrixRotationY(float r);
|
||||
extern Float4X4 MatrixRotationZ(float r);
|
||||
static inline Float4X4 MatrixIdentity(void)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = 1.0f;
|
||||
m.v._22 = 1.0f;
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
static inline Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2)
|
||||
{
|
||||
Float4X4 m;
|
||||
m.v._11 = M1.v._11 * M2.v._11 + M1.v._12 * M2.v._21 + M1.v._13 * M2.v._31 + M1.v._14 * M2.v._41;
|
||||
m.v._12 = M1.v._11 * M2.v._12 + M1.v._12 * M2.v._22 + M1.v._13 * M2.v._32 + M1.v._14 * M2.v._42;
|
||||
m.v._13 = M1.v._11 * M2.v._13 + M1.v._12 * M2.v._23 + M1.v._13 * M2.v._33 + M1.v._14 * M2.v._43;
|
||||
m.v._14 = M1.v._11 * M2.v._14 + M1.v._12 * M2.v._24 + M1.v._13 * M2.v._34 + M1.v._14 * M2.v._44;
|
||||
m.v._21 = M1.v._21 * M2.v._11 + M1.v._22 * M2.v._21 + M1.v._23 * M2.v._31 + M1.v._24 * M2.v._41;
|
||||
m.v._22 = M1.v._21 * M2.v._12 + M1.v._22 * M2.v._22 + M1.v._23 * M2.v._32 + M1.v._24 * M2.v._42;
|
||||
m.v._23 = M1.v._21 * M2.v._13 + M1.v._22 * M2.v._23 + M1.v._23 * M2.v._33 + M1.v._24 * M2.v._43;
|
||||
m.v._24 = M1.v._21 * M2.v._14 + M1.v._22 * M2.v._24 + M1.v._23 * M2.v._34 + M1.v._24 * M2.v._44;
|
||||
m.v._31 = M1.v._31 * M2.v._11 + M1.v._32 * M2.v._21 + M1.v._33 * M2.v._31 + M1.v._34 * M2.v._41;
|
||||
m.v._32 = M1.v._31 * M2.v._12 + M1.v._32 * M2.v._22 + M1.v._33 * M2.v._32 + M1.v._34 * M2.v._42;
|
||||
m.v._33 = M1.v._31 * M2.v._13 + M1.v._32 * M2.v._23 + M1.v._33 * M2.v._33 + M1.v._34 * M2.v._43;
|
||||
m.v._34 = M1.v._31 * M2.v._14 + M1.v._32 * M2.v._24 + M1.v._33 * M2.v._34 + M1.v._34 * M2.v._44;
|
||||
m.v._41 = M1.v._41 * M2.v._11 + M1.v._42 * M2.v._21 + M1.v._43 * M2.v._31 + M1.v._44 * M2.v._41;
|
||||
m.v._42 = M1.v._41 * M2.v._12 + M1.v._42 * M2.v._22 + M1.v._43 * M2.v._32 + M1.v._44 * M2.v._42;
|
||||
m.v._43 = M1.v._41 * M2.v._13 + M1.v._42 * M2.v._23 + M1.v._43 * M2.v._33 + M1.v._44 * M2.v._43;
|
||||
m.v._44 = M1.v._41 * M2.v._14 + M1.v._42 * M2.v._24 + M1.v._43 * M2.v._34 + M1.v._44 * M2.v._44;
|
||||
return m;
|
||||
}
|
||||
|
||||
static inline Float4X4 MatrixScaling(float x, float y, float z)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = x;
|
||||
m.v._22 = y;
|
||||
m.v._33 = z;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
static inline Float4X4 MatrixTranslation(float x, float y, float z)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = 1.0f;
|
||||
m.v._22 = 1.0f;
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
m.v._41 = x;
|
||||
m.v._42 = y;
|
||||
m.v._43 = z;
|
||||
return m;
|
||||
}
|
||||
|
||||
static inline Float4X4 MatrixRotationX(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = 1.0f;
|
||||
m.v._22 = cosR;
|
||||
m.v._23 = sinR;
|
||||
m.v._32 = -sinR;
|
||||
m.v._33 = cosR;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
static inline Float4X4 MatrixRotationY(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = cosR;
|
||||
m.v._13 = -sinR;
|
||||
m.v._22 = 1.0f;
|
||||
m.v._31 = sinR;
|
||||
m.v._33 = cosR;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
static inline Float4X4 MatrixRotationZ(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = cosR;
|
||||
m.v._12 = sinR;
|
||||
m.v._21 = -sinR;
|
||||
m.v._22 = cosR;
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
// Ends C function definitions when using C++
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -2737,94 +2737,6 @@ bool SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rec
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SDL_RenderLogicalBorders(SDL_Renderer *renderer, const SDL_FRect *dst)
|
||||
{
|
||||
const SDL_RenderViewState *view = renderer->view;
|
||||
|
||||
if (dst->x > 0.0f || dst->y > 0.0f) {
|
||||
SDL_BlendMode saved_blend_mode = renderer->blendMode;
|
||||
SDL_FColor saved_color = renderer->color;
|
||||
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
|
||||
SDL_SetRenderDrawColorFloat(renderer, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (dst->x > 0.0f) {
|
||||
SDL_FRect rect;
|
||||
|
||||
rect.x = 0.0f;
|
||||
rect.y = 0.0f;
|
||||
rect.w = dst->x;
|
||||
rect.h = (float)view->pixel_h;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
rect.x = dst->x + dst->w;
|
||||
rect.w = (float)view->pixel_w - rect.x;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
if (dst->y > 0.0f) {
|
||||
SDL_FRect rect;
|
||||
|
||||
rect.x = 0.0f;
|
||||
rect.y = 0.0f;
|
||||
rect.w = (float)view->pixel_w;
|
||||
rect.h = dst->y;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
rect.y = dst->y + dst->h;
|
||||
rect.h = (float)view->pixel_h - rect.y;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawBlendMode(renderer, saved_blend_mode);
|
||||
SDL_SetRenderDrawColorFloat(renderer, saved_color.r, saved_color.g, saved_color.b, saved_color.a);
|
||||
}
|
||||
}
|
||||
|
||||
static void SDL_RenderLogicalPresentation(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_assert(renderer->view == &renderer->main_view);
|
||||
|
||||
SDL_RenderViewState *view = &renderer->main_view;
|
||||
const SDL_RendererLogicalPresentation mode = view->logical_presentation_mode;
|
||||
if (mode == SDL_LOGICAL_PRESENTATION_LETTERBOX) {
|
||||
// save off some state we're going to trample.
|
||||
const int logical_w = view->logical_w;
|
||||
const int logical_h = view->logical_h;
|
||||
const float scale_x = view->scale.x;
|
||||
const float scale_y = view->scale.y;
|
||||
const bool clipping_enabled = view->clipping_enabled;
|
||||
SDL_Rect orig_viewport, orig_cliprect;
|
||||
const SDL_FRect logical_dst_rect = view->logical_dst_rect;
|
||||
|
||||
SDL_copyp(&orig_viewport, &view->viewport);
|
||||
if (clipping_enabled) {
|
||||
SDL_copyp(&orig_cliprect, &view->clip_rect);
|
||||
}
|
||||
|
||||
// trample some state.
|
||||
SDL_SetRenderLogicalPresentation(renderer, logical_w, logical_h, SDL_LOGICAL_PRESENTATION_DISABLED);
|
||||
SDL_SetRenderViewport(renderer, NULL);
|
||||
if (clipping_enabled) {
|
||||
SDL_SetRenderClipRect(renderer, NULL);
|
||||
}
|
||||
SDL_SetRenderScale(renderer, 1.0f, 1.0f);
|
||||
|
||||
// draw the borders.
|
||||
SDL_RenderLogicalBorders(renderer, &logical_dst_rect);
|
||||
|
||||
// now set everything back.
|
||||
view->logical_presentation_mode = mode;
|
||||
SDL_SetRenderViewport(renderer, &orig_viewport);
|
||||
if (clipping_enabled) {
|
||||
SDL_SetRenderClipRect(renderer, &orig_cliprect);
|
||||
}
|
||||
SDL_SetRenderScale(renderer, scale_x, scale_y);
|
||||
|
||||
SDL_SetRenderLogicalPresentation(renderer, logical_w, logical_h, mode);
|
||||
}
|
||||
}
|
||||
|
||||
static bool SDL_RenderVectorFromWindow(SDL_Renderer *renderer, float window_dx, float window_dy, float *dx, float *dy)
|
||||
{
|
||||
// Convert from window coordinates to pixels within the window
|
||||
@@ -5136,8 +5048,6 @@ bool SDL_RenderPresent(SDL_Renderer *renderer)
|
||||
SDL_SetRenderTarget(renderer, NULL);
|
||||
}
|
||||
|
||||
SDL_RenderLogicalPresentation(renderer);
|
||||
|
||||
if (renderer->transparent_window) {
|
||||
SDL_RenderApplyWindowShape(renderer);
|
||||
}
|
||||
|
||||
@@ -620,6 +620,8 @@ static bool InitVertexBuffer(GPU_RenderData *data, Uint32 size)
|
||||
return false;
|
||||
}
|
||||
|
||||
data->vertices.buffer_size = size;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ static bool GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const
|
||||
#if 0
|
||||
#define GL_CheckError(prefix, renderer)
|
||||
#else
|
||||
#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, SDL_FILE, SDL_LINE, SDL_FUNCTION)
|
||||
#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, "SDL_render_gl.c", SDL_LINE, SDL_FUNCTION)
|
||||
#endif
|
||||
|
||||
static bool GL_LoadFunctions(GL_RenderData *data)
|
||||
@@ -439,6 +439,40 @@ static bool convert_format(Uint32 pixel_format, GLint *internalFormat, GLenum *f
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SetTextureScaleMode(GL_RenderData *data, GLenum textype, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
switch (scaleMode) {
|
||||
case SDL_SCALEMODE_NEAREST:
|
||||
data->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
data->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
break;
|
||||
case SDL_SCALEMODE_LINEAR:
|
||||
data->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
data->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
default:
|
||||
return SDL_SetError("Unknown texture scale mode: %d", scaleMode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SetTextureAddressMode(GL_RenderData *data, GLenum textype, SDL_TextureAddressMode addressMode)
|
||||
{
|
||||
switch (addressMode) {
|
||||
case SDL_TEXTURE_ADDRESS_CLAMP:
|
||||
data->glTexParameteri(textype, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
data->glTexParameteri(textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
break;
|
||||
case SDL_TEXTURE_ADDRESS_WRAP:
|
||||
data->glTexParameteri(textype, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
data->glTexParameteri(textype, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
break;
|
||||
default:
|
||||
return SDL_SetError("Unknown texture address mode: %d", addressMode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_PropertiesID create_props)
|
||||
{
|
||||
GL_RenderData *renderdata = (GL_RenderData *)renderer->internal;
|
||||
@@ -535,10 +569,12 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
|
||||
data->format = format;
|
||||
data->formattype = type;
|
||||
data->texture_scale_mode = SDL_SCALEMODE_INVALID;
|
||||
data->texture_address_mode = SDL_TEXTURE_ADDRESS_INVALID;
|
||||
data->texture_scale_mode = texture->scaleMode;
|
||||
data->texture_address_mode = SDL_TEXTURE_ADDRESS_CLAMP;
|
||||
renderdata->glEnable(textype);
|
||||
renderdata->glBindTexture(textype, data->texture);
|
||||
SetTextureScaleMode(renderdata, textype, data->texture_scale_mode);
|
||||
SetTextureAddressMode(renderdata, textype, data->texture_address_mode);
|
||||
#ifdef SDL_PLATFORM_MACOS
|
||||
#ifndef GL_TEXTURE_STORAGE_HINT_APPLE
|
||||
#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC
|
||||
@@ -570,10 +606,11 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
renderdata->glTexImage2D(textype, 0, internalFormat, texture_w,
|
||||
texture_h, 0, format, type, NULL);
|
||||
}
|
||||
renderdata->glDisable(textype);
|
||||
if (!GL_CheckError("glTexImage2D()", renderer)) {
|
||||
return false;
|
||||
}
|
||||
SetTextureScaleMode(renderdata, textype, data->texture_scale_mode);
|
||||
SetTextureAddressMode(renderdata, textype, data->texture_address_mode);
|
||||
|
||||
#ifdef SDL_HAVE_YUV
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12 ||
|
||||
@@ -596,11 +633,15 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
renderdata->glBindTexture(textype, data->utexture);
|
||||
renderdata->glTexImage2D(textype, 0, internalFormat, (texture_w + 1) / 2,
|
||||
(texture_h + 1) / 2, 0, format, type, NULL);
|
||||
SetTextureScaleMode(renderdata, textype, data->texture_scale_mode);
|
||||
SetTextureAddressMode(renderdata, textype, data->texture_address_mode);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER, data->utexture);
|
||||
|
||||
renderdata->glBindTexture(textype, data->vtexture);
|
||||
renderdata->glTexImage2D(textype, 0, internalFormat, (texture_w + 1) / 2,
|
||||
(texture_h + 1) / 2, 0, format, type, NULL);
|
||||
SetTextureScaleMode(renderdata, textype, data->texture_scale_mode);
|
||||
SetTextureAddressMode(renderdata, textype, data->texture_address_mode);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER, data->vtexture);
|
||||
}
|
||||
|
||||
@@ -617,6 +658,8 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
renderdata->glBindTexture(textype, data->utexture);
|
||||
renderdata->glTexImage2D(textype, 0, GL_LUMINANCE_ALPHA, (texture_w + 1) / 2,
|
||||
(texture_h + 1) / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||
SetTextureScaleMode(renderdata, textype, data->texture_scale_mode);
|
||||
SetTextureAddressMode(renderdata, textype, data->texture_address_mode);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER, data->utexture);
|
||||
}
|
||||
#endif
|
||||
@@ -651,6 +694,8 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
|
||||
}
|
||||
#endif // SDL_HAVE_YUV
|
||||
|
||||
renderdata->glDisable(textype);
|
||||
|
||||
return GL_CheckError("", renderer);
|
||||
}
|
||||
|
||||
@@ -1074,40 +1119,6 @@ static bool SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, cons
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SetTextureScaleMode(GL_RenderData *data, GLenum textype, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
switch (scaleMode) {
|
||||
case SDL_SCALEMODE_NEAREST:
|
||||
data->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
data->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
break;
|
||||
case SDL_SCALEMODE_LINEAR:
|
||||
data->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
data->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
break;
|
||||
default:
|
||||
return SDL_SetError("Unknown texture scale mode: %d", scaleMode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SetTextureAddressMode(GL_RenderData *data, GLenum textype, SDL_TextureAddressMode addressMode)
|
||||
{
|
||||
switch (addressMode) {
|
||||
case SDL_TEXTURE_ADDRESS_CLAMP:
|
||||
data->glTexParameteri(textype, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
data->glTexParameteri(textype, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
break;
|
||||
case SDL_TEXTURE_ADDRESS_WRAP:
|
||||
data->glTexParameteri(textype, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
data->glTexParameteri(textype, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
break;
|
||||
default:
|
||||
return SDL_SetError("Unknown texture address mode: %d", addressMode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
|
||||
@@ -252,7 +252,7 @@ static bool GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const
|
||||
#if 0
|
||||
#define GL_CheckError(prefix, renderer)
|
||||
#else
|
||||
#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, SDL_FILE, SDL_LINE, SDL_FUNCTION)
|
||||
#define GL_CheckError(prefix, renderer) GL_CheckAllErrors(prefix, renderer, "SDL_render_gles2.c", SDL_LINE, SDL_FUNCTION)
|
||||
#endif
|
||||
|
||||
/*************************************************************************************************
|
||||
@@ -1616,8 +1616,8 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
data->texture_u = 0;
|
||||
data->texture_v = 0;
|
||||
#endif
|
||||
data->texture_scale_mode = SDL_SCALEMODE_INVALID;
|
||||
data->texture_address_mode = SDL_TEXTURE_ADDRESS_INVALID;
|
||||
data->texture_scale_mode = texture->scaleMode;
|
||||
data->texture_address_mode = SDL_TEXTURE_ADDRESS_CLAMP;
|
||||
|
||||
// Allocate a blob for image renderdata
|
||||
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||
@@ -1659,6 +1659,13 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
renderdata->glActiveTexture(GL_TEXTURE2);
|
||||
renderdata->glBindTexture(data->texture_type, data->texture_v);
|
||||
renderdata->glTexImage2D(data->texture_type, 0, format, (texture->w + 1) / 2, (texture->h + 1) / 2, 0, format, type, NULL);
|
||||
if (!GL_CheckError("glTexImage2D()", renderer)) {
|
||||
SDL_free(data->pixel_data);
|
||||
SDL_free(data);
|
||||
return false;
|
||||
}
|
||||
SetTextureScaleMode(renderdata, data->texture_type, data->texture_scale_mode);
|
||||
SetTextureAddressMode(renderdata, data->texture_type, data->texture_address_mode);
|
||||
SDL_SetNumberProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER, data->texture_v);
|
||||
|
||||
data->texture_u = (GLuint)SDL_GetNumberProperty(create_props, SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER, 0);
|
||||
@@ -1680,6 +1687,8 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
SDL_free(data);
|
||||
return false;
|
||||
}
|
||||
SetTextureScaleMode(renderdata, data->texture_type, data->texture_scale_mode);
|
||||
SetTextureAddressMode(renderdata, data->texture_type, data->texture_address_mode);
|
||||
SDL_SetNumberProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER, data->texture_u);
|
||||
|
||||
if (!SDL_GetYCbCRtoRGBConversionMatrix(texture->colorspace, texture->w, texture->h, 8)) {
|
||||
@@ -1707,6 +1716,8 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
SDL_free(data);
|
||||
return false;
|
||||
}
|
||||
SetTextureScaleMode(renderdata, data->texture_type, data->texture_scale_mode);
|
||||
SetTextureAddressMode(renderdata, data->texture_type, data->texture_address_mode);
|
||||
SDL_SetNumberProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER, data->texture_u);
|
||||
|
||||
if (!SDL_GetYCbCRtoRGBConversionMatrix(texture->colorspace, texture->w, texture->h, 8)) {
|
||||
@@ -1737,6 +1748,8 @@ static bool GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
|
||||
return false;
|
||||
}
|
||||
}
|
||||
SetTextureScaleMode(renderdata, data->texture_type, data->texture_scale_mode);
|
||||
SetTextureAddressMode(renderdata, data->texture_type, data->texture_address_mode);
|
||||
SDL_SetNumberProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER, data->texture);
|
||||
SDL_SetNumberProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER, data->texture_type);
|
||||
|
||||
|
||||
@@ -113,6 +113,16 @@ static gs_rgbaq float_color_to_RGBAQ(const SDL_FColor *color, float color_scale)
|
||||
return color_to_RGBAQ(colorR, colorG, colorB, colorA, 0x00);
|
||||
}
|
||||
|
||||
static gs_rgbaq float_color_to_RGBAQ_tex(const SDL_FColor *color, float color_scale)
|
||||
{
|
||||
uint8_t colorR = (uint8_t)SDL_roundf(SDL_clamp(color->r * color_scale, 0.0f, 1.0f) * 127.0f);
|
||||
uint8_t colorG = (uint8_t)SDL_roundf(SDL_clamp(color->g * color_scale, 0.0f, 1.0f) * 127.0f);
|
||||
uint8_t colorB = (uint8_t)SDL_roundf(SDL_clamp(color->b * color_scale, 0.0f, 1.0f) * 127.0f);
|
||||
uint8_t colorA = (uint8_t)SDL_roundf(SDL_clamp(color->a, 0.0f, 1.0f) * 63.0f);
|
||||
|
||||
return color_to_RGBAQ(colorR, colorG, colorB, colorA, 0x00);
|
||||
}
|
||||
|
||||
static uint64_t float_GS_SETREG_RGBAQ(const SDL_FColor *color, float color_scale)
|
||||
{
|
||||
uint8_t colorR = (uint8_t)SDL_roundf(SDL_clamp(color->r * color_scale, 0.0f, 1.0f) * 255.0f);
|
||||
@@ -281,7 +291,7 @@ static bool PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD
|
||||
uv_ = (float *)((char *)uv + j * uv_stride);
|
||||
|
||||
vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, xy_[0] * scale_x, xy_[1] * scale_y, 0);
|
||||
vertices->rgbaq = float_color_to_RGBAQ(col_, color_scale);
|
||||
vertices->rgbaq = float_color_to_RGBAQ_tex(col_, color_scale);
|
||||
vertices->uv = vertex_to_UV(ps2_tex, uv_[0] * ps2_tex->Width, uv_[1] * ps2_tex->Height);
|
||||
|
||||
vertices++;
|
||||
|
||||
@@ -878,9 +878,11 @@ static bool SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
PrepTextureForCopy(cmd, &drawstate);
|
||||
|
||||
// Apply viewport
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
copydata->dstrect.x += drawstate.viewport->x;
|
||||
copydata->dstrect.y += drawstate.viewport->y;
|
||||
if (drawstate.viewport &&
|
||||
(drawstate.viewport->x || drawstate.viewport->y) &&
|
||||
(copydata->scale_x > 0.0f && copydata->scale_y > 0.0f)) {
|
||||
copydata->dstrect.x += (int)(drawstate.viewport->x / copydata->scale_x);
|
||||
copydata->dstrect.y += (int)(drawstate.viewport->y / copydata->scale_y);
|
||||
}
|
||||
|
||||
SW_RenderCopyEx(renderer, surface, cmd->data.draw.texture, ©data->srcrect,
|
||||
|
||||
@@ -421,7 +421,7 @@ static int VULKAN_VkFormatGetNumPlanes(VkFormat vkFormat)
|
||||
}
|
||||
}
|
||||
|
||||
static VkDeviceSize VULKAN_GetBytesPerPixel(VkFormat vkFormat)
|
||||
static VkDeviceSize VULKAN_GetBytesPerPixel(VkFormat vkFormat, int plane)
|
||||
{
|
||||
switch (vkFormat) {
|
||||
case VK_FORMAT_R8_UNORM:
|
||||
@@ -436,6 +436,10 @@ static VkDeviceSize VULKAN_GetBytesPerPixel(VkFormat vkFormat)
|
||||
return 4;
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT:
|
||||
return 8;
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
|
||||
return 1;
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
|
||||
return (plane == 0) ? 1 : 2;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
@@ -903,7 +907,7 @@ static void VULKAN_RecordPipelineImageBarrier(VULKAN_RenderData *rendererData, V
|
||||
|
||||
static VkResult VULKAN_AcquireNextSwapchainImage(SDL_Renderer *renderer)
|
||||
{
|
||||
VULKAN_RenderData *rendererData = ( VULKAN_RenderData * )renderer->internal;
|
||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||
|
||||
VkResult result;
|
||||
|
||||
@@ -911,10 +915,12 @@ static VkResult VULKAN_AcquireNextSwapchainImage(SDL_Renderer *renderer)
|
||||
result = vkAcquireNextImageKHR(rendererData->device, rendererData->swapchain, UINT64_MAX,
|
||||
rendererData->imageAvailableSemaphores[rendererData->currentCommandBufferIndex], VK_NULL_HANDLE, &rendererData->currentSwapchainImageIndex);
|
||||
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_ERROR_SURFACE_LOST_KHR) {
|
||||
result = VULKAN_CreateWindowSizeDependentResources(renderer);
|
||||
if (!(renderer->window->flags & SDL_WINDOW_MINIMIZED)) {
|
||||
result = VULKAN_CreateWindowSizeDependentResources(renderer);
|
||||
}
|
||||
return result;
|
||||
} else if(result == VK_SUBOPTIMAL_KHR) {
|
||||
// Suboptimal, but we can contiue
|
||||
// Suboptimal, but we can continue
|
||||
} else if (result != VK_SUCCESS) {
|
||||
SET_ERROR_CODE("vkAcquireNextImageKHR()", result);
|
||||
return result;
|
||||
@@ -2499,7 +2505,7 @@ static VkResult VULKAN_CreateWindowSizeDependentResources(SDL_Renderer *renderer
|
||||
|
||||
result = VULKAN_CreateSwapChain(renderer, w, h);
|
||||
if (result != VK_SUCCESS) {
|
||||
rendererData->recreateSwapchain = VK_TRUE;
|
||||
rendererData->recreateSwapchain = true;
|
||||
}
|
||||
|
||||
rendererData->viewportDirty = true;
|
||||
@@ -2549,6 +2555,13 @@ static void VULKAN_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *ev
|
||||
if (event->type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) {
|
||||
rendererData->recreateSwapchain = true;
|
||||
}
|
||||
|
||||
#ifdef SDL_PLATFORM_ANDROID
|
||||
// Prevent black screen when app returns from background
|
||||
if (event->type == SDL_EVENT_WINDOW_RESTORED) {
|
||||
VULKAN_HandleDeviceLost(renderer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool VULKAN_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
|
||||
@@ -2738,7 +2751,7 @@ static bool VULKAN_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, S
|
||||
}
|
||||
|
||||
SDL_PropertiesID props = SDL_GetTextureProperties(texture);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER, (Sint64)textureData->mainImage.image);
|
||||
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER, (Sint64)textureData->mainImage.image);
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_TARGET) {
|
||||
result = VULKAN_CreateFramebuffersAndRenderPasses(renderer,
|
||||
@@ -2811,7 +2824,7 @@ static void VULKAN_DestroyTexture(SDL_Renderer *renderer,
|
||||
|
||||
static bool VULKAN_UpdateTextureInternal(VULKAN_RenderData *rendererData, VkImage image, VkFormat format, int plane, int x, int y, int w, int h, const void *pixels, int pitch, VkImageLayout *imageLayout)
|
||||
{
|
||||
VkDeviceSize pixelSize = VULKAN_GetBytesPerPixel(format);
|
||||
VkDeviceSize pixelSize = VULKAN_GetBytesPerPixel(format, plane);
|
||||
VkDeviceSize length = w * pixelSize;
|
||||
VkDeviceSize uploadBufferSize = length * h;
|
||||
const Uint8 *src;
|
||||
@@ -2964,11 +2977,20 @@ static bool VULKAN_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 0, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 2, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
if (texture->format == SDL_PIXELFORMAT_YV12) {
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Vplane, Vpitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 2, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Uplane, Upitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Uplane, Upitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
if (!VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 2, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Vplane, Vpitch, &textureData->mainImage.imageLayout)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -3010,7 +3032,7 @@ static bool VULKAN_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
return SDL_SetError("texture is already locked");
|
||||
}
|
||||
|
||||
VkDeviceSize pixelSize = VULKAN_GetBytesPerPixel(textureData->mainImage.format);
|
||||
VkDeviceSize pixelSize = VULKAN_GetBytesPerPixel(textureData->mainImage.format, 0);
|
||||
VkDeviceSize length = rect->w * pixelSize;
|
||||
VkDeviceSize stagingBufferSize = length * rect->h;
|
||||
rc = VULKAN_AllocateBuffer(rendererData,
|
||||
@@ -3999,7 +4021,7 @@ static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Re
|
||||
vkFormat = rendererData->surfaceFormat.format;
|
||||
}
|
||||
|
||||
pixelSize = VULKAN_GetBytesPerPixel(vkFormat);
|
||||
pixelSize = VULKAN_GetBytesPerPixel(vkFormat, 0);
|
||||
length = rect->w * pixelSize;
|
||||
readbackBufferSize = length * rect->h;
|
||||
if (VULKAN_AllocateBuffer(rendererData, readbackBufferSize,
|
||||
|
||||
@@ -95,6 +95,39 @@ void _ftol2()
|
||||
_ftol();
|
||||
}
|
||||
|
||||
void __declspec(naked) _ftoul2_legacy()
|
||||
{
|
||||
static const Uint64 LLONG_MAX_PLUS_ONE = 0x43e0000000000000ULL;
|
||||
/* *INDENT-OFF* */
|
||||
__asm {
|
||||
fld qword ptr [LLONG_MAX_PLUS_ONE]
|
||||
fcom
|
||||
fnstsw ax
|
||||
test ah, 41h
|
||||
jnp greater_than_int64
|
||||
|
||||
fstp st(0)
|
||||
jmp _ftol
|
||||
|
||||
greater_than_int64:
|
||||
fsub st(1), st(0)
|
||||
fcomp
|
||||
fnstsw ax
|
||||
test ah, 41h
|
||||
jnz greater_than_uint64
|
||||
|
||||
call _ftol
|
||||
add edx, 80000000h
|
||||
ret
|
||||
|
||||
greater_than_uint64:
|
||||
xor eax, eax
|
||||
mov edx, 80000000h
|
||||
ret
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
}
|
||||
|
||||
// 64-bit math operators for 32-bit systems
|
||||
void __declspec(naked) _allmul()
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ static bool GENERIC_EnumerateStorageDirectory(void *userdata, const char *path,
|
||||
|
||||
char *fullpath = GENERIC_INTERNAL_CreateFullPath((char *)userdata, path);
|
||||
if (fullpath) {
|
||||
wrap_data.base_len = SDL_strlen((char *)userdata);
|
||||
wrap_data.base_len = userdata ? SDL_strlen((char *)userdata) : 0;
|
||||
wrap_data.real_callback = callback;
|
||||
wrap_data.real_userdata = callback_userdata;
|
||||
|
||||
|
||||
+12
-4
@@ -80,6 +80,15 @@ bool SDL_SetTLS(SDL_TLSID *id, const void *value, SDL_TLSDestructorCallback dest
|
||||
* will have the same storage index for this id.
|
||||
*/
|
||||
storage_index = SDL_GetAtomicInt(id) - 1;
|
||||
} else {
|
||||
// Make sure we don't allocate an ID clobbering this one
|
||||
int tls_id = SDL_GetAtomicInt(&SDL_tls_id);
|
||||
while (storage_index >= tls_id) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&SDL_tls_id, tls_id, storage_index + 1)) {
|
||||
break;
|
||||
}
|
||||
tls_id = SDL_GetAtomicInt(&SDL_tls_id);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the storage for the current thread
|
||||
@@ -333,7 +342,7 @@ void SDL_RunThread(SDL_Thread *thread)
|
||||
// Mark us as ready to be joined (or detached)
|
||||
if (!SDL_CompareAndSwapAtomicInt(&thread->state, SDL_THREAD_ALIVE, SDL_THREAD_COMPLETE)) {
|
||||
// Clean up if something already detached us.
|
||||
if (SDL_GetThreadState(thread) == SDL_THREAD_DETACHED) {
|
||||
if (SDL_GetAtomicInt(&thread->state) == SDL_THREAD_DETACHED) {
|
||||
SDL_free(thread->name); // Can't free later, we've already cleaned up TLS
|
||||
SDL_free(thread);
|
||||
}
|
||||
@@ -487,11 +496,10 @@ void SDL_DetachThread(SDL_Thread *thread)
|
||||
return;
|
||||
}
|
||||
|
||||
// The thread may vanish at any time, it's no longer valid
|
||||
SDL_SetObjectValid(thread, SDL_OBJECT_TYPE_THREAD, false);
|
||||
|
||||
// Grab dibs if the state is alive+joinable.
|
||||
if (SDL_CompareAndSwapAtomicInt(&thread->state, SDL_THREAD_ALIVE, SDL_THREAD_DETACHED)) {
|
||||
// The thread may vanish at any time, it's no longer valid
|
||||
SDL_SetObjectValid(thread, SDL_OBJECT_TYPE_THREAD, false);
|
||||
SDL_SYS_DetachThread(thread);
|
||||
} else {
|
||||
// all other states are pretty final, see where we landed.
|
||||
|
||||
@@ -1434,6 +1434,7 @@ bool SDL_RLESurface(SDL_Surface *surface)
|
||||
|
||||
// The surface is now accelerated
|
||||
surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||
SDL_UpdateSurfaceLockFlag(surface);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1565,11 +1566,12 @@ void SDL_UnRLESurface(SDL_Surface *surface, bool recode)
|
||||
}
|
||||
}
|
||||
}
|
||||
surface->map.info.flags &=
|
||||
~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY);
|
||||
surface->map.info.flags &= ~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY);
|
||||
|
||||
SDL_free(surface->map.data);
|
||||
surface->map.data = NULL;
|
||||
|
||||
SDL_UpdateSurfaceLockFlag(surface);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-7
@@ -64,17 +64,26 @@ static bool SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect,
|
||||
SDL_BlitInfo *info = &src->map.info;
|
||||
|
||||
// Set up the blit information
|
||||
info->src = (Uint8 *)src->pixels +
|
||||
(Uint16)srcrect->y * src->pitch +
|
||||
(Uint16)srcrect->x * info->src_fmt->bytes_per_pixel;
|
||||
if (info->src_fmt->bits_per_pixel >= 8) {
|
||||
info->src = (Uint8 *)src->pixels +
|
||||
srcrect->y * src->pitch +
|
||||
srcrect->x * info->src_fmt->bytes_per_pixel;
|
||||
} else {
|
||||
info->src = (Uint8 *)src->pixels +
|
||||
srcrect->y * src->pitch +
|
||||
(srcrect->x * info->src_fmt->bits_per_pixel) / 8;
|
||||
info->leading_skip =
|
||||
((srcrect->x * info->src_fmt->bits_per_pixel) % 8) /
|
||||
info->src_fmt->bits_per_pixel;
|
||||
}
|
||||
info->src_w = srcrect->w;
|
||||
info->src_h = srcrect->h;
|
||||
info->src_pitch = src->pitch;
|
||||
info->src_skip =
|
||||
info->src_pitch - info->src_w * info->src_fmt->bytes_per_pixel;
|
||||
info->dst =
|
||||
(Uint8 *)dst->pixels + (Uint16)dstrect->y * dst->pitch +
|
||||
(Uint16)dstrect->x * info->dst_fmt->bytes_per_pixel;
|
||||
info->dst = (Uint8 *)dst->pixels +
|
||||
dstrect->y * dst->pitch +
|
||||
dstrect->x * info->dst_fmt->bytes_per_pixel;
|
||||
info->dst_w = dstrect->w;
|
||||
info->dst_h = dstrect->h;
|
||||
info->dst_pitch = dst->pitch;
|
||||
@@ -191,7 +200,7 @@ bool SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst)
|
||||
|
||||
#ifdef SDL_HAVE_RLE
|
||||
// Clean everything out to start
|
||||
if (surface->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||
if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||
SDL_UnRLESurface(surface, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -60,6 +60,7 @@ typedef struct
|
||||
int src_w, src_h;
|
||||
int src_pitch;
|
||||
int src_skip;
|
||||
int leading_skip;
|
||||
SDL_Surface *dst_surface;
|
||||
Uint8 *dst;
|
||||
int dst_w, dst_h;
|
||||
|
||||
+188
-30
@@ -45,6 +45,8 @@ SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
dstskip = info->dst_skip;
|
||||
map = info->table;
|
||||
|
||||
width += info->leading_skip;
|
||||
|
||||
if (srcbpp == 4)
|
||||
srcskip += width - (width + 1) / 2;
|
||||
else if (srcbpp == 2)
|
||||
@@ -56,7 +58,13 @@ SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -73,7 +81,13 @@ SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -92,7 +106,13 @@ SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -109,7 +129,13 @@ SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -147,6 +173,8 @@ SDL_FORCE_INLINE void BlitBto2(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
dstskip = info->dst_skip / 2;
|
||||
map = (Uint16 *)info->table;
|
||||
|
||||
width += info->leading_skip;
|
||||
|
||||
if (srcbpp == 4)
|
||||
srcskip += width - (width + 1) / 2;
|
||||
else if (srcbpp == 2)
|
||||
@@ -157,7 +185,13 @@ SDL_FORCE_INLINE void BlitBto2(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -174,7 +208,13 @@ SDL_FORCE_INLINE void BlitBto2(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -210,6 +250,8 @@ SDL_FORCE_INLINE void BlitBto3(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
dstskip = info->dst_skip;
|
||||
map = info->table;
|
||||
|
||||
width += info->leading_skip;
|
||||
|
||||
if (srcbpp == 4)
|
||||
srcskip += width - (width + 1) / 2;
|
||||
else if (srcbpp == 2)
|
||||
@@ -220,7 +262,13 @@ SDL_FORCE_INLINE void BlitBto3(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -240,7 +288,13 @@ SDL_FORCE_INLINE void BlitBto3(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -280,6 +334,8 @@ SDL_FORCE_INLINE void BlitBto4(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
dstskip = info->dst_skip / 4;
|
||||
map = (Uint32 *)info->table;
|
||||
|
||||
width += info->leading_skip;
|
||||
|
||||
if (srcbpp == 4)
|
||||
srcskip += width - (width + 1) / 2;
|
||||
else if (srcbpp == 2)
|
||||
@@ -290,7 +346,13 @@ SDL_FORCE_INLINE void BlitBto4(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -307,7 +369,13 @@ SDL_FORCE_INLINE void BlitBto4(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -339,7 +407,8 @@ SDL_FORCE_INLINE void BlitBto1Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
Uint8 *palmap = info->table;
|
||||
int c;
|
||||
|
||||
// Set up some basic variables
|
||||
width += info->leading_skip;
|
||||
|
||||
if (srcbpp == 4)
|
||||
srcskip += width - (width + 1) / 2;
|
||||
else if (srcbpp == 2)
|
||||
@@ -351,7 +420,13 @@ SDL_FORCE_INLINE void BlitBto1Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -368,7 +443,13 @@ SDL_FORCE_INLINE void BlitBto1Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -387,7 +468,13 @@ SDL_FORCE_INLINE void BlitBto1Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -404,7 +491,13 @@ SDL_FORCE_INLINE void BlitBto1Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -437,7 +530,8 @@ SDL_FORCE_INLINE void BlitBto2Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
Uint8 *palmap = info->table;
|
||||
int c;
|
||||
|
||||
// Set up some basic variables
|
||||
width += info->leading_skip;
|
||||
|
||||
if (srcbpp == 4)
|
||||
srcskip += width - (width + 1) / 2;
|
||||
else if (srcbpp == 2)
|
||||
@@ -449,7 +543,13 @@ SDL_FORCE_INLINE void BlitBto2Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -466,7 +566,13 @@ SDL_FORCE_INLINE void BlitBto2Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -498,7 +604,8 @@ SDL_FORCE_INLINE void BlitBto3Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
Uint8 *palmap = info->table;
|
||||
int c;
|
||||
|
||||
// Set up some basic variables
|
||||
width += info->leading_skip;
|
||||
|
||||
if (srcbpp == 4)
|
||||
srcskip += width - (width + 1) / 2;
|
||||
else if (srcbpp == 2)
|
||||
@@ -509,7 +616,13 @@ SDL_FORCE_INLINE void BlitBto3Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -526,7 +639,13 @@ SDL_FORCE_INLINE void BlitBto3Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -558,7 +677,8 @@ SDL_FORCE_INLINE void BlitBto4Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
Uint8 *palmap = info->table;
|
||||
int c;
|
||||
|
||||
// Set up some basic variables
|
||||
width += info->leading_skip;
|
||||
|
||||
if (srcbpp == 4)
|
||||
srcskip += width - (width + 1) / 2;
|
||||
else if (srcbpp == 2)
|
||||
@@ -570,7 +690,13 @@ SDL_FORCE_INLINE void BlitBto4Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -587,7 +713,13 @@ SDL_FORCE_INLINE void BlitBto4Key(SDL_BlitInfo *info, const Uint32 srcbpp)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -622,7 +754,8 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
||||
unsigned dR, dG, dB, dA;
|
||||
const unsigned A = info->a;
|
||||
|
||||
// Set up some basic variables
|
||||
width += info->leading_skip;
|
||||
|
||||
srcbpp = srcfmt->bytes_per_pixel;
|
||||
dstbpp = dstfmt->bytes_per_pixel;
|
||||
if (srcbpp == 4)
|
||||
@@ -637,7 +770,13 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -659,7 +798,13 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -700,7 +845,8 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
||||
const unsigned A = info->a;
|
||||
Uint32 ckey = info->colorkey;
|
||||
|
||||
// Set up some basic variables
|
||||
width += info->leading_skip;
|
||||
|
||||
srcbpp = srcfmt->bytes_per_pixel;
|
||||
dstbpp = dstfmt->bytes_per_pixel;
|
||||
if (srcbpp == 4)
|
||||
@@ -715,7 +861,13 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
||||
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte >>= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
@@ -737,7 +889,13 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
|
||||
} else {
|
||||
while (height--) {
|
||||
Uint8 byte = 0, bit;
|
||||
for (c = 0; c < width; ++c) {
|
||||
for (c = 0; c < info->leading_skip; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
byte <<= srcbpp;
|
||||
}
|
||||
for (; c < width; ++c) {
|
||||
if (!(c & align)) {
|
||||
byte = *src++;
|
||||
}
|
||||
|
||||
+104
-2
@@ -242,6 +242,103 @@ static void SDL_TARGETING("sse2") Blit888to888SurfaceAlphaSSE2(SDL_BlitInfo *inf
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SDL_LSX_INTRINSICS
|
||||
|
||||
static void SDL_TARGETING("lsx") Blit8888to8888PixelAlphaSwizzleLSX(SDL_BlitInfo *info)
|
||||
{
|
||||
int width = info->dst_w;
|
||||
int height = info->dst_h;
|
||||
Uint8 *src = info->src;
|
||||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
bool fill_alpha = !dstfmt->Amask;
|
||||
Uint32 dstAmask, dstAshift;
|
||||
const Uint8 offsets[] = {0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 8, 8, 12, 12, 12, 12};
|
||||
|
||||
SDL_Get8888AlphaMaskAndShift(dstfmt, &dstAmask, &dstAshift);
|
||||
|
||||
const __m128i const_0xff00 = __lsx_vreplgr2vr_h(0xff00);
|
||||
const __m128i const_128 = __lsx_vreplgr2vr_b((Uint8)128);
|
||||
const __m128i const_32641 = __lsx_vreplgr2vr_h(32641);
|
||||
const __m128i const_257 = __lsx_vreplgr2vr_h(257);
|
||||
|
||||
// The byte offsets for the start of each pixel
|
||||
const __m128i mask_offsets = __lsx_vld(offsets, 0);
|
||||
|
||||
const __m128i convert_mask = __lsx_vadd_w(
|
||||
__lsx_vreplgr2vr_w(
|
||||
((srcfmt->Rshift >> 3) << dstfmt->Rshift) |
|
||||
((srcfmt->Gshift >> 3) << dstfmt->Gshift) |
|
||||
((srcfmt->Bshift >> 3) << dstfmt->Bshift)),
|
||||
mask_offsets);
|
||||
|
||||
const __m128i alpha_splat_mask = __lsx_vadd_b(__lsx_vreplgr2vr_b(srcfmt->Ashift >> 3), mask_offsets);
|
||||
const __m128i alpha_fill_mask = __lsx_vreplgr2vr_w((int)dstAmask);
|
||||
|
||||
while (height--) {
|
||||
int i = 0;
|
||||
|
||||
for (; i + 4 <= width; i += 4) {
|
||||
__m128i src128 = __lsx_vld(src, 0);
|
||||
__m128i dst128 = __lsx_vld(dst, 0);
|
||||
|
||||
__m128i srcA = __lsx_vshuf_b(src128, src128, alpha_splat_mask);
|
||||
src128 = __lsx_vshuf_b(src128, src128, convert_mask);
|
||||
|
||||
src128 = __lsx_vor_v(src128, alpha_fill_mask);
|
||||
|
||||
__m128i srca_lo = __lsx_vilvl_b(srcA, srcA);
|
||||
__m128i srca_hi = __lsx_vilvh_b(srcA, srcA);
|
||||
|
||||
srca_lo = __lsx_vxor_v(srca_lo, const_0xff00);
|
||||
srca_hi = __lsx_vxor_v(srca_hi, const_0xff00);
|
||||
|
||||
src128 = __lsx_vsub_b(src128, const_128);
|
||||
dst128 = __lsx_vsub_b(dst128, const_128);
|
||||
|
||||
__m128i tmp = __lsx_vilvl_b(dst128, src128);
|
||||
__m128i dst_lo = __lsx_vsadd_h(__lsx_vmulwev_h_bu_b(srca_lo, tmp), __lsx_vmulwod_h_bu_b(srca_lo, tmp));
|
||||
tmp = __lsx_vilvh_b(dst128, src128);
|
||||
__m128i dst_hi = __lsx_vsadd_h(__lsx_vmulwev_h_bu_b(srca_hi, tmp), __lsx_vmulwod_h_bu_b(srca_hi, tmp));
|
||||
|
||||
dst_lo = __lsx_vadd_h(dst_lo, const_32641);
|
||||
dst_hi = __lsx_vadd_h(dst_hi, const_32641);
|
||||
|
||||
dst_lo = __lsx_vmuh_hu(dst_lo, const_257);
|
||||
dst_hi = __lsx_vmuh_hu(dst_hi, const_257);
|
||||
|
||||
dst128 = __lsx_vssrarni_bu_h(dst_hi, dst_lo, 0);
|
||||
if (fill_alpha) {
|
||||
dst128 = __lsx_vor_v(dst128, alpha_fill_mask);
|
||||
}
|
||||
__lsx_vst(dst128, dst, 0);
|
||||
|
||||
src += 16;
|
||||
dst += 16;
|
||||
}
|
||||
|
||||
for (; i < width; ++i) {
|
||||
Uint32 src32 = *(Uint32 *)src;
|
||||
Uint32 dst32 = *(Uint32 *)dst;
|
||||
ALPHA_BLEND_SWIZZLE_8888(src32, dst32, srcfmt, dstfmt);
|
||||
if (fill_alpha) {
|
||||
dst32 |= dstAmask;
|
||||
}
|
||||
*(Uint32 *)dst = dst32;
|
||||
src += 4;
|
||||
dst += 4;
|
||||
}
|
||||
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// fast RGB888->(A)RGB888 blending with surface alpha=128 special case
|
||||
static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info)
|
||||
{
|
||||
@@ -1202,7 +1299,7 @@ static void SDL_TARGETING("avx2") Blit8888to8888PixelAlphaSwizzleAVX2(SDL_BlitIn
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8)
|
||||
#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8) && (defined(__aarch64__) || defined(_M_ARM64))
|
||||
|
||||
static void Blit8888to8888PixelAlphaSwizzleNEON(SDL_BlitInfo *info)
|
||||
{
|
||||
@@ -1402,7 +1499,12 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
||||
return Blit8888to8888PixelAlphaSwizzleSSE41;
|
||||
}
|
||||
#endif
|
||||
#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8)
|
||||
#ifdef SDL_LSX_INTRINSICS
|
||||
if (SDL_HasLSX()) {
|
||||
return Blit8888to8888PixelAlphaSwizzleLSX;
|
||||
}
|
||||
#endif
|
||||
#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8) && (defined(__aarch64__) || defined(_M_ARM64))
|
||||
// To prevent "unused function" compiler warnings/errors
|
||||
(void)Blit8888to8888PixelAlpha;
|
||||
(void)Blit8888to8888PixelAlphaSwizzle;
|
||||
|
||||
@@ -2719,7 +2719,7 @@ static void SDL_TARGETING("avx2") Blit8888to8888PixelSwizzleAVX2(SDL_BlitInfo *i
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8)
|
||||
#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8) && (defined(__aarch64__) || defined(_M_ARM64))
|
||||
|
||||
static void Blit8888to8888PixelSwizzleNEON(SDL_BlitInfo *info)
|
||||
{
|
||||
@@ -3135,7 +3135,7 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
|
||||
return Blit8888to8888PixelSwizzleSSE41;
|
||||
}
|
||||
#endif
|
||||
#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8)
|
||||
#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8) && (defined(__aarch64__) || defined(_M_ARM64))
|
||||
return Blit8888to8888PixelSwizzleNEON;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -85,8 +85,8 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
|
||||
last_index = SDL_LookupRGBAColor(palette_map, last_pixel, dst_pal);
|
||||
}
|
||||
|
||||
incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
||||
incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
||||
incy = info->dst_h ? ((Uint64)info->src_h << 16) / info->dst_h : 0;
|
||||
incx = info->dst_w ? ((Uint64)info->src_w << 16) / info->dst_w : 0;
|
||||
posy = incy / 2; // start at the middle of pixel
|
||||
|
||||
while (info->dst_h--) {
|
||||
|
||||
@@ -173,6 +173,11 @@ void *SDL_GetInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type
|
||||
void *data = NULL;
|
||||
|
||||
if (_this->clipboard_callback) {
|
||||
if (!SDL_HasInternalClipboardData(_this, mime_type)) {
|
||||
// The callback hasn't advertised that it can handle this mime type
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const void *provided_data = _this->clipboard_callback(_this->clipboard_userdata, mime_type, size);
|
||||
if (provided_data) {
|
||||
// Make a copy of it for the caller and guarantee null termination
|
||||
@@ -180,6 +185,8 @@ void *SDL_GetInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type
|
||||
if (data) {
|
||||
SDL_memcpy(data, provided_data, *size);
|
||||
SDL_memset((Uint8 *)data + *size, 0, sizeof(Uint32));
|
||||
} else {
|
||||
*size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1078,7 +1078,8 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_this->egl_data->egl_swapinterval = 0;
|
||||
// The default swap interval is 1, according to the spec
|
||||
_this->egl_data->egl_swapinterval = 1;
|
||||
|
||||
if (!SDL_EGL_MakeCurrent(_this, egl_surface, (SDL_GLContext)egl_context)) {
|
||||
// Delete the context
|
||||
|
||||
@@ -133,6 +133,69 @@ DEFINE_SSE_FILLRECT(4, Uint32)
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
#endif // __SSE__
|
||||
|
||||
#ifdef SDL_LSX_INTRINSICS
|
||||
/* *INDENT-OFF* */ // clang-format off
|
||||
|
||||
#define LSX_BEGIN __m128i c128 = __lsx_vreplgr2vr_w(color);
|
||||
|
||||
#define LSX_WORK \
|
||||
for (i = n / 64; i--;) { \
|
||||
__lsx_vst(c128, p, 0); \
|
||||
__lsx_vst(c128, p, 16); \
|
||||
__lsx_vst(c128, p, 32); \
|
||||
__lsx_vst(c128, p, 48); \
|
||||
p += 64; \
|
||||
}
|
||||
|
||||
#define DEFINE_LSX_FILLRECT(bpp, type) \
|
||||
static void SDL_TARGETING("lsx") SDL_FillSurfaceRect##bpp##LSX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
|
||||
{ \
|
||||
int i, n; \
|
||||
Uint8 *p = NULL; \
|
||||
\
|
||||
/* If the number of bytes per row is equal to the pitch, treat */ \
|
||||
/* all rows as one long continuous row (for better performance) */ \
|
||||
if ((w) * (bpp) == pitch) { \
|
||||
w = w * h; \
|
||||
h = 1; \
|
||||
} \
|
||||
\
|
||||
LSX_BEGIN; \
|
||||
\
|
||||
while (h--) { \
|
||||
n = (w) * (bpp); \
|
||||
p = pixels; \
|
||||
\
|
||||
if (n > 63) { \
|
||||
int adjust = 16 - ((uintptr_t)p & 15); \
|
||||
if (adjust < 16) { \
|
||||
n -= adjust; \
|
||||
adjust /= (bpp); \
|
||||
while (adjust--) { \
|
||||
*((type *)p) = (type)color; \
|
||||
p += (bpp); \
|
||||
} \
|
||||
} \
|
||||
LSX_WORK; \
|
||||
} \
|
||||
if (n & 63) { \
|
||||
int remainder = (n & 63); \
|
||||
remainder /= (bpp); \
|
||||
while (remainder--) { \
|
||||
*((type *)p) = (type)color; \
|
||||
p += (bpp); \
|
||||
} \
|
||||
} \
|
||||
pixels += pitch; \
|
||||
} \
|
||||
\
|
||||
}
|
||||
|
||||
DEFINE_LSX_FILLRECT(4, Uint32)
|
||||
|
||||
/* *INDENT-ON* */ // clang-format on
|
||||
#endif /* __LSX__ */
|
||||
|
||||
static void SDL_FillSurfaceRect1(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
||||
{
|
||||
int n;
|
||||
@@ -340,6 +403,12 @@ bool SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Ui
|
||||
fill_function = SDL_FillSurfaceRect4SSE;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef SDL_LSX_INTRINSICS
|
||||
if (SDL_HasLSX()) {
|
||||
fill_function = SDL_FillSurfaceRect4LSX;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
fill_function = SDL_FillSurfaceRect4;
|
||||
break;
|
||||
|
||||
@@ -48,8 +48,6 @@ bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B)
|
||||
SDL_RECT_CAN_OVERFLOW(B)) {
|
||||
SDL_SetError("Potential rect math overflow");
|
||||
return false;
|
||||
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) {
|
||||
return false; // Special cases for empty rects
|
||||
}
|
||||
|
||||
// Horizontal intersection
|
||||
@@ -100,10 +98,6 @@ bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result)
|
||||
} else if (!result) {
|
||||
SDL_InvalidParamError("result");
|
||||
return false;
|
||||
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { // Special cases for empty rects
|
||||
result->w = 0;
|
||||
result->h = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Horizontal intersection
|
||||
|
||||
@@ -49,7 +49,7 @@ bool SDL_SurfaceValid(SDL_Surface *surface)
|
||||
|
||||
void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface)
|
||||
{
|
||||
if (SDL_SurfaceHasRLE(surface)) {
|
||||
if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||
surface->flags |= SDL_SURFACE_LOCK_NEEDED;
|
||||
} else {
|
||||
surface->flags &= ~SDL_SURFACE_LOCK_NEEDED;
|
||||
@@ -611,7 +611,6 @@ bool SDL_SetSurfaceRLE(SDL_Surface *surface, bool enabled)
|
||||
if (surface->map.info.flags != flags) {
|
||||
SDL_InvalidateMap(&surface->map);
|
||||
}
|
||||
SDL_UpdateSurfaceLockFlag(surface);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1751,6 +1750,7 @@ bool SDL_LockSurface(SDL_Surface *surface)
|
||||
if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||
SDL_UnRLESurface(surface, true);
|
||||
surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL; // save accel'd state
|
||||
SDL_UpdateSurfaceLockFlag(surface);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
+25
-17
@@ -295,20 +295,6 @@ static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SDLCALL SDL_CleanupWindowTextureData(void *userdata, void *value)
|
||||
{
|
||||
SDL_WindowTextureData *data = (SDL_WindowTextureData *)value;
|
||||
|
||||
if (data->texture) {
|
||||
SDL_DestroyTexture(data->texture);
|
||||
}
|
||||
if (data->renderer) {
|
||||
SDL_DestroyRenderer(data->renderer);
|
||||
}
|
||||
SDL_free(data->pixels);
|
||||
SDL_free(data);
|
||||
}
|
||||
|
||||
static bool SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_PropertiesID props = SDL_GetWindowProperties(window);
|
||||
@@ -399,7 +385,7 @@ static bool SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window,
|
||||
SDL_DestroyRenderer(renderer);
|
||||
return false;
|
||||
}
|
||||
if (!SDL_SetPointerPropertyWithCleanup(props, SDL_PROP_WINDOW_TEXTUREDATA_POINTER, data, SDL_CleanupWindowTextureData, NULL)) {
|
||||
if (!SDL_SetPointerProperty(props, SDL_PROP_WINDOW_TEXTUREDATA_POINTER, data)) {
|
||||
SDL_DestroyRenderer(renderer);
|
||||
return false;
|
||||
}
|
||||
@@ -526,7 +512,21 @@ static bool SDL_UpdateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window,
|
||||
|
||||
static void SDL_DestroyWindowTexture(SDL_VideoDevice *_this, SDL_Window *window)
|
||||
{
|
||||
SDL_ClearProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_TEXTUREDATA_POINTER);
|
||||
SDL_PropertiesID props = SDL_GetWindowProperties(window);
|
||||
if (SDL_HasProperty(props, SDL_PROP_WINDOW_TEXTUREDATA_POINTER)) {
|
||||
SDL_WindowTextureData *data = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL);
|
||||
|
||||
if (data->texture) {
|
||||
SDL_DestroyTexture(data->texture);
|
||||
}
|
||||
if (data->renderer) {
|
||||
SDL_DestroyRenderer(data->renderer);
|
||||
}
|
||||
SDL_free(data->pixels);
|
||||
SDL_free(data);
|
||||
|
||||
SDL_ClearProperty(props, SDL_PROP_WINDOW_TEXTUREDATA_POINTER);
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *_this = NULL;
|
||||
@@ -2924,8 +2924,14 @@ bool SDL_GetWindowPosition(SDL_Window *window, int *x, int *y)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, false);
|
||||
|
||||
#ifdef SDL_PLATFORM_MACOS
|
||||
// On newer MacBooks, the fullscreen window might be placed below the camera notch, so use the actual window position
|
||||
bool use_display_origin = false;
|
||||
#else
|
||||
// Fullscreen windows are always at their display's origin
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
bool use_display_origin = ((window->flags & SDL_WINDOW_FULLSCREEN) != 0);
|
||||
#endif
|
||||
if (use_display_origin) {
|
||||
SDL_DisplayID displayID;
|
||||
|
||||
if (x) {
|
||||
@@ -4285,6 +4291,8 @@ void SDL_DestroyWindow(SDL_Window *window)
|
||||
}
|
||||
|
||||
SDL_DestroyProperties(window->text_input_props);
|
||||
|
||||
SDL_DestroyWindowTexture(_this, window);
|
||||
SDL_DestroyProperties(window->props);
|
||||
|
||||
/* Clear the modal status, but don't unset the parent just yet, as it
|
||||
|
||||
@@ -248,6 +248,12 @@ void Android_PumpEvents(Sint64 timeoutNS)
|
||||
|
||||
bool Android_WaitActiveAndLockActivity(void)
|
||||
{
|
||||
/* Make sure we have pumped all events so that Android_Paused state is correct */
|
||||
SDL_AndroidLifecycleEvent event;
|
||||
while (!Android_Destroyed && Android_WaitLifecycleEvent(&event, 0)) {
|
||||
Android_HandleLifecycleEvent(event);
|
||||
}
|
||||
|
||||
while (Android_Paused && !Android_Destroyed) {
|
||||
Android_PumpEvents(-1);
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ SDL_TouchID Android_ConvertJavaTouchID(int touchID)
|
||||
// adb shell input mouse tap 100 100
|
||||
// adb shell input touchscreen tap 100 100
|
||||
//
|
||||
// Prevent to be -1, since it's used in SDL internal for synthetic events:
|
||||
retval -= 1;
|
||||
// Prevent the values -1 and -2, since they're used in SDL internal for synthetic events:
|
||||
retval -= 2;
|
||||
} else {
|
||||
// Touch ID 0 is invalid
|
||||
retval += 1;
|
||||
@@ -81,7 +81,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin
|
||||
fingerId = (SDL_FingerID)(pointer_finger_id_in + 1);
|
||||
|
||||
if (SDL_AddTouch(touchDeviceId, SDL_TOUCH_DEVICE_DIRECT, "") < 0) {
|
||||
SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
|
||||
@@ -44,19 +44,20 @@
|
||||
{
|
||||
static NSCursor *invisibleCursor = NULL;
|
||||
if (!invisibleCursor) {
|
||||
// RAW 16x16 transparent GIF
|
||||
static unsigned char cursorBytes[] = {
|
||||
0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x10, 0x00, 0x80,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xF9, 0x04,
|
||||
0x01, 0x00, 0x00, 0x01, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x10,
|
||||
0x00, 0x10, 0x00, 0x00, 0x02, 0x0E, 0x8C, 0x8F, 0xA9, 0xCB, 0xED,
|
||||
0x0F, 0xA3, 0x9C, 0xB4, 0xDA, 0x8B, 0xB3, 0x3E, 0x05, 0x00, 0x3B
|
||||
};
|
||||
const int size = 32;
|
||||
NSImage *cursorImage = [[NSImage alloc] initWithSize:NSMakeSize(size, size)];
|
||||
NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
|
||||
pixelsWide:size
|
||||
pixelsHigh:size
|
||||
bitsPerSample:8
|
||||
samplesPerPixel:4
|
||||
hasAlpha:YES
|
||||
isPlanar:NO
|
||||
colorSpaceName:NSDeviceRGBColorSpace
|
||||
bytesPerRow:(size * 4)
|
||||
bitsPerPixel:32];
|
||||
[cursorImage addRepresentation:imgrep];
|
||||
|
||||
NSData *cursorData = [NSData dataWithBytesNoCopy:&cursorBytes[0]
|
||||
length:sizeof(cursorBytes)
|
||||
freeWhenDone:NO];
|
||||
NSImage *cursorImage = [[NSImage alloc] initWithData:cursorData];
|
||||
invisibleCursor = [[NSCursor alloc] initWithImage:cursorImage
|
||||
hotSpot:NSZeroPoint];
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ bool HAIKU_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL
|
||||
// Get the current screen
|
||||
BScreen bscreen;
|
||||
if (!bscreen.IsValid()) {
|
||||
printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
|
||||
return SDL_SetError("Invalid screen");
|
||||
}
|
||||
|
||||
// Set the mode using the driver data
|
||||
|
||||
@@ -240,16 +240,18 @@ static bool HAIKU_SetRelativeMouseMode(bool enabled)
|
||||
}
|
||||
|
||||
SDL_BWin *bewin = _ToBeWin(window);
|
||||
BGLView *_SDL_GLView = bewin->GetGLView();
|
||||
if (!_SDL_GLView) {
|
||||
return false;
|
||||
}
|
||||
BView *_SDL_View = bewin->GetGLView();
|
||||
if (!_SDL_View) {
|
||||
_SDL_View = bewin->GetView();
|
||||
if (!_SDL_View)
|
||||
return false;
|
||||
}
|
||||
|
||||
bewin->Lock();
|
||||
if (enabled)
|
||||
_SDL_GLView->SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||
_SDL_View->SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||
else
|
||||
_SDL_GLView->SetEventMask(0, 0);
|
||||
_SDL_View->SetEventMask(0, 0);
|
||||
bewin->Unlock();
|
||||
|
||||
return true;
|
||||
|
||||
Loaded 100 of 123 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user