Skip to content

Commit 79eaf02

Browse files
committed
Resync
1 parent ef8eb61 commit 79eaf02

4 files changed

Lines changed: 184 additions & 25 deletions

File tree

audio/conversion/float_to_s16.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void convert_float_to_s16(int16_t *out,
8585

8686
void convert_float_to_s16_init_simd(void)
8787
{
88-
unsigned cpu = cpu_features_get();
88+
uint64_t cpu = cpu_features_get();
8989

9090
if (cpu & RETRO_SIMD_NEON)
9191
float_to_s16_neon_enabled = true;

audio/conversion/s16_to_float.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void convert_s16_to_float(float *out,
8484

8585
void convert_s16_to_float_init_simd(void)
8686
{
87-
unsigned cpu = cpu_features_get();
87+
uint64_t cpu = cpu_features_get();
8888

8989
if (cpu & RETRO_SIMD_NEON)
9090
s16_to_float_neon_enabled = true;

include/retro_math.h

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,100 @@ static INLINE uint32_t prev_pow2(uint32_t v)
9191
return v - (v >> 1);
9292
}
9393

94+
/**
95+
* clamp:
96+
* @v : initial value
97+
*
98+
* Get the clamped value based on initial value.
99+
*
100+
* Returns: clamped value (derived from @v).
101+
**/
102+
static INLINE float clamp_value(float v, float min, float max)
103+
{
104+
return v <= min ? min : v >= max ? max : v;
105+
}
106+
107+
/**
108+
* saturate_value:
109+
* @v : initial value
110+
*
111+
* Get the clamped 0.0-1.0 value based on initial value.
112+
*
113+
* Returns: clamped 0.0-1.0 value (derived from @v).
114+
**/
115+
static INLINE float saturate_value(float v)
116+
{
117+
return clamp_value(v, 0.0f, 1.0f);
118+
}
119+
120+
/**
121+
* dot_product:
122+
* @a : left hand vector value
123+
* @b : right hand vector value
124+
*
125+
* Get the dot product of the two passed in vectors.
126+
*
127+
* Returns: dot product value (derived from @a and @b).
128+
**/
129+
static INLINE float dot_product(const float* a, const float* b)
130+
{
131+
return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]);
132+
}
133+
134+
/**
135+
* convert_rgb_to_yxy:
136+
* @rgb : in RGB colour space value
137+
* @Yxy : out Yxy colour space value
138+
*
139+
* Convert from RGB colour space to Yxy colour space.
140+
*
141+
* Returns: Yxy colour space value (derived from @rgb).
142+
**/
143+
static INLINE void convert_rgb_to_yxy(const float* rgb, float* Yxy)
144+
{
145+
float inv;
146+
float xyz[3];
147+
float one[3] = {1.0, 1.0, 1.0};
148+
float rgb_xyz[3][3] = {
149+
{0.4124564, 0.3575761, 0.1804375},
150+
{0.2126729, 0.7151522, 0.0721750},
151+
{0.0193339, 0.1191920, 0.9503041}
152+
};
153+
154+
xyz[0] = dot_product(rgb_xyz[0], rgb);
155+
xyz[1] = dot_product(rgb_xyz[1], rgb);
156+
xyz[2] = dot_product(rgb_xyz[2], rgb);
157+
158+
inv = 1.0f / dot_product(xyz, one);
159+
Yxy[0] = xyz[1];
160+
Yxy[1] = xyz[0] * inv;
161+
Yxy[2] = xyz[1] * inv;
162+
}
163+
164+
/**
165+
* convert_yxy_to_rgb:
166+
* @rgb : in Yxy colour space value
167+
* @Yxy : out rgb colour space value
168+
*
169+
* Convert from Yxy colour space to rgb colour space.
170+
*
171+
* Returns: rgb colour space value (derived from @Yxy).
172+
**/
173+
static INLINE void convert_yxy_to_rgb(const float* Yxy, float* rgb)
174+
{
175+
float xyz[3];
176+
float xyz_rgb[3][3] = {
177+
{3.2404542, -1.5371385, -0.4985314},
178+
{-0.9692660, 1.8760108, 0.0415560},
179+
{0.0556434, -0.2040259, 1.0572252}
180+
};
181+
xyz[0] = Yxy[0] * Yxy[1] / Yxy[2];
182+
xyz[1] = Yxy[0];
183+
xyz[2] = Yxy[0] * (1.0 - Yxy[1] - Yxy[2]) / Yxy[2];
184+
185+
rgb[0] = dot_product(xyz_rgb[0], xyz);
186+
rgb[1] = dot_product(xyz_rgb[1], xyz);
187+
rgb[2] = dot_product(xyz_rgb[2], xyz);
188+
}
189+
94190
#endif

vfs/vfs_implementation_uwp.cpp

Lines changed: 86 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ namespace
177177
}
178178
catch (Platform::AccessDeniedException^ e)
179179
{
180-
Windows::UI::Popups::MessageDialog^ dialog =
181-
ref new Windows::UI::Popups::MessageDialog("Path \"" + path + "\" is not currently accessible. Please open any containing directory to access it.");
180+
//for some reason the path is inaccessible from within here???
181+
Windows::UI::Popups::MessageDialog^ dialog = ref new Windows::UI::Popups::MessageDialog("Path is not currently accessible. Please open any containing directory to access it.");
182182
dialog->Commands->Append(ref new Windows::UI::Popups::UICommand("Open file picker"));
183183
dialog->Commands->Append(ref new Windows::UI::Popups::UICommand("Cancel"));
184184
return concurrency::create_task(dialog->ShowAsync()).then([path](Windows::UI::Popups::IUICommand^ cmd) {
185185
if (cmd->Label == "Open file picker")
186186
{
187187
return TriggerPickerAddDialog().then([path](Platform::String^ added_path) {
188-
/* Retry */
188+
// Retry
189189
return LocateStorageItem<T>(path);
190190
});
191191
}
@@ -403,7 +403,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
403403
creationDisposition = (mode & RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING) != 0 ?
404404
OPEN_ALWAYS : CREATE_ALWAYS;
405405
}
406-
406+
path_str = "\\\\?\\" + path_str;
407407
file_handle = CreateFile2FromAppW(path_str->Data(), desireAccess, FILE_SHARE_READ, creationDisposition, NULL);
408408

409409
if (file_handle != INVALID_HANDLE_VALUE)
@@ -991,7 +991,7 @@ int uwp_move_path(std::filesystem::path old_path, std::filesystem::path new_path
991991
bool fail = false;
992992
do
993993
{
994-
if (findDataResult.cFileName != L"." && findDataResult.cFileName != L"..")
994+
if (wcscmp(findDataResult.cFileName, L".") != 0 && wcscmp(findDataResult.cFileName, L"..") != 0)
995995
{
996996
std::filesystem::path temp_old = old_path;
997997
std::filesystem::path temp_new = new_path;
@@ -1113,30 +1113,93 @@ struct libretro_vfs_implementation_dir
11131113
char *entry_name;
11141114
};
11151115

1116-
libretro_vfs_implementation_dir *retro_vfs_opendir_impl(const char *name, bool include_hidden)
1116+
libretro_vfs_implementation_dir* retro_vfs_opendir_impl(const char* name, bool include_hidden)
11171117
{
1118-
wchar_t *name_wide;
1119-
Platform::String^ name_str;
1120-
libretro_vfs_implementation_dir *rdir;
1118+
wchar_t* name_wide;
1119+
Platform::String^ name_str;
1120+
libretro_vfs_implementation_dir* rdir;
11211121

1122-
if (!name || !*name)
1123-
return NULL;
1122+
if (!name || !*name)
1123+
return NULL;
11241124

1125-
rdir = (libretro_vfs_implementation_dir*)calloc(1, sizeof(*rdir));
1126-
if (!rdir)
1127-
return NULL;
1125+
rdir = (libretro_vfs_implementation_dir*)calloc(1, sizeof(*rdir));
1126+
if (!rdir)
1127+
return NULL;
11281128

1129-
name_wide = utf8_to_utf16_string_alloc(name);
1130-
windowsize_path(name_wide);
1131-
name_str = ref new Platform::String(name_wide);
1132-
free(name_wide);
1129+
name_wide = utf8_to_utf16_string_alloc(name);
1130+
windowsize_path(name_wide);
1131+
name_str = ref new Platform::String(name_wide);
1132+
free(name_wide);
11331133

1134-
rdir->directory = RunAsyncAndCatchErrors<IVectorView<IStorageItem^>^>([&]() {
1135-
return concurrency::create_task(LocateStorageItem<StorageFolder>(name_str)).then([&](StorageFolder^ folder) {
1136-
return folder->GetItemsAsync();
1137-
});
1138-
}, nullptr);
11391134

1135+
WIN32_FILE_ATTRIBUTE_DATA lpFileInfo;
1136+
std::filesystem::path dir(name);
1137+
1138+
if (dir.empty())
1139+
return NULL;
1140+
1141+
if (!(rdir->directory))
1142+
{
1143+
//check if file attributes can be gotten successfully
1144+
if (GetFileAttributesExFromAppW(dir.parent_path().wstring().c_str(), GetFileExInfoStandard, &lpFileInfo))
1145+
{
1146+
//check that the files attributes are not null or empty
1147+
if (lpFileInfo.dwFileAttributes != INVALID_FILE_ATTRIBUTES && lpFileInfo.dwFileAttributes != 0)
1148+
{
1149+
if (lpFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1150+
{
1151+
std::wstring filteredPath(dir.wstring().c_str());
1152+
WIN32_FIND_DATA findDataResult;
1153+
if (filteredPath[filteredPath.size() - 1] == '\\')
1154+
filteredPath.erase(filteredPath.size() - 1);
1155+
filteredPath += L"\\*.*";
1156+
HANDLE searchResults = FindFirstFileExFromAppW(filteredPath.c_str(), FindExInfoBasic, &findDataResult, FindExSearchNameMatch, nullptr, FIND_FIRST_EX_LARGE_FETCH);
1157+
if (searchResults != INVALID_HANDLE_VALUE)
1158+
{
1159+
Platform::Collections::Vector<IStorageItem^>^ result = ref new Platform::Collections::Vector<IStorageItem^>();
1160+
do
1161+
{
1162+
if (wcscmp(findDataResult.cFileName, L".") != 0 && wcscmp(findDataResult.cFileName, L"..") != 0)
1163+
{
1164+
if (!((findDataResult.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) || (findDataResult.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)))
1165+
{
1166+
std::filesystem::path temp_new = dir;
1167+
temp_new /= findDataResult.cFileName;
1168+
1169+
std::wstring temp_path = temp_new.generic_wstring();
1170+
while (true) {
1171+
size_t p = temp_path.find(L"/");
1172+
if (p == std::wstring::npos) break;
1173+
temp_path.replace(p, 1, L"\\");
1174+
}
1175+
IStorageItem^ item;
1176+
if (findDataResult.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1177+
{
1178+
item = RunAsyncAndCatchErrors<StorageFolder^>([&]() {
1179+
return concurrency::create_task(LocateStorageItem<StorageFolder>(ref new Platform::String(temp_path.c_str())));
1180+
}, nullptr);
1181+
}
1182+
else
1183+
{
1184+
item = RunAsyncAndCatchErrors<StorageFile^>([&]() {
1185+
return concurrency::create_task(LocateStorageItem<StorageFile>(ref new Platform::String(temp_path.c_str())));
1186+
}, nullptr);
1187+
}
1188+
1189+
if (item)
1190+
if (result)
1191+
result->Append(item);
1192+
}
1193+
}
1194+
} while (FindNextFile(searchResults, &findDataResult));
1195+
FindClose(searchResults);
1196+
if (result)
1197+
rdir->directory = result->GetView();
1198+
}
1199+
}
1200+
}
1201+
}
1202+
}
11401203
if (rdir->directory)
11411204
return rdir;
11421205

0 commit comments

Comments
 (0)