case VERTEX: { static Require _req(ARB_vertex_shader); gl_type = GL_VERTEX_SHADER; } break;
case GEOMETRY: { static Require _req(ARB_geometry_shader4); gl_type = GL_GEOMETRY_SHADER; } break;
case FRAGMENT: { static Require _req(ARB_fragment_shader); gl_type = GL_FRAGMENT_SHADER; } break;
- default: throw invalid_argument("Program::add_stage");
+ default: throw invalid_argument("OpenGLProgram::add_stage");
}
if(stage_ids[type])
- throw invalid_operation("Program::add_stage");
+ throw invalid_operation("OpenGLProgram::add_stage");
unsigned stage_id = glCreateShader(gl_type);
stage_ids[type] = stage_id;
vector<SL::Stage::Type> stages = compiler.get_stages();
if(stages.empty())
- throw invalid_argument("Program::add_glsl_stages");
+ throw invalid_argument("OpenGLProgram::add_glsl_stages");
for(SL::Stage::Type st: stages)
{
case SL::Stage::VERTEX: stage_id = add_stage(VERTEX); break;
case SL::Stage::GEOMETRY: stage_id = add_stage(GEOMETRY); break;
case SL::Stage::FRAGMENT: stage_id = add_stage(FRAGMENT); break;
- default: throw invalid_operation("Program::add_glsl_stages");
+ default: throw invalid_operation("OpenGLProgram::add_glsl_stages");
}
string stage_src = compiler.get_stage_glsl(st);
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");
+ default: throw invalid_operation("OpenGLProgram::add_spirv_stages");
}
used_stage_ids[n_stages++] = stage_id;
}
if(!n_stages)
- throw invalid_argument("Program::add_spirv_stages");
+ throw invalid_argument("OpenGLProgram::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);
glSpecializeShader(stage_ids[i], j->name.c_str(), spec_id_array.size(), &spec_id_array[0], &spec_value_array[0]);
}
-void OpenGLProgram::finalize(const Module &mod)
+void OpenGLProgram::finalize(const Module &mod, TransientData &transient)
{
glLinkProgram(id);
int status = 0;
if(!info_log.empty())
IO::print("Program link info log:\n%s", info_log);
#endif
+
+ if(mod.get_format()==Module::GLSL)
+ {
+ query_uniforms();
+ query_attributes();
+ apply_bindings(transient);
+ }
}
void OpenGLProgram::query_uniforms()
func = &uniform_wrapper<int, glUniform3iv>;
else if(u.type==INT_VEC4)
func = &uniform_wrapper<int, glUniform4iv>;
+ else if(u.type==UNSIGNED_INT)
+ func = &uniform_wrapper<unsigned, glUniform1uiv>;
+ else if(u.type==UINT_VEC2)
+ func = &uniform_wrapper<unsigned, glUniform2uiv>;
+ else if(u.type==UINT_VEC3)
+ func = &uniform_wrapper<unsigned, glUniform3uiv>;
+ else if(u.type==UINT_VEC4)
+ func = &uniform_wrapper<unsigned, glUniform4uiv>;
else if(u.type==FLOAT_MAT2)
func = &uniform_matrix_wrapper<float, glUniformMatrix2fv>;
else if(u.type==FLOAT_MAT3)
for(int j: indices)
{
if(!uniforms_by_index[j])
- throw logic_error("Program::link");
+ throw logic_error("OpenGLProgram::query_uniform_blocks");
info.uniforms.push_back(uniforms_by_index[j]);
uniforms_by_index[j]->block = &info;
}