Commit 4d43189e authored by Niklas Haas's avatar Niklas Haas

spirv: get rid of locale hacks

This was fixed upstream in https://github.com/KhronosGroup/glslang/pull/1385
parent b94421ac
......@@ -16,13 +16,6 @@
*/
#include <stdlib.h>
#include <locale.h>
#ifdef __APPLE__
# include <string.h>
# include <xlocale.h>
#endif
#include <shaderc/shaderc.h>
#include "spirv.h"
......@@ -30,10 +23,6 @@
struct priv {
shaderc_compiler_t compiler;
shaderc_compile_options_t opts;
#ifndef _WIN32
locale_t cloc;
#endif
};
static void shaderc_uninit(struct spirv_compiler *spirv)
......@@ -41,9 +30,6 @@ static void shaderc_uninit(struct spirv_compiler *spirv)
struct priv *p = spirv->priv;
shaderc_compile_options_release(p->opts);
shaderc_compiler_release(p->compiler);
#ifndef _WIN32
freelocale(p->cloc);
#endif
TA_FREEP(&spirv->priv);
}
......@@ -51,14 +37,6 @@ static bool shaderc_init(struct spirv_compiler *spirv)
{
struct priv *p = spirv->priv = talloc_zero(spirv, struct priv);
#ifndef _WIN32
p->cloc = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0);
if (!p->cloc) {
PL_FATAL(spirv, "Failed initializing C locale?!");
goto error;
}
#endif
p->compiler = shaderc_compiler_initialize();
if (!p->compiler)
goto error;
......@@ -109,18 +87,6 @@ static bool shaderc_compile(struct spirv_compiler *spirv, void *tactx,
{
struct priv *p = spirv->priv;
// Switch to C locale to work around libshaderc bugs
#ifndef _WIN32
locale_t oldloc = uselocale((locale_t) 0);
uselocale(p->cloc);
#else
int oldthread = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
wchar_t *oldloc = _wcsdup(_wsetlocale(LC_NUMERIC, NULL));
_wsetlocale(LC_NUMERIC, L"C");
if (!oldloc)
abort();
#endif
shaderc_compilation_result_t res = compile(p, type, glsl, false);
int errs = shaderc_result_get_num_errors(res),
warn = shaderc_result_get_num_warnings(res);
......@@ -166,13 +132,6 @@ static bool shaderc_compile(struct spirv_compiler *spirv, void *tactx,
}
shaderc_result_release(res);
#ifndef _WIN32
uselocale(oldloc);
#else
_wsetlocale(LC_NUMERIC, oldloc);
_configthreadlocale(oldthread);
free(oldloc);
#endif
return success;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment