Merge branch 'master' into master

This commit is contained in:
Diogo Barros 2018-02-11 12:59:44 +00:00 committed by GitHub
commit 8c95a5731a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
285 changed files with 17373 additions and 8151 deletions

View File

@ -15,28 +15,40 @@
- D3D9: Add menu support for MaterialUI/XMB.
- D3D10: Initial video driver implementation.
- D3D11: Initial video driver implementation.
- D3D11: SPIRV-Cross/slang shader support for D3D11.
- D3D12: Initial video driver implementation.
- DINPUT: don't reinitialize input driver on network events / media insertion / network drive connection
- INPUT: show friendly names when available under input binds and system information
- INPUT: show the config name when available under system information
- GUI: Allow changing menu font color.
- GUI: Menu visibility options for RGUI and MaterialUI.
- GUI/MaterialUI: Works now with D3D8, D3D9 Cg, D3D11 and D3D12 drivers.
- GUI/XMB: Add Monochrome Inverted icon theme.
- GUI/XMB: Allow changing menu scale to 200%.
- GUI/XMB: Works now with D3D8, D3D9 Cg, D3D11 and D3D12 drivers. Menu shader effects currently don't work on D3D8/D3D9 Cg.
- HAIKU: Restored port.
- KEYMAPPER: prevent a condition that caused input_menu_toggle to stop working when a RETRO_DEVICE_KEYBOARD type device is enabled
- GL: ignore hard gpu sync when fast-forwarding
- IOS10/11: Handle hardware keyboards and iCade controllers
- LOCALIZATION: Update Italian translation.
- LOCALIZATION: Update Japanese translation.
- LOCALIZATION: Update Portuguese-Brazilian translation.
- LOCALIZATION: Update Spanish translation.
- OSX: Modify HID buttons detection algorithm.
- NETPLAY: Add menu option to select different MITM (relay) server locations.
- OSX: Modify HID buttons detection algorithm.
- QB: Added --datarootdir.
- QB: Added --bindir and --mandir and deprecated --with-bin_dir and --with-man_dir.
- QB: Added --docdir.
- SHADERS: Allow saving of shader presets based on the parent directory (Saving one for */foo/bar/mario.sfc* would result in *shaders/presets/corename/bar.ext*). We decided it's safer to still isolate the presets to a single core because different cores may treat video output differently.
- SHADERS: Don't save the path to the current preset to the main config. This was causing weird behavior, instead it will try to load *currentconfig.ext* and it will save a preset with that name when select *apply shader preset*. The resulting shader will restore properly after restarting and even after core/parent/game specific presets are loaded
- SOLARIS: Initial port.
- SWITCH: Initial Nintendo Switch port, based on libtransistor SDK.
- PS3: Enable Cheevos.
- PSP: Enable threading support through pthreads.
- SHADERS: SPIRV-Cross/slang shader support for D3D11.
- SHIELD ATV: Allow the remote / gamepad takeover hack to work with the 2017 gamepad
- VULKAN: Fix swapchain recreation bug on Nvidia GPUs with Windows 10 through workaround (will be properly resolved in a future driver version).
- SUBSYSTEM: Subsystem saves now respect the save directory
- VULKAN: Fix swapchain recreation bug on Nvidia GPUs with Windows 10 (resolved in Windows Nvidia driver version 390.77).
- WINDOWS: Improved Unicode support (for cores/directory creation and 7zip archives).
- WINDOWS: Show progress meter on taskbar for downloads (Windows 7 and up).
- WINDOWS: WS_EX_LAYERED drastically decreases performance, so only set it when needed (transparency in windowed mode).
@ -45,6 +57,7 @@
- WIIU: Increased stability during core switching.
- WIIU: Shader support.
- WIIU: Menu shader effects added (shaders).
- WIIU: Add missing time/clock support. (also fixes RTC [Real Time Clock] in Gambatte)
- XBOX OG: Restored port.
# 1.7.0

View File

@ -201,29 +201,33 @@ install: $(TARGET)
rm -f $(OBJDIR)/git_version.o
mkdir -p $(DESTDIR)$(BIN_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(GLOBAL_CONFIG_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(PREFIX)/share/applications 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DATA_DIR)/applications 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DOC_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(MAN_DIR)/man6 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(PREFIX)/share/pixmaps 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DATA_DIR)/pixmaps 2>/dev/null || /bin/true
cp $(TARGET) $(DESTDIR)$(BIN_DIR)
cp tools/cg2glsl.py $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
cp retroarch.cfg $(DESTDIR)$(GLOBAL_CONFIG_DIR)
cp retroarch.desktop $(DESTDIR)$(PREFIX)/share/applications
cp retroarch.desktop $(DESTDIR)$(DATA_DIR)/applications
cp docs/retroarch.6 $(DESTDIR)$(MAN_DIR)/man6
cp docs/retroarch-cg2glsl.6 $(DESTDIR)$(MAN_DIR)/man6
cp media/retroarch.svg $(DESTDIR)$(PREFIX)/share/pixmaps
cp media/retroarch.svg $(DESTDIR)$(DATA_DIR)/pixmaps
cp COPYING $(DESTDIR)$(DOC_DIR)
cp README.md $(DESTDIR)$(DOC_DIR)
chmod 755 $(DESTDIR)$(BIN_DIR)/$(TARGET)
chmod 755 $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
chmod 644 $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
chmod 644 $(DESTDIR)$(PREFIX)/share/applications/retroarch.desktop
chmod 644 $(DESTDIR)$(DATA_DIR)/applications/retroarch.desktop
chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch.6
chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6
chmod 644 $(DESTDIR)$(PREFIX)/share/pixmaps/retroarch.svg
chmod 644 $(DESTDIR)$(DATA_DIR)/pixmaps/retroarch.svg
@if test -d media/assets; then \
echo "Installing media assets..."; \
mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb; \
mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/glui; \
cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \
cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \
mkdir -p $(DESTDIR)$(ASSETS_DIR)/assets/xmb; \
mkdir -p $(DESTDIR)$(ASSETS_DIR)/assets/glui; \
cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/assets; \
cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/assets; \
cp media/assets/COPYING $(DESTDIR)$(DOC_DIR)/COPYING.assets; \
echo "Asset copying done."; \
fi
@ -231,11 +235,14 @@ uninstall:
rm -f $(DESTDIR)$(BIN_DIR)/retroarch
rm -f $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
rm -f $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
rm -f $(DESTDIR)$(PREFIX)/share/applications/retroarch.desktop
rm -f $(DESTDIR)$(DATA_DIR)/applications/retroarch.desktop
rm -f $(DESTDIR)$(DATA_DIR)/pixmaps/retroarch.svg
rm -f $(DESTDIR)$(DOC_DIR)/COPYING
rm -f $(DESTDIR)$(DOC_DIR)/COPYING.assets
rm -f $(DESTDIR)$(DOC_DIR)/README.md
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch.6
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6
rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/retroarch.svg
rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch
rm -rf $(DESTDIR)$(ASSETS_DIR)
clean:
rm -rf $(OBJDIR_BASE)

View File

@ -284,7 +284,8 @@ OBJ += intl/msg_hash_de.o \
intl/msg_hash_ru.o \
intl/msg_hash_vn.o \
intl/msg_hash_chs.o \
intl/msg_hash_cht.o
intl/msg_hash_cht.o \
intl/msg_hash_ar.o
endif
@ -1267,8 +1268,12 @@ ifeq ($(HAVE_D3D11), 1)
endif
ifeq ($(HAVE_D3D12), 1)
OBJ += gfx/drivers/d3d12.o gfx/common/d3d12_common.o
OBJ += gfx/drivers/d3d12.o gfx/common/d3d12_common.o \
gfx/drivers_font/d3d12_font.o menu/drivers_display/menu_display_d3d12.o
DEFINES += -DHAVE_D3D12
HAVE_SLANG = 1
HAVE_GLSLANG = 1
HAVE_SPIRV_CROSS = 1
endif
ifneq ($(findstring 1, $(HAVE_D3D10) $(HAVE_D3D11) $(HAVE_D3D12)),)
@ -1355,11 +1360,13 @@ ifeq ($(HAVE_GLSLANG), 1)
endif
ifeq ($(HAVE_SPIRV_CROSS), 1)
DEFINES += -DHAVE_SPIRV_CROSS
INCLUDE_DIRS += -I$(DEPS_DIR)/SPIRV-Cross
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cross.o
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_cfg.o
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_glsl.o
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_hlsl.o
OBJ += $(DEPS_DIR)/SPIRV-Cross/spirv_msl.o
endif
ifeq ($(WANT_WGL), 1)

View File

@ -671,6 +671,10 @@ ifeq ($(HAVE_GRIFFIN_CPP), 1)
OBJ += griffin/griffin_cpp.o
endif
ifeq ($(WANT_GLSLANG), 1)
OBJ += griffin/griffin_glslang.o
endif
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)

View File

@ -5,6 +5,7 @@ OS = Win32
ARCH = amd64
#TARGET_ARCH = x86
BUILD_DIR = objs/msvc
CXX_BUILD = 0
WindowsSdkDir = C:\Program Files (x86)\Windows Kits\10\$(NOTHING)
@ -54,12 +55,12 @@ HAVE_LANGEXTRA := 1
HAVE_CHEEVOS := 1
HAVE_KEYMAPPER := 1
HAVE_SHADERPIPELINE := 1
HAVE_IMAGEVIEWER := 1
include Makefile.common
INCLUDE_DIRS := $(patsubst -isystem%,-I%,$(INCLUDE_DIRS))
CFLAGS := $(filter-out -Wno-unknown-pragmas,$(CFLAGS))
CXXFLAGS := $(filter-out -fpermissive -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -Wno-parentheses,$(CXXFLAGS))
CXXFLAGS += $(CFLAGS)
LIBS := $(filter-out -lstdc++,$(LIBS))
ifeq ($(ARCH),x64)
@ -124,11 +125,16 @@ FLAGS += -Gm- -Zc:inline -fp:precise -Zc:forScope -GR- -Gd -Oi -volatile:iso
#FLAGS += -utf-8
#FLAGS += -source-charset:utf-8
CXXFLAGS += $(CFLAGS) -TP -EHsc
ifeq ($(CXX_BUILD),1)
CFLAGS := $(CXXFLAGS)
DEFINES += -DCXX_BUILD
else
CFLAGS += -TC
endif
CFLAGS += -TC
CXXFLAGS += -TP -EHsc
WARNINGS += -WX -W3
WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 -wd4800
WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 -wd4800 -wd4838
CC = cl.exe
CXX = cl.exe

View File

@ -146,8 +146,10 @@ static size_t audio_driver_rewind_size = 0;
static int16_t *audio_driver_rewind_buf = NULL;
static int16_t *audio_driver_output_samples_conv_buf = NULL;
#ifdef DEBUG
static unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT];
static uint64_t audio_driver_free_samples_count = 0;
#endif
static size_t audio_driver_buffer_size = 0;
static size_t audio_driver_data_ptr = 0;
@ -191,6 +193,7 @@ enum resampler_quality audio_driver_get_resampler_quality(void)
return (enum resampler_quality)settings->uints.audio_resampler_quality;
}
#ifdef DEBUG
/**
* compute_audio_buffer_statistics:
*
@ -255,6 +258,7 @@ static void compute_audio_buffer_statistics(void)
(100.0 * low_water_count) / (samples - 1),
(100.0 * high_water_count) / (samples - 1));
}
#endif
/**
* audio_driver_find_handle:
@ -339,7 +343,9 @@ static bool audio_driver_deinit_internal(void)
command_event(CMD_EVENT_DSP_FILTER_DEINIT, NULL);
#ifdef DEBUG
compute_audio_buffer_statistics();
#endif
return true;
}
@ -508,7 +514,9 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
command_event(CMD_EVENT_DSP_FILTER_INIT, NULL);
#ifdef DEBUG
audio_driver_free_samples_count = 0;
#endif
audio_mixer_init(settings->uints.audio_out_rate);
@ -612,17 +620,19 @@ static void audio_driver_flush(const int16_t *data, size_t samples)
if (audio_driver_control)
{
/* Readjust the audio input rate. */
unsigned write_idx = audio_driver_free_samples_count++ &
(AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1);
int half_size = (int)(audio_driver_buffer_size / 2);
int avail =
(int)current_audio->write_avail(audio_driver_context_audio_data);
int delta_mid = avail - half_size;
double direction = (double)delta_mid / half_size;
double adjust = 1.0 + audio_driver_rate_control_delta * direction;
#ifdef DEBUG
unsigned write_idx = audio_driver_free_samples_count++ &
(AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1);
audio_driver_free_samples_buf
[write_idx] = avail;
#endif
audio_source_ratio_current =
audio_source_ratio_original * adjust;

View File

