mirror of
https://github.com/libretro/RetroArch
synced 2025-03-31 19:21:06 +00:00
Fix C++ comments
This commit is contained in:
parent
6be8dccd46
commit
ace21d28f7
@ -79,13 +79,14 @@ static void *gx_audio_init(const char *device,
|
||||
AIInit(NULL);
|
||||
AIRegisterDMACallback(dma_callback);
|
||||
|
||||
//ranges 0-32000 (default low) and 40000-47999 (in settings going down from 48000) -> set to 32000 hz
|
||||
/* Ranges 0-32000 (default low) and 40000-47999
|
||||
(in settings going down from 48000) -> set to 32000 hz */
|
||||
if (rate <= 32000 || (rate >= 40000 && rate < 48000))
|
||||
{
|
||||
AISetDSPSampleRate(AI_SAMPLERATE_32KHZ);
|
||||
*new_rate = 32000;
|
||||
}
|
||||
else //ranges 32001-39999 (in settings going up from 32000) and 48000-max (default high) -> set to 48000 hz
|
||||
else /* Ranges 32001-39999 (in settings going up from 32000) and 48000-max (default high) -> set to 48000 hz */
|
||||
{
|
||||
AISetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
||||
*new_rate = 48000;
|
||||
|
@ -274,7 +274,7 @@ fail_audio_output:
|
||||
fail_audio_ipc:
|
||||
switch_audio_ipc_finalize();
|
||||
fail:
|
||||
free(swa); // freeing a null ptr is valid
|
||||
free(swa); /* freeing a NULL ptr is valid */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
// Internal enumerations
|
||||
/* Internal enumerations */
|
||||
enum rsd_logtype
|
||||
{
|
||||
RSD_LOG_DEBUG = 0,
|
||||
@ -111,7 +111,7 @@ enum rsd_conn_type
|
||||
RSD_CONN_PROTO = 0x100
|
||||
};
|
||||
|
||||
// Some logging macros.
|
||||
/* Some logging macros. */
|
||||
#define RSD_WARN(fmt, args...)
|
||||
#define RSD_ERR(fmt, args...)
|
||||
#define RSD_DEBUG(fmt, args...)
|
||||
@ -159,7 +159,7 @@ static size_t rsnd_get_delay(rsound_t *rd);
|
||||
static size_t rsnd_get_ptr(rsound_t *rd);
|
||||
static int rsnd_reset(rsound_t *rd);
|
||||
|
||||
// Protocol functions
|
||||
/* Protocol functions */
|
||||
static int rsnd_send_identity_info(rsound_t *rd);
|
||||
static int rsnd_close_ctl(rsound_t *rd);
|
||||
static int rsnd_send_info_query(rsound_t *rd);
|
||||
@ -328,7 +328,7 @@ static int rsnd_send_header_info(rsound_t *rd)
|
||||
uint16_t temp_bits = 8 * rsnd_format_to_samplesize(rd->format);
|
||||
uint16_t temp_format = rd->format;
|
||||
|
||||
// Checks the format for native endian which will need to be set properly.
|
||||
/* Checks the format for native endian which will need to be set properly. */
|
||||
switch ( temp_format )
|
||||
{
|
||||
case RSD_S16_NE:
|
||||
@ -365,7 +365,7 @@ static int rsnd_send_header_info(rsound_t *rd)
|
||||
to determine whether we're running it or not, so we can byte swap accordingly.
|
||||
Could determine this compile time, but it was simpler to do it this way. */
|
||||
|
||||
// Fancy macros for embedding little endian values into the header.
|
||||
/* Fancy macros for embedding little endian values into the header. */
|
||||
#define SET32(buf,offset,x) (*((uint32_t*)(buf+offset)) = x)
|
||||
#define SET16(buf,offset,x) (*((uint16_t*)(buf+offset)) = x)
|
||||
|
||||
@ -383,7 +383,7 @@ static int rsnd_send_header_info(rsound_t *rd)
|
||||
LSB32(temp32);
|
||||
SET32(header, 16, temp32);
|
||||
|
||||
temp16 = 0; // PCM data
|
||||
temp16 = 0; /* PCM data */
|
||||
|
||||
switch( rd->format )
|
||||
{
|
||||
@ -404,10 +404,10 @@ static int rsnd_send_header_info(rsound_t *rd)
|
||||
LSB16(temp16);
|
||||
SET16(header, 20, temp16);
|
||||
|
||||
// Channels here
|
||||
/* Channels here */
|
||||
LSB16(temp_channels);
|
||||
SET16(header, CHANNEL, temp_channels);
|
||||
// Samples per sec
|
||||
/* Samples per sec */
|
||||
LSB32(temp_rate);
|
||||
SET32(header, RATE, temp_rate);
|
||||
|
||||
@ -419,7 +419,7 @@ static int rsnd_send_header_info(rsound_t *rd)
|
||||
LSB16(temp16);
|
||||
SET16(header, 32, temp16);
|
||||
|
||||
// Bits per sample
|
||||
/* Bits per sample */
|
||||
LSB16(temp_bits);
|
||||
SET16(header, FRAMESIZE, temp_bits);
|
||||
|
||||
@ -450,7 +450,7 @@ static int rsnd_get_backend_info ( rsound_t *rd )
|
||||
#define LATENCY 0
|
||||
#define CHUNKSIZE 1
|
||||
|
||||
// Header is 2 uint32_t's. = 8 bytes.
|
||||
/* Header is 2 uint32_t's. = 8 bytes. */
|
||||
uint32_t rsnd_header[2] = {0};
|
||||
|
||||
if ( rsnd_recv_chunk(rd->conn.socket, rsnd_header, RSND_HEADER_SIZE, 1) != RSND_HEADER_SIZE )
|
||||
@ -470,7 +470,7 @@ static int rsnd_get_backend_info ( rsound_t *rd )
|
||||
rd->backend_info.latency = rsnd_header[LATENCY];
|
||||
rd->backend_info.chunk_size = rsnd_header[CHUNKSIZE];
|
||||
|
||||
#define MAX_CHUNK_SIZE 1024 // We do not want larger chunk sizes than this.
|
||||
#define MAX_CHUNK_SIZE 1024 /* We do not want larger chunk sizes than this. */
|
||||
if ( rd->backend_info.chunk_size > MAX_CHUNK_SIZE || rd->backend_info.chunk_size <= 0 )
|
||||
rd->backend_info.chunk_size = MAX_CHUNK_SIZE;
|
||||
|
||||
@ -487,7 +487,7 @@ static int rsnd_get_backend_info ( rsound_t *rd )
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Only bother with setting network buffer size if we're doing TCP.
|
||||
/* Only bother with setting network buffer size if we're doing TCP. */
|
||||
if ( rd->conn_type & RSD_CONN_TCP )
|
||||
{
|
||||
#define MAX_TCP_BUFSIZE (1 << 14)
|
||||
@ -507,17 +507,17 @@ static int rsnd_get_backend_info ( rsound_t *rd )
|
||||
setsockopt(rd->conn.ctl_socket, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int));
|
||||
}
|
||||
|
||||
// Can we read the last 8 bytes so we can use the protocol interface?
|
||||
// This is non-blocking.
|
||||
/* Can we read the last 8 bytes so we can use the protocol interface? */
|
||||
/* This is non-blocking. */
|
||||
if ( rsnd_recv_chunk(rd->conn.socket, rsnd_header, RSND_HEADER_SIZE, 0) == RSND_HEADER_SIZE )
|
||||
rd->conn_type |= RSD_CONN_PROTO;
|
||||
else
|
||||
{ RSD_DEBUG("[RSound] Failed to get new proto.\n"); }
|
||||
|
||||
// We no longer want to read from this socket.
|
||||
/* We no longer want to read from this socket. */
|
||||
#ifdef _WIN32
|
||||
net_shutdown(rd->conn.socket, SD_RECEIVE);
|
||||
#elif !defined(__APPLE__) // OSX doesn't seem to like shutdown()
|
||||
#elif !defined(__APPLE__) /* OSX doesn't seem to like shutdown() */
|
||||
net_shutdown(rd->conn.socket, SHUT_RD);
|
||||
#endif
|
||||
|
||||
@ -727,7 +727,7 @@ static int64_t rsnd_get_time_usec(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
static LARGE_INTEGER freq;
|
||||
if (!freq.QuadPart && !QueryPerformanceFrequency(&freq)) // Frequency is guaranteed to not change.
|
||||
if (!freq.QuadPart && !QueryPerformanceFrequency(&freq)) /* Frequency is guaranteed to not change. */
|
||||
return 0;
|
||||
|
||||
LARGE_INTEGER count;
|
||||
@ -738,7 +738,7 @@ static int64_t rsnd_get_time_usec(void)
|
||||
return sysGetSystemTime();
|
||||
#elif defined(GEKKO)
|
||||
return ticks_to_microsecs(gettime());
|
||||
#elif defined(__MACH__) // OSX doesn't have clock_gettime ...
|
||||
#elif defined(__MACH__) /* OSX doesn't have clock_gettime ... */
|
||||
clock_serv_t cclock;
|
||||
mach_timespec_t mts;
|
||||
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||
@ -818,10 +818,14 @@ static size_t rsnd_fill_buffer(rsound_t *rd, const char *buf, size_t size)
|
||||
slock_lock(rd->thread.mutex);
|
||||
fifo_write(rd->fifo_buffer, buf, size);
|
||||
slock_unlock(rd->thread.mutex);
|
||||
//RSD_DEBUG("[RSound] fill_buffer: Wrote to buffer.\n");
|
||||
#if 0
|
||||
RSD_DEBUG("[RSound] fill_buffer: Wrote to buffer.\n");
|
||||
#endif
|
||||
|
||||
/* Send signal to thread that buffer has been updated */
|
||||
//RSD_DEBUG("[RSound] fill_buffer: Waking up thread.\n");
|
||||
#if 0
|
||||
RSD_DEBUG("[RSound] fill_buffer: Waking up thread.\n");
|
||||
#endif
|
||||
scond_signal(rd->thread.cond);
|
||||
|
||||
return size;
|
||||
@ -941,7 +945,7 @@ static int rsnd_close_ctl(rsound_t *rd)
|
||||
else if ( fd.revents & POLLHUP )
|
||||
return 0;
|
||||
|
||||
// Let's wait for reply (or POLLHUP)
|
||||
/* Let's wait for reply (or POLLHUP) */
|
||||
|
||||
fd.events = POLLIN;
|
||||
int index = 0;
|
||||
@ -958,14 +962,14 @@ static int rsnd_close_ctl(rsound_t *rd)
|
||||
if (fd.revents & POLLIN)
|
||||
{
|
||||
const char *subchar;
|
||||
|
||||
// We just read everything in large chunks until we find what we're looking for
|
||||
/* We just read everything in large chunks until we find
|
||||
* what we're looking for */
|
||||
int rc = net_recv(rd->conn.ctl_socket, buf + index, RSD_PROTO_MAXSIZE*2 - 1 - index, 0);
|
||||
|
||||
if (rc <= 0 )
|
||||
return -1;
|
||||
|
||||
// Can we find it directly?
|
||||
/* Can we find it directly? */
|
||||
if ( strstr(buf, "RSD 12 CLOSECTL OK") != NULL )
|
||||
break;
|
||||
else if ( strstr(buf, "RSD 15 CLOSECTL ERROR") != NULL )
|
||||
@ -989,8 +993,9 @@ static int rsnd_close_ctl(rsound_t *rd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Sends delay info request to server on the ctl socket. This code section isn't critical, and will work if it works.
|
||||
// It will never block.
|
||||
/* Sends delay info request to server on the ctl socket.
|
||||
* This code section isn't critical, and will work if it works.
|
||||
* It will never block. */
|
||||
static int rsnd_send_info_query(rsound_t *rd)
|
||||
{
|
||||
char tmpbuf[RSD_PROTO_MAXSIZE];
|
||||
@ -1007,15 +1012,15 @@ static int rsnd_send_info_query(rsound_t *rd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// We check if there's any pending delay information from the server.
|
||||
// In that case, we read the packet.
|
||||
/* We check if there's any pending delay information from the server.
|
||||
* In that case, we read the packet. */
|
||||
static int rsnd_update_server_info(rsound_t *rd)
|
||||
{
|
||||
long long int client_ptr = -1;
|
||||
long long int serv_ptr = -1;
|
||||
char temp[RSD_PROTO_MAXSIZE + 1] = {0};
|
||||
|
||||
// We read until we have the last (most recent) data in the network buffer.
|
||||
/* We read until we have the last (most recent) data in the network buffer. */
|
||||
for (;;)
|
||||
{
|
||||
ssize_t rc;
|
||||
@ -1023,7 +1028,7 @@ static int rsnd_update_server_info(rsound_t *rd)
|
||||
char *tmpstr;
|
||||
memset(temp, 0, sizeof(temp));
|
||||
|
||||
// We first recieve the small header. We just use the larger buffer as it is disposable.
|
||||
/* We first recieve the small header. We just use the larger buffer as it is disposable. */
|
||||
rc = rsnd_recv_chunk(rd->conn.ctl_socket, temp, RSD_PROTO_CHUNKSIZE, 0);
|
||||
if ( rc == 0 )
|
||||
break;
|
||||
@ -1035,22 +1040,22 @@ static int rsnd_update_server_info(rsound_t *rd)
|
||||
if (!(substr = strstr(temp, "RSD")))
|
||||
return -1;
|
||||
|
||||
// Jump over "RSD" in header
|
||||
/* Jump over "RSD" in header */
|
||||
substr += 3;
|
||||
|
||||
// The length of the argument message is stored in the small 8 byte header.
|
||||
/* The length of the argument message is stored in the small 8 byte header. */
|
||||
long int len = strtol(substr, NULL, 0);
|
||||
|
||||
// Recieve the rest of the data.
|
||||
/* Recieve the rest of the data. */
|
||||
if ( rsnd_recv_chunk(rd->conn.ctl_socket, temp, len, 0) < len )
|
||||
return -1;
|
||||
|
||||
// We only bother if this is an INFO message.
|
||||
/* We only bother if this is an INFO message. */
|
||||
substr = strstr(temp, "INFO");
|
||||
if (!substr)
|
||||
continue;
|
||||
|
||||
// Jump over "INFO" in header
|
||||
/* Jump over "INFO" in header */
|
||||
substr += 4;
|
||||
|
||||
client_ptr = strtoull(substr, &tmpstr, 0);
|
||||
@ -1074,7 +1079,7 @@ static int rsnd_update_server_info(rsound_t *rd)
|
||||
|
||||
RSD_DEBUG("[RSound] Delay: %d, Delta: %d.\n", delay, delta);
|
||||
|
||||
// We only update the pointer if the data we got is quite recent.
|
||||
/* We only update the pointer if the data we got is quite recent. */
|
||||
if ( rd->total_written - client_ptr < 4 * rd->backend_info.chunk_size && rd->total_written > client_ptr )
|
||||
{
|
||||
int offset_delta = delta - delay;
|
||||
@ -1094,7 +1099,7 @@ static int rsnd_update_server_info(rsound_t *rd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Sort of simulates the behavior of pthread_cancel()
|
||||
/* Sort of simulates the behavior of pthread_cancel() */
|
||||
#define _TEST_CANCEL() \
|
||||
if ( !rd->thread_active ) \
|
||||
break
|
||||
@ -1115,8 +1120,8 @@ static void rsnd_thread ( void * thread_data )
|
||||
{
|
||||
_TEST_CANCEL();
|
||||
|
||||
// We ask the server to send its latest backend data. Do not really care about errors atm.
|
||||
// We only bother to check after 1 sec of audio has been played, as it might be quite inaccurate in the start of the stream.
|
||||
/* We ask the server to send its latest backend data. Do not really care about errors atm.
|
||||
* We only bother to check after 1 sec of audio has been played, as it might be quite inaccurate in the start of the stream. */
|
||||
if ( (rd->conn_type & RSD_CONN_PROTO) && (rd->total_written > rd->channels * rd->rate * rd->samplesize) )
|
||||
{
|
||||
rsnd_send_info_query(rd);
|
||||
@ -1175,8 +1180,9 @@ static void rsnd_thread ( void * thread_data )
|
||||
|
||||
if ( rd->thread_active )
|
||||
{
|
||||
// There is a very slim change of getting a deadlock using the cond_wait scheme.
|
||||
// This solution is rather dirty, but avoids complete deadlocks at the very least.
|
||||
/* There is a very slim change of getting a deadlock using the cond_wait scheme.
|
||||
* This solution is rather dirty, but avoids complete deadlocks at the very least.
|
||||
*/
|
||||
|
||||
slock_lock(rd->thread.cond_mutex);
|
||||
scond_signal(rd->thread.cond);
|
||||
@ -1243,9 +1249,10 @@ static void rsnd_cb_thread(void *thread_data)
|
||||
}
|
||||
else
|
||||
{
|
||||
// The network might do things in large chunks, so it may request large amounts of data in short periods of time.
|
||||
// This breaks when the caller cannot buffer up big buffers beforehand, so do short sleeps inbetween.
|
||||
// This is somewhat dirty, but I cannot see a better solution
|
||||
/* The network might do things in large chunks, so it may request large amounts of data in short periods of time.
|
||||
* This breaks when the caller cannot buffer up big buffers beforehand, so do short sleeps inbetween.
|
||||
* This is somewhat dirty, but I cannot see a better solution
|
||||
*/
|
||||
retro_sleep(1);
|
||||
}
|
||||
}
|
||||
@ -1306,13 +1313,13 @@ static int rsnd_reset(rsound_t *rd)
|
||||
|
||||
int rsd_stop(rsound_t *rd)
|
||||
{
|
||||
const char buf[] = "RSD 5 STOP";
|
||||
|
||||
retro_assert(rd != NULL);
|
||||
rsnd_stop_thread(rd);
|
||||
|
||||
const char buf[] = "RSD 5 STOP";
|
||||
|
||||
// Do not really care about errors here.
|
||||
// The socket will be closed down in any case in rsnd_reset().
|
||||
/* Do not really care about errors here.
|
||||
* The socket will be closed down in any case in rsnd_reset(). */
|
||||
rsnd_send_chunk(rd->conn.ctl_socket, buf, strlen(buf), 0);
|
||||
|
||||
rsnd_reset(rd);
|
||||
@ -1364,7 +1371,7 @@ int rsd_exec(rsound_t *rsound)
|
||||
retro_assert(rsound != NULL);
|
||||
RSD_DEBUG("[RSound] rsd_exec().\n");
|
||||
|
||||
// Makes sure we have a working connection
|
||||
/* Makes sure we have a working connection */
|
||||
if ( rsound->conn.socket < 0 )
|
||||
{
|
||||
RSD_DEBUG("[RSound] Calling rsd_start().\n");
|
||||
@ -1459,7 +1466,7 @@ int rsd_set_param(rsound_t *rd, enum rsd_settings option, void* param)
|
||||
rd->max_latency = *((int*)param);
|
||||
break;
|
||||
|
||||
// Checks if format is valid.
|
||||
/* Checks if format is valid. */
|
||||
case RSD_FORMAT:
|
||||
rd->format = (uint16_t)(*((int*)param));
|
||||
rd->samplesize = rsnd_format_to_samplesize(rd->format);
|
||||
@ -1555,6 +1562,7 @@ int rsd_pause(rsound_t* rsound, int enable)
|
||||
|
||||
int rsd_init(rsound_t** rsound)
|
||||
{
|
||||
int format = RSD_S16_LE;
|
||||
*rsound = calloc(1, sizeof(rsound_t));
|
||||
if (*rsound == NULL)
|
||||
return -1;
|
||||
@ -1569,8 +1577,7 @@ int rsd_init(rsound_t** rsound)
|
||||
(*rsound)->cb_lock = slock_new();
|
||||
(*rsound)->thread.cond = scond_new();
|
||||
|
||||
// Assumes default of S16_LE samples.
|
||||
int format = RSD_S16_LE;
|
||||
/* Assumes default of S16_LE samples. */
|
||||
rsd_set_param(*rsound, RSD_FORMAT, &format);
|
||||
|
||||
rsd_set_param(*rsound, RSD_HOST, RSD_DEFAULT_HOST);
|
||||
|
@ -205,4 +205,4 @@ static INLINE void ctr_set_scale_vector(ctr_scale_vector_t* vec,
|
||||
vec->v = -1.0 / texture_height;
|
||||
}
|
||||
|
||||
#endif // CTR_COMMON_H__
|
||||
#endif /* CTR_COMMON_H__ */
|
||||
|
@ -18,7 +18,7 @@
|
||||
#ifndef __FPGA_COMMON_H
|
||||
#define __FPGA_COMMON_H
|
||||
|
||||
#define NUMBER_OF_WRITE_FRAMES 1//XPAR_AXIVDMA_0_NUM_FSTORES
|
||||
#define NUMBER_OF_WRITE_FRAMES 1 /* XPAR_AXIVDMA_0_NUM_FSTORES */
|
||||
#define STORAGE_SIZE NUMBER_OF_WRITE_FRAMES * ((1920*1080)<<2)
|
||||
#define FRAME_SIZE (STORAGE_SIZE / NUMBER_OF_WRITE_FRAMES)
|
||||
|
||||
|
@ -159,9 +159,9 @@ matrix_float4x4 matrix_rotate_z(float rot)
|
||||
id<CAMetalDrawable> _drawable;
|
||||
video_viewport_t _viewport;
|
||||
id<MTLSamplerState> _samplers[TEXTURE_FILTER_MIPMAP_NEAREST + 1];
|
||||
Filter *_filters[RPixelFormatCount]; // convert to bgra8888
|
||||
Filter *_filters[RPixelFormatCount]; /* convert to BGRA8888 */
|
||||
|
||||
// main render pass state
|
||||
/* Main render pass state */
|
||||
id<MTLRenderCommandEncoder> _rce;
|
||||
|
||||
id<MTLCommandBuffer> _blitCommandBuffer;
|
||||
@ -402,9 +402,9 @@ matrix_float4x4 matrix_rotate_z(float rot)
|
||||
{
|
||||
vals = [MTLFunctionConstantValues new];
|
||||
float values[3] = {
|
||||
1.25f, // baseScale
|
||||
0.50f, // density
|
||||
0.15f, // speed
|
||||
1.25f, /* baseScale */
|
||||
0.50f, /* density */
|
||||
0.15f, /* speed */
|
||||
};
|
||||
[vals setConstantValue:&values[0] type:MTLDataTypeFloat withName:@"snowBaseScale"];
|
||||
[vals setConstantValue:&values[1] type:MTLDataTypeFloat withName:@"snowDensity"];
|
||||
@ -423,9 +423,9 @@ matrix_float4x4 matrix_rotate_z(float rot)
|
||||
{
|
||||
vals = [MTLFunctionConstantValues new];
|
||||
float values[3] = {
|
||||
3.50f, // baseScale
|
||||
0.70f, // density
|
||||
0.25f, // speed
|
||||
3.50f, /* baseScale */
|
||||
0.70f, /* density */
|
||||
0.25f, /* speed */
|
||||
};
|
||||
[vals setConstantValue:&values[0] type:MTLDataTypeFloat withName:@"snowBaseScale"];
|
||||
[vals setConstantValue:&values[1] type:MTLDataTypeFloat withName:@"snowDensity"];
|
||||
@ -634,7 +634,9 @@ matrix_float4x4 matrix_rotate_z(float rot)
|
||||
return;
|
||||
|
||||
_captureEnabled = captureEnabled;
|
||||
//_layer.framebufferOnly = !captureEnabled;
|
||||
#if 0
|
||||
_layer.framebufferOnly = !captureEnabled;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (bool)captureEnabled
|
||||
@ -772,7 +774,7 @@ matrix_float4x4 matrix_rotate_z(float rot)
|
||||
[bce endEncoding];
|
||||
}
|
||||
#endif
|
||||
// pending blits for mipmaps or render passes for slang shaders
|
||||
/* Pending blits for mipmaps or render passes for slang shaders */
|
||||
[_blitCommandBuffer commit];
|
||||
[_blitCommandBuffer waitUntilCompleted];
|
||||
_blitCommandBuffer = nil;
|
||||
@ -829,7 +831,7 @@ matrix_float4x4 matrix_rotate_z(float rot)
|
||||
id<MTLDevice> _device;
|
||||
NSUInteger _blockLen;
|
||||
BufferNode *_head;
|
||||
NSUInteger _offset; // offset into _current
|
||||
NSUInteger _offset; /* offset into _current */
|
||||
BufferNode *_current;
|
||||
NSUInteger _length;
|
||||
NSUInteger _allocated;
|
||||
@ -1285,13 +1287,13 @@ static const NSUInteger kConstantAlignment = 4;
|
||||
@implementation TexturedView
|
||||
{
|
||||
Context *_context;
|
||||
id<MTLTexture> _texture; // optimal render texture
|
||||
id<MTLTexture> _texture; /* Optimal render texture */
|
||||
Vertex _v[4];
|
||||
CGSize _size; // size of view in pixels
|
||||
CGSize _size; /* Size of view in pixels */
|
||||
CGRect _frame;
|
||||
NSUInteger _bpp;
|
||||
|
||||
id<MTLTexture> _src; // source texture
|
||||
id<MTLTexture> _src; /* Source texture */
|
||||
bool _srcDirty;
|
||||
}
|
||||
|
||||
|
@ -45,33 +45,24 @@
|
||||
#define STRUCT_ASSIGN(x, y) \
|
||||
{ \
|
||||
NSObject * __y = y; \
|
||||
if (x != nil) { \
|
||||
if (x != nil) \
|
||||
{ \
|
||||
NSObject * __foo = (__bridge_transfer NSObject *)(__bridge void *)(x); \
|
||||
__foo = nil; \
|
||||
x = (__bridge __typeof__(x))nil; \
|
||||
} \
|
||||
if (__y != nil) \
|
||||
x = (__bridge __typeof__(x))(__bridge_retained void *)((NSObject *)__y); \
|
||||
}
|
||||
x = (__bridge __typeof__(x))(__bridge_retained void *)((NSObject *)__y)
|
||||
|
||||
@implementation MetalView
|
||||
|
||||
#if !defined(HAVE_COCOATOUCH)
|
||||
- (void)keyDown:(NSEvent*)theEvent
|
||||
{
|
||||
}
|
||||
- (void)keyDown:(NSEvent*)theEvent { }
|
||||
#endif
|
||||
|
||||
/* Stop the annoying sound when pressing a key. */
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isFlipped
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
- (BOOL)acceptsFirstResponder { return YES; }
|
||||
- (BOOL)isFlipped { return YES; }
|
||||
@end
|
||||
|
||||
#pragma mark - private categories
|
||||
@ -110,15 +101,14 @@
|
||||
|
||||
CAMetalLayer *_layer;
|
||||
|
||||
// render target layer state
|
||||
/* Render target layer state */
|
||||
id<MTLRenderPipelineState> _t_pipelineState;
|
||||
id<MTLRenderPipelineState> _t_pipelineStateNoAlpha;
|
||||
|
||||
id<MTLSamplerState> _samplerStateLinear;
|
||||
id<MTLSamplerState> _samplerStateNearest;
|
||||
|
||||
// other state
|
||||
Uniforms _viewportMVP;
|
||||
Uniforms _viewportMVP; /* Other state */
|
||||
}
|
||||
|
||||
- (instancetype)initWithVideo:(const video_info_t *)video
|
||||
@ -127,6 +117,7 @@
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
gfx_ctx_mode_t mode;
|
||||
_device = MTLCreateSystemDefaultDevice();
|
||||
MetalView *view = (MetalView *)apple_platform.renderView;
|
||||
view.device = _device;
|
||||
@ -134,9 +125,7 @@
|
||||
_layer = (CAMetalLayer *)view.layer;
|
||||
|
||||
if (![self _initMetal])
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
_video = *video;
|
||||
_viewport = (video_viewport_t *)calloc(1, sizeof(video_viewport_t));
|
||||
@ -144,16 +133,16 @@
|
||||
|
||||
_keepAspect = _video.force_aspect;
|
||||
|
||||
gfx_ctx_mode_t mode = {
|
||||
.width = _video.width,
|
||||
.height = _video.height,
|
||||
.fullscreen = _video.fullscreen,
|
||||
};
|
||||
mode.width = _video.width;
|
||||
mode.height = _video.height;
|
||||
mode.fullscreen = _video.fullscreen;
|
||||
|
||||
if (mode.width == 0 || mode.height == 0)
|
||||
{
|
||||
// 0 indicates full screen, so we'll use the view's dimensions, which should already be full screen
|
||||
// If this turns out to be the wrong assumption, we can use NSScreen to query the dimensions
|
||||
/* 0 indicates full screen, so we'll use the view's dimensions,
|
||||
* which should already be full screen.
|
||||
* If this turns out to be the wrong assumption,
|
||||
* we can use NSScreen to query the dimensions */
|
||||
CGSize size = view.frame.size;
|
||||
mode.width = (unsigned int)size.width;
|
||||
mode.height = (unsigned int)size.height;
|
||||
@ -164,16 +153,17 @@
|
||||
*input = NULL;
|
||||
*inputData = NULL;
|
||||
|
||||
// graphics display driver
|
||||
/* Graphics display driver */
|
||||
_display = [[MenuDisplay alloc] initWithContext:_context];
|
||||
|
||||
// menu view
|
||||
/* Menu view */
|
||||
_menu = [[MetalMenu alloc] initWithContext:_context];
|
||||
|
||||
// frame buffer view
|
||||
/* Framebuffer view */
|
||||
{
|
||||
ViewDescriptor *vd = [ViewDescriptor new];
|
||||
vd.format = _video.rgb32 ? RPixelFormatBGRX8Unorm : RPixelFormatB5G6R5Unorm;
|
||||
vd.format = _video.rgb32
|
||||
? RPixelFormatBGRX8Unorm
|
||||
: RPixelFormatB5G6R5Unorm;
|
||||
vd.size = CGSizeMake(video->width, video->height);
|
||||
vd.filter = _video.smooth ? RTextureFilterLinear : RTextureFilterNearest;
|
||||
_frameView = [[FrameView alloc] initWithDescriptor:vd context:_context];
|
||||
@ -181,7 +171,7 @@
|
||||
[_frameView setFilteringIndex:0 smooth:video->smooth];
|
||||
}
|
||||
|
||||
// overlay view
|
||||
/* Overlay view */
|
||||
_overlay = [[Overlay alloc] initWithContext:_context];
|
||||
|
||||
font_driver_init_osd((__bridge void *)self,
|
||||
@ -207,10 +197,12 @@
|
||||
{
|
||||
_library = [_device newDefaultLibrary];
|
||||
_context = [[Context alloc] initWithDevice:_device
|
||||
layer:_layer
|
||||
library:_library];
|
||||
layer:_layer library:_library];
|
||||
|
||||
{
|
||||
NSError *err;
|
||||
MTLRenderPipelineDescriptor *psd;
|
||||
MTLRenderPipelineColorAttachmentDescriptor *ca;
|
||||
MTLVertexDescriptor *vd = [MTLVertexDescriptor new];
|
||||
vd.attributes[0].offset = 0;
|
||||
vd.attributes[0].format = MTLVertexFormatFloat3;
|
||||
@ -218,10 +210,10 @@
|
||||
vd.attributes[1].format = MTLVertexFormatFloat2;
|
||||
vd.layouts[0].stride = sizeof(Vertex);
|
||||
|
||||
MTLRenderPipelineDescriptor *psd = [MTLRenderPipelineDescriptor new];
|
||||
psd = [MTLRenderPipelineDescriptor new];
|
||||
psd.label = @"Pipeline+Alpha";
|
||||
|
||||
MTLRenderPipelineColorAttachmentDescriptor *ca = psd.colorAttachments[0];
|
||||
ca = psd.colorAttachments[0];
|
||||
ca.pixelFormat = _layer.pixelFormat;
|
||||
ca.blendingEnabled = YES;
|
||||
ca.sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha;
|
||||
@ -234,7 +226,6 @@
|
||||
psd.vertexFunction = [_library newFunctionWithName:@"basic_vertex_proj_tex"];
|
||||
psd.fragmentFunction = [_library newFunctionWithName:@"basic_fragment_proj_tex"];
|
||||
|
||||
NSError *err;
|
||||
_t_pipelineState = [_device newRenderPipelineStateWithDescriptor:psd error:&err];
|
||||
if (err != nil)
|
||||
{
|
||||
@ -271,19 +262,14 @@
|
||||
video_driver_set_size(_viewport->full_width, _viewport->full_height);
|
||||
_layer.drawableSize = CGSizeMake(width, height);
|
||||
video_driver_update_viewport(_viewport, forceFull, _keepAspect);
|
||||
|
||||
// update matrix
|
||||
_context.viewport = _viewport;
|
||||
_context.viewport = _viewport; /* Update matrix */
|
||||
|
||||
_viewportMVP.outputSize = simd_make_float2(_viewport->full_width, _viewport->full_height);
|
||||
}
|
||||
|
||||
#pragma mark - video
|
||||
|
||||
- (void)setVideo:(const video_info_t *)video
|
||||
{
|
||||
|
||||
}
|
||||
- (void)setVideo:(const video_info_t *)video { }
|
||||
|
||||
- (bool)renderFrame:(const void *)frame
|
||||
data:(void*)data
|
||||
@ -418,7 +404,7 @@
|
||||
{
|
||||
id<MTLRenderCommandEncoder> rce = _context.rce;
|
||||
|
||||
/* draw back buffer */
|
||||
/* Draw back buffer */
|
||||
[rce pushDebugGroup:@"core frame"];
|
||||
[_frameView drawWithContext:_context];
|
||||
|
||||
@ -427,13 +413,9 @@
|
||||
[rce setVertexBytes:_context.uniforms length:sizeof(*_context.uniforms) atIndex:BufferIndexUniforms];
|
||||
[rce setRenderPipelineState:_t_pipelineStateNoAlpha];
|
||||
if (_frameView.filter == RTextureFilterNearest)
|
||||
{
|
||||
[rce setFragmentSamplerState:_samplerStateNearest atIndex:SamplerIndexDraw];
|
||||
}
|
||||
else
|
||||
{
|
||||
[rce setFragmentSamplerState:_samplerStateLinear atIndex:SamplerIndexDraw];
|
||||
}
|
||||
[_frameView drawWithEncoder:rce];
|
||||
}
|
||||
[rce popDebugGroup];
|
||||
@ -455,13 +437,9 @@
|
||||
[rce setVertexBytes:_context.uniforms length:sizeof(*_context.uniforms) atIndex:BufferIndexUniforms];
|
||||
[rce setRenderPipelineState:_t_pipelineState];
|
||||
if (_menu.view.filter == RTextureFilterNearest)
|
||||
{
|
||||
[rce setFragmentSamplerState:_samplerStateNearest atIndex:SamplerIndexDraw];
|
||||
}
|
||||
else
|
||||
{
|
||||
[rce setFragmentSamplerState:_samplerStateLinear atIndex:SamplerIndexDraw];
|
||||
}
|
||||
[_menu.view drawWithEncoder:rce];
|
||||
[rce popDebugGroup];
|
||||
}
|
||||
@ -476,31 +454,23 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)_endFrame
|
||||
{
|
||||
[_context end];
|
||||
}
|
||||
|
||||
- (void)setNeedsResize
|
||||
{
|
||||
// TODO(sgc): resize all drawables
|
||||
}
|
||||
/* TODO/FIXME (sgc): resize all drawables */
|
||||
- (void)setNeedsResize { }
|
||||
|
||||
- (void)_endFrame { [_context end]; }
|
||||
- (void)setRotation:(unsigned)rotation
|
||||
{
|
||||
[_context setRotation:rotation];
|
||||
}
|
||||
|
||||
- (Uniforms *)viewportMVP
|
||||
{
|
||||
return &_viewportMVP;
|
||||
}
|
||||
- (Uniforms *)viewportMVP { return &_viewportMVP; }
|
||||
|
||||
#pragma mark - MTKViewDelegate
|
||||
|
||||
- (void)mtkView:(MTKView *)view drawableSizeWillChange:(CGSize)size
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
NSLog(@"mtkView drawableSizeWillChange to: %f x %f",size.width,size.height);
|
||||
#endif
|
||||
#ifdef HAVE_COCOATOUCH
|
||||
CGFloat scale = [[UIScreen mainScreen] scale];
|
||||
[self setViewportWidth:(unsigned int)view.bounds.size.width*scale height:(unsigned int)view.bounds.size.height*scale forceFull:NO allowRotate:YES];
|
||||
@ -509,11 +479,7 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)drawInMTKView:(MTKView *)view
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)drawInMTKView:(MTKView *)view { }
|
||||
@end
|
||||
|
||||
@implementation MetalMenu
|
||||
@ -526,9 +492,7 @@
|
||||
- (instancetype)initWithContext:(Context *)context
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -561,10 +525,8 @@
|
||||
if (!(CGSizeEqualToSize(_view.size, size) &&
|
||||
_view.format == format &&
|
||||
_view.filter == filter))
|
||||
{
|
||||
_view = nil;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_view)
|
||||
{
|
||||
@ -632,14 +594,14 @@ typedef struct MTLALIGN(16)
|
||||
@implementation FrameView
|
||||
{
|
||||
Context *_context;
|
||||
id<MTLTexture> _texture; // final render texture
|
||||
id<MTLTexture> _texture; /* Final render texture */
|
||||
Vertex _v[4];
|
||||
VertexSlang _vertex[4];
|
||||
CGSize _size; // size of view in pixels
|
||||
CGSize _size; /* Size of view in pixels */
|
||||
CGRect _frame;
|
||||
NSUInteger _bpp;
|
||||
|
||||
id<MTLTexture> _src; // src texture
|
||||
id<MTLTexture> _src; /* Source texture */
|
||||
bool _srcDirty;
|
||||
|
||||
id<MTLSamplerState> _samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX];
|
||||
@ -661,14 +623,11 @@ typedef struct MTLALIGN(16)
|
||||
_format = d.format;
|
||||
_bpp = RPixelFormatToBPP(_format);
|
||||
_filter = d.filter;
|
||||
if (_format == RPixelFormatBGRA8Unorm || _format == RPixelFormatBGRX8Unorm)
|
||||
{
|
||||
if ( _format == RPixelFormatBGRA8Unorm
|
||||
|| _format == RPixelFormatBGRX8Unorm)
|
||||
_drawState = ViewDrawStateEncoder;
|
||||
}
|
||||
else
|
||||
{
|
||||
_drawState = ViewDrawStateAll;
|
||||
}
|
||||
_visible = YES;
|
||||
_engine.mvp = matrix_proj_ortho(0, 1, 0, 1);
|
||||
[self _initSamplers];
|
||||
@ -677,7 +636,7 @@ typedef struct MTLALIGN(16)
|
||||
self.frame = CGRectMake(0, 0, 1, 1);
|
||||
resize_render_targets = YES;
|
||||
|
||||
// init slang vertex buffer
|
||||
/* Initialize slang vertex buffer */
|
||||
VertexSlang v[4] = {
|
||||
{simd_make_float4(0, 1, 0, 1), simd_make_float2(0, 1)},
|
||||
{simd_make_float4(1, 1, 0, 1), simd_make_float2(1, 1)},
|
||||
@ -691,11 +650,14 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
- (void)_initSamplers
|
||||
{
|
||||
int i;
|
||||
MTLSamplerDescriptor *sd = [MTLSamplerDescriptor new];
|
||||
|
||||
/* Initialize samplers */
|
||||
for (unsigned i = 0; i < RARCH_WRAP_MAX; i++)
|
||||
for (i = 0; i < RARCH_WRAP_MAX; i++)
|
||||
{
|
||||
id<MTLSamplerState> ss;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case RARCH_WRAP_BORDER:
|
||||
@ -726,7 +688,7 @@ typedef struct MTLALIGN(16)
|
||||
sd.minFilter = MTLSamplerMinMagFilterLinear;
|
||||
sd.magFilter = MTLSamplerMinMagFilterLinear;
|
||||
|
||||
id<MTLSamplerState> ss = [_context.device newSamplerStateWithDescriptor:sd];
|
||||
ss = [_context.device newSamplerStateWithDescriptor:sd];
|
||||
_samplers[RARCH_FILTER_LINEAR][i] = ss;
|
||||
|
||||
sd.minFilter = MTLSamplerMinMagFilterNearest;
|
||||
@ -757,9 +719,11 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
resize_render_targets = YES;
|
||||
|
||||
if (_format != RPixelFormatBGRA8Unorm && _format != RPixelFormatBGRX8Unorm)
|
||||
if ( _format != RPixelFormatBGRA8Unorm
|
||||
&& _format != RPixelFormatBGRX8Unorm)
|
||||
{
|
||||
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatR16Uint
|
||||
MTLTextureDescriptor *td = [MTLTextureDescriptor
|
||||
texture2DDescriptorWithPixelFormat:MTLPixelFormatR16Uint
|
||||
width:(NSUInteger)size.width
|
||||
height:(NSUInteger)size.height
|
||||
mipmapped:NO];
|
||||
@ -778,16 +742,13 @@ typedef struct MTLALIGN(16)
|
||||
return;
|
||||
|
||||
_frame = frame;
|
||||
|
||||
// update vertices
|
||||
/* Update vertices */
|
||||
CGPoint o = frame.origin;
|
||||
CGSize s = frame.size;
|
||||
|
||||
CGFloat l = o.x;
|
||||
CGFloat t = o.y;
|
||||
CGFloat r = o.x + s.width;
|
||||
CGFloat b = o.y + s.height;
|
||||
|
||||
Vertex v[4] = {
|
||||
{simd_make_float3(l, b, 0), simd_make_float2(0, 1)},
|
||||
{simd_make_float3(r, b, 0), simd_make_float2(1, 1)},
|
||||
@ -797,10 +758,7 @@ typedef struct MTLALIGN(16)
|
||||
memcpy(_v, v, sizeof(_v));
|
||||
}
|
||||
|
||||
- (CGRect)frame
|
||||
{
|
||||
return _frame;
|
||||
}
|
||||
- (CGRect)frame { return _frame; }
|
||||
|
||||
- (void)_convertFormat
|
||||
{
|
||||
@ -840,24 +798,23 @@ typedef struct MTLALIGN(16)
|
||||
if (_engine.frame.texture[0].size_data.x != _size.width ||
|
||||
_engine.frame.texture[0].size_data.y != _size.height)
|
||||
{
|
||||
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
|
||||
width:(NSUInteger)_size.width
|
||||
height:(NSUInteger)_size.height
|
||||
mipmapped:false];
|
||||
td.usage = MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite;
|
||||
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm width:(NSUInteger)_size.width height:(NSUInteger)_size.height mipmapped:false];
|
||||
td.usage = MTLTextureUsageShaderRead
|
||||
| MTLTextureUsageShaderWrite;
|
||||
[self _initTexture:&_engine.frame.texture[0] withDescriptor:td];
|
||||
}
|
||||
}
|
||||
|
||||
- (bool)readViewport:(uint8_t *)buffer isIdle:(bool)isIdle
|
||||
{
|
||||
bool res;
|
||||
bool enabled = _context.captureEnabled;
|
||||
if (!enabled)
|
||||
_context.captureEnabled = YES;
|
||||
|
||||
video_driver_cached_frame();
|
||||
|
||||
bool res = [_context readBackBuffer:buffer];
|
||||
res = [_context readBackBuffer:buffer];
|
||||
|
||||
if (!enabled)
|
||||
_context.captureEnabled = NO;
|
||||
@ -915,11 +872,10 @@ typedef struct MTLALIGN(16)
|
||||
- (void)_initHistory
|
||||
{
|
||||
int i;
|
||||
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm
|
||||
width:(NSUInteger)_size.width
|
||||
height:(NSUInteger)_size.height
|
||||
mipmapped:false];
|
||||
td.usage = MTLTextureUsageShaderRead | MTLTextureUsageShaderWrite | MTLTextureUsageRenderTarget;
|
||||
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatBGRA8Unorm width:(NSUInteger)_size.width height:(NSUInteger)_size.height mipmapped:false];
|
||||
td.usage = MTLTextureUsageShaderRead
|
||||
| MTLTextureUsageShaderWrite
|
||||
| MTLTextureUsageRenderTarget;
|
||||
|
||||
for (i = 0; i < _shader->history_size + 1; i++)
|
||||
[self _initTexture:&_engine.frame.texture[i] withDescriptor:td];
|
||||
@ -939,7 +895,10 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
- (void)drawWithContext:(Context *)ctx
|
||||
{
|
||||
unsigned i;
|
||||
int i;
|
||||
id<MTLCommandBuffer> cb;
|
||||
MTLRenderPassDescriptor *rpd;
|
||||
|
||||
_texture = _engine.frame.texture[0].view;
|
||||
[self _convertFormat];
|
||||
|
||||
@ -956,23 +915,25 @@ typedef struct MTLALIGN(16)
|
||||
}
|
||||
}
|
||||
|
||||
id<MTLCommandBuffer> cb = ctx.blitCommandBuffer;
|
||||
cb = ctx.blitCommandBuffer;
|
||||
[cb pushDebugGroup:@"shaders"];
|
||||
|
||||
MTLRenderPassDescriptor *rpd = [MTLRenderPassDescriptor new];
|
||||
rpd = [MTLRenderPassDescriptor new];
|
||||
rpd.colorAttachments[0].loadAction = MTLLoadActionDontCare;
|
||||
rpd.colorAttachments[0].storeAction = MTLStoreActionStore;
|
||||
|
||||
for (unsigned i = 0; i < _shader->passes; i++)
|
||||
for (i = 0; i < _shader->passes; i++)
|
||||
{
|
||||
int j;
|
||||
NSURL *shader_path;
|
||||
__unsafe_unretained id<MTLTexture> textures[SLANG_NUM_BINDINGS] = {NULL};
|
||||
id<MTLSamplerState> samplers[SLANG_NUM_BINDINGS] = {NULL};
|
||||
texture_sem_t *texture_sem = NULL;
|
||||
id<MTLRenderCommandEncoder> rce = nil;
|
||||
|
||||
BOOL backBuffer = (_engine.pass[i].rt.view == nil);
|
||||
|
||||
if (backBuffer)
|
||||
{
|
||||
rce = _context.rce;
|
||||
}
|
||||
else
|
||||
{
|
||||
rpd.colorAttachments[0].texture = _engine.pass[i].rt.view;
|
||||
@ -981,8 +942,8 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
[rce setRenderPipelineState:_engine.pass[i]._state];
|
||||
|
||||
NSURL *shaderPath = [NSURL fileURLWithPath:_engine.pass[i]._state.label];
|
||||
rce.label = shaderPath.lastPathComponent.stringByDeletingPathExtension;
|
||||
shader_path = [NSURL fileURLWithPath:_engine.pass[i]._state.label];
|
||||
rce.label = shader_path.lastPathComponent.stringByDeletingPathExtension;
|
||||
|
||||
_engine.pass[i].frame_count = (uint32_t)_frameCount;
|
||||
if (_shader->pass[i].frame_count_mod)
|
||||
@ -996,7 +957,7 @@ typedef struct MTLALIGN(16)
|
||||
_engine.pass[i].frame_direction = 1;
|
||||
#endif
|
||||
|
||||
for (unsigned j = 0; j < SLANG_CBUFFER_MAX; j++)
|
||||
for (j = 0; j < SLANG_CBUFFER_MAX; j++)
|
||||
{
|
||||
id<MTLBuffer> buffer = _engine.pass[i].buffers[j];
|
||||
cbuffer_sem_t *buffer_sem = &_engine.pass[i].semantics.cbuffers[j];
|
||||
@ -1024,10 +985,8 @@ typedef struct MTLALIGN(16)
|
||||
}
|
||||
}
|
||||
|
||||
__unsafe_unretained id<MTLTexture> textures[SLANG_NUM_BINDINGS] = {NULL};
|
||||
id<MTLSamplerState> samplers[SLANG_NUM_BINDINGS] = {NULL};
|
||||
texture_sem = _engine.pass[i].semantics.textures;
|
||||
|
||||
texture_sem_t *texture_sem = _engine.pass[i].semantics.textures;
|
||||
while (texture_sem->stage_mask)
|
||||
{
|
||||
int binding = texture_sem->binding;
|
||||
@ -1038,13 +997,9 @@ typedef struct MTLALIGN(16)
|
||||
}
|
||||
|
||||
if (backBuffer)
|
||||
{
|
||||
[rce setViewport:_engine.frame.viewport];
|
||||
}
|
||||
else
|
||||
{
|
||||
[rce setViewport:_engine.pass[i].viewport];
|
||||
}
|
||||
|
||||
[rce setFragmentTextures:textures withRange:NSMakeRange(0, SLANG_NUM_BINDINGS)];
|
||||
[rce setFragmentSamplerStates:samplers withRange:NSMakeRange(0, SLANG_NUM_BINDINGS)];
|
||||
@ -1052,9 +1007,7 @@ typedef struct MTLALIGN(16)
|
||||
[rce drawPrimitives:MTLPrimitiveTypeTriangleStrip vertexStart:0 vertexCount:4];
|
||||
|
||||
if (!backBuffer)
|
||||
{
|
||||
[rce endEncoding];
|
||||
}
|
||||
|
||||
_texture = _engine.pass[i].rt.view;
|
||||
}
|
||||
@ -1069,10 +1022,13 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
- (void)_updateRenderTargets
|
||||
{
|
||||
if (!_shader || !resize_render_targets) return;
|
||||
int i;
|
||||
NSUInteger width, height;
|
||||
if (!_shader || !resize_render_targets)
|
||||
return;
|
||||
|
||||
// release existing targets
|
||||
for (int i = 0; i < _shader->passes; i++)
|
||||
/* release existing targets */
|
||||
for (i = 0; i < _shader->passes; i++)
|
||||
{
|
||||
STRUCT_ASSIGN(_engine.pass[i].rt.view, nil);
|
||||
STRUCT_ASSIGN(_engine.pass[i].feedback.view, nil);
|
||||
@ -1080,10 +1036,12 @@ typedef struct MTLALIGN(16)
|
||||
memset(&_engine.pass[i].feedback, 0, sizeof(_engine.pass[i].feedback));
|
||||
}
|
||||
|
||||
NSUInteger width = (NSUInteger)_size.width, height = (NSUInteger)_size.height;
|
||||
width = (NSUInteger)_size.width;
|
||||
height = (NSUInteger)_size.height;
|
||||
|
||||
for (unsigned i = 0; i < _shader->passes; i++)
|
||||
for (i = 0; i < _shader->passes; i++)
|
||||
{
|
||||
MTLPixelFormat fmt;
|
||||
struct video_shader_pass *shader_pass = &_shader->pass[i];
|
||||
|
||||
if (shader_pass->fbo.valid)
|
||||
@ -1137,30 +1095,31 @@ typedef struct MTLALIGN(16)
|
||||
}
|
||||
|
||||
/* Updating framebuffer size */
|
||||
fmt = SelectOptimalPixelFormat(glslang_format_to_metal(
|
||||
_engine.pass[i].semantics.format));
|
||||
|
||||
MTLPixelFormat fmt = SelectOptimalPixelFormat(glslang_format_to_metal(_engine.pass[i].semantics.format));
|
||||
if ((i != (_shader->passes - 1)) ||
|
||||
(width != _viewport->width) || (height != _viewport->height) ||
|
||||
fmt != MTLPixelFormatBGRA8Unorm)
|
||||
{
|
||||
MTLTextureDescriptor *td;
|
||||
|
||||
_engine.pass[i].viewport.width = width;
|
||||
_engine.pass[i].viewport.height = height;
|
||||
_engine.pass[i].viewport.znear = 0.0;
|
||||
_engine.pass[i].viewport.zfar = 1.0;
|
||||
_engine.pass[i].viewport.znear = 0.0f;
|
||||
_engine.pass[i].viewport.zfar = 1.0f;
|
||||
|
||||
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:fmt
|
||||
width:width
|
||||
height:height
|
||||
td = [MTLTextureDescriptor
|
||||
texture2DDescriptorWithPixelFormat:fmt width:width height:height
|
||||
mipmapped:false];
|
||||
td.storageMode = MTLStorageModePrivate;
|
||||
td.usage = MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget;
|
||||
td.usage = MTLTextureUsageShaderRead
|
||||
| MTLTextureUsageRenderTarget;
|
||||
[self _initTexture:&_engine.pass[i].rt withDescriptor:td];
|
||||
|
||||
if (shader_pass->feedback)
|
||||
{
|
||||
[self _initTexture:&_engine.pass[i].feedback withDescriptor:td];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_engine.pass[i].rt.size_data.x = width;
|
||||
@ -1175,11 +1134,13 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
- (void)_freeVideoShader:(struct video_shader *)shader
|
||||
{
|
||||
int i;
|
||||
if (!shader)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < GFX_MAX_SHADERS; i++)
|
||||
for (i = 0; i < GFX_MAX_SHADERS; i++)
|
||||
{
|
||||
int j;
|
||||
STRUCT_ASSIGN(_engine.pass[i].rt.view, nil);
|
||||
STRUCT_ASSIGN(_engine.pass[i].feedback.view, nil);
|
||||
memset(&_engine.pass[i].rt, 0, sizeof(_engine.pass[i].rt));
|
||||
@ -1187,13 +1148,13 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
STRUCT_ASSIGN(_engine.pass[i]._state, nil);
|
||||
|
||||
for (unsigned j = 0; j < SLANG_CBUFFER_MAX; j++)
|
||||
for (j = 0; j < SLANG_CBUFFER_MAX; j++)
|
||||
{
|
||||
STRUCT_ASSIGN(_engine.pass[i].buffers[j], nil);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < GFX_MAX_TEXTURES; i++)
|
||||
for (i = 0; i < GFX_MAX_TEXTURES; i++)
|
||||
{
|
||||
STRUCT_ASSIGN(_engine.luts[i].view, nil);
|
||||
}
|
||||
@ -1213,7 +1174,7 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
@try
|
||||
{
|
||||
unsigned i;
|
||||
int i;
|
||||
texture_t *source = NULL;
|
||||
if (!video_shader_load_preset_into_shader(path.UTF8String, shader))
|
||||
return NO;
|
||||
@ -1276,6 +1237,8 @@ typedef struct MTLALIGN(16)
|
||||
@try
|
||||
{
|
||||
NSError *err;
|
||||
MTLRenderPipelineColorAttachmentDescriptor *ca;
|
||||
MTLRenderPipelineDescriptor *psd;
|
||||
MTLVertexDescriptor *vd = [MTLVertexDescriptor new];
|
||||
vd.attributes[0].offset = offsetof(VertexSlang, position);
|
||||
vd.attributes[0].format = MTLVertexFormatFloat4;
|
||||
@ -1286,16 +1249,14 @@ typedef struct MTLALIGN(16)
|
||||
vd.layouts[4].stride = sizeof(VertexSlang);
|
||||
vd.layouts[4].stepFunction = MTLVertexStepFunctionPerVertex;
|
||||
|
||||
MTLRenderPipelineDescriptor *psd = [MTLRenderPipelineDescriptor new];
|
||||
psd = [MTLRenderPipelineDescriptor new];
|
||||
psd.label = [[NSString stringWithUTF8String:shader->pass[i].source.path] stringByReplacingOccurrencesOfString:shadersPath withString:@""];
|
||||
ca = psd.colorAttachments[0];
|
||||
ca.pixelFormat = SelectOptimalPixelFormat(
|
||||
glslang_format_to_metal(_engine.pass[i].semantics.format));
|
||||
|
||||
psd.label = [[NSString stringWithUTF8String:shader->pass[i].source.path]
|
||||
stringByReplacingOccurrencesOfString:shadersPath withString:@""];
|
||||
|
||||
MTLRenderPipelineColorAttachmentDescriptor *ca = psd.colorAttachments[0];
|
||||
|
||||
ca.pixelFormat = SelectOptimalPixelFormat(glslang_format_to_metal(_engine.pass[i].semantics.format));
|
||||
|
||||
/* TODO(sgc): confirm we never need blending for render passes */
|
||||
/* TODO/FIXME (sgc): confirm we never
|
||||
* need blending for render passes */
|
||||
ca.blendingEnabled = NO;
|
||||
ca.sourceAlphaBlendFactor = MTLBlendFactorSourceAlpha;
|
||||
ca.sourceRGBBlendFactor = MTLBlendFactorSourceAlpha;
|
||||
@ -1338,6 +1299,7 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
STRUCT_ASSIGN(_engine.pass[i]._state,
|
||||
[_context.device newRenderPipelineStateWithDescriptor:psd error:&err]);
|
||||
|
||||
if (err != nil)
|
||||
{
|
||||
save_msl = true;
|
||||
@ -1395,24 +1357,21 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
for (i = 0; i < shader->luts; i++)
|
||||
{
|
||||
MTLTextureDescriptor *td;
|
||||
struct texture_image image = {0};
|
||||
image.supports_rgba = true;
|
||||
|
||||
if (!image_texture_load(&image, shader->lut[i].path))
|
||||
return NO;
|
||||
|
||||
MTLTextureDescriptor *td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm
|
||||
width:image.width
|
||||
height:image.height
|
||||
mipmapped:shader->lut[i].mipmap];
|
||||
td = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm width:image.width height:image.height mipmapped:shader->lut[i].mipmap];
|
||||
td.usage = MTLTextureUsageShaderRead;
|
||||
[self _initTexture:&_engine.luts[i] withDescriptor:td];
|
||||
|
||||
[_engine.luts[i].view replaceRegion:MTLRegionMake2D(0, 0, image.width, image.height)
|
||||
mipmapLevel:0 withBytes:image.pixels
|
||||
bytesPerRow:4 * image.width];
|
||||
|
||||
/* TODO(sgc): generate mip maps */
|
||||
/* TODO/FIXME (sgc): generate mip maps */
|
||||
image_texture_free(&image);
|
||||
}
|
||||
_shader = shader;
|
||||
@ -1421,10 +1380,8 @@ typedef struct MTLALIGN(16)
|
||||
@finally
|
||||
{
|
||||
if (shader)
|
||||
{
|
||||
[self _freeVideoShader:shader];
|
||||
}
|
||||
}
|
||||
|
||||
resize_render_targets = YES;
|
||||
init_history = YES;
|
||||
@ -1445,25 +1402,23 @@ typedef struct MTLALIGN(16)
|
||||
- (instancetype)initWithContext:(Context *)context
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (bool)loadImages:(const struct texture_image *)images count:(NSUInteger)count
|
||||
{
|
||||
NSUInteger needed, i;
|
||||
|
||||
[self _freeImages];
|
||||
|
||||
_images = [NSMutableArray arrayWithCapacity:count];
|
||||
needed = sizeof(SpriteVertex) * count * 4;
|
||||
|
||||
NSUInteger needed = sizeof(SpriteVertex) * count * 4;
|
||||
if (!_vert || _vert.length < needed)
|
||||
{
|
||||
_vert = [_context.device newBufferWithLength:needed options:PLATFORM_METAL_RESOURCE_STORAGE_MODE];
|
||||
}
|
||||
|
||||
for (NSUInteger i = 0; i < count; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
_images[i] = [_context newTexture:images[i] mipmapped:NO];
|
||||
[self updateVertexX:0 y:0 w:1 h:1 index:i];
|
||||
@ -1478,6 +1433,7 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
- (void)drawWithEncoder:(id<MTLRenderCommandEncoder>)rce
|
||||
{
|
||||
NSUInteger count, i;
|
||||
#if !defined(HAVE_COCOATOUCH)
|
||||
if (_vertDirty)
|
||||
{
|
||||
@ -1486,8 +1442,8 @@ typedef struct MTLALIGN(16)
|
||||
}
|
||||
#endif
|
||||
|
||||
NSUInteger count = _images.count;
|
||||
for (NSUInteger i = 0; i < count; ++i)
|
||||
count = _images.count;
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
NSUInteger offset = sizeof(SpriteVertex) * 4 * i;
|
||||
[rce setVertexBuffer:_vert offset:offset atIndex:BufferIndexPositions];
|
||||
@ -1605,6 +1561,8 @@ MTLPixelFormat SelectOptimalPixelFormat(MTLPixelFormat fmt)
|
||||
return MTLPixelFormatBGRA8Unorm_sRGB;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return fmt;
|
||||
}
|
||||
}
|
||||
|
@ -216,11 +216,12 @@ static void supertwoxsai_generic_xrgb8888(unsigned width, unsigned height,
|
||||
{
|
||||
supertwoxsai_declare_variables(uint32_t, in, nextline);
|
||||
|
||||
//--------------------------- B1 B2
|
||||
// 4 5 6 S2
|
||||
// 1 2 3 S1
|
||||
// A1 A2
|
||||
//--------------------------------------
|
||||
/*--------------------------- B1 B2
|
||||
* 4 5 6 S2
|
||||
* 1 2 3 S1
|
||||
* A1 A2
|
||||
*--------------------------------------
|
||||
*/
|
||||
|
||||
supertwoxsai_function(supertwoxsai_result, supertwoxsai_interpolate_xrgb8888, supertwoxsai_interpolate2_xrgb8888);
|
||||
}
|
||||
@ -246,11 +247,12 @@ static void supertwoxsai_generic_rgb565(unsigned width, unsigned height,
|
||||
{
|
||||
supertwoxsai_declare_variables(uint16_t, in, nextline);
|
||||
|
||||
//--------------------------- B1 B2
|
||||
// 4 5 6 S2
|
||||
// 1 2 3 S1
|
||||
// A1 A2
|
||||
//--------------------------------------
|
||||
/*--------------------------- B1 B2
|
||||
* 4 5 6 S2
|
||||
* 1 2 3 S1
|
||||
* A1 A2
|
||||
*--------------------------------------
|
||||
*/
|
||||
|
||||
supertwoxsai_function(supertwoxsai_result, supertwoxsai_interpolate_rgb565, supertwoxsai_interpolate2_rgb565);
|
||||
}
|
||||
@ -311,7 +313,8 @@ static void supertwoxsai_generic_packets(void *data,
|
||||
thr->width = width;
|
||||
thr->height = y_end - y_start;
|
||||
|
||||
// Workers need to know if they can access pixels outside their given buffer.
|
||||
/* Workers need to know if they can access pixels
|
||||
* outside their given buffer. */
|
||||
thr->first = y_start;
|
||||
thr->last = y_end == height;
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Needed for memfd_create
|
||||
/* Needed for memfd_create */
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#endif
|
||||
@ -85,7 +85,7 @@ static void keyboard_handle_leave(void *data,
|
||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||
wl->input.keyboard_focus = false;
|
||||
|
||||
// Release all keys
|
||||
/* Release all keys */
|
||||
memset(wl->input.key_state, 0, sizeof(wl->input.key_state));
|
||||
}
|
||||
|
||||
@ -727,7 +727,7 @@ void* wayland_data_offer_receive(struct wl_display *display, struct wl_data_offe
|
||||
{
|
||||
wl_data_offer_receive(offer, mime_type, pipefd[1]);
|
||||
|
||||
// Wait for sending client to transfer
|
||||
/* Wait for sending client to transfer */
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
close(pipefd[1]);
|
||||
@ -849,9 +849,12 @@ static void data_device_handle_drop(void *data,
|
||||
line[strcspn(line, "\r\n")] = 0;
|
||||
RARCH_LOG("[Wayland]: > \"%s\"\n", line);
|
||||
|
||||
// TODO: Convert from file:// URI, Implement file loading
|
||||
//if (wayland_load_content_from_drop(g_filename_from_uri(line, NULL, NULL)))
|
||||
// RARCH_WARN("----- wayland_load_content_from_drop success\n");
|
||||
/* TODO/FIXME: Convert from file:// URI, Implement file loading
|
||||
* Drag and Drop */
|
||||
#if 0
|
||||
if (wayland_load_content_from_drop(g_filename_from_uri(line, NULL, NULL)))
|
||||
RARCH_WARN("----- wayland_load_content_from_drop success\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
@ -867,7 +870,7 @@ static void data_offer_handle_offer(void *data, struct wl_data_offer *offer,
|
||||
{
|
||||
data_offer_ctx *offer_data = data;
|
||||
|
||||
// TODO: Keep list of mime types for offer if beneficial
|
||||
/* TODO: Keep list of mime types for offer if beneficial */
|
||||
if (string_is_equal(mime_type, FILE_MIME))
|
||||
offer_data->is_file_mime_type = true;
|
||||
}
|
||||
@ -875,7 +878,7 @@ static void data_offer_handle_offer(void *data, struct wl_data_offer *offer,
|
||||
static void data_offer_handle_source_actions(void *data,
|
||||
struct wl_data_offer *offer, enum wl_data_device_manager_dnd_action actions)
|
||||
{
|
||||
// Report of actions for this offer supported by compositor
|
||||
/* Report of actions for this offer supported by compositor */
|
||||
data_offer_ctx *offer_data = data;
|
||||
offer_data->supported_actions = actions;
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ float cocoa_screen_get_backing_scale_factor(void);
|
||||
|
||||
static bool apple_key_state[MAX_KEYS];
|
||||
|
||||
// Send keyboard inputs directly using RETROK_* codes
|
||||
// Used by the iOS custom keyboard implementation
|
||||
/* Send keyboard inputs directly using RETROK_* codes
|
||||
* Used by the iOS custom keyboard implementation */
|
||||
void apple_direct_input_keyboard_event(bool down,
|
||||
unsigned code, uint32_t character, uint32_t mod, unsigned device)
|
||||
{
|
||||
|
@ -358,12 +358,12 @@ static inline void initAttributeGem(gemAttribute * attribute,
|
||||
|
||||
int initGemVideoConvert(ps3_input_t *ps3)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ps3->gem_video_convert.version = 2;
|
||||
ps3->gem_video_convert.format = 2; //GEM_RGBA_640x480;
|
||||
ps3->gem_video_convert.conversion= GEM_AUTO_WHITE_BALANCE | GEM_COMBINE_PREVIOUS_INPUT_FRAME |
|
||||
GEM_FILTER_OUTLIER_PIXELS | GEM_GAMMA_BOOST;
|
||||
ps3->gem_video_convert.format = 2; /* GEM_RGBA_640x480; */
|
||||
ps3->gem_video_convert.conversion = GEM_AUTO_WHITE_BALANCE
|
||||
| GEM_COMBINE_PREVIOUS_INPUT_FRAME
|
||||
| GEM_FILTER_OUTLIER_PIXELS
|
||||
| GEM_GAMMA_BOOST;
|
||||
ps3->gem_video_convert.gain = 1.0f;
|
||||
ps3->gem_video_convert.red_gain = 1.0f;
|
||||
ps3->gem_video_convert.green_gain = 1.0f;
|
||||
@ -373,45 +373,39 @@ int initGemVideoConvert(ps3_input_t *ps3)
|
||||
ps3->gem_video_convert.buffer_memory = ps3->buffer_mem;
|
||||
ps3->gem_video_convert.video_data_out = ps3->video_out;
|
||||
ps3->gem_video_convert.alpha = 255;
|
||||
ret = gemPrepareVideoConvert(&ps3->gem_video_convert);
|
||||
return ret;
|
||||
|
||||
return gemPrepareVideoConvert(&ps3->gem_video_convert);
|
||||
}
|
||||
|
||||
int initGem(ps3_input_t *ps3)
|
||||
{
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ret = initSpurs(ps3);
|
||||
if (ret)
|
||||
{
|
||||
gemAttribute gem_attr;
|
||||
u8 gem_spu_priorities[8] = { 1, 1, 1, 1, 1, 0, 0, 0 }; /* execute */
|
||||
/* libgem jobs */
|
||||
/* on 5 SPUs */
|
||||
if (initSpurs(ps3))
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = gemGetMemorySize(1);
|
||||
ps3->gem_memory = (void *)malloc(ret);
|
||||
ps3->gem_memory = (void *)malloc(gemGetMemorySize(1));
|
||||
if (!ps3->gem_memory)
|
||||
return -1;
|
||||
|
||||
u8 gem_spu_priorities[8] = { 1, 1, 1, 1, 1, 0, 0, 0 }; // execute
|
||||
// libgem jobs
|
||||
// on 5 spu
|
||||
gemAttribute gem_attr;
|
||||
initAttributeGem(&gem_attr, 1, ps3->gem_memory,
|
||||
ps3->spurs, gem_spu_priorities);
|
||||
|
||||
initAttributeGem(&gem_attr, 1, ps3->gem_memory, ps3->spurs, gem_spu_priorities);
|
||||
gemInit (&gem_attr);
|
||||
initGemVideoConvert(ps3);
|
||||
gemPrepareCamera (128, 0.5);
|
||||
gemReset(0);
|
||||
|
||||
ret = gemInit (&gem_attr);
|
||||
ret= initGemVideoConvert(ps3);
|
||||
ret = gemPrepareCamera (128, 0.5);
|
||||
ret = gemReset(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void readGemPad(ps3_input_t *ps3, int num_gem)
|
||||
{
|
||||
int ret;
|
||||
unsigned int hues[] = { 4 << 24, 4 << 24, 4 << 24, 4 << 24 };
|
||||
ret = gemGetState (0, 0, -22000, &ps3->gem_state);
|
||||
int ret = gemGetState(0, 0, -22000, &ps3->gem_state);
|
||||
|
||||
ps3->newGemPad = ps3->gem_state.paddata.buttons & (~ps3->oldGemPad);
|
||||
ps3->newGemAnalogT = ps3->gem_state.paddata.ANA_T;
|
||||
@ -441,10 +435,8 @@ void readGemAccPosition(int num_gem)
|
||||
|
||||
void readGemInertial(ps3_input_t *ps3, int num_gem)
|
||||
{
|
||||
int ret;
|
||||
VmathVector4 v;
|
||||
|
||||
ret = gemGetInertialState(num_gem, 0, -22000, &ps3->gem_inertial_state);
|
||||
int ret = gemGetInertialState(num_gem, 0, -22000, &ps3->gem_inertial_state);
|
||||
v.vec128 = ps3->gem_inertial_state.accelerometer;
|
||||
v.vec128 = ps3->gem_inertial_state.accelerometer_bias;
|
||||
v.vec128 = ps3->gem_inertial_state.gyro;
|
||||
@ -453,14 +445,16 @@ void readGemInertial(ps3_input_t *ps3, int num_gem)
|
||||
|
||||
void readGem(ps3_input_t *ps3)
|
||||
{
|
||||
VmathVector4 v;
|
||||
|
||||
proccessGem(ps3, 0);
|
||||
proccessGem(ps3, 1);
|
||||
proccessGem(ps3, 2);
|
||||
proccessGem(ps3, 3);
|
||||
readGemPad(ps3, 0); // This will read buttons from Move
|
||||
VmathVector4 v;
|
||||
readGemPad(ps3, 0); /* This will read buttons from Move */
|
||||
v.vec128 = ps3->gem_state.pos;
|
||||
switch (ps3->newGemPad) {
|
||||
switch (ps3->newGemPad)
|
||||
{
|
||||
case 1:
|
||||
ps3->select_pressed++;
|
||||
break;
|
||||
@ -484,17 +478,21 @@ void readGem(ps3_input_t *ps3)
|
||||
break;
|
||||
case 64:
|
||||
ps3->cross_pressed++;
|
||||
//readGemAccPosition(0);
|
||||
#if 0
|
||||
readGemAccPosition(0);
|
||||
#endif
|
||||
break;
|
||||
case 128:
|
||||
ps3->square_pressed++;
|
||||
//readGemInertial(ps3, 0);
|
||||
#if 0
|
||||
readGemInertial(ps3, 0);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // HAVE_LIGHTGUN
|
||||
#endif /* HAVE_LIGHTGUN */
|
||||
|
||||
static void ps3_input_poll(void *data)
|
||||
{
|
||||
@ -665,11 +663,14 @@ static int16_t ps3_mouse_device_state(ps3_input_t *ps3,
|
||||
static int16_t ps3_lightgun_device_state(ps3_input_t *ps3,
|
||||
unsigned user, unsigned id)
|
||||
{
|
||||
if (!ps3->gem_connected || !ps3->gem_init)
|
||||
return 0;
|
||||
|
||||
readCamera(ps3);
|
||||
readGem(ps3);
|
||||
float center_x;
|
||||
float center_y;
|
||||
float pointer_x;
|
||||
float pointer_y;
|
||||
videoState state;
|
||||
videoConfiguration vconfig;
|
||||
videoResolution res;
|
||||
VmathVector4 ray_start, ray_dir;
|
||||
struct video_viewport vp;
|
||||
const int edge_detect = 32700;
|
||||
bool inside = false;
|
||||
@ -677,27 +678,25 @@ static int16_t ps3_lightgun_device_state(ps3_input_t *ps3,
|
||||
int16_t res_y = 0;
|
||||
int16_t res_screen_x = 0;
|
||||
int16_t res_screen_y = 0;
|
||||
float center_x;
|
||||
float center_y;
|
||||
float pointer_x;
|
||||
float pointer_y;
|
||||
float sensitivity = 1.0f;
|
||||
if (!ps3->gem_connected || !ps3->gem_init)
|
||||
return 0;
|
||||
|
||||
readCamera(ps3);
|
||||
readGem(ps3);
|
||||
|
||||
videoState state;
|
||||
videoConfiguration vconfig;
|
||||
videoResolution res;
|
||||
videoGetState(0, 0, &state);
|
||||
videoGetResolution(state.displayMode.resolution, &res);
|
||||
|
||||
if (res.height == 720)
|
||||
{
|
||||
// 720p offset adjustments
|
||||
/* 720p offset adjustments */
|
||||
center_x = 645.0f;
|
||||
center_y = 375.0f;
|
||||
}
|
||||
else if (res.height == 1080)
|
||||
{
|
||||
// 1080p offset adjustments
|
||||
/* 1080p offset adjustments */
|
||||
center_x = 960.0f;
|
||||
center_y = 565.0f;
|
||||
}
|
||||
@ -709,21 +708,19 @@ static int16_t ps3_lightgun_device_state(ps3_input_t *ps3,
|
||||
vp.full_width = 0;
|
||||
vp.full_height = 0;
|
||||
|
||||
#if 1
|
||||
// tracking mode 1: laser pointer mode (this is closest to actual lightgun behavior)
|
||||
VmathVector4 ray_start;
|
||||
/* tracking mode 1: laser pointer mode (this is closest
|
||||
to actual lightgun behavior) */
|
||||
ray_start.vec128 = ps3->gem_state.pos;
|
||||
VmathVector4 ray_tmp = {.vec128 = {0.0f,0.0f,-1.0f,0.0f}};
|
||||
const VmathQuat *quat = &ps3->gem_state.quat;
|
||||
VmathVector4 ray_dir;
|
||||
vmathQRotate(&ray_dir, quat, &ray_tmp);
|
||||
float t = -ray_start.vec128[2] / ray_dir.vec128[2];
|
||||
pointer_x = ray_start.vec128[0] + ray_dir.vec128[0]*t;
|
||||
pointer_y = ray_start.vec128[1] + ray_dir.vec128[1]*t;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// tracking mode 2: 3D coordinate system (move pointer position by moving the whole controller)
|
||||
/* tracking mode 2: 3D coordinate system (move pointer position by moving the
|
||||
* whole controller) */
|
||||
VmathVector4 v;
|
||||
v.vec128 = ps3->gem_state.pos;
|
||||
pointer_x = v.vec128[0];
|
||||
@ -782,15 +779,11 @@ static int16_t ps3_lightgun_device_state(ps3_input_t *ps3,
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X:
|
||||
if (inside)
|
||||
{
|
||||
return (res_x);
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y:
|
||||
if (inside)
|
||||
{
|
||||
return (~res_y);
|
||||
}
|
||||
break;
|
||||
case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN:
|
||||
return !inside;
|
||||
@ -825,7 +818,7 @@ static int16_t ps3_input_state(
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (id == RETRO_DEVICE_ID_JOYPAD_MASK)
|
||||
{
|
||||
unsigned i;
|
||||
int i;
|
||||
int16_t ret = 0;
|
||||
|
||||
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||
@ -880,7 +873,10 @@ static void ps3_input_free_input(void *data)
|
||||
|
||||
static void* ps3_input_init(const char *joypad_driver)
|
||||
{
|
||||
unsigned i;
|
||||
int i;
|
||||
#ifdef HAVE_LIGHTGUN
|
||||
gemInfo gem_info;
|
||||
#endif
|
||||
ps3_input_t *ps3 = (ps3_input_t*)calloc(1, sizeof(*ps3));
|
||||
if (!ps3)
|
||||
return NULL;
|
||||
@ -903,7 +899,6 @@ static void* ps3_input_init(const char *joypad_driver)
|
||||
#endif
|
||||
#ifdef HAVE_LIGHTGUN
|
||||
ps3->gem_init = 0;
|
||||
gemInfo gem_info;
|
||||
gemGetInfo(&gem_info);
|
||||
ps3->gem_connected = gem_info.connected;
|
||||
if (ps3->gem_connected)
|
||||
@ -918,14 +913,12 @@ static void* ps3_input_init(const char *joypad_driver)
|
||||
if (!setupCamera(ps3));
|
||||
{
|
||||
if (!initGem(ps3))
|
||||
{
|
||||
ps3->gem_init = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ps3;
|
||||
}
|
||||
|
@ -372,28 +372,21 @@ static void qnx_process_keyboard_event(
|
||||
qnx_input_t *qnx,
|
||||
screen_event_t event, int type)
|
||||
{
|
||||
// Get key properties from screen event
|
||||
int flags = 0;
|
||||
/* Get key properties from screen event */
|
||||
int flags = 0, cap = 0, mod = 0;
|
||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags);
|
||||
|
||||
int cap = 0;
|
||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap);
|
||||
|
||||
int mod = 0;
|
||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &mod);
|
||||
|
||||
// Calculate state
|
||||
/* Calculate state */
|
||||
unsigned keycode = input_keymaps_translate_keysym_to_rk(cap);
|
||||
bool keydown = flags & KEY_DOWN;
|
||||
bool keyrepeat = flags & KEY_REPEAT;
|
||||
|
||||
// Fire keyboard event
|
||||
/* Fire keyboard event */
|
||||
if (!keyrepeat)
|
||||
{
|
||||
input_keyboard_event(keydown, keycode, 0, mod, RETRO_DEVICE_KEYBOARD);
|
||||
}
|
||||
|
||||
// Apply keyboard state
|
||||
/* Apply keyboard state */
|
||||
if (keydown && !keyrepeat)
|
||||
{
|
||||
BIT_SET(qnx->keyboard_state, cap);
|
||||
|
@ -279,16 +279,16 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr;
|
||||
|
||||
/* RFCOMM EVENTS */
|
||||
|
||||
// data: event(8), len(8), status (8), address (48), handle (16), server channel(8), rfcomm_cid(16), max frame size(16)
|
||||
/* data: event(8), len(8), status (8), address (48), handle (16), server channel(8), rfcomm_cid(16), max frame size(16) */
|
||||
#define RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE 0x80
|
||||
|
||||
// data: event(8), len(8), rfcomm_cid(16)
|
||||
/* data: event(8), len(8), rfcomm_cid(16) */
|
||||
#define RFCOMM_EVENT_CHANNEL_CLOSED 0x81
|
||||
|
||||
// data: event (8), len(8), address(48), channel (8), rfcomm_cid (16)
|
||||
/* data: event (8), len(8), address(48), channel (8), rfcomm_cid (16) */
|
||||
#define RFCOMM_EVENT_INCOMING_CONNECTION 0x82
|
||||
|
||||
// data: event (8), len(8), rfcommid (16), ...
|
||||
/* data: event (8), len(8), rfcommid (16), ... */
|
||||
#define RFCOMM_EVENT_REMOTE_LINE_STATUS 0x83
|
||||
|
||||
/* data: event(8), len(8), rfcomm_cid(16), credits(8) */
|
||||
|
@ -60,7 +60,7 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
||||
return;
|
||||
|
||||
slot = (uint32_t)controller.playerIndex;
|
||||
// if we have not assigned a slot to this controller yet, ignore it.
|
||||
/* If we have not assigned a slot to this controller yet, ignore it. */
|
||||
if (slot >= MAX_USERS)
|
||||
return;
|
||||
buttons = &mfi_buttons[slot];
|
||||
@ -68,13 +68,14 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
||||
/* retain the values from the paused controller handler and pass them through */
|
||||
if (@available(iOS 13, *))
|
||||
{
|
||||
// The menu button can be pressed/unpressed like any other button in iOS 13
|
||||
// so no need to passthrough anything
|
||||
/* The menu button can be pressed/unpressed
|
||||
* like any other button in iOS 13,
|
||||
* so no need to passthrough anything */
|
||||
*buttons = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the paused controller handler for iOS versions below 13
|
||||
/* Use the paused controller handler for iOS versions below 13 */
|
||||
pause = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_START);
|
||||
select = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_SELECT);
|
||||
l3 = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_L3);
|
||||
@ -110,14 +111,15 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 || __TV_OS_VERSION_MAX_ALLOWED >= 130000
|
||||
if (@available(iOS 13, *))
|
||||
{
|
||||
// Support "Options" button present in PS4 / XBox One controllers
|
||||
/* Support "Options" button present in PS4 / XBox One controllers */
|
||||
*buttons |= gp.buttonOptions.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
|
||||
|
||||
// Support buttons that aren't supported by older mFi controller via "hotkey" combinations:
|
||||
//
|
||||
// LS + Menu => Select
|
||||
// LT + Menu => L3
|
||||
// RT + Menu => R3
|
||||
/* Support buttons that aren't supported by older mFi controller via "hotkey" combinations:
|
||||
*
|
||||
* LS + Menu => Select
|
||||
* LT + Menu => L3
|
||||
* RT + Menu => R3
|
||||
*/
|
||||
if (gp.buttonMenu.pressed )
|
||||
{
|
||||
if (gp.leftShoulder.pressed)
|
||||
@ -138,7 +140,8 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
||||
mfi_axes[slot][3] = gp.rightThumbstick.yAxis.value * 32767.0f;
|
||||
|
||||
}
|
||||
// GCGamepad is deprecated
|
||||
|
||||
/* GCGamepad is deprecated */
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||
else if (controller.gamepad)
|
||||
@ -168,15 +171,17 @@ static void apple_gamecontroller_joypad_poll(void)
|
||||
apple_gamecontroller_joypad_poll_internal(controller);
|
||||
}
|
||||
|
||||
// GCGamepad is deprecated
|
||||
/* GCGamepad is deprecated */
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||
static void apple_gamecontroller_joypad_register(GCGamepad *gamepad)
|
||||
{
|
||||
#ifdef __IPHONE_14_0
|
||||
// dont let tvOS or iOS do anything with **our** buttons!!
|
||||
// iOS will start a screen recording if you hold or dbl click the OPTIONS button, we dont want that.
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
/* Don't let tvOS or iOS do anything with **our** buttons!!
|
||||
* iOS will start a screen recording if you hold or doubleclick
|
||||
* the OPTIONS button, we don't want that. */
|
||||
if (@available(iOS 14.0, tvOS 14.0, *))
|
||||
{
|
||||
GCExtendedGamepad *gp = (GCExtendedGamepad *)gamepad.controller.extendedGamepad;
|
||||
gp.buttonOptions.preferredSystemGestureState = GCSystemGestureStateDisabled;
|
||||
gp.buttonMenu.preferredSystemGestureState = GCSystemGestureStateDisabled;
|
||||
@ -189,13 +194,12 @@ static void apple_gamecontroller_joypad_register(GCGamepad *gamepad)
|
||||
apple_gamecontroller_joypad_poll_internal(updateGamepad.controller);
|
||||
};
|
||||
|
||||
/* controllerPausedHandler is deprecated in favor
|
||||
* of being able to deal with the menu
|
||||
* button as any other button */
|
||||
if (@available(iOS 13, *))
|
||||
{
|
||||
// controllerPausedHandler is deprecated in favor of being able to deal with the menu
|
||||
// button as any other button
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
gamepad.controller.controllerPausedHandler = ^(GCController *controller)
|
||||
|
||||
@ -294,11 +298,11 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
|
||||
}
|
||||
}
|
||||
|
||||
// GCGamepad is deprecated
|
||||
/* GCGamepad is deprecated */
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||
[mfiControllers addObject:controller];
|
||||
// move any non-game controllers (like the siri remote) to the end
|
||||
/* Move any non-game controllers (like the siri remote) to the end */
|
||||
if (mfiControllers.count > 1)
|
||||
{
|
||||
int newPlayerIndex = 0;
|
||||
|
@ -16,8 +16,9 @@
|
||||
#ifndef _KEYBOARD_EVENT_ANDROID_H
|
||||
#define _KEYBOARD_EVENT_ANDROID_H
|
||||
|
||||
// The list of defined Android keycodes is incomplete in SDK version 12 and lower.
|
||||
// If using an SDK lower than 13 then add missing keycodes here
|
||||
/* The list of defined Android keycodes is incomplete in SDK version 12
|
||||
* and lower.
|
||||
* If using an SDK lower than 13, add missing keycodes here */
|
||||
#if __ANDROID_API__ < 13
|
||||
|
||||
/*
|
||||
|
@ -1459,7 +1459,7 @@ const struct rarch_key_map rarch_key_map_qnx[] = {
|
||||
{ KEYCODE_RIGHT_CTRL, RETROK_RCTRL },
|
||||
{ KEYCODE_LEFT_ALT, RETROK_LALT },
|
||||
{ KEYCODE_RIGHT_ALT, RETROK_RALT },
|
||||
// TODO/FIXME: Code for 'sym' key on BB keyboards. Figure out which sys/keycodes.h define this maps to.
|
||||
/* TODO/FIXME: Code for 'sym' key on BB keyboards. Figure out which sys/keycodes.h define this maps to. */
|
||||
{ 61651, RETROK_RSUPER },
|
||||
{ KEYCODE_DOLLAR, RETROK_DOLLAR },
|
||||
{ KEYCODE_MENU, RETROK_MENU },
|
||||
|
@ -337,7 +337,7 @@ static ui_application_t ui_application_cocoa = {
|
||||
void *data;
|
||||
enum event_command cmd;
|
||||
}
|
||||
@end // @interface CommandPerformer
|
||||
@end /* @interface CommandPerformer */
|
||||
|
||||
@implementation CommandPerformer
|
||||
|
||||
@ -358,7 +358,7 @@ static ui_application_t ui_application_cocoa = {
|
||||
command_event(self->cmd, self->data);
|
||||
}
|
||||
|
||||
@end // @implementation CommandPerformer
|
||||
@end /* @implementation CommandPerformer */
|
||||
|
||||
#if defined(HAVE_COCOA_METAL)
|
||||
@interface RAWindow : NSWindow
|
||||
|
@ -471,8 +471,8 @@ enum
|
||||
NSString *filename = (NSString*)url.path.lastPathComponent;
|
||||
NSError *error = nil;
|
||||
NSString *destination = [self.documentsDirectory stringByAppendingPathComponent:filename];
|
||||
|
||||
// copy file to documents directory if its not already inside of documents directory
|
||||
/* Copy file to documents directory if it's not already
|
||||
* inside Documents directory */
|
||||
if ([url startAccessingSecurityScopedResource]) {
|
||||
if (![[url path] containsString: self.documentsDirectory])
|
||||
if (![manager fileExistsAtPath:destination])
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define IDI_ICON 1
|
||||
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K
|
||||
#define _WIN32_WINNT 0x0500 /* _WIN32_WINNT_WIN2K */
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32_IE
|
||||
|
Loading…
x
Reference in New Issue
Block a user