static bool hlsl_load_plain(hlsl_shader_data_t *hlsl, void *data, const char *path) { if (!hlsl_load_stock(hlsl, data)) return false; hlsl->cg_shader = (struct video_shader*)calloc(1, sizeof(*hlsl->cg_shader)); if (!hlsl->cg_shader) return false; hlsl->cg_shader->passes = 1; if (!string_is_empty(path)) { struct shader_program_info program_info; program_info.combined = path; program_info.is_file = true; RARCH_LOG("Loading Cg/HLSL file: %s\n", path); strlcpy(hlsl->cg_shader->pass[0].source.path, path, sizeof(hlsl->cg_shader->pass[0].source.path)); hlsl->d3d = (d3d_video_t*)data; if (!hlsl_compile_program(hlsl, 1, &hlsl->prg[1], &program_info)) return false; } else { RARCH_LOG("Loading stock Cg/HLSL file.\n"); hlsl->prg[1] = hlsl->prg[0]; } return true; }
static bool hlsl_load_stock(hlsl_shader_data_t *hlsl, void *data) { struct shader_program_info program_info; program_info.combined = stock_hlsl_program; program_info.is_file = false; hlsl->d3d = (d3d_video_t*)data; if (!hlsl_compile_program(hlsl, 0, &hlsl->prg[0], &program_info)) { RARCH_ERR("Failed to compile passthrough shader, is something wrong with your environment?\n"); return false; } return true; }
static bool hlsl_load_shader(hlsl_shader_data_t *hlsl, void *data, const char *cgp_path, unsigned i) { struct shader_program_info program_info; char path_buf[PATH_MAX_LENGTH] = {0}; program_info.combined = path_buf; program_info.is_file = true; fill_pathname_resolve_relative(path_buf, cgp_path, hlsl->cg_shader->pass[i].source.path, sizeof(path_buf)); RARCH_LOG("Loading Cg/HLSL shader: \"%s\".\n", path_buf); hlsl->d3d = (d3d_video_t*)data; if (!hlsl_compile_program(hlsl, data, i + 1, &hlsl->prg[i + 1], &program_info)) return false; return true; }