@ -59,13 +59,13 @@ typedef struct
size_t bufsize;
} xa_t;
#ifdef __cplusplus
#if defined(__cplusplus) && !defined(CINTERFACE)
struct xaudio2 : public IXAudio2VoiceCallback
#else
struct xaudio2
#endif
{
#ifdef __cplusplus
#if defined(__cplusplus) && !defined(CINTERFACE)
xaudio2() :
buf(0), pXAudio2(0), pMasterVoice(0),
pSourceVoice(0), hEvent(0), buffers(0), bufsize(0),
@ -101,8 +101,8 @@ struct xaudio2
unsigned write_buffer;
};
#ifndef __cplusplus
static void WINAPI voice_on_buffer_end(void *handle_, void *data)
#if !defined(__cplusplus) || defined(CINTERFACE)
static void WINAPI voice_on_buffer_end(IXAudio2VoiceCallback *handle_, void *data)
{
xaudio2_t *handle = (xaudio2_t*)handle_;
(void)data;
@ -110,10 +110,10 @@ static void WINAPI voice_on_buffer_end(void *handle_, void *data)
SetEvent(handle->hEvent);
}
static void WINAPI dummy_voidp(void *handle, void *data) { (void)handle; (void)data; }
static void WINAPI dummy_nil(void *handle) { (void)handle; }
static void WINAPI dummy_uint32(void *handle, UINT32 dummy) { (void)handle; (void)dummy; }
static void WINAPI dummy_voidp_hresult(void *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; }
static void WINAPI dummy_voidp(IXAudio2VoiceCallback *handle, void *data) { (void)handle; (void)data; }
static void WINAPI dummy_nil(IXAudio2VoiceCallback *handle) { (void)handle; }
static void WINAPI dummy_uint32(IXAudio2VoiceCallback *handle, UINT32 dummy) { (void)handle; (void)dummy; }
static void WINAPI dummy_voidp_hresult(IXAudio2VoiceCallback *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; }
const struct IXAudio2VoiceCallbackVtbl voice_vtable = {
dummy_uint32,
@ -189,7 +189,7 @@ static void xaudio2_free(xaudio2_t *handle)
free(handle->buf);
#ifdef __cplusplus
#if defined(__cplusplus) && !defined(CINTERFACE)
delete handle;
#else
free(handle);
@ -206,7 +206,7 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels,
CoInitializeEx(0, COINIT_MULTITHREADED);
#endif
#ifdef __cplusplus
#if defined(__cplusplus) && !defined(CINTERFACE)
handle = new xaudio2;
#else
handle = (xaudio2_t*)calloc(1, sizeof(*handle));
@ -215,7 +215,7 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels,
if (!handle)
goto error;
#ifndef __cplusplus
#if !defined(__cplusplus) || defined(CINTERFACE)
handle->lpVtbl = &voice_vtable;
#endif

View File

@ -26,7 +26,7 @@
/* All structures defined in this file use tight field packing */
#pragma pack(push, 1)
#ifdef __cplusplus
#if defined(__cplusplus) && !defined(CINTERFACE)
#define X2DEFAULT(x) = (x)
#else
#define X2DEFAULT(x)
@ -183,6 +183,9 @@ typedef struct XAUDIO2_BUFFER
void *pContext;
} XAUDIO2_BUFFER;
#undef INTERFACE
#define INTERFACE IXAudio2VoiceCallback
DECLARE_INTERFACE(IXAudio2VoiceCallback)
{
STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) PURE;
@ -194,6 +197,9 @@ DECLARE_INTERFACE(IXAudio2VoiceCallback)
STDMETHOD_(void, OnVoiceError) (THIS_ void *pBufferContext, HRESULT Error) PURE;
};
#undef INTERFACE
#define INTERFACE IXAudio2Voice
DECLARE_INTERFACE(IXAudio2Voice)
{
#define Declare_IXAudio2Voice_Methods() \
@ -235,11 +241,17 @@ DECLARE_INTERFACE(IXAudio2Voice)
Declare_IXAudio2Voice_Methods();
};
#undef INTERFACE
#define INTERFACE IXAudio2MasteringVoice
DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice)
{
Declare_IXAudio2Voice_Methods();
};
#undef INTERFACE
#define INTERFACE IXAudio2SourceVoice
DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice)
{
Declare_IXAudio2Voice_Methods();
@ -255,6 +267,8 @@ DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice)
STDMETHOD_(void, GetFrequencyRatio) (THIS_ float* pRatio) PURE;
};
#undef INTERFACE
#define INTERFACE IXAudio2
DECLARE_INTERFACE_(IXAudio2, IUnknown)
{
@ -292,7 +306,7 @@ DECLARE_INTERFACE_(IXAudio2, IUnknown)
void *pReserved X2DEFAULT(NULL)) PURE;
};
#ifdef __cplusplus
#if defined(__cplusplus) && !defined(CINTERFACE)
/* C++ hooks */
#define IXAudio2_Initialize(handle,a,b) handle->Initialize(a, b)
#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, a, b) handle->SubmitSourceBuffer(a, b)
@ -305,17 +319,17 @@ DECLARE_INTERFACE_(IXAudio2, IUnknown)
#define IXAudio2SourceVoice_Start(handle, a, b) handle->Start(a, b)
#else
/* C hooks */
#define IXAudio2_Initialize(THIS,a,b) (THIS)->lpVtbl->Initialize(THIS, a, b)
#define IXAudio2_Release(THIS) (THIS)->lpVtbl->Release(THIS)
#define IXAudio2_CreateSourceVoice(THIS,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (THIS)->lpVtbl->CreateSourceVoice(THIS, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain)
#define IXAudio2_CreateMasteringVoice(THIS,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (THIS)->lpVtbl->CreateMasteringVoice(THIS, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain)
#define IXAudio2_GetDeviceCount(THIS, puCount) (THIS)->lpVtbl->GetDeviceCount(THIS, puCount)
#define IXAudio2_GetDeviceDetails(THIS, Index,pDeviceDetails) (THIS)->lpVtbl->GetDeviceDetails(THIS, Index, pDeviceDetails)
#define IXAudio2SourceVoice_Start(THIS, Flags, OperationSet) (THIS)->lpVtbl->Start(THIS, Flags, OperationSet)
#define IXAudio2SourceVoice_Stop(THIS, Flags, OperationSet) (THIS)->lpVtbl->Stop(THIS, Flags, OperationSet)
#define IXAudio2SourceVoice_SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) (THIS)->lpVtbl->SubmitSourceBuffer(THIS, pBuffer, pBufferWMA)
#define IXAudio2SourceVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS)
#define IXAudio2MasteringVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS)
#define IXAudio2_Initialize(handle,a,b) (handle)->lpVtbl->Initialize(handle, a, b)
#define IXAudio2_Release(handle) (handle)->lpVtbl->Release(handle)
#define IXAudio2_CreateSourceVoice(handle,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (handle)->lpVtbl->CreateSourceVoice(handle, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain)
#define IXAudio2_CreateMasteringVoice(handle,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (handle)->lpVtbl->CreateMasteringVoice(handle, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain)
#define IXAudio2_GetDeviceCount(handle, puCount) (handle)->lpVtbl->GetDeviceCount(handle, puCount)
#define IXAudio2_GetDeviceDetails(handle, Index,pDeviceDetails) (handle)->lpVtbl->GetDeviceDetails(handle, Index, pDeviceDetails)
#define IXAudio2SourceVoice_Start(handle, Flags, OperationSet) (handle)->lpVtbl->Start(handle, Flags, OperationSet)
#define IXAudio2SourceVoice_Stop(handle, Flags, OperationSet) (handle)->lpVtbl->Stop(handle, Flags, OperationSet)
#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, pBuffer, pBufferWMA) (handle)->lpVtbl->SubmitSourceBuffer(handle, pBuffer, pBufferWMA)
#define IXAudio2SourceVoice_DestroyVoice(handle) (handle)->lpVtbl->DestroyVoice(handle)
#define IXAudio2MasteringVoice_DestroyVoice(handle) (handle)->lpVtbl->DestroyVoice(handle)
#endif
#ifdef _XBOX

View File

