Revert "Don't attempt to use std::string anymore in gfx/d3d/d3d.cpp"

This reverts commit f76b7f2b60.
This commit is contained in:
twinaphex 2016-01-09 03:06:18 +01:00
parent 14950cefc2
commit 7a55c2b8eb
2 changed files with 12 additions and 13 deletions

View File

@ -1084,7 +1084,7 @@ static bool d3d_init_multipass(d3d_video_t *d3d)
unsigned i; unsigned i;
bool use_extra_pass; bool use_extra_pass;
video_shader_pass *pass = NULL; video_shader_pass *pass = NULL;
config_file_t *conf = config_file_new(d3d->shader_path); config_file_t *conf = config_file_new(d3d->shader_path.c_str());
if (!conf) if (!conf)
{ {
@ -1103,7 +1103,7 @@ static bool d3d_init_multipass(d3d_video_t *d3d)
config_file_free(conf); config_file_free(conf);
video_shader_resolve_relative(&d3d->shader, d3d->shader_path); video_shader_resolve_relative(&d3d->shader, d3d->shader_path.c_str());
RARCH_LOG("[D3D9 Meta-Cg] Found %u shaders.\n", d3d->shader.passes); RARCH_LOG("[D3D9 Meta-Cg] Found %u shaders.\n", d3d->shader.passes);
@ -1162,7 +1162,7 @@ static bool d3d_init_singlepass(d3d_video_t *d3d)
pass->fbo.type_y = RARCH_SCALE_VIEWPORT; pass->fbo.type_y = RARCH_SCALE_VIEWPORT;
pass->fbo.scale_x = pass->fbo.scale_y; pass->fbo.scale_x = pass->fbo.scale_y;
pass->fbo.type_x = pass->fbo.type_y; pass->fbo.type_x = pass->fbo.type_y;
strlcpy(pass->source.path, d3d->shader_path, strlcpy(pass->source.path, d3d->shader_path.c_str(),
sizeof(pass->source.path)); sizeof(pass->source.path));
#endif #endif
@ -1172,7 +1172,8 @@ static bool d3d_init_singlepass(d3d_video_t *d3d)
static bool d3d_process_shader(d3d_video_t *d3d) static bool d3d_process_shader(d3d_video_t *d3d)
{ {
#ifdef HAVE_FBO #ifdef HAVE_FBO
if (strcmp(path_get_extension(d3d->shader_path), "cgp") == 0) if (strcmp(path_get_extension(
d3d->shader_path.c_str()), "cgp") == 0)
return d3d_init_multipass(d3d); return d3d_init_multipass(d3d);
#endif #endif
@ -1597,14 +1598,13 @@ static bool d3d_set_shader(void *data,
{ {
bool restore_old = false; bool restore_old = false;
d3d_video_t *d3d = (d3d_video_t*)data; d3d_video_t *d3d = (d3d_video_t*)data;
char old_shader[PATH_MAX_LENGTH]; std::string shader = "";
char shader[PATH_MAX_LENGTH];
switch (type) switch (type)
{ {
case RARCH_SHADER_CG: case RARCH_SHADER_CG:
if (path) if (path)
strlcpy(shader, path, sizeof(shader)); shader = path;
#ifdef HAVE_HLSL #ifdef HAVE_HLSL
d3d->shader = &hlsl_backend; d3d->shader = &hlsl_backend;
#endif #endif
@ -1613,8 +1613,8 @@ static bool d3d_set_shader(void *data,
break; break;
} }
strlcpy(old_shader, d3d->shader_path, sizeof(old_shader)); std::string old_shader = d3d->shader_path;
strlcpy(d3d->shader_path, shader, sizeof(d3d->shader_path)); d3d->shader_path = shader;
if (!d3d_process_shader(d3d) || !d3d_restore(d3d)) if (!d3d_process_shader(d3d) || !d3d_restore(d3d))
{ {
@ -1624,7 +1624,7 @@ static bool d3d_set_shader(void *data,
if (restore_old) if (restore_old)
{ {
strlcpy(d3d->shader_path, old_shader, sizeof(d3d->shader_path)); d3d->shader_path = old_shader;
d3d_process_shader(d3d); d3d_process_shader(d3d);
d3d_restore(d3d); d3d_restore(d3d);
} }

View File

@ -17,10 +17,9 @@
#ifndef __D3DVIDEO_INTF_H__ #ifndef __D3DVIDEO_INTF_H__
#define __D3DVIDEO_INTF_H__ #define __D3DVIDEO_INTF_H__
#include <string>
#include <vector> #include <vector>
#include <retro_miscellaneous.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../../config.h" #include "../../config.h"
#endif #endif
@ -100,7 +99,7 @@ typedef struct d3d_video
unsigned dev_rotation; unsigned dev_rotation;
D3DVIEWPORT final_viewport; D3DVIEWPORT final_viewport;
char shader_path[PATH_MAX_LENGTH]; std::string shader_path;
struct video_shader shader; struct video_shader shader;
video_info_t video_info; video_info_t video_info;