- if(st==SL::Stage::FRAGMENT && EXT_gpu_shader4)
- {
- for(const auto &kvp: compiler.get_fragment_outputs())
- glBindFragDataLocation(id, kvp.second, kvp.first.c_str());
- }
-
- compile_glsl_stage(mod, stage_id);
- }
-
- transient.textures = compiler.get_texture_bindings();
- transient.blocks = compiler.get_uniform_block_bindings();
-}
-
-void Program::compile_glsl_stage(const GlslModule &mod, unsigned stage_id)
-{
- glCompileShader(stage_id);
- int status = 0;
- glGetShaderiv(stage_id, GL_COMPILE_STATUS, &status);
-
- int info_log_len = 0;
- glGetShaderiv(stage_id, GL_INFO_LOG_LENGTH, &info_log_len);
- string info_log(info_log_len+1, 0);
- glGetShaderInfoLog(stage_id, info_log_len+1, &info_log_len, &info_log[0]);
- info_log.erase(info_log_len);
- info_log = mod.get_source_map().translate_errors(info_log);
-
- if(!status)
- throw compile_error(info_log);
-#ifdef DEBUG
- if(!info_log.empty())
- IO::print("Shader compile info log:\n%s", info_log);
-#endif
-}
-
-void Program::add_spirv_stages(const SpirVModule &mod, const map<string, int> &spec_values, TransientData &transient)
-{
- static Require _req(ARB_gl_spirv);
- static Require _req2(ARB_ES2_compatibility);
-
- unsigned n_stages = 0;
- unsigned used_stage_ids[MAX_STAGES];
- for(const SpirVModule::EntryPoint &e: mod.get_entry_points())
- {
- unsigned stage_id = 0;
- switch(e.stage)
- {
- case SpirVModule::VERTEX: stage_id = add_stage(VERTEX); break;
- case SpirVModule::GEOMETRY: stage_id = add_stage(GEOMETRY); break;
- case SpirVModule::FRAGMENT: stage_id = add_stage(FRAGMENT); break;
- default: throw invalid_operation("Program::add_spirv_stages");
- }
-
- used_stage_ids[n_stages++] = stage_id;
- }
-
- if(!n_stages)
- throw invalid_argument("Program::add_spirv_stages");
-
- const vector<uint32_t> &code = mod.get_code();
- glShaderBinary(n_stages, used_stage_ids, GL_SHADER_BINARY_FORMAT_SPIR_V, &code[0], code.size()*4);
-
- const vector<SpirVModule::Constant> &spec_consts = mod.get_spec_constants();
- vector<unsigned> spec_id_array;
- vector<unsigned> spec_value_array;
- spec_id_array.reserve(spec_consts.size());
- spec_value_array.reserve(spec_consts.size());
- for(const SpirVModule::Constant &c: spec_consts)