@ -611,19 +611,19 @@ static void cheevos_build_memaddr(const cheevos_condition_t* condition,
case CHEEVOS_COND_OP_EQUALS:
cheevos_add_char(&aux, &left, '=');
break;
case CHEEVOS_COND_OP_GREATER_THAN:
case CHEEVOS_COND_OP_GREATER_THAN:
cheevos_add_char(&aux, &left, '>');
break;
case CHEEVOS_COND_OP_GREATER_THAN_OR_EQUAL:
case CHEEVOS_COND_OP_GREATER_THAN_OR_EQUAL:
cheevos_add_string(&aux, &left, ">=");
break;
case CHEEVOS_COND_OP_LESS_THAN:
case CHEEVOS_COND_OP_LESS_THAN:
cheevos_add_char(&aux, &left, '<');
break;
case CHEEVOS_COND_OP_LESS_THAN_OR_EQUAL:
case CHEEVOS_COND_OP_LESS_THAN_OR_EQUAL:
cheevos_add_string(&aux, &left, "<=");
break;
case CHEEVOS_COND_OP_NOT_EQUAL_TO:
case CHEEVOS_COND_OP_NOT_EQUAL_TO:
cheevos_add_string(&aux, &left, "!=");
break;
}
@ -1028,11 +1028,11 @@ static int cheevos_parse_expression(cheevos_expr_t *expr, const char* mem)
cheevos_term_t *terms = NULL;
char *end = NULL;
if (expr)
{
expr->count = 1;
expr->compare_count = 1;
}
if (!expr)
return -1;
expr->count = 1;
expr->compare_count = 1;
for (aux = mem;; aux++)
{
@ -2359,49 +2359,49 @@ void cheevos_populate_menu(void *data)
menu_displaylist_info_t *info = (menu_displaylist_info_t*)data;
cheevo_t *end = NULL;
cheevo_t *cheevo = cheevos_locals.core.cheevos;
if (!cheevo)
return;
end = cheevo + cheevos_locals.core.count;
for (i = 0; cheevo < end; i++, cheevo++)
if (cheevo)
{
if (!(cheevo->active & CHEEVOS_ACTIVE_HARDCORE))
for (i = 0; cheevo < end; i++, cheevo++)
{
if (!(cheevo->active & CHEEVOS_ACTIVE_HARDCORE))
{
menu_entries_append_enum(info->list, cheevo->title,
cheevo->description,
MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY_HARDCORE,
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
cheevo->description,
MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY_HARDCORE,
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
items_found++;
set_badge_info(&badges_ctx, i, cheevo->badge,
(cheevo->active & CHEEVOS_ACTIVE_HARDCORE));
}
else if (!(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE))
{
}
else if (!(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE))
{
menu_entries_append_enum(info->list, cheevo->title,
cheevo->description,
MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY,
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
cheevo->description,
MENU_ENUM_LABEL_CHEEVOS_UNLOCKED_ENTRY,
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
items_found++;
set_badge_info(&badges_ctx, i, cheevo->badge,
(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE));
}
else
{
}
else
{
menu_entries_append_enum(info->list, cheevo->title,
cheevo->description,
MENU_ENUM_LABEL_CHEEVOS_LOCKED_ENTRY,
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
cheevo->description,
MENU_ENUM_LABEL_CHEEVOS_LOCKED_ENTRY,
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
items_found++;
set_badge_info(&badges_ctx, i, cheevo->badge,
(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE));
}
}
}
if (settings->bools.cheevos_test_unofficial)
cheevo = cheevos_locals.unofficial.cheevos;
if (cheevo && settings->bools.cheevos_test_unofficial)
{
cheevo = cheevos_locals.unofficial.cheevos;
end = cheevo + cheevos_locals.unofficial.count;
for (i = cheevos_locals.core.count; cheevo < end; i++, cheevo++)
@ -2487,8 +2487,9 @@ bool cheevos_apply_cheats(bool *data_bool)
bool cheevos_unload(void)
{
bool running;
CHEEVOS_LOCK(cheevos_locals.task_lock);
bool running = cheevos_locals.task != NULL;
running = cheevos_locals.task != NULL;
CHEEVOS_UNLOCK(cheevos_locals.task_lock);
if (running)
@ -3095,6 +3096,26 @@ found:
if ((void*)coro->json)
free((void*)coro->json);
if ( cheevos_locals.core.count == 0
&& cheevos_locals.unofficial.count == 0
&& cheevos_locals.lboard_count == 0)
{
runloop_msg_queue_push(
"This game has no achievements.",
0, 5 * 60, false);
cheevos_free_cheevo_set(&cheevos_locals.core);
cheevos_free_cheevo_set(&cheevos_locals.unofficial);
cheevos_locals.core.cheevos = NULL;
cheevos_locals.unofficial.cheevos = NULL;
cheevos_locals.core.count = 0;
cheevos_locals.unofficial.count = 0;
cheevos_loaded = false;
CORO_STOP();
}
cheevos_loaded = true;
/*
@ -3109,40 +3130,28 @@ found:
*/
CORO_GOSUB(PLAYING);
if (coro->settings->bools.cheevos_verbose_enable)
if (coro->settings->bools.cheevos_verbose_enable && cheevos_locals.core.count > 0)
{
if(cheevos_locals.core.count > 0)
{
char msg[256];
int mode = CHEEVOS_ACTIVE_SOFTCORE;
const cheevo_t* cheevo = cheevos_locals.core.cheevos;
const cheevo_t* end = cheevo + cheevos_locals.core.count;
int number_of_unlocked = cheevos_locals.core.count;
char msg[256];
int mode = CHEEVOS_ACTIVE_SOFTCORE;
const cheevo_t* cheevo = cheevos_locals.core.cheevos;
const cheevo_t* end = cheevo + cheevos_locals.core.count;
int number_of_unlocked = cheevos_locals.core.count;
if (coro->settings->bools.cheevos_hardcore_mode_enable)
mode = CHEEVOS_ACTIVE_HARDCORE;
if (coro->settings->bools.cheevos_hardcore_mode_enable)
mode = CHEEVOS_ACTIVE_HARDCORE;
for (; cheevo < end; cheevo++)
if(cheevo->active & mode)
number_of_unlocked--;
for (; cheevo < end; cheevo++)
if(cheevo->active & mode)
number_of_unlocked--;
snprintf(msg, sizeof(msg),
"You have %d of %d achievements unlocked.",
number_of_unlocked, cheevos_locals.core.count);
msg[sizeof(msg) - 1] = 0;
runloop_msg_queue_push(msg, 0, 6 * 60, false);
}
else
runloop_msg_queue_push(
"This game has no achievements.",
0, 5 * 60, false);
snprintf(msg, sizeof(msg),
"You have %d of %d achievements unlocked.",
number_of_unlocked, cheevos_locals.core.count);
msg[sizeof(msg) - 1] = 0;
runloop_msg_queue_push(msg, 0, 6 * 60, false);
}
if ( cheevos_locals.core.count == 0
&& cheevos_locals.unofficial.count == 0
&& cheevos_locals.lboard_count == 0)
cheevos_unload();
CORO_GOSUB(GET_BADGES);
CORO_STOP();

View File

@ -220,6 +220,7 @@ bool command_set_shader(const char *arg)
{
char msg[256];
enum rarch_shader_type type = RARCH_SHADER_NONE;
struct video_shader *shader = menu_shader_get();
switch (msg_hash_to_file_type(msg_hash_calculate(path_get_extension(arg))))
{
@ -245,7 +246,8 @@ bool command_set_shader(const char *arg)
msg_hash_to_str(MSG_APPLYING_SHADER),
arg);
return video_driver_set_shader(type, arg);
retroarch_set_shader_preset(arg);
return menu_shader_manager_set_preset(shader, type, arg);
}
#if defined(HAVE_COMMAND) && defined(HAVE_CHEEVOS)
@ -1295,31 +1297,13 @@ static void command_event_disable_overrides(void)
return;
/* reload the original config */
config_unload_override();
rarch_ctl(RARCH_CTL_UNSET_OVERRIDES_ACTIVE, NULL);
}
static void command_event_restore_default_shader_preset(void)
{
if (!path_is_empty(RARCH_PATH_DEFAULT_SHADER_PRESET))
{
/* auto shader preset: reload the original shader */
settings_t *settings = config_get_ptr();
const char *shader_preset = path_get(RARCH_PATH_DEFAULT_SHADER_PRESET);
if (!string_is_empty(shader_preset))
{
RARCH_LOG("%s %s\n",
msg_hash_to_str(MSG_RESTORING_DEFAULT_SHADER_PRESET_TO),
shader_preset);
strlcpy(settings->paths.path_shader,
shader_preset,
sizeof(settings->paths.path_shader));
}
}
path_clear(RARCH_PATH_DEFAULT_SHADER_PRESET);
retroarch_unset_shader_preset();
}
static void command_event_restore_remaps(void)
@ -1418,29 +1402,37 @@ static bool command_event_save_core_config(void)
bool found_path = false;
bool overrides_active = false;
const char *core_path = NULL;
char *config_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *config_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *config_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *config_name = NULL;
char *config_path = NULL;
char *config_dir = NULL;
size_t config_size = PATH_MAX_LENGTH * sizeof(char);
settings_t *settings = config_get_ptr();
config_dir[0] = config_name[0] =
config_path[0] = msg[0] = '\0';
msg[0] = '\0';
if (!string_is_empty(settings->paths.directory_menu_config))
strlcpy(config_dir, settings->paths.directory_menu_config,
config_size);
if (settings && !string_is_empty(settings->paths.directory_menu_config))
config_dir = strdup(settings->paths.directory_menu_config);
else if (!path_is_empty(RARCH_PATH_CONFIG)) /* Fallback */
{
config_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
config_dir[0] = '\0';
fill_pathname_basedir(config_dir, path_get(RARCH_PATH_CONFIG),
config_size);
else
}
if (string_is_empty(config_dir))
{
runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true);
RARCH_ERR("[Config]: %s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET));
goto error;
free (config_dir);
return false;
}
core_path = path_get(RARCH_PATH_CORE);
core_path = path_get(RARCH_PATH_CORE);
config_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
config_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
config_name[0] = '\0';
config_path[0] = '\0';
/* Infer file name based on libretro core. */
if (!string_is_empty(core_path) && filestream_exists(core_path))
@ -1514,12 +1506,6 @@ static bool command_event_save_core_config(void)
free(config_name);
free(config_path);
return ret;
error:
free(config_dir);
free(config_name);
free(config_path);
return false;
}
/**

View File

@ -125,6 +125,9 @@ static const unsigned fullscreen_y = 0;
*/
static const unsigned window_opacity = 100;
/* Whether to show the usual window decorations like border, titlebar etc. */
static const bool window_decorations = true;
#if defined(RARCH_CONSOLE) || defined(__APPLE__)
static const bool load_dummy_on_core_shutdown = false;
#else
@ -551,6 +554,8 @@ static const int netplay_check_frames = 600;
static const bool netplay_use_mitm_server = false;
static const char *netplay_mitm_server = "nyc";
#ifdef HAVE_NETWORKING
static const unsigned netplay_share_digital = RARCH_NETPLAY_SHARE_DIGITAL_NO_PREFERENCE;

View File

@ -1036,6 +1036,7 @@ static struct config_array_setting *populate_settings_array(settings_t *settings
SETTING_ARRAY("bundle_assets_dst_path", settings->arrays.bundle_assets_dst, false, NULL, true);
SETTING_ARRAY("bundle_assets_dst_path_subdir", settings->arrays.bundle_assets_dst_subdir, false, NULL, true);
SETTING_ARRAY("led_driver", settings->arrays.led_driver, false, NULL, true);
SETTING_ARRAY("netplay_mitm_server", settings->arrays.netplay_mitm_server, false, NULL, true);
*size = count;
return tmp;
@ -1378,6 +1379,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("screenshots_in_content_dir", &settings->bools.screenshots_in_content_dir, true, default_screenshots_in_content_dir, false);
SETTING_BOOL("video_msg_bgcolor_enable", &settings->bools.video_msg_bgcolor_enable, true, message_bgcolor_enable, false);
SETTING_BOOL("video_window_show_decorations", &settings->bools.video_window_show_decorations, true, window_decorations, false);
*size = count;
@ -1551,6 +1553,7 @@ static void config_set_defaults(void)
const char *def_led = config_get_default_led();
const char *def_location = config_get_default_location();
const char *def_record = config_get_default_record();
const char *def_mitm = netplay_mitm_server;
struct config_float_setting *float_settings = populate_settings_float (settings, &float_settings_size);
struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size);
struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size);
@ -1630,6 +1633,9 @@ static void config_set_defaults(void)
if (def_record)
strlcpy(settings->arrays.record_driver,
def_record, sizeof(settings->arrays.record_driver));
if (def_mitm)
strlcpy(settings->arrays.netplay_mitm_server,
def_mitm, sizeof(settings->arrays.netplay_mitm_server));
#ifdef HAVE_MENU
if (def_menu)
strlcpy(settings->arrays.menu_driver,
@ -2267,6 +2273,7 @@ static bool check_shader_compatibility(enum file_path_enum enum_idx)
if (string_is_equal(settings->arrays.video_driver, "vulkan") ||
string_is_equal(settings->arrays.video_driver, "d3d11") ||
string_is_equal(settings->arrays.video_driver, "d3d12") ||
string_is_equal(settings->arrays.video_driver, "gx2"))
{
if (enum_idx != FILE_PATH_SLANGP_EXTENSION)
@ -2363,6 +2370,7 @@ static bool config_load_file(const char *path, bool set_defaults,
#endif
const char *path_core = NULL;
const char *path_config = NULL;
const char *shader_ext = NULL;
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
@ -2870,29 +2878,28 @@ static bool config_load_file(const char *path, bool set_defaults,
config_read_keybinds_conf(conf);
shader_ext = path_get_extension(settings->paths.path_shader);
if (!string_is_empty(shader_ext))
{
for(i = FILE_PATH_CGP_EXTENSION; i <= FILE_PATH_SLANGP_EXTENSION; i++)
{
enum file_path_enum ext = (enum file_path_enum)(i);
if(!strstr(file_path_str(ext), shader_ext))
continue;
if (check_shader_compatibility(ext))
continue;
RARCH_LOG("Incompatible shader for backend %s, clearing...\n",
settings->arrays.video_driver);
settings->paths.path_shader[0] = '\0';
break;
}
}
ret = true;
{
const char *shader_ext = path_get_extension(settings->paths.path_shader);
if (!string_is_empty(shader_ext))
{
for(i = FILE_PATH_CGP_EXTENSION; i <= FILE_PATH_SLANGP_EXTENSION; i++)
{
enum file_path_enum ext = (enum file_path_enum)(i);
if(!strstr(file_path_str(ext), shader_ext))
continue;
if (check_shader_compatibility(ext))
continue;
RARCH_LOG("Incompatible shader for backend %s, clearing...\n",
settings->arrays.video_driver);
settings->paths.path_shader[0] = '\0';
break;
}
}
}
end:
if (conf)
@ -2935,24 +2942,23 @@ end:
bool config_load_override(void)
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *buf = NULL;
char *core_path = NULL;
char *game_path = NULL;
char *config_directory = NULL;
config_file_t *new_conf = NULL;
const char *core_name = NULL;
const char *game_name = NULL;
bool should_append = false;
rarch_system_info_t *system = runloop_get_system_info();
if (system)
core_name = system->info.library_name;
game_name = path_basename(path_get(RARCH_PATH_BASENAME));
const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
if (string_is_empty(core_name) || string_is_empty(game_name))
goto error;
return false;
game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
config_directory[0] = core_path[0] = game_path[0] = '\0';
fill_pathname_application_special(config_directory, path_size,
@ -3105,28 +3111,29 @@ bool config_unload_override(void)
bool config_load_remap(void)
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *remap_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* path to the directory containing retroarch.cfg (prefix) */
char *core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* final path for core-specific configuration (prefix+suffix) */
char *game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* final path for game-specific configuration (prefix+suffix) */
char *remap_directory = NULL;
char *core_path = NULL;
char *game_path = NULL;
config_file_t *new_conf = NULL;
const char *core_name = NULL;
const char *game_name = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = runloop_get_system_info();
if (system)
core_name = system->info.library_name;
game_name = path_basename(path_get(RARCH_PATH_BASENAME));
const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
if (string_is_empty(core_name) || string_is_empty(game_name))
goto error;
return false;
/* Remap directory: remap_directory.
* Try remap directory setting, no fallbacks defined */
if (string_is_empty(settings->paths.directory_input_remapping))
goto error;
return false;
/* path to the directory containing retroarch.cfg (prefix) */
remap_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
/* final path for core-specific configuration (prefix+suffix) */
core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
/* final path for game-specific configuration (prefix+suffix) */
game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
remap_directory[0] = core_path[0] = game_path[0] = '\0';
strlcpy(remap_directory,
@ -3189,7 +3196,6 @@ bool config_load_remap(void)
new_conf = NULL;
error:
free(remap_directory);
free(core_path);
free(game_path);
@ -3218,28 +3224,37 @@ success:
bool config_load_shader_preset(void)
{
unsigned idx;
config_file_t *new_conf = NULL;
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *shader_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* path to the directory containing retroarch.cfg (prefix) */
char *core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* final path for core-specific configuration (prefix+suffix) */
char *game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); /* final path for game-specific configuration (prefix+suffix) */
const char *core_name = NULL;
const char *game_name = NULL;
config_file_t *new_conf = NULL;
char *shader_directory = NULL;
char *core_path = NULL;
char *game_path = NULL;
char *parent_path = NULL;
settings_t *settings = config_get_ptr();
rarch_system_info_t *system = runloop_get_system_info();
const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
char parent_name[PATH_MAX_LENGTH];
if (system)
core_name = system->info.library_name;
game_name = path_basename(path_get(RARCH_PATH_BASENAME));
if (!string_is_empty(path_get(RARCH_PATH_BASENAME)))
fill_pathname_parent_dir_name(parent_name, path_get(RARCH_PATH_BASENAME), sizeof(parent_name));
if (string_is_empty(core_name) || string_is_empty(game_name))
goto error;
return false;
/* Shader directory: shader_directory.
* Try shader directory setting, no fallbacks defined */
if (string_is_empty(settings->paths.directory_video_shader))
goto error;
return false;
/* path to the directory containing retroarch.cfg (prefix) */
shader_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
/* final path for core-specific configuration (prefix+suffix) */
core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
/* final path for game-specific configuration (prefix+suffix) */
game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
/* final path for parent-dir-specific configuration (prefix+suffix) */
parent_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
shader_directory[0] = core_path[0] = game_path[0] = '\0';
@ -3277,9 +3292,33 @@ bool config_load_shader_preset(void)
/* Game shader preset exists, load it. */
RARCH_LOG("Shaders: game-specific shader preset found at %s.\n", game_path);
retroarch_set_shader_preset(game_path);
goto success;
}
path_set(RARCH_PATH_DEFAULT_SHADER_PRESET, settings->paths.path_shader);
strlcpy(settings->paths.path_shader, game_path, sizeof(settings->paths.path_shader));
for(idx = FILE_PATH_CGP_EXTENSION; idx <= FILE_PATH_SLANGP_EXTENSION; idx++)
{
if (!check_shader_compatibility((enum file_path_enum)(idx)))
continue;
/* Concatenate strings into full paths for core_path, parent path */
fill_pathname_join_special_ext(parent_path,
shader_directory, core_name,
parent_name,
file_path_str((enum file_path_enum)(idx)),
path_size);
/* Create a new config file from parent path */
new_conf = config_file_new(parent_path);
if (!new_conf)
{
RARCH_LOG("Shaders: no parent-dir-specific preset found at %s.\n", parent_path);
continue;
}
/* Parent-dir shader preset exists, load it. */
RARCH_LOG("Shaders: parent-dir-specific shader preset found at %s.\n", parent_path);
retroarch_set_shader_preset(parent_path);
goto success;
}
@ -3305,12 +3344,10 @@ bool config_load_shader_preset(void)
/* Core shader preset exists, load it. */
RARCH_LOG("Shaders: core-specific shader preset found at %s.\n", core_path);
path_set(RARCH_PATH_DEFAULT_SHADER_PRESET, settings->paths.path_shader);
strlcpy(settings->paths.path_shader, core_path, sizeof(settings->paths.path_shader));
retroarch_set_shader_preset(core_path);
goto success;
}
error:
free(shader_directory);
free(core_path);
free(game_path);
@ -3320,6 +3357,7 @@ success:
free(shader_directory);
free(core_path);
free(game_path);
free(parent_path);
config_file_free(new_conf);
return true;
}
@ -3591,24 +3629,25 @@ static bool config_save_keybinds_file(const char *path)
bool config_save_autoconf_profile(const char *path, unsigned user)
{
unsigned i;
char *buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *autoconf_file = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *buf = NULL;
char *autoconf_file = NULL;
char *path_new = NULL;
config_file_t *conf = NULL;
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
int32_t pid_user = 0;
int32_t vid_user = 0;
bool ret = false;
config_file_t *conf = NULL;
settings_t *settings = config_get_ptr();
const char *autoconf_dir = settings->paths.directory_autoconfig;
const char *joypad_ident = settings->arrays.input_joypad_driver;
buf[0] = autoconf_file[0] = '\0';
if (string_is_empty(path))
goto error;
return false;
path_new = strdup(path);
buf = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
autoconf_file = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
buf[0] = autoconf_file[0] = '\0';
path_new = strdup(path);
for (i = 0; invalid_filename_chars[i]; i++)
{
@ -3915,15 +3954,9 @@ bool config_save_file(const char *path)
bool config_save_overrides(int override_type)
{
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *override_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
char *game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
int tmp_i = 0;
unsigned i = 0;
bool ret = false;
const char *core_name = NULL;
const char *game_name = NULL;
config_file_t *conf = NULL;
settings_t *settings = NULL;
struct config_bool_setting *bool_settings = NULL;
@ -3938,6 +3971,10 @@ bool config_save_overrides(int override_type)
struct config_array_setting *array_overrides= NULL;
struct config_path_setting *path_settings = NULL;
struct config_path_setting *path_overrides = NULL;
char *config_directory = NULL;
char *override_directory = NULL;
char *core_path = NULL;
char *game_path = NULL;
settings_t *overrides = config_get_ptr();
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
@ -3946,16 +3983,17 @@ bool config_save_overrides(int override_type)
int array_settings_size = sizeof(settings->arrays) / sizeof(settings->arrays.placeholder);
int path_settings_size = sizeof(settings->paths) / sizeof(settings->paths.placeholder);
rarch_system_info_t *system = runloop_get_system_info();
if (system)
core_name = system->info.library_name;
game_name = path_basename(path_get(RARCH_PATH_BASENAME));
const char *core_name = system ? system->info.library_name : NULL;
const char *game_name = path_basename(path_get(RARCH_PATH_BASENAME));
if (string_is_empty(core_name) || string_is_empty(game_name))
goto error;
return false;
settings = (settings_t*)calloc(1, sizeof(settings_t));
settings = (settings_t*)calloc(1, sizeof(settings_t));
config_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
override_directory = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
core_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
game_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
config_directory[0] = override_directory[0] = core_path[0] = game_path[0] = '\0';
@ -4170,14 +4208,6 @@ bool config_save_overrides(int override_type)
free(game_path);
return ret;
error:
free(config_directory);
free(override_directory);
free(core_path);
free(game_path);
return false;
}
/* Replaces currently loaded configuration file with

View File

@ -254,6 +254,7 @@ typedef struct settings
bool bluetooth_enable;
bool automatically_add_content_to_playlist;
bool video_window_show_decorations;
} bools;
struct
@ -408,6 +409,8 @@ typedef struct settings
char bundle_assets_src[PATH_MAX_LENGTH];
char bundle_assets_dst[PATH_MAX_LENGTH];
char bundle_assets_dst_subdir[PATH_MAX_LENGTH];
char netplay_mitm_server[255];
} arrays;
struct

View File

@ -189,14 +189,16 @@ static bool core_info_list_iterate(
struct string_list *contents, size_t i)
{
size_t info_path_base_size = PATH_MAX_LENGTH * sizeof(char);
char *info_path_base = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP) && !defined(_3DS) && !defined(VITA))
char *info_path_base = NULL;
char *substr = NULL;
#endif
const char *current_path = contents->elems[i].data;
const char *current_path = contents ? contents->elems[i].data : NULL;
if (!contents || !current_path)
goto error;
(void)substr;
if (!current_path)
return false;
info_path_base = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
info_path_base[0] = '\0';
@ -220,10 +222,6 @@ static bool core_info_list_iterate(
free(info_path_base);
return true;
error:
free(info_path_base);
return false;
}
static core_info_list_t *core_info_list_new(const char *path)
@ -524,19 +522,21 @@ static bool core_info_list_update_missing_firmware_internal(
{
size_t i;
core_info_t *info = NULL;
char *path = NULL;
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
char *path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
if (!core_info_list || !core)
goto error;
return false;
path[0] = '\0';
info = core_info_find_internal(core_info_list, core);
info = core_info_find_internal(core_info_list, core);
if (!info)
goto error;
return false;
path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
path[0] = '\0';
rarch_ctl(RARCH_CTL_UNSET_MISSING_BIOS, NULL);
for (i = 0; i < info->firmware_count; i++)
{
if (string_is_empty(info->firmware[i].path))
@ -554,10 +554,6 @@ static bool core_info_list_update_missing_firmware_internal(
free(path);
return true;
error:
free(path);
return false;
}
#if 0

0
deps/SPIRV-Cross/checkout_glslang_spirv_tools.sh vendored Normal file → Executable file
View File

View File

@ -0,0 +1,43 @@
struct Foo
{
float a;
float b;
};
static const float _16[4] = { 1.0f, 4.0f, 3.0f, 2.0f };
static const Foo _24 = { 10.0f, 20.0f };
static const Foo _27 = { 30.0f, 40.0f };
static const Foo _28[2] = { { 10.0f, 20.0f }, { 30.0f, 40.0f } };
static float4 FragColor;
static int _line;
struct SPIRV_Cross_Input
{
nointerpolation int _line : TEXCOORD0;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
static float lut[4];
static Foo foos[2];
void frag_main()
{
lut = _16;
foos = _28;
FragColor = lut[_line].xxxx;
FragColor += (foos[_line].a * (foos[1 - _line].a)).xxxx;
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
_line = stage_input._line;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -0,0 +1,30 @@
Texture2D<float4> uTex : register(t0);
SamplerState uSampler : register(s1);
static int2 FooOut;
struct SPIRV_Cross_Output
{
int2 FooOut : SV_Target0;
};
uint2 SPIRV_Cross_textureSize(Texture2D<float4> Tex, uint Level, out uint Param)
{
uint2 ret;
Tex.GetDimensions(Level, ret.x, ret.y, Param);
return ret;
}
void frag_main()
{
uint _23_dummy_parameter;
FooOut = int2(SPIRV_Cross_textureSize(uTex, uint(0), _23_dummy_parameter));
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FooOut = FooOut;
return stage_output;
}

View File

@ -14,7 +14,7 @@ struct _6
float _m0[1];
};
kernel void main0(uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]])
kernel void main0(device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]])
{
_8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x];
}

View File

@ -101,7 +101,7 @@ struct main0_out
float4 _entryPointOutput [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]], constant CB0& _19 [[buffer(0)]], texture3d<float> LightMapTexture [[texture(0)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], texture2d<float> ShadowMapTexture [[texture(1)]], texturecube<float> EnvironmentMapTexture [[texture(2)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], texture2d<float> DiffuseMapTexture [[texture(3)]], sampler NormalMapSampler [[sampler(4)]], texture2d<float> NormalMapTexture [[texture(4)]], texture2d<float> NormalDetailMapTexture [[texture(5)]], sampler NormalDetailMapSampler [[sampler(5)]], texture2d<float> StudsMapTexture [[texture(6)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], texture2d<float> SpecularMapTexture [[texture(7)]])
fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)]], texture3d<float> LightMapTexture [[texture(0)]], texture2d<float> ShadowMapTexture [[texture(1)]], texturecube<float> EnvironmentMapTexture [[texture(2)]], texture2d<float> DiffuseMapTexture [[texture(3)]], texture2d<float> NormalMapTexture [[texture(4)]], texture2d<float> NormalDetailMapTexture [[texture(5)]], texture2d<float> StudsMapTexture [[texture(6)]], texture2d<float> SpecularMapTexture [[texture(7)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], sampler NormalMapSampler [[sampler(4)]], sampler NormalDetailMapSampler [[sampler(5)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
VertexOutput _128 = _121;

View File

@ -95,7 +95,7 @@ struct main0_out
float4 m_5 [[color(0)]];
};
fragment main0_out main0(float4 gl_FragCoord [[position]], constant _6& _7 [[buffer(0)]], texture2d<float> _8 [[texture(0)]], sampler _9 [[sampler(0)]], constant _10& _11 [[buffer(1)]], texture2d<float> _12 [[texture(1)]], sampler _13 [[sampler(1)]], texture2d<float> _14 [[texture(2)]], sampler _15 [[sampler(2)]], constant _18& _19 [[buffer(2)]])
fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d<float> _8 [[texture(0)]], texture2d<float> _12 [[texture(1)]], texture2d<float> _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
_28 _77 = _74;

View File

@ -21,7 +21,7 @@ struct SSBO3
uint counter;
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float4 _29 = _23.in_data[gl_GlobalInvocationID.x];
if (dot(_29, float4(1.0, 5.0, 6.0, 2.0)) > 8.19999980926513671875)

View File

@ -23,7 +23,7 @@ struct SSBO3
uint count;
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]])
kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float _28 = _22.in_data[gl_GlobalInvocationID.x];
if (_28 > 12.0)

View File

@ -14,7 +14,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]])
kernel void main0(device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
int i = 0;
float4 _56;

View File

@ -3,7 +3,7 @@
using namespace metal;
kernel void main0(texture2d<float> uImageIn [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], texture2d<float, access::write> uImageOut [[texture(1)]])
kernel void main0(texture2d<float> uImageIn [[texture(0)]], texture2d<float, access::write> uImageOut [[texture(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uImageOut.write(uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height())))), uint2(int2(gl_GlobalInvocationID.xy)));
}

View File

@ -14,7 +14,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]])
kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 idat = _24.in_data[ident];

View File

@ -8,7 +8,7 @@ struct SSBO2
float3x3 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _22 [[buffer(0)]])
kernel void main0(device SSBO2& _22 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_22.out_data[gl_GlobalInvocationID.x] = float3x3(float3(10.0), float3(20.0), float3(40.0));
}

View File

@ -22,7 +22,7 @@ Tx mod(Tx x, Ty y)
return x - y * floor(x / y);
}
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_33.out_data[gl_GlobalInvocationID.x] = mod(_23.in_data[gl_GlobalInvocationID.x], _33.out_data[gl_GlobalInvocationID.x]);
_33.out_data[gl_GlobalInvocationID.x] = as_type<float4>(as_type<uint4>(_23.in_data[gl_GlobalInvocationID.x]) % as_type<uint4>(_33.out_data[gl_GlobalInvocationID.x]));

View File

@ -13,7 +13,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float4 i;
float4 _31 = modf(_23.in_data[gl_GlobalInvocationID.x], i);

View File

@ -10,7 +10,7 @@ struct SSBO2
constant int _69 = {};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _27 [[buffer(0)]])
kernel void main0(device SSBO2& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
if (gl_GlobalInvocationID.x == 2u)
{

View File

@ -0,0 +1,20 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant uint3 gl_WorkGroupSize = uint3(4u, 4u, 1u);
struct SSBO
{
float out_data[1];
};
kernel void main0(device SSBO& _67 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
threadgroup float foo[4][4];
foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex);
threadgroup_barrier(mem_flags::mem_threadgroup);
_67.out_data[gl_GlobalInvocationID.x] = (((0.0 + foo[gl_LocalInvocationID.x][0]) + foo[gl_LocalInvocationID.x][1]) + foo[gl_LocalInvocationID.x][2]) + foo[gl_LocalInvocationID.x][3];
}

View File

@ -15,7 +15,7 @@ struct SSBO2
float out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], device SSBO2& _44 [[buffer(1)]])
kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _44 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]])
{
threadgroup float sShared[4];
sShared[gl_LocalInvocationIndex] = _22.in_data[gl_GlobalInvocationID.x];

View File

@ -18,7 +18,7 @@ struct SSBO
Foo in_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]])
kernel void main0(device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_23.out_data[gl_GlobalInvocationID.x].m = _30.in_data[gl_GlobalInvocationID.x].m * _30.in_data[gl_GlobalInvocationID.x].m;
}

View File

@ -16,15 +16,15 @@ struct SSBO2
constant uint _98 = {};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]])
kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float4 _93;
int _94;
_93 = _24.in_data[gl_GlobalInvocationID.x];
_94 = 0;
int _48;
int _40;
float4 _46;
int _48;
for (;;)
{
_40 = _94 + 1;

View File

@ -28,7 +28,7 @@ struct SSBO2
float4 outputs[1];
};
kernel void main0(device SSBO0& _36 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]])
kernel void main0(device SSBO0& _36 [[buffer(0)]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_66.outputs[gl_GlobalInvocationID.x] = _36.s0s[gl_GlobalInvocationID.x].a + _55.s1s[gl_GlobalInvocationID.x].a;
}

View File

@ -13,7 +13,7 @@ struct SSBO
uint inputs[1];
};
kernel void main0(device SSBO2& _10 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(1)]])
kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u;
}

View File

@ -8,7 +8,7 @@ struct main0_out
float4 FragColor [[color(0)]];
};
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], texture2d_ms<float> uSamplerArray [[texture(1)]], sampler uSamplerArraySmplr [[sampler(1)]], texture2d_ms<float> uImage [[texture(2)]], texture2d_ms<float> uImageArray [[texture(3)]])
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], texture2d_ms<float> uSamplerArray [[texture(1)]], texture2d_ms<float> uImage [[texture(2)]], texture2d_ms<float> uImageArray [[texture(3)]], sampler uSamplerSmplr [[sampler(0)]], sampler uSamplerArraySmplr [[sampler(1)]])
{
main0_out out = {};
out.FragColor = float4(float(((int(uSampler.get_num_samples()) + int(uSamplerArray.get_num_samples())) + int(uImage.get_num_samples())) + int(uImageArray.get_num_samples())));

View File

@ -14,7 +14,7 @@ struct main0_out
float4 FragColor1 [[color(1)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> TextureBase [[texture(0)]], sampler TextureBaseSmplr [[sampler(0)]], texture2d<float> TextureDetail [[texture(1)]], sampler TextureDetailSmplr [[sampler(1)]])
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> TextureBase [[texture(0)]], texture2d<float> TextureDetail [[texture(1)]], sampler TextureBaseSmplr [[sampler(0)]], sampler TextureDetailSmplr [[sampler(1)]])
{
main0_out out = {};
float4 _20 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy);

View File

@ -0,0 +1,31 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Foo
{
float a;
float b;
};
struct main0_in
{
int line [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
float lut[4] = {1.0, 4.0, 3.0, 2.0};
Foo foos[2] = {{10.0, 20.0}, {30.0, 40.0}};
out.FragColor = float4(lut[in.line]);
out.FragColor += float4(foos[in.line].a * (foos[1 - in.line].a));
return out;
}

View File

@ -8,7 +8,7 @@ struct main0_out
float4 FragColor [[color(0)]];
};
fragment main0_out main0(float4 gl_FragCoord [[position]], texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]])
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
int2 _17 = int2(gl_FragCoord.xy);

View File

@ -15,7 +15,7 @@ struct main0_out
float FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[texture(0)]], sampler uShadow2DSmplr [[sampler(0)]], texture1d<float> uSampler1D [[texture(1)]], sampler uSampler1DSmplr [[sampler(1)]], texture2d<float> uSampler2D [[texture(2)]], sampler uSampler2DSmplr [[sampler(2)]], texture3d<float> uSampler3D [[texture(3)]], sampler uSampler3DSmplr [[sampler(3)]])
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[texture(0)]], texture1d<float> uSampler1D [[texture(1)]], texture2d<float> uSampler2D [[texture(2)]], texture3d<float> uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]])
{
main0_out out = {};
float4 _20 = in.vClip4;

View File

@ -0,0 +1,39 @@
#version 450
struct Params
{
vec4 TextureSize;
vec4 Params1;
vec4 Params2;
vec4 Params3;
vec4 Params4;
vec4 Bloom;
};
layout(binding = 1, std140) uniform CB1
{
Params CB1;
} _8;
uniform sampler2D SPIRV_Cross_CombinedmapTexturemapSampler;
layout(location = 0) in vec2 IN_uv;
layout(location = 0) out vec4 _entryPointOutput;
void main()
{
vec4 _49 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv);
float _50 = _49.y;
float _55;
float _58;
_55 = 0.0;
_58 = 0.0;
float _64;
vec4 _72;
float _78;
for (int _60 = -3; _60 <= 3; _64 = float(_60), _72 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (vec2(0.0, _8.CB1.TextureSize.w) * _64)), _78 = exp(((-_64) * _64) * 0.2222220003604888916015625) * float(abs(_72.y - _50) < clamp((_50 * 80.0) * 0.0007999999797903001308441162109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375)), _55 += (_72.x * _78), _58 += _78, _60++)
{
}
_entryPointOutput = vec4(_55 / _58, _50, 0.0, 1.0);
}

View File

@ -20,9 +20,9 @@ void main()
int _94;
_93 = _24.in_data[gl_GlobalInvocationID.x];
_94 = 0;
int _48;
int _40;
vec4 _46;
int _48;
for (;;)
{
_40 = _94 + 1;

View File

@ -0,0 +1,23 @@
#version 310 es
precision mediump float;
precision highp int;
struct Foo
{
float a;
float b;
};
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in mediump int _line;
float lut[4];
Foo foos[2];
void main()
{
lut = float[](1.0, 4.0, 3.0, 2.0);
foos = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
FragColor = vec4(lut[_line]);
FragColor += vec4(foos[_line].a * (foos[1 - _line].a));
}

View File

@ -0,0 +1,43 @@
struct Foo
{
float a;
float b;
};
static const float _16[4] = { 1.0f, 4.0f, 3.0f, 2.0f };
static const Foo _24 = { 10.0f, 20.0f };
static const Foo _27 = { 30.0f, 40.0f };
static const Foo _28[2] = { { 10.0f, 20.0f }, { 30.0f, 40.0f } };
static float4 FragColor;
static int _line;
struct SPIRV_Cross_Input
{
nointerpolation int _line : TEXCOORD0;
};
struct SPIRV_Cross_Output
{
float4 FragColor : SV_Target0;
};
static float lut[4];
static Foo foos[2];
void frag_main()
{
lut = _16;
foos = _28;
FragColor = lut[_line].xxxx;
FragColor += (foos[_line].a * (foos[1 - _line].a)).xxxx;
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
_line = stage_input._line;
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FragColor = FragColor;
return stage_output;
}

View File

@ -4,6 +4,8 @@ struct B
float b;
};
static const B _80 = { 10.0f, 20.0f };
cbuffer _42 : register(b0)
{
int _42_some_value : packoffset(c0);
@ -61,7 +63,7 @@ void frag_main()
float4 param_3;
branchy_inout_2(param_3);
a = param_3;
B b = { 10.0f, 20.0f };
B b = _80;
B param_4 = b;
partial_inout(param_4);
b = param_4;

View File

@ -0,0 +1,30 @@
Texture2D<float4> uTex : register(t0);
SamplerState uSampler : register(s1);
static int2 FooOut;
struct SPIRV_Cross_Output
{
int2 FooOut : SV_Target0;
};
uint2 SPIRV_Cross_textureSize(Texture2D<float4> Tex, uint Level, out uint Param)
{
uint2 ret;
Tex.GetDimensions(Level, ret.x, ret.y, Param);
return ret;
}
void frag_main()
{
uint _23_dummy_parameter;
FooOut = int2(SPIRV_Cross_textureSize(uTex, uint(0), _23_dummy_parameter));
}
SPIRV_Cross_Output main()
{
frag_main();
SPIRV_Cross_Output stage_output;
stage_output.FooOut = FooOut;
return stage_output;
}

View File

@ -167,7 +167,7 @@ void vs_adjust(thread float4& dst_reg0, thread float4& dst_reg1, thread float4&
dst_reg0.x = float4(dot(float4(tmp0.xyz, 1.0), v_309.vc[0])).x;
}
vertex main0_out main0(constant VertexBuffer& v_227 [[buffer(0)]], uint gl_VertexIndex [[vertex_id]], texture2d<uint> buff_in_2 [[texture(0)]], texture2d<uint> buff_in_1 [[texture(1)]], constant VertexConstantsBuffer& v_309 [[buffer(1)]])
vertex main0_out main0(constant VertexBuffer& v_227 [[buffer(0)]], constant VertexConstantsBuffer& v_309 [[buffer(1)]], texture2d<uint> buff_in_2 [[texture(0)]], texture2d<uint> buff_in_1 [[texture(1)]], uint gl_VertexIndex [[vertex_id]])
{
main0_out out = {};
float4 dst_reg0 = float4(0.0, 0.0, 0.0, 1.0);

View File

@ -14,7 +14,7 @@ struct _6
float _m0[1];
};
kernel void main0(uint3 gl_WorkGroupID [[threadgroup_position_in_grid]], device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]])
kernel void main0(device _6& _8 [[buffer(0)]], device _6& _9 [[buffer(1)]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]])
{
uint3 _23 = gl_WorkGroupSize;
_8._m0[gl_WorkGroupID.x] = _9._m0[gl_WorkGroupID.x] + _8._m0[gl_WorkGroupID.x];

View File

@ -101,7 +101,7 @@ struct main0_out
float4 _entryPointOutput [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], float4 gl_FragCoord [[position]], constant CB0& _19 [[buffer(0)]], texture3d<float> LightMapTexture [[texture(0)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], texture2d<float> ShadowMapTexture [[texture(1)]], texturecube<float> EnvironmentMapTexture [[texture(2)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], texture2d<float> DiffuseMapTexture [[texture(3)]], sampler NormalMapSampler [[sampler(4)]], texture2d<float> NormalMapTexture [[texture(4)]], texture2d<float> NormalDetailMapTexture [[texture(5)]], sampler NormalDetailMapSampler [[sampler(5)]], texture2d<float> StudsMapTexture [[texture(6)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], texture2d<float> SpecularMapTexture [[texture(7)]])
fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)]], texture3d<float> LightMapTexture [[texture(0)]], texture2d<float> ShadowMapTexture [[texture(1)]], texturecube<float> EnvironmentMapTexture [[texture(2)]], texture2d<float> DiffuseMapTexture [[texture(3)]], texture2d<float> NormalMapTexture [[texture(4)]], texture2d<float> NormalDetailMapTexture [[texture(5)]], texture2d<float> StudsMapTexture [[texture(6)]], texture2d<float> SpecularMapTexture [[texture(7)]], sampler LightMapSampler [[sampler(0)]], sampler ShadowMapSampler [[sampler(1)]], sampler EnvironmentMapSampler [[sampler(2)]], sampler DiffuseMapSampler [[sampler(3)]], sampler NormalMapSampler [[sampler(4)]], sampler NormalDetailMapSampler [[sampler(5)]], sampler StudsMapSampler [[sampler(6)]], sampler SpecularMapSampler [[sampler(7)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
VertexOutput _128 = _121;

View File

@ -95,7 +95,7 @@ struct main0_out
float4 m_5 [[color(0)]];
};
fragment main0_out main0(float4 gl_FragCoord [[position]], constant _6& _7 [[buffer(0)]], texture2d<float> _8 [[texture(0)]], sampler _9 [[sampler(0)]], constant _10& _11 [[buffer(1)]], texture2d<float> _12 [[texture(1)]], sampler _13 [[sampler(1)]], texture2d<float> _14 [[texture(2)]], sampler _15 [[sampler(2)]], constant _18& _19 [[buffer(2)]])
fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buffer(1)]], constant _18& _19 [[buffer(2)]], texture2d<float> _8 [[texture(0)]], texture2d<float> _12 [[texture(1)]], texture2d<float> _14 [[texture(2)]], sampler _9 [[sampler(0)]], sampler _13 [[sampler(1)]], sampler _15 [[sampler(2)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
_28 _77 = _74;

View File

@ -21,7 +21,7 @@ struct SSBO3
uint counter;
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _45 [[buffer(1)]], device SSBO3& _48 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 idata = _23.in_data[ident];

View File

@ -23,7 +23,7 @@ struct SSBO3
uint count;
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]])
kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _38 [[buffer(1)]], device SSBO3& _41 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float idata = _22.in_data[ident];

View File

@ -14,7 +14,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]])
kernel void main0(device SSBO& _28 [[buffer(0)]], device SSBO2& _52 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
int i = 0;

View File

@ -5,7 +5,7 @@
using namespace metal;
void myfunc(threadgroup int* foo)
void myfunc(threadgroup int (&foo)[1337])
{
foo[0] = 13;
}

View File

@ -3,7 +3,7 @@
using namespace metal;
kernel void main0(texture2d<float> uImageIn [[texture(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], texture2d<float, access::write> uImageOut [[texture(1)]])
kernel void main0(texture2d<float> uImageIn [[texture(0)]], texture2d<float, access::write> uImageOut [[texture(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
float4 v = uImageIn.read(uint2((int2(gl_GlobalInvocationID.xy) + int2(uImageIn.get_width(), uImageIn.get_height()))));
uImageOut.write(v, uint2(int2(gl_GlobalInvocationID.xy)));

View File

@ -14,7 +14,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]])
kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 idat = _24.in_data[ident];

View File

@ -8,7 +8,7 @@ struct SSBO2
float3x3 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _22 [[buffer(0)]])
kernel void main0(device SSBO2& _22 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
_22.out_data[ident] = float3x3(float3(10.0), float3(20.0), float3(40.0));

View File

@ -22,7 +22,7 @@ Tx mod(Tx x, Ty y)
return x - y * floor(x / y);
}
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _33 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 v = mod(_23.in_data[ident], _33.out_data[ident]);

View File

@ -13,7 +13,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]])
kernel void main0(device SSBO& _23 [[buffer(0)]], device SSBO2& _35 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 i;

View File

@ -8,7 +8,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _27 [[buffer(0)]])
kernel void main0(device SSBO2& _27 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
if (ident == 2u)

View File

@ -0,0 +1,32 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant uint3 gl_WorkGroupSize = uint3(4u, 4u, 1u);
struct SSBO
{
float out_data[1];
};
void work(threadgroup float (&foo)[4][4], thread uint3& gl_LocalInvocationID, thread uint& gl_LocalInvocationIndex, device SSBO& v_67, thread uint3& gl_GlobalInvocationID)
{
foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex);
threadgroup_barrier(mem_flags::mem_threadgroup);
float x = 0.0;
x += foo[gl_LocalInvocationID.x][0];
x += foo[gl_LocalInvocationID.x][1];
x += foo[gl_LocalInvocationID.x][2];
x += foo[gl_LocalInvocationID.x][3];
v_67.out_data[gl_GlobalInvocationID.x] = x;
}
kernel void main0(device SSBO& v_67 [[buffer(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
threadgroup float foo[4][4];
work(foo, gl_LocalInvocationID, gl_LocalInvocationIndex, v_67, gl_GlobalInvocationID);
}

View File

@ -15,7 +15,7 @@ struct SSBO2
float out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _22 [[buffer(0)]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]], device SSBO2& _44 [[buffer(1)]])
kernel void main0(device SSBO& _22 [[buffer(0)]], device SSBO2& _44 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], uint gl_LocalInvocationIndex [[thread_index_in_threadgroup]])
{
uint ident = gl_GlobalInvocationID.x;
float idata = _22.in_data[ident];

View File

@ -18,7 +18,7 @@ struct SSBO
Foo in_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]])
kernel void main0(device SSBO2& _23 [[buffer(0)]], device SSBO& _30 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
_23.out_data[ident].m = _30.in_data[ident].m * _30.in_data[ident].m;

View File

@ -14,7 +14,7 @@ struct SSBO2
float4 out_data[1];
};
kernel void main0(uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]])
kernel void main0(device SSBO& _24 [[buffer(0)]], device SSBO2& _89 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
uint ident = gl_GlobalInvocationID.x;
float4 idat = _24.in_data[ident];

View File

@ -40,7 +40,7 @@ float4 overload(thread const S1& s1)
return s1.a;
}
kernel void main0(device SSBO0& _36 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]])
kernel void main0(device SSBO0& _36 [[buffer(0)]], device SSBO1& _55 [[buffer(1)]], device SSBO2& _66 [[buffer(2)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
S0 s0;
s0.a = _36.s0s[gl_GlobalInvocationID.x].a;

View File

@ -13,7 +13,7 @@ struct SSBO
uint inputs[1];
};
kernel void main0(device SSBO2& _10 [[buffer(0)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]], device SSBO& _23 [[buffer(1)]])
kernel void main0(device SSBO2& _10 [[buffer(0)]], device SSBO& _23 [[buffer(1)]], uint3 gl_GlobalInvocationID [[thread_position_in_grid]])
{
_10.outputs[gl_GlobalInvocationID.x] = _23.inputs[gl_GlobalInvocationID.x] / 29u;
}

View File

@ -8,7 +8,7 @@ struct main0_out
float4 FragColor [[color(0)]];
};
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], texture2d_ms<float> uSamplerArray [[texture(1)]], sampler uSamplerArraySmplr [[sampler(1)]], texture2d_ms<float> uImage [[texture(2)]], texture2d_ms<float> uImageArray [[texture(3)]])
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], texture2d_ms<float> uSamplerArray [[texture(1)]], texture2d_ms<float> uImage [[texture(2)]], texture2d_ms<float> uImageArray [[texture(3)]], sampler uSamplerSmplr [[sampler(0)]], sampler uSamplerArraySmplr [[sampler(1)]])
{
main0_out out = {};
out.FragColor = float4(float(((int(uSampler.get_num_samples()) + int(uSamplerArray.get_num_samples())) + int(uImage.get_num_samples())) + int(uImageArray.get_num_samples())));

View File

@ -14,7 +14,7 @@ struct main0_out
float4 FragColor1 [[color(1)]];
};
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> TextureBase [[texture(0)]], sampler TextureBaseSmplr [[sampler(0)]], texture2d<float> TextureDetail [[texture(1)]], sampler TextureDetailSmplr [[sampler(1)]])
fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> TextureBase [[texture(0)]], texture2d<float> TextureDetail [[texture(1)]], sampler TextureBaseSmplr [[sampler(0)]], sampler TextureDetailSmplr [[sampler(1)]])
{
main0_out out = {};
float4 texSample0 = TextureBase.sample(TextureBaseSmplr, in.VertGeom.xy);

View File

@ -0,0 +1,31 @@
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Foo
{
float a;
float b;
};
struct main0_in
{
int line [[user(locn0)]];
};
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]])
{
main0_out out = {};
float lut[4] = {1.0, 4.0, 3.0, 2.0};
Foo foos[2] = {{10.0, 20.0}, {30.0, 40.0}};
out.FragColor = float4(lut[in.line]);
out.FragColor += float4(foos[in.line].a * (foos[1 - in.line].a));
return out;
}

View File

@ -8,7 +8,7 @@ struct main0_out
float4 FragColor [[color(0)]];
};
fragment main0_out main0(float4 gl_FragCoord [[position]], texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]])
fragment main0_out main0(texture2d_ms<float> uSampler [[texture(0)]], sampler uSamplerSmplr [[sampler(0)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
int2 coord = int2(gl_FragCoord.xy);

View File

@ -15,7 +15,7 @@ struct main0_out
float FragColor [[color(0)]];
};
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[texture(0)]], sampler uShadow2DSmplr [[sampler(0)]], texture1d<float> uSampler1D [[texture(1)]], sampler uSampler1DSmplr [[sampler(1)]], texture2d<float> uSampler2D [[texture(2)]], sampler uSampler2DSmplr [[sampler(2)]], texture3d<float> uSampler3D [[texture(3)]], sampler uSampler3DSmplr [[sampler(3)]])
fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[texture(0)]], texture1d<float> uSampler1D [[texture(1)]], texture2d<float> uSampler2D [[texture(2)]], texture3d<float> uSampler3D [[texture(3)]], sampler uShadow2DSmplr [[sampler(0)]], sampler uSampler1DSmplr [[sampler(1)]], sampler uSampler2DSmplr [[sampler(2)]], sampler uSampler3DSmplr [[sampler(3)]])
{
main0_out out = {};
float4 _20 = in.vClip4;

View File

@ -0,0 +1,39 @@
#version 450
struct Params
{
vec4 TextureSize;
vec4 Params1;
vec4 Params2;
vec4 Params3;
vec4 Params4;
vec4 Bloom;
};
layout(binding = 1, std140) uniform CB1
{
Params CB1;
} _8;
uniform sampler2D SPIRV_Cross_CombinedmapTexturemapSampler;
layout(location = 0) in vec2 IN_uv;
layout(location = 0) out vec4 _entryPointOutput;
void main()
{
vec4 _49 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv);
float _50 = _49.y;
float _55;
float _58;
_55 = 0.0;
_58 = 0.0;
float _64;
vec4 _72;
float _78;
for (int _60 = -3; _60 <= 3; _64 = float(_60), _72 = texture(SPIRV_Cross_CombinedmapTexturemapSampler, IN_uv + (vec2(0.0, _8.CB1.TextureSize.w) * _64)), _78 = exp(((-_64) * _64) * 0.2222220003604888916015625) * float(abs(_72.y - _50) < clamp((_50 * 80.0) * 0.0007999999797903001308441162109375, 7.999999797903001308441162109375e-05, 0.008000000379979610443115234375)), _55 += (_72.x * _78), _58 += _78, _60++)
{
}
_entryPointOutput = vec4(_55 / _58, _50, 0.0, 1.0);
}

View File

@ -0,0 +1,23 @@
#version 310 es
precision mediump float;
precision highp int;
struct Foo
{
float a;
float b;
};
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in mediump int _line;
float lut[4];
Foo foos[2];
void main()
{
lut = float[](1.0, 4.0, 3.0, 2.0);
foos = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
FragColor = vec4(lut[_line]);
FragColor += vec4(foos[_line].a * (foos[1 - _line].a));
}

View File

@ -0,0 +1,20 @@
#version 310 es
precision mediump float;
float lut[4] = float[](1.0, 4.0, 3.0, 2.0);
struct Foo
{
float a;
float b;
};
Foo foos[2] = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in int line;
void main()
{
FragColor = vec4(lut[line]);
FragColor += foos[line].a * foos[1 - line].a;
}

View File

@ -0,0 +1,9 @@
#version 450
layout(set = 0, binding = 0) uniform texture2D uTex;
layout(set = 0, binding = 1) uniform sampler uSampler;
layout(location = 0) out ivec2 FooOut;
void main()
{
FooOut = textureSize(sampler2D(uTex, uSampler), 0);
}

View File

@ -0,0 +1,29 @@
#version 310 es
layout(local_size_x = 4, local_size_y = 4) in;
shared float foo[4][4];
layout(binding = 0, std430) buffer SSBO
{
float out_data[];
};
void work()
{
foo[gl_LocalInvocationID.x][gl_LocalInvocationID.y] = float(gl_LocalInvocationIndex);
memoryBarrierShared();
barrier();
float x = 0.0;
x += foo[gl_LocalInvocationID.x][0];
x += foo[gl_LocalInvocationID.x][1];
x += foo[gl_LocalInvocationID.x][2];
x += foo[gl_LocalInvocationID.x][3];
out_data[gl_GlobalInvocationID.x] = x;
}
void main()
{
work();
}

View File

@ -0,0 +1,20 @@
#version 310 es
precision mediump float;
float lut[4] = float[](1.0, 4.0, 3.0, 2.0);
struct Foo
{
float a;
float b;
};
Foo foos[2] = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in int line;
void main()
{
FragColor = vec4(lut[line]);
FragColor += foos[line].a * foos[1 - line].a;
}

View File

@ -0,0 +1,132 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 3
; Bound: 279
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %IN_p %IN_uv %_entryPointOutput
OpExecutionMode %main OriginUpperLeft
OpSource HLSL 500
OpName %main "main"
OpName %Params "Params"
OpMemberName %Params 0 "TextureSize"
OpMemberName %Params 1 "Params1"
OpMemberName %Params 2 "Params2"
OpMemberName %Params 3 "Params3"
OpMemberName %Params 4 "Params4"
OpMemberName %Params 5 "Bloom"
OpName %CB1 "CB1"
OpMemberName %CB1 0 "CB1"
OpName %_ ""
OpName %mapSampler "mapSampler"
OpName %mapTexture "mapTexture"
OpName %IN_p "IN.p"
OpName %IN_uv "IN.uv"
OpName %_entryPointOutput "@entryPointOutput"
OpMemberDecorate %Params 0 Offset 0
OpMemberDecorate %Params 1 Offset 16
OpMemberDecorate %Params 2 Offset 32
OpMemberDecorate %Params 3 Offset 48
OpMemberDecorate %Params 4 Offset 64
OpMemberDecorate %Params 5 Offset 80
OpMemberDecorate %CB1 0 Offset 0
OpDecorate %CB1 Block
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 1
OpDecorate %mapSampler DescriptorSet 1
OpDecorate %mapSampler Binding 2
OpDecorate %mapTexture DescriptorSet 1
OpDecorate %mapTexture Binding 2
OpDecorate %IN_p BuiltIn FragCoord
OpDecorate %IN_uv Location 0
OpDecorate %_entryPointOutput Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%9 = OpTypeSampler
%11 = OpTypeImage %float 2D 0 0 0 1 Unknown
%v4float = OpTypeVector %float 4
%float_0_222222 = OpConstant %float 0.222222
%33 = OpTypeSampledImage %11
%uint = OpTypeInt 32 0
%float_80 = OpConstant %float 80
%float_0_0008 = OpConstant %float 0.0008
%float_8en05 = OpConstant %float 8e-05
%float_0_008 = OpConstant %float 0.008
%float_0 = OpConstant %float 0
%int = OpTypeInt 32 1
%int_n3 = OpConstant %int -3
%int_3 = OpConstant %int 3
%bool = OpTypeBool
%float_1 = OpConstant %float 1
%int_1 = OpConstant %int 1
%Params = OpTypeStruct %v4float %v4float %v4float %v4float %v4float %v4float
%CB1 = OpTypeStruct %Params
%_ptr_Uniform_CB1 = OpTypePointer Uniform %CB1
%_ = OpVariable %_ptr_Uniform_CB1 Uniform
%int_0 = OpConstant %int 0
%uint_3 = OpConstant %uint 3
%_ptr_Uniform_float = OpTypePointer Uniform %float
%_ptr_UniformConstant_9 = OpTypePointer UniformConstant %9
%mapSampler = OpVariable %_ptr_UniformConstant_9 UniformConstant
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
%mapTexture = OpVariable %_ptr_UniformConstant_11 UniformConstant
%_ptr_Input_v4float = OpTypePointer Input %v4float
%IN_p = OpVariable %_ptr_Input_v4float Input
%_ptr_Input_v2float = OpTypePointer Input %v2float
%IN_uv = OpVariable %_ptr_Input_v2float Input
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_entryPointOutput = OpVariable %_ptr_Output_v4float Output
%main = OpFunction %void None %3
%5 = OpLabel
%158 = OpLoad %v2float %IN_uv
%178 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_0 %uint_3
%179 = OpLoad %float %178
%180 = OpCompositeConstruct %v2float %float_0 %179
%184 = OpLoad %9 %mapSampler
%185 = OpLoad %11 %mapTexture
%204 = OpSampledImage %33 %185 %184
%206 = OpImageSampleImplicitLod %v4float %204 %158
%207 = OpCompositeExtract %float %206 1
%209 = OpFMul %float %207 %float_80
%210 = OpFMul %float %209 %float_0_0008
%211 = OpExtInst %float %1 FClamp %210 %float_8en05 %float_0_008
OpBranch %212
%212 = OpLabel
%276 = OpPhi %float %float_0 %5 %252 %218
%277 = OpPhi %float %float_0 %5 %255 %218
%278 = OpPhi %int %int_n3 %5 %257 %218
%217 = OpSLessThanEqual %bool %278 %int_3
OpLoopMerge %213 %218 None
OpBranchConditional %217 %218 %213
%218 = OpLabel
%220 = OpConvertSToF %float %278
%222 = OpFNegate %float %220
%224 = OpFMul %float %222 %220
%226 = OpFMul %float %224 %float_0_222222
%227 = OpExtInst %float %1 Exp %226
%230 = OpSampledImage %33 %185 %184
%234 = OpVectorTimesScalar %v2float %180 %220
%235 = OpFAdd %v2float %158 %234
%236 = OpImageSampleImplicitLod %v4float %230 %235
%273 = OpCompositeExtract %float %236 1
%241 = OpFSub %float %273 %207
%242 = OpExtInst %float %1 FAbs %241
%244 = OpFOrdLessThan %bool %242 %211
%245 = OpSelect %float %244 %float_1 %float_0
%246 = OpFMul %float %227 %245
%275 = OpCompositeExtract %float %236 0
%250 = OpFMul %float %275 %246
%252 = OpFAdd %float %276 %250
%255 = OpFAdd %float %277 %246
%257 = OpIAdd %int %278 %int_1
OpBranch %212
%213 = OpLabel
%260 = OpFDiv %float %276 %277
%190 = OpCompositeConstruct %v4float %260 %207 %float_0 %float_1
OpStore %_entryPointOutput %190
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,20 @@
#version 310 es
precision mediump float;
float lut[4] = float[](1.0, 4.0, 3.0, 2.0);
struct Foo
{
float a;
float b;
};
Foo foos[2] = Foo[](Foo(10.0, 20.0), Foo(30.0, 40.0));
layout(location = 0) out vec4 FragColor;
layout(location = 0) flat in int line;
void main()
{
FragColor = vec4(lut[line]);
FragColor += foos[line].a * foos[1 - line].a;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 ARM Limited
* Copyright 2016-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 ARM Limited
* Copyright 2016-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -723,16 +723,30 @@ struct SPIRConstant : IVariant
{
Constant r[4];
// If != 0, this element is a specialization constant, and we should keep track of it as such.
uint32_t id[4] = {};
uint32_t id[4];
uint32_t vecsize = 1;
ConstantVector()
{
unsigned i;
for (i = 0; i < 4; i++)
id[i] = 0;
}
};
struct ConstantMatrix
{
ConstantVector c[4];
// If != 0, this column is a specialization constant, and we should keep track of it as such.
uint32_t id[4] = {};
uint32_t id[4];
uint32_t columns = 1;
ConstantMatrix()
{
unsigned i;
for (i = 0; i < 4; i++)
id[i] = 0;
}
};
inline uint32_t specialization_constant_id(uint32_t col, uint32_t row) const

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -3368,7 +3368,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
CFG cfg(*this, entry);
// Analyze if there are parameters which need to be implicitly preserved with an "in" qualifier.
analyze_parameter_preservation(entry, cfg, handler.accessed_variables_to_block,
this->analyze_parameter_preservation(entry, cfg, handler.accessed_variables_to_block,
handler.complete_write_variables_to_block);
unordered_map<uint32_t, uint32_t> potential_loop_variables;
@ -3393,7 +3393,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
// The continue block is dominated by the inner part of the loop, which does not make sense in high-level
// language output because it will be declared before the body,
// so we will have to lift the dominator up to the relevant loop header instead.
builder.add_block(continue_block_to_loop_header[block]);
builder.add_block(this->continue_block_to_loop_header[block]);
if (type.vecsize == 1 && type.columns == 1)
{
@ -3447,7 +3447,7 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
// If a temporary is used in more than one block, we might have to lift continue block
// access up to loop header like we did for variables.
if (blocks.size() != 1 && this->is_continue(block))
builder.add_block(continue_block_to_loop_header[block]);
builder.add_block(this->continue_block_to_loop_header[block]);
}
uint32_t dominating_block = builder.get_dominator();
@ -3462,10 +3462,10 @@ void Compiler::analyze_variable_scope(SPIRFunction &entry)
// This should be very rare, but if we try to declare a temporary inside a loop,
// and that temporary is used outside the loop as well (spirv-opt inliner likes this)
// we should actually emit the temporary outside the loop.
hoisted_temporaries.insert(var.first);
forced_temporaries.insert(var.first);
this->hoisted_temporaries.insert(var.first);
this->forced_temporaries.insert(var.first);
auto &block_temporaries = get<SPIRBlock>(dominating_block).declare_temporary;
auto &block_temporaries = this->get<SPIRBlock>(dominating_block).declare_temporary;
block_temporaries.emplace_back(handler.result_id_to_type[var.first], var.first);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1634,10 +1634,10 @@ void CompilerGLSL::replace_illegal_names()
"iimageCubeArray", "image1D", "image1DArray", "image2D", "image2DArray", "image2DMS", "image2DMSArray", "image2DRect",
"image3D", "imageBuffer", "imageCube", "imageCubeArray", "in", "inline", "inout", "input", "int", "interface", "invariant",
"isampler1D", "isampler1DArray", "isampler2D", "isampler2DArray", "isampler2DMS", "isampler2DMSArray", "isampler2DRect",
"isampler3D", "isamplerBuffer", "isamplerCube", "isamplerCubeArray", "ivec2", "ivec3", "ivec4", "layout", "long", "lowp",
"mat2", "mat2x2", "mat2x3", "mat2x4", "mat3", "mat3x2", "mat3x3", "mat3x4", "mat4", "mat4x2", "mat4x3", "mat4x4", "mediump",
"namespace", "noinline", "noperspective", "out", "output", "packed", "partition", "patch", "precision", "public", "readonly",
"resource", "restrict", "return", "row_major", "sample", "sampler1D", "sampler1DArray", "sampler1DArrayShadow",
"isampler3D", "isamplerBuffer", "isamplerCube", "isamplerCubeArray", "ivec2", "ivec3", "ivec4", "layout", "line", "linear", "long", "lowp",
"mat2", "mat2x2", "mat2x3", "mat2x4", "mat3", "mat3x2", "mat3x3", "mat3x4", "mat4", "mat4x2", "mat4x3", "mat4x4", "matrix", "mediump",
"namespace", "noinline", "noperspective", "out", "output", "packed", "partition", "patch", "point", "precision", "public", "readonly",
"resource", "restrict", "return", "row_major", "sample", "sampler", "sampler1D", "sampler1DArray", "sampler1DArrayShadow",
"sampler1DShadow", "sampler2D", "sampler2DArray", "sampler2DArrayShadow", "sampler2DMS", "sampler2DMSArray",
"sampler2DRect", "sampler2DRectShadow", "sampler2DShadow", "sampler3D", "sampler3DRect", "samplerBuffer",
"samplerCube", "samplerCubeArray", "samplerCubeArrayShadow", "samplerCubeShadow", "short", "sizeof", "smooth", "static",
@ -2256,6 +2256,7 @@ string CompilerGLSL::to_expression(uint32_t id)
case TypeConstant:
{
auto &c = get<SPIRConstant>(id);
auto &type = get<SPIRType>(c.constant_type);
// WorkGroupSize may be a constant.
auto &dec = meta[c.self].decoration;
@ -2263,6 +2264,10 @@ string CompilerGLSL::to_expression(uint32_t id)
return builtin_to_glsl(dec.builtin_type, StorageClassGeneric);
else if (c.specialization && options.vulkan_semantics)
return to_name(id);
else if (type.basetype == SPIRType::Struct && !backend.can_declare_struct_inline)
return to_name(id);
else if (!type.array.empty() && !backend.can_declare_arrays_inline)
return to_name(id);
else
return constant_expression(c);
}
@ -5497,6 +5502,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
if (out_type.basetype == SPIRType::Struct && !backend.can_declare_struct_inline)
forward = false;
if (!out_type.array.empty() && !backend.can_declare_arrays_inline)
forward = false;
string constructor_op;
if (backend.use_initializer_list && composite)
@ -7881,11 +7888,29 @@ void CompilerGLSL::branch(uint32_t from, uint32_t to)
else
{
auto &from_block = get<SPIRBlock>(from);
auto &dominator = get<SPIRBlock>(from_block.loop_dominator);
bool outside_control_flow = false;
uint32_t loop_dominator = 0;
// For non-complex continue blocks, we implicitly branch to the continue block
// by having the continue block be part of the loop header in for (; ; continue-block).
bool outside_control_flow = block_is_outside_flow_control_from_block(dominator, from_block);
// FIXME: Refactor this to not use the old loop_dominator tracking.
if (from_block.merge_block)
{
// If we are a loop header, we don't set the loop dominator,
// so just use "self" here.
loop_dominator = from;
}
else if (from_block.loop_dominator != -1u)
{
loop_dominator = from_block.loop_dominator;
}
if (loop_dominator != 0)
{
auto &dominator = get<SPIRBlock>(loop_dominator);
// For non-complex continue blocks, we implicitly branch to the continue block
// by having the continue block be part of the loop header in for (; ; continue-block).
outside_control_flow = block_is_outside_flow_control_from_block(dominator, from_block);
}
// Some simplification for for-loops. We always end up with a useless continue;
// statement since we branch to a loop block.
@ -8265,6 +8290,10 @@ void CompilerGLSL::emit_block_chain(SPIRBlock &block)
bool emitted_for_loop_header = false;
// If we need to force temporaries for certain IDs due to continue blocks, do it before starting loop header.
// Need to sort these to ensure that reference output is stable.
sort(begin(block.declare_temporary), end(block.declare_temporary),
[](const pair<uint32_t, uint32_t> &a, const pair<uint32_t, uint32_t> &b) { return a.second < b.second; });
for (auto &tmp : block.declare_temporary)
{
auto flags = meta[tmp.second].decoration.decoration_flags;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 ARM Limited
* Copyright 2015-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -323,6 +323,7 @@ protected:
bool use_initializer_list = false;
bool use_typed_initializer_list = false;
bool can_declare_struct_inline = true;
bool can_declare_arrays_inline = true;
bool native_row_major_matrix = true;
bool use_constructor_splatting = true;
bool boolean_mix_support = true;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 Robert Konrad
* Copyright 2016-2018 Robert Konrad
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -204,7 +204,7 @@ static string image_format_to_type(ImageFormat fmt, SPIRType::BaseType basetype)
}
// Returns true if an arithmetic operation does not change behavior depending on signedness.
static bool opcode_is_sign_invariant(Op opcode)
static bool hlsl_opcode_is_sign_invariant(Op opcode)
{
switch (opcode)
{
@ -841,6 +841,34 @@ void CompilerHLSL::emit_builtin_variables()
}
}
void CompilerHLSL::emit_composite_constants()
{
// HLSL cannot declare structs or arrays inline, so we must move them out to
// global constants directly.
bool emitted = false;
for (auto &id : ids)
{
if (id.get_type() == TypeConstant)
{
auto &c = id.get<SPIRConstant>();
if (c.specialization)
continue;
auto &type = get<SPIRType>(c.constant_type);
if (type.basetype == SPIRType::Struct || !type.array.empty())
{
auto name = to_name(c.self);
statement("static const ", variable_decl(type, name), " = ", constant_expression(c), ";");
emitted = true;
}
}
}
if (emitted)
statement("");
}
void CompilerHLSL::emit_specialization_constants()
{
bool emitted = false;
@ -880,6 +908,8 @@ void CompilerHLSL::emit_resources()
{
auto &execution = get_entry_point();
replace_illegal_names();
emit_specialization_constants();
// Output all basic struct types which are not Block or BufferBlock as these are declared inplace
@ -898,6 +928,8 @@ void CompilerHLSL::emit_resources()
}
}
emit_composite_constants();
bool emitted = false;
// Output UBOs and SSBOs
@ -3022,15 +3054,24 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
auto ops = stream(instruction);
auto opcode = static_cast<Op>(instruction.op);
#undef BOP
#undef BOP_CAST
#undef UOP
#undef QFOP
#undef TFOP
#undef BFOP
#undef BFOP_CAST
#undef BFOP
#undef UFOP
#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BOP_CAST(op, type) \
emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode))
emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode))
#define UOP(op) emit_unary_op(ops[0], ops[1], ops[2], #op)
#define QFOP(op) emit_quaternary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], ops[5], #op)
#define TFOP(op) emit_trinary_func_op(ops[0], ops[1], ops[2], ops[3], ops[4], #op)
#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BFOP_CAST(op, type) \
emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode))
emit_binary_func_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, hlsl_opcode_is_sign_invariant(opcode))
#define BFOP(op) emit_binary_func_op(ops[0], ops[1], ops[2], ops[3], #op)
#define UFOP(op) emit_unary_func_op(ops[0], ops[1], ops[2], #op)
@ -3088,8 +3129,11 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction)
{
uint32_t result_type = ops[0];
uint32_t id = ops[1];
emit_op(result_type, id, to_expression(ops[2]), true, true);
// TODO: Maybe change this when separate samplers/images are supported
auto *combined = maybe_get<SPIRCombinedImageSampler>(ops[2]);
if (combined)
emit_op(result_type, id, to_expression(combined->image), true, true);
else
emit_op(result_type, id, to_expression(ops[2]), true, true);
break;
}
@ -3645,6 +3689,7 @@ string CompilerHLSL::compile()
backend.boolean_mix_support = false;
backend.can_swizzle_scalar = true;
backend.can_declare_struct_inline = false;
backend.can_declare_arrays_inline = false;
update_active_builtins();
analyze_sampler_comparison_states();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 Robert Konrad
* Copyright 2016-2018 Robert Konrad
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -91,6 +91,7 @@ private:
void emit_modern_uniform(const SPIRVariable &var);
void emit_legacy_uniform(const SPIRVariable &var);
void emit_specialization_constants();
void emit_composite_constants();
void emit_fixup() override;
std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) override;
std::string layout_for_member(const SPIRType &type, uint32_t index) override;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 The Brenwill Workshop Ltd.
* Copyright 2016-2018 The Brenwill Workshop Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -1230,7 +1230,13 @@ void CompilerMSL::emit_specialization_constants()
// Override for MSL-specific syntax instructions
void CompilerMSL::emit_instruction(const Instruction &instruction)
{
#undef BOP
#undef BOP_CAST
#undef UOP
#undef QFOP
#undef TFOP
#undef BFOP
#undef BFOP_CAST
#define BOP(op) emit_binary_op(ops[0], ops[1], ops[2], ops[3], #op)
#define BOP_CAST(op, type) \
emit_binary_op_cast(ops[0], ops[1], ops[2], ops[3], #op, type, opcode_is_sign_invariant(opcode))
@ -2692,7 +2698,19 @@ string CompilerMSL::entry_point_args(bool append_comma)
convert_to_string(nsi_var.first) + ")]]";
}
// Uniforms
// Output resources, sorted by resource index & type
// We need to sort to work around a bug on macOS 10.13 with NVidia drivers where switching between shaders
// with different order of buffers can result in issues with buffer assignments inside the driver.
struct Resource
{
Variant *id;
string name;
SPIRType::BaseType basetype;
uint32_t index;
};
vector<Resource> resources;
for (auto &id : ids)
{
if (id.get_type() == TypeVariable)
@ -2706,48 +2724,75 @@ string CompilerMSL::entry_point_args(bool append_comma)
var.storage == StorageClassPushConstant || var.storage == StorageClassStorageBuffer) &&
!is_hidden_variable(var))
{
switch (type.basetype)
if (type.basetype == SPIRType::SampledImage)
{
case SPIRType::Struct:
{
auto &m = meta.at(type.self);
if (m.members.size() == 0)
break;
if (!ep_args.empty())
ep_args += ", ";
ep_args += get_argument_address_space(var) + " " + type_to_glsl(type) + "& " + to_name(var_id);
ep_args += " [[buffer(" + convert_to_string(get_metal_resource_index(var, type.basetype)) + ")]]";
break;
}
case SPIRType::Sampler:
if (!ep_args.empty())
ep_args += ", ";
ep_args += type_to_glsl(type) + " " + to_name(var_id);
ep_args += " [[sampler(" + convert_to_string(get_metal_resource_index(var, type.basetype)) + ")]]";
break;
case SPIRType::Image:
if (!ep_args.empty())
ep_args += ", ";
ep_args += type_to_glsl(type, var_id) + " " + to_name(var_id);
ep_args += " [[texture(" + convert_to_string(get_metal_resource_index(var, type.basetype)) + ")]]";
break;
case SPIRType::SampledImage:
if (!ep_args.empty())
ep_args += ", ";
ep_args += type_to_glsl(type, var_id) + " " + to_name(var_id);
ep_args +=
" [[texture(" + convert_to_string(get_metal_resource_index(var, SPIRType::Image)) + ")]]";
resources.push_back(
{ &id, to_name(var_id), SPIRType::Image, get_metal_resource_index(var, SPIRType::Image) });
if (type.image.dim != DimBuffer)
{
ep_args += ", sampler " + to_sampler_expression(var_id);
ep_args +=
" [[sampler(" + convert_to_string(get_metal_resource_index(var, SPIRType::Sampler)) + ")]]";
}
break;
default:
break;
resources.push_back({ &id, to_sampler_expression(var_id), SPIRType::Sampler,
get_metal_resource_index(var, SPIRType::Sampler) });
}
else
{
resources.push_back(
{ &id, to_name(var_id), type.basetype, get_metal_resource_index(var, type.basetype) });
}
}
}
}
std::sort(resources.begin(), resources.end(), [](const Resource &lhs, const Resource &rhs) {
return tie(lhs.basetype, lhs.index) < tie(rhs.basetype, rhs.index);
});
for (auto &r : resources)
{
auto &var = r.id->get<SPIRVariable>();
auto &type = get<SPIRType>(var.basetype);
uint32_t var_id = var.self;
switch (r.basetype)
{
case SPIRType::Struct:
{
auto &m = meta.at(type.self);
if (m.members.size() == 0)
break;
if (!ep_args.empty())
ep_args += ", ";
ep_args += get_argument_address_space(var) + " " + type_to_glsl(type) + "& " + r.name;
ep_args += " [[buffer(" + convert_to_string(r.index) + ")]]";
break;
}
case SPIRType::Sampler:
if (!ep_args.empty())
ep_args += ", ";
ep_args += "sampler " + r.name;
ep_args += " [[sampler(" + convert_to_string(r.index) + ")]]";
break;
case SPIRType::Image:
if (!ep_args.empty())
ep_args += ", ";
ep_args += type_to_glsl(type, var_id) + " " + r.name;
ep_args += " [[texture(" + convert_to_string(r.index) + ")]]";
break;
default:
SPIRV_CROSS_THROW("Unexpected resource type");
break;
}
}
// Builtin variables
for (auto &id : ids)
{
if (id.get_type() == TypeVariable)
{
auto &var = id.get<SPIRVariable>();
uint32_t var_id = var.self;
if (var.storage == StorageClassInput && is_builtin_variable(var))
{
if (!ep_args.empty())
@ -2837,17 +2882,28 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg)
decl += "const ";
if (is_builtin_variable(var))
decl += builtin_type_decl((BuiltIn)get_decoration(arg.id, DecorationBuiltIn));
decl += builtin_type_decl(static_cast<BuiltIn>(get_decoration(arg.id, DecorationBuiltIn)));
else
decl += type_to_glsl(type, arg.id);
if (is_array(type))
decl += "*";
{
decl += " (&";
decl += to_name(var.self);
decl += ")";
decl += type_to_array_glsl(type);
}
else if (!pointer)
{
decl += "&";
decl += " ";
decl += to_name(var.self);
decl += " ";
decl += to_name(var.self);
}
else
{
decl += " ";
decl += to_name(var.self);
}
return decl;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 The Brenwill Workshop Ltd.
* Copyright 2016-2018 The Brenwill Workshop Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@
#define SPIRV_CROSS_MSL_HPP
#include "spirv_glsl.hpp"
#include <stdint.h>
#include <limits>
#include <map>
#include <set>
@ -64,7 +65,7 @@ using MSLStructMemberKey = uint64_t;
// Special constant used in a MSLResourceBinding desc_set
// element to indicate the bindings for the push constants.
static const uint32_t kPushConstDescSet = std::numeric_limits<uint32_t>::max();
static const uint32_t kPushConstDescSet = ((uint32_t)-1);
// Special constant used in a MSLResourceBinding binding
// element to indicate the bindings for the push constants.

0
deps/SPIRV-Cross/test_shaders.sh vendored Normal file → Executable file
View File

0
deps/SPIRV-Cross/update_test_shaders.sh vendored Normal file → Executable file
View File

View File

@ -363,7 +363,7 @@ bool glslang::compile_spirv(const string &source, Stage stage, std::vector<uint3
messages, &msg, forbid_include))
{
fprintf(stderr, "%s\n", msg.c_str());
return {};
return false;
}
if (!shader.parse(&process.GetResources(), 100, false, messages))

View File

@ -33,6 +33,9 @@
//POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _MACHINE_INDEPENDENT_LIVE_TRAVERSER_H
#define _MACHINE_INDEPENDENT_LIVE_TRAVERSER_H
#include "../Include/Common.h"
#include "reflection.h"
#include "localintermediate.h"
@ -134,3 +137,5 @@ private:
};
} // namespace glslang
#endif

View File

@ -52,6 +52,7 @@
// preprocessor includes
#include "preprocessor/PpContext.h"
#include "preprocessor/PpTokens.h"
#include "preprocessor/Compare.h"
// Required to avoid missing prototype warnings for some compilers
int yylex(YYSTYPE*, glslang::TParseContext&);
@ -287,38 +288,15 @@ protected:
} // end namespace glslang
// This is the function the glslang parser (i.e., bison) calls to get its next token
int yylex(YYSTYPE* glslangTokenDesc, glslang::TParseContext& parseContext)
int yylex(YYSTYPE* glslangTokenDesc, glslang::TParseContext& _parseContext)
{
glslang::TParserToken token(*glslangTokenDesc);
return parseContext.getScanContext()->tokenize(parseContext.getPpContext(), token);
return _parseContext.getScanContext()->tokenize(_parseContext.getPpContext(), token);
}
namespace {
struct str_eq
{
bool operator()(const char* lhs, const char* rhs) const
{
return strcmp(lhs, rhs) == 0;
}
};
struct str_hash
{
size_t operator()(const char* str) const
{
// djb2
unsigned long hash = 5381;
int c;
while ((c = *str++) != 0)
hash = ((hash << 5) + hash) + c;
return hash;
}
};
// A single global usable by all threads, by all versions, by all languages.
// After a single process-level initialization, this is read only and thread safe
std::unordered_map<const char*, int, str_hash, str_eq>* KeywordMap = nullptr;
@ -670,7 +648,7 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
case '{': return LEFT_BRACE;
case '}': return RIGHT_BRACE;
case '\\':
parseContext.error(loc, "illegal use of escape character", "\\", "");
_parseContext.error(loc, "illegal use of escape character", "\\", "");
break;
case PpAtomAdd: return ADD_ASSIGN;
@ -722,7 +700,7 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
char buf[2];
buf[0] = (char)ppToken.token;
buf[1] = 0;
parseContext.error(loc, "unexpected token", buf, "");
_parseContext.error(loc, "unexpected token", buf, "");
break;
}
} while (true);
@ -761,8 +739,8 @@ int TScanContext::tokenizeIdentifier()
case SWITCH:
case DEFAULT:
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 130))
if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) ||
(_parseContext.profile != EEsProfile && _parseContext.version < 130))
reservedWord();
return keyword;
@ -796,19 +774,19 @@ int TScanContext::tokenizeIdentifier()
case ATTRIBUTE:
case VARYING:
if (parseContext.profile == EEsProfile && parseContext.version >= 300)
if (_parseContext.profile == EEsProfile && _parseContext.version >= 300)
reservedWord();
return keyword;
case BUFFER:
if ((parseContext.profile == EEsProfile && parseContext.version < 310) ||
(parseContext.profile != EEsProfile && parseContext.version < 430))
if ((_parseContext.profile == EEsProfile && _parseContext.version < 310) ||
(_parseContext.profile != EEsProfile && _parseContext.version < 430))
return identifierOrType();
return keyword;
case ATOMIC_UINT:
if ((parseContext.profile == EEsProfile && parseContext.version >= 310) ||
parseContext.extensionTurnedOn(E_GL_ARB_shader_atomic_counters))
if ((_parseContext.profile == EEsProfile && _parseContext.version >= 310) ||
_parseContext.extensionTurnedOn(E_GL_ARB_shader_atomic_counters))
return keyword;
return es30ReservedFromGLSL(420);
@ -816,14 +794,14 @@ int TScanContext::tokenizeIdentifier()
case RESTRICT:
case READONLY:
case WRITEONLY:
if (parseContext.profile == EEsProfile && parseContext.version >= 310)
if (_parseContext.profile == EEsProfile && _parseContext.version >= 310)
return keyword;
return es30ReservedFromGLSL(parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store) ? 130 : 420);
return es30ReservedFromGLSL(_parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store) ? 130 : 420);
case VOLATILE:
if (parseContext.profile == EEsProfile && parseContext.version >= 310)
if (_parseContext.profile == EEsProfile && _parseContext.version >= 310)
return keyword;
if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile || (parseContext.version < 420 && ! parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
if (!_parseContext.symbolTable.atBuiltInLevel() && (_parseContext.profile == EEsProfile || (_parseContext.version < 420 && ! _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
reservedWord();
return keyword;
@ -832,28 +810,28 @@ int TScanContext::tokenizeIdentifier()
const int numLayoutExts = 2;
const char* layoutExts[numLayoutExts] = { E_GL_ARB_shading_language_420pack,
E_GL_ARB_explicit_attrib_location };
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 140 &&
! parseContext.extensionsTurnedOn(numLayoutExts, layoutExts)))
if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) ||
(_parseContext.profile != EEsProfile && _parseContext.version < 140 &&
!_parseContext.extensionsTurnedOn(numLayoutExts, layoutExts)))
return identifierOrType();
return keyword;
}
case SHARED:
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 140))
if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) ||
(_parseContext.profile != EEsProfile && _parseContext.version < 140))
return identifierOrType();
return keyword;
case PATCH:
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile == EEsProfile && parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader)) ||
(parseContext.profile != EEsProfile && parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader)))
if (_parseContext.symbolTable.atBuiltInLevel() ||
(_parseContext.profile == EEsProfile && _parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader)) ||
(_parseContext.profile != EEsProfile && _parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader)))
return keyword;
return es30ReservedFromGLSL(400);
case SAMPLE:
if (parseContext.extensionsTurnedOn(1, &E_GL_OES_shader_multisample_interpolation))
if (_parseContext.extensionsTurnedOn(1, &E_GL_OES_shader_multisample_interpolation))
return keyword;
return es30ReservedFromGLSL(400);
@ -907,7 +885,7 @@ int TScanContext::tokenizeIdentifier()
case IIMAGEBUFFER:
case UIMAGEBUFFER:
afterType = true;
if (parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer))
if (_parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer))
return keyword;
return firstGenerationImage(false);
@ -930,7 +908,7 @@ int TScanContext::tokenizeIdentifier()
case IIMAGECUBEARRAY:
case UIMAGECUBEARRAY:
afterType = true;
if (parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array))
if (_parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array))
return keyword;
return secondGenerationImage();
@ -948,7 +926,7 @@ int TScanContext::tokenizeIdentifier()
case DVEC3:
case DVEC4:
afterType = true;
if (parseContext.profile == EEsProfile || parseContext.version < 400)
if (_parseContext.profile == EEsProfile || _parseContext.version < 400)
reservedWord();
return keyword;
@ -961,9 +939,9 @@ int TScanContext::tokenizeIdentifier()
case U64VEC3:
case U64VEC4:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) &&
parseContext.profile != EEsProfile && parseContext.version >= 450))
if (_parseContext.symbolTable.atBuiltInLevel() ||
(_parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) &&
_parseContext.profile != EEsProfile && _parseContext.version >= 450))
return keyword;
return identifierOrType();
@ -997,9 +975,9 @@ int TScanContext::tokenizeIdentifier()
case ISAMPLERCUBEARRAY:
case USAMPLERCUBEARRAY:
afterType = true;
if (parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array))
if (_parseContext.extensionsTurnedOn(Num_AEP_texture_cube_map_array, AEP_texture_cube_map_array))
return keyword;
if (parseContext.profile == EEsProfile || (parseContext.version < 400 && ! parseContext.extensionTurnedOn(E_GL_ARB_texture_cube_map_array)))
if (_parseContext.profile == EEsProfile || (_parseContext.version < 400 && ! _parseContext.extensionTurnedOn(E_GL_ARB_texture_cube_map_array)))
reservedWord();
return keyword;
@ -1036,14 +1014,14 @@ int TScanContext::tokenizeIdentifier()
case SAMPLERBUFFER:
afterType = true;
if (parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer))
if (_parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer))
return keyword;
return es30ReservedFromGLSL(130);
case ISAMPLERBUFFER:
case USAMPLERBUFFER:
afterType = true;
if (parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer))
if (_parseContext.extensionsTurnedOn(Num_AEP_texture_buffer, AEP_texture_buffer))
return keyword;
return es30ReservedFromGLSL(140);
@ -1051,7 +1029,7 @@ int TScanContext::tokenizeIdentifier()
case ISAMPLER2DMS:
case USAMPLER2DMS:
afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version >= 310)
if (_parseContext.profile == EEsProfile && _parseContext.version >= 310)
return keyword;
return es30ReservedFromGLSL(150);
@ -1059,39 +1037,39 @@ int TScanContext::tokenizeIdentifier()
case ISAMPLER2DMSARRAY:
case USAMPLER2DMSARRAY:
afterType = true;
if (parseContext.extensionsTurnedOn(1, &E_GL_OES_texture_storage_multisample_2d_array))
if (_parseContext.extensionsTurnedOn(1, &E_GL_OES_texture_storage_multisample_2d_array))
return keyword;
return es30ReservedFromGLSL(150);
case SAMPLER1D:
case SAMPLER1DSHADOW:
afterType = true;
if (parseContext.profile == EEsProfile)
if (_parseContext.profile == EEsProfile)
reservedWord();
return keyword;
case SAMPLER3D:
afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version < 300) {
if (! parseContext.extensionTurnedOn(E_GL_OES_texture_3D))
if (_parseContext.profile == EEsProfile && _parseContext.version < 300) {
if (!_parseContext.extensionTurnedOn(E_GL_OES_texture_3D))
reservedWord();
}
return keyword;
case SAMPLER2DSHADOW:
afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version < 300)
if (_parseContext.profile == EEsProfile && _parseContext.version < 300)
reservedWord();
return keyword;
case SAMPLER2DRECT:
case SAMPLER2DRECTSHADOW:
afterType = true;
if (parseContext.profile == EEsProfile)
if (_parseContext.profile == EEsProfile)
reservedWord();
else if (parseContext.version < 140 && ! parseContext.symbolTable.atBuiltInLevel() && ! parseContext.extensionTurnedOn(E_GL_ARB_texture_rectangle)) {
if (parseContext.relaxedErrors())
parseContext.requireExtensions(loc, 1, &E_GL_ARB_texture_rectangle, "texture-rectangle sampler keyword");
else if (_parseContext.version < 140 && ! _parseContext.symbolTable.atBuiltInLevel() && ! _parseContext.extensionTurnedOn(E_GL_ARB_texture_rectangle)) {
if (_parseContext.relaxedErrors())
_parseContext.requireExtensions(loc, 1, &E_GL_ARB_texture_rectangle, "texture-rectangle sampler keyword");
else
reservedWord();
}
@ -1099,16 +1077,16 @@ int TScanContext::tokenizeIdentifier()
case SAMPLER1DARRAY:
afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version == 300)
if (_parseContext.profile == EEsProfile && _parseContext.version == 300)
reservedWord();
else if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 130))
else if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) ||
(_parseContext.profile != EEsProfile && _parseContext.version < 130))
return identifierOrType();
return keyword;
case SAMPLEREXTERNALOES:
afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() || parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external))
if (_parseContext.symbolTable.atBuiltInLevel() || _parseContext.extensionTurnedOn(E_GL_OES_EGL_image_external))
return keyword;
return identifierOrType();
@ -1147,7 +1125,7 @@ int TScanContext::tokenizeIdentifier()
case TEXTURE1DARRAY:
case SAMPLER:
case SAMPLERSHADOW:
if (parseContext.spvVersion.vulkan >= 100)
if (_parseContext.spvVersion.vulkan >= 100)
return keyword;
else
return identifierOrType();
@ -1158,7 +1136,7 @@ int TScanContext::tokenizeIdentifier()
case ISUBPASSINPUTMS:
case USUBPASSINPUT:
case USUBPASSINPUTMS:
if (parseContext.spvVersion.vulkan >= 100)
if (_parseContext.spvVersion.vulkan >= 100)
return keyword;
else
return identifierOrType();
@ -1167,8 +1145,8 @@ int TScanContext::tokenizeIdentifier()
return es30ReservedFromGLSL(130);
case SMOOTH:
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 130))
if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) ||
(_parseContext.profile != EEsProfile && _parseContext.version < 130))
return identifierOrType();
return keyword;
@ -1181,52 +1159,52 @@ int TScanContext::tokenizeIdentifier()
#endif
case FLAT:
if (parseContext.profile == EEsProfile && parseContext.version < 300)
if (_parseContext.profile == EEsProfile && _parseContext.version < 300)
reservedWord();
else if (parseContext.profile != EEsProfile && parseContext.version < 130)
else if (_parseContext.profile != EEsProfile && _parseContext.version < 130)
return identifierOrType();
return keyword;
case CENTROID:
if (parseContext.version < 120)
if (_parseContext.version < 120)
return identifierOrType();
return keyword;
case PRECISE:
if ((parseContext.profile == EEsProfile && parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5)) ||
(parseContext.profile != EEsProfile && parseContext.version >= 400))
if ((_parseContext.profile == EEsProfile && _parseContext.extensionsTurnedOn(Num_AEP_gpu_shader5, AEP_gpu_shader5)) ||
(_parseContext.profile != EEsProfile && _parseContext.version >= 400))
return keyword;
if (parseContext.profile == EEsProfile && parseContext.version == 310) {
if (_parseContext.profile == EEsProfile && _parseContext.version == 310) {
reservedWord();
return keyword;
}
return identifierOrType();
case INVARIANT:
if (parseContext.profile != EEsProfile && parseContext.version < 120)
if (_parseContext.profile != EEsProfile && _parseContext.version < 120)
return identifierOrType();
return keyword;
case PACKED:
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < 330))
if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) ||
(_parseContext.profile != EEsProfile && _parseContext.version < 330))
return reservedWord();
return identifierOrType();
case RESOURCE:
{
bool reserved = (parseContext.profile == EEsProfile && parseContext.version >= 300) ||
(parseContext.profile != EEsProfile && parseContext.version >= 420);
bool reserved = (_parseContext.profile == EEsProfile && _parseContext.version >= 300) ||
(_parseContext.profile != EEsProfile && _parseContext.version >= 420);
return identifierOrReserved(reserved);
}
case SUPERP:
{
bool reserved = parseContext.profile == EEsProfile || parseContext.version >= 130;
bool reserved = _parseContext.profile == EEsProfile || _parseContext.version >= 130;
return identifierOrReserved(reserved);
}
default:
parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
_parseContext.infoSink.info.message(EPrefixInternalError, "Unknown glslang keyword", loc);
return 0;
}
}
@ -1237,7 +1215,7 @@ int TScanContext::identifierOrType()
if (field)
return IDENTIFIER;
parserToken->sType.lex.symbol = parseContext.symbolTable.find(*parserToken->sType.lex.string);
parserToken->sType.lex.symbol = _parseContext.symbolTable.find(*parserToken->sType.lex.string);
if (afterType == false && parserToken->sType.lex.symbol) {
if (const TVariable* variable = parserToken->sType.lex.symbol->getAsVariable()) {
if (variable->isUserType()) {
@ -1256,8 +1234,8 @@ int TScanContext::identifierOrType()
// extension support before the extension is enabled.
int TScanContext::reservedWord()
{
if (! parseContext.symbolTable.atBuiltInLevel())
parseContext.error(loc, "Reserved word.", tokenText, "", "");
if (!_parseContext.symbolTable.atBuiltInLevel())
_parseContext.error(loc, "Reserved word.", tokenText, "", "");
return 0;
}
@ -1270,8 +1248,8 @@ int TScanContext::identifierOrReserved(bool reserved)
return 0;
}
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future reserved keyword", tokenText, "");
if (_parseContext.forwardCompatible)
_parseContext.warn(loc, "using future reserved keyword", tokenText, "");
return identifierOrType();
}
@ -1280,16 +1258,16 @@ int TScanContext::identifierOrReserved(bool reserved)
// but then got reserved by ES 3.0.
int TScanContext::es30ReservedFromGLSL(int version)
{
if (parseContext.symbolTable.atBuiltInLevel())
if (_parseContext.symbolTable.atBuiltInLevel())
return keyword;
if ((parseContext.profile == EEsProfile && parseContext.version < 300) ||
(parseContext.profile != EEsProfile && parseContext.version < version)) {
if (parseContext.forwardCompatible)
parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, "");
if ((_parseContext.profile == EEsProfile && _parseContext.version < 300) ||
(_parseContext.profile != EEsProfile && _parseContext.version < version)) {
if (_parseContext.forwardCompatible)
_parseContext.warn(loc, "future reserved word in ES 300 and keyword in GLSL", tokenText, "");
return identifierOrType();
} else if (parseContext.profile == EEsProfile && parseContext.version >= 300)
} else if (_parseContext.profile == EEsProfile && _parseContext.version >= 300)
reservedWord();
return keyword;
@ -1299,10 +1277,10 @@ int TScanContext::es30ReservedFromGLSL(int version)
// showed up, both in an es version and a non-ES version.
int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion)
{
if ((parseContext.profile == EEsProfile && parseContext.version < esVersion) ||
(parseContext.profile != EEsProfile && parseContext.version < nonEsVersion)) {
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future keyword", tokenText, "");
if ((_parseContext.profile == EEsProfile && _parseContext.version < esVersion) ||
(_parseContext.profile != EEsProfile && _parseContext.version < nonEsVersion)) {
if (_parseContext.forwardCompatible)
_parseContext.warn(loc, "using future keyword", tokenText, "");
return identifierOrType();
}
@ -1312,11 +1290,11 @@ int TScanContext::nonreservedKeyword(int esVersion, int nonEsVersion)
int TScanContext::precisionKeyword()
{
if (parseContext.profile == EEsProfile || parseContext.version >= 130)
if (_parseContext.profile == EEsProfile || _parseContext.version >= 130)
return keyword;
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using ES precision qualifier keyword", tokenText, "");
if (_parseContext.forwardCompatible)
_parseContext.warn(loc, "using ES precision qualifier keyword", tokenText, "");
return identifierOrType();
}
@ -1325,11 +1303,11 @@ int TScanContext::matNxM()
{
afterType = true;
if (parseContext.version > 110)
if (_parseContext.version > 110)
return keyword;
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future non-square matrix type keyword", tokenText, "");
if (_parseContext.forwardCompatible)
_parseContext.warn(loc, "using future non-square matrix type keyword", tokenText, "");
return identifierOrType();
}
@ -1338,55 +1316,55 @@ int TScanContext::dMat()
{
afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version >= 300) {
if (_parseContext.profile == EEsProfile && _parseContext.version >= 300) {
reservedWord();
return keyword;
}
if (parseContext.profile != EEsProfile && parseContext.version >= 400)
if (_parseContext.profile != EEsProfile && _parseContext.version >= 400)
return keyword;
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future type keyword", tokenText, "");
if (_parseContext.forwardCompatible)
_parseContext.warn(loc, "using future type keyword", tokenText, "");
return identifierOrType();
}
int TScanContext::firstGenerationImage(bool inEs310)
{
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) ||
(inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310))
if (_parseContext.symbolTable.atBuiltInLevel() ||
(_parseContext.profile != EEsProfile && (_parseContext.version >= 420 || _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) ||
(inEs310 && _parseContext.profile == EEsProfile && _parseContext.version >= 310))
return keyword;
if ((parseContext.profile == EEsProfile && parseContext.version >= 300) ||
(parseContext.profile != EEsProfile && parseContext.version >= 130)) {
if ((_parseContext.profile == EEsProfile && _parseContext.version >= 300) ||
(_parseContext.profile != EEsProfile && _parseContext.version >= 130)) {
reservedWord();
return keyword;
}
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future type keyword", tokenText, "");
if (_parseContext.forwardCompatible)
_parseContext.warn(loc, "using future type keyword", tokenText, "");
return identifierOrType();
}
int TScanContext::secondGenerationImage()
{
if (parseContext.profile == EEsProfile && parseContext.version >= 310) {
if (_parseContext.profile == EEsProfile && _parseContext.version >= 310) {
reservedWord();
return keyword;
}
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile != EEsProfile &&
(parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
if (_parseContext.symbolTable.atBuiltInLevel() ||
(_parseContext.profile != EEsProfile &&
(_parseContext.version >= 420 || _parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
return keyword;
if (parseContext.forwardCompatible)
parseContext.warn(loc, "using future type keyword", tokenText, "");
if (_parseContext.forwardCompatible)
_parseContext.warn(loc, "using future type keyword", tokenText, "");
return identifierOrType();
}

View File

@ -33,6 +33,9 @@
//POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _MACHINE_INDEPENDENT_SCAN_CONTEXT_H
#define _MACHINE_INDEPENDENT_SCAN_CONTEXT_H
//
// This holds context specific to the GLSL scanner, which
// sits between the preprocessor scanner and parser.
@ -48,7 +51,7 @@ class TParserToken;
class TScanContext {
public:
explicit TScanContext(TParseContextBase& pc) : parseContext(pc), afterType(false), field(false) { }
explicit TScanContext(TParseContextBase& pc) : _parseContext(pc), afterType(false), field(false) { }
virtual ~TScanContext() { }
static void fillInKeywordMap();
@ -72,7 +75,7 @@ protected:
int firstGenerationImage(bool inEs310);
int secondGenerationImage();
TParseContextBase& parseContext;
TParseContextBase& _parseContext;
bool afterType; // true if we've recognized a type, so can only be looking for an identifier
bool field; // true if we're on a field, right after a '.'
TSourceLoc loc;
@ -84,3 +87,5 @@ protected:
};
} // end namespace glslang
#endif

View File

@ -217,15 +217,15 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
intermediate.setSource(source);
std::unique_ptr<TParseContextBase> parseContext(CreateParseContext(symbolTable, intermediate, version, profile, source,
std::unique_ptr<TParseContextBase> _parseContext(CreateParseContext(symbolTable, intermediate, version, profile, source,
language, infoSink, spvVersion, true, EShMsgDefault,
true));
TShader::ForbidInclude includer;
TPpContext ppContext(*parseContext, "", includer);
TScanContext scanContext(*parseContext);
parseContext->setScanContext(&scanContext);
parseContext->setPpContext(&ppContext);
TPpContext ppContext(*_parseContext, "", includer);
TScanContext scanContext(*_parseContext);
_parseContext->setScanContext(&scanContext);
_parseContext->setPpContext(&ppContext);
//
// Push the symbol table to give it an initial scope. This
@ -244,7 +244,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
return true;
TInputScanner input(1, builtInShaders, builtInLengths);
if (! parseContext->parseShaderStrings(ppContext, input) != 0) {
if (!_parseContext->parseShaderStrings(ppContext, input) != 0) {
infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
printf("Unable to parse built-ins\n%s\n", infoSink.info.c_str());
printf("%s\n", builtInShaders[0]);
@ -732,32 +732,32 @@ bool ProcessDeferred(
// Now we can process the full shader under proper symbols and rules.
//
TParseContextBase* parseContext = CreateParseContext(symbolTable, intermediate, version, profile, source,
TParseContextBase *_parseContext = CreateParseContext(symbolTable, intermediate, version, profile, source,
compiler->getLanguage(), compiler->infoSink,
spvVersion, forwardCompatible, messages, false, sourceEntryPointName);
TPpContext ppContext(*parseContext, names[numPre]? names[numPre]: "", includer);
TPpContext ppContext(*_parseContext, names[numPre]? names[numPre]: "", includer);
// only GLSL (bison triggered, really) needs an externally set scan context
glslang::TScanContext scanContext(*parseContext);
glslang::TScanContext scanContext(*_parseContext);
if ((messages & EShMsgReadHlsl) == 0)
parseContext->setScanContext(&scanContext);
_parseContext->setScanContext(&scanContext);
parseContext->setPpContext(&ppContext);
parseContext->setLimits(*resources);
_parseContext->setPpContext(&ppContext);
_parseContext->setLimits(*resources);
if (! goodVersion)
parseContext->addError();
_parseContext->addError();
if (warnVersionNotFirst) {
TSourceLoc loc;
loc.init();
parseContext->warn(loc, "Illegal to have non-comment, non-whitespace tokens before #version", "#version", "");
_parseContext->warn(loc, "Illegal to have non-comment, non-whitespace tokens before #version", "#version", "");
}
parseContext->initializeExtensionBehavior();
_parseContext->initializeExtensionBehavior();
// Fill in the strings as outlined above.
std::string preamble;
parseContext->getPreamble(preamble);
_parseContext->getPreamble(preamble);
strings[0] = preamble.c_str();
lengths[0] = strlen(strings[0]);
names[0] = nullptr;
@ -776,14 +776,14 @@ bool ProcessDeferred(
// Push a new symbol allocation scope that will get used for the shader's globals.
symbolTable.push();
bool success = processingContext(*parseContext, ppContext, fullInput,
bool success = processingContext(*_parseContext, ppContext, fullInput,
versionWillBeError, symbolTable,
intermediate, optLevel, messages);
// Clean up the symbol table. The AST is self-sufficient now.
delete symbolTableMemory;
delete parseContext;
delete _parseContext;
delete [] lengths;
delete [] strings;
delete [] names;
@ -860,7 +860,7 @@ private:
// It places the result in the "string" argument to its constructor.
struct DoPreprocessing {
explicit DoPreprocessing(std::string* string): outputString(string) {}
bool operator()(TParseContextBase& parseContext, TPpContext& ppContext,
bool operator()(TParseContextBase&_parseContext, TPpContext& ppContext,
TInputScanner& input, bool versionWillBeError,
TSymbolTable&, TIntermediate&,
EShOptimizationLevel, EShMessages)
@ -870,20 +870,20 @@ struct DoPreprocessing {
static const std::string noSpaceBeforeTokens = ",";
glslang::TPpToken token;
parseContext.setScanner(&input);
_parseContext.setScanner(&input);
ppContext.setInput(input, versionWillBeError);
std::stringstream outputStream;
SourceLineSynchronizer lineSync(
std::bind(&TInputScanner::getLastValidSourceIndex, &input), &outputStream);
parseContext.setExtensionCallback([&lineSync, &outputStream](
_parseContext.setExtensionCallback([&lineSync, &outputStream](
int line, const char* extension, const char* behavior) {
lineSync.syncToLine(line);
outputStream << "#extension " << extension << " : " << behavior;
});
parseContext.setLineCallback([&lineSync, &outputStream, &parseContext](
_parseContext.setLineCallback([&lineSync, &outputStream, &_parseContext](
int curLineNum, int newLineNum, bool hasSource, int sourceNum, const char* sourceName) {
// SourceNum is the number of the source-string that is being parsed.
lineSync.syncToLine(curLineNum);
@ -896,7 +896,7 @@ struct DoPreprocessing {
outputStream << sourceNum;
}
}
if (parseContext.lineDirectiveShouldSetNextLine()) {
if (_parseContext.lineDirectiveShouldSetNextLine()) {
// newLineNum is the new line number for the line following the #line
// directive. So the new line number for the current line is
newLineNum -= 1;
@ -906,7 +906,7 @@ struct DoPreprocessing {
lineSync.setLineNum(newLineNum + 1);
});
parseContext.setVersionCallback(
_parseContext.setVersionCallback(
[&lineSync, &outputStream](int line, int version, const char* str) {
lineSync.syncToLine(line);
outputStream << "#version " << version;
@ -915,7 +915,7 @@ struct DoPreprocessing {
}
});
parseContext.setPragmaCallback([&lineSync, &outputStream](
_parseContext.setPragmaCallback([&lineSync, &outputStream](
int line, const glslang::TVector<glslang::TString>& ops) {
lineSync.syncToLine(line);
outputStream << "#pragma ";
@ -924,7 +924,7 @@ struct DoPreprocessing {
}
});
parseContext.setErrorCallback([&lineSync, &outputStream](
_parseContext.setErrorCallback([&lineSync, &outputStream](
int line, const char* errorMessage) {
lineSync.syncToLine(line);
outputStream << "#error " << errorMessage;
@ -958,10 +958,10 @@ struct DoPreprocessing {
*outputString = outputStream.str();
bool success = true;
if (parseContext.getNumErrors() > 0) {
if (_parseContext.getNumErrors() > 0) {
success = false;
parseContext.infoSink.info.prefix(EPrefixError);
parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n";
_parseContext.infoSink.info.prefix(EPrefixError);
_parseContext.infoSink.info << _parseContext.getNumErrors() << " compilation errors. No code generated.\n\n";
}
return success;
}
@ -971,28 +971,28 @@ struct DoPreprocessing {
// DoFullParse is a valid ProcessingConext template argument for fully
// parsing the shader. It populates the "intermediate" with the AST.
struct DoFullParse{
bool operator()(TParseContextBase& parseContext, TPpContext& ppContext,
bool operator()(TParseContextBase&_parseContext, TPpContext& ppContext,
TInputScanner& fullInput, bool versionWillBeError,
TSymbolTable&, TIntermediate& intermediate,
EShOptimizationLevel optLevel, EShMessages messages)
{
bool success = true;
// Parse the full shader.
if (! parseContext.parseShaderStrings(ppContext, fullInput, versionWillBeError))
if (!_parseContext.parseShaderStrings(ppContext, fullInput, versionWillBeError))
success = false;
if (success && intermediate.getTreeRoot()) {
if (optLevel == EShOptNoGeneration)
parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested.");
_parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested.");
else
success = intermediate.postProcess(intermediate.getTreeRoot(), parseContext.getLanguage());
success = intermediate.postProcess(intermediate.getTreeRoot(), _parseContext.getLanguage());
} else if (! success) {
parseContext.infoSink.info.prefix(EPrefixError);
parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n";
_parseContext.infoSink.info.prefix(EPrefixError);
_parseContext.infoSink.info << _parseContext.getNumErrors() << " compilation errors. No code generated.\n\n";
}
if (messages & EShMsgAST)
intermediate.output(parseContext.infoSink, true);
intermediate.output(_parseContext.infoSink, true);
return success;
}

View File

@ -0,0 +1,32 @@
#ifndef _MACHINE_INDEPENDENT_COMPARE_H
#define _MACHINE_INDEPENDENT_COMPARE_H
#include "../../../hlsl/hlslTokens.h"
namespace {
struct str_eq
{
bool operator()(const char* lhs, const char* rhs) const
{
return strcmp(lhs, rhs) == 0;
}
};
struct str_hash
{
size_t operator()(const char* str) const
{
// djb2
unsigned long hash = 5381;
int c;
while ((c = *str++) != 0)
hash = ((hash << 5) + hash) + c;
return hash;
}
};
};
#endif

Some files were not shown because too many files have changed in this diff Show More