use strl functions

This commit is contained in:
Brad Parker 2018-08-16 13:35:04 -04:00
parent d3c6fc1601
commit 12539f310d
3 changed files with 18 additions and 28 deletions

View File

@ -393,20 +393,17 @@ static bool d3d10_gfx_set_shader(void* data,
#endif
static const char vs_ext[] = ".vs.hlsl";
static const char ps_ext[] = ".ps.hlsl";
char vs_path[PATH_MAX_LENGTH];
char ps_path[PATH_MAX_LENGTH];
char vs_path[PATH_MAX_LENGTH] = {0};
char ps_path[PATH_MAX_LENGTH] = {0};
const char* slang_path = d3d10->shader_preset->pass[i].source.path;
const char* vs_src = d3d10->shader_preset->pass[i].source.string.vertex;
const char* ps_src = d3d10->shader_preset->pass[i].source.string.fragment;
int base_len = strlen(slang_path) - strlen(".slang");
if (base_len <= 0)
base_len = strlen(slang_path);
strncpy(vs_path, slang_path, base_len);
strncpy(ps_path, slang_path, base_len);
strncpy(vs_path + base_len, vs_ext, sizeof(vs_ext));
strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext));
strlcpy(vs_path, slang_path, sizeof(vs_path));
strlcpy(ps_path, slang_path, sizeof(ps_path));
strlcat(vs_path, vs_ext, sizeof(vs_path));
strlcat(ps_path, ps_ext, sizeof(ps_path));
if (!d3d10_init_shader(
d3d10->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc),

View File

@ -407,20 +407,16 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const
#endif
static const char vs_ext[] = ".vs.hlsl";
static const char ps_ext[] = ".ps.hlsl";
char vs_path[PATH_MAX_LENGTH];
char ps_path[PATH_MAX_LENGTH];
char vs_path[PATH_MAX_LENGTH] = {0};
char ps_path[PATH_MAX_LENGTH] = {0};
const char* slang_path = d3d11->shader_preset->pass[i].source.path;
const char* vs_src = d3d11->shader_preset->pass[i].source.string.vertex;
const char* ps_src = d3d11->shader_preset->pass[i].source.string.fragment;
int base_len = strlen(slang_path) - strlen(".slang");
if (base_len <= 0)
base_len = strlen(slang_path);
strncpy(vs_path, slang_path, base_len);
strncpy(ps_path, slang_path, base_len);
strncpy(vs_path + base_len, vs_ext, sizeof(vs_ext));
strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext));
strlcpy(vs_path, slang_path, sizeof(vs_path));
strlcpy(ps_path, slang_path, sizeof(ps_path));
strlcat(vs_path, vs_ext, sizeof(vs_path));
strlcat(ps_path, ps_ext, sizeof(ps_path));
if (!d3d11_init_shader(
d3d11->device, vs_src, 0, vs_path, "main", NULL, NULL, desc, countof(desc),

View File

@ -420,20 +420,17 @@ static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const
#endif
static const char vs_ext[] = ".vs.hlsl";
static const char ps_ext[] = ".ps.hlsl";
char vs_path[PATH_MAX_LENGTH];
char ps_path[PATH_MAX_LENGTH];
char vs_path[PATH_MAX_LENGTH] = {0};
char ps_path[PATH_MAX_LENGTH] = {0};
const char* slang_path = d3d12->shader_preset->pass[i].source.path;
const char* vs_src = d3d12->shader_preset->pass[i].source.string.vertex;
const char* ps_src = d3d12->shader_preset->pass[i].source.string.fragment;
int base_len = strlen(slang_path) - strlen(".slang");
if (base_len <= 0)
base_len = strlen(slang_path);
strncpy(vs_path, slang_path, base_len);
strncpy(ps_path, slang_path, base_len);
strncpy(vs_path + base_len, vs_ext, sizeof(vs_ext));
strncpy(ps_path + base_len, ps_ext, sizeof(ps_ext));
strlcpy(vs_path, slang_path, sizeof(vs_path));
strlcpy(ps_path, slang_path, sizeof(ps_path));
strlcat(vs_path, vs_ext, sizeof(vs_path));
strlcat(ps_path, ps_ext, sizeof(ps_path));
if (!d3d_compile(vs_src, 0, vs_path, "main", "vs_5_0", &vs_code))
save_hlsl = true;