static bool hlsl_init(const char *path) { xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; if (path && strcmp(path_get_extension(path), ".cgp") == 0) { if (!load_preset(path)) return false; } else { if (!load_plain(path)) return false; } for(unsigned i = 1; i <= cg_shader->passes; i++) set_program_attributes(i); d3d_device_ptr = d3d->d3d_render_device; d3d->d3d_render_device->SetVertexShader(prg[1].vprg); d3d->d3d_render_device->SetPixelShader(prg[1].fprg); hlsl_active = true; return true; }
size_t FindDetectorsPar::loadParFile(const std::string &fileName){ // load ASCII par or phx file std::ifstream dataStream; std::vector<double> result; this->current_ASCII_file = get_ASCII_header(fileName,dataStream); load_plain(dataStream,result,current_ASCII_file); m_nDetectors = current_ASCII_file.nData_records; dataStream.close(); // transfer par data into internal algorithm parameters; azimuthal.resize(m_nDetectors); polar.resize(m_nDetectors); detID.resize(m_nDetectors); int Block_size,shift; if(current_ASCII_file.Type==PAR_type) { m_SizesAreLinear = true; Block_size = 5; // this value coinside with the value defined in load_plain shift = 0; azimuthalWidth.resize(m_nDetectors); polarWidth.resize(m_nDetectors); secondaryFlightpath.resize(m_nDetectors,std::numeric_limits<double>::quiet_NaN()); for(size_t i=0;i<m_nDetectors;i++){ azimuthal[i] = result[shift+2+i*Block_size]; polar[i] = result[shift+1+i*Block_size]; azimuthalWidth[i] =-result[shift+3+i*Block_size]; polarWidth[i] = result[shift+4+i*Block_size]; secondaryFlightpath[i] = result[shift+0+i*Block_size]; detID[i] = i+1; } }else if(current_ASCII_file.Type==PHX_type) { m_SizesAreLinear = false; Block_size = 6; // this value coinside with the value defined in load_plain shift = 1; azimuthalWidth.resize(m_nDetectors); polarWidth.resize(m_nDetectors); for(size_t i=0;i<m_nDetectors;i++) { azimuthal[i] =result[shift+2+i*Block_size]; polar[i] =result[shift+1+i*Block_size]; azimuthalWidth[i] =result[shift+4+i*Block_size]; polarWidth[i] =result[shift+3+i*Block_size]; detID[i] =i+1; } }else{ g_log.error()<<" unsupported type of ASCII parameter file: "<<fileName<<std::endl; throw(std::invalid_argument("unsupported ASCII file type")); } return m_nDetectors; }
bool hlsl_init(const char *path, IDirect3DDevice9 * device_ptr) { if (!device_ptr) return false; d3d_device_ptr = device_ptr; if (strstr(path, ".cgp")) { if (!load_preset(path)) return false; } else { if (!load_plain(path)) return false; } set_program_attributes(0); active_index = 0; hlsl_active = true; return true; }
static bool hlsl_init(void *data, const char *path) { d3d_video_t *d3d = (d3d_video_t*)data; if (path && strcmp(path_get_extension(path), ".cgp") == 0) { if (!load_preset(d3d, path)) return false; } else { if (!load_plain(d3d, path)) return false; } for(unsigned i = 1; i <= cg_shader->passes; i++) set_program_attributes(i); d3d->dev->SetVertexShader(prg[1].vprg); d3d->dev->SetPixelShader(prg[1].fprg); hlsl_active = true; return true; }
static bool hlsl_init(void *data, const char *path) { d3d_video_t *d3d = (d3d_video_t*)data; hlsl_shader_data_t *hlsl = (hlsl_shader_data_t*) calloc(1, sizeof(hlsl_shader_data_t)); driver_t *driver = driver_get_ptr(); if (!hlsl) return false; if (path && !strcmp(path_get_extension(path), ".cgp")) { if (!load_preset(hlsl, d3d, path)) goto error; } else { if (!load_plain(hlsl, d3d, path)) goto error; } for(unsigned i = 1; i <= hlsl->cg_shader->passes; i++) set_program_attributes(hlsl, i); d3d_set_vertex_shader(d3d->dev, 1, hlsl->prg[1].vprg); d3d->dev->SetPixelShader(hlsl->prg[1].fprg); driver->video_shader_data = hlsl; return true; error: if (hlsl) free(hlsl); return false; }
static bool gl_cg_init(const char *path) { unsigned i; #ifdef HAVE_CG_RUNTIME_COMPILER cgRTCgcInit(); #endif if (!cgCtx) cgCtx = cgCreateContext(); if (cgCtx == NULL) { RARCH_ERR("Failed to create Cg context\n"); return false; } #ifdef RARCH_CG_DEBUG cgGLSetDebugMode(CG_TRUE); cgSetErrorHandler(cg_error_handler, NULL); #endif cgFProf = cgGLGetLatestProfile(CG_GL_FRAGMENT); cgVProf = cgGLGetLatestProfile(CG_GL_VERTEX); if (cgFProf == CG_PROFILE_UNKNOWN || cgVProf == CG_PROFILE_UNKNOWN) { RARCH_ERR("Invalid profile type\n"); goto error; } #ifndef HAVE_RGL RARCH_LOG("[Cg]: Vertex profile: %s\n", cgGetProfileString(cgVProf)); RARCH_LOG("[Cg]: Fragment profile: %s\n", cgGetProfileString(cgFProf)); #endif cgGLSetOptimalOptions(cgFProf); cgGLSetOptimalOptions(cgVProf); cgGLEnableProfile(cgFProf); cgGLEnableProfile(cgVProf); if (path && strcmp(path_get_extension(path), "cgp") == 0) { if (!load_preset(path)) goto error; } else { if (!load_plain(path)) goto error; } prg[0].mvp = cgGetNamedParameter(prg[0].vprg, "IN.mvp_matrix"); for (i = 1; i <= cg_shader->passes; i++) set_program_attributes(i); // If we aren't using last pass non-FBO shader, // this shader will be assumed to be "fixed-function". // Just use prg[0] for that pass, which will be // pass-through. prg[cg_shader->passes + 1] = prg[0]; // No need to apply Android hack in Cg. prg[GL_SHADER_STOCK_BLEND] = prg[0]; cgGLBindProgram(prg[1].fprg); cgGLBindProgram(prg[1].vprg); cg_active = true; return true; error: gl_cg_deinit(); return false; }
static bool gl_cg_init(void *data, const char *path) { cg_shader_data_t *cg = NULL; driver_t *driver = NULL; unsigned i; (void)data; cg = (cg_shader_data_t*)calloc(1, sizeof(cg_shader_data_t)); driver = driver_get_ptr(); if (!cg) return false; #ifdef HAVE_CG_RUNTIME_COMPILER cgRTCgcInit(); #endif cg->cgCtx = cgCreateContext(); if (!cg->cgCtx) { RARCH_ERR("Failed to create Cg context\n"); free(cg); return false; } #ifdef RARCH_CG_DEBUG cgGLSetDebugMode(CG_TRUE); cgSetErrorHandler(cg_error_handler, NULL); #endif cg->cgFProf = cgGLGetLatestProfile(CG_GL_FRAGMENT); cg->cgVProf = cgGLGetLatestProfile(CG_GL_VERTEX); if ( cg->cgFProf == CG_PROFILE_UNKNOWN || cg->cgVProf == CG_PROFILE_UNKNOWN) { RARCH_ERR("Invalid profile type\n"); free(cg); goto error; } RARCH_LOG("[Cg]: Vertex profile: %s\n", cgGetProfileString(cg->cgVProf)); RARCH_LOG("[Cg]: Fragment profile: %s\n", cgGetProfileString(cg->cgFProf)); cgGLSetOptimalOptions(cg->cgFProf); cgGLSetOptimalOptions(cg->cgVProf); cgGLEnableProfile(cg->cgFProf); cgGLEnableProfile(cg->cgVProf); memset(cg->cg_alias_define, 0, sizeof(cg->cg_alias_define)); if (path && !strcmp(path_get_extension(path), "cgp")) { if (!load_preset(cg, path)) goto error; } else { if (!load_plain(cg, path)) goto error; } cg->prg[0].mvp = cgGetNamedParameter(cg->prg[0].vprg, "IN.mvp_matrix"); for (i = 1; i <= cg->shader->passes; i++) set_program_attributes(cg, i); /* If we aren't using last pass non-FBO shader, * this shader will be assumed to be "fixed-function". * * Just use prg[0] for that pass, which will be * pass-through. */ cg->prg[cg->shader->passes + 1] = cg->prg[0]; /* No need to apply Android hack in Cg. */ cg->prg[GL_SHADER_STOCK_BLEND] = cg->prg[0]; cgGLBindProgram(cg->prg[1].fprg); cgGLBindProgram(cg->prg[1].vprg); driver->video_shader_data = cg; return true; error: gl_cg_destroy_resources(cg); if (!cg) free(cg); return false; }