mirror of https://github.com/libsdl-org/SDL.git
Compare commits
28 Commits
51dc29359a
...
d6d81eeac3
| Author | SHA1 | Date |
|---|---|---|
|
|
d6d81eeac3 | |
|
|
038a3806eb | |
|
|
e6c2649afc | |
|
|
e80d084766 | |
|
|
6aedc488d3 | |
|
|
81e3066303 | |
|
|
7d9fd48557 | |
|
|
e68f5ca99a | |
|
|
051ce0ff89 | |
|
|
5fcc83d93b | |
|
|
1bd5110ff0 | |
|
|
eb04219efe | |
|
|
d06b6e42d2 | |
|
|
c19ad189dc | |
|
|
7882e60f0e | |
|
|
e4e29b8601 | |
|
|
d7939abf42 | |
|
|
390fe65323 | |
|
|
ca9b7c8ea3 | |
|
|
c04624972e | |
|
|
b4ac5f43f5 | |
|
|
3896b1b3f4 | |
|
|
efed3c63b3 | |
|
|
d6bae53341 | |
|
|
f62c982bcf | |
|
|
b833c618a9 | |
|
|
9dc6c6e4d4 | |
|
|
4f79d4c94d |
|
|
@ -9,6 +9,7 @@ versionfname = include/SDL3/SDL_version.h
|
||||||
versionmajorregex = \A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z
|
versionmajorregex = \A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z
|
||||||
versionminorregex = \A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z
|
versionminorregex = \A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z
|
||||||
versionmicroregex = \A\#define\s+SDL_MICRO_VERSION\s+(\d+)\Z
|
versionmicroregex = \A\#define\s+SDL_MICRO_VERSION\s+(\d+)\Z
|
||||||
|
apipropertyregex = \A\s*\#\s*define\s+SDL_PROP_
|
||||||
selectheaderregex = \ASDL.*?\.h\Z
|
selectheaderregex = \ASDL.*?\.h\Z
|
||||||
projecturl = https://libsdl.org/
|
projecturl = https://libsdl.org/
|
||||||
wikiurl = https://wiki.libsdl.org
|
wikiurl = https://wiki.libsdl.org
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ my $wikisubdir = '';
|
||||||
my $incsubdir = 'include';
|
my $incsubdir = 'include';
|
||||||
my $readmesubdir = undef;
|
my $readmesubdir = undef;
|
||||||
my $apiprefixregex = undef;
|
my $apiprefixregex = undef;
|
||||||
|
my $apipropertyregex = undef;
|
||||||
my $versionfname = 'include/SDL_version.h';
|
my $versionfname = 'include/SDL_version.h';
|
||||||
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
|
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
|
||||||
my $versionminorregex = '\A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z';
|
my $versionminorregex = '\A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z';
|
||||||
|
|
@ -110,6 +111,7 @@ if (defined $optionsfname) {
|
||||||
$srcpath = $val, next if $key eq 'srcpath';
|
$srcpath = $val, next if $key eq 'srcpath';
|
||||||
$wikipath = $val, next if $key eq 'wikipath';
|
$wikipath = $val, next if $key eq 'wikipath';
|
||||||
$apiprefixregex = $val, next if $key eq 'apiprefixregex';
|
$apiprefixregex = $val, next if $key eq 'apiprefixregex';
|
||||||
|
$apipropertyregex = $val, next if $key eq 'apipropertyregex';
|
||||||
$projectfullname = $val, next if $key eq 'projectfullname';
|
$projectfullname = $val, next if $key eq 'projectfullname';
|
||||||
$projectshortname = $val, next if $key eq 'projectshortname';
|
$projectshortname = $val, next if $key eq 'projectshortname';
|
||||||
$wikisubdir = $val, next if $key eq 'wikisubdir';
|
$wikisubdir = $val, next if $key eq 'wikisubdir';
|
||||||
|
|
@ -1366,7 +1368,7 @@ while (my $d = readdir(DH)) {
|
||||||
# update strings now that we know everything pending is to be applied to this declaration. Add pending blank lines and the new text.
|
# update strings now that we know everything pending is to be applied to this declaration. Add pending blank lines and the new text.
|
||||||
|
|
||||||
# At Sam's request, don't list property defines with functions. (See #9440)
|
# At Sam's request, don't list property defines with functions. (See #9440)
|
||||||
my $is_property = /\A\s*\#\s*define\s+SDL_PROP_/;
|
my $is_property = (defined $apipropertyregex) ? /$apipropertyregex/ : 0;
|
||||||
if (!$is_property) {
|
if (!$is_property) {
|
||||||
if ($blank_lines > 0) {
|
if ($blank_lines > 0) {
|
||||||
while ($blank_lines > 0) {
|
while ($blank_lines > 0) {
|
||||||
|
|
|
||||||
|
|
@ -1021,7 +1021,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_UnbindAudioStream(SDL_AudioStream *stream);
|
||||||
/**
|
/**
|
||||||
* Query an audio stream for its currently-bound device.
|
* Query an audio stream for its currently-bound device.
|
||||||
*
|
*
|
||||||
* This reports the audio device that an audio stream is currently bound to.
|
* This reports the logical audio device that an audio stream is currently
|
||||||
|
* bound to.
|
||||||
*
|
*
|
||||||
* If not bound, or invalid, this returns zero, which is not a valid device
|
* If not bound, or invalid, this returns zero, which is not a valid device
|
||||||
* ID.
|
* ID.
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,8 @@ typedef enum SDL_EventType
|
||||||
/* 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat */
|
/* 0x201 was SDL_SYSWMEVENT, reserve the number for sdl2-compat */
|
||||||
SDL_EVENT_WINDOW_SHOWN = 0x202, /**< Window has been shown */
|
SDL_EVENT_WINDOW_SHOWN = 0x202, /**< Window has been shown */
|
||||||
SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */
|
SDL_EVENT_WINDOW_HIDDEN, /**< Window has been hidden */
|
||||||
SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event */
|
SDL_EVENT_WINDOW_EXPOSED, /**< Window has been exposed and should be redrawn, and can be redrawn directly from event watchers for this event.
|
||||||
|
data1 is 1 for live-resize expose events, 0 otherwise. */
|
||||||
SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */
|
SDL_EVENT_WINDOW_MOVED, /**< Window has been moved to data1, data2 */
|
||||||
SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */
|
SDL_EVENT_WINDOW_RESIZED, /**< Window has been resized to data1xdata2 */
|
||||||
SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */
|
SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED,/**< The pixel size of the window has changed to data1xdata2 */
|
||||||
|
|
|
||||||
|
|
@ -823,7 +823,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS8(SDL_IOStream *src, Sint8 *value);
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -846,7 +846,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16LE(SDL_IOStream *src, Uint16 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -869,7 +869,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16LE(SDL_IOStream *src, Sint16 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -892,7 +892,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU16BE(SDL_IOStream *src, Uint16 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -915,7 +915,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS16BE(SDL_IOStream *src, Sint16 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -938,7 +938,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32LE(SDL_IOStream *src, Uint32 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -961,7 +961,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32LE(SDL_IOStream *src, Sint32 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -984,7 +984,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU32BE(SDL_IOStream *src, Uint32 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -1007,7 +1007,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS32BE(SDL_IOStream *src, Sint32 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -1030,7 +1030,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64LE(SDL_IOStream *src, Uint64 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -1053,7 +1053,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadS64LE(SDL_IOStream *src, Sint64 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
@ -1076,7 +1076,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadU64BE(SDL_IOStream *src, Uint64 *value)
|
||||||
*
|
*
|
||||||
* \param src the stream from which to read data.
|
* \param src the stream from which to read data.
|
||||||
* \param value a pointer filled in with the data read.
|
* \param value a pointer filled in with the data read.
|
||||||
* \returns true on successful write or false on failure; call SDL_GetError()
|
* \returns true on successful read or false on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety This function is not thread safe.
|
* \threadsafety This function is not thread safe.
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ static void SDLCALL CleanupHintProperty(void *userdata, void *value)
|
||||||
SDL_free(hint);
|
SDL_free(hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* GetHintEnvironmentVariable(const char *name)
|
static const char *GetHintEnvironmentVariable(const char *name)
|
||||||
{
|
{
|
||||||
const char *result = SDL_getenv(name);
|
const char *result = SDL_getenv(name);
|
||||||
if (!result && name && *name) {
|
if (!result && name && *name) {
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ bool SDL_CompareAndSwapAtomicU32(SDL_AtomicU32 *a, Uint32 oldval, Uint32 newval)
|
||||||
#elif defined(HAVE_GCC_ATOMICS)
|
#elif defined(HAVE_GCC_ATOMICS)
|
||||||
return __sync_bool_compare_and_swap(&a->value, oldval, newval);
|
return __sync_bool_compare_and_swap(&a->value, oldval, newval);
|
||||||
#elif defined(SDL_PLATFORM_MACOS) // this is deprecated in 10.12 sdk; favor gcc atomics.
|
#elif defined(SDL_PLATFORM_MACOS) // this is deprecated in 10.12 sdk; favor gcc atomics.
|
||||||
return OSAtomicCompareAndSwap32Barrier((int32_t)oldval, (int32_t)newval, (int32_t*)&a->value);
|
return OSAtomicCompareAndSwap32Barrier((int32_t)oldval, (int32_t)newval, (int32_t *)&a->value);
|
||||||
#elif defined(SDL_PLATFORM_SOLARIS)
|
#elif defined(SDL_PLATFORM_SOLARIS)
|
||||||
SDL_COMPILE_TIME_ASSERT(atomic_cas, sizeof(uint_t) == sizeof(a->value));
|
SDL_COMPILE_TIME_ASSERT(atomic_cas, sizeof(uint_t) == sizeof(a->value));
|
||||||
return ((Uint32)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval);
|
return ((Uint32)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval);
|
||||||
|
|
|
||||||
|
|
@ -1415,6 +1415,7 @@ static int SDLCALL RecordingAudioThread(void *devicep) // thread entry point
|
||||||
typedef struct CountAudioDevicesData
|
typedef struct CountAudioDevicesData
|
||||||
{
|
{
|
||||||
int devs_seen;
|
int devs_seen;
|
||||||
|
int devs_skipped;
|
||||||
const int num_devices;
|
const int num_devices;
|
||||||
SDL_AudioDeviceID *result;
|
SDL_AudioDeviceID *result;
|
||||||
const bool recording;
|
const bool recording;
|
||||||
|
|
@ -1430,7 +1431,13 @@ static bool SDLCALL CountAudioDevices(void *userdata, const SDL_HashTable *table
|
||||||
const bool isphysical = !!(devid & (1<<1));
|
const bool isphysical = !!(devid & (1<<1));
|
||||||
if (isphysical && (devid_recording == data->recording)) {
|
if (isphysical && (devid_recording == data->recording)) {
|
||||||
SDL_assert(data->devs_seen < data->num_devices);
|
SDL_assert(data->devs_seen < data->num_devices);
|
||||||
data->result[data->devs_seen++] = devid;
|
SDL_AudioDevice *device = (SDL_AudioDevice *) value; // this is normally risky, but we hold the device_hash_lock here.
|
||||||
|
const bool zombie = SDL_GetAtomicInt(&device->zombie) != 0;
|
||||||
|
if (zombie) {
|
||||||
|
data->devs_skipped++;
|
||||||
|
} else {
|
||||||
|
data->result[data->devs_seen++] = devid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true; // keep iterating.
|
return true; // keep iterating.
|
||||||
}
|
}
|
||||||
|
|
@ -1446,10 +1453,11 @@ static SDL_AudioDeviceID *GetAudioDevices(int *count, bool recording)
|
||||||
num_devices = SDL_GetAtomicInt(recording ? ¤t_audio.recording_device_count : ¤t_audio.playback_device_count);
|
num_devices = SDL_GetAtomicInt(recording ? ¤t_audio.recording_device_count : ¤t_audio.playback_device_count);
|
||||||
result = (SDL_AudioDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_AudioDeviceID));
|
result = (SDL_AudioDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_AudioDeviceID));
|
||||||
if (result) {
|
if (result) {
|
||||||
CountAudioDevicesData data = { 0, num_devices, result, recording };
|
CountAudioDevicesData data = { 0, 0, num_devices, result, recording };
|
||||||
SDL_IterateHashTable(current_audio.device_hash, CountAudioDevices, &data);
|
SDL_IterateHashTable(current_audio.device_hash, CountAudioDevices, &data);
|
||||||
SDL_assert(data.devs_seen == num_devices);
|
SDL_assert((data.devs_seen + data.devs_skipped) == num_devices);
|
||||||
result[data.devs_seen] = 0; // null-terminated.
|
num_devices = data.devs_seen; // might be less if we skipped any.
|
||||||
|
result[num_devices] = 0; // null-terminated.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
SDL_UnlockRWLock(current_audio.device_hash_lock);
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ void ConvertAudio(int num_frames,
|
||||||
|
|
||||||
// swizzle input to "standard" format if necessary.
|
// swizzle input to "standard" format if necessary.
|
||||||
if (src_map) {
|
if (src_map) {
|
||||||
void* buf = scratch ? scratch : dst; // use scratch if available, since it has to be big enough to hold src, unless it's NULL, then dst has to be.
|
void *buf = scratch ? scratch : dst; // use scratch if available, since it has to be big enough to hold src, unless it's NULL, then dst has to be.
|
||||||
SwizzleAudio(num_frames, buf, src, src_channels, src_map, src_format);
|
SwizzleAudio(num_frames, buf, src, src_channels, src_map, src_format);
|
||||||
src = buf;
|
src = buf;
|
||||||
}
|
}
|
||||||
|
|
@ -318,7 +318,7 @@ void ConvertAudio(int num_frames,
|
||||||
|
|
||||||
// get us to float format.
|
// get us to float format.
|
||||||
if (srcconvert) {
|
if (srcconvert) {
|
||||||
void* buf = (channelconvert || dstconvert) ? scratch : dst;
|
void *buf = (channelconvert || dstconvert) ? scratch : dst;
|
||||||
ConvertAudioToFloat((float *) buf, src, num_frames * src_channels, src_format);
|
ConvertAudioToFloat((float *) buf, src, num_frames * src_channels, src_format);
|
||||||
src = buf;
|
src = buf;
|
||||||
}
|
}
|
||||||
|
|
@ -368,7 +368,7 @@ void ConvertAudio(int num_frames,
|
||||||
channel_converter = override;
|
channel_converter = override;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* buf = dstconvert ? scratch : dst;
|
void *buf = dstconvert ? scratch : dst;
|
||||||
channel_converter((float *) buf, (const float *) src, num_frames);
|
channel_converter((float *) buf, (const float *) src, num_frames);
|
||||||
src = buf;
|
src = buf;
|
||||||
}
|
}
|
||||||
|
|
@ -399,7 +399,7 @@ static int CalculateMaxFrameSize(SDL_AudioFormat src_format, int src_channels, S
|
||||||
return max_format_size * max_channels;
|
return max_format_size * max_channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Sint64 GetAudioStreamResampleRate(SDL_AudioStream* stream, int src_freq, Sint64 resample_offset)
|
static Sint64 GetAudioStreamResampleRate(SDL_AudioStream *stream, int src_freq, Sint64 resample_offset)
|
||||||
{
|
{
|
||||||
src_freq = (int)((float)src_freq * stream->freq_ratio);
|
src_freq = (int)((float)src_freq * stream->freq_ratio);
|
||||||
|
|
||||||
|
|
@ -778,9 +778,9 @@ static bool CheckAudioStreamIsFullySetup(SDL_AudioStream *stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
// you MUST hold `stream->lock` when calling this, and validate your parameters!
|
// you MUST hold `stream->lock` when calling this, and validate your parameters!
|
||||||
static bool PutAudioStreamBufferInternal(SDL_AudioStream *stream, const SDL_AudioSpec *spec, const int *chmap, const void *buf, int len, SDL_ReleaseAudioBufferCallback callback, void* userdata)
|
static bool PutAudioStreamBufferInternal(SDL_AudioStream *stream, const SDL_AudioSpec *spec, const int *chmap, const void *buf, int len, SDL_ReleaseAudioBufferCallback callback, void *userdata)
|
||||||
{
|
{
|
||||||
SDL_AudioTrack* track = NULL;
|
SDL_AudioTrack *track = NULL;
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
track = SDL_CreateAudioTrack(stream->queue, spec, chmap, (Uint8 *)buf, len, len, callback, userdata);
|
track = SDL_CreateAudioTrack(stream->queue, spec, chmap, (Uint8 *)buf, len, len, callback, userdata);
|
||||||
|
|
@ -809,7 +809,7 @@ static bool PutAudioStreamBufferInternal(SDL_AudioStream *stream, const SDL_Audi
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool PutAudioStreamBuffer(SDL_AudioStream *stream, const void *buf, int len, SDL_ReleaseAudioBufferCallback callback, void* userdata)
|
static bool PutAudioStreamBuffer(SDL_AudioStream *stream, const void *buf, int len, SDL_ReleaseAudioBufferCallback callback, void *userdata)
|
||||||
{
|
{
|
||||||
#if DEBUG_AUDIOSTREAM
|
#if DEBUG_AUDIOSTREAM
|
||||||
SDL_Log("AUDIOSTREAM: wants to put %d bytes", len);
|
SDL_Log("AUDIOSTREAM: wants to put %d bytes", len);
|
||||||
|
|
@ -836,7 +836,7 @@ static bool PutAudioStreamBuffer(SDL_AudioStream *stream, const void *buf, int l
|
||||||
|
|
||||||
static void SDLCALL FreeAllocatedAudioBuffer(void *userdata, const void *buf, int len)
|
static void SDLCALL FreeAllocatedAudioBuffer(void *userdata, const void *buf, int len)
|
||||||
{
|
{
|
||||||
SDL_free((void*) buf);
|
SDL_free((void *)buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
|
bool SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len)
|
||||||
|
|
@ -1081,8 +1081,8 @@ static Uint8 *EnsureAudioStreamWorkBufferSize(SDL_AudioStream *stream, size_t ne
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Sint64 NextAudioStreamIter(SDL_AudioStream* stream, void** inout_iter,
|
static Sint64 NextAudioStreamIter(SDL_AudioStream *stream, void **inout_iter,
|
||||||
Sint64* inout_resample_offset, SDL_AudioSpec* out_spec, int **out_chmap, bool* out_flushed)
|
Sint64 *inout_resample_offset, SDL_AudioSpec *out_spec, int **out_chmap, bool *out_flushed)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
bool flushed;
|
bool flushed;
|
||||||
|
|
@ -1136,9 +1136,9 @@ static Sint64 NextAudioStreamIter(SDL_AudioStream* stream, void** inout_iter,
|
||||||
return output_frames;
|
return output_frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Sint64 GetAudioStreamAvailableFrames(SDL_AudioStream* stream, Sint64* out_resample_offset)
|
static Sint64 GetAudioStreamAvailableFrames(SDL_AudioStream *stream, Sint64 *out_resample_offset)
|
||||||
{
|
{
|
||||||
void* iter = SDL_BeginAudioQueueIter(stream->queue);
|
void *iter = SDL_BeginAudioQueueIter(stream->queue);
|
||||||
|
|
||||||
Sint64 resample_offset = stream->resample_offset;
|
Sint64 resample_offset = stream->resample_offset;
|
||||||
Sint64 output_frames = 0;
|
Sint64 output_frames = 0;
|
||||||
|
|
@ -1160,9 +1160,9 @@ static Sint64 GetAudioStreamAvailableFrames(SDL_AudioStream* stream, Sint64* out
|
||||||
return output_frames;
|
return output_frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Sint64 GetAudioStreamHead(SDL_AudioStream* stream, SDL_AudioSpec* out_spec, int **out_chmap, bool* out_flushed)
|
static Sint64 GetAudioStreamHead(SDL_AudioStream *stream, SDL_AudioSpec *out_spec, int **out_chmap, bool *out_flushed)
|
||||||
{
|
{
|
||||||
void* iter = SDL_BeginAudioQueueIter(stream->queue);
|
void *iter = SDL_BeginAudioQueueIter(stream->queue);
|
||||||
|
|
||||||
if (!iter) {
|
if (!iter) {
|
||||||
SDL_zerop(out_spec);
|
SDL_zerop(out_spec);
|
||||||
|
|
@ -1178,8 +1178,8 @@ static Sint64 GetAudioStreamHead(SDL_AudioStream* stream, SDL_AudioSpec* out_spe
|
||||||
// Enough input data MUST be available!
|
// Enough input data MUST be available!
|
||||||
static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int output_frames, float gain)
|
static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int output_frames, float gain)
|
||||||
{
|
{
|
||||||
const SDL_AudioSpec* src_spec = &stream->input_spec;
|
const SDL_AudioSpec *src_spec = &stream->input_spec;
|
||||||
const SDL_AudioSpec* dst_spec = &stream->dst_spec;
|
const SDL_AudioSpec *dst_spec = &stream->dst_spec;
|
||||||
|
|
||||||
const SDL_AudioFormat src_format = src_spec->format;
|
const SDL_AudioFormat src_format = src_spec->format;
|
||||||
const int src_channels = src_spec->channels;
|
const int src_channels = src_spec->channels;
|
||||||
|
|
@ -1199,7 +1199,7 @@ static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int o
|
||||||
|
|
||||||
// Not resampling? It's an easy conversion (and maybe not even that!)
|
// Not resampling? It's an easy conversion (and maybe not even that!)
|
||||||
if (resample_rate == 0) {
|
if (resample_rate == 0) {
|
||||||
Uint8* work_buffer = NULL;
|
Uint8 *work_buffer = NULL;
|
||||||
|
|
||||||
// Ensure we have enough scratch space for any conversions
|
// Ensure we have enough scratch space for any conversions
|
||||||
if ((src_format != dst_format) || (src_channels != dst_channels) || (gain != 1.0f)) {
|
if ((src_format != dst_format) || (src_channels != dst_channels) || (gain != 1.0f)) {
|
||||||
|
|
@ -1269,7 +1269,7 @@ static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int o
|
||||||
work_buffer_capacity += resample_bytes;
|
work_buffer_capacity += resample_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8* work_buffer = EnsureAudioStreamWorkBufferSize(stream, work_buffer_capacity);
|
Uint8 *work_buffer = EnsureAudioStreamWorkBufferSize(stream, work_buffer_capacity);
|
||||||
|
|
||||||
if (!work_buffer) {
|
if (!work_buffer) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1281,7 +1281,7 @@ static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int o
|
||||||
const float postresample_gain = (input_frames > output_frames) ? gain : 1.0f;
|
const float postresample_gain = (input_frames > output_frames) ? gain : 1.0f;
|
||||||
|
|
||||||
// (dst channel map is NULL because we'll do the final swizzle on ConvertAudio after resample.)
|
// (dst channel map is NULL because we'll do the final swizzle on ConvertAudio after resample.)
|
||||||
const Uint8* input_buffer = SDL_ReadFromAudioQueue(stream->queue,
|
const Uint8 *input_buffer = SDL_ReadFromAudioQueue(stream->queue,
|
||||||
NULL, resample_format, resample_channels, NULL,
|
NULL, resample_format, resample_channels, NULL,
|
||||||
padding_frames, input_frames, padding_frames, work_buffer, preresample_gain);
|
padding_frames, input_frames, padding_frames, work_buffer, preresample_gain);
|
||||||
|
|
||||||
|
|
@ -1292,11 +1292,11 @@ static bool GetAudioStreamDataInternal(SDL_AudioStream *stream, void *buf, int o
|
||||||
input_buffer += padding_frames * resample_frame_size;
|
input_buffer += padding_frames * resample_frame_size;
|
||||||
|
|
||||||
// Decide where the resampled output goes
|
// Decide where the resampled output goes
|
||||||
void* resample_buffer = (resample_buffer_offset != -1) ? (work_buffer + resample_buffer_offset) : buf;
|
void *resample_buffer = (resample_buffer_offset != -1) ? (work_buffer + resample_buffer_offset) : buf;
|
||||||
|
|
||||||
SDL_ResampleAudio(resample_channels,
|
SDL_ResampleAudio(resample_channels,
|
||||||
(const float *) input_buffer, input_frames,
|
(const float *)input_buffer, input_frames,
|
||||||
(float*) resample_buffer, output_frames,
|
(float *)resample_buffer, output_frames,
|
||||||
resample_rate, &stream->resample_offset);
|
resample_rate, &stream->resample_offset);
|
||||||
|
|
||||||
// Convert to the final format, if necessary (src channel map is NULL because SDL_ReadFromAudioQueue already handled this).
|
// Convert to the final format, if necessary (src channel map is NULL because SDL_ReadFromAudioQueue already handled this).
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ static void SDL_Convert_F32_to_S32_Scalar(Sint32 *dst, const float *src, int num
|
||||||
|
|
||||||
#undef SIGNMASK
|
#undef SIGNMASK
|
||||||
|
|
||||||
static void SDL_Convert_Swap16_Scalar(Uint16* dst, const Uint16* src, int num_samples)
|
static void SDL_Convert_Swap16_Scalar(Uint16 *dst, const Uint16 *src, int num_samples)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
@ -194,7 +194,7 @@ static void SDL_Convert_Swap16_Scalar(Uint16* dst, const Uint16* src, int num_sa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_Convert_Swap32_Scalar(Uint32* dst, const Uint32* src, int num_samples)
|
static void SDL_Convert_Swap32_Scalar(Uint32 *dst, const Uint32 *src, int num_samples)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
@ -375,7 +375,7 @@ static void SDL_TARGETING("sse2") SDL_Convert_F32_to_S8_SSE2(Sint8 *dst, const f
|
||||||
|
|
||||||
const __m128i bytes = _mm_packus_epi16(shorts0, shorts1);
|
const __m128i bytes = _mm_packus_epi16(shorts0, shorts1);
|
||||||
|
|
||||||
_mm_store_si128((__m128i*)&dst[i], bytes);
|
_mm_store_si128((__m128i *)&dst[i], bytes);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -409,7 +409,7 @@ static void SDL_TARGETING("sse2") SDL_Convert_F32_to_U8_SSE2(Uint8 *dst, const f
|
||||||
|
|
||||||
const __m128i bytes = _mm_packus_epi16(shorts0, shorts1);
|
const __m128i bytes = _mm_packus_epi16(shorts0, shorts1);
|
||||||
|
|
||||||
_mm_store_si128((__m128i*)&dst[i], bytes);
|
_mm_store_si128((__m128i *)&dst[i], bytes);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -441,8 +441,8 @@ static void SDL_TARGETING("sse2") SDL_Convert_F32_to_S16_SSE2(Sint16 *dst, const
|
||||||
const __m128i shorts0 = _mm_packs_epi32(ints0, ints1);
|
const __m128i shorts0 = _mm_packs_epi32(ints0, ints1);
|
||||||
const __m128i shorts1 = _mm_packs_epi32(ints2, ints3);
|
const __m128i shorts1 = _mm_packs_epi32(ints2, ints3);
|
||||||
|
|
||||||
_mm_store_si128((__m128i*)&dst[i], shorts0);
|
_mm_store_si128((__m128i *)&dst[i], shorts0);
|
||||||
_mm_store_si128((__m128i*)&dst[i + 8], shorts1);
|
_mm_store_si128((__m128i *)&dst[i + 8], shorts1);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -477,55 +477,55 @@ static void SDL_TARGETING("sse2") SDL_Convert_F32_to_S32_SSE2(Sint32 *dst, const
|
||||||
const __m128i ints2 = _mm_xor_si128(_mm_cvttps_epi32(values3), _mm_castps_si128(_mm_cmpge_ps(values3, limit)));
|
const __m128i ints2 = _mm_xor_si128(_mm_cvttps_epi32(values3), _mm_castps_si128(_mm_cmpge_ps(values3, limit)));
|
||||||
const __m128i ints3 = _mm_xor_si128(_mm_cvttps_epi32(values4), _mm_castps_si128(_mm_cmpge_ps(values4, limit)));
|
const __m128i ints3 = _mm_xor_si128(_mm_cvttps_epi32(values4), _mm_castps_si128(_mm_cmpge_ps(values4, limit)));
|
||||||
|
|
||||||
_mm_store_si128((__m128i*)&dst[i], ints0);
|
_mm_store_si128((__m128i *)&dst[i], ints0);
|
||||||
_mm_store_si128((__m128i*)&dst[i + 4], ints1);
|
_mm_store_si128((__m128i *)&dst[i + 4], ints1);
|
||||||
_mm_store_si128((__m128i*)&dst[i + 8], ints2);
|
_mm_store_si128((__m128i *)&dst[i + 8], ints2);
|
||||||
_mm_store_si128((__m128i*)&dst[i + 12], ints3);
|
_mm_store_si128((__m128i *)&dst[i + 12], ints3);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME: SDL doesn't have SSSE3 detection, so use the next one up
|
// FIXME: SDL doesn't have SSSE3 detection, so use the next one up
|
||||||
#ifdef SDL_SSE4_1_INTRINSICS
|
#ifdef SDL_SSE4_1_INTRINSICS
|
||||||
static void SDL_TARGETING("ssse3") SDL_Convert_Swap16_SSSE3(Uint16* dst, const Uint16* src, int num_samples)
|
static void SDL_TARGETING("ssse3") SDL_Convert_Swap16_SSSE3(Uint16 *dst, const Uint16 *src, int num_samples)
|
||||||
{
|
{
|
||||||
const __m128i shuffle = _mm_set_epi8(14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1);
|
const __m128i shuffle = _mm_set_epi8(14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1);
|
||||||
|
|
||||||
CONVERT_16_FWD({
|
CONVERT_16_FWD({
|
||||||
dst[i] = SDL_Swap16(src[i]);
|
dst[i] = SDL_Swap16(src[i]);
|
||||||
}, {
|
}, {
|
||||||
__m128i ints0 = _mm_loadu_si128((const __m128i*)&src[i]);
|
__m128i ints0 = _mm_loadu_si128((const __m128i *)&src[i]);
|
||||||
__m128i ints1 = _mm_loadu_si128((const __m128i*)&src[i + 8]);
|
__m128i ints1 = _mm_loadu_si128((const __m128i *)&src[i + 8]);
|
||||||
|
|
||||||
ints0 = _mm_shuffle_epi8(ints0, shuffle);
|
ints0 = _mm_shuffle_epi8(ints0, shuffle);
|
||||||
ints1 = _mm_shuffle_epi8(ints1, shuffle);
|
ints1 = _mm_shuffle_epi8(ints1, shuffle);
|
||||||
|
|
||||||
_mm_store_si128((__m128i*)&dst[i], ints0);
|
_mm_store_si128((__m128i *)&dst[i], ints0);
|
||||||
_mm_store_si128((__m128i*)&dst[i + 8], ints1);
|
_mm_store_si128((__m128i *)&dst[i + 8], ints1);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_TARGETING("ssse3") SDL_Convert_Swap32_SSSE3(Uint32* dst, const Uint32* src, int num_samples)
|
static void SDL_TARGETING("ssse3") SDL_Convert_Swap32_SSSE3(Uint32 *dst, const Uint32 *src, int num_samples)
|
||||||
{
|
{
|
||||||
const __m128i shuffle = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3);
|
const __m128i shuffle = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3);
|
||||||
|
|
||||||
CONVERT_16_FWD({
|
CONVERT_16_FWD({
|
||||||
dst[i] = SDL_Swap32(src[i]);
|
dst[i] = SDL_Swap32(src[i]);
|
||||||
}, {
|
}, {
|
||||||
__m128i ints0 = _mm_loadu_si128((const __m128i*)&src[i]);
|
__m128i ints0 = _mm_loadu_si128((const __m128i *)&src[i]);
|
||||||
__m128i ints1 = _mm_loadu_si128((const __m128i*)&src[i + 4]);
|
__m128i ints1 = _mm_loadu_si128((const __m128i *)&src[i + 4]);
|
||||||
__m128i ints2 = _mm_loadu_si128((const __m128i*)&src[i + 8]);
|
__m128i ints2 = _mm_loadu_si128((const __m128i *)&src[i + 8]);
|
||||||
__m128i ints3 = _mm_loadu_si128((const __m128i*)&src[i + 12]);
|
__m128i ints3 = _mm_loadu_si128((const __m128i *)&src[i + 12]);
|
||||||
|
|
||||||
ints0 = _mm_shuffle_epi8(ints0, shuffle);
|
ints0 = _mm_shuffle_epi8(ints0, shuffle);
|
||||||
ints1 = _mm_shuffle_epi8(ints1, shuffle);
|
ints1 = _mm_shuffle_epi8(ints1, shuffle);
|
||||||
ints2 = _mm_shuffle_epi8(ints2, shuffle);
|
ints2 = _mm_shuffle_epi8(ints2, shuffle);
|
||||||
ints3 = _mm_shuffle_epi8(ints3, shuffle);
|
ints3 = _mm_shuffle_epi8(ints3, shuffle);
|
||||||
|
|
||||||
_mm_store_si128((__m128i*)&dst[i], ints0);
|
_mm_store_si128((__m128i *)&dst[i], ints0);
|
||||||
_mm_store_si128((__m128i*)&dst[i + 4], ints1);
|
_mm_store_si128((__m128i *)&dst[i + 4], ints1);
|
||||||
_mm_store_si128((__m128i*)&dst[i + 8], ints2);
|
_mm_store_si128((__m128i *)&dst[i + 8], ints2);
|
||||||
_mm_store_si128((__m128i*)&dst[i + 12], ints3);
|
_mm_store_si128((__m128i *)&dst[i + 12], ints3);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -774,41 +774,41 @@ static void SDL_Convert_F32_to_S32_NEON(Sint32 *dst, const float *src, int num_s
|
||||||
fesetenv(&fenv);
|
fesetenv(&fenv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_Convert_Swap16_NEON(Uint16* dst, const Uint16* src, int num_samples)
|
static void SDL_Convert_Swap16_NEON(Uint16 *dst, const Uint16 *src, int num_samples)
|
||||||
{
|
{
|
||||||
CONVERT_16_FWD({
|
CONVERT_16_FWD({
|
||||||
dst[i] = SDL_Swap16(src[i]);
|
dst[i] = SDL_Swap16(src[i]);
|
||||||
}, {
|
}, {
|
||||||
uint8x16_t ints0 = vld1q_u8((const Uint8*)&src[i]);
|
uint8x16_t ints0 = vld1q_u8((const Uint8 *)&src[i]);
|
||||||
uint8x16_t ints1 = vld1q_u8((const Uint8*)&src[i + 8]);
|
uint8x16_t ints1 = vld1q_u8((const Uint8 *)&src[i + 8]);
|
||||||
|
|
||||||
ints0 = vrev16q_u8(ints0);
|
ints0 = vrev16q_u8(ints0);
|
||||||
ints1 = vrev16q_u8(ints1);
|
ints1 = vrev16q_u8(ints1);
|
||||||
|
|
||||||
vst1q_u8((Uint8*)&dst[i], ints0);
|
vst1q_u8((Uint8 *)&dst[i], ints0);
|
||||||
vst1q_u8((Uint8*)&dst[i + 8], ints1);
|
vst1q_u8((Uint8 *)&dst[i + 8], ints1);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_Convert_Swap32_NEON(Uint32* dst, const Uint32* src, int num_samples)
|
static void SDL_Convert_Swap32_NEON(Uint32 *dst, const Uint32 *src, int num_samples)
|
||||||
{
|
{
|
||||||
CONVERT_16_FWD({
|
CONVERT_16_FWD({
|
||||||
dst[i] = SDL_Swap32(src[i]);
|
dst[i] = SDL_Swap32(src[i]);
|
||||||
}, {
|
}, {
|
||||||
uint8x16_t ints0 = vld1q_u8((const Uint8*)&src[i]);
|
uint8x16_t ints0 = vld1q_u8((const Uint8 *)&src[i]);
|
||||||
uint8x16_t ints1 = vld1q_u8((const Uint8*)&src[i + 4]);
|
uint8x16_t ints1 = vld1q_u8((const Uint8 *)&src[i + 4]);
|
||||||
uint8x16_t ints2 = vld1q_u8((const Uint8*)&src[i + 8]);
|
uint8x16_t ints2 = vld1q_u8((const Uint8 *)&src[i + 8]);
|
||||||
uint8x16_t ints3 = vld1q_u8((const Uint8*)&src[i + 12]);
|
uint8x16_t ints3 = vld1q_u8((const Uint8 *)&src[i + 12]);
|
||||||
|
|
||||||
ints0 = vrev32q_u8(ints0);
|
ints0 = vrev32q_u8(ints0);
|
||||||
ints1 = vrev32q_u8(ints1);
|
ints1 = vrev32q_u8(ints1);
|
||||||
ints2 = vrev32q_u8(ints2);
|
ints2 = vrev32q_u8(ints2);
|
||||||
ints3 = vrev32q_u8(ints3);
|
ints3 = vrev32q_u8(ints3);
|
||||||
|
|
||||||
vst1q_u8((Uint8*)&dst[i], ints0);
|
vst1q_u8((Uint8 *)&dst[i], ints0);
|
||||||
vst1q_u8((Uint8*)&dst[i + 4], ints1);
|
vst1q_u8((Uint8 *)&dst[i + 4], ints1);
|
||||||
vst1q_u8((Uint8*)&dst[i + 8], ints2);
|
vst1q_u8((Uint8 *)&dst[i + 8], ints2);
|
||||||
vst1q_u8((Uint8*)&dst[i + 12], ints3);
|
vst1q_u8((Uint8 *)&dst[i + 12], ints3);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -839,8 +839,8 @@ static void (*SDL_Convert_F32_to_U8)(Uint8 *dst, const float *src, int num_sampl
|
||||||
static void (*SDL_Convert_F32_to_S16)(Sint16 *dst, const float *src, int num_samples) = NULL;
|
static void (*SDL_Convert_F32_to_S16)(Sint16 *dst, const float *src, int num_samples) = NULL;
|
||||||
static void (*SDL_Convert_F32_to_S32)(Sint32 *dst, const float *src, int num_samples) = NULL;
|
static void (*SDL_Convert_F32_to_S32)(Sint32 *dst, const float *src, int num_samples) = NULL;
|
||||||
|
|
||||||
static void (*SDL_Convert_Swap16)(Uint16* dst, const Uint16* src, int num_samples) = NULL;
|
static void (*SDL_Convert_Swap16)(Uint16 *dst, const Uint16 *src, int num_samples) = NULL;
|
||||||
static void (*SDL_Convert_Swap32)(Uint32* dst, const Uint32* src, int num_samples) = NULL;
|
static void (*SDL_Convert_Swap32)(Uint32 *dst, const Uint32 *src, int num_samples) = NULL;
|
||||||
|
|
||||||
void ConvertAudioToFloat(float *dst, const void *src, int num_samples, SDL_AudioFormat src_fmt)
|
void ConvertAudioToFloat(float *dst, const void *src, int num_samples, SDL_AudioFormat src_fmt)
|
||||||
{
|
{
|
||||||
|
|
@ -858,7 +858,7 @@ void ConvertAudioToFloat(float *dst, const void *src, int num_samples, SDL_Audio
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_AUDIO_S16 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
case SDL_AUDIO_S16 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
||||||
SDL_Convert_Swap16((Uint16*) dst, (const Uint16*) src, num_samples);
|
SDL_Convert_Swap16((Uint16 *)dst, (const Uint16 *)src, num_samples);
|
||||||
SDL_Convert_S16_to_F32(dst, (const Sint16 *) dst, num_samples);
|
SDL_Convert_S16_to_F32(dst, (const Sint16 *) dst, num_samples);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -867,12 +867,12 @@ void ConvertAudioToFloat(float *dst, const void *src, int num_samples, SDL_Audio
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_AUDIO_S32 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
case SDL_AUDIO_S32 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
||||||
SDL_Convert_Swap32((Uint32*) dst, (const Uint32*) src, num_samples);
|
SDL_Convert_Swap32((Uint32 *)dst, (const Uint32 *)src, num_samples);
|
||||||
SDL_Convert_S32_to_F32(dst, (const Sint32 *) dst, num_samples);
|
SDL_Convert_S32_to_F32(dst, (const Sint32 *) dst, num_samples);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_AUDIO_F32 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
case SDL_AUDIO_F32 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
||||||
SDL_Convert_Swap32((Uint32*) dst, (const Uint32*) src, num_samples);
|
SDL_Convert_Swap32((Uint32 *)dst, (const Uint32 *)src, num_samples);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: SDL_assert(!"Unexpected audio format!"); break;
|
default: SDL_assert(!"Unexpected audio format!"); break;
|
||||||
|
|
@ -896,7 +896,7 @@ void ConvertAudioFromFloat(void *dst, const float *src, int num_samples, SDL_Aud
|
||||||
|
|
||||||
case SDL_AUDIO_S16 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
case SDL_AUDIO_S16 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
||||||
SDL_Convert_F32_to_S16((Sint16 *) dst, src, num_samples);
|
SDL_Convert_F32_to_S16((Sint16 *) dst, src, num_samples);
|
||||||
SDL_Convert_Swap16((Uint16*) dst, (const Uint16*) dst, num_samples);
|
SDL_Convert_Swap16((Uint16 *)dst, (const Uint16 *)dst, num_samples);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_AUDIO_S32:
|
case SDL_AUDIO_S32:
|
||||||
|
|
@ -905,22 +905,22 @@ void ConvertAudioFromFloat(void *dst, const float *src, int num_samples, SDL_Aud
|
||||||
|
|
||||||
case SDL_AUDIO_S32 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
case SDL_AUDIO_S32 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
||||||
SDL_Convert_F32_to_S32((Sint32 *) dst, src, num_samples);
|
SDL_Convert_F32_to_S32((Sint32 *) dst, src, num_samples);
|
||||||
SDL_Convert_Swap32((Uint32*) dst, (const Uint32*) dst, num_samples);
|
SDL_Convert_Swap32((Uint32 *)dst, (const Uint32 *)dst, num_samples);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_AUDIO_F32 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
case SDL_AUDIO_F32 ^ SDL_AUDIO_MASK_BIG_ENDIAN:
|
||||||
SDL_Convert_Swap32((Uint32*) dst, (const Uint32*) src, num_samples);
|
SDL_Convert_Swap32((Uint32 *)dst, (const Uint32 *)src, num_samples);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: SDL_assert(!"Unexpected audio format!"); break;
|
default: SDL_assert(!"Unexpected audio format!"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertAudioSwapEndian(void* dst, const void* src, int num_samples, int bitsize)
|
void ConvertAudioSwapEndian(void *dst, const void *src, int num_samples, int bitsize)
|
||||||
{
|
{
|
||||||
switch (bitsize) {
|
switch (bitsize) {
|
||||||
case 16: SDL_Convert_Swap16((Uint16*) dst, (const Uint16*) src, num_samples); break;
|
case 16: SDL_Convert_Swap16((Uint16 *)dst, (const Uint16 *)src, num_samples); break;
|
||||||
case 32: SDL_Convert_Swap32((Uint32*) dst, (const Uint32*) src, num_samples); break;
|
case 32: SDL_Convert_Swap32((Uint32 *)dst, (const Uint32 *)src, num_samples); break;
|
||||||
default: SDL_assert(!"Unexpected audio format!"); break;
|
default: SDL_assert(!"Unexpected audio format!"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ extern void SDL_AudioThreadFinalize(SDL_AudioDevice *device);
|
||||||
|
|
||||||
extern void ConvertAudioToFloat(float *dst, const void *src, int num_samples, SDL_AudioFormat src_fmt);
|
extern void ConvertAudioToFloat(float *dst, const void *src, int num_samples, SDL_AudioFormat src_fmt);
|
||||||
extern void ConvertAudioFromFloat(void *dst, const float *src, int num_samples, SDL_AudioFormat dst_fmt);
|
extern void ConvertAudioFromFloat(void *dst, const float *src, int num_samples, SDL_AudioFormat dst_fmt);
|
||||||
extern void ConvertAudioSwapEndian(void* dst, const void* src, int num_samples, int bitsize);
|
extern void ConvertAudioSwapEndian(void *dst, const void *src, int num_samples, int bitsize);
|
||||||
|
|
||||||
extern bool SDL_ChannelMapIsDefault(const int *map, int channels);
|
extern bool SDL_ChannelMapIsDefault(const int *map, int channels);
|
||||||
extern bool SDL_ChannelMapIsBogus(const int *map, int channels);
|
extern bool SDL_ChannelMapIsBogus(const int *map, int channels);
|
||||||
|
|
@ -121,7 +121,7 @@ extern bool SDL_ChannelMapIsBogus(const int *map, int channels);
|
||||||
extern void ConvertAudio(int num_frames,
|
extern void ConvertAudio(int num_frames,
|
||||||
const void *src, SDL_AudioFormat src_format, int src_channels, const int *src_map,
|
const void *src, SDL_AudioFormat src_format, int src_channels, const int *src_map,
|
||||||
void *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map,
|
void *dst, SDL_AudioFormat dst_format, int dst_channels, const int *dst_map,
|
||||||
void* scratch, float gain);
|
void *scratch, float gain);
|
||||||
|
|
||||||
// Compare two SDL_AudioSpecs, return true if they match exactly.
|
// Compare two SDL_AudioSpecs, return true if they match exactly.
|
||||||
// Using SDL_memcmp directly isn't safe, since potential padding might not be initialized.
|
// Using SDL_memcmp directly isn't safe, since potential padding might not be initialized.
|
||||||
|
|
@ -201,7 +201,7 @@ struct SDL_AudioQueue; // forward decl.
|
||||||
|
|
||||||
struct SDL_AudioStream
|
struct SDL_AudioStream
|
||||||
{
|
{
|
||||||
SDL_Mutex* lock;
|
SDL_Mutex *lock;
|
||||||
|
|
||||||
SDL_PropertiesID props;
|
SDL_PropertiesID props;
|
||||||
|
|
||||||
|
|
@ -217,7 +217,7 @@ struct SDL_AudioStream
|
||||||
float freq_ratio;
|
float freq_ratio;
|
||||||
float gain;
|
float gain;
|
||||||
|
|
||||||
struct SDL_AudioQueue* queue;
|
struct SDL_AudioQueue *queue;
|
||||||
|
|
||||||
SDL_AudioSpec input_spec; // The spec of input data currently being processed
|
SDL_AudioSpec input_spec; // The spec of input data currently being processed
|
||||||
int *input_chmap;
|
int *input_chmap;
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
#include "../SDL_sysaudio.h"
|
#include "../SDL_sysaudio.h"
|
||||||
#include "SDL_alsa_audio.h"
|
#include "SDL_alsa_audio.h"
|
||||||
|
#include "../../core/linux/SDL_udev.h"
|
||||||
|
|
||||||
#if SDL_ALSA_DEBUG
|
#if SDL_ALSA_DEBUG
|
||||||
#define LOGDEBUG(...) SDL_LogDebug(SDL_LOG_CATEGORY_AUDIO, "ALSA: " __VA_ARGS__)
|
#define LOGDEBUG(...) SDL_LogDebug(SDL_LOG_CATEGORY_AUDIO, "ALSA: " __VA_ARGS__)
|
||||||
|
|
@ -87,7 +88,7 @@ static int (*ALSA_snd_device_name_free_hint)(void **);
|
||||||
static snd_pcm_sframes_t (*ALSA_snd_pcm_avail)(snd_pcm_t *);
|
static snd_pcm_sframes_t (*ALSA_snd_pcm_avail)(snd_pcm_t *);
|
||||||
static size_t (*ALSA_snd_ctl_card_info_sizeof)(void);
|
static size_t (*ALSA_snd_ctl_card_info_sizeof)(void);
|
||||||
static size_t (*ALSA_snd_pcm_info_sizeof)(void);
|
static size_t (*ALSA_snd_pcm_info_sizeof)(void);
|
||||||
static int (*ALSA_snd_card_next)(int*);
|
static int (*ALSA_snd_card_next)(int *);
|
||||||
static int (*ALSA_snd_ctl_open)(snd_ctl_t **,const char *,int);
|
static int (*ALSA_snd_ctl_open)(snd_ctl_t **,const char *,int);
|
||||||
static int (*ALSA_snd_ctl_close)(snd_ctl_t *);
|
static int (*ALSA_snd_ctl_close)(snd_ctl_t *);
|
||||||
static int (*ALSA_snd_ctl_card_info)(snd_ctl_t *, snd_ctl_card_info_t *);
|
static int (*ALSA_snd_ctl_card_info)(snd_ctl_t *, snd_ctl_card_info_t *);
|
||||||
|
|
@ -348,28 +349,25 @@ static char *get_pcm_str(void *handle)
|
||||||
// This function waits until it is possible to write a full sound buffer
|
// This function waits until it is possible to write a full sound buffer
|
||||||
static bool ALSA_WaitDevice(SDL_AudioDevice *device)
|
static bool ALSA_WaitDevice(SDL_AudioDevice *device)
|
||||||
{
|
{
|
||||||
const int fulldelay = (int) ((((Uint64) device->sample_frames) * 1000) / device->spec.freq);
|
const int sample_frames = device->sample_frames;
|
||||||
const int delay = SDL_max(fulldelay, 10);
|
const int fulldelay = (int) ((((Uint64) sample_frames) * 1000) / device->spec.freq);
|
||||||
|
const int delay = SDL_clamp(fulldelay, 1, 5);
|
||||||
|
|
||||||
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
while (!SDL_GetAtomicInt(&device->shutdown)) {
|
||||||
const int rc = ALSA_snd_pcm_wait(device->hidden->pcm, delay);
|
const int rc = ALSA_snd_pcm_avail(device->hidden->pcm);
|
||||||
if (rc < 0 && (rc != -EAGAIN)) {
|
if (rc < 0) {
|
||||||
const int status = ALSA_snd_pcm_recover(device->hidden->pcm, rc, 0);
|
const int status = ALSA_snd_pcm_recover(device->hidden->pcm, rc, 0);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
// Hmm, not much we can do - abort
|
// Hmm, not much we can do - abort
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "ALSA: snd_pcm_wait failed (unrecoverable): %s", ALSA_snd_strerror(rc));
|
SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "ALSA wait failed (unrecoverable): %s", ALSA_snd_strerror(rc));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
if (rc >= sample_frames) {
|
||||||
if (rc > 0) {
|
break;
|
||||||
break; // ready to go!
|
|
||||||
}
|
}
|
||||||
|
SDL_Delay(delay);
|
||||||
// Timed out! Make sure we aren't shutting down and then wait again.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -431,8 +429,11 @@ static int ALSA_RecordDevice(SDL_AudioDevice *device, void *buffer, int buflen)
|
||||||
SDL_assert((buflen % frame_size) == 0);
|
SDL_assert((buflen % frame_size) == 0);
|
||||||
|
|
||||||
const snd_pcm_sframes_t total_available = ALSA_snd_pcm_avail(device->hidden->pcm);
|
const snd_pcm_sframes_t total_available = ALSA_snd_pcm_avail(device->hidden->pcm);
|
||||||
const int total_frames = SDL_min(buflen / frame_size, total_available);
|
if (total_available == 0) {
|
||||||
|
return 0; // go back to WaitDevice and try again.
|
||||||
|
}
|
||||||
|
|
||||||
|
const int total_frames = SDL_min(buflen / frame_size, total_available);
|
||||||
const int rc = ALSA_snd_pcm_readi(device->hidden->pcm, buffer, total_frames);
|
const int rc = ALSA_snd_pcm_readi(device->hidden->pcm, buffer, total_frames);
|
||||||
|
|
||||||
SDL_assert(rc != -EAGAIN); // assuming this can't happen if we used snd_pcm_wait and queried for available space. snd_pcm_recover won't handle it!
|
SDL_assert(rc != -EAGAIN); // assuming this can't happen if we used snd_pcm_wait and queried for available space. snd_pcm_recover won't handle it!
|
||||||
|
|
@ -671,7 +672,7 @@ static void swizzle_map_compute(const struct ALSA_pcm_cfg_ctx *ctx, int *swizzle
|
||||||
static int alsa_chmap_install(struct ALSA_pcm_cfg_ctx *ctx, const unsigned int *chmap)
|
static int alsa_chmap_install(struct ALSA_pcm_cfg_ctx *ctx, const unsigned int *chmap)
|
||||||
{
|
{
|
||||||
bool isstack;
|
bool isstack;
|
||||||
snd_pcm_chmap_t *chmap_to_install = (snd_pcm_chmap_t*)SDL_small_alloc(unsigned int, 1 + ctx->chans_n, &isstack);
|
snd_pcm_chmap_t *chmap_to_install = (snd_pcm_chmap_t *)SDL_small_alloc(unsigned int, 1 + ctx->chans_n, &isstack);
|
||||||
if (!chmap_to_install) {
|
if (!chmap_to_install) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1215,7 +1216,7 @@ static int hotplug_device_process(snd_ctl_t *ctl, snd_ctl_card_info_t *ctl_card_
|
||||||
unsigned int subdev_idx = 0;
|
unsigned int subdev_idx = 0;
|
||||||
const bool recording = direction == SND_PCM_STREAM_CAPTURE ? true : false; // used for the unicity of the device
|
const bool recording = direction == SND_PCM_STREAM_CAPTURE ? true : false; // used for the unicity of the device
|
||||||
bool isstack;
|
bool isstack;
|
||||||
snd_pcm_info_t *pcm_info = (snd_pcm_info_t*)SDL_small_alloc(Uint8, ALSA_snd_pcm_info_sizeof(), &isstack);
|
snd_pcm_info_t *pcm_info = (snd_pcm_info_t *)SDL_small_alloc(Uint8, ALSA_snd_pcm_info_sizeof(), &isstack);
|
||||||
SDL_memset(pcm_info, 0, ALSA_snd_pcm_info_sizeof());
|
SDL_memset(pcm_info, 0, ALSA_snd_pcm_info_sizeof());
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
@ -1445,6 +1446,65 @@ static int SDLCALL ALSA_HotplugThread(void *arg)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SDL_USE_LIBUDEV
|
||||||
|
|
||||||
|
static bool udev_initialized;
|
||||||
|
|
||||||
|
static void ALSA_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath)
|
||||||
|
{
|
||||||
|
if (!devpath) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (udev_type) {
|
||||||
|
case SDL_UDEV_DEVICEADDED:
|
||||||
|
ALSA_HotplugIteration(NULL, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_UDEV_DEVICEREMOVED:
|
||||||
|
ALSA_HotplugIteration(NULL, NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ALSA_start_udev()
|
||||||
|
{
|
||||||
|
udev_initialized = SDL_UDEV_Init();
|
||||||
|
if (udev_initialized) {
|
||||||
|
// Set up the udev callback
|
||||||
|
if (!SDL_UDEV_AddCallback(ALSA_udev_callback)) {
|
||||||
|
SDL_UDEV_Quit();
|
||||||
|
udev_initialized = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return udev_initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ALSA_stop_udev()
|
||||||
|
{
|
||||||
|
if (udev_initialized) {
|
||||||
|
SDL_UDEV_DelCallback(ALSA_udev_callback);
|
||||||
|
SDL_UDEV_Quit();
|
||||||
|
udev_initialized = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
static bool ALSA_start_udev()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ALSA_stop_udev()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SDL_USE_LIBUDEV
|
||||||
|
|
||||||
static void ALSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
static void ALSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevice **default_recording)
|
||||||
{
|
{
|
||||||
ALSA_guess_device_prefix();
|
ALSA_guess_device_prefix();
|
||||||
|
|
@ -1454,17 +1514,19 @@ static void ALSA_DetectDevices(SDL_AudioDevice **default_playback, SDL_AudioDevi
|
||||||
bool has_default_playback = false, has_default_recording = false;
|
bool has_default_playback = false, has_default_recording = false;
|
||||||
ALSA_HotplugIteration(&has_default_playback, &has_default_recording); // run once now before a thread continues to check.
|
ALSA_HotplugIteration(&has_default_playback, &has_default_recording); // run once now before a thread continues to check.
|
||||||
if (has_default_playback) {
|
if (has_default_playback) {
|
||||||
*default_playback = SDL_AddAudioDevice(/*recording=*/false, "ALSA default playback device", NULL, (void*)&default_playback_handle);
|
*default_playback = SDL_AddAudioDevice(/*recording=*/false, "ALSA default playback device", NULL, (void *)&default_playback_handle);
|
||||||
}
|
}
|
||||||
if (has_default_recording) {
|
if (has_default_recording) {
|
||||||
*default_recording = SDL_AddAudioDevice(/*recording=*/true, "ALSA default recording device", NULL, (void*)&default_recording_handle);
|
*default_recording = SDL_AddAudioDevice(/*recording=*/true, "ALSA default recording device", NULL, (void *)&default_recording_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ALSA_start_udev()) {
|
||||||
#if SDL_ALSA_HOTPLUG_THREAD
|
#if SDL_ALSA_HOTPLUG_THREAD
|
||||||
SDL_SetAtomicInt(&ALSA_hotplug_shutdown, 0);
|
SDL_SetAtomicInt(&ALSA_hotplug_shutdown, 0);
|
||||||
ALSA_hotplug_thread = SDL_CreateThread(ALSA_HotplugThread, "SDLHotplugALSA", NULL);
|
ALSA_hotplug_thread = SDL_CreateThread(ALSA_HotplugThread, "SDLHotplugALSA", NULL);
|
||||||
// if the thread doesn't spin, oh well, you just don't get further hotplug events.
|
// if the thread doesn't spin, oh well, you just don't get further hotplug events.
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ALSA_DeinitializeStart(void)
|
static void ALSA_DeinitializeStart(void)
|
||||||
|
|
@ -1479,6 +1541,7 @@ static void ALSA_DeinitializeStart(void)
|
||||||
ALSA_hotplug_thread = NULL;
|
ALSA_hotplug_thread = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
ALSA_stop_udev();
|
||||||
|
|
||||||
// Shutting down! Clean up any data we've gathered.
|
// Shutting down! Clean up any data we've gathered.
|
||||||
for (dev = hotplug_devices; dev; dev = next) {
|
for (dev = hotplug_devices; dev; dev = next) {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ static bool EMSCRIPTENAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buf
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var j = 0; j < $1; ++j) {
|
for (var j = 0; j < $1; ++j) {
|
||||||
channelData[j] = HEAPF32[buf + (j*numChannels + c)];
|
channelData[j] = HEAPF32[buf + (j * numChannels + c)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, buffer, buffer_size / framelen);
|
}, buffer, buffer_size / framelen);
|
||||||
|
|
|
||||||
|
|
@ -546,7 +546,7 @@ static void node_event_info(void *object, const struct pw_node_info *info)
|
||||||
|
|
||||||
// Need to parse the parameters to get the sample rate
|
// Need to parse the parameters to get the sample rate
|
||||||
for (i = 0; i < info->n_params; ++i) {
|
for (i = 0; i < info->n_params; ++i) {
|
||||||
pw_node_enum_params((struct pw_node*)node->proxy, 0, info->params[i].id, 0, 0, NULL);
|
pw_node_enum_params((struct pw_node *)node->proxy, 0, info->params[i].id, 0, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
hotplug_core_sync(node);
|
hotplug_core_sync(node);
|
||||||
|
|
|
||||||
|
|
@ -750,7 +750,7 @@ static bool mgmtthrtask_PrepDevice(void *userdata)
|
||||||
// Try querying IAudioClient3 if sharemode is AUDCLNT_SHAREMODE_SHARED
|
// Try querying IAudioClient3 if sharemode is AUDCLNT_SHAREMODE_SHARED
|
||||||
if (sharemode == AUDCLNT_SHAREMODE_SHARED) {
|
if (sharemode == AUDCLNT_SHAREMODE_SHARED) {
|
||||||
IAudioClient3 *client3 = NULL;
|
IAudioClient3 *client3 = NULL;
|
||||||
ret = IAudioClient_QueryInterface(client, &SDL_IID_IAudioClient3, (void**)&client3);
|
ret = IAudioClient_QueryInterface(client, &SDL_IID_IAudioClient3, (void **)&client3);
|
||||||
if (SUCCEEDED(ret)) {
|
if (SUCCEEDED(ret)) {
|
||||||
UINT32 default_period_in_frames = 0;
|
UINT32 default_period_in_frames = 0;
|
||||||
UINT32 fundamental_period_in_frames = 0;
|
UINT32 fundamental_period_in_frames = 0;
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ static void COREMEDIA_CloseDevice(SDL_Camera *device)
|
||||||
hidden.session = nil;
|
hidden.session = nil;
|
||||||
[session stopRunning];
|
[session stopRunning];
|
||||||
[session removeInput:[session.inputs objectAtIndex:0]];
|
[session removeInput:[session.inputs objectAtIndex:0]];
|
||||||
[session removeOutput:(AVCaptureVideoDataOutput*)[session.outputs objectAtIndex:0]];
|
[session removeOutput:(AVCaptureVideoDataOutput *)[session.outputs objectAtIndex:0]];
|
||||||
session = nil;
|
session = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -675,7 +675,7 @@ static HRESULT GetDefaultStride(IMFMediaType *pType, LONG *plStride)
|
||||||
LONG lStride = 0;
|
LONG lStride = 0;
|
||||||
|
|
||||||
// Try to get the default stride from the media type.
|
// Try to get the default stride from the media type.
|
||||||
HRESULT ret = IMFMediaType_GetUINT32(pType, &SDL_MF_MT_DEFAULT_STRIDE, (UINT32*)&lStride);
|
HRESULT ret = IMFMediaType_GetUINT32(pType, &SDL_MF_MT_DEFAULT_STRIDE, (UINT32 *)&lStride);
|
||||||
if (FAILED(ret)) {
|
if (FAILED(ret)) {
|
||||||
// Attribute not set. Try to calculate the default stride.
|
// Attribute not set. Try to calculate the default stride.
|
||||||
|
|
||||||
|
|
@ -1001,7 +1001,7 @@ static void MaybeAddDevice(IMFActivate *activation)
|
||||||
if (name && symlink) {
|
if (name && symlink) {
|
||||||
IMFMediaSource *source = NULL;
|
IMFMediaSource *source = NULL;
|
||||||
// "activating" here only creates an object, it doesn't open the actual camera hardware or start recording.
|
// "activating" here only creates an object, it doesn't open the actual camera hardware or start recording.
|
||||||
HRESULT ret = IMFActivate_ActivateObject(activation, &SDL_IID_IMFMediaSource, (void**)&source);
|
HRESULT ret = IMFActivate_ActivateObject(activation, &SDL_IID_IMFMediaSource, (void **)&source);
|
||||||
if (SUCCEEDED(ret) && source) {
|
if (SUCCEEDED(ret) && source) {
|
||||||
CameraFormatAddData add_data;
|
CameraFormatAddData add_data;
|
||||||
GatherCameraSpecs(source, &add_data);
|
GatherCameraSpecs(source, &add_data);
|
||||||
|
|
|
||||||
|
|
@ -838,7 +838,7 @@ static void node_event_info(void *object, const struct pw_node_info *info)
|
||||||
if (!(info->params[i].flags & SPA_PARAM_INFO_READ))
|
if (!(info->params[i].flags & SPA_PARAM_INFO_READ))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
res = pw_node_enum_params((struct pw_node*)g->proxy,
|
res = pw_node_enum_params((struct pw_node *)g->proxy,
|
||||||
++SPA_PARAMS_INFO_SEQ(info->params[i]), id, 0, -1, NULL);
|
++SPA_PARAMS_INFO_SEQ(info->params[i]), id, 0, -1, NULL);
|
||||||
if (SPA_RESULT_IS_ASYNC(res))
|
if (SPA_RESULT_IS_ASYNC(res))
|
||||||
SPA_PARAMS_INFO_SEQ(info->params[i]) = res;
|
SPA_PARAMS_INFO_SEQ(info->params[i]) = res;
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ static SDL_CameraFrameResult V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *
|
||||||
*timestampNS = (((Uint64) buf.timestamp.tv_sec) * SDL_NS_PER_SECOND) + SDL_US_TO_NS(buf.timestamp.tv_usec);
|
*timestampNS = (((Uint64) buf.timestamp.tv_sec) * SDL_NS_PER_SECOND) + SDL_US_TO_NS(buf.timestamp.tv_usec);
|
||||||
|
|
||||||
#if DEBUG_CAMERA
|
#if DEBUG_CAMERA
|
||||||
SDL_Log("CAMERA: debug mmap: image %d/%d data[0]=%p", buf.index, device->hidden->nb_buffers, (void*)frame->pixels);
|
SDL_Log("CAMERA: debug mmap: image %d/%d data[0]=%p", buf.index, device->hidden->nb_buffers, (void *)frame->pixels);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -230,7 +230,7 @@ static SDL_CameraFrameResult V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *
|
||||||
return SDL_CAMERA_FRAME_ERROR;
|
return SDL_CAMERA_FRAME_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->pixels = (void*)buf.m.userptr;
|
frame->pixels = (void *)buf.m.userptr;
|
||||||
if (device->hidden->driver_pitch) {
|
if (device->hidden->driver_pitch) {
|
||||||
frame->pitch = device->hidden->driver_pitch;
|
frame->pitch = device->hidden->driver_pitch;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -241,7 +241,7 @@ static SDL_CameraFrameResult V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *
|
||||||
*timestampNS = (((Uint64) buf.timestamp.tv_sec) * SDL_NS_PER_SECOND) + SDL_US_TO_NS(buf.timestamp.tv_usec);
|
*timestampNS = (((Uint64) buf.timestamp.tv_sec) * SDL_NS_PER_SECOND) + SDL_US_TO_NS(buf.timestamp.tv_usec);
|
||||||
|
|
||||||
#if DEBUG_CAMERA
|
#if DEBUG_CAMERA
|
||||||
SDL_Log("CAMERA: debug userptr: image %d/%d data[0]=%p", buf.index, device->hidden->nb_buffers, (void*)frame->pixels);
|
SDL_Log("CAMERA: debug userptr: image %d/%d data[0]=%p", buf.index, device->hidden->nb_buffers, (void *)frame->pixels);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ static void MaybeAddDevice(Sint32 devid)
|
||||||
GatherCameraSpecs(devid, &add_data, &fullname, &position);
|
GatherCameraSpecs(devid, &add_data, &fullname, &position);
|
||||||
|
|
||||||
if (add_data.num_specs > 0) {
|
if (add_data.num_specs > 0) {
|
||||||
SDL_AddCamera(fullname, position, add_data.num_specs, add_data.specs, (void*)devid);
|
SDL_AddCamera(fullname, position, add_data.num_specs, add_data.specs, (void *)devid);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_free(fullname);
|
SDL_free(fullname);
|
||||||
|
|
@ -102,7 +102,7 @@ static void MaybeAddDevice(Sint32 devid)
|
||||||
|
|
||||||
static SceUID imbUid = -1;
|
static SceUID imbUid = -1;
|
||||||
|
|
||||||
static void freeBuffers(SceCameraInfo* info)
|
static void freeBuffers(SceCameraInfo *info)
|
||||||
{
|
{
|
||||||
if (imbUid != -1) {
|
if (imbUid != -1) {
|
||||||
sceKernelFreeMemBlock(imbUid);
|
sceKernelFreeMemBlock(imbUid);
|
||||||
|
|
@ -118,7 +118,7 @@ static bool VITACAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec
|
||||||
return SDL_SetError("Only one camera can be active");
|
return SDL_SetError("Only one camera can be active");
|
||||||
}
|
}
|
||||||
|
|
||||||
SceCameraInfo* info = (SceCameraInfo*)SDL_calloc(1, sizeof(SceCameraInfo));
|
SceCameraInfo *info = (SceCameraInfo *)SDL_calloc(1, sizeof(SceCameraInfo));
|
||||||
|
|
||||||
info->size = sizeof(SceCameraInfo);
|
info->size = sizeof(SceCameraInfo);
|
||||||
info->priority = SCE_CAMERA_PRIORITY_SHARE;
|
info->priority = SCE_CAMERA_PRIORITY_SHARE;
|
||||||
|
|
@ -139,12 +139,12 @@ static bool VITACAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec
|
||||||
info->format = SCE_CAMERA_FORMAT_YUV420_PLANE;
|
info->format = SCE_CAMERA_FORMAT_YUV420_PLANE;
|
||||||
info->pitch = 0; // same size surface
|
info->pitch = 0; // same size surface
|
||||||
|
|
||||||
info->sizeIBase = spec->width*spec->height;;
|
info->sizeIBase = spec->width * spec->height;;
|
||||||
info->sizeUBase = ((spec->width+1)/2) * ((spec->height+1) / 2);
|
info->sizeUBase = ((spec->width+1)/2) * ((spec->height+1) / 2);
|
||||||
info->sizeVBase = ((spec->width+1)/2) * ((spec->height+1) / 2);
|
info->sizeVBase = ((spec->width+1)/2) * ((spec->height+1) / 2);
|
||||||
|
|
||||||
// PHYCONT memory size *must* be a multiple of 1MB, we can just always spend 2MB, since we don't use PHYCONT anywhere else
|
// PHYCONT memory size *must* be a multiple of 1MB, we can just always spend 2MB, since we don't use PHYCONT anywhere else
|
||||||
imbUid = sceKernelAllocMemBlock("CameraI", SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW, 2*1024*1024 , NULL);
|
imbUid = sceKernelAllocMemBlock("CameraI", SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW, 2 * 1024 * 1024 , NULL);
|
||||||
if (imbUid < 0)
|
if (imbUid < 0)
|
||||||
{
|
{
|
||||||
return SDL_SetError("sceKernelAllocMemBlock error: 0x%08X", imbUid);
|
return SDL_SetError("sceKernelAllocMemBlock error: 0x%08X", imbUid);
|
||||||
|
|
@ -179,7 +179,7 @@ static void VITACAMERA_CloseDevice(SDL_Camera *device)
|
||||||
if (device->hidden) {
|
if (device->hidden) {
|
||||||
sceCameraStop((int)device->handle);
|
sceCameraStop((int)device->handle);
|
||||||
sceCameraClose((int)device->handle);
|
sceCameraClose((int)device->handle);
|
||||||
freeBuffers((SceCameraInfo*)device->hidden);
|
freeBuffers((SceCameraInfo *)device->hidden);
|
||||||
SDL_free(device->hidden);
|
SDL_free(device->hidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -205,7 +205,7 @@ static SDL_CameraFrameResult VITACAMERA_AcquireFrame(SDL_Camera *device, SDL_Sur
|
||||||
|
|
||||||
*timestampNS = read.timestamp;
|
*timestampNS = read.timestamp;
|
||||||
|
|
||||||
SceCameraInfo* info = (SceCameraInfo*)(device->hidden);
|
SceCameraInfo *info = (SceCameraInfo *)(device->hidden);
|
||||||
|
|
||||||
frame->pitch = info->width;
|
frame->pitch = info->width;
|
||||||
frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), info->sizeIBase + info->sizeUBase + info->sizeVBase);
|
frame->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), info->sizeIBase + info->sizeUBase + info->sizeVBase);
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ void *SDL_GetAndroidActivity(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidCachePath(void);
|
SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidCachePath(void);
|
||||||
const char* SDL_GetAndroidCachePath(void)
|
const char *SDL_GetAndroidCachePath(void)
|
||||||
{
|
{
|
||||||
SDL_Unsupported();
|
SDL_Unsupported();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -127,7 +127,7 @@ const char* SDL_GetAndroidCachePath(void)
|
||||||
|
|
||||||
|
|
||||||
SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidExternalStoragePath(void);
|
SDL_DECLSPEC const char * SDLCALL SDL_GetAndroidExternalStoragePath(void);
|
||||||
const char* SDL_GetAndroidExternalStoragePath(void)
|
const char *SDL_GetAndroidExternalStoragePath(void)
|
||||||
{
|
{
|
||||||
SDL_Unsupported();
|
SDL_Unsupported();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -172,7 +172,7 @@ bool SDL_SendAndroidMessage(Uint32 command, int param)
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DECLSPEC bool SDLCALL SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset);
|
SDL_DECLSPEC bool SDLCALL SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset);
|
||||||
bool SDL_ShowAndroidToast(const char* message, int duration, int gravity, int xoffset, int yoffset)
|
bool SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset)
|
||||||
{
|
{
|
||||||
(void)message;
|
(void)message;
|
||||||
(void)duration;
|
(void)duration;
|
||||||
|
|
|
||||||
|
|
@ -2691,7 +2691,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)(
|
||||||
|
|
||||||
// Convert fileList to string
|
// Convert fileList to string
|
||||||
size_t count = (*env)->GetArrayLength(env, fileList);
|
size_t count = (*env)->GetArrayLength(env, fileList);
|
||||||
char **charFileList = SDL_calloc(count + 1, sizeof(char*));
|
char **charFileList = SDL_calloc(count + 1, sizeof(char *));
|
||||||
|
|
||||||
if (charFileList == NULL) {
|
if (charFileList == NULL) {
|
||||||
mAndroidFileDialogData.callback(mAndroidFileDialogData.userdata, NULL, -1);
|
mAndroidFileDialogData.callback(mAndroidFileDialogData.userdata, NULL, -1);
|
||||||
|
|
@ -2747,7 +2747,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeFileDialog)(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Android_JNI_OpenFileDialog(
|
bool Android_JNI_OpenFileDialog(
|
||||||
SDL_DialogFileCallback callback, void* userdata,
|
SDL_DialogFileCallback callback, void *userdata,
|
||||||
const SDL_DialogFileFilter *filters, int nfilters, bool forwrite,
|
const SDL_DialogFileFilter *filters, int nfilters, bool forwrite,
|
||||||
bool multiple)
|
bool multiple)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ bool SDL_IsAndroidTablet(void);
|
||||||
bool SDL_IsAndroidTV(void);
|
bool SDL_IsAndroidTV(void);
|
||||||
|
|
||||||
// File Dialogs
|
// File Dialogs
|
||||||
bool Android_JNI_OpenFileDialog(SDL_DialogFileCallback callback, void* userdata,
|
bool Android_JNI_OpenFileDialog(SDL_DialogFileCallback callback, void *userdata,
|
||||||
const SDL_DialogFileFilter *filters, int nfilters, bool forwrite,
|
const SDL_DialogFileFilter *filters, int nfilters, bool forwrite,
|
||||||
bool multiple);
|
bool multiple);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data)
|
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void *), void *release_callback_data, void (*acquire_callback)(void *), void *acquire_callback_data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ extern "C" SDL_BLooper *SDL_Looper;
|
||||||
class SDL_BLooper : public BLooper
|
class SDL_BLooper : public BLooper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SDL_BLooper(const char* name) : BLooper(name)
|
SDL_BLooper(const char *name) : BLooper(name)
|
||||||
{
|
{
|
||||||
#ifdef SDL_VIDEO_OPENGL
|
#ifdef SDL_VIDEO_OPENGL
|
||||||
_current_context = NULL;
|
_current_context = NULL;
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ const char *SDL_signature = "application/x-SDL-executable";
|
||||||
// Create a descendant of BApplication
|
// Create a descendant of BApplication
|
||||||
class SDL_BApp : public BApplication {
|
class SDL_BApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
SDL_BApp(const char* signature) :
|
SDL_BApp(const char *signature) :
|
||||||
BApplication(signature) {
|
BApplication(signature) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void RefsReceived(BMessage* message) {
|
virtual void RefsReceived(BMessage *message) {
|
||||||
entry_ref entryRef;
|
entry_ref entryRef;
|
||||||
for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) {
|
for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) {
|
||||||
BPath referencePath = BPath(&entryRef);
|
BPath referencePath = BPath(&entryRef);
|
||||||
|
|
|
||||||
|
|
@ -287,8 +287,8 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl
|
||||||
}
|
}
|
||||||
#endif // SDL_USE_LIBUDEV
|
#endif // SDL_USE_LIBUDEV
|
||||||
|
|
||||||
void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data,
|
void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void *), void *release_callback_data,
|
||||||
void (*acquire_callback)(void*), void *acquire_callback_data)
|
void (*acquire_callback)(void *), void *acquire_callback_data)
|
||||||
{
|
{
|
||||||
SDL_EVDEV_kbd_set_vt_switch_callbacks(_this->kbd,
|
SDL_EVDEV_kbd_set_vt_switch_callbacks(_this->kbd,
|
||||||
release_callback, release_callback_data,
|
release_callback, release_callback_data,
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ struct input_event;
|
||||||
|
|
||||||
extern bool SDL_EVDEV_Init(void);
|
extern bool SDL_EVDEV_Init(void);
|
||||||
extern void SDL_EVDEV_Quit(void);
|
extern void SDL_EVDEV_Quit(void);
|
||||||
extern void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data,
|
extern void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void *), void *release_callback_data,
|
||||||
void (*acquire_callback)(void*), void *acquire_callback_data);
|
void (*acquire_callback)(void *), void *acquire_callback_data);
|
||||||
extern int SDL_EVDEV_GetDeviceCount(int device_class);
|
extern int SDL_EVDEV_GetDeviceCount(int device_class);
|
||||||
extern void SDL_EVDEV_Poll(void);
|
extern void SDL_EVDEV_Poll(void);
|
||||||
extern Uint64 SDL_EVDEV_GetEventTimestamp(struct input_event *event);
|
extern Uint64 SDL_EVDEV_GetEventTimestamp(struct input_event *event);
|
||||||
|
|
|
||||||
|
|
@ -495,7 +495,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted)
|
||||||
state->muted = muted;
|
state->muted = muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data)
|
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void *), void *release_callback_data, void (*acquire_callback)(void *), void *acquire_callback_data)
|
||||||
{
|
{
|
||||||
if (state == NULL) {
|
if (state == NULL) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -978,7 +978,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data)
|
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void *), void *release_callback_data, void (*acquire_callback)(void *), void *acquire_callback_data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ typedef struct SDL_EVDEV_keyboard_state SDL_EVDEV_keyboard_state;
|
||||||
|
|
||||||
extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void);
|
extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void);
|
||||||
extern void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted);
|
extern void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, bool muted);
|
||||||
extern void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data);
|
extern void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void *), void *release_callback_data, void (*acquire_callback)(void *), void *acquire_callback_data);
|
||||||
extern void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state);
|
extern void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state);
|
||||||
extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down);
|
extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down);
|
||||||
extern void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state);
|
extern void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state);
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *pr
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
char type;
|
char type;
|
||||||
struct udev_device *dev;
|
struct udev_device *dev;
|
||||||
const char* val;
|
const char *val;
|
||||||
int class_temp;
|
int class_temp;
|
||||||
|
|
||||||
if (!_this) {
|
if (!_this) {
|
||||||
|
|
|
||||||
|
|
@ -58,13 +58,13 @@ static void ReactivateAfterDialog(void)
|
||||||
|
|
||||||
void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFileCallback callback, void *userdata, SDL_PropertiesID props)
|
void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFileCallback callback, void *userdata, SDL_PropertiesID props)
|
||||||
{
|
{
|
||||||
SDL_Window* window = SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_WINDOW_POINTER, NULL);
|
SDL_Window *window = SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_WINDOW_POINTER, NULL);
|
||||||
SDL_DialogFileFilter *filters = SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_FILTERS_POINTER, NULL);
|
SDL_DialogFileFilter *filters = SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_FILTERS_POINTER, NULL);
|
||||||
int nfilters = (int) SDL_GetNumberProperty(props, SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER, 0);
|
int nfilters = (int) SDL_GetNumberProperty(props, SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER, 0);
|
||||||
bool allow_many = SDL_GetBooleanProperty(props, SDL_PROP_FILE_DIALOG_MANY_BOOLEAN, false);
|
bool allow_many = SDL_GetBooleanProperty(props, SDL_PROP_FILE_DIALOG_MANY_BOOLEAN, false);
|
||||||
const char* default_location = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_LOCATION_STRING, NULL);
|
const char *default_location = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_LOCATION_STRING, NULL);
|
||||||
const char* title = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_TITLE_STRING, NULL);
|
const char *title = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_TITLE_STRING, NULL);
|
||||||
const char* accept = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_ACCEPT_STRING, NULL);
|
const char *accept = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_ACCEPT_STRING, NULL);
|
||||||
|
|
||||||
if (filters) {
|
if (filters) {
|
||||||
const char *msg = validate_filters(filters, nfilters);
|
const char *msg = validate_filters(filters, nfilters);
|
||||||
|
|
@ -170,7 +170,7 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
|
||||||
[dialog beginSheetModalForWindow:w completionHandler:^(NSInteger result) {
|
[dialog beginSheetModalForWindow:w completionHandler:^(NSInteger result) {
|
||||||
if (result == NSModalResponseOK) {
|
if (result == NSModalResponseOK) {
|
||||||
if (dialog_as_open) {
|
if (dialog_as_open) {
|
||||||
NSArray* urls = [dialog_as_open URLs];
|
NSArray *urls = [dialog_as_open URLs];
|
||||||
const char *files[[urls count] + 1];
|
const char *files[[urls count] + 1];
|
||||||
for (int i = 0; i < [urls count]; i++) {
|
for (int i = 0; i < [urls count]; i++) {
|
||||||
files[i] = [[[urls objectAtIndex:i] path] UTF8String];
|
files[i] = [[[urls objectAtIndex:i] path] UTF8String];
|
||||||
|
|
@ -191,7 +191,7 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
|
||||||
} else {
|
} else {
|
||||||
if ([dialog runModal] == NSModalResponseOK) {
|
if ([dialog runModal] == NSModalResponseOK) {
|
||||||
if (dialog_as_open) {
|
if (dialog_as_open) {
|
||||||
NSArray* urls = [dialog_as_open URLs];
|
NSArray *urls = [dialog_as_open URLs];
|
||||||
const char *files[[urls count] + 1];
|
const char *files[[urls count] + 1];
|
||||||
for (int i = 0; i < [urls count]; i++) {
|
for (int i = 0; i < [urls count]; i++) {
|
||||||
files[i] = [[[urls objectAtIndex:i] path] UTF8String];
|
files[i] = [[[urls objectAtIndex:i] path] UTF8String];
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ public:
|
||||||
case B_CANCEL: // Whenever the dialog is closed (Cancel but also after Open and Save)
|
case B_CANCEL: // Whenever the dialog is closed (Cancel but also after Open and Save)
|
||||||
{
|
{
|
||||||
nFiles = m_files.size();
|
nFiles = m_files.size();
|
||||||
const char* files[nFiles + 1];
|
const char *files[nFiles + 1];
|
||||||
for (int i = 0; i < nFiles; i++) {
|
for (int i = 0; i < nFiles; i++) {
|
||||||
files[i] = m_files[i].c_str();
|
files[i] = m_files[i].c_str();
|
||||||
}
|
}
|
||||||
|
|
@ -194,14 +194,14 @@ private:
|
||||||
|
|
||||||
void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFileCallback callback, void *userdata, SDL_PropertiesID props)
|
void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFileCallback callback, void *userdata, SDL_PropertiesID props)
|
||||||
{
|
{
|
||||||
SDL_Window* window = (SDL_Window*) SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_WINDOW_POINTER, NULL);
|
SDL_Window *window = (SDL_Window *)SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_WINDOW_POINTER, NULL);
|
||||||
SDL_DialogFileFilter* filters = (SDL_DialogFileFilter*) SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_FILTERS_POINTER, NULL);
|
SDL_DialogFileFilter *filters = (SDL_DialogFileFilter *)SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_FILTERS_POINTER, NULL);
|
||||||
int nfilters = (int) SDL_GetNumberProperty(props, SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER, 0);
|
int nfilters = (int) SDL_GetNumberProperty(props, SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER, 0);
|
||||||
bool many = SDL_GetBooleanProperty(props, SDL_PROP_FILE_DIALOG_MANY_BOOLEAN, false);
|
bool many = SDL_GetBooleanProperty(props, SDL_PROP_FILE_DIALOG_MANY_BOOLEAN, false);
|
||||||
const char* location = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_LOCATION_STRING, NULL);
|
const char *location = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_LOCATION_STRING, NULL);
|
||||||
const char* title = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_TITLE_STRING, NULL);
|
const char *title = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_TITLE_STRING, NULL);
|
||||||
const char* accept = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_ACCEPT_STRING, NULL);
|
const char *accept = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_ACCEPT_STRING, NULL);
|
||||||
const char* cancel = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_CANCEL_STRING, NULL);
|
const char *cancel = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_CANCEL_STRING, NULL);
|
||||||
|
|
||||||
bool modal = !!window;
|
bool modal = !!window;
|
||||||
|
|
||||||
|
|
@ -222,7 +222,7 @@ void SDL_SYS_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFil
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!SDL_InitBeApp()) {
|
if (!SDL_InitBeApp()) {
|
||||||
char* err = SDL_strdup(SDL_GetError());
|
char *err = SDL_strdup(SDL_GetError());
|
||||||
SDL_SetError("Couldn't init Be app: %s", err);
|
SDL_SetError("Couldn't init Be app: %s", err);
|
||||||
SDL_free(err);
|
SDL_free(err);
|
||||||
callback(userdata, NULL, -1);
|
callback(userdata, NULL, -1);
|
||||||
|
|
|
||||||
|
|
@ -288,12 +288,12 @@ void SDL_Portal_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_Dialog
|
||||||
const char *method;
|
const char *method;
|
||||||
const char *method_title;
|
const char *method_title;
|
||||||
|
|
||||||
SDL_Window* window = SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_WINDOW_POINTER, NULL);
|
SDL_Window *window = SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_WINDOW_POINTER, NULL);
|
||||||
SDL_DialogFileFilter *filters = SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_FILTERS_POINTER, NULL);
|
SDL_DialogFileFilter *filters = SDL_GetPointerProperty(props, SDL_PROP_FILE_DIALOG_FILTERS_POINTER, NULL);
|
||||||
int nfilters = (int) SDL_GetNumberProperty(props, SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER, 0);
|
int nfilters = (int) SDL_GetNumberProperty(props, SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER, 0);
|
||||||
bool allow_many = SDL_GetBooleanProperty(props, SDL_PROP_FILE_DIALOG_MANY_BOOLEAN, false);
|
bool allow_many = SDL_GetBooleanProperty(props, SDL_PROP_FILE_DIALOG_MANY_BOOLEAN, false);
|
||||||
const char* default_location = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_LOCATION_STRING, NULL);
|
const char *default_location = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_LOCATION_STRING, NULL);
|
||||||
const char* accept = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_ACCEPT_STRING, NULL);
|
const char *accept = SDL_GetStringProperty(props, SDL_PROP_FILE_DIALOG_ACCEPT_STRING, NULL);
|
||||||
bool open_folders = false;
|
bool open_folders = false;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
|
||||||
|
|
@ -277,7 +277,7 @@ void windows_ShowFileDialog(void *ptr)
|
||||||
|
|
||||||
while (*file_ptr) {
|
while (*file_ptr) {
|
||||||
nfiles++;
|
nfiles++;
|
||||||
char **new_cfl = (char **) SDL_realloc(chosen_files_list, sizeof(char*) * (nfiles + 1));
|
char **new_cfl = (char **) SDL_realloc(chosen_files_list, sizeof(char *) * (nfiles + 1));
|
||||||
|
|
||||||
if (!new_cfl) {
|
if (!new_cfl) {
|
||||||
for (size_t i = 0; i < nfiles - 1; i++) {
|
for (size_t i = 0; i < nfiles - 1; i++) {
|
||||||
|
|
@ -327,7 +327,7 @@ void windows_ShowFileDialog(void *ptr)
|
||||||
// If the user chose only one file, it's all just one string
|
// If the user chose only one file, it's all just one string
|
||||||
if (nfiles == 0) {
|
if (nfiles == 0) {
|
||||||
nfiles++;
|
nfiles++;
|
||||||
char **new_cfl = (char **) SDL_realloc(chosen_files_list, sizeof(char*) * (nfiles + 1));
|
char **new_cfl = (char **) SDL_realloc(chosen_files_list, sizeof(char *) * (nfiles + 1));
|
||||||
|
|
||||||
if (!new_cfl) {
|
if (!new_cfl) {
|
||||||
SDL_free(chosen_files_list);
|
SDL_free(chosen_files_list);
|
||||||
|
|
@ -348,7 +348,7 @@ void windows_ShowFileDialog(void *ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(userdata, (const char * const*) chosen_files_list, getFilterIndex(dialog.nFilterIndex));
|
callback(userdata, (const char * const *) chosen_files_list, getFilterIndex(dialog.nFilterIndex));
|
||||||
|
|
||||||
for (size_t i = 0; i < nfiles; i++) {
|
for (size_t i = 0; i < nfiles; i++) {
|
||||||
SDL_free(chosen_files_list[i]);
|
SDL_free(chosen_files_list[i]);
|
||||||
|
|
@ -443,11 +443,11 @@ void windows_ShowFolderDialog(void *ptr)
|
||||||
SHGetPathFromIDListW(lpItem, buffer);
|
SHGetPathFromIDListW(lpItem, buffer);
|
||||||
char *chosen_file = WIN_StringToUTF8W(buffer);
|
char *chosen_file = WIN_StringToUTF8W(buffer);
|
||||||
const char *files[2] = { chosen_file, NULL };
|
const char *files[2] = { chosen_file, NULL };
|
||||||
callback(userdata, (const char * const*) files, -1);
|
callback(userdata, (const char * const *) files, -1);
|
||||||
SDL_free(chosen_file);
|
SDL_free(chosen_file);
|
||||||
} else {
|
} else {
|
||||||
const char *files[1] = { NULL };
|
const char *files[1] = { NULL };
|
||||||
callback(userdata, (const char * const*) files, -1);
|
callback(userdata, (const char * const *) files, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -371,10 +371,10 @@ static const SDL_Scancode xfree86_scancode_table2[] = {
|
||||||
/* 188, 0x0bc */ SDL_SCANCODE_F18, // XF86Launch9
|
/* 188, 0x0bc */ SDL_SCANCODE_F18, // XF86Launch9
|
||||||
/* 189, 0x0bd */ SDL_SCANCODE_F19, // NoSymbol
|
/* 189, 0x0bd */ SDL_SCANCODE_F19, // NoSymbol
|
||||||
/* 190, 0x0be */ SDL_SCANCODE_F20, // XF86AudioMicMute
|
/* 190, 0x0be */ SDL_SCANCODE_F20, // XF86AudioMicMute
|
||||||
/* 191, 0x0bf */ SDL_SCANCODE_UNKNOWN, // XF86TouchpadToggle
|
/* 191, 0x0bf */ SDL_SCANCODE_F21, // XF86TouchpadToggle
|
||||||
/* 192, 0x0c0 */ SDL_SCANCODE_UNKNOWN, // XF86TouchpadOn
|
/* 192, 0x0c0 */ SDL_SCANCODE_F22, // XF86TouchpadOn
|
||||||
/* 193, 0x0c1 */ SDL_SCANCODE_UNKNOWN, // XF86TouchpadOff
|
/* 193, 0x0c1 */ SDL_SCANCODE_F23, // XF86TouchpadOff
|
||||||
/* 194, 0x0c2 */ SDL_SCANCODE_UNKNOWN, // NoSymbol
|
/* 194, 0x0c2 */ SDL_SCANCODE_F24, // NoSymbol
|
||||||
/* 195, 0x0c3 */ SDL_SCANCODE_MODE, // Mode_switch
|
/* 195, 0x0c3 */ SDL_SCANCODE_MODE, // Mode_switch
|
||||||
/* 196, 0x0c4 */ SDL_SCANCODE_UNKNOWN, // NoSymbol
|
/* 196, 0x0c4 */ SDL_SCANCODE_UNKNOWN, // NoSymbol
|
||||||
/* 197, 0x0c5 */ SDL_SCANCODE_UNKNOWN, // NoSymbol
|
/* 197, 0x0c5 */ SDL_SCANCODE_UNKNOWN, // NoSymbol
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder)
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
const char* base;
|
const char *base;
|
||||||
NSArray *array;
|
NSArray *array;
|
||||||
NSSearchPathDirectory dir;
|
NSSearchPathDirectory dir;
|
||||||
NSString *str;
|
NSString *str;
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
folderPath = (char*) SDL_malloc(MAX_PATH);
|
folderPath = (char *)SDL_malloc(MAX_PATH);
|
||||||
do {
|
do {
|
||||||
result = XGameSaveFilesGetFolderWithUiResult(&block, MAX_PATH, folderPath);
|
result = XGameSaveFilesGetFolderWithUiResult(&block, MAX_PATH, folderPath);
|
||||||
} while (result == E_PENDING);
|
} while (result == E_PENDING);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
extern void NGAGE_GetAppPath(char* path);
|
extern void NGAGE_GetAppPath(char *path);
|
||||||
|
|
||||||
char *SDL_SYS_GetBasePath(void)
|
char *SDL_SYS_GetBasePath(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void NGAGE_GetAppPath(char* path)
|
void NGAGE_GetAppPath(char *path)
|
||||||
{
|
{
|
||||||
TBuf<512> aPath;
|
TBuf<512> aPath;
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ void NGAGE_GetAppPath(char* path)
|
||||||
CnvUtfConverter::ConvertFromUnicodeToUtf8(utf8Path, aPath);
|
CnvUtfConverter::ConvertFromUnicodeToUtf8(utf8Path, aPath);
|
||||||
|
|
||||||
// Copy UTF-8 data to the provided char* buffer.
|
// Copy UTF-8 data to the provided char* buffer.
|
||||||
strncpy(path, (const char*)utf8Path.Ptr(), utf8Path.Length());
|
strncpy(path, (const char *)utf8Path.Ptr(), utf8Path.Length());
|
||||||
path[utf8Path.Length()] = '\0';
|
path[utf8Path.Length()] = '\0';
|
||||||
|
|
||||||
// Replace backslashes with forward slashes.
|
// Replace backslashes with forward slashes.
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa
|
||||||
if (!config_home || config_home[0] == 0)
|
if (!config_home || config_home[0] == 0)
|
||||||
{
|
{
|
||||||
l = SDL_strlen (home_dir) + SDL_strlen ("/.config/user-dirs.dirs") + 1;
|
l = SDL_strlen (home_dir) + SDL_strlen ("/.config/user-dirs.dirs") + 1;
|
||||||
config_file = (char*) SDL_malloc (l);
|
config_file = (char *)SDL_malloc (l);
|
||||||
if (!config_file)
|
if (!config_file)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
@ -387,7 +387,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
l = SDL_strlen (config_home) + SDL_strlen ("/user-dirs.dirs") + 1;
|
l = SDL_strlen (config_home) + SDL_strlen ("/user-dirs.dirs") + 1;
|
||||||
config_file = (char*) SDL_malloc (l);
|
config_file = (char *)SDL_malloc (l);
|
||||||
if (!config_file)
|
if (!config_file)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|
@ -449,7 +449,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa
|
||||||
if (relative)
|
if (relative)
|
||||||
{
|
{
|
||||||
l = SDL_strlen (home_dir) + 1 + SDL_strlen (p) + 1;
|
l = SDL_strlen (home_dir) + 1 + SDL_strlen (p) + 1;
|
||||||
user_dir = (char*) SDL_malloc (l);
|
user_dir = (char *)SDL_malloc (l);
|
||||||
if (!user_dir)
|
if (!user_dir)
|
||||||
goto error2;
|
goto error2;
|
||||||
|
|
||||||
|
|
@ -458,7 +458,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user_dir = (char*) SDL_malloc (SDL_strlen (p) + 1);
|
user_dir = (char *)SDL_malloc (SDL_strlen (p) + 1);
|
||||||
if (!user_dir)
|
if (!user_dir)
|
||||||
goto error2;
|
goto error2;
|
||||||
|
|
||||||
|
|
@ -503,7 +503,7 @@ static char *xdg_user_dir_lookup (const char *type)
|
||||||
// Special case desktop for historical compatibility
|
// Special case desktop for historical compatibility
|
||||||
if (SDL_strcmp(type, "DESKTOP") == 0) {
|
if (SDL_strcmp(type, "DESKTOP") == 0) {
|
||||||
size_t length = SDL_strlen(home_dir) + SDL_strlen("/Desktop") + 1;
|
size_t length = SDL_strlen(home_dir) + SDL_strlen("/Desktop") + 1;
|
||||||
user_dir = (char*) SDL_malloc(length);
|
user_dir = (char *)SDL_malloc(length);
|
||||||
if (!user_dir)
|
if (!user_dir)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1954,7 +1954,7 @@ void SDL_BindGPUVertexSamplers(
|
||||||
if (RENDERPASS_DEVICE->debug_mode) {
|
if (RENDERPASS_DEVICE->debug_mode) {
|
||||||
CHECK_RENDERPASS
|
CHECK_RENDERPASS
|
||||||
|
|
||||||
if (!((CommandBufferCommonHeader*)RENDERPASS_COMMAND_BUFFER)->ignore_render_pass_texture_validation)
|
if (!((CommandBufferCommonHeader *)RENDERPASS_COMMAND_BUFFER)->ignore_render_pass_texture_validation)
|
||||||
{
|
{
|
||||||
CHECK_SAMPLER_TEXTURES
|
CHECK_SAMPLER_TEXTURES
|
||||||
}
|
}
|
||||||
|
|
@ -2050,7 +2050,7 @@ void SDL_BindGPUFragmentSamplers(
|
||||||
if (RENDERPASS_DEVICE->debug_mode) {
|
if (RENDERPASS_DEVICE->debug_mode) {
|
||||||
CHECK_RENDERPASS
|
CHECK_RENDERPASS
|
||||||
|
|
||||||
if (!((CommandBufferCommonHeader*)RENDERPASS_COMMAND_BUFFER)->ignore_render_pass_texture_validation) {
|
if (!((CommandBufferCommonHeader *)RENDERPASS_COMMAND_BUFFER)->ignore_render_pass_texture_validation) {
|
||||||
CHECK_SAMPLER_TEXTURES
|
CHECK_SAMPLER_TEXTURES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1210,7 +1210,7 @@ static ID3D12CommandQueue *s_CommandQueue;
|
||||||
|
|
||||||
#if defined(SDL_PLATFORM_XBOXONE)
|
#if defined(SDL_PLATFORM_XBOXONE)
|
||||||
// These are not defined in d3d12_x.h.
|
// These are not defined in d3d12_x.h.
|
||||||
typedef HRESULT (D3DAPI* PFN_D3D12_XBOX_CREATE_DEVICE)(_In_opt_ IGraphicsUnknown*, _In_ const D3D12XBOX_CREATE_DEVICE_PARAMETERS*, _In_ REFIID, _Outptr_opt_ void**);
|
typedef HRESULT (D3DAPI* PFN_D3D12_XBOX_CREATE_DEVICE)(_In_opt_ IGraphicsUnknown *, _In_ const D3D12XBOX_CREATE_DEVICE_PARAMETERS*, _In_ REFIID, _Outptr_opt_ void **);
|
||||||
#define D3D12_STANDARD_MULTISAMPLE_PATTERN DXGI_STANDARD_MULTISAMPLE_QUALITY_PATTERN
|
#define D3D12_STANDARD_MULTISAMPLE_PATTERN DXGI_STANDARD_MULTISAMPLE_QUALITY_PATTERN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -2212,15 +2212,15 @@ static D3D12StagingDescriptorPool *D3D12_INTERNAL_CreateStagingDescriptorPool(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12StagingDescriptorPool *pool = (D3D12StagingDescriptorPool*) SDL_calloc(1, sizeof(D3D12StagingDescriptorPool));
|
D3D12StagingDescriptorPool *pool = (D3D12StagingDescriptorPool *)SDL_calloc(1, sizeof(D3D12StagingDescriptorPool));
|
||||||
|
|
||||||
pool->heapCount = 1;
|
pool->heapCount = 1;
|
||||||
pool->heaps = (D3D12DescriptorHeap**) SDL_malloc(sizeof(D3D12DescriptorHeap*));
|
pool->heaps = (D3D12DescriptorHeap **)SDL_malloc(sizeof(D3D12DescriptorHeap *));
|
||||||
pool->heaps[0] = heap;
|
pool->heaps[0] = heap;
|
||||||
|
|
||||||
pool->freeDescriptorCapacity = STAGING_HEAP_DESCRIPTOR_COUNT;
|
pool->freeDescriptorCapacity = STAGING_HEAP_DESCRIPTOR_COUNT;
|
||||||
pool->freeDescriptorCount = STAGING_HEAP_DESCRIPTOR_COUNT;
|
pool->freeDescriptorCount = STAGING_HEAP_DESCRIPTOR_COUNT;
|
||||||
pool->freeDescriptors = (D3D12StagingDescriptor*) SDL_malloc(STAGING_HEAP_DESCRIPTOR_COUNT * sizeof(D3D12StagingDescriptor));
|
pool->freeDescriptors = (D3D12StagingDescriptor *)SDL_malloc(STAGING_HEAP_DESCRIPTOR_COUNT * sizeof(D3D12StagingDescriptor));
|
||||||
|
|
||||||
for (Uint32 i = 0; i < STAGING_HEAP_DESCRIPTOR_COUNT; i += 1) {
|
for (Uint32 i = 0; i < STAGING_HEAP_DESCRIPTOR_COUNT; i += 1) {
|
||||||
pool->freeDescriptors[i].pool = pool;
|
pool->freeDescriptors[i].pool = pool;
|
||||||
|
|
@ -2250,12 +2250,12 @@ static bool D3D12_INTERNAL_ExpandStagingDescriptorPool(
|
||||||
}
|
}
|
||||||
|
|
||||||
pool->heapCount += 1;
|
pool->heapCount += 1;
|
||||||
pool->heaps = (D3D12DescriptorHeap**) SDL_realloc(pool->heaps, pool->heapCount * sizeof(D3D12DescriptorHeap*));
|
pool->heaps = (D3D12DescriptorHeap **)SDL_realloc(pool->heaps, pool->heapCount * sizeof(D3D12DescriptorHeap *));
|
||||||
pool->heaps[pool->heapCount - 1] = heap;
|
pool->heaps[pool->heapCount - 1] = heap;
|
||||||
|
|
||||||
pool->freeDescriptorCapacity += STAGING_HEAP_DESCRIPTOR_COUNT;
|
pool->freeDescriptorCapacity += STAGING_HEAP_DESCRIPTOR_COUNT;
|
||||||
pool->freeDescriptorCount += STAGING_HEAP_DESCRIPTOR_COUNT;
|
pool->freeDescriptorCount += STAGING_HEAP_DESCRIPTOR_COUNT;
|
||||||
pool->freeDescriptors = (D3D12StagingDescriptor*) SDL_realloc(pool->freeDescriptors, pool->freeDescriptorCapacity * sizeof(D3D12StagingDescriptor));
|
pool->freeDescriptors = (D3D12StagingDescriptor *)SDL_realloc(pool->freeDescriptors, pool->freeDescriptorCapacity * sizeof(D3D12StagingDescriptor));
|
||||||
|
|
||||||
for (Uint32 i = 0; i < STAGING_HEAP_DESCRIPTOR_COUNT; i += 1) {
|
for (Uint32 i = 0; i < STAGING_HEAP_DESCRIPTOR_COUNT; i += 1) {
|
||||||
pool->freeDescriptors[i].pool = pool;
|
pool->freeDescriptors[i].pool = pool;
|
||||||
|
|
@ -7521,7 +7521,7 @@ static bool D3D12_INTERNAL_AcquireSwapchainTexture(
|
||||||
1,
|
1,
|
||||||
&barrierDesc);
|
&barrierDesc);
|
||||||
|
|
||||||
*swapchainTexture = (SDL_GPUTexture*)&windowData->textureContainers[swapchainIndex];
|
*swapchainTexture = (SDL_GPUTexture *)&windowData->textureContainers[swapchainIndex];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7933,7 +7933,7 @@ static bool D3D12_Submit(
|
||||||
ID3D12Resource_Release(windowData->textureContainers[presentData->swapchainImageIndex].activeTexture->resource);
|
ID3D12Resource_Release(windowData->textureContainers[presentData->swapchainImageIndex].activeTexture->resource);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
windowData->inFlightFences[windowData->frameCounter] = (SDL_GPUFence*)d3d12CommandBuffer->inFlightFence;
|
windowData->inFlightFences[windowData->frameCounter] = (SDL_GPUFence *)d3d12CommandBuffer->inFlightFence;
|
||||||
(void)SDL_AtomicIncRef(&d3d12CommandBuffer->inFlightFence->referenceCount);
|
(void)SDL_AtomicIncRef(&d3d12CommandBuffer->inFlightFence->referenceCount);
|
||||||
windowData->frameCounter = (windowData->frameCounter + 1) % renderer->allowedFramesInFlight;
|
windowData->frameCounter = (windowData->frameCounter + 1) % renderer->allowedFramesInFlight;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3297,7 +3297,7 @@ static void SDLCALL VULKAN_INTERNAL_GraphicsPipelineResourceLayoutHashDestroy(vo
|
||||||
VulkanRenderer *renderer = (VulkanRenderer *)userdata;
|
VulkanRenderer *renderer = (VulkanRenderer *)userdata;
|
||||||
VulkanGraphicsPipelineResourceLayout *resourceLayout = (VulkanGraphicsPipelineResourceLayout *)value;
|
VulkanGraphicsPipelineResourceLayout *resourceLayout = (VulkanGraphicsPipelineResourceLayout *)value;
|
||||||
VULKAN_INTERNAL_DestroyGraphicsPipelineResourceLayout(renderer, resourceLayout);
|
VULKAN_INTERNAL_DestroyGraphicsPipelineResourceLayout(renderer, resourceLayout);
|
||||||
SDL_free((void*)key);
|
SDL_free((void *)key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint32 SDLCALL VULKAN_INTERNAL_ComputePipelineResourceLayoutHashFunction(void *userdata, const void *key)
|
static Uint32 SDLCALL VULKAN_INTERNAL_ComputePipelineResourceLayoutHashFunction(void *userdata, const void *key)
|
||||||
|
|
@ -3328,7 +3328,7 @@ static void SDLCALL VULKAN_INTERNAL_ComputePipelineResourceLayoutHashDestroy(voi
|
||||||
VulkanRenderer *renderer = (VulkanRenderer *)userdata;
|
VulkanRenderer *renderer = (VulkanRenderer *)userdata;
|
||||||
VulkanComputePipelineResourceLayout *resourceLayout = (VulkanComputePipelineResourceLayout *)value;
|
VulkanComputePipelineResourceLayout *resourceLayout = (VulkanComputePipelineResourceLayout *)value;
|
||||||
VULKAN_INTERNAL_DestroyComputePipelineResourceLayout(renderer, resourceLayout);
|
VULKAN_INTERNAL_DestroyComputePipelineResourceLayout(renderer, resourceLayout);
|
||||||
SDL_free((void*)key);
|
SDL_free((void *)key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint32 SDLCALL VULKAN_INTERNAL_DescriptorSetLayoutHashFunction(void *userdata, const void *key)
|
static Uint32 SDLCALL VULKAN_INTERNAL_DescriptorSetLayoutHashFunction(void *userdata, const void *key)
|
||||||
|
|
@ -3361,7 +3361,7 @@ static void SDLCALL VULKAN_INTERNAL_DescriptorSetLayoutHashDestroy(void *userdat
|
||||||
VulkanRenderer *renderer = (VulkanRenderer *)userdata;
|
VulkanRenderer *renderer = (VulkanRenderer *)userdata;
|
||||||
DescriptorSetLayout *layout = (DescriptorSetLayout *)value;
|
DescriptorSetLayout *layout = (DescriptorSetLayout *)value;
|
||||||
VULKAN_INTERNAL_DestroyDescriptorSetLayout(renderer, layout);
|
VULKAN_INTERNAL_DestroyDescriptorSetLayout(renderer, layout);
|
||||||
SDL_free((void*)key);
|
SDL_free((void *)key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint32 SDLCALL VULKAN_INTERNAL_CommandPoolHashFunction(void *userdata, const void *key)
|
static Uint32 SDLCALL VULKAN_INTERNAL_CommandPoolHashFunction(void *userdata, const void *key)
|
||||||
|
|
@ -10111,7 +10111,7 @@ static SDL_GPUTextureFormat VULKAN_GetSwapchainTextureFormat(
|
||||||
SDL_GPURenderer *driverData,
|
SDL_GPURenderer *driverData,
|
||||||
SDL_Window *window)
|
SDL_Window *window)
|
||||||
{
|
{
|
||||||
VulkanRenderer *renderer = (VulkanRenderer*)driverData;
|
VulkanRenderer *renderer = (VulkanRenderer *)driverData;
|
||||||
WindowData *windowData = VULKAN_INTERNAL_FetchWindowData(window);
|
WindowData *windowData = VULKAN_INTERNAL_FetchWindowData(window);
|
||||||
|
|
||||||
if (windowData == NULL) {
|
if (windowData == NULL) {
|
||||||
|
|
@ -10622,7 +10622,7 @@ static bool VULKAN_Submit(
|
||||||
|
|
||||||
if (presentResult == VK_SUCCESS || presentResult == VK_SUBOPTIMAL_KHR || presentResult == VK_ERROR_OUT_OF_DATE_KHR) {
|
if (presentResult == VK_SUCCESS || presentResult == VK_SUBOPTIMAL_KHR || presentResult == VK_ERROR_OUT_OF_DATE_KHR) {
|
||||||
// If presenting, the swapchain is using the in-flight fence
|
// If presenting, the swapchain is using the in-flight fence
|
||||||
presentData->windowData->inFlightFences[presentData->windowData->frameCounter] = (SDL_GPUFence*)vulkanCommandBuffer->inFlightFence;
|
presentData->windowData->inFlightFences[presentData->windowData->frameCounter] = (SDL_GPUFence *)vulkanCommandBuffer->inFlightFence;
|
||||||
(void)SDL_AtomicIncRef(&vulkanCommandBuffer->inFlightFence->referenceCount);
|
(void)SDL_AtomicIncRef(&vulkanCommandBuffer->inFlightFence->referenceCount);
|
||||||
|
|
||||||
if (presentResult == VK_SUBOPTIMAL_KHR || presentResult == VK_ERROR_OUT_OF_DATE_KHR) {
|
if (presentResult == VK_SUBOPTIMAL_KHR || presentResult == VK_ERROR_OUT_OF_DATE_KHR) {
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ private:
|
||||||
hid_buffer_entry *m_pFree;
|
hid_buffer_entry *m_pFree;
|
||||||
};
|
};
|
||||||
|
|
||||||
static jbyteArray NewByteArray( JNIEnv* env, const uint8_t *pData, size_t nDataLen )
|
static jbyteArray NewByteArray( JNIEnv *env, const uint8_t *pData, size_t nDataLen )
|
||||||
{
|
{
|
||||||
jbyteArray array = env->NewByteArray( (jsize)nDataLen );
|
jbyteArray array = env->NewByteArray( (jsize)nDataLen );
|
||||||
jbyte *pBuf = env->GetByteArrayElements( array, NULL );
|
jbyte *pBuf = env->GetByteArrayElements( array, NULL );
|
||||||
|
|
@ -333,7 +333,7 @@ static char *CreateStringFromJString( JNIEnv *env, const jstring &sString )
|
||||||
{
|
{
|
||||||
size_t nLength = env->GetStringUTFLength( sString );
|
size_t nLength = env->GetStringUTFLength( sString );
|
||||||
const char *pjChars = env->GetStringUTFChars( sString, NULL );
|
const char *pjChars = env->GetStringUTFChars( sString, NULL );
|
||||||
char *psString = (char*)malloc( nLength + 1 );
|
char *psString = (char *)malloc( nLength + 1 );
|
||||||
SDL_memcpy( psString, pjChars, nLength );
|
SDL_memcpy( psString, pjChars, nLength );
|
||||||
psString[ nLength ] = '\0';
|
psString[ nLength ] = '\0';
|
||||||
env->ReleaseStringUTFChars( sString, pjChars );
|
env->ReleaseStringUTFChars( sString, pjChars );
|
||||||
|
|
@ -344,7 +344,7 @@ static wchar_t *CreateWStringFromJString( JNIEnv *env, const jstring &sString )
|
||||||
{
|
{
|
||||||
size_t nLength = env->GetStringLength( sString );
|
size_t nLength = env->GetStringLength( sString );
|
||||||
const jchar *pjChars = env->GetStringChars( sString, NULL );
|
const jchar *pjChars = env->GetStringChars( sString, NULL );
|
||||||
wchar_t *pwString = (wchar_t*)malloc( ( nLength + 1 ) * sizeof( wchar_t ) );
|
wchar_t *pwString = (wchar_t *)malloc( ( nLength + 1 ) * sizeof( wchar_t ) );
|
||||||
wchar_t *pwChars = pwString;
|
wchar_t *pwChars = pwString;
|
||||||
for ( size_t iIndex = 0; iIndex < nLength; ++iIndex )
|
for ( size_t iIndex = 0; iIndex < nLength; ++iIndex )
|
||||||
{
|
{
|
||||||
|
|
@ -358,7 +358,7 @@ static wchar_t *CreateWStringFromJString( JNIEnv *env, const jstring &sString )
|
||||||
static wchar_t *CreateWStringFromWString( const wchar_t *pwSrc )
|
static wchar_t *CreateWStringFromWString( const wchar_t *pwSrc )
|
||||||
{
|
{
|
||||||
size_t nLength = SDL_wcslen( pwSrc );
|
size_t nLength = SDL_wcslen( pwSrc );
|
||||||
wchar_t *pwString = (wchar_t*)malloc( ( nLength + 1 ) * sizeof( wchar_t ) );
|
wchar_t *pwString = (wchar_t *)malloc( ( nLength + 1 ) * sizeof( wchar_t ) );
|
||||||
SDL_memcpy( pwString, pwSrc, nLength * sizeof( wchar_t ) );
|
SDL_memcpy( pwString, pwSrc, nLength * sizeof( wchar_t ) );
|
||||||
pwString[ nLength ] = '\0';
|
pwString[ nLength ] = '\0';
|
||||||
return pwString;
|
return pwString;
|
||||||
|
|
@ -997,7 +997,7 @@ JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceInputReport)(J
|
||||||
hid_device_ref<CHIDDevice> pDevice = FindDevice( nDeviceID );
|
hid_device_ref<CHIDDevice> pDevice = FindDevice( nDeviceID );
|
||||||
if ( pDevice )
|
if ( pDevice )
|
||||||
{
|
{
|
||||||
pDevice->ProcessInput( reinterpret_cast< const uint8_t* >( pBuf ), nBufSize );
|
pDevice->ProcessInput( reinterpret_cast< const uint8_t * >( pBuf ), nBufSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
env->ReleaseByteArrayElements(value, pBuf, 0);
|
env->ReleaseByteArrayElements(value, pBuf, 0);
|
||||||
|
|
@ -1013,7 +1013,7 @@ JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceReportResponse
|
||||||
hid_device_ref<CHIDDevice> pDevice = FindDevice( nDeviceID );
|
hid_device_ref<CHIDDevice> pDevice = FindDevice( nDeviceID );
|
||||||
if ( pDevice )
|
if ( pDevice )
|
||||||
{
|
{
|
||||||
pDevice->ProcessReportResponse( reinterpret_cast< const uint8_t* >( pBuf ), nBufSize );
|
pDevice->ProcessReportResponse( reinterpret_cast< const uint8_t * >( pBuf ), nBufSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
env->ReleaseByteArrayElements(value, pBuf, 0);
|
env->ReleaseByteArrayElements(value, pBuf, 0);
|
||||||
|
|
@ -1375,7 +1375,7 @@ int hid_get_report_descriptor(hid_device *device, unsigned char *buf, size_t buf
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device)
|
HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *device)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,11 @@ extern "C" {
|
||||||
#define DETACH_KERNEL_DRIVER
|
#define DETACH_KERNEL_DRIVER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:5287) /* operands are different enum types */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Uncomment to enable the retrieval of Usage and Usage Page in
|
/* Uncomment to enable the retrieval of Usage and Usage Page in
|
||||||
hid_enumerate(). Warning, on platforms different from FreeBSD
|
hid_enumerate(). Warning, on platforms different from FreeBSD
|
||||||
this is very invasive as it requires the detach
|
this is very invasive as it requires the detach
|
||||||
|
|
@ -2144,6 +2149,10 @@ uint16_t get_usb_code_for_current_locale(void)
|
||||||
return 0x0;
|
return 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning (pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ static void *ioring_handle = NULL;
|
||||||
SDL_IORING_FUNC(BOOL, IsIoRingOpSupported, (HIORING ioRing, IORING_OP_CODE op)) \
|
SDL_IORING_FUNC(BOOL, IsIoRingOpSupported, (HIORING ioRing, IORING_OP_CODE op)) \
|
||||||
SDL_IORING_FUNC(HRESULT, CreateIoRing, (IORING_VERSION ioringVersion, IORING_CREATE_FLAGS flags, UINT32 submissionQueueSize, UINT32 completionQueueSize, HIORING* h)) \
|
SDL_IORING_FUNC(HRESULT, CreateIoRing, (IORING_VERSION ioringVersion, IORING_CREATE_FLAGS flags, UINT32 submissionQueueSize, UINT32 completionQueueSize, HIORING* h)) \
|
||||||
SDL_IORING_FUNC(HRESULT, GetIoRingInfo, (HIORING ioRing, IORING_INFO* info)) \
|
SDL_IORING_FUNC(HRESULT, GetIoRingInfo, (HIORING ioRing, IORING_INFO* info)) \
|
||||||
SDL_IORING_FUNC(HRESULT, SubmitIoRing, (HIORING ioRing, UINT32 waitOperations, UINT32 milliseconds, UINT32* submittedEntries)) \
|
SDL_IORING_FUNC(HRESULT, SubmitIoRing, (HIORING ioRing, UINT32 waitOperations, UINT32 milliseconds, UINT32 * submittedEntries)) \
|
||||||
SDL_IORING_FUNC(HRESULT, CloseIoRing, (HIORING ioRing)) \
|
SDL_IORING_FUNC(HRESULT, CloseIoRing, (HIORING ioRing)) \
|
||||||
SDL_IORING_FUNC(HRESULT, PopIoRingCompletion, (HIORING ioRing, IORING_CQE* cqe)) \
|
SDL_IORING_FUNC(HRESULT, PopIoRingCompletion, (HIORING ioRing, IORING_CQE* cqe)) \
|
||||||
SDL_IORING_FUNC(HRESULT, SetIoRingCompletionEvent, (HIORING ioRing, HANDLE hEvent)) \
|
SDL_IORING_FUNC(HRESULT, SetIoRingCompletionEvent, (HIORING ioRing, HANDLE hEvent)) \
|
||||||
|
|
|
||||||
|
|
@ -841,6 +841,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
|
||||||
case 80:
|
case 80:
|
||||||
case 81:
|
case 81:
|
||||||
case 85:
|
case 85:
|
||||||
|
case 105:
|
||||||
// Vader series of controllers have C/Z buttons
|
// Vader series of controllers have C/Z buttons
|
||||||
SDL_strlcat(mapping_string, "misc2:b15,misc3:b16,", sizeof(mapping_string));
|
SDL_strlcat(mapping_string, "misc2:b15,misc3:b16,", sizeof(mapping_string));
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -209,8 +209,8 @@ static GAMEINPUT_InternalDevice *GAMEINPUT_InternalFindByIndex(int idx)
|
||||||
|
|
||||||
static void CALLBACK GAMEINPUT_InternalJoystickDeviceCallback(
|
static void CALLBACK GAMEINPUT_InternalJoystickDeviceCallback(
|
||||||
_In_ GameInputCallbackToken callbackToken,
|
_In_ GameInputCallbackToken callbackToken,
|
||||||
_In_ void* context,
|
_In_ void *context,
|
||||||
_In_ IGameInputDevice* device,
|
_In_ IGameInputDevice *device,
|
||||||
_In_ uint64_t timestamp,
|
_In_ uint64_t timestamp,
|
||||||
_In_ GameInputDeviceStatus currentStatus,
|
_In_ GameInputDeviceStatus currentStatus,
|
||||||
_In_ GameInputDeviceStatus previousStatus)
|
_In_ GameInputDeviceStatus previousStatus)
|
||||||
|
|
@ -697,7 +697,7 @@ static void GAMEINPUT_JoystickUpdate(SDL_Joystick *joystick)
|
||||||
GAMEINPUT_UpdatePowerInfo(joystick, device);
|
GAMEINPUT_UpdatePowerInfo(joystick, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GAMEINPUT_JoystickClose(SDL_Joystick* joystick)
|
static void GAMEINPUT_JoystickClose(SDL_Joystick *joystick)
|
||||||
{
|
{
|
||||||
GAMEINPUT_InternalJoystickHwdata *hwdata = joystick->hwdata;
|
GAMEINPUT_InternalJoystickHwdata *hwdata = joystick->hwdata;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ typedef struct
|
||||||
bool sensors_supported;
|
bool sensors_supported;
|
||||||
bool sensors_enabled;
|
bool sensors_enabled;
|
||||||
Uint16 firmware_version;
|
Uint16 firmware_version;
|
||||||
Uint64 sensor_timestamp_ns; // Simulate onboard clock. Advance by known time step. Nanoseconds.
|
Uint64 sensor_timestamp_ns; // Simulate onboard clock. Advance by known time step. Nanoseconds.
|
||||||
Uint64 sensor_timestamp_step_ns; // Based on observed rate of receipt of IMU sensor packets.
|
Uint64 sensor_timestamp_step_ns; // Based on observed rate of receipt of IMU sensor packets.
|
||||||
float accelScale;
|
float accelScale;
|
||||||
Uint8 last_state[USB_PACKET_LENGTH];
|
Uint8 last_state[USB_PACKET_LENGTH];
|
||||||
|
|
@ -95,19 +95,18 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
||||||
{
|
{
|
||||||
SDL_DriverFlydigi_Context *ctx = (SDL_DriverFlydigi_Context *)device->context;
|
SDL_DriverFlydigi_Context *ctx = (SDL_DriverFlydigi_Context *)device->context;
|
||||||
|
|
||||||
for (int attempt = 0; ctx->deviceID == 0 && attempt < 3; ++attempt) {
|
// Detecting the Vader 2 can take over 1000 read retries, so be generous here
|
||||||
|
for (int attempt = 0; ctx->deviceID == 0 && attempt < 30; ++attempt) {
|
||||||
const Uint8 request[] = { FLYDIGI_CMD_REPORT_ID, FLYDIGI_GET_INFO_COMMAND, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
const Uint8 request[] = { FLYDIGI_CMD_REPORT_ID, FLYDIGI_GET_INFO_COMMAND, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
int size = SDL_hid_write(device->dev, request, sizeof(request));
|
// This write will occasionally return -1, so ignore failure here and try again
|
||||||
if (size < 0) {
|
(void)SDL_hid_write(device->dev, request, sizeof(request));
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the reply
|
// Read the reply
|
||||||
for (int i = 0; i < 100; ++i) {
|
for (int i = 0; i < 100; ++i) {
|
||||||
SDL_Delay(1);
|
SDL_Delay(1);
|
||||||
|
|
||||||
Uint8 data[USB_PACKET_LENGTH];
|
Uint8 data[USB_PACKET_LENGTH];
|
||||||
size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0);
|
int size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 0);
|
||||||
if (size < 0) {
|
if (size < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -211,6 +210,7 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
||||||
ctx->sensor_timestamp_step_ns = ctx->wireless ? SENSOR_INTERVAL_VADER4_PRO_DONGLE_NS : SENSOR_INTERVAL_VADER_PRO4_WIRED_NS;
|
ctx->sensor_timestamp_step_ns = ctx->wireless ? SENSOR_INTERVAL_VADER4_PRO_DONGLE_NS : SENSOR_INTERVAL_VADER_PRO4_WIRED_NS;
|
||||||
break;
|
break;
|
||||||
case 85:
|
case 85:
|
||||||
|
case 105:
|
||||||
HIDAPI_SetDeviceName(device, "Flydigi Vader 4 Pro");
|
HIDAPI_SetDeviceName(device, "Flydigi Vader 4 Pro");
|
||||||
ctx->has_cz = true;
|
ctx->has_cz = true;
|
||||||
ctx->sensors_supported = true;
|
ctx->sensors_supported = true;
|
||||||
|
|
@ -218,6 +218,7 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
||||||
ctx->sensor_timestamp_step_ns = ctx->wireless ? SENSOR_INTERVAL_VADER4_PRO_DONGLE_NS : SENSOR_INTERVAL_VADER_PRO4_WIRED_NS;
|
ctx->sensor_timestamp_step_ns = ctx->wireless ? SENSOR_INTERVAL_VADER4_PRO_DONGLE_NS : SENSOR_INTERVAL_VADER_PRO4_WIRED_NS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "Unknown FlyDigi controller with ID %d, name '%s'", ctx->deviceID, device->name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -901,7 +901,7 @@ static bool GIP_ParseDeviceMetadata(GIP_Metadata *metadata, const Uint8 *bytes,
|
||||||
}
|
}
|
||||||
if (buffer_offset > 0) {
|
if (buffer_offset > 0) {
|
||||||
device->num_preferred_types = bytes[buffer_offset];
|
device->num_preferred_types = bytes[buffer_offset];
|
||||||
device->preferred_types = SDL_calloc(device->num_preferred_types, sizeof(char*));
|
device->preferred_types = SDL_calloc(device->num_preferred_types, sizeof(char *));
|
||||||
buffer_offset++;
|
buffer_offset++;
|
||||||
for (i = 0; i < device->num_preferred_types; i++) {
|
for (i = 0; i < device->num_preferred_types; i++) {
|
||||||
if (buffer_offset + 2 >= length) {
|
if (buffer_offset + 2 >= length) {
|
||||||
|
|
@ -1013,7 +1013,7 @@ static bool GIP_ParseMessageMetadata(GIP_MessageMetadata *metadata, const Uint8
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool GIP_ParseMetadata(GIP_Metadata *metadata, const Uint8* bytes, int num_bytes)
|
static bool GIP_ParseMetadata(GIP_Metadata *metadata, const Uint8 *bytes, int num_bytes)
|
||||||
{
|
{
|
||||||
int header_size;
|
int header_size;
|
||||||
int metadata_size;
|
int metadata_size;
|
||||||
|
|
@ -2427,7 +2427,7 @@ static void GIP_ReceivePacket(GIP_Device *device, const Uint8 *bytes, int num_by
|
||||||
Uint16 bytes_remaining = 0;
|
Uint16 bytes_remaining = 0;
|
||||||
bool is_fragment;
|
bool is_fragment;
|
||||||
Uint8 attachment_index;
|
Uint8 attachment_index;
|
||||||
GIP_Attachment* attachment;
|
GIP_Attachment *attachment;
|
||||||
|
|
||||||
if (num_bytes < 5) {
|
if (num_bytes < 5) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -979,7 +979,7 @@ static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
||||||
/* Stick calibration values are 12-bits each and are packed by bit
|
/* Stick calibration values are 12-bits each and are packed by bit
|
||||||
* For whatever reason the fields are in a different order for each stick
|
* For whatever reason the fields are in a different order for each stick
|
||||||
* Left: X-Max, Y-Max, X-Center, Y-Center, X-Min, Y-Min
|
* Left: X-Max, Y-Max, X-Center, Y-Center, X-Min, Y-Min
|
||||||
* Right: X-Center, Y-Center, X-Min, Y-Min, X-Max, Y-Max
|
* Right: X-Center, Y-Center, X-Max, Y-Max, X-Min, Y-Min
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Left stick
|
// Left stick
|
||||||
|
|
@ -993,10 +993,10 @@ static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
||||||
// Right stick
|
// Right stick
|
||||||
ctx->m_StickCalData[1].axis[0].sCenter = ((pRightStickCal[1] << 8) & 0xF00) | pRightStickCal[0]; // X Axis center
|
ctx->m_StickCalData[1].axis[0].sCenter = ((pRightStickCal[1] << 8) & 0xF00) | pRightStickCal[0]; // X Axis center
|
||||||
ctx->m_StickCalData[1].axis[1].sCenter = (pRightStickCal[2] << 4) | (pRightStickCal[1] >> 4); // Y Axis center
|
ctx->m_StickCalData[1].axis[1].sCenter = (pRightStickCal[2] << 4) | (pRightStickCal[1] >> 4); // Y Axis center
|
||||||
ctx->m_StickCalData[1].axis[0].sMin = ((pRightStickCal[4] << 8) & 0xF00) | pRightStickCal[3]; // X Axis min below center
|
ctx->m_StickCalData[1].axis[0].sMax = ((pRightStickCal[4] << 8) & 0xF00) | pRightStickCal[3]; // X Axis max above center
|
||||||
ctx->m_StickCalData[1].axis[1].sMin = (pRightStickCal[5] << 4) | (pRightStickCal[4] >> 4); // Y Axis min below center
|
ctx->m_StickCalData[1].axis[1].sMax = (pRightStickCal[5] << 4) | (pRightStickCal[4] >> 4); // Y Axis max above center
|
||||||
ctx->m_StickCalData[1].axis[0].sMax = ((pRightStickCal[7] << 8) & 0xF00) | pRightStickCal[6]; // X Axis max above center
|
ctx->m_StickCalData[1].axis[0].sMin = ((pRightStickCal[7] << 8) & 0xF00) | pRightStickCal[6]; // X Axis min below center
|
||||||
ctx->m_StickCalData[1].axis[1].sMax = (pRightStickCal[8] << 4) | (pRightStickCal[7] >> 4); // Y Axis max above center
|
ctx->m_StickCalData[1].axis[1].sMin = (pRightStickCal[8] << 4) | (pRightStickCal[7] >> 4); // Y Axis min below center
|
||||||
|
|
||||||
// Filter out any values that were uninitialized (0xFFF) in the SPI read
|
// Filter out any values that were uninitialized (0xFFF) in the SPI read
|
||||||
for (stick = 0; stick < 2; ++stick) {
|
for (stick = 0; stick < 2; ++stick) {
|
||||||
|
|
@ -1109,14 +1109,17 @@ static Sint16 ApplyStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, i
|
||||||
{
|
{
|
||||||
sRawValue -= ctx->m_StickCalData[nStick].axis[nAxis].sCenter;
|
sRawValue -= ctx->m_StickCalData[nStick].axis[nAxis].sCenter;
|
||||||
|
|
||||||
if (sRawValue > ctx->m_StickExtents[nStick].axis[nAxis].sMax) {
|
if (sRawValue >= 0) {
|
||||||
ctx->m_StickExtents[nStick].axis[nAxis].sMax = sRawValue;
|
if (sRawValue > ctx->m_StickExtents[nStick].axis[nAxis].sMax) {
|
||||||
|
ctx->m_StickExtents[nStick].axis[nAxis].sMax = sRawValue;
|
||||||
|
}
|
||||||
|
return (Sint16)HIDAPI_RemapVal(sRawValue, 0, ctx->m_StickExtents[nStick].axis[nAxis].sMax, 0, SDL_MAX_SINT16);
|
||||||
|
} else {
|
||||||
|
if (sRawValue < ctx->m_StickExtents[nStick].axis[nAxis].sMin) {
|
||||||
|
ctx->m_StickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
||||||
|
}
|
||||||
|
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, 0, SDL_MIN_SINT16, 0);
|
||||||
}
|
}
|
||||||
if (sRawValue < ctx->m_StickExtents[nStick].axis[nAxis].sMin) {
|
|
||||||
ctx->m_StickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, ctx->m_StickExtents[nStick].axis[nAxis].sMax, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue)
|
static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue)
|
||||||
|
|
@ -1126,14 +1129,17 @@ static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nSt
|
||||||
|
|
||||||
sRawValue -= usJoystickCenter;
|
sRawValue -= usJoystickCenter;
|
||||||
|
|
||||||
if (sRawValue > ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax) {
|
if (sRawValue >= 0) {
|
||||||
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax = sRawValue;
|
if (sRawValue > ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax) {
|
||||||
|
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax = sRawValue;
|
||||||
|
}
|
||||||
|
return (Sint16)HIDAPI_RemapVal(sRawValue, 0, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax, 0, SDL_MAX_SINT16);
|
||||||
|
} else {
|
||||||
|
if (sRawValue < ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin) {
|
||||||
|
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
||||||
|
}
|
||||||
|
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin, 0, SDL_MIN_SINT16, 0);
|
||||||
}
|
}
|
||||||
if (sRawValue < ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin) {
|
|
||||||
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint8 RemapButton(SDL_DriverSwitch_Context *ctx, Uint8 button)
|
static Uint8 RemapButton(SDL_DriverSwitch_Context *ctx, Uint8 button)
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ bool SDL_HasMainCallbacks(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AppResult SDL_InitMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
SDL_AppResult SDL_InitMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
||||||
{
|
{
|
||||||
SDL_main_iteration_callback = appiter;
|
SDL_main_iteration_callback = appiter;
|
||||||
SDL_main_event_callback = appevent;
|
SDL_main_event_callback = appevent;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
* If not, you can special case it here by appending || defined(__YOUR_PLATFORM__) */
|
* If not, you can special case it here by appending || defined(__YOUR_PLATFORM__) */
|
||||||
#if ( !defined(SDL_MAIN_NEEDED) && !defined(SDL_MAIN_AVAILABLE) ) || defined(SDL_PLATFORM_ANDROID)
|
#if ( !defined(SDL_MAIN_NEEDED) && !defined(SDL_MAIN_AVAILABLE) ) || defined(SDL_PLATFORM_ANDROID)
|
||||||
|
|
||||||
int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved)
|
int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserved)
|
||||||
{
|
{
|
||||||
(void)reserved;
|
(void)reserved;
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserv
|
||||||
{
|
{
|
||||||
// make sure argv isn't NULL, in case some user code doesn't like that
|
// make sure argv isn't NULL, in case some user code doesn't like that
|
||||||
static char dummyargv0[] = { 'S', 'D', 'L', '_', 'a', 'p', 'p', '\0' };
|
static char dummyargv0[] = { 'S', 'D', 'L', '_', 'a', 'p', 'p', '\0' };
|
||||||
static char* argvdummy[2] = { dummyargv0, NULL };
|
static char *argvdummy[2] = { dummyargv0, NULL };
|
||||||
argc = 1;
|
argc = 1;
|
||||||
argv = argvdummy;
|
argv = argvdummy;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ static void EmscriptenInternalMainloop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
int SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
||||||
{
|
{
|
||||||
const SDL_AppResult rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
const SDL_AppResult rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
||||||
if (rc == SDL_APP_CONTINUE) {
|
if (rc == SDL_APP_CONTINUE) {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
EM_JS_DEPS(sdlrunapp, "$dynCall,$stringToNewUTF8");
|
EM_JS_DEPS(sdlrunapp, "$dynCall,$stringToNewUTF8");
|
||||||
|
|
||||||
int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved)
|
int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserved)
|
||||||
{
|
{
|
||||||
(void)reserved;
|
(void)reserved;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ static BOOL OutOfMemory(void)
|
||||||
/* Gets the arguments with GetCommandLine, converts them to argc and argv
|
/* Gets the arguments with GetCommandLine, converts them to argc and argv
|
||||||
and calls SDL_main */
|
and calls SDL_main */
|
||||||
extern "C"
|
extern "C"
|
||||||
int SDL_RunApp(int, char**, SDL_main_func mainFunction, void *reserved)
|
int SDL_RunApp(int, char **, SDL_main_func mainFunction, void *reserved)
|
||||||
{
|
{
|
||||||
LPWSTR *argvw;
|
LPWSTR *argvw;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ static SDL_AppResult GenericIterateMainCallbacks(void)
|
||||||
return SDL_IterateMainCallbacks(!iterate_after_waitevent);
|
return SDL_IterateMainCallbacks(!iterate_after_waitevent);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
int SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
||||||
{
|
{
|
||||||
SDL_AppResult rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
SDL_AppResult rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ static SDLIosMainCallbacksDisplayLink *globalDisplayLink;
|
||||||
|
|
||||||
// SDL_RunApp will land in UIApplicationMain, which calls SDL_main from postFinishLaunch, which calls this.
|
// SDL_RunApp will land in UIApplicationMain, which calls SDL_main from postFinishLaunch, which calls this.
|
||||||
// When we return from here, we're living in the RunLoop, and a CADisplayLink is firing regularly for us.
|
// When we return from here, we're living in the RunLoop, and a CADisplayLink is firing regularly for us.
|
||||||
int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
int SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
||||||
{
|
{
|
||||||
SDL_AppResult rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
SDL_AppResult rc = SDL_InitMainCallbacks(argc, argv, appinit, appiter, appevent, appquit);
|
||||||
if (rc == SDL_APP_CONTINUE) {
|
if (rc == SDL_APP_CONTINUE) {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved)
|
int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserved)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
// init
|
// init
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#ifdef SDL_PLATFORM_NGAGE
|
#ifdef SDL_PLATFORM_NGAGE
|
||||||
|
|
||||||
int SDL_EnterAppMainCallbacks(int argc, char* argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
int SDL_EnterAppMainCallbacks(int argc, char *argv[], SDL_AppInit_func appinit, SDL_AppIterate_func appiter, SDL_AppEvent_func appevent, SDL_AppQuit_func appquit)
|
||||||
{
|
{
|
||||||
// Intentionally does nothing; Callbacks are called using the RunL() method.
|
// Intentionally does nothing; Callbacks are called using the RunL() method.
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ extern "C" {
|
||||||
|
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
extern SDL_AppResult SDL_AppInit(void** appstate, int argc, char* argv[]);
|
extern SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]);
|
||||||
extern SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event);
|
extern SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event);
|
||||||
extern SDL_AppResult SDL_AppIterate(void* appstate);
|
extern SDL_AppResult SDL_AppIterate(void *appstate);
|
||||||
extern void SDL_AppQuit(void* appstate, SDL_AppResult result);
|
extern void SDL_AppQuit(void *appstate, SDL_AppResult result);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
@ -48,14 +48,14 @@ GLDEF_C TInt E32Main()
|
||||||
{
|
{
|
||||||
// Get args and environment.
|
// Get args and environment.
|
||||||
int argc = 1;
|
int argc = 1;
|
||||||
char* argv[] = { "game", NULL };
|
char *argv[] = { "game", NULL };
|
||||||
char** envp = NULL;
|
char **envp = NULL;
|
||||||
|
|
||||||
// Create lvalue variables for __crt0 arguments.
|
// Create lvalue variables for __crt0 arguments.
|
||||||
char** argv_lvalue = argv;
|
char **argv_lvalue = argv;
|
||||||
char** envp_lvalue = envp;
|
char **envp_lvalue = envp;
|
||||||
|
|
||||||
CTrapCleanup* cleanup = CTrapCleanup::New();
|
CTrapCleanup *cleanup = CTrapCleanup::New();
|
||||||
if (!cleanup)
|
if (!cleanup)
|
||||||
{
|
{
|
||||||
return KErrNoMemory;
|
return KErrNoMemory;
|
||||||
|
|
@ -63,7 +63,7 @@ GLDEF_C TInt E32Main()
|
||||||
|
|
||||||
TRAPD(err,
|
TRAPD(err,
|
||||||
{
|
{
|
||||||
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
|
CActiveScheduler *scheduler = new (ELeave) CActiveScheduler();
|
||||||
CleanupStack::PushL(scheduler);
|
CleanupStack::PushL(scheduler);
|
||||||
CActiveScheduler::Install(scheduler);
|
CActiveScheduler::Install(scheduler);
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ GLDEF_C TInt E32Main()
|
||||||
__crt0(argc, argv_lvalue, envp_lvalue);
|
__crt0(argc, argv_lvalue, envp_lvalue);
|
||||||
|
|
||||||
// Increase heap size.
|
// Increase heap size.
|
||||||
RHeap* newHeap = User::ChunkHeap(NULL, 7500000, 7500000, KMinHeapGrowBy);
|
RHeap *newHeap = User::ChunkHeap(NULL, 7500000, 7500000, KMinHeapGrowBy);
|
||||||
if (!newHeap)
|
if (!newHeap)
|
||||||
{
|
{
|
||||||
SDL_Log("Error: Failed to create new heap");
|
SDL_Log("Error: Failed to create new heap");
|
||||||
|
|
@ -85,7 +85,7 @@ GLDEF_C TInt E32Main()
|
||||||
}
|
}
|
||||||
CleanupStack::PushL(newHeap);
|
CleanupStack::PushL(newHeap);
|
||||||
|
|
||||||
RHeap* oldHeap = User::SwitchHeap(newHeap);
|
RHeap *oldHeap = User::SwitchHeap(newHeap);
|
||||||
|
|
||||||
TInt targetLatency = 225;
|
TInt targetLatency = 225;
|
||||||
InitAudio(&targetLatency);
|
InitAudio(&targetLatency);
|
||||||
|
|
@ -101,7 +101,7 @@ GLDEF_C TInt E32Main()
|
||||||
CleanupStack::PushL(gRenderer);
|
CleanupStack::PushL(gRenderer);
|
||||||
|
|
||||||
// Create and start the SDL main runner.
|
// Create and start the SDL main runner.
|
||||||
CSDLmain* mainApp = CSDLmain::NewL();
|
CSDLmain *mainApp = CSDLmain::NewL();
|
||||||
CleanupStack::PushL(mainApp);
|
CleanupStack::PushL(mainApp);
|
||||||
mainApp->Start();
|
mainApp->Start();
|
||||||
|
|
||||||
|
|
@ -125,9 +125,9 @@ GLDEF_C TInt E32Main()
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSDLmain* CSDLmain::NewL()
|
CSDLmain *CSDLmain::NewL()
|
||||||
{
|
{
|
||||||
CSDLmain* self = new (ELeave) CSDLmain();
|
CSDLmain *self = new (ELeave) CSDLmain();
|
||||||
CleanupStack::PushL(self);
|
CleanupStack::PushL(self);
|
||||||
self->ConstructL();
|
self->ConstructL();
|
||||||
CleanupStack::Pop(self);
|
CleanupStack::Pop(self);
|
||||||
|
|
@ -149,7 +149,7 @@ CSDLmain::~CSDLmain()
|
||||||
void CSDLmain::Start()
|
void CSDLmain::Start()
|
||||||
{
|
{
|
||||||
SetActive();
|
SetActive();
|
||||||
TRequestStatus* status = &iStatus;
|
TRequestStatus *status = &iStatus;
|
||||||
User::RequestComplete(status, KErrNone);
|
User::RequestComplete(status, KErrNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
class CSDLmain : public CActive
|
class CSDLmain : public CActive
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CSDLmain* NewL();
|
static CSDLmain *NewL();
|
||||||
~CSDLmain();
|
~CSDLmain();
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ static void deinit_drivers(void)
|
||||||
deinit_ps2_filesystem_driver();
|
deinit_ps2_filesystem_driver();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved)
|
int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserved)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
(void)reserved;
|
(void)reserved;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ int sdl_psp_setup_callbacks(void)
|
||||||
return thid;
|
return thid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved)
|
int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserved)
|
||||||
{
|
{
|
||||||
(void)reserved;
|
(void)reserved;
|
||||||
sdl_psp_setup_callbacks();
|
sdl_psp_setup_callbacks();
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ static int OutOfMemory(void)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char* _argv[], SDL_main_func mainFunction, void * reserved)
|
int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char *_argv[], SDL_main_func mainFunction, void * reserved)
|
||||||
{
|
{
|
||||||
/* Gets the arguments with GetCommandLine, converts them to argc and argv
|
/* Gets the arguments with GetCommandLine, converts them to argc and argv
|
||||||
and calls SDL_main */
|
and calls SDL_main */
|
||||||
|
|
|
||||||
|
|
@ -1512,7 +1512,7 @@ static void D3D12_FreeSRVIndex(SDL_Renderer *renderer, SIZE_T index)
|
||||||
|
|
||||||
static bool GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D12Resource **texture)
|
static bool GetTextureProperty(SDL_PropertiesID props, const char *name, ID3D12Resource **texture)
|
||||||
{
|
{
|
||||||
IUnknown *unknown = (IUnknown*)SDL_GetPointerProperty(props, name, NULL);
|
IUnknown *unknown = (IUnknown *)SDL_GetPointerProperty(props, name, NULL);
|
||||||
if (unknown) {
|
if (unknown) {
|
||||||
#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
|
||||||
HRESULT result = unknown->QueryInterface(D3D_GUID(SDL_IID_ID3D12Resource), (void **)texture);
|
HRESULT result = unknown->QueryInterface(D3D_GUID(SDL_IID_ID3D12Resource), (void **)texture);
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@ void ApplyColorMod(void *dest, void *source, int pitch, int width, int height, S
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyFlip(void* dest, void* source, int pitch, int width, int height, SDL_FlipMode flip)
|
void ApplyFlip(void *dest, void *source, int pitch, int width, int height, SDL_FlipMode flip)
|
||||||
{
|
{
|
||||||
TUint16* src_pixels = static_cast<TUint16*>(source);
|
TUint16 *src_pixels = static_cast<TUint16 *>(source);
|
||||||
TUint16* dst_pixels = static_cast<TUint16*>(dest);
|
TUint16 *dst_pixels = static_cast<TUint16 *>(dest);
|
||||||
|
|
||||||
for (int y = 0; y < height; ++y)
|
for (int y = 0; y < height; ++y)
|
||||||
{
|
{
|
||||||
|
|
@ -75,10 +75,10 @@ void ApplyFlip(void* dest, void* source, int pitch, int width, int height, SDL_F
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyRotation(void* dest, void* source, int pitch, int width, int height, TFixed center_x, TFixed center_y, TFixed angle)
|
void ApplyRotation(void *dest, void *source, int pitch, int width, int height, TFixed center_x, TFixed center_y, TFixed angle)
|
||||||
{
|
{
|
||||||
TUint16* src_pixels = static_cast<TUint16*>(source);
|
TUint16 *src_pixels = static_cast<TUint16 *>(source);
|
||||||
TUint16* dst_pixels = static_cast<TUint16*>(dest);
|
TUint16 *dst_pixels = static_cast<TUint16 *>(dest);
|
||||||
|
|
||||||
TFixed cos_angle = 0;
|
TFixed cos_angle = 0;
|
||||||
TFixed sin_angle = 0;
|
TFixed sin_angle = 0;
|
||||||
|
|
@ -117,10 +117,10 @@ void ApplyRotation(void* dest, void* source, int pitch, int width, int height, T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyScale(void* dest, void* source, int pitch, int width, int height, TFixed center_x, TFixed center_y, TFixed scale_x, TFixed scale_y)
|
void ApplyScale(void *dest, void *source, int pitch, int width, int height, TFixed center_x, TFixed center_y, TFixed scale_x, TFixed scale_y)
|
||||||
{
|
{
|
||||||
TUint16* src_pixels = static_cast<TUint16*>(source);
|
TUint16 *src_pixels = static_cast<TUint16 *>(source);
|
||||||
TUint16* dst_pixels = static_cast<TUint16*>(dest);
|
TUint16 *dst_pixels = static_cast<TUint16 *>(dest);
|
||||||
|
|
||||||
for (int y = 0; y < height; ++y)
|
for (int y = 0; y < height; ++y)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@
|
||||||
|
|
||||||
#include <3dtypes.h>
|
#include <3dtypes.h>
|
||||||
|
|
||||||
void ApplyColorMod(void* dest, void* source, int pitch, int width, int height, SDL_FColor color);
|
void ApplyColorMod(void *dest, void *source, int pitch, int width, int height, SDL_FColor color);
|
||||||
void ApplyFlip(void* dest, void* source, int pitch, int width, int height, SDL_FlipMode flip);
|
void ApplyFlip(void *dest, void *source, int pitch, int width, int height, SDL_FlipMode flip);
|
||||||
void ApplyRotation(void* dest, void* source, int pitch, int width, int height, TFixed center_x, TFixed center_y, TFixed angle);
|
void ApplyRotation(void *dest, void *source, int pitch, int width, int height, TFixed center_x, TFixed center_y, TFixed angle);
|
||||||
void ApplyScale(void* dest, void* source, int pitch, int width, int height, TFixed center_x, TFixed center_y, TFixed scale_x, TFixed scale_y);
|
void ApplyScale(void *dest, void *source, int pitch, int width, int height, TFixed center_x, TFixed center_y, TFixed scale_x, TFixed scale_y);
|
||||||
|
|
||||||
#endif // ngage_video_render_ops_hpp
|
#endif // ngage_video_render_ops_hpp
|
||||||
|
|
|
||||||
|
|
@ -820,6 +820,35 @@ static SceGxmTextureAddrMode TranslateAddressMode(SDL_TextureAddressMode mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ClampCliprectToViewport(SDL_Rect *clip, const SDL_Rect *viewport)
|
||||||
|
{
|
||||||
|
int max_x_v, max_y_v, max_x_c, max_y_c;
|
||||||
|
|
||||||
|
if (clip->x < 0) {
|
||||||
|
clip->w += clip->x;
|
||||||
|
clip->x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clip->y < 0) {
|
||||||
|
clip->h += clip->y;
|
||||||
|
clip->y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
max_x_c = clip->x + clip->w;
|
||||||
|
max_y_c = clip->y + clip->h;
|
||||||
|
|
||||||
|
max_x_v = viewport->x + viewport->w;
|
||||||
|
max_y_v = viewport->y + viewport->h;
|
||||||
|
|
||||||
|
if (max_x_c > max_x_v) {
|
||||||
|
clip->w -= (max_x_v - max_x_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (max_y_c > max_y_v) {
|
||||||
|
clip->h -= (max_y_v - max_y_c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
static bool SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
||||||
{
|
{
|
||||||
SDL_Texture *texture = cmd->data.draw.texture;
|
SDL_Texture *texture = cmd->data.draw.texture;
|
||||||
|
|
@ -862,9 +891,13 @@ static bool SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd
|
||||||
data->drawstate.cliprect_enabled_dirty = false;
|
data->drawstate.cliprect_enabled_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->drawstate.cliprect_enabled && data->drawstate.cliprect_dirty) {
|
if ((data->drawstate.cliprect_enabled || data->drawstate.viewport_is_set) && data->drawstate.cliprect_dirty) {
|
||||||
const SDL_Rect *rect = &data->drawstate.cliprect;
|
SDL_Rect rect;
|
||||||
set_clip_rectangle(data, rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
|
SDL_copyp(&rect, &data->drawstate.cliprect);
|
||||||
|
if (data->drawstate.viewport_is_set) {
|
||||||
|
ClampCliprectToViewport(&rect, &data->drawstate.viewport);
|
||||||
|
}
|
||||||
|
set_clip_rectangle(data, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h);
|
||||||
data->drawstate.cliprect_dirty = false;
|
data->drawstate.cliprect_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -952,20 +985,31 @@ static void VITA_GXM_InvalidateCachedState(SDL_Renderer *renderer)
|
||||||
static bool VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
static bool VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||||
{
|
{
|
||||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->internal;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
StartDrawing(renderer);
|
StartDrawing(renderer);
|
||||||
|
|
||||||
data->drawstate.target = renderer->target;
|
data->drawstate.target = renderer->target;
|
||||||
if (!data->drawstate.target) {
|
if (!data->drawstate.target) {
|
||||||
int w, h;
|
|
||||||
SDL_GetWindowSizeInPixels(renderer->window, &w, &h);
|
SDL_GetWindowSizeInPixels(renderer->window, &w, &h);
|
||||||
if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) {
|
} else {
|
||||||
data->drawstate.viewport_dirty = true; // if the window dimensions changed, invalidate the current viewport, etc.
|
float fw, fh;
|
||||||
data->drawstate.cliprect_dirty = true;
|
if (!SDL_GetTextureSize(renderer->target, &fw, &fh)) {
|
||||||
data->drawstate.drawablew = w;
|
w = data->drawstate.drawablew;
|
||||||
data->drawstate.drawableh = h;
|
h = data->drawstate.drawableh;
|
||||||
|
} else {
|
||||||
|
w = (int)SDL_roundf(fw);
|
||||||
|
h = (int)SDL_roundf(fh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) {
|
||||||
|
data->drawstate.viewport_dirty = true; // if the window dimensions changed, invalidate the current viewport, etc.
|
||||||
|
data->drawstate.cliprect_dirty = true;
|
||||||
|
data->drawstate.drawablew = w;
|
||||||
|
data->drawstate.drawableh = h;
|
||||||
|
}
|
||||||
|
|
||||||
while (cmd) {
|
while (cmd) {
|
||||||
switch (cmd->command) {
|
switch (cmd->command) {
|
||||||
|
|
||||||
|
|
@ -976,6 +1020,16 @@ static bool VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *
|
||||||
SDL_copyp(viewport, &cmd->data.viewport.rect);
|
SDL_copyp(viewport, &cmd->data.viewport.rect);
|
||||||
data->drawstate.viewport_dirty = true;
|
data->drawstate.viewport_dirty = true;
|
||||||
data->drawstate.cliprect_dirty = true;
|
data->drawstate.cliprect_dirty = true;
|
||||||
|
data->drawstate.viewport_is_set = viewport->x != 0 || viewport->y != 0 || viewport->w != data->drawstate.drawablew || viewport->h != data->drawstate.drawableh;
|
||||||
|
if (!data->drawstate.cliprect_enabled) {
|
||||||
|
if (data->drawstate.viewport_is_set) {
|
||||||
|
SDL_copyp(&data->drawstate.cliprect, viewport);
|
||||||
|
data->drawstate.cliprect.x = 0;
|
||||||
|
data->drawstate.cliprect.y = 0;
|
||||||
|
} else {
|
||||||
|
data->drawstate.cliprect_enabled_dirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -983,9 +1037,15 @@ static bool VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *
|
||||||
case SDL_RENDERCMD_SETCLIPRECT:
|
case SDL_RENDERCMD_SETCLIPRECT:
|
||||||
{
|
{
|
||||||
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
||||||
|
const SDL_Rect *viewport = &data->drawstate.viewport;
|
||||||
if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) {
|
if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) {
|
||||||
data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled;
|
data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled;
|
||||||
data->drawstate.cliprect_enabled_dirty = true;
|
data->drawstate.cliprect_enabled_dirty = true;
|
||||||
|
if (!data->drawstate.cliprect_enabled && data->drawstate.viewport_is_set) {
|
||||||
|
SDL_copyp(&data->drawstate.cliprect, viewport);
|
||||||
|
data->drawstate.cliprect.x = 0;
|
||||||
|
data->drawstate.cliprect.y = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) {
|
if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) {
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
SDL_Rect viewport;
|
SDL_Rect viewport;
|
||||||
bool viewport_dirty;
|
bool viewport_dirty;
|
||||||
|
bool viewport_is_set;
|
||||||
SDL_Texture *texture;
|
SDL_Texture *texture;
|
||||||
SDL_Texture *target;
|
SDL_Texture *target;
|
||||||
SDL_FColor color;
|
SDL_FColor color;
|
||||||
|
|
|
||||||
|
|
@ -1607,7 +1607,7 @@ static VkSemaphore VULKAN_CreateSemaphore(VULKAN_RenderData *rendererData)
|
||||||
return semaphore;
|
return semaphore;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool VULKAN_DeviceExtensionsFound(VULKAN_RenderData *rendererData, int extensionsToCheck, const char* const* extNames)
|
static bool VULKAN_DeviceExtensionsFound(VULKAN_RenderData *rendererData, int extensionsToCheck, const char * const *extNames)
|
||||||
{
|
{
|
||||||
uint32_t extensionCount;
|
uint32_t extensionCount;
|
||||||
bool foundExtensions = true;
|
bool foundExtensions = true;
|
||||||
|
|
@ -2364,7 +2364,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create descriptor pools - start by allocating one per swapchain image, let it grow if more are needed
|
// Create descriptor pools - start by allocating one per swapchain image, let it grow if more are needed
|
||||||
rendererData->descriptorPools = (VkDescriptorPool **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkDescriptorPool*));
|
rendererData->descriptorPools = (VkDescriptorPool **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VkDescriptorPool *));
|
||||||
rendererData->numDescriptorPools = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t));
|
rendererData->numDescriptorPools = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t));
|
||||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
||||||
// Start by just allocating one pool, it will grow if needed
|
// Start by just allocating one pool, it will grow if needed
|
||||||
|
|
@ -2394,7 +2394,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload buffers
|
// Upload buffers
|
||||||
rendererData->uploadBuffers = (VULKAN_Buffer **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer*));
|
rendererData->uploadBuffers = (VULKAN_Buffer **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer *));
|
||||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
||||||
rendererData->uploadBuffers[i] = (VULKAN_Buffer *)SDL_calloc(SDL_VULKAN_NUM_UPLOAD_BUFFERS, sizeof(VULKAN_Buffer));
|
rendererData->uploadBuffers[i] = (VULKAN_Buffer *)SDL_calloc(SDL_VULKAN_NUM_UPLOAD_BUFFERS, sizeof(VULKAN_Buffer));
|
||||||
}
|
}
|
||||||
|
|
@ -2402,7 +2402,7 @@ static VkResult VULKAN_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||||
rendererData->currentUploadBuffer = (int *)SDL_calloc(rendererData->swapchainImageCount, sizeof(int));
|
rendererData->currentUploadBuffer = (int *)SDL_calloc(rendererData->swapchainImageCount, sizeof(int));
|
||||||
|
|
||||||
// Constant buffers
|
// Constant buffers
|
||||||
rendererData->constantBuffers = (VULKAN_Buffer **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer*));
|
rendererData->constantBuffers = (VULKAN_Buffer **)SDL_calloc(rendererData->swapchainImageCount, sizeof(VULKAN_Buffer *));
|
||||||
rendererData->numConstantBuffers = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t));
|
rendererData->numConstantBuffers = (uint32_t *)SDL_calloc(rendererData->swapchainImageCount, sizeof(uint32_t));
|
||||||
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
for (uint32_t i = 0; i < rendererData->swapchainImageCount; i++) {
|
||||||
// Start with just allocating one, will grow if needed
|
// Start with just allocating one, will grow if needed
|
||||||
|
|
@ -3939,7 +3939,7 @@ static bool VULKAN_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cm
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_Surface* VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
|
static SDL_Surface *VULKAN_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
|
||||||
{
|
{
|
||||||
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
VULKAN_RenderData *rendererData = (VULKAN_RenderData *)renderer->internal;
|
||||||
VkImage backBuffer;
|
VkImage backBuffer;
|
||||||
|
|
|
||||||
|
|
@ -535,8 +535,8 @@ void *SDL_aligned_alloc(size_t alignment, size_t size)
|
||||||
Uint8 *result = NULL;
|
Uint8 *result = NULL;
|
||||||
size_t requested_size = size;
|
size_t requested_size = size;
|
||||||
|
|
||||||
if (alignment < sizeof(void*)) {
|
if (alignment < sizeof(void *)) {
|
||||||
alignment = sizeof(void*);
|
alignment = sizeof(void *);
|
||||||
}
|
}
|
||||||
padding = (alignment - (size % alignment));
|
padding = (alignment - (size % alignment));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,14 @@ typedef struct TitleStorageBootStrap
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *desc;
|
const char *desc;
|
||||||
SDL_Storage *(*create)(const char*, SDL_PropertiesID);
|
SDL_Storage *(*create)(const char *, SDL_PropertiesID);
|
||||||
} TitleStorageBootStrap;
|
} TitleStorageBootStrap;
|
||||||
|
|
||||||
typedef struct UserStorageBootStrap
|
typedef struct UserStorageBootStrap
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *desc;
|
const char *desc;
|
||||||
SDL_Storage *(*create)(const char*, const char*, SDL_PropertiesID);
|
SDL_Storage *(*create)(const char *, const char *, SDL_PropertiesID);
|
||||||
} UserStorageBootStrap;
|
} UserStorageBootStrap;
|
||||||
|
|
||||||
// Not all of these are available in a given build. Use #ifdefs, etc.
|
// Not all of these are available in a given build. Use #ifdefs, etc.
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ typedef struct STEAM_RemoteStorage
|
||||||
static bool STEAM_CloseStorage(void *userdata)
|
static bool STEAM_CloseStorage(void *userdata)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage *)userdata;
|
||||||
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
||||||
if (steamremotestorage == NULL) {
|
if (steamremotestorage == NULL) {
|
||||||
result = SDL_SetError("SteamRemoteStorage unavailable");
|
result = SDL_SetError("SteamRemoteStorage unavailable");
|
||||||
|
|
@ -60,7 +60,7 @@ static bool STEAM_StorageReady(void *userdata)
|
||||||
|
|
||||||
static bool STEAM_GetStoragePathInfo(void *userdata, const char *path, SDL_PathInfo *info)
|
static bool STEAM_GetStoragePathInfo(void *userdata, const char *path, SDL_PathInfo *info)
|
||||||
{
|
{
|
||||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage *)userdata;
|
||||||
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
||||||
if (steamremotestorage == NULL) {
|
if (steamremotestorage == NULL) {
|
||||||
return SDL_SetError("SteamRemoteStorage unavailable");
|
return SDL_SetError("SteamRemoteStorage unavailable");
|
||||||
|
|
@ -77,7 +77,7 @@ static bool STEAM_GetStoragePathInfo(void *userdata, const char *path, SDL_PathI
|
||||||
static bool STEAM_ReadStorageFile(void *userdata, const char *path, void *destination, Uint64 length)
|
static bool STEAM_ReadStorageFile(void *userdata, const char *path, void *destination, Uint64 length)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage *)userdata;
|
||||||
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
||||||
if (steamremotestorage == NULL) {
|
if (steamremotestorage == NULL) {
|
||||||
return SDL_SetError("SteamRemoteStorage unavailable");
|
return SDL_SetError("SteamRemoteStorage unavailable");
|
||||||
|
|
@ -96,7 +96,7 @@ static bool STEAM_ReadStorageFile(void *userdata, const char *path, void *destin
|
||||||
static bool STEAM_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length)
|
static bool STEAM_WriteStorageFile(void *userdata, const char *path, const void *source, Uint64 length)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage *)userdata;
|
||||||
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
||||||
if (steamremotestorage == NULL) {
|
if (steamremotestorage == NULL) {
|
||||||
return SDL_SetError("SteamRemoteStorage unavailable");
|
return SDL_SetError("SteamRemoteStorage unavailable");
|
||||||
|
|
@ -115,7 +115,7 @@ static bool STEAM_WriteStorageFile(void *userdata, const char *path, const void
|
||||||
static Uint64 STEAM_GetStorageSpaceRemaining(void *userdata)
|
static Uint64 STEAM_GetStorageSpaceRemaining(void *userdata)
|
||||||
{
|
{
|
||||||
Uint64 total, remaining;
|
Uint64 total, remaining;
|
||||||
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage*) userdata;
|
STEAM_RemoteStorage *steam = (STEAM_RemoteStorage *)userdata;
|
||||||
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
void *steamremotestorage = steam->SteamAPI_SteamRemoteStorage_v016();
|
||||||
if (steamremotestorage == NULL) {
|
if (steamremotestorage == NULL) {
|
||||||
SDL_SetError("SteamRemoteStorage unavailable");
|
SDL_SetError("SteamRemoteStorage unavailable");
|
||||||
|
|
@ -149,7 +149,7 @@ static SDL_Storage *STEAM_User_Create(const char *org, const char *app, SDL_Prop
|
||||||
STEAM_RemoteStorage *steam;
|
STEAM_RemoteStorage *steam;
|
||||||
void *steamremotestorage;
|
void *steamremotestorage;
|
||||||
|
|
||||||
steam = (STEAM_RemoteStorage*) SDL_malloc(sizeof(STEAM_RemoteStorage));
|
steam = (STEAM_RemoteStorage *)SDL_malloc(sizeof(STEAM_RemoteStorage));
|
||||||
if (steam == NULL) {
|
if (steam == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ static unsigned int get_allocation_bucket(void *mem)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_tracked_allocation* SDL_GetTrackedAllocation(void *mem)
|
static SDL_tracked_allocation *SDL_GetTrackedAllocation(void *mem)
|
||||||
{
|
{
|
||||||
SDL_tracked_allocation *entry;
|
SDL_tracked_allocation *entry;
|
||||||
LOCK_ALLOCATOR();
|
LOCK_ALLOCATOR();
|
||||||
|
|
@ -216,9 +216,9 @@ static void SDL_UntrackAllocation(void *mem)
|
||||||
UNLOCK_ALLOCATOR();
|
UNLOCK_ALLOCATOR();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rand_fill_memory(void* ptr, size_t start, size_t end)
|
static void rand_fill_memory(void *ptr, size_t start, size_t end)
|
||||||
{
|
{
|
||||||
Uint8* mem = (Uint8*) ptr;
|
Uint8 *mem = (Uint8 *)ptr;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!s_randfill_allocations)
|
if (!s_randfill_allocations)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
/* Glib 2.0 */
|
/* Glib 2.0 */
|
||||||
|
|
||||||
typedef unsigned long gulong;
|
typedef unsigned long gulong;
|
||||||
typedef void* gpointer;
|
typedef void *gpointer;
|
||||||
typedef char gchar;
|
typedef char gchar;
|
||||||
typedef int gint;
|
typedef int gint;
|
||||||
typedef unsigned int guint;
|
typedef unsigned int guint;
|
||||||
|
|
@ -88,11 +88,11 @@ typedef struct _GtkCheckMenuItem GtkCheckMenuItem;
|
||||||
|
|
||||||
static gboolean (*gtk_init_check)(int *argc, char ***argv);
|
static gboolean (*gtk_init_check)(int *argc, char ***argv);
|
||||||
static gboolean (*gtk_main_iteration_do)(gboolean blocking);
|
static gboolean (*gtk_main_iteration_do)(gboolean blocking);
|
||||||
static GtkWidget* (*gtk_menu_new)(void);
|
static GtkWidget *(*gtk_menu_new)(void);
|
||||||
static GtkWidget* (*gtk_separator_menu_item_new)(void);
|
static GtkWidget *(*gtk_separator_menu_item_new)(void);
|
||||||
static GtkWidget* (*gtk_menu_item_new_with_label)(const gchar *label);
|
static GtkWidget *(*gtk_menu_item_new_with_label)(const gchar *label);
|
||||||
static void (*gtk_menu_item_set_submenu)(GtkMenuItem *menu_item, GtkWidget *submenu);
|
static void (*gtk_menu_item_set_submenu)(GtkMenuItem *menu_item, GtkWidget *submenu);
|
||||||
static GtkWidget* (*gtk_check_menu_item_new_with_label)(const gchar *label);
|
static GtkWidget *(*gtk_check_menu_item_new_with_label)(const gchar *label);
|
||||||
static void (*gtk_check_menu_item_set_active)(GtkCheckMenuItem *check_menu_item, gboolean is_active);
|
static void (*gtk_check_menu_item_set_active)(GtkCheckMenuItem *check_menu_item, gboolean is_active);
|
||||||
static void (*gtk_widget_set_sensitive)(GtkWidget *widget, gboolean sensitive);
|
static void (*gtk_widget_set_sensitive)(GtkWidget *widget, gboolean sensitive);
|
||||||
static void (*gtk_widget_show)(GtkWidget *widget);
|
static void (*gtk_widget_show)(GtkWidget *widget);
|
||||||
|
|
|
||||||
|
|
@ -486,8 +486,8 @@ static void SDL_TARGETING("mmx") Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info)
|
||||||
d &= 0x07e0f81f;
|
d &= 0x07e0f81f;
|
||||||
*dstp++ = (Uint16)(d | d >> 16);
|
*dstp++ = (Uint16)(d | d >> 16);
|
||||||
},{
|
},{
|
||||||
src1 = *(__m64*)srcp; // 4 src pixels -> src1
|
src1 = *(__m64 *)srcp; // 4 src pixels -> src1
|
||||||
dst1 = *(__m64*)dstp; // 4 dst pixels -> dst1
|
dst1 = *(__m64 *)dstp; // 4 dst pixels -> dst1
|
||||||
|
|
||||||
// red
|
// red
|
||||||
src2 = src1;
|
src2 = src1;
|
||||||
|
|
@ -536,7 +536,7 @@ static void SDL_TARGETING("mmx") Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info)
|
||||||
|
|
||||||
mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN | BLUE -> mm_res
|
mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN | BLUE -> mm_res
|
||||||
|
|
||||||
*(__m64*)dstp = mm_res; // mm_res -> 4 dst pixels
|
*(__m64 *)dstp = mm_res; // mm_res -> 4 dst pixels
|
||||||
|
|
||||||
srcp += 4;
|
srcp += 4;
|
||||||
dstp += 4;
|
dstp += 4;
|
||||||
|
|
@ -624,8 +624,8 @@ static void SDL_TARGETING("mmx") Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info)
|
||||||
d &= 0x03e07c1f;
|
d &= 0x03e07c1f;
|
||||||
*dstp++ = (Uint16)(d | d >> 16);
|
*dstp++ = (Uint16)(d | d >> 16);
|
||||||
},{
|
},{
|
||||||
src1 = *(__m64*)srcp; // 4 src pixels -> src1
|
src1 = *(__m64 *)srcp; // 4 src pixels -> src1
|
||||||
dst1 = *(__m64*)dstp; // 4 dst pixels -> dst1
|
dst1 = *(__m64 *)dstp; // 4 dst pixels -> dst1
|
||||||
|
|
||||||
// red -- process the bits in place
|
// red -- process the bits in place
|
||||||
src2 = src1;
|
src2 = src1;
|
||||||
|
|
@ -674,7 +674,7 @@ static void SDL_TARGETING("mmx") Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info)
|
||||||
|
|
||||||
mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN | BLUE -> mm_res
|
mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN | BLUE -> mm_res
|
||||||
|
|
||||||
*(__m64*)dstp = mm_res; // mm_res -> 4 dst pixels
|
*(__m64 *)dstp = mm_res; // mm_res -> 4 dst pixels
|
||||||
|
|
||||||
srcp += 4;
|
srcp += 4;
|
||||||
dstp += 4;
|
dstp += 4;
|
||||||
|
|
@ -1061,8 +1061,8 @@ static void SDL_TARGETING("sse4.1") Blit8888to8888PixelAlphaSwizzleSSE41(SDL_Bli
|
||||||
__m128i dst_hi = _mm_maddubs_epi16(srca_hi, _mm_unpackhi_epi8(src128, dst128));
|
__m128i dst_hi = _mm_maddubs_epi16(srca_hi, _mm_unpackhi_epi8(src128, dst128));
|
||||||
|
|
||||||
// dst += 0x1U (use 0x80 to round instead of floor) + 128*255 (to fix maddubs result)
|
// dst += 0x1U (use 0x80 to round instead of floor) + 128*255 (to fix maddubs result)
|
||||||
dst_lo = _mm_add_epi16(dst_lo, _mm_set1_epi16(1 + 128*255));
|
dst_lo = _mm_add_epi16(dst_lo, _mm_set1_epi16(1 + 128 * 255));
|
||||||
dst_hi = _mm_add_epi16(dst_hi, _mm_set1_epi16(1 + 128*255));
|
dst_hi = _mm_add_epi16(dst_hi, _mm_set1_epi16(1 + 128 * 255));
|
||||||
|
|
||||||
// dst = (dst + (dst >> 8)) >> 8 = (dst * 257) >> 16
|
// dst = (dst + (dst >> 8)) >> 8 = (dst * 257) >> 16
|
||||||
dst_lo = _mm_mulhi_epu16(dst_lo, _mm_set1_epi16(257));
|
dst_lo = _mm_mulhi_epu16(dst_lo, _mm_set1_epi16(257));
|
||||||
|
|
@ -1165,8 +1165,8 @@ static void SDL_TARGETING("avx2") Blit8888to8888PixelAlphaSwizzleAVX2(SDL_BlitIn
|
||||||
__m256i dst_hi = _mm256_maddubs_epi16(alpha_hi, _mm256_unpackhi_epi8(src256, dst256));
|
__m256i dst_hi = _mm256_maddubs_epi16(alpha_hi, _mm256_unpackhi_epi8(src256, dst256));
|
||||||
|
|
||||||
// dst += 0x1U (use 0x80 to round instead of floor) + 128*255 (to fix maddubs result)
|
// dst += 0x1U (use 0x80 to round instead of floor) + 128*255 (to fix maddubs result)
|
||||||
dst_lo = _mm256_add_epi16(dst_lo, _mm256_set1_epi16(1 + 128*255));
|
dst_lo = _mm256_add_epi16(dst_lo, _mm256_set1_epi16(1 + 128 * 255));
|
||||||
dst_hi = _mm256_add_epi16(dst_hi, _mm256_set1_epi16(1 + 128*255));
|
dst_hi = _mm256_add_epi16(dst_hi, _mm256_set1_epi16(1 + 128 * 255));
|
||||||
|
|
||||||
// dst = (dst + (dst >> 8)) >> 8 = (dst * 257) >> 16
|
// dst = (dst + (dst >> 8)) >> 8 = (dst * 257) >> 16
|
||||||
dst_lo = _mm256_mulhi_epu16(dst_lo, _mm256_set1_epi16(257));
|
dst_lo = _mm256_mulhi_epu16(dst_lo, _mm256_set1_epi16(257));
|
||||||
|
|
@ -1290,8 +1290,8 @@ static void Blit8888to8888PixelAlphaSwizzleNEON(SDL_BlitInfo *info)
|
||||||
// Process 1 pixel per iteration, max 3 iterations, same calculations as above
|
// Process 1 pixel per iteration, max 3 iterations, same calculations as above
|
||||||
for (; i < width; ++i) {
|
for (; i < width; ++i) {
|
||||||
// Top 32-bits will be not used in src32 & dst32
|
// Top 32-bits will be not used in src32 & dst32
|
||||||
uint8x8_t src32 = vreinterpret_u8_u32(vld1_dup_u32((Uint32*)src));
|
uint8x8_t src32 = vreinterpret_u8_u32(vld1_dup_u32((Uint32 *)src));
|
||||||
uint8x8_t dst32 = vreinterpret_u8_u32(vld1_dup_u32((Uint32*)dst));
|
uint8x8_t dst32 = vreinterpret_u8_u32(vld1_dup_u32((Uint32 *)dst));
|
||||||
|
|
||||||
uint8x8_t srcA = vtbl1_u8(src32, vget_low_u8(alpha_splat_mask));
|
uint8x8_t srcA = vtbl1_u8(src32, vget_low_u8(alpha_splat_mask));
|
||||||
src32 = vtbl1_u8(src32, vget_low_u8(convert_mask));
|
src32 = vtbl1_u8(src32, vget_low_u8(convert_mask));
|
||||||
|
|
@ -1309,7 +1309,7 @@ static void Blit8888to8888PixelAlphaSwizzleNEON(SDL_BlitInfo *info)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the result, only low 32-bits
|
// Save the result, only low 32-bits
|
||||||
vst1_lane_u32((Uint32*)dst, vreinterpret_u32_u8(dst32), 0);
|
vst1_lane_u32((Uint32 *)dst, vreinterpret_u32_u8(dst32), 0);
|
||||||
|
|
||||||
src += 4;
|
src += 4;
|
||||||
dst += 4;
|
dst += 4;
|
||||||
|
|
|
||||||
|
|
@ -2258,7 +2258,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info)
|
||||||
/* *INDENT-OFF* */ // clang-format off
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
DUFFS_LOOP(
|
DUFFS_LOOP(
|
||||||
{
|
{
|
||||||
Uint32 *src32 = (Uint32*)src;
|
Uint32 *src32 = (Uint32 *)src;
|
||||||
|
|
||||||
if ((*src32 & rgbmask) != ckey) {
|
if ((*src32 & rgbmask) != ckey) {
|
||||||
dst[0] = src[p0];
|
dst[0] = src[p0];
|
||||||
|
|
@ -2366,7 +2366,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info)
|
||||||
/* *INDENT-OFF* */ // clang-format off
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
DUFFS_LOOP(
|
DUFFS_LOOP(
|
||||||
{
|
{
|
||||||
Uint32 *src32 = (Uint32*)src;
|
Uint32 *src32 = (Uint32 *)src;
|
||||||
if ((*src32 & rgbmask) != ckey) {
|
if ((*src32 & rgbmask) != ckey) {
|
||||||
dst[0] = src[p0];
|
dst[0] = src[p0];
|
||||||
dst[1] = src[p1];
|
dst[1] = src[p1];
|
||||||
|
|
@ -2516,7 +2516,7 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
|
||||||
/* *INDENT-OFF* */ // clang-format off
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
DUFFS_LOOP(
|
DUFFS_LOOP(
|
||||||
{
|
{
|
||||||
Uint32 *src32 = (Uint32*)src;
|
Uint32 *src32 = (Uint32 *)src;
|
||||||
if ((*src32 & rgbmask) != ckey) {
|
if ((*src32 & rgbmask) != ckey) {
|
||||||
dst[0] = src[p0];
|
dst[0] = src[p0];
|
||||||
dst[1] = src[p1];
|
dst[1] = src[p1];
|
||||||
|
|
@ -2777,7 +2777,7 @@ static void Blit8888to8888PixelSwizzleNEON(SDL_BlitInfo *info)
|
||||||
// Process 1 pixel per iteration, max 3 iterations, same calculations as above
|
// Process 1 pixel per iteration, max 3 iterations, same calculations as above
|
||||||
for (; i < width; ++i) {
|
for (; i < width; ++i) {
|
||||||
// Top 32-bits will be not used in src32
|
// Top 32-bits will be not used in src32
|
||||||
uint8x8_t src32 = vreinterpret_u8_u32(vld1_dup_u32((Uint32*)src));
|
uint8x8_t src32 = vreinterpret_u8_u32(vld1_dup_u32((Uint32 *)src));
|
||||||
|
|
||||||
// Convert to dst format
|
// Convert to dst format
|
||||||
src32 = vtbl1_u8(src32, vget_low_u8(convert_mask));
|
src32 = vtbl1_u8(src32, vget_low_u8(convert_mask));
|
||||||
|
|
@ -2788,7 +2788,7 @@ static void Blit8888to8888PixelSwizzleNEON(SDL_BlitInfo *info)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the result, only low 32-bits
|
// Save the result, only low 32-bits
|
||||||
vst1_lane_u32((Uint32*)dst, vreinterpret_u32_u8(src32), 0);
|
vst1_lane_u32((Uint32 *)dst, vreinterpret_u32_u8(src32), 0);
|
||||||
|
|
||||||
src += 4;
|
src += 4;
|
||||||
dst += 4;
|
dst += 4;
|
||||||
|
|
@ -2829,7 +2829,7 @@ static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info)
|
||||||
/* *INDENT-OFF* */ // clang-format off
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
DUFFS_LOOP(
|
DUFFS_LOOP(
|
||||||
{
|
{
|
||||||
Uint32 *dst32 = (Uint32*)dst;
|
Uint32 *dst32 = (Uint32 *)dst;
|
||||||
Uint8 s0 = src[i0];
|
Uint8 s0 = src[i0];
|
||||||
Uint8 s1 = src[i1];
|
Uint8 s1 = src[i1];
|
||||||
Uint8 s2 = src[i2];
|
Uint8 s2 = src[i2];
|
||||||
|
|
@ -2901,7 +2901,7 @@ static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info)
|
||||||
/* *INDENT-OFF* */ // clang-format off
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
DUFFS_LOOP(
|
DUFFS_LOOP(
|
||||||
{
|
{
|
||||||
Uint32 *dst32 = (Uint32*)dst;
|
Uint32 *dst32 = (Uint32 *)dst;
|
||||||
Uint8 s0 = src[i0];
|
Uint8 s0 = src[i0];
|
||||||
Uint8 s1 = src[i1];
|
Uint8 s1 = src[i1];
|
||||||
Uint8 s2 = src[i2];
|
Uint8 s2 = src[i2];
|
||||||
|
|
@ -2929,7 +2929,7 @@ static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info)
|
||||||
/* *INDENT-OFF* */ // clang-format off
|
/* *INDENT-OFF* */ // clang-format off
|
||||||
DUFFS_LOOP(
|
DUFFS_LOOP(
|
||||||
{
|
{
|
||||||
Uint32 *dst32 = (Uint32*)dst;
|
Uint32 *dst32 = (Uint32 *)dst;
|
||||||
Uint8 s0 = src[i0];
|
Uint8 s0 = src[i0];
|
||||||
Uint8 s1 = src[i1];
|
Uint8 s1 = src[i1];
|
||||||
Uint8 s2 = src[i2];
|
Uint8 s2 = src[i2];
|
||||||
|
|
|
||||||
|
|
@ -288,7 +288,7 @@ typedef struct color_t
|
||||||
#if 0
|
#if 0
|
||||||
static void printf_64(const char *str, void *var)
|
static void printf_64(const char *str, void *var)
|
||||||
{
|
{
|
||||||
uint8_t *val = (uint8_t*) var;
|
uint8_t *val = (uint8_t *)var;
|
||||||
printf(" * %s: %02x %02x %02x %02x _ %02x %02x %02x %02x\n",
|
printf(" * %s: %02x %02x %02x %02x _ %02x %02x %02x %02x\n",
|
||||||
str, val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]);
|
str, val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]);
|
||||||
}
|
}
|
||||||
|
|
@ -394,7 +394,7 @@ static bool scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, Ui
|
||||||
#if 0
|
#if 0
|
||||||
static void SDL_TARGETING("sse2") printf_128(const char *str, __m128i var)
|
static void SDL_TARGETING("sse2") printf_128(const char *str, __m128i var)
|
||||||
{
|
{
|
||||||
uint16_t *val = (uint16_t*) &var;
|
uint16_t *val = (uint16_t *)&var;
|
||||||
printf(" * %s: %04x %04x %04x %04x _ %04x %04x %04x %04x\n",
|
printf(" * %s: %04x %04x %04x %04x _ %04x %04x %04x %04x\n",
|
||||||
str, val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]);
|
str, val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ struct SDL_VideoDevice
|
||||||
*/
|
*/
|
||||||
bool (*Vulkan_LoadLibrary)(SDL_VideoDevice *_this, const char *path);
|
bool (*Vulkan_LoadLibrary)(SDL_VideoDevice *_this, const char *path);
|
||||||
void (*Vulkan_UnloadLibrary)(SDL_VideoDevice *_this);
|
void (*Vulkan_UnloadLibrary)(SDL_VideoDevice *_this);
|
||||||
char const* const* (*Vulkan_GetInstanceExtensions)(SDL_VideoDevice *_this, Uint32 *count);
|
char const * const *(*Vulkan_GetInstanceExtensions)(SDL_VideoDevice *_this, Uint32 *count);
|
||||||
bool (*Vulkan_CreateSurface)(SDL_VideoDevice *_this, SDL_Window *window, VkInstance instance, const struct VkAllocationCallbacks *allocator, VkSurfaceKHR *surface);
|
bool (*Vulkan_CreateSurface)(SDL_VideoDevice *_this, SDL_Window *window, VkInstance instance, const struct VkAllocationCallbacks *allocator, VkSurfaceKHR *surface);
|
||||||
void (*Vulkan_DestroySurface)(SDL_VideoDevice *_this, VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator);
|
void (*Vulkan_DestroySurface)(SDL_VideoDevice *_this, VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator);
|
||||||
bool (*Vulkan_GetPresentationSupport)(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex);
|
bool (*Vulkan_GetPresentationSupport)(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex);
|
||||||
|
|
|
||||||
|
|
@ -3672,6 +3672,10 @@ bool SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent)
|
||||||
CHECK_WINDOW_NOT_POPUP(parent, false);
|
CHECK_WINDOW_NOT_POPUP(parent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (window == parent) {
|
||||||
|
return SDL_SetError("Cannot set the parent of a window to itself.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!_this->SetWindowParent) {
|
if (!_this->SetWindowParent) {
|
||||||
return SDL_Unsupported();
|
return SDL_Unsupported();
|
||||||
}
|
}
|
||||||
|
|
@ -4135,7 +4139,7 @@ void SDL_OnWindowLiveResizeUpdate(SDL_Window *window)
|
||||||
SDL_IterateMainCallbacks(false);
|
SDL_IterateMainCallbacks(false);
|
||||||
} else {
|
} else {
|
||||||
// Send an expose event so the application can redraw
|
// Send an expose event so the application can redraw
|
||||||
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 0, 0);
|
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_PumpEventMaintenance();
|
SDL_PumpEventMaintenance();
|
||||||
|
|
@ -6020,7 +6024,7 @@ void SDL_Vulkan_UnloadLibrary(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* const* SDL_Vulkan_GetInstanceExtensions(Uint32 *count)
|
char const * const *SDL_Vulkan_GetInstanceExtensions(Uint32 *count)
|
||||||
{
|
{
|
||||||
return _this->Vulkan_GetInstanceExtensions(_this, count);
|
return _this->Vulkan_GetInstanceExtensions(_this, count);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,7 @@ void Android_Vulkan_UnloadLibrary(SDL_VideoDevice *_this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* const* Android_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this,
|
char const * const *Android_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count)
|
||||||
Uint32 *count)
|
|
||||||
{
|
{
|
||||||
static const char *const extensionsForAndroid[] = {
|
static const char *const extensionsForAndroid[] = {
|
||||||
VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME
|
VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
extern bool Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
extern bool Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||||
extern void Android_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
|
extern void Android_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
|
||||||
extern char const* const* Android_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count);
|
extern char const * const *Android_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count);
|
||||||
extern bool Android_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
extern bool Android_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||||
SDL_Window *window,
|
SDL_Window *window,
|
||||||
VkInstance instance,
|
VkInstance instance,
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ void Cocoa_VideoQuit(SDL_VideoDevice *_this)
|
||||||
SDL_SystemTheme Cocoa_GetSystemTheme(void)
|
SDL_SystemTheme Cocoa_GetSystemTheme(void)
|
||||||
{
|
{
|
||||||
if (@available(macOS 10.14, *)) {
|
if (@available(macOS 10.14, *)) {
|
||||||
NSAppearance* appearance = [[NSApplication sharedApplication] effectiveAppearance];
|
NSAppearance *appearance = [[NSApplication sharedApplication] effectiveAppearance];
|
||||||
|
|
||||||
if ([appearance.name containsString: @"Dark"]) {
|
if ([appearance.name containsString: @"Dark"]) {
|
||||||
return SDL_SYSTEM_THEME_DARK;
|
return SDL_SYSTEM_THEME_DARK;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
extern bool Cocoa_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
extern bool Cocoa_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||||
extern void Cocoa_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
|
extern void Cocoa_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
|
||||||
extern char const* const* Cocoa_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count);
|
extern char const * const *Cocoa_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count);
|
||||||
extern bool Cocoa_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
extern bool Cocoa_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||||
SDL_Window *window,
|
SDL_Window *window,
|
||||||
VkInstance instance,
|
VkInstance instance,
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,7 @@ void Cocoa_Vulkan_UnloadLibrary(SDL_VideoDevice *_this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char const* const* Cocoa_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this,
|
char const * const *Cocoa_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count)
|
||||||
Uint32 *count)
|
|
||||||
{
|
{
|
||||||
static const char *const extensionsForCocoa[] = {
|
static const char *const extensionsForCocoa[] = {
|
||||||
VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_METAL_SURFACE_EXTENSION_NAME, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME
|
VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_METAL_SURFACE_EXTENSION_NAME, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ bool Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wind
|
||||||
data32.set(HEAP32.subarray(src, src + num));
|
data32.set(HEAP32.subarray(src, src + num));
|
||||||
var data8 = SDL3.data8;
|
var data8 = SDL3.data8;
|
||||||
var i = 3;
|
var i = 3;
|
||||||
var j = i + 4*num;
|
var j = i + 4 * num;
|
||||||
if (num % 8 == 0) {
|
if (num % 8 == 0) {
|
||||||
// unrolling gives big speedups
|
// unrolling gives big speedups
|
||||||
while (i < j) {
|
while (i < j) {
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ char *HAIKU_GetClipboardText(SDL_VideoDevice *_this) {
|
||||||
if (be_clipboard->Lock()) {
|
if (be_clipboard->Lock()) {
|
||||||
if ((clip = be_clipboard->Data())) {
|
if ((clip = be_clipboard->Data())) {
|
||||||
// Presumably the string of characters is ascii-format
|
// Presumably the string of characters is ascii-format
|
||||||
clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text,
|
clip->FindData("text/plain", B_MIME_TYPE, (const void **)&text,
|
||||||
&length);
|
&length);
|
||||||
}
|
}
|
||||||
be_clipboard->Unlock();
|
be_clipboard->Unlock();
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
SetTitle(const char* aTitle)
|
SetTitle(const char *aTitle)
|
||||||
{
|
{
|
||||||
fTitle = aTitle;
|
fTitle = aTitle;
|
||||||
BAlert::SetTitle(aTitle);
|
BAlert::SetTitle(aTitle);
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ static void _BDisplayModeToSdlDisplayMode(display_mode *bmode, SDL_DisplayMode *
|
||||||
get_refresh_rate(*bmode, &mode->refresh_rate_numerator, &mode->refresh_rate_denominator);
|
get_refresh_rate(*bmode, &mode->refresh_rate_numerator, &mode->refresh_rate_denominator);
|
||||||
|
|
||||||
#if WRAP_BMODE
|
#if WRAP_BMODE
|
||||||
SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
SDL_DisplayModeData *data = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData));
|
||||||
data->bmode = bmode;
|
data->bmode = bmode;
|
||||||
|
|
||||||
mode->internal = data;
|
mode->internal = data;
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ bool HAIKU_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window * window)
|
||||||
|
|
||||||
bool HAIKU_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window * window, SDL_GLContext context)
|
bool HAIKU_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window * window, SDL_GLContext context)
|
||||||
{
|
{
|
||||||
BGLView* glView = (BGLView*)context;
|
BGLView *glView = (BGLView *)context;
|
||||||
// printf("HAIKU_GL_MakeCurrent(%llx), win = %llx, thread = %d\n", (uint64)context, (uint64)window, find_thread(NULL));
|
// printf("HAIKU_GL_MakeCurrent(%llx), win = %llx, thread = %d\n", (uint64)context, (uint64)window, find_thread(NULL));
|
||||||
if (glView) {
|
if (glView) {
|
||||||
if ((glView->Window() == NULL) || (!window) || (_ToBeWin(window)->GetGLView() != glView)) {
|
if ((glView->Window() == NULL) || (!window) || (_ToBeWin(window)->GetGLView() != glView)) {
|
||||||
|
|
@ -150,8 +150,8 @@ SDL_GLContext HAIKU_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window * window
|
||||||
bool HAIKU_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context)
|
bool HAIKU_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context)
|
||||||
{
|
{
|
||||||
// printf("HAIKU_GL_DestroyContext(%llx), thread = %d\n", (uint64)context, find_thread(NULL));
|
// printf("HAIKU_GL_DestroyContext(%llx), thread = %d\n", (uint64)context, find_thread(NULL));
|
||||||
BGLView* glView = (BGLView*)context;
|
BGLView *glView = (BGLView *)context;
|
||||||
SDL_BWin *bwin = (SDL_BWin*)glView->Window();
|
SDL_BWin *bwin = (SDL_BWin *)glView->Window();
|
||||||
if (!bwin) {
|
if (!bwin) {
|
||||||
delete glView;
|
delete glView;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,23 @@ void KMSDRM_DestroyCursorBO(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
|
||||||
|
|
||||||
// Destroy the curso GBM BO.
|
// Destroy the curso GBM BO.
|
||||||
if (dispdata->cursor_bo) {
|
if (dispdata->cursor_bo) {
|
||||||
|
SDL_VideoData *viddata = (SDL_VideoData *) _this->internal;
|
||||||
|
if (viddata->is_atomic) {
|
||||||
|
if (dispdata->cursor_plane) {
|
||||||
|
// Unset the the cursor BO from the cursor plane.
|
||||||
|
KMSDRM_PlaneInfo info;
|
||||||
|
SDL_zero(info);
|
||||||
|
info.plane = dispdata->cursor_plane;
|
||||||
|
drm_atomic_set_plane_props(&info);
|
||||||
|
// Wait until the cursor is unset from the cursor plane before destroying it's BO.
|
||||||
|
if (drm_atomic_commit(_this, true, false)) {
|
||||||
|
SDL_SetError("Failed atomic commit in KMSDRM_DenitMouse.");
|
||||||
|
}
|
||||||
|
// Free the cursor plane, on which the cursor was being shown.
|
||||||
|
free_plane(&dispdata->cursor_plane);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
|
KMSDRM_gbm_bo_destroy(dispdata->cursor_bo);
|
||||||
dispdata->cursor_bo = NULL;
|
dispdata->cursor_bo = NULL;
|
||||||
dispdata->cursor_bo_drm_fd = -1;
|
dispdata->cursor_bo_drm_fd = -1;
|
||||||
|
|
@ -78,11 +95,14 @@ void KMSDRM_DestroyCursorBO(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
|
||||||
build a window and assign a display to it. */
|
build a window and assign a display to it. */
|
||||||
bool KMSDRM_CreateCursorBO(SDL_VideoDisplay *display)
|
bool KMSDRM_CreateCursorBO(SDL_VideoDisplay *display)
|
||||||
{
|
{
|
||||||
|
|
||||||
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||||
SDL_VideoData *viddata = dev->internal;
|
SDL_VideoData *viddata = dev->internal;
|
||||||
SDL_DisplayData *dispdata = display->internal;
|
SDL_DisplayData *dispdata = display->internal;
|
||||||
|
|
||||||
|
if (viddata->is_atomic) {
|
||||||
|
setup_plane(dev, &dispdata->cursor_plane, DRM_PLANE_TYPE_CURSOR);
|
||||||
|
}
|
||||||
|
|
||||||
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev,
|
if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev,
|
||||||
GBM_FORMAT_ARGB8888,
|
GBM_FORMAT_ARGB8888,
|
||||||
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) {
|
GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) {
|
||||||
|
|
@ -121,15 +141,29 @@ static bool KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display)
|
||||||
SDL_VideoDevice *video_device = SDL_GetVideoDevice();
|
SDL_VideoDevice *video_device = SDL_GetVideoDevice();
|
||||||
SDL_VideoData *viddata = video_device->internal;
|
SDL_VideoData *viddata = video_device->internal;
|
||||||
|
|
||||||
const int rc = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc->crtc_id, 0, 0, 0);
|
if (viddata->is_atomic) {
|
||||||
if (rc < 0) {
|
if (dispdata->cursor_plane) {
|
||||||
result = SDL_SetError("drmModeSetCursor() failed: %s", strerror(-rc));
|
KMSDRM_PlaneInfo info;
|
||||||
|
SDL_zero(info);
|
||||||
|
info.plane = dispdata->cursor_plane;
|
||||||
|
// The rest of the members are zeroed, so this takes away the cursor from the cursor plane.
|
||||||
|
drm_atomic_set_plane_props(&info);
|
||||||
|
if (drm_atomic_commit(video_device, true, false)) {
|
||||||
|
result = SDL_SetError("Failed atomic commit in KMSDRM_ShowCursor.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const int rc = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc.crtc->crtc_id, 0, 0, 0);
|
||||||
|
if (rc < 0) {
|
||||||
|
result = SDL_SetError("drmModeSetCursor() failed: %s", strerror(-rc));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump a cursor buffer to a display's DRM cursor BO.
|
// Dump a cursor buffer to a display's DRM cursor BO.
|
||||||
static bool KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor)
|
static bool KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Mouse *mouse, SDL_Cursor *cursor)
|
||||||
{
|
{
|
||||||
SDL_DisplayData *dispdata = display->internal;
|
SDL_DisplayData *dispdata = display->internal;
|
||||||
SDL_CursorData *curdata = cursor->internal;
|
SDL_CursorData *curdata = cursor->internal;
|
||||||
|
|
@ -173,22 +207,42 @@ static bool KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the GBM BO buffer on screen using the DRM interface.
|
if (viddata->is_atomic) {
|
||||||
bo_handle = KMSDRM_gbm_bo_get_handle(dispdata->cursor_bo).u32;
|
// Get the fb_id for the GBM BO so we can show it on the cursor plane.
|
||||||
if (curdata->hot_x == 0 && curdata->hot_y == 0) {
|
KMSDRM_FBInfo *fb = KMSDRM_FBFromBO(video_device, dispdata->cursor_bo);
|
||||||
rc = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc->crtc_id,
|
KMSDRM_PlaneInfo info;
|
||||||
bo_handle, dispdata->cursor_w, dispdata->cursor_h);
|
|
||||||
|
// Show the GBM BO buffer on the cursor plane.
|
||||||
|
SDL_zero(info);
|
||||||
|
info.plane = dispdata->cursor_plane;
|
||||||
|
info.crtc_id = dispdata->crtc.crtc->crtc_id;
|
||||||
|
info.fb_id = fb->fb_id;
|
||||||
|
info.src_w = dispdata->cursor_w;
|
||||||
|
info.src_h = dispdata->cursor_h;
|
||||||
|
info.crtc_x = ((int32_t) SDL_roundf(mouse->x)) - curdata->hot_x;
|
||||||
|
info.crtc_y = ((int32_t) SDL_roundf(mouse->y)) - curdata->hot_y;
|
||||||
|
info.crtc_w = curdata->w;
|
||||||
|
info.crtc_h = curdata->h;
|
||||||
|
drm_atomic_set_plane_props(&info);
|
||||||
|
if (drm_atomic_commit(video_device, true, false)) {
|
||||||
|
result = SDL_SetError("Failed atomic commit in KMSDRM_ShowCursor.");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rc = KMSDRM_drmModeSetCursor2(viddata->drm_fd, dispdata->crtc->crtc_id,
|
// Put the GBM BO buffer on screen using the DRM interface.
|
||||||
bo_handle, dispdata->cursor_w, dispdata->cursor_h, curdata->hot_x, curdata->hot_y);
|
bo_handle = KMSDRM_gbm_bo_get_handle(dispdata->cursor_bo).u32;
|
||||||
}
|
if (curdata->hot_x == 0 && curdata->hot_y == 0) {
|
||||||
if (rc < 0) {
|
rc = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc.crtc->crtc_id, bo_handle, dispdata->cursor_w, dispdata->cursor_h);
|
||||||
result = SDL_SetError("Failed to set DRM cursor: %s", strerror(-rc));
|
} else {
|
||||||
goto cleanup;
|
rc = KMSDRM_drmModeSetCursor2(viddata->drm_fd, dispdata->crtc.crtc->crtc_id, bo_handle, dispdata->cursor_w, dispdata->cursor_h, curdata->hot_x, curdata->hot_y);
|
||||||
|
}
|
||||||
|
if (rc < 0) {
|
||||||
|
result = SDL_SetError("Failed to set DRM cursor: %s", strerror(-rc));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
if (ready_buffer) {
|
if (ready_buffer) {
|
||||||
SDL_free(ready_buffer);
|
SDL_free(ready_buffer);
|
||||||
}
|
}
|
||||||
|
|
@ -316,7 +370,7 @@ static bool KMSDRM_ShowCursor(SDL_Cursor *cursor)
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
/* Dump the cursor to the display DRM cursor BO so it becomes visible
|
/* Dump the cursor to the display DRM cursor BO so it becomes visible
|
||||||
on that display. */
|
on that display. */
|
||||||
result = KMSDRM_DumpCursorToBO(display, cursor);
|
result = KMSDRM_DumpCursorToBO(display, mouse, cursor);
|
||||||
} else {
|
} else {
|
||||||
// Hide the cursor on that display.
|
// Hide the cursor on that display.
|
||||||
result = KMSDRM_RemoveCursorFromBO(display);
|
result = KMSDRM_RemoveCursorFromBO(display);
|
||||||
|
|
@ -327,6 +381,19 @@ static bool KMSDRM_ShowCursor(SDL_Cursor *cursor)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void drm_atomic_movecursor(const SDL_CursorData *curdata, uint16_t x, uint16_t y)
|
||||||
|
{
|
||||||
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||||
|
if (dispdata->cursor_plane) { // We can't move a non-existing cursor, but that's ok.
|
||||||
|
// Do we have a set of changes already in the making? If not, allocate a new one.
|
||||||
|
if (!dispdata->atomic_req) {
|
||||||
|
dispdata->atomic_req = KMSDRM_drmModeAtomicAlloc();
|
||||||
|
}
|
||||||
|
add_plane_property(dispdata->atomic_req, dispdata->cursor_plane, "CRTC_X", x - curdata->hot_x);
|
||||||
|
add_plane_property(dispdata->atomic_req, dispdata->cursor_plane, "CRTC_Y", y - curdata->hot_y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool KMSDRM_WarpMouseGlobal(float x, float y)
|
static bool KMSDRM_WarpMouseGlobal(float x, float y)
|
||||||
{
|
{
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
|
|
@ -340,17 +407,25 @@ static bool KMSDRM_WarpMouseGlobal(float x, float y)
|
||||||
|
|
||||||
// And now update the cursor graphic position on screen.
|
// And now update the cursor graphic position on screen.
|
||||||
if (dispdata->cursor_bo) {
|
if (dispdata->cursor_bo) {
|
||||||
const int rc = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, (int)x, (int)y);
|
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||||
if (rc < 0) {
|
SDL_VideoData *viddata = dev->internal;
|
||||||
return SDL_SetError("drmModeMoveCursor() failed: %s", strerror(-rc));
|
if (viddata->is_atomic) {
|
||||||
|
const SDL_CursorData *curdata = (const SDL_CursorData *) mouse->cur_cursor->internal;
|
||||||
|
drm_atomic_movecursor(curdata, (uint16_t) (int) x, (uint16_t) (int) y);
|
||||||
|
} else {
|
||||||
|
const int rc = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc.crtc->crtc_id, (int)x, (int)y);
|
||||||
|
if (rc < 0) {
|
||||||
|
return SDL_SetError("drmModeMoveCursor() failed: %s", strerror(-rc));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
return SDL_SetError("Cursor not initialized properly.");
|
return SDL_SetError("Cursor not initialized properly.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return SDL_SetError("No mouse or current cursor.");
|
return SDL_SetError("No mouse or current cursor.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool KMSDRM_WarpMouse(SDL_Window *window, float x, float y)
|
static bool KMSDRM_WarpMouse(SDL_Window *window, float x, float y)
|
||||||
|
|
@ -394,14 +469,27 @@ static bool KMSDRM_MoveCursor(SDL_Cursor *cursor)
|
||||||
if (mouse && mouse->cur_cursor && mouse->focus) {
|
if (mouse && mouse->cur_cursor && mouse->focus) {
|
||||||
SDL_Window *window = mouse->focus;
|
SDL_Window *window = mouse->focus;
|
||||||
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
|
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
|
||||||
|
SDL_VideoDevice *dev = SDL_GetVideoDevice();
|
||||||
|
SDL_VideoData *viddata = dev->internal;
|
||||||
|
|
||||||
if (!dispdata->cursor_bo) {
|
if (!dispdata->cursor_bo) {
|
||||||
return SDL_SetError("Cursor not initialized properly.");
|
return SDL_SetError("Cursor not initialized properly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const int rc = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, (int)mouse->x, (int)mouse->y);
|
if (viddata->is_atomic) {
|
||||||
if (rc < 0) {
|
/* !!! FIXME: Some programs expect cursor movement even while they don't do SwapWindow() calls,
|
||||||
return SDL_SetError("drmModeMoveCursor() failed: %s", strerror(-rc));
|
and since we ride on the atomic_commit() in SwapWindow() for cursor movement,
|
||||||
|
cursor won't move in these situations. We could do an atomic_commit() here
|
||||||
|
for each cursor movement request, but it cripples the movement to 30FPS,
|
||||||
|
so a future solution is needed. SDLPoP "QUIT?" menu is an example of this
|
||||||
|
situation. */
|
||||||
|
const SDL_CursorData *curdata = (const SDL_CursorData *) mouse->cur_cursor->internal;
|
||||||
|
drm_atomic_movecursor(curdata, (uint16_t) (int) mouse->x, (uint16_t) (int) mouse->y);
|
||||||
|
} else {
|
||||||
|
const int rc = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc.crtc->crtc_id, (int)mouse->x, (int)mouse->y);
|
||||||
|
if (rc < 0) {
|
||||||
|
return SDL_SetError("drmModeMoveCursor() failed: %s", strerror(-rc));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,25 @@
|
||||||
#include "SDL_kmsdrmdyn.h"
|
#include "SDL_kmsdrmdyn.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#define VOID2U64(x) ((uint64_t)(size_t)(x))
|
||||||
|
|
||||||
#ifndef EGL_PLATFORM_GBM_MESA
|
#ifndef EGL_PLATFORM_GBM_MESA
|
||||||
#define EGL_PLATFORM_GBM_MESA 0x31D7
|
#define EGL_PLATFORM_GBM_MESA 0x31D7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef EGL_SYNC_NATIVE_FENCE_ANDROID
|
||||||
|
#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EGL_SYNC_NATIVE_FENCE_FD_ANDROID
|
||||||
|
#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EGL_NO_NATIVE_FENCE_FD_ANDROID
|
||||||
|
#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// EGL implementation of SDL OpenGL support
|
// EGL implementation of SDL OpenGL support
|
||||||
|
|
||||||
void KMSDRM_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor)
|
void KMSDRM_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor)
|
||||||
|
|
@ -83,7 +98,263 @@ bool KMSDRM_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
static EGLSyncKHR create_fence(SDL_VideoDevice *_this, int fd)
|
||||||
|
{
|
||||||
|
EGLint attrib_list[] = {
|
||||||
|
EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
|
||||||
|
EGL_NONE,
|
||||||
|
};
|
||||||
|
|
||||||
|
EGLSyncKHR fence = _this->egl_data->eglCreateSyncKHR(_this->egl_data->egl_display, EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list);
|
||||||
|
|
||||||
|
SDL_assert(fence);
|
||||||
|
return fence;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************************/
|
||||||
|
/* Comments about buffer access protection mechanism (=fences) are the ones boxed. */
|
||||||
|
/* Also, DON'T remove the asserts: if a fence-related call fails, it's better that */
|
||||||
|
/* program exits immediately, or we could leave KMS waiting for a failed/missing */
|
||||||
|
/* fence forever. */
|
||||||
|
/***********************************************************************************/
|
||||||
|
static bool KMSDRM_GLES_SwapWindowFenced(SDL_VideoDevice *_this, SDL_Window * window)
|
||||||
|
{
|
||||||
|
SDL_WindowData *windata = ((SDL_WindowData *) window->internal);
|
||||||
|
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
|
||||||
|
KMSDRM_FBInfo *fb;
|
||||||
|
KMSDRM_PlaneInfo info;
|
||||||
|
bool modesetting = false;
|
||||||
|
|
||||||
|
SDL_zero(info);
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
/* Create the GPU-side FENCE OBJECT. It will be inserted into the */
|
||||||
|
/* GL CMDSTREAM exactly at the end of the gl commands that form a */
|
||||||
|
/* frame.(KMS will have to wait on it before doing a pageflip.) */
|
||||||
|
/******************************************************************/
|
||||||
|
dispdata->gpu_fence = create_fence(_this, EGL_NO_NATIVE_FENCE_FD_ANDROID);
|
||||||
|
SDL_assert(dispdata->gpu_fence);
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
/* eglSwapBuffers flushes the fence down the GL CMDSTREAM, so we */
|
||||||
|
/* know for sure it's there now. */
|
||||||
|
/* Also it marks, at EGL level, the buffer that we want to become */
|
||||||
|
/* the new front buffer. (Remember that won't really happen until */
|
||||||
|
/* we request a pageflip at the KMS level and it completes. */
|
||||||
|
/******************************************************************/
|
||||||
|
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
||||||
|
return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
/* EXPORT the GPU-side FENCE OBJECT to the fence INPUT FD, so we */
|
||||||
|
/* can pass it into the kernel. Atomic ioctl will pass the */
|
||||||
|
/* in-fence fd into the kernel, thus telling KMS that it has to */
|
||||||
|
/* wait for GPU to finish rendering the frame (remember where we */
|
||||||
|
/* put the fence in the GL CMDSTREAM) before doing the changes */
|
||||||
|
/* requested in the atomic ioct (the pageflip in this case). */
|
||||||
|
/* (We export the GPU-side FENCE OJECT to the fence INPUT FD now, */
|
||||||
|
/* not sooner, because now we are sure that the GPU-side fence is */
|
||||||
|
/* in the CMDSTREAM to be lifted when the CMDSTREAM to this point */
|
||||||
|
/* is completed). */
|
||||||
|
/******************************************************************/
|
||||||
|
dispdata->kms_in_fence_fd = _this->egl_data->eglDupNativeFenceFDANDROID (_this->egl_data->egl_display, dispdata->gpu_fence);
|
||||||
|
|
||||||
|
_this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->gpu_fence);
|
||||||
|
SDL_assert(dispdata->kms_in_fence_fd != -1);
|
||||||
|
|
||||||
|
/* Lock the buffer that is marked by eglSwapBuffers() to become the
|
||||||
|
next front buffer (so it can not be chosen by EGL as back buffer
|
||||||
|
to draw on), and get a handle to it to request the pageflip on it.
|
||||||
|
REMEMBER that gbm_surface_lock_front_buffer() ALWAYS has to be
|
||||||
|
called after eglSwapBuffers(). */
|
||||||
|
windata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(windata->gs);
|
||||||
|
if (!windata->next_bo) {
|
||||||
|
return SDL_SetError("Failed to lock frontbuffer");
|
||||||
|
}
|
||||||
|
fb = KMSDRM_FBFromBO(_this, windata->next_bo);
|
||||||
|
if (!fb) {
|
||||||
|
return SDL_SetError("Failed to get a new framebuffer from BO");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add the pageflip to the request list. */
|
||||||
|
info.plane = dispdata->display_plane;
|
||||||
|
info.crtc_id = dispdata->crtc.crtc->crtc_id;
|
||||||
|
info.fb_id = fb->fb_id;
|
||||||
|
info.src_w = window->w; // !!! FIXME: was windata->src_w in the original atomic patch
|
||||||
|
info.src_h = window->h; // !!! FIXME: was windata->src_h in the original atomic patch
|
||||||
|
info.crtc_w = dispdata->mode.hdisplay; // !!! FIXME: was windata->output_w in the original atomic patch
|
||||||
|
info.crtc_h = dispdata->mode.vdisplay; // !!! FIXME: was windata->output_h in the original atomic patch
|
||||||
|
info.crtc_x = 0; // !!! FIXME: was windata->output_x in the original atomic patch
|
||||||
|
|
||||||
|
drm_atomic_set_plane_props(&info);
|
||||||
|
|
||||||
|
/*****************************************************************/
|
||||||
|
/* Tell the display (KMS) that it will have to wait on the fence */
|
||||||
|
/* for the GPU-side FENCE. */
|
||||||
|
/* */
|
||||||
|
/* Since KMS is a kernel thing, we have to pass an FD into */
|
||||||
|
/* the kernel, and get another FD out of the kernel. */
|
||||||
|
/* */
|
||||||
|
/* 1) To pass the GPU-side fence into the kernel, we set the */
|
||||||
|
/* INPUT FD as the IN_FENCE_FD prop of the PRIMARY PLANE. */
|
||||||
|
/* This FD tells KMS (the kernel) to wait for the GPU-side fence.*/
|
||||||
|
/* */
|
||||||
|
/* 2) To get the KMS-side fence out of the kernel, we set the */
|
||||||
|
/* OUTPUT FD as the OUT_FEWNCE_FD prop of the CRTC. */
|
||||||
|
/* This FD will be later imported as a FENCE OBJECT which will be*/
|
||||||
|
/* used to tell the GPU to wait for KMS to complete the changes */
|
||||||
|
/* requested in atomic_commit (the pageflip in this case). */
|
||||||
|
/*****************************************************************/
|
||||||
|
if (dispdata->kms_in_fence_fd != -1)
|
||||||
|
{
|
||||||
|
add_plane_property(dispdata->atomic_req, dispdata->display_plane,
|
||||||
|
"IN_FENCE_FD", dispdata->kms_in_fence_fd);
|
||||||
|
add_crtc_property(dispdata->atomic_req, &dispdata->crtc,
|
||||||
|
"OUT_FENCE_PTR", VOID2U64(&dispdata->kms_out_fence_fd));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do we have a pending modesetting? If so, set the necessary
|
||||||
|
props so it's included in the incoming atomic commit. */
|
||||||
|
if (windata->egl_surface_dirty) {
|
||||||
|
// !!! FIXME: this CreateSurfaces call is what the legacy path does; it's not clear to me if the atomic paths need to do it too.
|
||||||
|
KMSDRM_CreateSurfaces(_this, window);
|
||||||
|
|
||||||
|
uint32_t blob_id;
|
||||||
|
SDL_VideoData *viddata = (SDL_VideoData *)_this->internal;
|
||||||
|
|
||||||
|
add_connector_property(dispdata->atomic_req, &dispdata->connector, "CRTC_ID", dispdata->crtc.crtc->crtc_id);
|
||||||
|
KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
|
||||||
|
add_crtc_property(dispdata->atomic_req, &dispdata->crtc, "MODE_ID", blob_id);
|
||||||
|
add_crtc_property(dispdata->atomic_req, &dispdata->crtc, "active", 1);
|
||||||
|
modesetting = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************/
|
||||||
|
/* Issue a non-blocking atomic commit: for triple buffering, */
|
||||||
|
/* this must not block so the game can start building another */
|
||||||
|
/* frame, even if the just-requested pageflip hasnt't completed. */
|
||||||
|
/*****************************************************************/
|
||||||
|
if (drm_atomic_commit(_this, false, modesetting)) {
|
||||||
|
return SDL_SetError("Failed to issue atomic commit on pageflip");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release the previous front buffer so EGL can chose it as back buffer
|
||||||
|
and render on it again. */
|
||||||
|
if (windata->bo) {
|
||||||
|
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
|
||||||
|
}
|
||||||
|
/* Take note of the buffer about to become front buffer, so next
|
||||||
|
time we come here we can free it like we just did with the previous
|
||||||
|
front buffer. */
|
||||||
|
windata->bo = windata->next_bo;
|
||||||
|
|
||||||
|
/****************************************************************/
|
||||||
|
/* Import the KMS-side FENCE OUTPUT FD from the kernel to the */
|
||||||
|
/* KMS-side FENCE OBJECT so we can use use it to fence the GPU. */
|
||||||
|
/****************************************************************/
|
||||||
|
dispdata->kms_fence = create_fence(_this, dispdata->kms_out_fence_fd);
|
||||||
|
SDL_assert(dispdata->kms_fence);
|
||||||
|
|
||||||
|
/****************************************************************/
|
||||||
|
/* "Delete" the fence OUTPUT FD, because we already have the */
|
||||||
|
/* KMS FENCE OBJECT, the fence itself is away from us, on the */
|
||||||
|
/* kernel side. */
|
||||||
|
/****************************************************************/
|
||||||
|
dispdata->kms_out_fence_fd = -1;
|
||||||
|
|
||||||
|
/*****************************************************************/
|
||||||
|
/* Tell the GPU to wait on the fence for the KMS-side FENCE, */
|
||||||
|
/* which means waiting until the requested pageflip is completed.*/
|
||||||
|
/*****************************************************************/
|
||||||
|
_this->egl_data->eglWaitSyncKHR(_this->egl_data->egl_display, dispdata->kms_fence, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool KMSDRM_GLES_SwapWindowDoubleBuffered(SDL_VideoDevice *_this, SDL_Window * window)
|
||||||
|
{
|
||||||
|
SDL_WindowData *windata = ((SDL_WindowData *) window->internal);
|
||||||
|
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
|
||||||
|
KMSDRM_FBInfo *fb;
|
||||||
|
KMSDRM_PlaneInfo info;
|
||||||
|
bool modesetting = false;
|
||||||
|
|
||||||
|
SDL_zero(info);
|
||||||
|
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* In double-buffer mode, atomic_commit will always be synchronous/blocking (ie: */
|
||||||
|
/* won't return until the requested changes are really done). */
|
||||||
|
/* Also, there's no need to fence KMS or the GPU, because we won't be entering */
|
||||||
|
/* game loop again (hence not building or executing a new cmdstring) until */
|
||||||
|
/* pageflip is done, so we don't need to protect the KMS/GPU access to the buffer.*/
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
/* Mark, at EGL level, the buffer that we want to become the new front buffer.
|
||||||
|
It won't really happen until we request a pageflip at the KMS level and it
|
||||||
|
completes. */
|
||||||
|
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
||||||
|
return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
||||||
|
}
|
||||||
|
/* Lock the buffer that is marked by eglSwapBuffers() to become the next front buffer
|
||||||
|
(so it can not be chosen by EGL as back buffer to draw on), and get a handle to it,
|
||||||
|
to request the pageflip on it. */
|
||||||
|
windata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(windata->gs);
|
||||||
|
if (!windata->next_bo) {
|
||||||
|
return SDL_SetError("Failed to lock frontbuffer");
|
||||||
|
}
|
||||||
|
fb = KMSDRM_FBFromBO(_this, windata->next_bo);
|
||||||
|
if (!fb) {
|
||||||
|
return SDL_SetError("Failed to get a new framebuffer BO");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add the pageflip to the request list. */
|
||||||
|
info.plane = dispdata->display_plane;
|
||||||
|
info.crtc_id = dispdata->crtc.crtc->crtc_id;
|
||||||
|
info.fb_id = fb->fb_id;
|
||||||
|
info.src_w = window->w; // !!! FIXME: was windata->src_w in the original atomic patch
|
||||||
|
info.src_h = window->h; // !!! FIXME: was windata->src_h in the original atomic patch
|
||||||
|
info.crtc_w = dispdata->mode.hdisplay; // !!! FIXME: was windata->output_w in the original atomic patch
|
||||||
|
info.crtc_h = dispdata->mode.vdisplay; // !!! FIXME: was windata->output_h in the original atomic patch
|
||||||
|
info.crtc_x = 0; // !!! FIXME: was windata->output_x in the original atomic patch
|
||||||
|
|
||||||
|
drm_atomic_set_plane_props(&info);
|
||||||
|
|
||||||
|
/* Do we have a pending modesetting? If so, set the necessary
|
||||||
|
props so it's included in the incoming atomic commit. */
|
||||||
|
if (windata->egl_surface_dirty) {
|
||||||
|
// !!! FIXME: this CreateSurfaces call is what the legacy path does; it's not clear to me if the atomic paths need to do it too.
|
||||||
|
KMSDRM_CreateSurfaces(_this, window);
|
||||||
|
|
||||||
|
uint32_t blob_id;
|
||||||
|
|
||||||
|
SDL_VideoData *viddata = (SDL_VideoData *)_this->internal;
|
||||||
|
|
||||||
|
add_connector_property(dispdata->atomic_req, &dispdata->connector, "CRTC_ID", dispdata->crtc.crtc->crtc_id);
|
||||||
|
KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
|
||||||
|
add_crtc_property(dispdata->atomic_req, &dispdata->crtc, "MODE_ID", blob_id);
|
||||||
|
add_crtc_property(dispdata->atomic_req, &dispdata->crtc, "active", 1);
|
||||||
|
modesetting = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Issue the one and only atomic commit where all changes will be requested!
|
||||||
|
Blocking for double buffering: won't return until completed. */
|
||||||
|
if (drm_atomic_commit(_this, true, modesetting)) {
|
||||||
|
return SDL_SetError("Failed to issue atomic commit on pageflip");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release last front buffer so EGL can chose it as back buffer and render on it again. */
|
||||||
|
if (windata->bo) {
|
||||||
|
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Take note of current front buffer, so we can free it next time we come here. */
|
||||||
|
windata->bo = windata->next_bo;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool KMSDRM_GLES_SwapWindowLegacy(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
{
|
{
|
||||||
SDL_WindowData *windata = window->internal;
|
SDL_WindowData *windata = window->internal;
|
||||||
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
|
SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window);
|
||||||
|
|
@ -116,13 +387,12 @@ bool KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
// Release the previous front buffer
|
// Release the previous front buffer
|
||||||
if (windata->bo) {
|
if (windata->bo) {
|
||||||
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
|
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
|
||||||
windata->bo = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
windata->bo = windata->next_bo;
|
windata->bo = windata->next_bo;
|
||||||
|
|
||||||
/* Mark a buffer to become the next front buffer.
|
/* Mark a buffer to become the next front buffer.
|
||||||
This won't happen until pagelip completes. */
|
This won't happen until pageflip completes. */
|
||||||
if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display,
|
if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display,
|
||||||
windata->egl_surface))) {
|
windata->egl_surface))) {
|
||||||
return SDL_SetError("eglSwapBuffers failed");
|
return SDL_SetError("eglSwapBuffers failed");
|
||||||
|
|
@ -147,8 +417,8 @@ bool KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
drmModePageFlip can be used the CRTC has to be configured to use
|
drmModePageFlip can be used the CRTC has to be configured to use
|
||||||
the current connector and mode with drmModeSetCrtc */
|
the current connector and mode with drmModeSetCrtc */
|
||||||
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd,
|
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd,
|
||||||
dispdata->crtc->crtc_id, fb_info->fb_id, 0, 0,
|
dispdata->crtc.crtc->crtc_id, fb_info->fb_id, 0, 0,
|
||||||
&dispdata->connector->connector_id, 1, &dispdata->mode);
|
&dispdata->connector.connector->connector_id, 1, &dispdata->mode);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return SDL_SetError("Could not set videomode on CRTC.");
|
return SDL_SetError("Could not set videomode on CRTC.");
|
||||||
|
|
@ -170,7 +440,7 @@ bool KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
flip_flags |= DRM_MODE_PAGE_FLIP_ASYNC;
|
flip_flags |= DRM_MODE_PAGE_FLIP_ASYNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id,
|
ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc.crtc->crtc_id,
|
||||||
fb_info->fb_id, flip_flags, &windata->waiting_for_flip);
|
fb_info->fb_id, flip_flags, &windata->waiting_for_flip);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
|
@ -198,6 +468,26 @@ bool KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window * window)
|
||||||
|
{
|
||||||
|
SDL_WindowData *windata = (SDL_WindowData *) window->internal;
|
||||||
|
|
||||||
|
if (windata->swap_window == NULL) {
|
||||||
|
SDL_VideoData *viddata = _this->internal;
|
||||||
|
if (viddata->is_atomic) {
|
||||||
|
// We want the fenced version by default, but it needs extensions.
|
||||||
|
if ( (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, false)) || (!SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_ANDROID_native_fence_sync")) ) {
|
||||||
|
windata->swap_window = KMSDRM_GLES_SwapWindowDoubleBuffered;
|
||||||
|
} else {
|
||||||
|
windata->swap_window = KMSDRM_GLES_SwapWindowFenced;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
windata->swap_window = KMSDRM_GLES_SwapWindowLegacy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return windata->swap_window(_this, window);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_EGL_MakeCurrent_impl(KMSDRM)
|
SDL_EGL_MakeCurrent_impl(KMSDRM)
|
||||||
|
|
||||||
#endif // SDL_VIDEO_DRIVER_KMSDRM
|
#endif // SDL_VIDEO_DRIVER_KMSDRM
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,16 @@ SDL_KMSDRM_SYM_OPT(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane))
|
||||||
SDL_KMSDRM_SYM_OPT(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane))
|
SDL_KMSDRM_SYM_OPT(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane))
|
||||||
SDL_KMSDRM_SYM_OPT(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *bo, int plane))
|
SDL_KMSDRM_SYM_OPT(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *bo, int plane))
|
||||||
|
|
||||||
|
|
||||||
|
SDL_KMSDRM_MODULE(ATOMIC)
|
||||||
|
SDL_KMSDRM_SYM(int,drmIoctl,(int fd, unsigned long request, void *arg))
|
||||||
|
SDL_KMSDRM_SYM(drmModeAtomicReqPtr,drmModeAtomicAlloc,(void))
|
||||||
|
SDL_KMSDRM_SYM(void,drmModeAtomicFree,(drmModeAtomicReqPtr req))
|
||||||
|
SDL_KMSDRM_SYM(int,drmModeAtomicCommit,(int fd,drmModeAtomicReqPtr req,uint32_t flags,void *user_data))
|
||||||
|
SDL_KMSDRM_SYM(int,drmModeAtomicAddProperty,(drmModeAtomicReqPtr req,uint32_t object_id,uint32_t property_id,uint64_t value))
|
||||||
|
SDL_KMSDRM_SYM(int,drmModeCreatePropertyBlob,(int fd,const void *data,size_t size,uint32_t *id))
|
||||||
|
|
||||||
|
|
||||||
#undef SDL_KMSDRM_MODULE
|
#undef SDL_KMSDRM_MODULE
|
||||||
#undef SDL_KMSDRM_SYM
|
#undef SDL_KMSDRM_SYM
|
||||||
#undef SDL_KMSDRM_SYM_CONST
|
#undef SDL_KMSDRM_SYM_CONST
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,14 @@ static char kmsdrm_dri_devname[8];
|
||||||
static int kmsdrm_dri_devnamesize = 0;
|
static int kmsdrm_dri_devnamesize = 0;
|
||||||
static char kmsdrm_dri_cardpath[32];
|
static char kmsdrm_dri_cardpath[32];
|
||||||
|
|
||||||
|
/* for older KMSDRM headers... */
|
||||||
|
#ifndef DRM_FORMAT_MOD_VENDOR_NONE
|
||||||
|
#define DRM_FORMAT_MOD_VENDOR_NONE 0
|
||||||
|
#endif
|
||||||
|
#ifndef DRM_FORMAT_MOD_LINEAR
|
||||||
|
#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef EGL_PLATFORM_GBM_MESA
|
#ifndef EGL_PLATFORM_GBM_MESA
|
||||||
#define EGL_PLATFORM_GBM_MESA 0x31D7
|
#define EGL_PLATFORM_GBM_MESA 0x31D7
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -191,6 +199,409 @@ static void CalculateRefreshRate(drmModeModeInfo *mode, int *numerator, int *den
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int add_connector_property(drmModeAtomicReq *req, connector *conn, const char *name, uint64_t value)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
int prop_id = 0;
|
||||||
|
|
||||||
|
for (i = 0 ; i < conn->props->count_props ; i++) {
|
||||||
|
if (SDL_strcmp(conn->props_info[i]->name, name) == 0) {
|
||||||
|
prop_id = conn->props_info[i]->prop_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop_id < 0) {
|
||||||
|
SDL_SetError("no connector property: %s", name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return KMSDRM_drmModeAtomicAddProperty(req, conn->connector->connector_id, prop_id, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_crtc_property(drmModeAtomicReq *req, crtc *c, const char *name, uint64_t value)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
int prop_id = -1;
|
||||||
|
|
||||||
|
for (i = 0 ; i < c->props->count_props ; i++) {
|
||||||
|
if (SDL_strcmp(c->props_info[i]->name, name) == 0) {
|
||||||
|
prop_id = c->props_info[i]->prop_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop_id < 0) {
|
||||||
|
SDL_SetError("no crtc property: %s", name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return KMSDRM_drmModeAtomicAddProperty(req, c->crtc->crtc_id, prop_id, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_plane_property(drmModeAtomicReq *req, plane *p, const char *name, uint64_t value)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
int prop_id = -1;
|
||||||
|
|
||||||
|
for (i = 0 ; i < p->props->count_props ; i++) {
|
||||||
|
if (SDL_strcmp(p->props_info[i]->name, name) == 0) {
|
||||||
|
prop_id = p->props_info[i]->prop_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop_id < 0) {
|
||||||
|
SDL_SetError("no plane property: %s", name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return KMSDRM_drmModeAtomicAddProperty(req, p->plane->plane_id, prop_id, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
static void print_plane_info(_THIS, drmModePlanePtr plane)
|
||||||
|
{
|
||||||
|
char *plane_type;
|
||||||
|
drmModeRes *resources;
|
||||||
|
uint32_t type = 0;
|
||||||
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd,
|
||||||
|
plane->plane_id, DRM_MODE_OBJECT_PLANE);
|
||||||
|
|
||||||
|
/* Search the plane props for the plane type. */
|
||||||
|
for (i = 0; i < props->count_props; i++) {
|
||||||
|
drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd, props->props[i]);
|
||||||
|
if ((strcmp(p->name, "type") == 0)) {
|
||||||
|
type = props->prop_values[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
KMSDRM_drmModeFreeProperty(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case DRM_PLANE_TYPE_OVERLAY:
|
||||||
|
plane_type = "overlay";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DRM_PLANE_TYPE_PRIMARY:
|
||||||
|
plane_type = "primary";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DRM_PLANE_TYPE_CURSOR:
|
||||||
|
plane_type = "cursor";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Remember that to present a plane on screen, it has to be
|
||||||
|
connected to a CRTC so the CRTC scans it,
|
||||||
|
scales it, etc... and presents it on screen. */
|
||||||
|
|
||||||
|
/* Now we look for the CRTCs supported by the plane. */
|
||||||
|
resources = KMSDRM_drmModeGetResources(viddata->drm_fd);
|
||||||
|
if (!resources)
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf("--PLANE ID: %d\nPLANE TYPE: %s\nCRTC READING THIS PLANE: %d\nCRTCS SUPPORTED BY THIS PLANE: ", plane->plane_id, plane_type, plane->crtc_id);
|
||||||
|
for (i = 0; i < resources->count_crtcs; i++) {
|
||||||
|
if (plane->possible_crtcs & (1 << i)) {
|
||||||
|
uint32_t crtc_id = resources->crtcs[i];
|
||||||
|
printf ("%d", crtc_id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf ("\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void get_planes_info(_THIS)
|
||||||
|
{
|
||||||
|
drmModePlaneResPtr plane_resources;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||||
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||||
|
|
||||||
|
plane_resources = KMSDRM_drmModeGetPlaneResources(viddata->drm_fd);
|
||||||
|
if (!plane_resources) {
|
||||||
|
printf("drmModeGetPlaneResources failed: %s\n", strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("--Number of planes found: %d-- \n", plane_resources->count_planes);
|
||||||
|
printf("--Usable CRTC that we have chosen: %d-- \n", dispdata->crtc.crtc->crtc_id);
|
||||||
|
|
||||||
|
/* Iterate on all the available planes. */
|
||||||
|
for (i = 0; (i < plane_resources->count_planes); i++) {
|
||||||
|
|
||||||
|
uint32_t plane_id = plane_resources->planes[i];
|
||||||
|
|
||||||
|
drmModePlanePtr plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id);
|
||||||
|
if (!plane) {
|
||||||
|
printf("drmModeGetPlane(%u) failed: %s\n", plane_id, strerror(errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print plane info. */
|
||||||
|
print_plane_info(_this, plane);
|
||||||
|
KMSDRM_drmModeFreePlane(plane);
|
||||||
|
}
|
||||||
|
|
||||||
|
KMSDRM_drmModeFreePlaneResources(plane_resources);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Get the plane_id of a plane that is of the specified plane type (primary,
|
||||||
|
overlay, cursor...) and can use specified CRTC. */
|
||||||
|
static int get_plane_id(SDL_VideoDevice *_this, unsigned int crtc_id, uint32_t plane_type)
|
||||||
|
{
|
||||||
|
drmModeRes *resources = NULL;
|
||||||
|
drmModePlaneResPtr plane_resources = NULL;
|
||||||
|
uint32_t i, j;
|
||||||
|
unsigned int crtc_index = 0;
|
||||||
|
int ret = -EINVAL;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->internal);
|
||||||
|
|
||||||
|
resources = KMSDRM_drmModeGetResources(viddata->drm_fd);
|
||||||
|
|
||||||
|
/* Get the crtc_index for the current CRTC.
|
||||||
|
It's needed to find out if a plane supports the CRTC. */
|
||||||
|
for (i = 0; i < resources->count_crtcs; i++) {
|
||||||
|
if (resources->crtcs[i] == crtc_id) {
|
||||||
|
crtc_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plane_resources = KMSDRM_drmModeGetPlaneResources(viddata->drm_fd);
|
||||||
|
if (!plane_resources) {
|
||||||
|
return SDL_SetError("drmModeGetPlaneResources failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Iterate on all the available planes. */
|
||||||
|
for (i = 0; (i < plane_resources->count_planes) && !found; i++) {
|
||||||
|
|
||||||
|
uint32_t plane_id = plane_resources->planes[i];
|
||||||
|
|
||||||
|
drmModePlanePtr _plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id);
|
||||||
|
if (!_plane) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See if the current CRTC is available for this plane. */
|
||||||
|
if (_plane->possible_crtcs & (1 << crtc_index)) {
|
||||||
|
|
||||||
|
drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(
|
||||||
|
viddata->drm_fd, plane_id, DRM_MODE_OBJECT_PLANE);
|
||||||
|
ret = plane_id;
|
||||||
|
|
||||||
|
/* Iterate on the plane props to find the type of the plane,
|
||||||
|
to see if it's of the type we want. */
|
||||||
|
for (j = 0; j < props->count_props; j++) {
|
||||||
|
|
||||||
|
drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
||||||
|
props->props[j]);
|
||||||
|
|
||||||
|
if ((strcmp(p->name, "type") == 0) && (props->prop_values[j] == plane_type)) {
|
||||||
|
/* found our plane, use that: */
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
KMSDRM_drmModeFreeProperty(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
KMSDRM_drmModeFreeObjectProperties(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
KMSDRM_drmModeFreePlane(_plane);
|
||||||
|
}
|
||||||
|
|
||||||
|
KMSDRM_drmModeFreePlaneResources(plane_resources);
|
||||||
|
KMSDRM_drmModeFreeResources(resources);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setup a plane and it's props. */
|
||||||
|
bool setup_plane(SDL_VideoDevice *_this, plane **_plane, uint32_t plane_type)
|
||||||
|
{
|
||||||
|
uint32_t plane_id;
|
||||||
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->internal);
|
||||||
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
|
*_plane = SDL_calloc(1, sizeof(**_plane));
|
||||||
|
if (!(*_plane)) {
|
||||||
|
ret = false;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get plane ID for a given CRTC and plane type. */
|
||||||
|
plane_id = get_plane_id(_this, dispdata->crtc.crtc->crtc_id, plane_type);
|
||||||
|
|
||||||
|
if (!plane_id) {
|
||||||
|
ret = SDL_SetError("Invalid Plane ID");
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the DRM plane itself. */
|
||||||
|
(*_plane)->plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id);
|
||||||
|
|
||||||
|
/* Get the DRM plane properties. */
|
||||||
|
if ((*_plane)->plane) {
|
||||||
|
unsigned int i;
|
||||||
|
(*_plane)->props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd,
|
||||||
|
(*_plane)->plane->plane_id, DRM_MODE_OBJECT_PLANE);
|
||||||
|
(*_plane)->props_info = SDL_calloc((*_plane)->props->count_props, sizeof(*(*_plane)->props_info));
|
||||||
|
|
||||||
|
if ( !((*_plane)->props_info) ) {
|
||||||
|
ret = false;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < (*_plane)->props->count_props; i++) {
|
||||||
|
(*_plane)->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd, (*_plane)->props->props[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if (!ret) {
|
||||||
|
if (*_plane) {
|
||||||
|
SDL_free(*_plane);
|
||||||
|
*_plane = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free a plane and it's props. */
|
||||||
|
void free_plane(plane **_plane)
|
||||||
|
{
|
||||||
|
if (*_plane) {
|
||||||
|
if ((*_plane)->plane) {
|
||||||
|
KMSDRM_drmModeFreePlane((*_plane)->plane);
|
||||||
|
(*_plane)->plane = NULL;
|
||||||
|
}
|
||||||
|
if ((*_plane)->props_info) {
|
||||||
|
SDL_free((*_plane)->props_info);
|
||||||
|
(*_plane)->props_info = NULL;
|
||||||
|
}
|
||||||
|
SDL_free(*_plane);
|
||||||
|
*_plane = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************************/
|
||||||
|
/* The most important ATOMIC fn of the backend. */
|
||||||
|
/* A PLANE reads a BUFFER, and a CRTC reads a PLANE and sends it's contents */
|
||||||
|
/* over to a CONNECTOR->ENCODER system (several CONNECTORS can be connected */
|
||||||
|
/* to the same PLANE). */
|
||||||
|
/* Think of a plane as a "frame" sorrounding a picture, where the "picture" */
|
||||||
|
/* is the buffer, and we move the "frame" from a picture to another, */
|
||||||
|
/* and the one that has the "frame" is the one sent over to the screen */
|
||||||
|
/* via the CONNECTOR->ENCODER system. */
|
||||||
|
/* Think of a PLANE as being "in the middle", it's the CENTRAL part */
|
||||||
|
/* bewteen the CRTC and the BUFFER that is shown on screen. */
|
||||||
|
/* What we do here is connect a PLANE to a CRTC and a BUFFER. */
|
||||||
|
/* -ALWAYS set the CRTC_ID and FB_ID attribs of a plane at the same time, */
|
||||||
|
/* meaning IN THE SAME atomic request. */
|
||||||
|
/* -And NEVER destroy a GBM surface whose buffers are being read by a plane: */
|
||||||
|
/* first, move the plane away from those buffers and ONLY THEN destroy the */
|
||||||
|
/* buffers and/or the GBM surface containig them. */
|
||||||
|
/**********************************************************************************/
|
||||||
|
void
|
||||||
|
drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info)
|
||||||
|
{
|
||||||
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||||
|
|
||||||
|
/* Do we have a set of changes already in the making? If not, allocate a new one. */
|
||||||
|
if (!dispdata->atomic_req) {
|
||||||
|
dispdata->atomic_req = KMSDRM_drmModeAtomicAlloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "FB_ID", info->fb_id);
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "CRTC_ID", info->crtc_id);
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "SRC_W", info->src_w << 16);
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "SRC_H", info->src_h << 16);
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "SRC_X", info->src_x);
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "SRC_Y", info->src_y);
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "CRTC_W", info->crtc_w);
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "CRTC_H", info->crtc_h);
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "CRTC_X", info->crtc_x);
|
||||||
|
add_plane_property(dispdata->atomic_req, info->plane, "CRTC_Y", info->crtc_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int drm_atomic_commit(SDL_VideoDevice *_this, bool blocking, bool allow_modeset)
|
||||||
|
{
|
||||||
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||||
|
SDL_VideoData *viddata = ((SDL_VideoData *)_this->internal);
|
||||||
|
uint32_t atomic_flags = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!blocking) {
|
||||||
|
atomic_flags |= DRM_MODE_ATOMIC_NONBLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allow_modeset) {
|
||||||
|
atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Never issue a new atomic commit if previous has not yet completed,
|
||||||
|
or it will error. */
|
||||||
|
drm_atomic_waitpending(_this);
|
||||||
|
|
||||||
|
ret = KMSDRM_drmModeAtomicCommit(viddata->drm_fd, dispdata->atomic_req,
|
||||||
|
atomic_flags, NULL);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
SDL_SetError("Atomic commit failed, returned %d.", ret);
|
||||||
|
/* Uncomment this for fast-debugging */
|
||||||
|
#if 0
|
||||||
|
printf("ATOMIC COMMIT FAILED: %s.\n", strerror(errno));
|
||||||
|
#endif
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dispdata->kms_in_fence_fd != -1) {
|
||||||
|
close(dispdata->kms_in_fence_fd);
|
||||||
|
dispdata->kms_in_fence_fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
KMSDRM_drmModeAtomicFree(dispdata->atomic_req);
|
||||||
|
dispdata->atomic_req = NULL;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drm_atomic_waitpending(SDL_VideoDevice *_this)
|
||||||
|
{
|
||||||
|
SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
|
||||||
|
|
||||||
|
/* Will return immediately if we have already destroyed the fence, because we NULL-ify it just after.
|
||||||
|
Also, will return immediately in double-buffer mode, because kms_fence will alsawys be NULL. */
|
||||||
|
if (dispdata->kms_fence) {
|
||||||
|
EGLint status;
|
||||||
|
|
||||||
|
do {
|
||||||
|
status = _this->egl_data->eglClientWaitSyncKHR(_this->egl_data->egl_display,
|
||||||
|
dispdata->kms_fence, 0, EGL_FOREVER_KHR);
|
||||||
|
} while (status != EGL_CONDITION_SATISFIED_KHR);
|
||||||
|
|
||||||
|
_this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->kms_fence);
|
||||||
|
dispdata->kms_fence = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool KMSDRM_Available(void)
|
static bool KMSDRM_Available(void)
|
||||||
{
|
{
|
||||||
#ifdef SDL_PLATFORM_OPENBSD
|
#ifdef SDL_PLATFORM_OPENBSD
|
||||||
|
|
@ -519,14 +930,14 @@ static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display,
|
||||||
{
|
{
|
||||||
|
|
||||||
SDL_DisplayData *dispdata = display->internal;
|
SDL_DisplayData *dispdata = display->internal;
|
||||||
drmModeConnector *connector = dispdata->connector;
|
drmModeConnector *conn = dispdata->connector.connector;
|
||||||
|
|
||||||
SDL_DisplayMode closest;
|
SDL_DisplayMode closest;
|
||||||
drmModeModeInfo *drm_mode;
|
drmModeModeInfo *drm_mode;
|
||||||
|
|
||||||
if (SDL_GetClosestFullscreenDisplayMode(display->id, width, height, 0.0f, false, &closest)) {
|
if (SDL_GetClosestFullscreenDisplayMode(display->id, width, height, 0.0f, false, &closest)) {
|
||||||
const SDL_DisplayModeData *modedata = closest.internal;
|
const SDL_DisplayModeData *modedata = closest.internal;
|
||||||
drm_mode = &connector->modes[modedata->mode_index];
|
drm_mode = &conn->modes[modedata->mode_index];
|
||||||
return drm_mode;
|
return drm_mode;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -542,6 +953,11 @@ static bool KMSDRM_DropMaster(SDL_VideoDevice *_this)
|
||||||
{
|
{
|
||||||
SDL_VideoData *viddata = _this->internal;
|
SDL_VideoData *viddata = _this->internal;
|
||||||
|
|
||||||
|
if (viddata->is_atomic) { // turn off atomic support until we are in control again.
|
||||||
|
KMSDRM_drmSetClientCap(viddata->drm_fd, DRM_CLIENT_CAP_ATOMIC, 0);
|
||||||
|
KMSDRM_drmSetClientCap(viddata->drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if we have DRM master to begin with */
|
/* Check if we have DRM master to begin with */
|
||||||
if (KMSDRM_drmAuthMagic(viddata->drm_fd, 0) == -EACCES) {
|
if (KMSDRM_drmAuthMagic(viddata->drm_fd, 0) == -EACCES) {
|
||||||
/* Nope, nothing to do then */
|
/* Nope, nothing to do then */
|
||||||
|
|
@ -568,15 +984,15 @@ static void KMSDRM_DeinitDisplays(SDL_VideoDevice *_this)
|
||||||
dispdata = SDL_GetDisplayDriverData(displays[i]);
|
dispdata = SDL_GetDisplayDriverData(displays[i]);
|
||||||
|
|
||||||
// Free connector
|
// Free connector
|
||||||
if (dispdata && dispdata->connector) {
|
if (dispdata && dispdata->connector.connector) {
|
||||||
KMSDRM_drmModeFreeConnector(dispdata->connector);
|
KMSDRM_drmModeFreeConnector(dispdata->connector.connector);
|
||||||
dispdata->connector = NULL;
|
dispdata->connector.connector = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free CRTC
|
// Free CRTC
|
||||||
if (dispdata && dispdata->crtc) {
|
if (dispdata && dispdata->crtc.crtc) {
|
||||||
KMSDRM_drmModeFreeCrtc(dispdata->crtc);
|
KMSDRM_drmModeFreeCrtc(dispdata->crtc.crtc);
|
||||||
dispdata->crtc = NULL;
|
dispdata->crtc.crtc = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_free(displays);
|
SDL_free(displays);
|
||||||
|
|
@ -795,14 +1211,14 @@ static int KMSDRM_CrtcGetOrientation(uint32_t drm_fd, uint32_t crtc_id)
|
||||||
|
|
||||||
/* Gets a DRM connector, builds an SDL_Display with it, and adds it to the
|
/* Gets a DRM connector, builds an SDL_Display with it, and adds it to the
|
||||||
list of SDL Displays in _this->displays[] */
|
list of SDL Displays in _this->displays[] */
|
||||||
static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connector, drmModeRes *resources)
|
static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *conn, drmModeRes *resources)
|
||||||
{
|
{
|
||||||
SDL_VideoData *viddata = _this->internal;
|
SDL_VideoData *viddata = _this->internal;
|
||||||
SDL_DisplayData *dispdata = NULL;
|
SDL_DisplayData *dispdata = NULL;
|
||||||
SDL_VideoDisplay display = { 0 };
|
SDL_VideoDisplay display = { 0 };
|
||||||
SDL_DisplayModeData *modedata = NULL;
|
SDL_DisplayModeData *modedata = NULL;
|
||||||
drmModeEncoder *encoder = NULL;
|
drmModeEncoder *encoder = NULL;
|
||||||
drmModeCrtc *crtc = NULL;
|
drmModeCrtc *_crtc = NULL;
|
||||||
const char *connector_type = NULL;
|
const char *connector_type = NULL;
|
||||||
SDL_DisplayID display_id;
|
SDL_DisplayID display_id;
|
||||||
SDL_PropertiesID display_properties;
|
SDL_PropertiesID display_properties;
|
||||||
|
|
@ -823,6 +1239,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
to sane values. */
|
to sane values. */
|
||||||
dispdata->cursor_bo = NULL;
|
dispdata->cursor_bo = NULL;
|
||||||
dispdata->cursor_bo_drm_fd = -1;
|
dispdata->cursor_bo_drm_fd = -1;
|
||||||
|
dispdata->kms_out_fence_fd = -1;
|
||||||
|
|
||||||
/* Since we create and show the default cursor on KMSDRM_InitMouse(),
|
/* Since we create and show the default cursor on KMSDRM_InitMouse(),
|
||||||
and we call KMSDRM_InitMouse() when we create a window, we have to know
|
and we call KMSDRM_InitMouse() when we create a window, we have to know
|
||||||
|
|
@ -839,7 +1256,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoder->encoder_id == connector->encoder_id) {
|
if (encoder->encoder_id == conn->encoder_id) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -857,13 +1274,13 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < connector->count_encoders; j++) {
|
for (j = 0; j < conn->count_encoders; j++) {
|
||||||
if (connector->encoders[j] == encoder->encoder_id) {
|
if (conn->encoders[j] == encoder->encoder_id) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j != connector->count_encoders) {
|
if (j != conn->count_encoders) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -878,21 +1295,21 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find a CRTC connected to this encoder
|
// Try to find a CRTC connected to this encoder
|
||||||
crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
|
_crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
|
||||||
|
|
||||||
/* If no CRTC was connected to the encoder, find the first CRTC
|
/* If no CRTC was connected to the encoder, find the first CRTC
|
||||||
that is supported by the encoder, and use that. */
|
that is supported by the encoder, and use that. */
|
||||||
if (!crtc) {
|
if (!_crtc) {
|
||||||
for (i = 0; i < resources->count_crtcs; i++) {
|
for (i = 0; i < resources->count_crtcs; i++) {
|
||||||
if (encoder->possible_crtcs & (1 << i)) {
|
if (encoder->possible_crtcs & (1 << i)) {
|
||||||
encoder->crtc_id = resources->crtcs[i];
|
encoder->crtc_id = resources->crtcs[i];
|
||||||
crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
|
_crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!crtc) {
|
if (!_crtc) {
|
||||||
ret = SDL_SetError("No CRTC found for connector.");
|
ret = SDL_SetError("No CRTC found for connector.");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
@ -900,10 +1317,10 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
// Find the index of the mode attached to this CRTC
|
// Find the index of the mode attached to this CRTC
|
||||||
mode_index = -1;
|
mode_index = -1;
|
||||||
|
|
||||||
for (i = 0; i < connector->count_modes; i++) {
|
for (i = 0; i < conn->count_modes; i++) {
|
||||||
drmModeModeInfo *mode = &connector->modes[i];
|
drmModeModeInfo *mode = &conn->modes[i];
|
||||||
|
|
||||||
if (!SDL_memcmp(mode, &crtc->mode, sizeof(crtc->mode))) {
|
if (!SDL_memcmp(mode, &_crtc->mode, sizeof(_crtc->mode))) {
|
||||||
mode_index = i;
|
mode_index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -913,8 +1330,8 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
int current_area, largest_area = 0;
|
int current_area, largest_area = 0;
|
||||||
|
|
||||||
// Find the preferred mode or the highest resolution mode
|
// Find the preferred mode or the highest resolution mode
|
||||||
for (i = 0; i < connector->count_modes; i++) {
|
for (i = 0; i < conn->count_modes; i++) {
|
||||||
drmModeModeInfo *mode = &connector->modes[i];
|
drmModeModeInfo *mode = &conn->modes[i];
|
||||||
|
|
||||||
if (mode->type & DRM_MODE_TYPE_PREFERRED) {
|
if (mode->type & DRM_MODE_TYPE_PREFERRED) {
|
||||||
mode_index = i;
|
mode_index = i;
|
||||||
|
|
@ -928,7 +1345,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mode_index != -1) {
|
if (mode_index != -1) {
|
||||||
crtc->mode = connector->modes[mode_index];
|
_crtc->mode = conn->modes[mode_index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -948,9 +1365,9 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
/* Get the mode currently setup for this display,
|
/* Get the mode currently setup for this display,
|
||||||
which is the mode currently setup on the CRTC
|
which is the mode currently setup on the CRTC
|
||||||
we found for the active connector. */
|
we found for the active connector. */
|
||||||
dispdata->mode = crtc->mode;
|
dispdata->mode = _crtc->mode;
|
||||||
dispdata->original_mode = crtc->mode;
|
dispdata->original_mode = _crtc->mode;
|
||||||
dispdata->fullscreen_mode = crtc->mode;
|
dispdata->fullscreen_mode = _crtc->mode;
|
||||||
|
|
||||||
if (dispdata->mode.hdisplay == 0 || dispdata->mode.vdisplay == 0) {
|
if (dispdata->mode.hdisplay == 0 || dispdata->mode.vdisplay == 0) {
|
||||||
ret = SDL_SetError("Couldn't get a valid connector videomode.");
|
ret = SDL_SetError("Couldn't get a valid connector videomode.");
|
||||||
|
|
@ -958,24 +1375,48 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the connector and crtc for this display.
|
// Store the connector and crtc for this display.
|
||||||
dispdata->connector = connector;
|
dispdata->connector.connector = conn;
|
||||||
dispdata->crtc = crtc;
|
dispdata->crtc.crtc = _crtc;
|
||||||
|
|
||||||
// save previous vrr state
|
// save previous vrr state
|
||||||
dispdata->saved_vrr = KMSDRM_CrtcGetVrr(viddata->drm_fd, crtc->crtc_id);
|
dispdata->saved_vrr = KMSDRM_CrtcGetVrr(viddata->drm_fd, _crtc->crtc_id);
|
||||||
// try to enable vrr
|
// try to enable vrr
|
||||||
if (KMSDRM_ConnectorCheckVrrCapable(viddata->drm_fd, connector->connector_id, "VRR_CAPABLE")) {
|
if (KMSDRM_ConnectorCheckVrrCapable(viddata->drm_fd, conn->connector_id, "VRR_CAPABLE")) {
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Enabling VRR");
|
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Enabling VRR");
|
||||||
KMSDRM_CrtcSetVrr(viddata->drm_fd, crtc->crtc_id, true);
|
KMSDRM_CrtcSetVrr(viddata->drm_fd, _crtc->crtc_id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the name by the connector type, if possible
|
// Set the name by the connector type, if possible
|
||||||
if (KMSDRM_drmModeGetConnectorTypeName) {
|
if (KMSDRM_drmModeGetConnectorTypeName) {
|
||||||
connector_type = KMSDRM_drmModeGetConnectorTypeName(connector->connector_type);
|
connector_type = KMSDRM_drmModeGetConnectorTypeName(conn->connector_type);
|
||||||
if (connector_type == NULL) {
|
if (connector_type == NULL) {
|
||||||
connector_type = "Unknown";
|
connector_type = "Unknown";
|
||||||
}
|
}
|
||||||
SDL_snprintf(name_fmt, sizeof(name_fmt), "%s-%u", connector_type, connector->connector_type_id);
|
SDL_snprintf(name_fmt, sizeof(name_fmt), "%s-%u", connector_type, conn->connector_type_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
dispdata->crtc.props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd, _crtc->crtc_id, DRM_MODE_OBJECT_CRTC);
|
||||||
|
dispdata->crtc.props_info = SDL_calloc(dispdata->crtc.props->count_props, sizeof(*dispdata->crtc.props_info));
|
||||||
|
if (!dispdata->crtc.props_info) {
|
||||||
|
ret = false;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < dispdata->crtc.props->count_props; i++) {
|
||||||
|
dispdata->crtc.props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd, dispdata->crtc.props->props[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get connector properties */
|
||||||
|
dispdata->connector.props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd, conn->connector_id, DRM_MODE_OBJECT_CONNECTOR);
|
||||||
|
dispdata->connector.props_info = SDL_calloc(dispdata->connector.props->count_props, sizeof(*dispdata->connector.props_info));
|
||||||
|
if (!dispdata->connector.props_info) {
|
||||||
|
ret = false;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < dispdata->connector.props->count_props; i++) {
|
||||||
|
dispdata->connector.props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd,
|
||||||
|
dispdata->connector.props->props[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
|
|
@ -1010,7 +1451,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
orientation = KMSDRM_CrtcGetOrientation(viddata->drm_fd, crtc->crtc_id);
|
orientation = KMSDRM_CrtcGetOrientation(viddata->drm_fd, _crtc->crtc_id);
|
||||||
display_properties = SDL_GetDisplayProperties(display_id);
|
display_properties = SDL_GetDisplayProperties(display_id);
|
||||||
SDL_SetNumberProperty(display_properties, SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER, orientation);
|
SDL_SetNumberProperty(display_properties, SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER, orientation);
|
||||||
|
|
||||||
|
|
@ -1021,14 +1462,15 @@ cleanup:
|
||||||
if (ret) {
|
if (ret) {
|
||||||
// Error (complete) cleanup
|
// Error (complete) cleanup
|
||||||
if (dispdata) {
|
if (dispdata) {
|
||||||
if (dispdata->connector) {
|
if (dispdata->connector.connector) {
|
||||||
KMSDRM_drmModeFreeConnector(dispdata->connector);
|
KMSDRM_drmModeFreeConnector(dispdata->connector.connector);
|
||||||
dispdata->connector = NULL;
|
|
||||||
}
|
}
|
||||||
if (dispdata->crtc) {
|
if (dispdata->crtc.crtc) {
|
||||||
KMSDRM_drmModeFreeCrtc(dispdata->crtc);
|
KMSDRM_drmModeFreeCrtc(dispdata->crtc.crtc);
|
||||||
dispdata->crtc = NULL;
|
|
||||||
}
|
}
|
||||||
|
SDL_free(dispdata->connector.props_info);
|
||||||
|
SDL_free(dispdata->crtc.props_info);
|
||||||
|
SDL_free(dispdata->display_plane);
|
||||||
SDL_free(dispdata);
|
SDL_free(dispdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1077,13 +1519,22 @@ static void KMSDRM_SortDisplays(SDL_VideoDevice *_this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool set_client_atomic_caps(int fd)
|
||||||
|
{
|
||||||
|
if (KMSDRM_drmSetClientCap(fd, DRM_CLIENT_CAP_ATOMIC, 1)) {
|
||||||
|
return false; // no atomic modesetting support.
|
||||||
|
} else if (KMSDRM_drmSetClientCap(fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) {
|
||||||
|
return false; // no universal planes support.
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initializes the list of SDL displays: we build a new display for each
|
/* Initializes the list of SDL displays: we build a new display for each
|
||||||
connecter connector we find.
|
connecter connector we find.
|
||||||
This is to be called early, in VideoInit(), because it gets us
|
This is to be called early, in VideoInit(), because it gets us
|
||||||
the videomode information, which SDL needs immediately after VideoInit(). */
|
the videomode information, which SDL needs immediately after VideoInit(). */
|
||||||
static bool KMSDRM_InitDisplays(SDL_VideoDevice *_this)
|
static bool KMSDRM_InitDisplays(SDL_VideoDevice *_this)
|
||||||
{
|
{
|
||||||
|
|
||||||
SDL_VideoData *viddata = _this->internal;
|
SDL_VideoData *viddata = _this->internal;
|
||||||
drmModeRes *resources = NULL;
|
drmModeRes *resources = NULL;
|
||||||
uint64_t async_pageflip = 0;
|
uint64_t async_pageflip = 0;
|
||||||
|
|
@ -1104,6 +1555,11 @@ static bool KMSDRM_InitDisplays(SDL_VideoDevice *_this)
|
||||||
|
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opened DRM FD (%d)", viddata->drm_fd);
|
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opened DRM FD (%d)", viddata->drm_fd);
|
||||||
|
|
||||||
|
// Set ATOMIC & UNIVERSAL PLANES compatibility
|
||||||
|
viddata->is_atomic = set_client_atomic_caps(viddata->drm_fd);
|
||||||
|
|
||||||
|
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "DRM FD (%d) %s atomic", viddata->drm_fd, viddata->is_atomic ? "SUPPORTS" : "DOES NOT SUPPORT");
|
||||||
|
|
||||||
// Get all of the available connectors / devices / crtcs
|
// Get all of the available connectors / devices / crtcs
|
||||||
resources = KMSDRM_drmModeGetResources(viddata->drm_fd);
|
resources = KMSDRM_drmModeGetResources(viddata->drm_fd);
|
||||||
if (!resources) {
|
if (!resources) {
|
||||||
|
|
@ -1114,22 +1570,20 @@ static bool KMSDRM_InitDisplays(SDL_VideoDevice *_this)
|
||||||
/* Iterate on the available connectors. For every connected connector,
|
/* Iterate on the available connectors. For every connected connector,
|
||||||
we create an SDL_Display and add it to the list of SDL Displays. */
|
we create an SDL_Display and add it to the list of SDL Displays. */
|
||||||
for (i = 0; i < resources->count_connectors; i++) {
|
for (i = 0; i < resources->count_connectors; i++) {
|
||||||
drmModeConnector *connector = KMSDRM_drmModeGetConnector(viddata->drm_fd,
|
drmModeConnector *conn = KMSDRM_drmModeGetConnector(viddata->drm_fd, resources->connectors[i]);
|
||||||
resources->connectors[i]);
|
if (!conn) {
|
||||||
|
|
||||||
if (!connector) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes) {
|
if (conn->connection == DRM_MODE_CONNECTED && conn->count_modes) {
|
||||||
/* If it's a connected connector with available videomodes, try to add
|
/* If it's a connected connector with available videomodes, try to add
|
||||||
an SDL Display representing it. KMSDRM_AddDisplay() is purposely void,
|
an SDL Display representing it. KMSDRM_AddDisplay() is purposely void,
|
||||||
so if it fails (no encoder for connector, no valid video mode for
|
so if it fails (no encoder for connector, no valid video mode for
|
||||||
connector etc...) we can keep looking for connected connectors. */
|
connector etc...) we can keep looking for connected connectors. */
|
||||||
KMSDRM_AddDisplay(_this, connector, resources);
|
KMSDRM_AddDisplay(_this, conn, resources);
|
||||||
} else {
|
} else {
|
||||||
// If it's not, free it now.
|
// If it's not, free it now.
|
||||||
KMSDRM_drmModeFreeConnector(connector);
|
KMSDRM_drmModeFreeConnector(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1194,6 +1648,8 @@ static bool KMSDRM_GBMInit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viddata->is_atomic = set_client_atomic_caps(viddata->drm_fd);
|
||||||
|
|
||||||
// Set the FD as current DRM master.
|
// Set the FD as current DRM master.
|
||||||
KMSDRM_drmSetMaster(viddata->drm_fd);
|
KMSDRM_drmSetMaster(viddata->drm_fd);
|
||||||
|
|
||||||
|
|
@ -1201,6 +1657,13 @@ static bool KMSDRM_GBMInit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata)
|
||||||
viddata->gbm_dev = KMSDRM_gbm_create_device(viddata->drm_fd);
|
viddata->gbm_dev = KMSDRM_gbm_create_device(viddata->drm_fd);
|
||||||
if (!viddata->gbm_dev) {
|
if (!viddata->gbm_dev) {
|
||||||
result = SDL_SetError("Couldn't create gbm device.");
|
result = SDL_SetError("Couldn't create gbm device.");
|
||||||
|
} else {
|
||||||
|
// Setup the display plane. ONLY do this after dispdata has the right
|
||||||
|
// crtc and connector, because these are used in this function.
|
||||||
|
result = setup_plane(_this, &dispdata->display_plane, DRM_PLANE_TYPE_PRIMARY);
|
||||||
|
if (!result) {
|
||||||
|
SDL_SetError("can't find suitable display plane.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
viddata->gbm_init = true;
|
viddata->gbm_init = true;
|
||||||
|
|
@ -1213,6 +1676,12 @@ static void KMSDRM_GBMDeinit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata)
|
||||||
{
|
{
|
||||||
SDL_VideoData *viddata = _this->internal;
|
SDL_VideoData *viddata = _this->internal;
|
||||||
|
|
||||||
|
// Free display plane
|
||||||
|
free_plane(&dispdata->display_plane);
|
||||||
|
|
||||||
|
// Free cursor plane (if still not freed)
|
||||||
|
free_plane(&dispdata->cursor_plane);
|
||||||
|
|
||||||
/* Destroy GBM device. GBM surface is destroyed by DestroySurfaces(),
|
/* Destroy GBM device. GBM surface is destroyed by DestroySurfaces(),
|
||||||
already called when we get here. */
|
already called when we get here. */
|
||||||
if (viddata->gbm_dev) {
|
if (viddata->gbm_dev) {
|
||||||
|
|
@ -1242,19 +1711,86 @@ static void KMSDRM_DestroySurfaces(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
/**********************************************/
|
/**********************************************/
|
||||||
// KMSDRM_WaitPageflip(_this, windata);
|
// KMSDRM_WaitPageflip(_this, windata);
|
||||||
|
|
||||||
|
if (viddata->is_atomic) {
|
||||||
|
|
||||||
|
/* TODO : Continue investigating why this doesn't work. We should do this instead
|
||||||
|
of making the display plane point to the TTY console, which isn't there
|
||||||
|
after creating and destroying a Vulkan window. */
|
||||||
|
|
||||||
|
#if 0 // (note that this code has bitrotted a little, in addition to TODO comment above.)
|
||||||
|
/* Disconnect the connector from the CRTC (remember: several connectors
|
||||||
|
can read a CRTC), deactivate the CRTC, and set the PRIMARY PLANE props
|
||||||
|
CRTC_ID and FB_ID to 0. Then we can destroy the GBM buffers and surface. */
|
||||||
|
add_connector_property(dispdata->atomic_req, dispdata->connector , "CRTC_ID", 0);
|
||||||
|
add_crtc_property(dispdata->atomic_req, dispdata->crtc , "MODE_ID", 0);
|
||||||
|
add_crtc_property(dispdata->atomic_req, dispdata->crtc , "active", 0);
|
||||||
|
/**********************************************/
|
||||||
|
/* Wait for last issued pageflip to complete. */
|
||||||
|
/**********************************************/
|
||||||
|
KMSDRM_WaitPageFlip(_this, windata, -1);
|
||||||
|
|
||||||
|
plane_info.plane = dispdata->display_plane;
|
||||||
|
plane_info.crtc_id = 0;
|
||||||
|
plane_info.fb_id = 0;
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Restore the original CRTC configuration: configue the crtc with the */
|
||||||
|
/* original video mode and make it point to the original TTY buffer. */
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
drm_atomic_set_plane_props(&plane_info);
|
||||||
|
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id,
|
||||||
|
dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1,
|
||||||
|
&dispdata->original_mode);
|
||||||
|
|
||||||
|
/* Issue atomic commit that is blocking and allows modesetting. */
|
||||||
|
if (drm_atomic_commit(_this, true, true)) {
|
||||||
|
SDL_SetError("Failed to issue atomic commit on surfaces destruction.");
|
||||||
|
/* If we failed to set the original mode, try to set the connector prefered mode. */
|
||||||
|
if (ret && (dispdata->crtc->mode_valid == 0)) {
|
||||||
|
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id,
|
||||||
|
dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1,
|
||||||
|
&dispdata->original_mode);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
/************************************************************/
|
||||||
|
/* Make the display plane point to the original TTY buffer. */
|
||||||
|
/* We have to configure it's input and output scaling */
|
||||||
|
/* parameters accordingly. */
|
||||||
|
/************************************************************/
|
||||||
|
|
||||||
|
KMSDRM_PlaneInfo plane_info;
|
||||||
|
SDL_zero(plane_info);
|
||||||
|
plane_info.plane = dispdata->display_plane;
|
||||||
|
plane_info.crtc_id = dispdata->crtc.crtc->crtc_id;
|
||||||
|
plane_info.fb_id = dispdata->crtc.crtc->buffer_id;
|
||||||
|
plane_info.src_w = dispdata->original_mode.hdisplay;
|
||||||
|
plane_info.src_h = dispdata->original_mode.vdisplay;
|
||||||
|
plane_info.crtc_w = dispdata->original_mode.hdisplay;
|
||||||
|
plane_info.crtc_h = dispdata->original_mode.vdisplay;
|
||||||
|
|
||||||
|
drm_atomic_set_plane_props(&plane_info);
|
||||||
|
|
||||||
|
if (drm_atomic_commit(_this, true, false)) {
|
||||||
|
SDL_SetError("Failed to issue atomic commit on surfaces destruction.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
// Restore the original CRTC configuration: configure the crtc with the
|
// Restore the original CRTC configuration: configure the crtc with the
|
||||||
// original video mode and make it point to the original TTY buffer.
|
// original video mode and make it point to the original TTY buffer.
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id,
|
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc.crtc->crtc_id,
|
||||||
dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1,
|
dispdata->crtc.crtc->buffer_id, 0, 0, &dispdata->connector.connector->connector_id, 1,
|
||||||
&dispdata->original_mode);
|
&dispdata->original_mode);
|
||||||
|
|
||||||
// If we failed to set the original mode, try to set the connector preferred mode.
|
// If we failed to set the original mode, try to set the connector preferred mode.
|
||||||
if (ret && (dispdata->crtc->mode_valid == 0)) {
|
if (ret && (dispdata->crtc.crtc->mode_valid == 0)) {
|
||||||
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id,
|
ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc.crtc->crtc_id,
|
||||||
dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1,
|
dispdata->crtc.crtc->buffer_id, 0, 0, &dispdata->connector.connector->connector_id, 1,
|
||||||
&dispdata->original_mode);
|
&dispdata->original_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1462,6 +1998,10 @@ bool KMSDRM_VideoInit(SDL_VideoDevice *_this)
|
||||||
result = SDL_SetError("error getting KMSDRM displays information");
|
result = SDL_SetError("error getting KMSDRM displays information");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // Use this if you ever need to see info on all available planes.
|
||||||
|
get_planes_info(_this);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SDL_INPUT_LINUXEV
|
#ifdef SDL_INPUT_LINUXEV
|
||||||
SDL_EVDEV_Init();
|
SDL_EVDEV_Init();
|
||||||
SDL_EVDEV_SetVTSwitchCallbacks(KMSDRM_ReleaseVT, _this, KMSDRM_AcquireVT, _this);
|
SDL_EVDEV_SetVTSwitchCallbacks(KMSDRM_ReleaseVT, _this, KMSDRM_AcquireVT, _this);
|
||||||
|
|
@ -1501,7 +2041,7 @@ void KMSDRM_VideoQuit(SDL_VideoDevice *_this)
|
||||||
bool KMSDRM_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
|
bool KMSDRM_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display)
|
||||||
{
|
{
|
||||||
SDL_DisplayData *dispdata = display->internal;
|
SDL_DisplayData *dispdata = display->internal;
|
||||||
drmModeConnector *conn = dispdata->connector;
|
drmModeConnector *conn = dispdata->connector.connector;
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
@ -1534,7 +2074,7 @@ bool KMSDRM_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SD
|
||||||
SDL_VideoData *viddata = _this->internal;
|
SDL_VideoData *viddata = _this->internal;
|
||||||
SDL_DisplayData *dispdata = display->internal;
|
SDL_DisplayData *dispdata = display->internal;
|
||||||
SDL_DisplayModeData *modedata = mode->internal;
|
SDL_DisplayModeData *modedata = mode->internal;
|
||||||
drmModeConnector *conn = dispdata->connector;
|
drmModeConnector *conn = dispdata->connector.connector;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Don't do anything if we are in Vulkan mode.
|
// Don't do anything if we are in Vulkan mode.
|
||||||
|
|
@ -1570,7 +2110,7 @@ void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore vrr state
|
// restore vrr state
|
||||||
KMSDRM_CrtcSetVrr(windata->viddata->drm_fd, dispdata->crtc->crtc_id, dispdata->saved_vrr);
|
KMSDRM_CrtcSetVrr(windata->viddata->drm_fd, dispdata->crtc.crtc->crtc_id, dispdata->saved_vrr);
|
||||||
|
|
||||||
viddata = windata->viddata;
|
viddata = windata->viddata;
|
||||||
|
|
||||||
|
|
@ -1632,7 +2172,7 @@ void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window)
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
// We simply IGNORE if it's a fullscreen window, window->flags don't
|
// We simply IGNORE if it's a fullscreen window, window->flags don't
|
||||||
// reflect it: if it's fullscreen, KMSDRM_SetWindwoFullscreen() will
|
// reflect it: if it's fullscreen, KMSDRM_SetWindowFullscreen() will
|
||||||
// be called by SDL later, and we can manage it there.
|
// be called by SDL later, and we can manage it there.
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
bool KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
bool KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Atomic KMSDRM backend originally written by Manuel Alfayate Corchete <redwindwanderer@gmail.com>
|
||||||
|
|
||||||
#include "SDL_internal.h"
|
#include "SDL_internal.h"
|
||||||
|
|
||||||
#ifndef SDL_kmsdrmvideo_h
|
#ifndef SDL_kmsdrmvideo_h
|
||||||
|
|
@ -32,6 +34,7 @@
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
#include <gbm.h>
|
#include <gbm.h>
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
|
#include <EGL/eglext.h>
|
||||||
|
|
||||||
#ifndef DRM_FORMAT_MOD_INVALID
|
#ifndef DRM_FORMAT_MOD_INVALID
|
||||||
#define DRM_FORMAT_MOD_INVALID 0x00ffffffffffffffULL
|
#define DRM_FORMAT_MOD_INVALID 0x00ffffffffffffffULL
|
||||||
|
|
@ -72,6 +75,24 @@
|
||||||
#define GBM_BO_USE_LINEAR (1 << 4)
|
#define GBM_BO_USE_LINEAR (1 << 4)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef struct plane {
|
||||||
|
drmModePlane *plane;
|
||||||
|
drmModeObjectProperties *props;
|
||||||
|
drmModePropertyRes **props_info;
|
||||||
|
} plane;
|
||||||
|
|
||||||
|
typedef struct crtc {
|
||||||
|
drmModeCrtc *crtc;
|
||||||
|
drmModeObjectProperties *props;
|
||||||
|
drmModePropertyRes **props_info;
|
||||||
|
} crtc;
|
||||||
|
|
||||||
|
typedef struct connector {
|
||||||
|
drmModeConnector *connector;
|
||||||
|
drmModeObjectProperties *props;
|
||||||
|
drmModePropertyRes **props_info;
|
||||||
|
} connector;
|
||||||
|
|
||||||
struct SDL_VideoData
|
struct SDL_VideoData
|
||||||
{
|
{
|
||||||
int devindex; // device index that was passed on creation
|
int devindex; // device index that was passed on creation
|
||||||
|
|
@ -92,6 +113,7 @@ struct SDL_VideoData
|
||||||
open 1 FD and create 1 gbm device. */
|
open 1 FD and create 1 gbm device. */
|
||||||
bool gbm_init;
|
bool gbm_init;
|
||||||
|
|
||||||
|
bool is_atomic; // true if atomic interfaces are supported.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SDL_DisplayModeData
|
struct SDL_DisplayModeData
|
||||||
|
|
@ -101,8 +123,11 @@ struct SDL_DisplayModeData
|
||||||
|
|
||||||
struct SDL_DisplayData
|
struct SDL_DisplayData
|
||||||
{
|
{
|
||||||
drmModeConnector *connector;
|
plane *display_plane;
|
||||||
drmModeCrtc *crtc;
|
plane *cursor_plane;
|
||||||
|
crtc crtc;
|
||||||
|
connector connector;
|
||||||
|
|
||||||
drmModeModeInfo mode;
|
drmModeModeInfo mode;
|
||||||
drmModeModeInfo original_mode;
|
drmModeModeInfo original_mode;
|
||||||
drmModeModeInfo fullscreen_mode;
|
drmModeModeInfo fullscreen_mode;
|
||||||
|
|
@ -118,6 +143,15 @@ struct SDL_DisplayData
|
||||||
int cursor_bo_drm_fd;
|
int cursor_bo_drm_fd;
|
||||||
uint64_t cursor_w, cursor_h;
|
uint64_t cursor_w, cursor_h;
|
||||||
|
|
||||||
|
/* Central atomic request list, used for the prop
|
||||||
|
changeset related to pageflip in SwapWindow. */
|
||||||
|
drmModeAtomicReq *atomic_req;
|
||||||
|
|
||||||
|
int kms_in_fence_fd;
|
||||||
|
int kms_out_fence_fd;
|
||||||
|
EGLSyncKHR kms_fence;
|
||||||
|
EGLSyncKHR gpu_fence;
|
||||||
|
|
||||||
bool default_cursor_init;
|
bool default_cursor_init;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -137,6 +171,9 @@ struct SDL_WindowData
|
||||||
|
|
||||||
EGLSurface egl_surface;
|
EGLSurface egl_surface;
|
||||||
bool egl_surface_dirty;
|
bool egl_surface_dirty;
|
||||||
|
|
||||||
|
/* This dictates what approach we'll use for SwapBuffers. */
|
||||||
|
bool (*swap_window)(SDL_VideoDevice *_this, SDL_Window *window);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct KMSDRM_FBInfo
|
typedef struct KMSDRM_FBInfo
|
||||||
|
|
@ -145,12 +182,37 @@ typedef struct KMSDRM_FBInfo
|
||||||
uint32_t fb_id; // DRM framebuffer ID
|
uint32_t fb_id; // DRM framebuffer ID
|
||||||
} KMSDRM_FBInfo;
|
} KMSDRM_FBInfo;
|
||||||
|
|
||||||
|
typedef struct KMSDRM_PlaneInfo
|
||||||
|
{
|
||||||
|
struct plane *plane;
|
||||||
|
uint32_t fb_id;
|
||||||
|
uint32_t crtc_id;
|
||||||
|
int32_t src_x;
|
||||||
|
int32_t src_y;
|
||||||
|
int32_t src_w;
|
||||||
|
int32_t src_h;
|
||||||
|
int32_t crtc_x;
|
||||||
|
int32_t crtc_y;
|
||||||
|
int32_t crtc_w;
|
||||||
|
int32_t crtc_h;
|
||||||
|
} KMSDRM_PlaneInfo;
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
extern bool KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window);
|
extern bool KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window);
|
||||||
extern KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo);
|
extern KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo);
|
||||||
extern KMSDRM_FBInfo *KMSDRM_FBFromBO2(SDL_VideoDevice *_this, struct gbm_bo *bo, int w, int h);
|
extern KMSDRM_FBInfo *KMSDRM_FBFromBO2(SDL_VideoDevice *_this, struct gbm_bo *bo, int w, int h);
|
||||||
extern bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata);
|
extern bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata);
|
||||||
|
|
||||||
|
// Atomic functions that are used from SDL_kmsdrmopengles.c and SDL_kmsdrmmouse.c
|
||||||
|
void drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info);
|
||||||
|
void drm_atomic_waitpending(SDL_VideoDevice *_this);
|
||||||
|
int drm_atomic_commit(SDL_VideoDevice *_this, bool blocking, bool allow_modeset);
|
||||||
|
int add_plane_property(drmModeAtomicReq *req, struct plane *plane, const char *name, uint64_t value);
|
||||||
|
int add_crtc_property(drmModeAtomicReq *req, struct crtc *crtc, const char *name, uint64_t value);
|
||||||
|
int add_connector_property(drmModeAtomicReq *req, struct connector *connector, const char *name, uint64_t value);
|
||||||
|
bool setup_plane(SDL_VideoDevice *_this, struct plane **plane, uint32_t plane_type);
|
||||||
|
void free_plane(struct plane **plane);
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
// SDL_VideoDevice functions declaration
|
// SDL_VideoDevice functions declaration
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -140,8 +140,7 @@ void KMSDRM_Vulkan_UnloadLibrary(SDL_VideoDevice *_this)
|
||||||
// members of the VkInstanceCreateInfo struct passed to
|
// members of the VkInstanceCreateInfo struct passed to
|
||||||
// vkCreateInstance().
|
// vkCreateInstance().
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
char const* const* KMSDRM_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this,
|
char const * const *KMSDRM_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count)
|
||||||
Uint32 *count)
|
|
||||||
{
|
{
|
||||||
static const char *const extensionsForKMSDRM[] = {
|
static const char *const extensionsForKMSDRM[] = {
|
||||||
VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_DISPLAY_EXTENSION_NAME
|
VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_DISPLAY_EXTENSION_NAME
|
||||||
|
|
@ -171,7 +170,7 @@ bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||||
uint32_t display_count;
|
uint32_t display_count;
|
||||||
uint32_t mode_count;
|
uint32_t mode_count;
|
||||||
uint32_t plane_count;
|
uint32_t plane_count;
|
||||||
uint32_t plane = UINT32_MAX;
|
uint32_t _plane = UINT32_MAX;
|
||||||
|
|
||||||
VkPhysicalDevice *physical_devices = NULL;
|
VkPhysicalDevice *physical_devices = NULL;
|
||||||
VkPhysicalDeviceProperties *device_props = NULL;
|
VkPhysicalDeviceProperties *device_props = NULL;
|
||||||
|
|
@ -450,13 +449,13 @@ bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||||
vkGetDisplayPlaneCapabilitiesKHR(gpu, display_mode, i, &plane_caps);
|
vkGetDisplayPlaneCapabilitiesKHR(gpu, display_mode, i, &plane_caps);
|
||||||
if (plane_caps.supportedAlpha == alpha_mode) {
|
if (plane_caps.supportedAlpha == alpha_mode) {
|
||||||
// Yep, this plane is alright.
|
// Yep, this plane is alright.
|
||||||
plane = i;
|
_plane = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we couldn't find an appropriate plane, error out.
|
// If we couldn't find an appropriate plane, error out.
|
||||||
if (plane == UINT32_MAX) {
|
if (_plane == UINT32_MAX) {
|
||||||
SDL_SetError("Vulkan couldn't find an appropriate plane.");
|
SDL_SetError("Vulkan couldn't find an appropriate plane.");
|
||||||
goto clean;
|
goto clean;
|
||||||
}
|
}
|
||||||
|
|
@ -471,7 +470,7 @@ bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||||
SDL_zero(display_plane_surface_create_info);
|
SDL_zero(display_plane_surface_create_info);
|
||||||
display_plane_surface_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR;
|
display_plane_surface_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR;
|
||||||
display_plane_surface_create_info.displayMode = display_mode;
|
display_plane_surface_create_info.displayMode = display_mode;
|
||||||
display_plane_surface_create_info.planeIndex = plane;
|
display_plane_surface_create_info.planeIndex = _plane;
|
||||||
display_plane_surface_create_info.imageExtent = image_size;
|
display_plane_surface_create_info.imageExtent = image_size;
|
||||||
display_plane_surface_create_info.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
display_plane_surface_create_info.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||||
display_plane_surface_create_info.alphaMode = alpha_mode;
|
display_plane_surface_create_info.alphaMode = alpha_mode;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
extern bool KMSDRM_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
extern bool KMSDRM_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path);
|
||||||
extern void KMSDRM_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
|
extern void KMSDRM_Vulkan_UnloadLibrary(SDL_VideoDevice *_this);
|
||||||
extern char const* const* KMSDRM_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count);
|
extern char const * const *KMSDRM_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count);
|
||||||
extern bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
extern bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this,
|
||||||
SDL_Window *window,
|
SDL_Window *window,
|
||||||
VkInstance instance,
|
VkInstance instance,
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ static BOOL (*ov_wglMakeCurrent)(HDC, HGLRC);
|
||||||
#define OPENVR_DEFAULT_WIDTH 1920
|
#define OPENVR_DEFAULT_WIDTH 1920
|
||||||
#define OPENVR_DEFAULT_HEIGHT 1080
|
#define OPENVR_DEFAULT_HEIGHT 1080
|
||||||
|
|
||||||
#define OPENVR_SetupProc(proc) { proc = (void*)SDL_GL_GetProcAddress((#proc)+3); if (!proc) { failed_extension = (#proc)+3; } }
|
#define OPENVR_SetupProc(proc) { proc = (void *)SDL_GL_GetProcAddress((#proc)+3); if (!proc) { failed_extension = (#proc)+3; } }
|
||||||
|
|
||||||
static bool OPENVR_InitExtensions(SDL_VideoDevice *_this)
|
static bool OPENVR_InitExtensions(SDL_VideoDevice *_this)
|
||||||
{
|
{
|
||||||
|
|
@ -211,7 +211,7 @@ static bool OPENVR_VideoInit(SDL_VideoDevice *_this)
|
||||||
}
|
}
|
||||||
|
|
||||||
display.internal = (SDL_DisplayData *)data;
|
display.internal = (SDL_DisplayData *)data;
|
||||||
display.name = (char*)"OpenVRDisplay";
|
display.name = (char *)"OpenVRDisplay";
|
||||||
SDL_AddVideoDisplay(&display, false);
|
SDL_AddVideoDisplay(&display, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -250,7 +250,7 @@ static uint32_t *ImageSDLToOpenVRGL(SDL_Surface * surf, bool bFlipY)
|
||||||
int x, y;
|
int x, y;
|
||||||
uint32_t * pxd = SDL_malloc(4 * surf->w * surf->h);
|
uint32_t * pxd = SDL_malloc(4 * surf->w * surf->h);
|
||||||
for(y = 0; y < h; y++) {
|
for(y = 0; y < h; y++) {
|
||||||
uint32_t * iline = (uint32_t*)&(((uint8_t*)surf->pixels)[y*pitch]);
|
uint32_t * iline = (uint32_t *)&(((uint8_t *)surf->pixels)[y * pitch]);
|
||||||
uint32_t * oline = &pxd[(bFlipY?(h-y-1):y)*w];
|
uint32_t * oline = &pxd[(bFlipY?(h-y-1):y)*w];
|
||||||
for(x = 0; x < w; x++)
|
for(x = 0; x < w; x++)
|
||||||
{
|
{
|
||||||
|
|
@ -430,7 +430,7 @@ static void OPENVR_VirtualControllerUpdate(void *userdata)
|
||||||
xval *= -1.0f;
|
xval *= -1.0f;
|
||||||
if (a == SDL_GAMEPAD_AXIS_LEFT_TRIGGER || a == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER)
|
if (a == SDL_GAMEPAD_AXIS_LEFT_TRIGGER || a == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER)
|
||||||
xval = xval * 2.0f - 1.0f;
|
xval = xval * 2.0f - 1.0f;
|
||||||
//SDL_SetJoystickVirtualAxis(joystick, a, analog_input_action.x*32767);
|
//SDL_SetJoystickVirtualAxis(joystick, a, analog_input_action.x * 32767);
|
||||||
xval *= SDL_JOYSTICK_AXIS_MAX;
|
xval *= SDL_JOYSTICK_AXIS_MAX;
|
||||||
SDL_SetJoystickVirtualAxis(joystick, a, xval);
|
SDL_SetJoystickVirtualAxis(joystick, a, xval);
|
||||||
#ifdef DEBUG_OPENVR
|
#ifdef DEBUG_OPENVR
|
||||||
|
|
@ -1039,7 +1039,7 @@ static SDL_GLContext OVR_EGL_CreateContext(SDL_VideoDevice *_this, SDL_Window *
|
||||||
|
|
||||||
ov_glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
|
ov_glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
|
||||||
for(int i = 0; i < numExtensions; i++) {
|
for(int i = 0; i < numExtensions; i++) {
|
||||||
const char * ccc = (const char*)ov_glGetStringi(GL_EXTENSIONS, i);
|
const char * ccc = (const char *)ov_glGetStringi(GL_EXTENSIONS, i);
|
||||||
if (SDL_strcmp(ccc, "GL_KHR_debug") == 0) {
|
if (SDL_strcmp(ccc, "GL_KHR_debug") == 0) {
|
||||||
#ifdef DEBUG_OPENVR
|
#ifdef DEBUG_OPENVR
|
||||||
SDL_Log("Found renderdoc debug extension.");
|
SDL_Log("Found renderdoc debug extension.");
|
||||||
|
|
@ -1327,7 +1327,7 @@ static bool OPENVR_ShowCursor(SDL_Cursor * cursor)
|
||||||
hotspot.v[0] = (float)ovrc->hot_x / (float)ovrc->w;
|
hotspot.v[0] = (float)ovrc->hot_x / (float)ovrc->w;
|
||||||
hotspot.v[1] = (float)ovrc->hot_y / (float)ovrc->h;
|
hotspot.v[1] = (float)ovrc->hot_y / (float)ovrc->h;
|
||||||
|
|
||||||
texture.handle = (void*)(intptr_t)(ovrc->texture_id_handle);
|
texture.handle = (void *)(intptr_t)(ovrc->texture_id_handle);
|
||||||
texture.eType = ETextureType_TextureType_OpenGL;
|
texture.eType = ETextureType_TextureType_OpenGL;
|
||||||
texture.eColorSpace = EColorSpace_ColorSpace_Auto;
|
texture.eColorSpace = EColorSpace_ColorSpace_Auto;
|
||||||
|
|
||||||
|
|
@ -1395,7 +1395,7 @@ static bool OPENVR_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window * window, SD
|
||||||
SDL_free(pixels);
|
SDL_free(pixels);
|
||||||
ov_glBindTexture(GL_TEXTURE_2D, 0);
|
ov_glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
texture.handle = (void*)(intptr_t)(texture_id_handle);
|
texture.handle = (void *)(intptr_t)(texture_id_handle);
|
||||||
texture.eType = ETextureType_TextureType_OpenGL;
|
texture.eType = ETextureType_TextureType_OpenGL;
|
||||||
texture.eColorSpace = EColorSpace_ColorSpace_Auto;
|
texture.eColorSpace = EColorSpace_ColorSpace_Auto;
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue