This commit is contained in:
libretroadmin 2023-02-19 18:09:42 +01:00
parent 458bcd842b
commit 6ad1884add
27 changed files with 267 additions and 112 deletions

View file

@ -185,30 +185,28 @@ static void revmodel_setmode(struct revmodel *rev, float value)
revmodel_update(rev);
}
static void revmodel_init(struct revmodel *rev,int srate,bool right)
static void revmodel_init(struct revmodel *rev,int srate)
{
static const int comb_lengths[8] = { 1116,1188,1277,1356,1422,1491,1557,1617 };
static const int allpass_lengths[4] = { 225,341,441,556 };
double r = srate * (1 / 44100.0);
int stereosep = right ? 23 : 0;
unsigned c;
for (c = 0; c < numcombs; ++c)
{
rev->bufcomb[c] = malloc(r*comb_lengths[c]+stereosep*sizeof(float));
rev->combL[c].buffer = rev->bufcomb[c];
memset(rev->combL[c].buffer,0,r*comb_lengths[c]+stereosep*sizeof(float));
rev->combL[c].bufsize=r*comb_lengths[c]+stereosep;
rev->bufcomb[c] = malloc(r*comb_lengths[c]*sizeof(float));
rev->combL[c].buffer = rev->bufcomb[c];
memset(rev->combL[c].buffer,0,r*comb_lengths[c]*sizeof(float));
rev->combL[c].bufsize=r*comb_lengths[c];
}
for (c = 0; c < numallpasses; ++c)
{
rev->bufallpass[c] = malloc(r*allpass_lengths[c]+stereosep*sizeof(float));
rev->allpassL[c].buffer = rev->bufallpass[c];
memset(rev->allpassL[c].buffer,0,r*allpass_lengths[c]+stereosep*sizeof(float));
rev->allpassL[c].bufsize=r*allpass_lengths[c]+stereosep;
rev->bufallpass[c] = malloc(r*allpass_lengths[c]*sizeof(float));
rev->allpassL[c].buffer = rev->bufallpass[c];
memset(rev->allpassL[c].buffer,0,r*allpass_lengths[c]*sizeof(float));
rev->allpassL[c].bufsize=r*allpass_lengths[c];
rev->allpassL[c].feedback = 0.5f;
}
@ -277,8 +275,8 @@ static void *reverb_init(const struct dspfilter_info *info,
config->get_float(userdata, "roomwidth", &roomwidth, 0.56f);
config->get_float(userdata, "roomsize", &roomsize, 0.56f);
revmodel_init(&rev->left,info->input_rate,false);
revmodel_init(&rev->right,info->input_rate,true);
revmodel_init(&rev->left,info->input_rate);
revmodel_init(&rev->right,info->input_rate);
revmodel_setdamp(&rev->left, damping);
revmodel_setdry(&rev->left, drytime);

View file

@ -138,7 +138,7 @@ static void resampler_sinc_process_neon_kaiser(void *re_, struct resampler_data
float32x4_t p1 = {0, 0, 0, 0}, p2 = {0, 0, 0, 0};
float32x2_t p3, p4;
for (i = 0; i < taps; i += 8)
for (i = 0; i < (int)taps; i += 8)
{
float32x4x2_t coeff8 = vld2q_f32(&phase_table[i]);
float32x4x2_t delta8 = vld2q_f32(&delta_table[i]);
@ -213,7 +213,7 @@ static void resampler_sinc_process_neon(void *re_, struct resampler_data *data)
float32x4_t p1 = {0, 0, 0, 0}, p2 = {0, 0, 0, 0};
float32x2_t p3, p4;
for (i = 0; i < taps; i += 8)
for (i = 0; i < (int)taps; i += 8)
{
float32x4x2_t coeff8 = vld2q_f32(&phase_table[i]);
float32x4x2_t left8 = vld2q_f32(&buffer_l[i]);
@ -289,7 +289,7 @@ static void resampler_sinc_process_avx_kaiser(void *re_, struct resampler_data *
__m256 sum_l = _mm256_setzero_ps();
__m256 sum_r = _mm256_setzero_ps();
for (i = 0; i < taps; i += 8)
for (i = 0; i < (int)taps; i += 8)
{
__m256 buf_l = _mm256_loadu_ps(buffer_l + i);
__m256 buf_r = _mm256_loadu_ps(buffer_r + i);
@ -371,7 +371,7 @@ static void resampler_sinc_process_avx(void *re_, struct resampler_data *data)
__m256 sum_l = _mm256_setzero_ps();
__m256 sum_r = _mm256_setzero_ps();
for (i = 0; i < taps; i += 8)
for (i = 0; i < (int)taps; i += 8)
{
__m256 buf_l = _mm256_loadu_ps(buffer_l + i);
__m256 buf_r = _mm256_loadu_ps(buffer_r + i);
@ -456,7 +456,7 @@ static void resampler_sinc_process_sse_kaiser(void *re_, struct resampler_data *
__m128 sum_l = _mm_setzero_ps();
__m128 sum_r = _mm_setzero_ps();
for (i = 0; i < taps; i += 4)
for (i = 0; i < (int)taps; i += 4)
{
__m128 buf_l = _mm_loadu_ps(buffer_l + i);
__m128 buf_r = _mm_loadu_ps(buffer_r + i);
@ -548,7 +548,7 @@ static void resampler_sinc_process_sse(void *re_, struct resampler_data *data)
__m128 sum_l = _mm_setzero_ps();
__m128 sum_r = _mm_setzero_ps();
for (i = 0; i < taps; i += 4)
for (i = 0; i < (int)taps; i += 4)
{
__m128 buf_l = _mm_loadu_ps(buffer_l + i);
__m128 buf_r = _mm_loadu_ps(buffer_r + i);
@ -640,7 +640,7 @@ static void resampler_sinc_process_c_kaiser(void *re_, struct resampler_data *da
float delta = (float)
(resamp->time & resamp->subphase_mask) * resamp->subphase_mod;
for (i = 0; i < taps; i++)
for (i = 0; i < (int)taps; i++)
{
float sinc_val = phase_table[i] + delta_table[i] * delta;
@ -706,7 +706,7 @@ static void resampler_sinc_process_c(void *re_, struct resampler_data *data)
unsigned phase = resamp->time >> resamp->subphase_bits;
float *phase_table = resamp->phase_table + phase * taps;
for (i = 0; i < taps; i++)
for (i = 0; i < (int)taps; i++)
{
float sinc_val = phase_table[i];

View file

@ -35,8 +35,6 @@
#include <compat/strcasestr.h>
#include <compat/posix_string.h>
#include <retro_assert.h>
char *optarg;
int optind, opterr, optopt;
@ -184,8 +182,6 @@ static void shuffle_block(char **begin, char **last, char **end)
ptrdiff_t len = last - begin;
const char **tmp = (const char**)calloc(len, sizeof(const char*));
retro_assert(tmp);
memcpy((void*)tmp, begin, len * sizeof(const char*));
memmove(begin, last, (end - last) * sizeof(const char*));
memcpy(end - len, tmp, len * sizeof(const char*));
@ -198,8 +194,6 @@ int getopt_long(int argc, char *argv[],
{
int short_index, long_index;
(void)longindex;
if (optind == 0)
optind = 1;
@ -227,8 +221,6 @@ int getopt_long(int argc, char *argv[],
long_index = 0;
}
retro_assert(short_index == 0 || long_index == 0);
if (short_index == 0)
return parse_short(optstring, &argv[optind]);
if (long_index == 0)

View file

@ -29,7 +29,6 @@
#include <boolean.h>
#include <file/file_path.h>
#include <retro_assert.h>
#include <compat/strl.h>
#include <compat/posix_string.h>
#include <retro_miscellaneous.h>

View file

@ -119,7 +119,7 @@ uint32_t cdfs_get_num_sectors(cdfs_file_t* file)
if (frame_size == 0)
frame_size = 1; /* prevent divide by 0 error if sector size is unknown */
}
return intfstream_get_size(file->track->stream) / frame_size;
return (uint32_t)(intfstream_get_size(file->track->stream) / frame_size);
}
uint32_t cdfs_get_first_sector(cdfs_file_t* file)
@ -287,7 +287,7 @@ int64_t cdfs_read_file(cdfs_file_t* file, void* buffer, uint64_t len)
cdfs_seek_track_sector(file->track, file->current_sector);
intfstream_read(file->track->stream, file->sector_buffer, 2048);
memcpy(buffer, file->sector_buffer, (size_t)len);
file->current_sector_offset = len;
file->current_sector_offset = (unsigned int)len;
file->sector_buffer_valid = 1;
bytes_read += len;

View file

@ -28,7 +28,6 @@
#include <stdlib.h>
#include <string.h>
#include <retro_assert.h>
#include <retro_inline.h>
#include <boolean.h>
#include <formats/image.h>
@ -412,7 +411,6 @@ static INLINE int rjpeg_jpeg_huff_decode(rjpeg_jpeg *j, rjpeg_huffman *h)
/* convert the huffman code to the symbol id */
c = ((j->code_buffer >> (32 - k)) & rjpeg_bmask[k]) + h->delta[k];
retro_assert((((j->code_buffer) >> (32 - h->size[c])) & rjpeg_bmask[h->size[c]]) == h->code[c]);
/* convert the id to a symbol */
j->code_bits -= k;
@ -432,9 +430,8 @@ static INLINE int rjpeg_extend_receive(rjpeg_jpeg *j, int n)
if (j->code_bits < n)
rjpeg_grow_buffer_unsafe(j);
sgn = (int32_t)j->code_buffer >> 31; /* sign bit is always in MSB */
k = RJPEG_LROT(j->code_buffer, n);
retro_assert(n >= 0 && n < (int) (sizeof(rjpeg_bmask)/sizeof(*rjpeg_bmask)));
sgn = (int32_t)j->code_buffer >> 31; /* sign bit is always in MSB */
k = RJPEG_LROT(j->code_buffer, n);
j->code_buffer = k & ~rjpeg_bmask[n];
k &= rjpeg_bmask[n];
j->code_bits -= n;

View file

@ -1251,6 +1251,17 @@ char* rjsonwriter_get_memory_buffer(rjsonwriter_t *writer, int* len)
return writer->buf;
}
int rjsonwriter_count_memory_buffer(rjsonwriter_t *writer)
{
return writer->buf_num;
}
void rjsonwriter_erase_memory_buffer(rjsonwriter_t *writer, int keep_len)
{
if (keep_len <= writer->buf_num)
writer->buf_num = (keep_len < 0 ? 0 : keep_len);
}
bool rjsonwriter_free(rjsonwriter_t *writer)
{
bool res;

View file

@ -174,9 +174,9 @@ chd_error zlib_codec_init(void *codec, uint32_t hunkbytes)
else
err = CHDERR_NONE;
/* handle an error */
if (err != CHDERR_NONE)
free(data);
/* handle an error */
if (err != CHDERR_NONE)
zlib_codec_free(data);
return err;
}
@ -194,7 +194,7 @@ void zlib_codec_free(void *codec)
if (data != NULL)
{
int i;
zlib_allocator alloc;
zlib_allocator alloc;
inflateEnd(&data->inflater);
@ -229,7 +229,7 @@ chd_error zlib_codec_decompress(void *codec, const uint8_t *src, uint32_t comple
/* do it */
zerr = inflate(&data->inflater, Z_FINISH);
(void)zerr;
(void)zerr;
if (data->inflater.total_out != destlen)
return CHDERR_DECOMPRESSION_ERROR;
@ -270,7 +270,7 @@ voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size)
}
/* alloc a new one */
ptr = (UINT32 *)malloc(size + sizeof(UINT32) + ZLIB_MIN_ALIGNMENT_BYTES);
ptr = (UINT32 *)malloc(size + sizeof(UINT32) + ZLIB_MIN_ALIGNMENT_BYTES);
if (!ptr)
return NULL;

View file

@ -237,7 +237,7 @@ static void rpng_reverse_filter_copy_line_rgb(uint32_t *data,
bpp /= 8;
for (i = 0; i < width; i++)
for (i = 0; i < (int)width; i++)
{
uint32_t r, g, b;
@ -258,7 +258,7 @@ static void rpng_reverse_filter_copy_line_rgba(uint32_t *data,
bpp /= 8;
for (i = 0; i < width; i++)
for (i = 0; i < (int)width; i++)
{
uint32_t r, g, b, a;
r = *decoded;
@ -283,7 +283,7 @@ static void rpng_reverse_filter_copy_line_bw(uint32_t *data,
if (depth == 16)
{
for (i = 0; i < width; i++)
for (i = 0; i < (int)width; i++)
{
uint32_t val = decoded[i << 1];
data[i] = (val * 0x010101) | (0xffu << 24);
@ -295,7 +295,7 @@ static void rpng_reverse_filter_copy_line_bw(uint32_t *data,
mask = (1 << depth) - 1;
bit = 0;
for (i = 0; i < width; i++, bit += depth)
for (i = 0; i < (int)width; i++, bit += depth)
{
unsigned byte = bit >> 3;
unsigned val = decoded[byte] >> (8 - depth - (bit & 7));
@ -314,7 +314,7 @@ static void rpng_reverse_filter_copy_line_gray_alpha(uint32_t *data,
bpp /= 8;
for (i = 0; i < width; i++)
for (i = 0; i < (int)width; i++)
{
uint32_t gray, alpha;
@ -335,10 +335,9 @@ static void rpng_reverse_filter_copy_line_plt(uint32_t *data,
{
case 1:
{
unsigned w = width / 8;
int i;
for (i = 0; i < w; i++, decoded++)
unsigned w = width / 8;
for (i = 0; i < (int)w; i++, decoded++)
{
*data++ = palette[(*decoded >> 7) & 1];
*data++ = palette[(*decoded >> 6) & 1];
@ -373,10 +372,9 @@ static void rpng_reverse_filter_copy_line_plt(uint32_t *data,
case 2:
{
unsigned w = width / 4;
int i;
for (i = 0; i < w; i++, decoded++)
unsigned w = width / 4;
for (i = 0; i < (int)w; i++, decoded++)
{
*data++ = palette[(*decoded >> 6) & 3];
*data++ = palette[(*decoded >> 4) & 3];
@ -399,10 +397,9 @@ static void rpng_reverse_filter_copy_line_plt(uint32_t *data,
case 4:
{
unsigned w = width / 2;
int i;
for (i = 0; i < w; i++, decoded++)
unsigned w = width / 2;
for (i = 0; i < (int)w; i++, decoded++)
{
*data++ = palette[*decoded >> 4];
*data++ = palette[*decoded & 0x0f];
@ -416,8 +413,7 @@ static void rpng_reverse_filter_copy_line_plt(uint32_t *data,
case 8:
{
int i;
for (i = 0; i < width; i++, decoded++, data++)
for (i = 0; i < (int)width; i++, decoded++, data++)
*data = palette[*decoded];
}
break;
@ -1086,7 +1082,7 @@ bool rpng_iterate_image(rpng_t *rpng)
buf += 8;
palette = rpng->palette;
for (i = 0; i < chunk_size; i++, buf++, palette++)
for (i = 0; i < (int)chunk_size; i++, buf++, palette++)
*palette = (*palette & 0x00ffffff) | (unsigned)*buf << 24;
}
/* TODO: support colorkey in grayscale and truecolor images */

View file

@ -29,7 +29,6 @@
#include <stdlib.h>
#include <string.h>
#include <retro_assert.h>
#include <retro_inline.h>
#include <formats/image.h>

View file

@ -195,6 +195,14 @@ rjsonwriter_t *rjsonwriter_open_user(rjsonwriter_io_t io, void *user_data);
* Returned buffer is only valid until writer is modified or freed. */
char* rjsonwriter_get_memory_buffer(rjsonwriter_t *writer, int* len);
/* When opened with rjsonwriter_open_memory, will return current length */
int rjsonwriter_count_memory_buffer(rjsonwriter_t *writer);
/* When opened with rjsonwriter_open_memory, will clear the buffer.
The buffer will be partially erased if keep_len is > 0.
No memory is freed or re-allocated with this function. */
void rjsonwriter_erase_memory_buffer(rjsonwriter_t *writer, int keep_len);
/* Free rjsonwriter handle and return result of final rjsonwriter_flush call */
bool rjsonwriter_free(rjsonwriter_t *writer);

View file

@ -70,6 +70,8 @@ static INLINE void rjsonwriter_add_int(rjsonwriter_t *writer, int value)
static INLINE void rjsonwriter_add_bool(rjsonwriter_t *writer, bool value)
{ rjsonwriter_raw(writer, (value ? "true" : "false"), (value ? 4 : 5)); }
static INLINE void rjsonwriter_add_null(rjsonwriter_t *writer)
{ rjsonwriter_raw(writer, "null", 4); }
RETRO_END_DECLS

View file

@ -28,6 +28,9 @@ typedef unsigned long long int GLuint64;
typedef unsigned long long int GLuint64EXT;
typedef struct __GLsync *GLsync;
#endif
#ifndef GL_APIENTRYP
#define GL_APIENTRYP GL_APIENTRY*
#endif
typedef void (GL_APIENTRYP RGLSYMGLBLENDBARRIERKHRPROC) (void);
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);

View file

@ -289,6 +289,8 @@ enum retro_language
RETRO_LANGUAGE_CZECH = 27,
RETRO_LANGUAGE_CATALAN_VALENCIA = 28,
RETRO_LANGUAGE_CATALAN = 29,
RETRO_LANGUAGE_BRITISH_ENGLISH = 30,
RETRO_LANGUAGE_HUNGARIAN = 31,
RETRO_LANGUAGE_LAST,
/* Ensure sizeof(enum) == sizeof(int) */
@ -1765,6 +1767,33 @@ enum retro_mod
* (see enum retro_savestate_context)
*/
#define RETRO_ENVIRONMENT_GET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_SUPPORT (73 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* struct retro_hw_render_context_negotiation_interface * --
* Before calling SET_HW_RNEDER_CONTEXT_NEGOTIATION_INTERFACE, a core can query
* which version of the interface is supported.
*
* Frontend looks at interface_type and returns the maximum supported
* context negotiation interface version.
* If the interface_type is not supported or recognized by the frontend, a version of 0
* must be returned in interface_version and true is returned by frontend.
*
* If this environment call returns true with interface_version greater than 0,
* a core can always use a negotiation interface version larger than what the frontend returns, but only
* earlier versions of the interface will be used by the frontend.
* A frontend must not reject a negotiation interface version that is larger than
* what the frontend supports. Instead, the frontend will use the older entry points that it recognizes.
* If this is incompatible with a particular core's requirements, it can error out early.
*
* Backwards compatibility note:
* This environment call was introduced after Vulkan v1 context negotiation.
* If this environment call is not supported by frontend - i.e. the environment call returns false -
* only Vulkan v1 context negotiation is supported (if Vulkan HW rendering is supported at all).
* If a core uses Vulkan negotiation interface with version > 1, negotiation may fail unexpectedly.
* All future updates to the context negotiation interface implies that frontend must support
* this environment call to query support.
*/
/* VFS functionality */
/* File paths:

View file

@ -27,7 +27,7 @@
#include <vulkan/vulkan.h>
#define RETRO_HW_RENDER_INTERFACE_VULKAN_VERSION 5
#define RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN_VERSION 1
#define RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN_VERSION 2
struct retro_vulkan_image
{
@ -64,6 +64,8 @@ struct retro_vulkan_context
uint32_t presentation_queue_family_index;
};
/* This is only used in v1 of the negotiation interface.
* It is deprecated since it cannot express PDF2 features or optional extensions. */
typedef bool (*retro_vulkan_create_device_t)(
struct retro_vulkan_context *context,
VkInstance instance,
@ -78,6 +80,32 @@ typedef bool (*retro_vulkan_create_device_t)(
typedef void (*retro_vulkan_destroy_device_t)(void);
/* v2 CONTEXT_NEGOTIATION_INTERFACE only. */
typedef VkInstance (*retro_vulkan_create_instance_wrapper_t)(
void *opaque, const VkInstanceCreateInfo *create_info);
/* v2 CONTEXT_NEGOTIATION_INTERFACE only. */
typedef VkInstance (*retro_vulkan_create_instance_t)(
PFN_vkGetInstanceProcAddr get_instance_proc_addr,
const VkApplicationInfo *app,
retro_vulkan_create_instance_wrapper_t create_instance_wrapper,
void *opaque);
/* v2 CONTEXT_NEGOTIATION_INTERFACE only. */
typedef VkDevice (*retro_vulkan_create_device_wrapper_t)(
VkPhysicalDevice gpu, void *opaque,
const VkDeviceCreateInfo *create_info);
/* v2 CONTEXT_NEGOTIATION_INTERFACE only. */
typedef bool (*retro_vulkan_create_device2_t)(
struct retro_vulkan_context *context,
VkInstance instance,
VkPhysicalDevice gpu,
VkSurfaceKHR surface,
PFN_vkGetInstanceProcAddr get_instance_proc_addr,
retro_vulkan_create_device_wrapper_t create_device_wrapper,
void *opaque);
/* Note on thread safety:
* The Vulkan API is heavily designed around multi-threading, and
* the libretro interface for it should also be threading friendly.
@ -89,11 +117,24 @@ struct retro_hw_render_context_negotiation_interface_vulkan
{
/* Must be set to RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN. */
enum retro_hw_render_context_negotiation_interface_type interface_type;
/* Must be set to RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN_VERSION. */
/* Usually set to RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN_VERSION,
* but can be lower depending on GET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_SUPPORT. */
unsigned interface_version;
/* If non-NULL, returns a VkApplicationInfo struct that the frontend can use instead of
* its "default" application info.
* VkApplicationInfo::apiVersion also controls the target core Vulkan version for instance level functionality.
* Lifetime of the returned pointer must remain until the retro_vulkan_context is initialized.
*
* NOTE: For optimal compatibility with e.g. Android which is very slow to update its loader,
* a core version of 1.1 should be requested. Features beyond that can be requested with extensions.
* Vulkan 1.0 is only appropriate for legacy cores, but is still supported.
* A frontend is free to bump the instance creation apiVersion as necessary if the frontend requires more advanced core features.
*
* v2: This function must not be NULL, and must not return NULL.
* v1: It was not clearly defined if this function could return NULL.
* Frontends should be defensive and provide a default VkApplicationInfo
* if this function returns NULL or if this function is NULL.
*/
retro_vulkan_get_application_info_t get_application_info;
@ -102,8 +143,8 @@ struct retro_hw_render_context_negotiation_interface_vulkan
* The core must prepare a designated PhysicalDevice, Device, Queue and queue family index
* which the frontend will use for its internal operation.
*
* If gpu is not VK_NULL_HANDLE, the physical device provided to the frontend must be this PhysicalDevice.
* The core is still free to use other physical devices.
* If gpu is not VK_NULL_HANDLE, the physical device provided to the frontend must be this PhysicalDevice if the call succeeds.
* The core is still free to use other physical devices for other purposes that are private to the core.
*
* The frontend will request certain extensions and layers for a device which is created.
* The core must ensure that the queue and queue_family_index support GRAPHICS and COMPUTE.
@ -132,8 +173,64 @@ struct retro_hw_render_context_negotiation_interface_vulkan
* tearing down its own device resources.
*
* Only auxillary resources should be freed here, i.e. resources which are not part of retro_vulkan_context.
* v2: Auxillary instance resources created during create_instance can also be freed here.
*/
retro_vulkan_destroy_device_t destroy_device;
/* v2 API: If interface_version is < 2, fields below must be ignored.
* If the frontend does not support interface version 2, the v1 entry points will be used instead. */
/* If non-NULL, this is called to create an instance, otherwise a VkInstance is created by the frontend.
* v1 interface bug: The only way to enable instance features is through core versions signalled in VkApplicationInfo.
* The frontend may request that certain extensions and layers
* are enabled on the VkInstance. Application may add additional features.
* If app is non-NULL, apiVersion controls the minimum core version required by the application.
* Return a VkInstance or VK_NULL_HANDLE. The VkInstance is owned by the frontend.
*
* Rather than call vkCreateInstance directly, a core must call the CreateInstance wrapper provided with:
* VkInstance instance = create_instance_wrapper(opaque, &create_info);
* If the core wishes to create a private instance for whatever reason (relying on shared memory for example),
* it may call vkCreateInstance directly. */
retro_vulkan_create_instance_t create_instance;
/* If non-NULL and frontend recognizes negotiation interface >= 2, create_device2 takes precedence over create_device.
* Similar to create_device, but is extended to better understand new core versions and PDF2 feature enablement.
* Requirements for create_device2 are the same as create_device unless a difference is mentioned.
*
* v2 consideration:
* If the chosen gpu by frontend cannot be supported, a core must return false.
*
* NOTE: "Cannot be supported" is intentionally vaguely defined.
* Refusing to run on an iGPU for a very intensive core with desktop GPU as a minimum spec may be in the gray area.
* Not supporting optional features is not a good reason to reject a physical device, however.
*
* On device creation feature with explicit gpu, a frontend should fall back create_device2 with gpu == VK_NULL_HANDLE and let core
* decide on a supported device if possible.
*
* A core must assume that the explicitly provided GPU is the only guaranteed attempt it has to create a device.
* A fallback may not be attempted if there are particular reasons why only a specific physical device can work,
* but these situations should be esoteric and rare in nature, e.g. a libretro frontend is implemented with external memory
* and only LUID matching would work.
* Cores and frontends should ensure "best effort" when negotiating like this and appropriate logging is encouraged.
*
* v1 note: In the v1 version of create_device, it was never expected that create_device would fail like this,
* and frontends are not expected to attempt fall backs.
*
* Rather than call vkCreateDevice directly, a core must call the CreateDevice wrapper provided with:
* VkDevice device = create_device_wrapper(gpu, opaque, &create_info);
* If the core wishes to create a private device for whatever reason (relying on shared memory for example),
* it may call vkCreateDevice directly.
*
* This allows the frontend to add additional extensions that it requires as well as adjust the PDF2 pNext as required.
* It is also possible adjust the queue create infos in case the frontend desires to allocate some private queues.
*
* The get_instance_proc_addr provided in create_device2 must be the same as create_instance.
*
* NOTE: The frontend must not disable features requested by application.
* NOTE: The frontend must not add any robustness features as some API behavior may change (VK_EXT_descriptor_buffer comes to mind).
* I.e. robustBufferAccess and the like. (nullDescriptor from robustness2 is allowed to be enabled).
*/
retro_vulkan_create_device2_t create_device2;
};
struct retro_hw_render_interface_vulkan

View file

@ -74,6 +74,17 @@ static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count)
return false;
}
static INLINE bool bits_any_different(uint32_t *a, uint32_t *b, uint32_t count)
{
uint32_t i;
for (i = 0; i < count; i++)
{
if (a[i] != b[i])
return true;
}
return false;
}
#ifndef PATH_MAX_LENGTH
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(PS2) || defined(GEKKO)|| defined(WIIU) || defined(__PSL1GHT__) || defined(__PS3__)
#define PATH_MAX_LENGTH 512

View file

@ -11,6 +11,8 @@ extern "C" {
extern PFN_vkCreateInstance vulkan_symbol_wrapper_vkCreateInstance;
#define vkCreateInstance vulkan_symbol_wrapper_vkCreateInstance
extern PFN_vkEnumerateInstanceVersion vulkan_symbol_wrapper_vkEnumerateInstanceVersion;
#define vkEnumerateInstanceVersion vulkan_symbol_wrapper_vkEnumerateInstanceVersion
extern PFN_vkEnumerateInstanceExtensionProperties vulkan_symbol_wrapper_vkEnumerateInstanceExtensionProperties;
#define vkEnumerateInstanceExtensionProperties vulkan_symbol_wrapper_vkEnumerateInstanceExtensionProperties
extern PFN_vkEnumerateInstanceLayerProperties vulkan_symbol_wrapper_vkEnumerateInstanceLayerProperties;

View file

@ -448,11 +448,11 @@ int string_list_find_elem(const struct string_list *list, const char *elem)
{
if (list)
{
int i;
size_t i;
for (i = 0; i < list->size; i++)
{
if (string_is_equal_noncase(list->elems[i].data, elem))
return (i + 1);
return (int)(i + 1);
}
}
return 0;

View file

@ -440,7 +440,19 @@ static int net_http_new_socket(struct http_connection_t *conn)
fd = -1;
goto done;
}
if (ssl_socket_connect(conn->sock_state.ssl_ctx, addr, true, true)
/* TODO: Properly figure out what's going wrong when the newer
timeout/poll code interacts with mbed and winsock
https://github.com/libretro/RetroArch/issues/14742 */
/* Temp fix, don't use new timeout/poll code for cheevos http requests */
bool timeout = true;
#ifdef __WIN32
if (!strcmp(conn->domain, "retroachievements.org"))
timeout = false;
#endif
if (ssl_socket_connect(conn->sock_state.ssl_ctx, addr, timeout, true)
< 0)
{
fd = -1;
@ -1199,14 +1211,16 @@ void net_http_delete(struct http_t *state)
if (state->sock_state.fd >= 0)
{
socket_close(state->sock_state.fd);
#ifdef HAVE_SSL
if (state->sock_state.ssl && state->sock_state.ssl_ctx)
{
ssl_socket_close(state->sock_state.ssl_ctx);
ssl_socket_free(state->sock_state.ssl_ctx);
state->sock_state.ssl_ctx = NULL;
}
else
#endif
socket_close(state->sock_state.fd);
}
free(state);
}

View file

@ -55,12 +55,13 @@ bool net_ifinfo_new(net_ifinfo_t *list)
PIP_ADAPTER_ADDRESSES addr;
struct net_ifinfo_entry *entry;
size_t interfaces = 0;
ULONG flags = GAA_FLAG_SKIP_ANYCAST |
GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER;
ULONG flags = GAA_FLAG_SKIP_ANYCAST
| GAA_FLAG_SKIP_MULTICAST
| GAA_FLAG_SKIP_DNS_SERVER;
ULONG len = 15 * 1024;
PIP_ADAPTER_ADDRESSES addresses = (PIP_ADAPTER_ADDRESSES)calloc(1, len);
list->entries = NULL;
list->entries = NULL;
if (!addresses)
goto failure;
@ -104,15 +105,14 @@ bool net_ifinfo_new(net_ifinfo_t *list)
if (!interfaces)
goto failure;
list->entries =
(struct net_ifinfo_entry*)calloc(interfaces, sizeof(*list->entries));
if (!list->entries)
if (!(list->entries =
(struct net_ifinfo_entry*)calloc(interfaces, sizeof(*list->entries))))
goto failure;
list->size = 0;
list->size = 0;
/* Now create the entries. */
addr = addresses;
entry = list->entries;
addr = addresses;
entry = list->entries;
do
{
@ -161,22 +161,19 @@ failure:
return false;
#elif defined(VITA)
SceNetCtlInfo info;
list->entries = (struct net_ifinfo_entry*)calloc(2, sizeof(*list->entries));
if (!list->entries)
if (!(list->entries = (struct net_ifinfo_entry*)calloc(2, sizeof(*list->entries))))
{
list->size = 0;
return false;
}
strcpy_literal(list->entries[0].name, "lo");
strcpy_literal(list->entries[0].host, "127.0.0.1");
strlcpy(list->entries[0].name, "lo", sizeof(list->entries[0].name));
strlcpy(list->entries[0].host, "127.0.0.1", sizeof(list->entries[0].host));
list->size = 1;
if (!sceNetCtlInetGetInfo(SCE_NETCTL_INFO_GET_IP_ADDRESS, &info))
{
strcpy_literal(list->entries[1].name, "wlan");
strlcpy(list->entries[1].name, "wlan", sizeof(list->entries[1].name));
strlcpy(list->entries[1].host, info.ip_address,
sizeof(list->entries[1].host));
list->size++;
@ -185,17 +182,14 @@ failure:
return true;
#elif defined(HAVE_LIBNX) || defined(_3DS) || defined(GEKKO)
uint32_t addr = 0;
list->entries = (struct net_ifinfo_entry*)calloc(2, sizeof(*list->entries));
if (!list->entries)
if (!(list->entries = (struct net_ifinfo_entry*)calloc(2, sizeof(*list->entries))))
{
list->size = 0;
return false;
}
strcpy_literal(list->entries[0].name, "lo");
strcpy_literal(list->entries[0].host, "127.0.0.1");
strlcpy(list->entries[0].name, "lo", sizeof(list->entries[0].name));
strlcpy(list->entries[0].host, "127.0.0.1", sizeof(list->entries[0].host));
list->size = 1;
#if defined(HAVE_LIBNX)
@ -213,8 +207,7 @@ failure:
if (addr)
{
uint8_t *addr8 = (uint8_t*)&addr;
strcpy_literal(list->entries[1].name,
strlcpy(list->entries[1].name,
#if defined(HAVE_LIBNX)
"switch"
#elif defined(_3DS)
@ -222,7 +215,7 @@ failure:
#else
"gekko"
#endif
);
, sizeof(list->entries[1].name));
snprintf(list->entries[1].host, sizeof(list->entries[1].host),
"%d.%d.%d.%d",
(int)addr8[0], (int)addr8[1], (int)addr8[2], (int)addr8[3]);
@ -236,13 +229,13 @@ failure:
size_t interfaces = 0;
struct ifaddrs *addresses = NULL;
list->entries = NULL;
list->entries = NULL;
if (getifaddrs(&addresses) || !addresses)
goto failure;
/* Count the number of valid interfaces first. */
addr = addresses;
addr = addresses;
do
{
@ -350,7 +343,7 @@ bool net_ifinfo_best(const char *dst, void *src, bool ipv6)
#ifdef __WINRT__
struct sockaddr_in dst_addr = {0};
#endif
IPAddr dst_ip = inet_addr(dst);
ULONG dst_ip = (ULONG)inet_addr(dst);
if (!src)
return false;

View file

@ -182,7 +182,7 @@ bool socket_set_block(int fd, bool block)
u_long i = !block;
return !ioctlsocket(fd, FIONBIO, &i);
#elif !defined(__PSL1GHT__) && defined(__PS3__) || defined(VITA) || defined(WIIU)
#elif defined(__PS3__) || defined(VITA) || defined(WIIU)
int i = !block;
return !setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(i));
@ -212,7 +212,7 @@ int socket_close(int fd)
#if defined(_WIN32) && !defined(_XBOX360)
/* WinSock has headers from the stone age. */
return closesocket(fd);
#elif !defined(__PSL1GHT__) && defined(__PS3__) || defined(WIIU)
#elif defined(__PS3__) || defined(WIIU)
return socketclose(fd);
#elif defined(VITA)
return sceNetSocketClose(fd);
@ -224,7 +224,7 @@ int socket_close(int fd)
int socket_select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *errorfds, struct timeval *timeout)
{
#if !defined(__PSL1GHT__) && defined(__PS3__)
#if defined(__PS3__)
return socketselect(nfds, readfds, writefds, errorfds, timeout);
#elif defined(VITA)
int i, j;
@ -762,15 +762,21 @@ bool socket_connect_with_timeout(int fd, void *data, int timeout)
return false;
#elif defined(_3DS)
/* libctru getsockopt does not return expected value */
if (connect(fd, addr->ai_addr, addr->ai_addrlen) < 0 && errno != EISCONN)
if ((connect(fd, addr->ai_addr, addr->ai_addrlen) < 0) && errno != EISCONN)
return false;
#elif defined(WIIU)
/* On WiiU, getsockopt() returns -1 and sets lastsocketerr() (Wii's
* equivalent to errno) to 16. */
if ((connect(fd, addr->ai_addr, addr->ai_addrlen) == -1)
&& socketlasterr() != SO_EISCONN)
return false;
#else
{
int error = -1;
socklen_t errsz = sizeof(error);
/* Only error out here if the getsockopt() call succeeds and error is still set. */
if(!getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&error, &errsz) && error)
getsockopt(fd, SOL_SOCKET, SO_ERROR, (char*)&error, &errsz);
if (error)
return false;
}
#endif

View file

@ -55,7 +55,7 @@
#include <time.h>
#endif
#if defined(VITA) || defined(BSD) || defined(ORBIS) || defined(__mips__) || defined(_3DS)
#if defined(VITA) || defined(BSD) || defined(ORBIS)
#include <sys/time.h>
#endif

View file

@ -233,7 +233,7 @@ void word_wrap(
/* Early return if src string length is less
* than line width */
if (src_len < line_width)
if (src_len < (size_t)line_width)
{
strlcpy(dst, src, dst_size);
return;

View file

@ -22,7 +22,6 @@
#ifdef HAVE_THREADS
#include <rthreads/rthreads.h>
#include <retro_assert.h>
#include <stdlib.h>
#endif
@ -41,8 +40,6 @@ void rtime_init(void)
#ifdef HAVE_THREADS
if (!rtime_localtime_lock)
rtime_localtime_lock = slock_new();
retro_assert(rtime_localtime_lock);
#endif
}

View file

@ -648,7 +648,7 @@ int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream,
int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, const void *s, uint64_t len)
{
int64_t pos = 0;
int64_t pos = 0;
size_t result = -1;
if (!stream)
@ -656,7 +656,7 @@ int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, cons
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
{
pos = retro_vfs_file_tell_impl(stream);
pos = retro_vfs_file_tell_impl(stream);
result = fwrite(s, 1, (size_t)len, stream->fp);
if (result != -1 && pos + result > stream->size)
@ -669,7 +669,7 @@ int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, cons
return -1;
#endif
pos = retro_vfs_file_tell_impl(stream);
pos = retro_vfs_file_tell_impl(stream);
result = write(stream->fd, s, (size_t)len);
if (result != -1 && pos + result > stream->size)

View file

@ -48,7 +48,6 @@
#include <encodings/utf.h>
#include <retro_miscellaneous.h>
#include <file/file_path.h>
#include <retro_assert.h>
#include <string/stdstring.h>
#include <retro_environment.h>
#include <uwp/uwp_async.h>

View file

@ -3,6 +3,7 @@
#include <vulkan/vulkan_symbol_wrapper.h>
PFN_vkCreateInstance vulkan_symbol_wrapper_vkCreateInstance;
PFN_vkEnumerateInstanceVersion vulkan_symbol_wrapper_vkEnumerateInstanceVersion;
PFN_vkEnumerateInstanceExtensionProperties vulkan_symbol_wrapper_vkEnumerateInstanceExtensionProperties;
PFN_vkEnumerateInstanceLayerProperties vulkan_symbol_wrapper_vkEnumerateInstanceLayerProperties;
PFN_vkDestroyInstance vulkan_symbol_wrapper_vkDestroyInstance;
@ -189,6 +190,7 @@ VkBool32 vulkan_symbol_wrapper_load_global_symbols(void)
if (!VULKAN_SYMBOL_WRAPPER_LOAD_INSTANCE_SYMBOL(NULL, "vkCreateInstance", vkCreateInstance)) return VK_FALSE;
if (!VULKAN_SYMBOL_WRAPPER_LOAD_INSTANCE_SYMBOL(NULL, "vkEnumerateInstanceExtensionProperties", vkEnumerateInstanceExtensionProperties)) return VK_FALSE;
if (!VULKAN_SYMBOL_WRAPPER_LOAD_INSTANCE_SYMBOL(NULL, "vkEnumerateInstanceLayerProperties", vkEnumerateInstanceLayerProperties)) return VK_FALSE;
VULKAN_SYMBOL_WRAPPER_LOAD_INSTANCE_SYMBOL(NULL, "vkEnumerateInstanceVersion", vkEnumerateInstanceVersion);
return VK_TRUE;
}