Compare commits

..

26 Commits

Author SHA1 Message Date
Sam Lantinga
ef7261bc41 Updated to version 2.29.2 for RC build 2024-01-22 08:43:05 -08:00
Sam Lantinga
12bab1c981 Fixed warning C4244: '=': conversion from 'Sint64' to 'int', possible loss of data 2024-01-22 08:39:22 -08:00
pionere
61821bd876 fix audio conversion from S16 to F32 using SSE2 2024-01-22 10:45:58 -05:00
Simon McVittie
0f9422a6a5 linux: Handle upower's UP_DEVICE_STATE_PENDING_CHARGE, PENDING_DISCHARGE
On my laptop, the battery is configured to stop charging at around 80%
most of the time, to increase the overall useful lifetime of the battery.
When in that state, upower reports UP_DEVICE_STATE_PENDING_CHARGE
(numeric value 5), which SDL previously mapped to SDL_POWERSTATE_UNKNOWN.
This made the platform_testGetPowerInfo automated test fail, because
it assumes that SDL_POWERSTATE_UNKNOWN means no battery is connected,
and does not expect to see a percentage.

Map UP_DEVICE_STATE_PENDING_CHARGE (5) to SDL_POWERSTATE_CHARGED, which
seems close enough.

Also map UP_DEVICE_STATE_PENDING_DISCHARGE (6) to
SDL_POWERSTATE_ON_BATTERY, which matches how at least GNOME presents it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit eebd5d18a2)
2024-01-22 06:34:12 -08:00
Simon McVittie
55ba686530 test: Run testautomation under Autotools too, not just CMake
The CMake build system runs this since #8313, so we already have to make
sure it doesn't regress.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-01-22 06:33:27 -08:00
Simon McVittie
4cb43db1a9 test: Don't distinguish between different categories of tests
It's reasonable to assume that any of them might need a display and an
audio backend. We run them with SDL_VIDEODRIVER and SDL_AUDIODRIVER
set to dummy anyway.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-01-22 06:33:27 -08:00
Sylvain
237535b23a Fixed bug #8897 - SDL_BlitSurface segfault when dest_rect is null 2024-01-22 09:22:41 +01:00
yuanhecai
ed5d3d9f82 Fix compilation on loongarch 2024-01-21 19:27:59 -08:00
Frank Praznik
f569cc56a9 tests: Fix automated audio tests on Windows and Linux
If a specific audio driver was requested for testing, don't loop over all drivers in the init, open/close, and pause/unpause tests.

Additionally, drivers can fail if attempting to open an audio device when no underlying output is present, which is a valid case if the system has no audio hardware available. Check for the presence of audio output devices before attempting to open them.

Fixes automated tests with various drivers on Windows and Linux.
2024-01-21 23:44:53 +01:00
Frank Praznik
06dd70bc8b video: Use string comparison instead of #ifdefs for driver detection
The dummy driver can be in use on these platforms, so check the actual driver name string.

Fixes the automated video tests with the dummy driver on Win32.
2024-01-21 23:44:53 +01:00
Anonymous Maarten
a420eb79bb cmake: run testautomation with CTest on ci 2024-01-21 23:44:53 +01:00
Anonymous Maarten
41fc398114 Move check for SDL_Delay upper bounds to testtimer
(cherry picked from commit f45761908a)
2024-01-21 23:44:53 +01:00
Anonymous Maarten
1737340978 Use helper_ddtod function to compare atan2 infinity cases
This fixes a test failure when building on mingw32 in Release mode.
2024-01-21 23:44:53 +01:00
Anonymous Maarten
69a6efcd1b Avoid using higher precision floating point numbers by using it in a function 2024-01-21 23:44:53 +01:00
Anonymous Maarten
fbee0b86bf video: verify SDL_GetNumVideoDisplays is succesful 2024-01-21 23:44:53 +01:00
Anonymous Maarten
880c69392a testautomation_math: do relative comparison + more precise correct trigonometric values 2024-01-21 23:44:53 +01:00
Anonymous Maarten
811adaa342 Only test error message when using specific video drivers
The dummy driver does not sen an error message when passing
a NULL rect argument to SDL_SetTextInputRect.
2024-01-21 23:44:53 +01:00
Sylvain
5368f45567 Remove one test that contains call of SDL_Quit() / SDL_Init() because it
conficts with the initializaion of test common.
(before it used SDL_VideoInit SDL_VideoQuit which weren't perturbated by SDL_Quit())
2024-01-21 23:44:53 +01:00
Sylvain
3d5679bb8e Fix video_getSetWindowPosition() that fail when checking events,
because testautomation_events.c() didn't finish to poll all events before

(cherry picked from commit 3ccfd361cb)
2024-01-21 23:44:53 +01:00
Sam Lantinga
e3203278f4 Updated tests so they'll pass if we enable the C runtime in SDL2.dll
This isn't needed here, but will be necessary for sdl2-compat
2024-01-21 11:23:50 -08:00
Ethan Lee
b5aec14d43 gdk: Backport SDL3 MR #8844
Co-authored-by: chalonverse <sanjay12@gmail.com>
2024-01-21 13:55:17 -05:00
Ozkan Sezer
8eb2ec6a8d watcom makefiles: remove yuv_rgb_lsx.c from sources 2024-01-21 11:56:20 +03:00
Sam Lantinga
83f3045ee8 Revert "updated WhatsNew.txt"
This reverts commit c3a3f18076.
2024-01-20 05:28:05 -08:00
Sylvain
f1bc5f305c Prevent asan warning on qsort():
'src/stdlib/SDL_qsort.c:27:5: runtime error: null pointer passed as argument 1, which is declared to never be null`

(cherry picked from commit 2cd583ee13)
2024-01-20 11:26:37 +01:00
Ozkan Sezer
c3a3f18076 updated WhatsNew.txt 2024-01-20 11:51:00 +03:00
Sylvain
5d6eb4a5a5 Fixed overflow in SDL_SoftStretch() (see #8878)
(cherry picked from commit 7b02d328fa)
2024-01-20 06:39:21 +01:00
51 changed files with 1520 additions and 332 deletions

View File

@@ -41,6 +41,7 @@ jobs:
set(CMAKE_SHARED_LINKER_FLAGS "-DEBUG" CACHE STRING "Linker flag for shared libraries")
cmake_minimum_required(VERSION 3.0...3.25)
project(sdl_user)
enable_testing()
add_subdirectory("{ srcdir }" SDL)
"""))
- name: Configure (CMake)

1
.gitignore vendored
View File

@@ -103,6 +103,7 @@ VisualC/visualtest/testsprite2_sample.actions
VisualC/visualtest/testsprite2_sample.config
VisualC/visualtest/testsprite2_sample.parameters
VisualC-GDK/**/Layout
VisualC-GDK/shaders/*.h
# for Android
android-project/local.properties

View File

@@ -87,7 +87,7 @@ endif()
# See docs/release_checklist.md
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 29)
set(SDL_MICRO_VERSION 1)
set(SDL_MICRO_VERSION 2)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Set defaults preventing destination file conflicts
@@ -911,7 +911,7 @@ if(SDL_ASSEMBLY)
if(SDL_LSX)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_FLAGS "-mlsx")
set(CMAKE_REQUIRED_FLAGS "-mlsx")
check_c_source_compiles("
#ifndef __loongarch_sx
#error Assembler CPP flag not enabled
@@ -928,7 +928,7 @@ if(SDL_ASSEMBLY)
if(SDL_LASX)
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_FLAGS "-mlasx")
set(CMAKE_REQUIRED_FLAGS "-mlasx")
check_c_source_compiles("
#ifndef __loongarch_asx
#error Assembler CPP flag not enabled

View File

@@ -15,7 +15,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 29
MICRO_VERSION = 1
MICRO_VERSION = 2
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2
@@ -81,7 +81,7 @@ SRCS+= SDL_events.c SDL_quit.c SDL_keyboard.c SDL_mouse.c SDL_windowevents.c &
SDL_clipboardevents.c SDL_dropevents.c SDL_displayevents.c SDL_gesture.c &
SDL_sensor.c SDL_touch.c
SRCS+= SDL_haptic.c SDL_hidapi.c SDL_gamecontroller.c SDL_joystick.c controller_type.c
SRCS+= SDL_render.c yuv_rgb_lsx.c yuv_rgb_sse.c yuv_rgb_std.c SDL_yuv.c SDL_yuv_sw.c SDL_blendfillrect.c &
SRCS+= SDL_render.c yuv_rgb_sse.c yuv_rgb_std.c SDL_yuv.c SDL_yuv_sw.c SDL_blendfillrect.c &
SDL_blendline.c SDL_blendpoint.c SDL_drawline.c SDL_drawpoint.c &
SDL_render_sw.c SDL_rotate.c SDL_triangle.c
SRCS+= SDL_blit.c SDL_blit_0.c SDL_blit_1.c SDL_blit_A.c SDL_blit_auto.c &
@@ -152,15 +152,14 @@ SDL_blendpoint.obj: SDL_blendpoint.c
wcc386 $(CFLAGS_DLL) -wcd=200 -fo=$^@ $<
SDL_RLEaccel.obj: SDL_RLEaccel.c
wcc386 $(CFLAGS_DLL) -wcd=201 -fo=$^@ $<
yuv_rgb_sse.obj: yuv_rgb_sse.c
wcc386 $(CFLAGS_DLL) -wcd=202 -fo=$^@ $<
!ifeq HIDAPI 1
# c99 mode needed because of structs with flexible array members in libusb.h
SDL_hidapi.obj: SDL_hidapi.c
wcc386 $(CFLAGS_DLL) -za99 -fo=$^@ $<
!endif
yuv_rgb_sse.obj: yuv_rgb_sse.c
wcc386 $(CFLAGS_DLL) -wcd=202 -fo=$^@ $<
$(LIBICONV_LIB): "src/core/os2/iconv2.lbc"
@echo * Creating: $@
wlib -q -b -n -c -pa -s -t -zld -ii -io $@ @$<

View File

@@ -6,7 +6,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 29
MICRO_VERSION = 1
MICRO_VERSION = 2
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
LIBHOME = .
@@ -60,7 +60,7 @@ SRCS+= SDL_events.c SDL_quit.c SDL_keyboard.c SDL_mouse.c SDL_windowevents.c &
SDL_clipboardevents.c SDL_dropevents.c SDL_displayevents.c SDL_gesture.c &
SDL_sensor.c SDL_touch.c
SRCS+= SDL_haptic.c SDL_hidapi.c SDL_gamecontroller.c SDL_joystick.c controller_type.c
SRCS+= SDL_render.c yuv_rgb_lsx.c yuv_rgb_sse.c yuv_rgb_std.c SDL_yuv.c SDL_yuv_sw.c SDL_blendfillrect.c &
SRCS+= SDL_render.c yuv_rgb_sse.c yuv_rgb_std.c SDL_yuv.c SDL_yuv_sw.c SDL_blendfillrect.c &
SDL_blendline.c SDL_blendpoint.c SDL_drawline.c SDL_drawpoint.c &
SDL_render_sw.c SDL_rotate.c SDL_triangle.c
SRCS+= SDL_blit.c SDL_blit_0.c SDL_blit_1.c SDL_blit_A.c SDL_blit_auto.c &

View File

@@ -173,6 +173,12 @@
<SubSystem>Windows</SubSystem>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Link>
<PreBuildEvent>
<Command>$(SolutionDir)\shaders\buildshaders.bat $(SolutionDir)</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Building shader blobs (Xbox Series)</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Gaming.Xbox.XboxOne.x64'">
<Midl>
@@ -201,6 +207,12 @@
<SubSystem>Windows</SubSystem>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Link>
<PreBuildEvent>
<Command>$(SolutionDir)\shaders\buildshaders.bat $(SolutionDir) one</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Building shader blobs (Xbox One)</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Desktop.x64'">
<Midl>
@@ -259,6 +271,12 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Link>
<PreBuildEvent>
<Command>$(SolutionDir)\shaders\buildshaders.bat $(SolutionDir)</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Building shader blobs (Xbox Series)</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Gaming.Xbox.XboxOne.x64'">
<Midl>
@@ -288,6 +306,12 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
</Link>
<PreBuildEvent>
<Command>$(SolutionDir)\shaders\buildshaders.bat $(SolutionDir) one</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Building shader blobs (Xbox One)</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\include\begin_code.h" />

View File

@@ -4,3 +4,4 @@ find . -type f \( -name '*.bmp' -o -name '*.wav' -o -name '*.dat' \) -print -del
find . -depth -type d \( -name Gaming.Desktop.x64 \) -exec rm -rv {} \;
find . -depth -type d \( -name Gaming.Xbox.Scarlett.x64 \) -exec rm -rv {} \;
find . -depth -type d \( -name Gaming.Xbox.XboxOne.x64 \) -exec rm -rv {} \;
rm shaders/*.h

View File

@@ -0,0 +1,19 @@
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define ColorRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
"DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
"DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
"DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0)"
[RootSignature(ColorRS)]
float4 main(PixelShaderInput input) : SV_TARGET0
{
return input.color;
}

View File

@@ -0,0 +1,43 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureUV : register(t1);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(NVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.1644, 0.0000, 1.5960};
const float3 Gcoeff = {1.1644, -0.3918, -0.8130};
const float3 Bcoeff = {1.1644, 2.0172, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg;
yuv += offset;
Output.r = dot(yuv, Rcoeff);
Output.g = dot(yuv, Gcoeff);
Output.b = dot(yuv, Bcoeff);
Output.a = 1.0f;
return Output * input.color;
}

View File

@@ -0,0 +1,43 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureUV : register(t1);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(NVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.1644, 0.0000, 1.7927};
const float3 Gcoeff = {1.1644, -0.2132, -0.5329};
const float3 Bcoeff = {1.1644, 2.1124, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg;
yuv += offset;
Output.r = dot(yuv, Rcoeff);
Output.g = dot(yuv, Gcoeff);
Output.b = dot(yuv, Bcoeff);
Output.a = 1.0f;
return Output * input.color;
}

View File

@@ -0,0 +1,43 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureUV : register(t1);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(NVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {0.0, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg;
yuv += offset;
Output.r = dot(yuv, Rcoeff);
Output.g = dot(yuv, Gcoeff);
Output.b = dot(yuv, Bcoeff);
Output.a = 1.0f;
return Output * input.color;
}

View File

@@ -0,0 +1,43 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureUV : register(t1);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(NVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.1644, 0.0000, 1.5960};
const float3 Gcoeff = {1.1644, -0.3918, -0.8130};
const float3 Bcoeff = {1.1644, 2.0172, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr;
yuv += offset;
Output.r = dot(yuv, Rcoeff);
Output.g = dot(yuv, Gcoeff);
Output.b = dot(yuv, Bcoeff);
Output.a = 1.0f;
return Output * input.color;
}

View File

@@ -0,0 +1,43 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureUV : register(t1);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(NVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.1644, 0.0000, 1.7927};
const float3 Gcoeff = {1.1644, -0.2132, -0.5329};
const float3 Bcoeff = {1.1644, 2.1124, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr;
yuv += offset;
Output.r = dot(yuv, Rcoeff);
Output.g = dot(yuv, Gcoeff);
Output.b = dot(yuv, Bcoeff);
Output.a = 1.0f;
return Output * input.color;
}

View File

@@ -0,0 +1,43 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureUV : register(t1);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(NVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {0.0, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr;
yuv += offset;
Output.r = dot(yuv, Rcoeff);
Output.g = dot(yuv, Gcoeff);
Output.b = dot(yuv, Bcoeff);
Output.a = 1.0f;
return Output * input.color;
}

View File

@@ -0,0 +1,24 @@
Texture2D theTexture : register(t0);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define TextureRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(TextureRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
return theTexture.Sample(theSampler, input.tex) * input.color;
}

View File

@@ -0,0 +1,46 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureU : register(t1);
Texture2D theTextureV : register(t2);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define YUVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t2), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(YUVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.1644, 0.0000, 1.5960};
const float3 Gcoeff = {1.1644, -0.3918, -0.8130};
const float3 Bcoeff = {1.1644, 2.0172, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.y = theTextureU.Sample(theSampler, input.tex).r;
yuv.z = theTextureV.Sample(theSampler, input.tex).r;
yuv += offset;
Output.r = dot(yuv, Rcoeff);
Output.g = dot(yuv, Gcoeff);
Output.b = dot(yuv, Bcoeff);
Output.a = 1.0f;
return Output * input.color;
}

View File

@@ -0,0 +1,46 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureU : register(t1);
Texture2D theTextureV : register(t2);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define YUVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t2), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(YUVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.1644, 0.0000, 1.7927};
const float3 Gcoeff = {1.1644, -0.2132, -0.5329};
const float3 Bcoeff = {1.1644, 2.1124, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.y = theTextureU.Sample(theSampler, input.tex).r;
yuv.z = theTextureV.Sample(theSampler, input.tex).r;
yuv += offset;
Output.r = dot(yuv, Rcoeff);
Output.g = dot(yuv, Gcoeff);
Output.b = dot(yuv, Bcoeff);
Output.a = 1.0f;
return Output * input.color;
}

View File

@@ -0,0 +1,46 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureU : register(t1);
Texture2D theTextureV : register(t2);
SamplerState theSampler : register(s0);
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define YUVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t2), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(YUVRS)]
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {0.0, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.y = theTextureU.Sample(theSampler, input.tex).r;
yuv.z = theTextureV.Sample(theSampler, input.tex).r;
yuv += offset;
Output.r = dot(yuv, Rcoeff);
Output.g = dot(yuv, Gcoeff);
Output.b = dot(yuv, Bcoeff);
Output.a = 1.0f;
return Output * input.color;
}

View File

@@ -0,0 +1,95 @@
#pragma pack_matrix( row_major )
struct VertexShaderConstants
{
matrix model;
matrix projectionAndView;
};
ConstantBuffer<VertexShaderConstants> Constants : register(b0);
struct VertexShaderInput
{
float3 pos : POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
struct VertexShaderOutput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
#define ColorRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
"DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
"DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
"DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0)"
#define TextureRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
#define YUVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t2), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
#define NVRS \
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
" DENY_GEOMETRY_SHADER_ROOT_ACCESS |" \
" DENY_HULL_SHADER_ROOT_ACCESS )," \
"RootConstants(num32BitConstants=32, b0),"\
"DescriptorTable ( SRV(t0), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( SRV(t1), visibility = SHADER_VISIBILITY_PIXEL ),"\
"DescriptorTable ( Sampler(s0), visibility = SHADER_VISIBILITY_PIXEL )"
[RootSignature(ColorRS)]
VertexShaderOutput mainColor(VertexShaderInput input)
{
VertexShaderOutput output;
float4 pos = float4(input.pos, 1.0f);
// Transform the vertex position into projected space.
pos = mul(pos, Constants.model);
pos = mul(pos, Constants.projectionAndView);
output.pos = pos;
// Pass through texture coordinates and color values without transformation
output.tex = input.tex;
output.color = input.color;
return output;
}
[RootSignature(TextureRS)]
VertexShaderOutput mainTexture(VertexShaderInput input)
{
return mainColor(input);
}
[RootSignature(YUVRS)]
VertexShaderOutput mainYUV(VertexShaderInput input)
{
return mainColor(input);
}
[RootSignature(NVRS)]
VertexShaderOutput mainNV(VertexShaderInput input)
{
return mainColor(input);
}

View File

@@ -0,0 +1,35 @@
if %2.==one. goto setxboxone
rem Xbox Series compile
set XBOXDXC="%GameDKLatest%\GXDK\bin\Scarlett\DXC.exe"
set SUFFIX=_Series.h
goto startbuild
:setxboxone
set XBOXDXC="%GameDKLatest%\GXDK\bin\XboxOne\DXC.exe"
set SUFFIX=_One.h
:startbuild
echo Building with %XBOXDXC%
cd "%1\shaders"
rem Root Signatures
%XBOXDXC% -E ColorRS -T rootsig_1_1 -rootsig-define ColorRS -Fh D3D12_RootSig_Color%SUFFIX% -Vn D3D12_RootSig_Color D3D12_VertexShader.hlsl
%XBOXDXC% -E TextureRS -T rootsig_1_1 -rootsig-define TextureRS -Fh D3D12_RootSig_Texture%SUFFIX% -Vn D3D12_RootSig_Texture D3D12_VertexShader.hlsl
%XBOXDXC% -E YUVRS -T rootsig_1_1 -rootsig-define YUVRS -Fh D3D12_RootSig_YUV%SUFFIX% -Vn D3D12_RootSig_YUV D3D12_VertexShader.hlsl
%XBOXDXC% -E NVRS -T rootsig_1_1 -rootsig-define NVRS -Fh D3D12_RootSig_NV%SUFFIX% -Vn D3D12_RootSig_NV D3D12_VertexShader.hlsl
rem Vertex Shaders
%XBOXDXC% -E mainColor -T vs_6_0 -Fh D3D12_VertexShader_Color%SUFFIX% -Vn D3D12_VertexShader_Color D3D12_VertexShader.hlsl
%XBOXDXC% -E mainTexture -T vs_6_0 -Fh D3D12_VertexShader_Texture%SUFFIX% -Vn D3D12_VertexShader_Texture D3D12_VertexShader.hlsl
%XBOXDXC% -E mainNV -T vs_6_0 -Fh D3D12_VertexShader_NV%SUFFIX% -Vn D3D12_VertexShader_NV D3D12_VertexShader.hlsl
%XBOXDXC% -E mainYUV -T vs_6_0 -Fh D3D12_VertexShader_YUV%SUFFIX% -Vn D3D12_VertexShader_YUV D3D12_VertexShader.hlsl
rem Pixel Shaders
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_Colors%SUFFIX% -Vn D3D12_PixelShader_Colors D3D12_PixelShader_Colors.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_NV12_BT601%SUFFIX% -Vn D3D12_PixelShader_NV12_BT601 D3D12_PixelShader_NV12_BT601.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_NV12_BT709%SUFFIX% -Vn D3D12_PixelShader_NV12_BT709 D3D12_PixelShader_NV12_BT709.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_NV12_JPEG%SUFFIX% -Vn D3D12_PixelShader_NV12_JPEG D3D12_PixelShader_NV12_JPEG.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_NV21_BT601%SUFFIX% -Vn D3D12_PixelShader_NV21_BT601 D3D12_PixelShader_NV21_BT601.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_NV21_BT709%SUFFIX% -Vn D3D12_PixelShader_NV21_BT709 D3D12_PixelShader_NV21_BT709.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_NV21_JPEG%SUFFIX% -Vn D3D12_PixelShader_NV21_JPEG D3D12_PixelShader_NV21_JPEG.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_Textures%SUFFIX% -Vn D3D12_PixelShader_Textures D3D12_PixelShader_Textures.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_YUV_BT601%SUFFIX% -Vn D3D12_PixelShader_YUV_BT601 D3D12_PixelShader_YUV_BT601.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_YUV_BT709%SUFFIX% -Vn D3D12_PixelShader_YUV_BT709 D3D12_PixelShader_YUV_BT709.hlsl
%XBOXDXC% -E main -T ps_6_0 -Fh D3D12_PixelShader_YUV_JPEG%SUFFIX% -Vn D3D12_PixelShader_YUV_JPEG D3D12_PixelShader_YUV_JPEG.hlsl

View File

@@ -19,10 +19,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.29.1</string>
<string>2.29.2</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleVersion</key>
<string>2.29.1</string>
<string>2.29.2</string>
</dict>
</plist>

View File

@@ -9768,8 +9768,8 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 2902.0.0;
DYLIB_CURRENT_VERSION = 2902.0.0;
DYLIB_COMPATIBILITY_VERSION = 2903.0.0;
DYLIB_CURRENT_VERSION = 2903.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_ALTIVEC_EXTENSIONS = YES;
@@ -9810,7 +9810,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO;
MARKETING_VERSION = 2.29.1;
MARKETING_VERSION = 2.29.2;
OTHER_LDFLAGS = "-liconv";
};
name = Release;
@@ -9853,8 +9853,8 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 2902.0.0;
DYLIB_CURRENT_VERSION = 2902.0.0;
DYLIB_COMPATIBILITY_VERSION = 2903.0.0;
DYLIB_CURRENT_VERSION = 2903.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@@ -9896,7 +9896,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO;
MARKETING_VERSION = 2.29.1;
MARKETING_VERSION = 2.29.2;
OTHER_LDFLAGS = "-liconv";
};
name = Debug;
@@ -10102,8 +10102,8 @@
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 2902.0.0;
DYLIB_CURRENT_VERSION = 2902.0.0;
DYLIB_COMPATIBILITY_VERSION = 2903.0.0;
DYLIB_CURRENT_VERSION = 2903.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
@@ -10154,8 +10154,8 @@
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 2902.0.0;
DYLIB_CURRENT_VERSION = 2902.0.0;
DYLIB_COMPATIBILITY_VERSION = 2903.0.0;
DYLIB_CURRENT_VERSION = 2903.0.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;

View File

@@ -1,4 +1,4 @@
Title SDL 2.29.1
Title SDL 2.29.2
Version 1
Description SDL Library for Mac OS X (http://www.libsdl.org)
DefaultLocation /Library/Frameworks

View File

@@ -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 = 2;
private static final int SDL_MINOR_VERSION = 29;
private static final int SDL_MICRO_VERSION = 1;
private static final int SDL_MICRO_VERSION = 2;
/*
// Display InputType.SOURCE/CLASS of events and devices
//

2
configure vendored
View File

@@ -3510,7 +3510,7 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=29
SDL_MICRO_VERSION=1
SDL_MICRO_VERSION=2
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`

View File

@@ -13,7 +13,7 @@ dnl Set various version strings - taken gratefully from the GTk sources
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=29
SDL_MICRO_VERSION=1
SDL_MICRO_VERSION=2
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`

View File

@@ -3,7 +3,7 @@ GDK
This port allows SDL applications to run via Microsoft's Game Development Kit (GDK).
Windows (GDK) and Xbox One/Xbox Series (GDKX) are supported. Although most of the Xbox code is included in the public SDL source code, NDA access is required for a small number of source files. If you have access to GDKX, these required Xbox files are posted on the GDK forums [here](https://forums.xboxlive.com/questions/130003/).
Windows (GDK) and Xbox One/Xbox Series (GDKX) are both supported and all the required code is included in this public SDL release. However, only licensed Xbox developers have access to the GDKX libraries which will allow you to build the Xbox targets.
Requirements
@@ -11,6 +11,7 @@ Requirements
* Microsoft Visual Studio 2022 (in theory, it should also work in 2017 or 2019, but this has not been tested)
* Microsoft GDK June 2022 or newer (public release [here](https://github.com/microsoft/GDK/releases/tag/June_2022))
* For Xbox, you will need the corresponding GDKX version (licensed developers only)
* To publish a package or successfully authenticate a user, you will need to create an app id/configure services in Partner Center. However, for local testing purposes (without authenticating on Xbox Live), the identifiers used by the GDK test programs in the included solution will work.
@@ -33,7 +34,7 @@ The Windows GDK port supports the full set of Win32 APIs, renderers, controllers
* Call `SDL_GDKGetDefaultUser` to get the default XUserHandle pointer.
* `SDL_GetPrefPath` still works, but only for single-player titles.
These functions mostly wrap around async APIs, and thus should be treated as synchronous alternatives. Also note that the single-player functions return on any OS errors, so be sure to validate the return values!
These functions mostly wrap around async APIs, and thus should be treated as synchronous alternatives. Also note that the single-player functions return on any OS errors, so be sure to validate the return values!
* What doesn't work:
* Compilation with anything other than through the included Visual C++ solution file
@@ -145,6 +146,20 @@ To create the package:
6. Once the package is installed, you can run it from the start menu.
7. As with when running from Visual Studio, if you need to test any Xbox Live functionality you must switch to the correct sandbox.
Xbox GDKX Setup
---------------------
In general, the same process in the Windows GDK instructions work. There are just a few additional notes:
* For Xbox One consoles, use the Gaming.Xbox.XboxOne.x64 target
* For Xbox Series consoles, use the Gaming.Xbox.Scarlett.x64 target
* The Xbox One target sets the `__XBOXONE__` define and the Xbox Series target sets the `__XBOXSERIES__` define
* You don't need to link against the Xbox.Services Thunks lib nor include that dll in your package (it doesn't exist for Xbox)
* The shader blobs for Xbox are created in a pre-build step for the Xbox targets, rather than included in the source (due to NDA and version compatability reasons)
* To create a package, use:
`makepkg pack /f PackageLayout.xml /lt /d . /pd Package`
* To install the package, use:
`xbapp install [PACKAGE].xvc`
* For some reason, if you make changes that require SDL2.dll to build, and you are running through the debugger (instead of a package), you have to rebuild your .exe target for the debugger to recognize the dll has changed and needs to be transferred to the console again
* While there are successful releases of Xbox titles using this port, it is not as extensively tested as other targets
Troubleshooting
---------------

View File

@@ -59,7 +59,7 @@ typedef struct SDL_version
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 29
#define SDL_PATCHLEVEL 1
#define SDL_PATCHLEVEL 2
/**
* Macro to determine SDL version program was compiled against.

View File

@@ -427,7 +427,7 @@ static void SDLCALL SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma
static void SDLCALL SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format)
{
const Sint8 *src = (const Sint8 *)cvt->buf;
const Sint16 *src = (const Sint16 *)cvt->buf;
float *dst = (float *)cvt->buf;
int i = cvt->len_cvt / 2;

View File

@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,29,1,0
PRODUCTVERSION 2,29,1,0
FILEVERSION 2,29,2,0
PRODUCTVERSION 2,29,2,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 29, 1, 0\0"
VALUE "FileVersion", "2, 29, 2, 0\0"
VALUE "InternalName", "SDL\0"
VALUE "LegalCopyright", "Copyright (C) 2024 Sam Lantinga\0"
VALUE "OriginalFilename", "SDL2.dll\0"
VALUE "ProductName", "Simple DirectMedia Layer\0"
VALUE "ProductVersion", "2, 29, 1, 0\0"
VALUE "ProductVersion", "2, 29, 2, 0\0"
END
END
BLOCK "VarFileInfo"

View File

@@ -562,9 +562,17 @@ static void check_upower_device(DBusConnection *conn, const char *path, SDL_Powe
st = SDL_POWERSTATE_UNKNOWN; /* uh oh */
} else if (ui32 == 1) { /* 1 == charging */
st = SDL_POWERSTATE_CHARGING;
} else if ((ui32 == 2) || (ui32 == 3)) { /* 2 == discharging, 3 == empty. */
} else if ((ui32 == 2) || (ui32 == 3) || (ui32 == 6)) {
/* 2 == discharging;
* 3 == empty;
* 6 == "pending discharge" which GNOME interprets as equivalent
* to discharging */
st = SDL_POWERSTATE_ON_BATTERY;
} else if (ui32 == 4) { /* 4 == full */
} else if ((ui32 == 4) || (ui32 == 5)) {
/* 4 == full;
* 5 == "pending charge" which GNOME shows as "Not charging",
* used when a battery is configured to stop charging at a
* lower than 100% threshold */
st = SDL_POWERSTATE_CHARGED;
} else {
st = SDL_POWERSTATE_UNKNOWN; /* uh oh */

View File

@@ -20,8 +20,155 @@
*/
#include "../../SDL_internal.h"
#if defined(SDL_VIDEO_RENDER_D3D12) && !defined(SDL_RENDER_DISABLED) && (defined(__XBOXONE__) || defined(__XBOXSERIES__))
#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && (defined(__XBOXONE__) || defined(__XBOXSERIES__))
#include "SDL_render_d3d12_xbox.h"
#include "../../core/windows/SDL_windows.h"
#include <XGameRuntime.h>
#if defined(_MSC_VER) && !defined(__clang__)
#define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str
#else
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
#endif
static const GUID SDL_IID_ID3D12Device1 = { 0x77acce80, 0x638e, 0x4e65, { 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e } };
static const GUID SDL_IID_ID3D12Resource = { 0x696442be, 0xa72e, 0x4059, { 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad } };
static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
extern "C" HRESULT
D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug)
{
HRESULT result;
D3D12XBOX_CREATE_DEVICE_PARAMETERS params;
IDXGIDevice1 *dxgiDevice;
IDXGIAdapter *dxgiAdapter;
IDXGIOutput *dxgiOutput;
SDL_zero(params);
params.Version = D3D12_SDK_VERSION;
params.ProcessDebugFlags = createDebug ? D3D12_PROCESS_DEBUG_FLAG_DEBUG_LAYER_ENABLED : D3D12XBOX_PROCESS_DEBUG_FLAG_NONE;
params.GraphicsCommandQueueRingSizeBytes = D3D12XBOX_DEFAULT_SIZE_BYTES;
params.GraphicsScratchMemorySizeBytes = D3D12XBOX_DEFAULT_SIZE_BYTES;
params.ComputeScratchMemorySizeBytes = D3D12XBOX_DEFAULT_SIZE_BYTES;
result = D3D12XboxCreateDevice(NULL, &params, SDL_IID_ID3D12Device1, (void **) device);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] D3D12XboxCreateDevice"), result);
goto done;
}
result = (*device)->QueryInterface(SDL_IID_IDXGIDevice1, (void **) &dxgiDevice);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] ID3D12Device to IDXGIDevice1"), result);
goto done;
}
result = dxgiDevice->GetAdapter(&dxgiAdapter);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] dxgiDevice->GetAdapter"), result);
goto done;
}
result = dxgiAdapter->EnumOutputs(0, &dxgiOutput);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] dxgiAdapter->EnumOutputs"), result);
goto done;
}
/* Set frame interval */
result = (*device)->SetFrameIntervalX(dxgiOutput, D3D12XBOX_FRAME_INTERVAL_60_HZ, 1, D3D12XBOX_FRAME_INTERVAL_FLAG_NONE);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] SetFrameIntervalX"), result);
goto done;
}
result = (*device)->ScheduleFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, 0, NULL, D3D12XBOX_SCHEDULE_FRAME_EVENT_FLAG_NONE);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] ScheduleFrameEventX"), result);
goto done;
}
done:
return result;
}
extern "C" HRESULT
D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height, void **resource)
{
D3D12_HEAP_PROPERTIES heapProps;
D3D12_RESOURCE_DESC resourceDesc;
SDL_zero(heapProps);
heapProps.Type = D3D12_HEAP_TYPE_DEFAULT;
heapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
heapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
heapProps.CreationNodeMask = 1;
heapProps.VisibleNodeMask = 1;
SDL_zero(resourceDesc);
resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
resourceDesc.Alignment = 0;
resourceDesc.Width = width;
resourceDesc.Height = height;
resourceDesc.DepthOrArraySize = 1;
resourceDesc.MipLevels = 1;
resourceDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
resourceDesc.SampleDesc.Count = 1;
resourceDesc.SampleDesc.Quality = 0;
resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
resourceDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
return device->CreateCommittedResource(&heapProps,
D3D12_HEAP_FLAG_ALLOW_DISPLAY,
&resourceDesc,
D3D12_RESOURCE_STATE_PRESENT,
NULL,
SDL_IID_ID3D12Resource,
resource
);
}
extern "C" HRESULT
D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken)
{
*outToken = D3D12XBOX_FRAME_PIPELINE_TOKEN_NULL;
return device->WaitFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, INFINITE, NULL, D3D12XBOX_WAIT_FRAME_EVENT_FLAG_NONE, outToken);
}
extern "C" HRESULT
D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget)
{
D3D12XBOX_PRESENT_PLANE_PARAMETERS planeParameters;
SDL_zero(planeParameters);
planeParameters.Token = token;
planeParameters.ResourceCount = 1;
planeParameters.ppResources = &renderTarget;
return commandQueue->PresentX(1, &planeParameters, NULL);
}
extern "C" void
D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height)
{
switch (XSystemGetDeviceType()) {
case XSystemDeviceType::XboxScarlettLockhart:
*width = 2560;
*height = 1440;
break;
case XSystemDeviceType::XboxOneX:
case XSystemDeviceType::XboxScarlettAnaconda:
case XSystemDeviceType::XboxOneXDevkit:
case XSystemDeviceType::XboxScarlettDevkit:
*width = 3840;
*height = 2160;
break;
default:
*width = 1920;
*height = 1080;
break;
}
}
#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info."
#endif

View File

@@ -19,4 +19,31 @@
3. This notice may not be removed or altered from any source distribution.
*/
#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info."
#ifndef SDL_render_d3d12_xbox_h_
#define SDL_render_d3d12_xbox_h_
#include "../../SDL_internal.h"
#if defined(__XBOXONE__)
#include <d3d12_x.h>
#else /* __XBOXSERIES__ */
#include <d3d12_xs.h>
#endif
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
extern HRESULT D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug);
extern HRESULT D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height, void **resource);
extern HRESULT D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken);
extern HRESULT D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget);
extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -20,9 +20,124 @@
*/
#include "../../SDL_internal.h"
#if defined(SDL_VIDEO_RENDER_D3D12) && !defined(SDL_RENDER_DISABLED) && defined(__XBOXONE__)
#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__)
#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info."
#include <SDL_stdinc.h>
#include "../../core/windows/SDL_windows.h"
#include <d3d12_x.h>
#include "SDL_shaders_d3d12.h"
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
/* Shader blob headers are generated with a pre-build step using buildshaders.bat */
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Colors_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT601_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT709_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_JPEG_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT601_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT709_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_JPEG_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Textures_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT601_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT709_One.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_JPEG_One.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Color_One.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_NV_One.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Texture_One.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_YUV_One.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_Color_One.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_NV_One.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_Texture_One.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_YUV_One.h"
static struct
{
const void *ps_shader_data;
SIZE_T ps_shader_size;
const void *vs_shader_data;
SIZE_T vs_shader_size;
D3D12_RootSignature root_sig;
} D3D12_shaders[NUM_SHADERS] = {
{ D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
D3D12_VertexShader_Color, sizeof(D3D12_VertexShader_Color),
ROOTSIG_COLOR },
{ D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
D3D12_VertexShader_Texture, sizeof(D3D12_VertexShader_Texture),
ROOTSIG_TEXTURE },
#if SDL_HAVE_YUV
{ D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
#endif
};
static struct
{
const void *rs_shader_data;
SIZE_T rs_shader_size;
} D3D12_rootsigs[NUM_ROOTSIGS] = {
{ D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) },
{ D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) },
#if SDL_HAVE_YUV
{ D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) },
{ D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) },
#endif
};
extern "C" void
D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
{
outBytecode->pShaderBytecode = D3D12_shaders[shader].vs_shader_data;
outBytecode->BytecodeLength = D3D12_shaders[shader].vs_shader_size;
}
extern "C" void
D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
{
outBytecode->pShaderBytecode = D3D12_shaders[shader].ps_shader_data;
outBytecode->BytecodeLength = D3D12_shaders[shader].ps_shader_size;
}
extern "C" D3D12_RootSignature
D3D12_GetRootSignatureType(D3D12_Shader shader)
{
return D3D12_shaders[shader].root_sig;
}
extern "C" void
D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode)
{
outBytecode->pShaderBytecode = D3D12_rootsigs[rootSig].rs_shader_data;
outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
}
#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__) */

View File

@@ -20,9 +20,124 @@
*/
#include "../../SDL_internal.h"
#if defined(SDL_VIDEO_RENDER_D3D12) && !defined(SDL_RENDER_DISABLED) && defined(__XBOXSERIES__)
#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__)
#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info."
#include <SDL_stdinc.h>
#include "../../core/windows/SDL_windows.h"
#include <d3d12_xs.h>
#include "SDL_shaders_d3d12.h"
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
/* Shader blob headers are generated with a pre-build step using buildshaders.bat */
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Colors_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_Textures_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT601_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT709_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_JPEG_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT601_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT709_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_JPEG_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT601_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT709_Series.h"
#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_JPEG_Series.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Color_Series.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_Texture_Series.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_NV_Series.h"
#include "../VisualC-GDK/shaders/D3D12_VertexShader_YUV_Series.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_Color_Series.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_Texture_Series.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_YUV_Series.h"
#include "../VisualC-GDK/shaders/D3D12_RootSig_NV_Series.h"
static struct
{
const void *ps_shader_data;
SIZE_T ps_shader_size;
const void *vs_shader_data;
SIZE_T vs_shader_size;
D3D12_RootSignature root_sig;
} D3D12_shaders[NUM_SHADERS] = {
{ D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
D3D12_VertexShader_Color, sizeof(D3D12_VertexShader_Color),
ROOTSIG_COLOR },
{ D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
D3D12_VertexShader_Texture, sizeof(D3D12_VertexShader_Texture),
ROOTSIG_TEXTURE },
#if SDL_HAVE_YUV
{ D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
ROOTSIG_YUV },
{ D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
{ D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
ROOTSIG_NV },
#endif
};
static struct
{
const void *rs_shader_data;
SIZE_T rs_shader_size;
} D3D12_rootsigs[NUM_ROOTSIGS] = {
{ D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) },
{ D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) },
#if SDL_HAVE_YUV
{ D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) },
{ D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) },
#endif
};
extern "C" void
D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
{
outBytecode->pShaderBytecode = D3D12_shaders[shader].vs_shader_data;
outBytecode->BytecodeLength = D3D12_shaders[shader].vs_shader_size;
}
extern "C" void
D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode)
{
outBytecode->pShaderBytecode = D3D12_shaders[shader].ps_shader_data;
outBytecode->BytecodeLength = D3D12_shaders[shader].ps_shader_size;
}
extern "C" D3D12_RootSignature
D3D12_GetRootSignatureType(D3D12_Shader shader)
{
return D3D12_shaders[shader].root_sig;
}
extern "C" void
D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode)
{
outBytecode->pShaderBytecode = D3D12_rootsigs[rootSig].rs_shader_data;
outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size;
}
#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__) */

View File

@@ -30,6 +30,9 @@
#if defined(HAVE_QSORT)
void SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *))
{
if (!base) {
return;
}
qsort(base, nmemb, size, compare);
}

View File

@@ -149,9 +149,12 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
#define BILINEAR___START \
int i; \
int fp_sum_h, fp_step_h, left_pad_h, right_pad_h; \
int fp_sum_w, fp_step_w, left_pad_w, right_pad_w; \
int fp_sum_w_init, left_pad_w_init, right_pad_w_init, dst_gap, middle_init; \
Sint64 fp_sum_h; \
int fp_step_h, left_pad_h, right_pad_h; \
Sint64 fp_sum_w; \
int fp_step_w, left_pad_w, right_pad_w; \
Sint64 fp_sum_w_init; \
int left_pad_w_init, right_pad_w_init, dst_gap, middle_init; \
get_scaler_datas(src_h, dst_h, &fp_sum_h, &fp_step_h, &left_pad_h, &right_pad_h); \
get_scaler_datas(src_w, dst_w, &fp_sum_w, &fp_step_w, &left_pad_w, &right_pad_w); \
fp_sum_w_init = fp_sum_w + left_pad_w * fp_step_w; \
@@ -194,12 +197,12 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
// OK with clang 12.0.0 / Xcode
__attribute__((noinline))
#endif
static void get_scaler_datas(int src_nb, int dst_nb, int *fp_start, int *fp_step, int *left_pad, int *right_pad)
static void get_scaler_datas(int src_nb, int dst_nb, Sint64 *fp_start, int *fp_step, int *left_pad, int *right_pad)
{
int step = FIXED_POINT(src_nb) / (dst_nb); /* source step in fixed point */
int x0 = FP_ONE / 2; /* dst first pixel center at 0.5 in fixed point */
int fp_sum;
Sint64 fp_sum;
int i;
#if 0
/* scale to source coordinates */

View File

@@ -772,7 +772,7 @@ int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect,
if (dstrect) { /* update output parameter */
*dstrect = r_dst;
}
return SDL_LowerBlit(src, &r_src, dst, dstrect);
return SDL_LowerBlit(src, &r_src, dst, &r_dst);
}
end:

View File

@@ -1496,20 +1496,21 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
/* Generate a mode change event here */
if (resized) {
#if !defined(__ANDROID__) && !defined(__WIN32__)
/* Android may not resize the window to exactly what our fullscreen mode is, especially on
* windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
* use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
* Android's SetWindowFullscreen will generate the window event for us with the proper final size.
*/
if (SDL_strcmp(_this->name, "Android") != 0 && SDL_strcmp(_this->name, "windows") != 0) {
/* Android may not resize the window to exactly what our fullscreen mode is, especially on
* windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't
* use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such,
* Android's SetWindowFullscreen will generate the window event for us with the proper final size.
*/
/* This is also unnecessary on Win32 (WIN_SetWindowFullscreen calls SetWindowPos,
* WM_WINDOWPOSCHANGED will send SDL_WINDOWEVENT_RESIZED). Also, on Windows with DPI scaling enabled,
* we're keeping modes in pixels, but window sizes in dpi-scaled points, so this would be a unit mismatch.
*/
SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
fullscreen_mode.w, fullscreen_mode.h);
}
/* This is also unnecessary on Win32 (WIN_SetWindowFullscreen calls SetWindowPos,
* WM_WINDOWPOSCHANGED will send SDL_WINDOWEVENT_RESIZED). Also, on Windows with DPI scaling enabled,
* we're keeping modes in pixels, but window sizes in dpi-scaled points, so this would be a unit mismatch.
*/
SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED,
fullscreen_mode.w, fullscreen_mode.h);
#endif
} else {
SDL_OnWindowResized(other);
}

View File

@@ -4,7 +4,7 @@
#if SDL_HAVE_YUV
#include "yuv_rgb.h"
#include "yuv_rgb_internal.h"
#include "SDL_cpuinfo.h"
#ifdef __loongarch_sx

View File

@@ -140,7 +140,7 @@ add_sdl_test_executable(testresample NEEDS_RESOURCES testresample.c)
add_sdl_test_executable(testaudioinfo testaudioinfo.c)
file(GLOB TESTAUTOMATION_SOURCE_FILES testautomation*.c)
add_sdl_test_executable(testautomation NEEDS_RESOURCES ${TESTAUTOMATION_SOURCE_FILES})
add_sdl_test_executable(testautomation NONINTERACTIVE NEEDS_RESOURCES ${TESTAUTOMATION_SOURCE_FILES})
add_sdl_test_executable(testmultiaudio NEEDS_RESOURCES testmultiaudio.c testutils.c)
add_sdl_test_executable(testaudiohotplug NEEDS_RESOURCES testaudiohotplug.c testutils.c)
add_sdl_test_executable(testaudiocapture testaudiocapture.c)
@@ -491,6 +491,7 @@ foreach(TESTCASE ${SDL_TESTS_NONINTERACTIVE})
endif()
endforeach()
set_tests_properties(testautomation PROPERTIES TIMEOUT 120)
set_tests_properties(testthread PROPERTIES TIMEOUT 40)
set_tests_properties(testtimer PROPERTIES TIMEOUT 60)
if(TARGET testfilesystem_pre)

View File

@@ -95,7 +95,7 @@ installedtestsmetadir = $(datadir)/installed-tests/SDL2
generatetestmeta:
rm -f *.test
set -e; for exe in $(noninteractive) $(needs_audio) $(needs_display); do \
set -e; for exe in $(TESTS); do \
sed \
-e 's#@installedtestsdir@#$(installedtestsdir)#g' \
-e "s#@exe@#$$exe#g" \
@@ -386,8 +386,12 @@ distclean: clean
rm -f config.status config.cache config.log
rm -rf $(srcdir)/autom4te*
noninteractive = \
TESTS = \
testatomic$(EXE) \
testaudioinfo$(EXE) \
testautomation$(EXE) \
testbounds$(EXE) \
testdisplayinfo$(EXE) \
testerror$(EXE) \
testevdev$(EXE) \
testfilesystem$(EXE) \
@@ -396,23 +400,12 @@ noninteractive = \
testplatform$(EXE) \
testpower$(EXE) \
testqsort$(EXE) \
testsurround$(EXE) \
testthread$(EXE) \
testtimer$(EXE) \
testver$(EXE) \
$(NULL)
needs_audio = \
testaudioinfo$(EXE) \
testsurround$(EXE) \
$(NULL)
needs_display = \
testbounds$(EXE) \
testdisplayinfo$(EXE) \
$(NULL)
TESTS = $(noninteractive) $(needs_audio) $(needs_display)
check:
@set -e; \
status=0; \

View File

@@ -52,6 +52,42 @@ void SDLCALL _audio_testCallback(void *userdata, Uint8 *stream, int len)
_audio_testCallbackLength += len;
}
#if defined(__linux__)
/* Linux builds can include many audio drivers, but some are very
* obscure and typically unsupported on modern systems. They will
* be skipped in tests that run against all included drivers, as
* they are basically guaranteed to fail.
*/
static SDL_bool DriverIsProblematic(const char *driver)
{
static const char *driverList[] = {
/* Omnipresent in Linux builds, but deprecated since 2002,
* very rarely used on Linux nowadays, and is almost certainly
* guaranteed to fail.
*/
"dsp",
/* OpenBSD sound API. Can be used on Linux, but very rare. */
"sndio",
/* Always fails on initialization and/or opening a device.
* Does anyone or anything actually use this?
*/
"nas"
};
int i;
for (i = 0; i < SDL_arraysize(driverList); ++i) {
if (SDL_strcmp(driver, driverList[i]) == 0) {
return SDL_TRUE;
}
}
return SDL_FALSE;
}
#endif
/* Test case functions */
/**
@@ -89,15 +125,33 @@ int audio_initQuitAudio()
SDL_QuitSubSystem(SDL_INIT_AUDIO);
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
/* Loop over all available audio drivers */
iMax = SDL_GetNumAudioDrivers();
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
/* Was a specific driver requested? */
audioDriver = SDL_GetHint(SDL_HINT_AUDIODRIVER);
if (audioDriver == NULL) {
/* Loop over all available audio drivers */
iMax = SDL_GetNumAudioDrivers();
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
} else {
/* A specific driver was requested for testing */
iMax = 1;
}
for (i = 0; i < iMax; i++) {
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
if (audioDriver == NULL) {
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
#if defined(__linux__)
if (DriverIsProblematic(audioDriver)) {
SDLTest_Log("Audio driver '%s' flagged as problematic: skipping init/quit test (set SDL_AUDIODRIVER=%s to force)", audioDriver, audioDriver);
audioDriver = NULL;
continue;
}
#endif
}
if (hint && SDL_strcmp(audioDriver, hint) != 0) {
continue;
@@ -111,6 +165,8 @@ int audio_initQuitAudio()
/* Call Quit */
SDL_AudioQuit();
SDLTest_AssertPass("Call to SDL_AudioQuit()");
audioDriver = NULL;
}
/* NULL driver specification */
@@ -151,15 +207,33 @@ int audio_initOpenCloseQuitAudio()
SDL_QuitSubSystem(SDL_INIT_AUDIO);
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
/* Loop over all available audio drivers */
iMax = SDL_GetNumAudioDrivers();
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
/* Was a specific driver requested? */
audioDriver = SDL_GetHint(SDL_HINT_AUDIODRIVER);
if (audioDriver == NULL) {
/* Loop over all available audio drivers */
iMax = SDL_GetNumAudioDrivers();
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
} else {
/* A specific driver was requested for testing */
iMax = 1;
}
for (i = 0; i < iMax; i++) {
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
if (audioDriver == NULL) {
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
#if defined(__linux__)
if (DriverIsProblematic(audioDriver)) {
SDLTest_Log("Audio driver '%s' flagged as problematic: skipping device open/close test (set SDL_AUDIODRIVER=%s to force)", audioDriver, audioDriver);
audioDriver = NULL;
continue;
}
#endif
}
if (hint && SDL_strcmp(audioDriver, hint) != 0) {
continue;
@@ -173,6 +247,17 @@ int audio_initOpenCloseQuitAudio()
SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
/* Check for output devices */
result = SDL_GetNumAudioDevices(SDL_FALSE);
SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(SDL_FALSE)");
SDLTest_AssertCheck(result >= 0, "Validate result value; expected: >=0 got: %d", result);
if (result <= 0) {
SDLTest_Log("No output devices for '%s': skipping device open/close test", audioDriver);
SDL_AudioQuit();
SDLTest_AssertPass("Call to SDL_AudioQuit()");
break;
}
/* Set spec */
SDL_memset(&desired, 0, sizeof(desired));
switch (j) {
@@ -217,7 +302,10 @@ int audio_initOpenCloseQuitAudio()
}
} /* spec loop */
} /* driver loop */
audioDriver = NULL;
} /* driver loop */
/* Restart audio again */
_audioSetUp(NULL);
@@ -245,15 +333,33 @@ int audio_pauseUnpauseAudio()
SDL_QuitSubSystem(SDL_INIT_AUDIO);
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
/* Loop over all available audio drivers */
iMax = SDL_GetNumAudioDrivers();
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
/* Was a specific driver requested? */
audioDriver = SDL_GetHint(SDL_HINT_AUDIODRIVER);
if (audioDriver == NULL) {
/* Loop over all available audio drivers */
iMax = SDL_GetNumAudioDrivers();
SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()");
SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax);
} else {
/* A specific driver was requested for testing */
iMax = 1;
}
for (i = 0; i < iMax; i++) {
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
if (audioDriver == NULL) {
audioDriver = SDL_GetAudioDriver(i);
SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i);
SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL");
SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */
#if defined(__linux__)
if (DriverIsProblematic(audioDriver)) {
SDLTest_Log("Audio driver '%s' flagged as problematic: skipping pause/unpause test (set SDL_AUDIODRIVER=%s to force)", audioDriver, audioDriver);
audioDriver = NULL;
continue;
}
#endif
}
if (hint && SDL_strcmp(audioDriver, hint) != 0) {
continue;
@@ -267,6 +373,16 @@ int audio_pauseUnpauseAudio()
SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver);
SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result);
result = SDL_GetNumAudioDevices(SDL_FALSE);
SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(SDL_FALSE)");
SDLTest_AssertCheck(result >= 0, "Validate result value; expected: >=0 got: %d", result);
if (result <= 0) {
SDLTest_Log("No output devices for '%s': skipping pause/unpause test", audioDriver);
SDL_AudioQuit();
SDLTest_AssertPass("Call to SDL_AudioQuit()");
break;
}
/* Set spec */
SDL_memset(&desired, 0, sizeof(desired));
switch (j) {
@@ -341,7 +457,10 @@ int audio_pauseUnpauseAudio()
SDLTest_AssertPass("Call to SDL_AudioQuit()");
} /* spec loop */
} /* driver loop */
audioDriver = NULL;
} /* driver loop */
/* Restart audio again */
_audioSetUp(NULL);

View File

@@ -68,6 +68,10 @@ int events_pushPumpAndPollUserevent(void *arg)
SDLTest_AssertPass("Call to SDL_PollEvent()");
SDLTest_AssertCheck(result == 1, "Check result from SDL_PollEvent, expected: 1, got: %d", result);
/* Need to finish getting all events and sentinel, otherwise other tests that rely on event are in bad state */
while (SDL_PollEvent(&event2)) {
}
return TEST_COMPLETED;
}

View File

@@ -463,32 +463,34 @@ int keyboard_setTextInputRect(void *arg)
*/
int keyboard_setTextInputRectNegative(void *arg)
{
int platform_sets_error_message = SDL_strcmp(SDL_GetCurrentVideoDriver(), "windows") == 0 ||
SDL_strcmp(SDL_GetCurrentVideoDriver(), "android") == 0 ||
SDL_strcmp(SDL_GetCurrentVideoDriver(), "cococa") == 0;
/* Some platforms set also an error message; prepare for checking it */
#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_COCOA)
const char *expectedError = "Parameter 'rect' is invalid";
const char *error;
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
#endif
/* NULL refRect */
SDL_SetTextInputRect(NULL);
SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
/* Some platforms set also an error message; so check it */
#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_COCOA)
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
if (platform_sets_error_message) {
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
if (error != NULL) {
SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0,
"Validate error message, expected: '%s', got: '%s'", expectedError, error);
}
}
SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()");
#endif
return TEST_COMPLETED;
}

View File

@@ -9,37 +9,6 @@
#include "SDL.h"
#include "SDL_test.h"
/* !
* \brief Tests SDL_Init() and SDL_Quit() of Joystick and Haptic subsystems
* \sa
* http://wiki.libsdl.org/SDL_Init
* http://wiki.libsdl.org/SDL_Quit
*/
static int main_testInitQuitJoystickHaptic(void *arg)
{
#if defined SDL_JOYSTICK_DISABLED || defined SDL_HAPTIC_DISABLED
return TEST_SKIPPED;
#else
int enabled_subsystems;
int previous_subsystems = SDL_WasInit(SDL_INIT_EVERYTHING);
int initialized_subsystems = SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC;
SDLTest_AssertCheck(SDL_Init(initialized_subsystems) == 0, "SDL_Init multiple systems.");
enabled_subsystems = SDL_WasInit(initialized_subsystems);
SDLTest_AssertCheck(enabled_subsystems == initialized_subsystems, "SDL_WasInit(SDL_INIT_EVERYTHING) contains all systems (%i)", enabled_subsystems);
SDL_Quit();
enabled_subsystems = SDL_WasInit(initialized_subsystems);
SDLTest_AssertCheck(enabled_subsystems == 0, "SDL_Quit should shut down everything (%i)", enabled_subsystems);
SDL_Init(previous_subsystems);
return TEST_COMPLETED;
#endif
}
/* !
* \brief Tests SDL_InitSubSystem() and SDL_QuitSubSystem()
* \sa
@@ -157,22 +126,18 @@ main_testSetError(void *arg)
#endif
static const SDLTest_TestCaseReference mainTest1 = {
(SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED
};
static const SDLTest_TestCaseReference mainTest2 = {
(SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED
};
static const SDLTest_TestCaseReference mainTest3 = {
static const SDLTest_TestCaseReference mainTest2 = {
(SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED
};
static const SDLTest_TestCaseReference mainTest4 = {
static const SDLTest_TestCaseReference mainTest3 = {
(SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED
};
static const SDLTest_TestCaseReference mainTest5 = {
static const SDLTest_TestCaseReference mainTest4 = {
(SDLTest_TestCaseFp)main_testSetError, "main_testSetError", "Tests that SDL_SetError() handles arbitrarily large strings", TEST_ENABLED
};
@@ -182,7 +147,6 @@ static const SDLTest_TestCaseReference *mainTests[] = {
&mainTest2,
&mainTest3,
&mainTest4,
&mainTest5,
NULL
};
@@ -193,5 +157,3 @@ SDLTest_TestSuiteReference mainTestSuite = {
mainTests,
NULL
};
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -49,6 +49,12 @@ typedef struct
double expected;
} dd_to_d;
#define DD_TO_D_CASE(IDX, X, Y, E) do { \
cases[IDX].x_input = (X); \
cases[IDX].y_input = (Y); \
cases[IDX].expected = (E); \
} while (0)
/*
NB: You cannot create an array of these structures containing INFINITY or NAN.
On platforms such as OS/2, they are defined as 'extern const double' making them
@@ -102,8 +108,15 @@ helper_dtod_inexact(const char *func_name, d_to_d_func func,
Uint32 i;
for (i = 0; i < cases_size; i++) {
const double result = func(cases[i].input);
SDLTest_AssertCheck(result >= cases[i].expected - EPSILON &&
result <= cases[i].expected + EPSILON,
double diff = result - cases[i].expected;
double max_err = (cases[i].expected + 1.) * EPSILON;
if (diff < 0) {
diff = -diff;
}
if (max_err < 0) {
max_err = -max_err;
}
SDLTest_AssertCheck(diff <= max_err,
"%s(%f), expected [%f,%f], got %f",
func_name,
cases[i].input,
@@ -131,6 +144,8 @@ helper_ddtod(const char *func_name, dd_to_d_func func,
Uint32 i;
for (i = 0; i < cases_size; i++) {
const double result = func(cases[i].x_input, cases[i].y_input);
/* By using the result as input, the compiler is less likely to use higher precision floating point number */
(void)SDL_sin(result);
SDLTest_AssertCheck(result == cases[i].expected,
"%s(%f,%f), expected %f, got %f",
func_name,
@@ -157,8 +172,16 @@ helper_ddtod_inexact(const char *func_name, dd_to_d_func func,
Uint32 i;
for (i = 0; i < cases_size; i++) {
const double result = func(cases[i].x_input, cases[i].y_input);
SDLTest_AssertCheck(result >= cases[i].expected - EPSILON &&
result <= cases[i].expected + EPSILON,
double diff = result - cases[i].expected;
double max_err = (cases[i].expected + 1.) * EPSILON;
if (diff < 0) {
diff = -diff;
}
if (max_err < 0) {
max_err = -max_err;
}
SDLTest_AssertCheck(diff <= max_err,
"%s(%f,%f), expected [%f,%f], got %f",
func_name,
cases[i].x_input, cases[i].y_input,
@@ -1646,14 +1669,16 @@ static int
pow_regularCases(void *args)
{
const dd_to_d regular_cases[] = {
#if 0 /* These tests fail when using the Mingw C runtime, we'll disable them for now */
{ -391.25, -2.0, 0.00000653267870448815438463212659780943170062528224661946296691894531250 },
{ -72.3, 12.0, 20401381050275984310272.0 },
#endif
{ -5.0, 3.0, -125.0 },
{ 3.0, 2.5, 15.58845726811989607085706666111946105957031250 },
{ 39.23, -1.5, 0.0040697950366865498147972424192175822099670767784118652343750 },
{ 478.972, 12.125, 315326359630449587856007411793920.0 }
};
return helper_ddtod("Pow", SDL_pow, regular_cases, SDL_arraysize(regular_cases));
return helper_ddtod_inexact("Pow", SDL_pow, regular_cases, SDL_arraysize(regular_cases));
}
/**
@@ -1981,24 +2006,24 @@ static int
cos_precisionTest(void *args)
{
const d_to_d precision_cases[] = {
{ M_PI * 1.0 / 10.0, 0.9510565162 },
{ M_PI * 2.0 / 10.0, 0.8090169943 },
{ M_PI * 3.0 / 10.0, 0.5877852522 },
{ M_PI * 4.0 / 10.0, 0.3090169943 },
{ M_PI * 1.0 / 10.0, 0.9510565162951535 },
{ M_PI * 2.0 / 10.0, 0.8090169943749475 },
{ M_PI * 3.0 / 10.0, 0.5877852522924731 },
{ M_PI * 4.0 / 10.0, 0.30901699437494745 },
{ M_PI * 5.0 / 10.0, 0.0 },
{ M_PI * 6.0 / 10.0, -0.3090169943 },
{ M_PI * 7.0 / 10.0, -0.5877852522 },
{ M_PI * 8.0 / 10.0, -0.8090169943 },
{ M_PI * 9.0 / 10.0, -0.9510565162 },
{ M_PI * -1.0 / 10.0, 0.9510565162 },
{ M_PI * -2.0 / 10.0, 0.8090169943 },
{ M_PI * -3.0 / 10.0, 0.5877852522 },
{ M_PI * -4.0 / 10.0, 0.3090169943 },
{ M_PI * 6.0 / 10.0, -0.30901699437494734 },
{ M_PI * 7.0 / 10.0, -0.587785252292473 },
{ M_PI * 8.0 / 10.0, -0.8090169943749473 },
{ M_PI * 9.0 / 10.0, -0.9510565162951535 },
{ M_PI * -1.0 / 10.0, 0.9510565162951535 },
{ M_PI * -2.0 / 10.0, 0.8090169943749475 },
{ M_PI * -3.0 / 10.0, 0.5877852522924731 },
{ M_PI * -4.0 / 10.0, 0.30901699437494745 },
{ M_PI * -5.0 / 10.0, 0.0 },
{ M_PI * -6.0 / 10.0, -0.3090169943 },
{ M_PI * -7.0 / 10.0, -0.5877852522 },
{ M_PI * -8.0 / 10.0, -0.8090169943 },
{ M_PI * -9.0 / 10.0, -0.9510565162 }
{ M_PI * -6.0 / 10.0, -0.30901699437494734 },
{ M_PI * -7.0 / 10.0, -0.587785252292473 },
{ M_PI * -8.0 / 10.0, -0.8090169943749473 },
{ M_PI * -9.0 / 10.0, -0.9510565162951535 }
};
return helper_dtod_inexact("Cos", SDL_cos, precision_cases, SDL_arraysize(precision_cases));
}
@@ -2099,23 +2124,23 @@ static int
sin_precisionTest(void *args)
{
const d_to_d precision_cases[] = {
{ M_PI * 1.0 / 10.0, 0.3090169943 },
{ M_PI * 2.0 / 10.0, 0.5877852522 },
{ M_PI * 3.0 / 10.0, 0.8090169943 },
{ M_PI * 4.0 / 10.0, 0.9510565162 },
{ M_PI * 6.0 / 10.0, 0.9510565162 },
{ M_PI * 7.0 / 10.0, 0.8090169943 },
{ M_PI * 8.0 / 10.0, 0.5877852522 },
{ M_PI * 9.0 / 10.0, 0.3090169943 },
{ M_PI * 1.0 / 10.0, 0.3090169943749474 },
{ M_PI * 2.0 / 10.0, 0.5877852522924731 },
{ M_PI * 3.0 / 10.0, 0.8090169943749475 },
{ M_PI * 4.0 / 10.0, 0.9510565162951535 },
{ M_PI * 6.0 / 10.0, 0.9510565162951536 },
{ M_PI * 7.0 / 10.0, 0.8090169943749475 },
{ M_PI * 8.0 / 10.0, 0.5877852522924732 },
{ M_PI * 9.0 / 10.0, 0.3090169943749475 },
{ M_PI, 0.0 },
{ M_PI * -1.0 / 10.0, -0.3090169943 },
{ M_PI * -2.0 / 10.0, -0.5877852522 },
{ M_PI * -3.0 / 10.0, -0.8090169943 },
{ M_PI * -4.0 / 10.0, -0.9510565162 },
{ M_PI * -6.0 / 10.0, -0.9510565162 },
{ M_PI * -7.0 / 10.0, -0.8090169943 },
{ M_PI * -8.0 / 10.0, -0.5877852522 },
{ M_PI * -9.0 / 10.0, -0.3090169943 },
{ M_PI * -1.0 / 10.0, -0.3090169943749474 },
{ M_PI * -2.0 / 10.0, -0.5877852522924731 },
{ M_PI * -3.0 / 10.0, -0.8090169943749475 },
{ M_PI * -4.0 / 10.0, -0.9510565162951535 },
{ M_PI * -6.0 / 10.0, -0.9510565162951536 },
{ M_PI * -7.0 / 10.0, -0.8090169943749475 },
{ M_PI * -8.0 / 10.0, -0.5877852522924732 },
{ M_PI * -9.0 / 10.0, -0.3090169943749475 },
{ -M_PI, 0.0 },
};
return helper_dtod_inexact("Sin", SDL_sin, precision_cases, SDL_arraysize(precision_cases));
@@ -2215,26 +2240,26 @@ static int
tan_precisionTest(void *args)
{
const d_to_d precision_cases[] = {
{ M_PI * 1.0 / 11.0, 0.2936264929 },
{ M_PI * 2.0 / 11.0, 0.6426609771 },
{ M_PI * 3.0 / 11.0, 1.1540615205 },
{ M_PI * 4.0 / 11.0, 2.1896945629 },
{ M_PI * 5.0 / 11.0, 6.9551527717 },
{ M_PI * 6.0 / 11.0, -6.9551527717 },
{ M_PI * 7.0 / 11.0, -2.1896945629 },
{ M_PI * 8.0 / 11.0, -1.1540615205 },
{ M_PI * 9.0 / 11.0, -0.6426609771 },
{ M_PI * 10.0 / 11.0, -0.2936264929 },
{ M_PI * -1.0 / 11.0, -0.2936264929 },
{ M_PI * -2.0 / 11.0, -0.6426609771 },
{ M_PI * -3.0 / 11.0, -1.1540615205 },
{ M_PI * -4.0 / 11.0, -2.1896945629 },
{ M_PI * -5.0 / 11.0, -6.9551527717 },
{ M_PI * -6.0 / 11.0, 6.9551527717 },
{ M_PI * -7.0 / 11.0, 2.1896945629 },
{ M_PI * -8.0 / 11.0, 1.1540615205 },
{ M_PI * -9.0 / 11.0, 0.6426609771 },
{ M_PI * -10.0 / 11.0, 0.2936264929 }
{ M_PI * 1.0 / 11.0, 0.29362649293836673 },
{ M_PI * 2.0 / 11.0, 0.642660977168331 },
{ M_PI * 3.0 / 11.0, 1.1540615205330094 },
{ M_PI * 4.0 / 11.0, 2.189694562989681 },
{ M_PI * 5.0 / 11.0, 6.9551527717734745 },
{ M_PI * 6.0 / 11.0, -6.955152771773481 },
{ M_PI * 7.0 / 11.0, -2.189694562989682 },
{ M_PI * 8.0 / 11.0, -1.1540615205330096 },
{ M_PI * 9.0 / 11.0, -0.6426609771683314 },
{ M_PI * 10.0 / 11.0, -0.2936264929383667 },
{ M_PI * -1.0 / 11.0, -0.29362649293836673 },
{ M_PI * -2.0 / 11.0, -0.642660977168331 },
{ M_PI * -3.0 / 11.0, -1.1540615205330094 },
{ M_PI * -4.0 / 11.0, -2.189694562989681 },
{ M_PI * -5.0 / 11.0, -6.9551527717734745 },
{ M_PI * -6.0 / 11.0, 6.955152771773481 },
{ M_PI * -7.0 / 11.0, 2.189694562989682 },
{ M_PI * -8.0 / 11.0, 1.1540615205330096 },
{ M_PI * -9.0 / 11.0, 0.6426609771683314 },
{ M_PI * -10.0 / 11.0, 0.2936264929383667 }
};
return helper_dtod_inexact("Tan", SDL_tan, precision_cases, SDL_arraysize(precision_cases));
}
@@ -2399,26 +2424,26 @@ static int
asin_precisionTest(void *args)
{
const d_to_d precision_cases[] = {
{ 0.9, 1.1197695149 },
{ 0.8, 0.9272952180 },
{ 0.7, 0.7753974966 },
{ 0.6, 0.6435011087 },
{ 0.5, 0.5235987755 },
{ 0.4, 0.4115168460 },
{ 0.3, 0.3046926540 },
{ 0.2, 0.2013579207 },
{ 0.1, 0.1001674211 },
{ 0.9, 1.1197695149986342 },
{ 0.8, 0.9272952180016123 },
{ 0.7, 0.775397496610753 },
{ 0.6, 0.6435011087932844 },
{ 0.5, 0.5235987755982989 },
{ 0.4, 0.41151684606748806 },
{ 0.3, 0.3046926540153976 },
{ 0.2, 0.20135792079033074 },
{ 0.1, 0.10016742116155977 },
{ 0.0, 0.0 },
{ -0.0, -0.0 },
{ -0.1, -0.1001674211 },
{ -0.2, -0.2013579207 },
{ -0.3, -0.3046926540 },
{ -0.4, -0.4115168460 },
{ -0.5, -0.5235987755 },
{ -0.6, -0.6435011087 },
{ -0.7, -0.7753974966 },
{ -0.8, -0.9272952180 },
{ -0.9, -1.1197695149 }
{ -0.1, -0.10016742116155977 },
{ -0.2, -0.20135792079033074 },
{ -0.3, -0.3046926540153976 },
{ -0.4, -0.41151684606748806 },
{ -0.5, -0.5235987755982989 },
{ -0.6, -0.6435011087932844 },
{ -0.7, -0.775397496610753 },
{ -0.8, -0.9272952180016123 },
{ -0.9, -1.1197695149986342 }
};
return helper_dtod_inexact("Asin", SDL_asin, precision_cases, SDL_arraysize(precision_cases));
}
@@ -2493,24 +2518,24 @@ static int
atan_precisionTest(void *args)
{
const d_to_d precision_cases[] = {
{ 6.313751514675041, 1.4137166941 },
{ 3.0776835371752527, 1.2566370614 },
{ 1.9626105055051504, 1.0995574287 },
{ 1.3763819204711734, 0.9424777960 },
{ 1.0, 0.7853981633 },
{ 0.7265425280053609, 0.6283185307 },
{ 0.5095254494944288, 0.4712388980 },
{ 0.3249196962329063, 0.3141592653 },
{ 0.15838444032453627, 0.1570796326 },
{ -0.15838444032453627, -0.1570796326 },
{ -0.3249196962329063, -0.3141592653 },
{ -0.5095254494944288, -0.4712388980 },
{ -0.7265425280053609, -0.6283185307 },
{ -1.0, -0.7853981633 },
{ -1.3763819204711734, -0.9424777960 },
{ -1.9626105055051504, -1.0995574287 },
{ -3.0776835371752527, -1.2566370614 },
{ -6.313751514675041, -1.4137166941 },
{ 6.313751514675041, 1.413716694115407 },
{ 3.0776835371752527, 1.2566370614359172 },
{ 1.9626105055051504, 1.0995574287564276 },
{ 1.3763819204711734, 0.9424777960769379 },
{ 1.0, 0.7853981633974483 },
{ 0.7265425280053609, 0.6283185307179586 },
{ 0.5095254494944288, 0.47123889803846897 },
{ 0.3249196962329063, 0.3141592653589793 },
{ 0.15838444032453627, 0.15707963267948966 },
{ -0.15838444032453627, -0.15707963267948966 },
{ -0.3249196962329063, -0.3141592653589793 },
{ -0.5095254494944288, -0.47123889803846897 },
{ -0.7265425280053609, -0.6283185307179586 },
{ -1.0, -0.7853981633974483 },
{ -1.3763819204711734, -0.9424777960769379 },
{ -1.9626105055051504, -1.0995574287564276 },
{ -3.0776835371752527, -1.2566370614359172 },
{ -6.313751514675041, -1.413716694115407 },
};
return helper_dtod_inexact("Atan", SDL_atan, precision_cases, SDL_arraysize(precision_cases));
}
@@ -2586,29 +2611,12 @@ atan2_xZeroCases(void *args)
static int
atan2_bothInfCases(void *args)
{
double result;
result = SDL_atan2(INFINITY, INFINITY);
SDLTest_AssertCheck(SDL_fabs(M_PI / 4.0 - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
INFINITY, INFINITY, M_PI / 4.0, result);
result = SDL_atan2(INFINITY, -INFINITY);
SDLTest_AssertCheck(SDL_fabs(3.0 * M_PI / 4.0 - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
INFINITY, -INFINITY, 3.0 * M_PI / 4.0, result);
result = SDL_atan2(-INFINITY, INFINITY);
SDLTest_AssertCheck(SDL_fabs(-M_PI / 4.0 - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
-INFINITY, INFINITY, -M_PI / 4.0, result);
result = SDL_atan2(-INFINITY, -INFINITY);
SDLTest_AssertCheck(SDL_fabs(-3.0 * M_PI / 4.0 - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
-INFINITY, -INFINITY, -3.0 * M_PI / 4.0, result);
return TEST_COMPLETED;
dd_to_d cases[4];
DD_TO_D_CASE(0, INFINITY, INFINITY, 1.0 * M_PI / 4.0);
DD_TO_D_CASE(1, INFINITY, -INFINITY, 3.0 * M_PI / 4.0);
DD_TO_D_CASE(2, -INFINITY, INFINITY, -1.0 * M_PI / 4.0);
DD_TO_D_CASE(3, -INFINITY, -INFINITY, -3.0 * M_PI / 4.0);
return helper_ddtod("SDL_atan2(bothInfCases)", SDL_atan2, cases, SDL_arraysize(cases));
}
/**
@@ -2618,29 +2626,12 @@ atan2_bothInfCases(void *args)
static int
atan2_yInfCases(void *args)
{
double result;
result = SDL_atan2(INFINITY, 1.0);
SDLTest_AssertCheck(SDL_fabs(M_PI / 2.0 - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
INFINITY, 1.0, M_PI / 2.0, result);
result = SDL_atan2(INFINITY, -1.0);
SDLTest_AssertCheck(SDL_fabs(M_PI / 2.0 - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
INFINITY, -1.0, M_PI / 2.0, result);
result = SDL_atan2(-INFINITY, 1.0);
SDLTest_AssertCheck(SDL_fabs(-M_PI / 2.0 - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
-INFINITY, 1.0, -M_PI / 2.0, result);
result = SDL_atan2(-INFINITY, -1.0);
SDLTest_AssertCheck(SDL_fabs(-M_PI / 2.0 - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
-INFINITY, -1.0, -M_PI / 2.0, result);
return TEST_COMPLETED;
dd_to_d cases[4];
DD_TO_D_CASE(0, INFINITY, 1.0, 1.0 * M_PI / 2.0);
DD_TO_D_CASE(1, INFINITY, -1.0, 1.0 * M_PI / 2.0);
DD_TO_D_CASE(2, -INFINITY, 1.0, -1.0 * M_PI / 2.0);
DD_TO_D_CASE(3, -INFINITY, -1.0, -1.0 * M_PI / 2.0);
return helper_ddtod("SDL_atan2(atan2_yInfCases)", SDL_atan2, cases, SDL_arraysize(cases));
}
/**
@@ -2652,29 +2643,12 @@ atan2_yInfCases(void *args)
static int
atan2_xInfCases(void *args)
{
double result;
result = SDL_atan2(1.0, INFINITY);
SDLTest_AssertCheck(0.0 == result,
"Atan2(%f,%f), expected %f, got %f",
1.0, INFINITY, 0.0, result);
result = SDL_atan2(-1.0, INFINITY);
SDLTest_AssertCheck(-0.0 == result,
"Atan2(%f,%f), expected %f, got %f",
-1.0, INFINITY, -0.0, result);
result = SDL_atan2(1.0, -INFINITY);
SDLTest_AssertCheck(SDL_fabs(M_PI - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
1.0, -INFINITY, M_PI, result);
result = SDL_atan2(-1.0, -INFINITY);
SDLTest_AssertCheck(SDL_fabs(-M_PI - result) <= EPSILON,
"Atan2(%f,%f), expected %f, got %f",
-1.0, -INFINITY, -M_PI, result);
return TEST_COMPLETED;
dd_to_d cases[4];
DD_TO_D_CASE(0, 1.0, INFINITY, 0.0);
DD_TO_D_CASE(1, -1.0, INFINITY, -0.0);
DD_TO_D_CASE(2, 1.0, -INFINITY, M_PI);
DD_TO_D_CASE(3, -1.0, -INFINITY, -M_PI);
return helper_ddtod("atan2_xInfCases(atan2_yInfCases)", SDL_atan2, cases, SDL_arraysize(cases));
}
/* Miscelanious cases */

View File

@@ -53,7 +53,7 @@ int stdlib_snprintf(void *arg)
int result;
int predicted;
char text[1024];
const char *expected;
const char *expected, *expected2, *expected3, *expected4, *expected5;
size_t size;
result = SDL_snprintf(text, sizeof(text), "%s", "foo");
@@ -177,22 +177,58 @@ int stdlib_snprintf(void *arg)
result = SDL_snprintf(text, sizeof(text), "%p", (void *)0x1234abcd);
expected = "0x1234abcd";
expected2 = "1234ABCD";
expected3 = "000000001234ABCD";
expected4 = "1234abcd";
expected5 = "000000001234abcd";
SDLTest_AssertPass("Call to SDL_snprintf(text, sizeof(text), \"%%p\", 0x1234abcd)");
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
SDLTest_AssertCheck(result == SDL_strlen(expected), "Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0 ||
SDL_strcmp(text, expected2) == 0 ||
SDL_strcmp(text, expected3) == 0 ||
SDL_strcmp(text, expected4) == 0 ||
SDL_strcmp(text, expected5) == 0,
"Check text, expected: '%s', got: '%s'", expected, text);
SDLTest_AssertCheck(result == SDL_strlen(expected) ||
result == SDL_strlen(expected2) ||
result == SDL_strlen(expected3) ||
result == SDL_strlen(expected4) ||
result == SDL_strlen(expected5),
"Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
result = SDL_snprintf(text, sizeof(text), "A %p B", (void *)0x1234abcd);
expected = "A 0x1234abcd B";
expected2 = "A 1234ABCD B";
expected3 = "A 000000001234ABCD B";
expected4 = "A 1234abcd B";
expected5 = "A 000000001234abcd B";
SDLTest_AssertPass("Call to SDL_snprintf(text, sizeof(text), \"A %%p B\", 0x1234abcd)");
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
SDLTest_AssertCheck(result == SDL_strlen(expected), "Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0 ||
SDL_strcmp(text, expected2) == 0 ||
SDL_strcmp(text, expected3) == 0 ||
SDL_strcmp(text, expected4) == 0 ||
SDL_strcmp(text, expected5) == 0,
"Check text, expected: '%s', got: '%s'", expected, text);
SDLTest_AssertCheck(result == SDL_strlen(expected) ||
result == SDL_strlen(expected2) ||
result == SDL_strlen(expected3) ||
result == SDL_strlen(expected4) ||
result == SDL_strlen(expected5),
"Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
if (sizeof(void *) >= 8) {
result = SDL_snprintf(text, sizeof(text), "%p", (void *)0x1ba07bddf60L);
expected = "0x1ba07bddf60";
expected2 = "000001BA07BDDF60";
expected3 = "000001ba07bddf60";
SDLTest_AssertPass("Call to SDL_snprintf(text, sizeof(text), \"%%p\", 0x1ba07bddf60)");
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
SDLTest_AssertCheck(result == SDL_strlen(expected), "Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0 ||
SDL_strcmp(text, expected2) == 0 ||
SDL_strcmp(text, expected3) == 0,
"Check text, expected: '%s', got: '%s'", expected, text);
SDLTest_AssertCheck(result == SDL_strlen(expected) ||
result == SDL_strlen(expected2) ||
result == SDL_strlen(expected3),
"Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
}
return TEST_COMPLETED;
}

View File

@@ -94,7 +94,10 @@ int timer_delayAndGetTicks(void *arg)
SDLTest_AssertCheck(result2 > 0, "Check result value, expected: >0, got: %" SDL_PRIu32, result2);
difference = result2 - result;
SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%" SDL_PRIu32 ", got: %" SDL_PRIu32, testDelay - marginOfError, difference);
#if 0
/* Disabled because this might fail on non-interactive systems. Moved to testtimer. */
SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%" SDL_PRIu32 ", got: %" SDL_PRIu32, testDelay + marginOfError, difference);
#endif
return TEST_COMPLETED;
}

View File

@@ -2017,6 +2017,11 @@ int video_setWindowCenteredOnDisplay(void *arg)
SDL_Rect display0, display1;
displayNum = SDL_GetNumVideoDisplays();
SDLTest_AssertPass("SDL_GetNumVideoDisplays()");
SDLTest_AssertCheck(displayNum >= 1, "Validate result (current: %d, expected >= 1)", displayNum);
if (displayNum <= 0) {
return TEST_ABORTED;
}
/* Get display bounds */
result = SDL_GetDisplayBounds(0 % displayNum, &display0);

View File

@@ -18,9 +18,38 @@
#include <stdio.h>
#include "SDL.h"
#include "SDL_test.h"
#define DEFAULT_RESOLUTION 1
static int test_sdl_delay_within_bounds(void) {
const int testDelay = 100;
const int marginOfError = 25;
Uint64 result;
Uint64 result2;
Sint64 difference;
SDLTest_ResetAssertSummary();
/* Get ticks count - should be non-zero by now */
result = SDL_GetTicks();
SDLTest_AssertPass("Call to SDL_GetTicks()");
SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %" SDL_PRIu64, result);
/* Delay a bit longer and measure ticks and verify difference */
SDL_Delay(testDelay);
SDLTest_AssertPass("Call to SDL_Delay(%d)", testDelay);
result2 = SDL_GetTicks();
SDLTest_AssertPass("Call to SDL_GetTicks()");
SDLTest_AssertCheck(result2 > 0, "Check result value, expected: >0, got: %" SDL_PRIu64, result2);
difference = result2 - result;
SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%d, got: %" SDL_PRIu64, testDelay - marginOfError, difference);
/* Disabled because this might fail on non-interactive systems. */
SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%d, got: %" SDL_PRIu64, testDelay + marginOfError, difference);
return SDLTest_AssertSummaryToTestResult() == TEST_RESULT_PASSED ? 0 : 1;
}
static int ticks = 0;
static Uint32 SDLCALL
@@ -39,15 +68,43 @@ callback(Uint32 interval, void *param)
int main(int argc, char *argv[])
{
int i, desired;
int i;
int desired = -1;
SDL_TimerID t1, t2, t3;
Uint64 start64, now64;
Uint32 start32, now32;
Uint64 start, now;
SDL_bool run_interactive_tests = SDL_FALSE;
int return_code = 0;
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Parse commandline */
for (i = 1; i < argc;) {
int consumed = 0;
if (!consumed) {
if (SDL_strcmp(argv[i], "--interactive") == 0) {
run_interactive_tests = SDL_TRUE;
consumed = 1;
} else if (desired < 0) {
char *endptr;
desired = SDL_strtoul(argv[i], &endptr, 0);
if (desired != 0 && endptr != argv[i] && *endptr == '\0') {
consumed = 1;
}
}
}
if (consumed <= 0) {
SDL_Log("Usage: %s [--interactive] [interval]", argv[0]);
return 1;
}
i += consumed;
}
if (SDL_Init(SDL_INIT_TIMER) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
@@ -74,14 +131,11 @@ int main(int argc, char *argv[])
}
}
/* Start the timer */
desired = 0;
if (argv[1]) {
desired = SDL_atoi(argv[1]);
}
if (desired == 0) {
if (desired < 0) {
desired = DEFAULT_RESOLUTION;
}
/* Start the timer */
t1 = SDL_AddTimer(desired, ticktock, NULL);
/* Wait 10 seconds */
@@ -102,14 +156,17 @@ int main(int argc, char *argv[])
t1 = SDL_AddTimer(100, callback, (void *)1);
if (!t1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 1: %s\n", SDL_GetError());
return_code = 1;
}
t2 = SDL_AddTimer(50, callback, (void *)2);
if (!t2) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 2: %s\n", SDL_GetError());
return_code = 1;
}
t3 = SDL_AddTimer(233, callback, (void *)3);
if (!t3) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 3: %s\n", SDL_GetError());
return_code = 1;
}
/* Wait 10 seconds */
@@ -141,8 +198,11 @@ int main(int argc, char *argv[])
now32 = SDL_GetTicks();
SDL_Log("Delay 1 second = %d ms in ticks, %d ms in ticks64, %f ms according to performance counter\n", (int)(now32 - start32), (int)(now64 - start64), (double)((now - start) * 1000) / SDL_GetPerformanceFrequency());
if (run_interactive_tests) {
return_code |= test_sdl_delay_within_bounds();
}
SDL_Quit();
return 0;
return return_code;
}
/* vi: set ts=4 sw=4 expandtab: */