X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fprogram.cpp;h=9ed1e634ff4e6c0f214d3dd9aaeebec941d8cb23;hb=6065f6622cc275dc0b20baaf7c267e71169d18f3;hp=468a40f5c8ba06025fe0729d4fc14bb8a536d227;hpb=e9a898f315b5d1396f196d785913a283c30940f2;p=libs%2Fgl.git diff --git a/source/core/program.cpp b/source/core/program.cpp index 468a40f5..9ed1e634 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -22,7 +22,6 @@ #include "misc.h" #include "program.h" #include "resources.h" -#include "shader.h" #include "glsl/compiler.h" using namespace std; @@ -35,30 +34,6 @@ Program::Program() init(); } -Program::Program(const string &source) -{ - init(); - - GlslModule mod; - mod.set_source(source); - add_stages(mod); - - link(); - module = 0; -} - -Program::Program(const string &vert, const string &frag) -{ - init(); - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - attach_shader_owned(new VertexShader(vert)); - attach_shader_owned(new FragmentShader(frag)); -#pragma GCC diagnostic pop - link(); -} - Program::Program(const Module &mod, const map &spec_values) { init(); @@ -227,7 +202,7 @@ void Program::add_spirv_stages(const SpirVModule &mod, const map &s used_stage_ids[n_stages++] = stage_id; } - const vector &code = mod.get_code(); + const vector &code = mod.get_code(); glShaderBinary(n_stages, used_stage_ids, GL_SHADER_BINARY_FORMAT_SPIR_V, &code[0], code.size()*4); if(!spec_values.empty() && !transient) @@ -255,61 +230,6 @@ void Program::add_spirv_stages(const SpirVModule &mod, const map &s glSpecializeShader(stage_ids[i], j->name.c_str(), spec_id_array.size(), &spec_id_array[0], &spec_value_array[0]); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Program::attach_shader(Shader &shader) -{ - unsigned shader_id = shader.steal_id(); - if(!shader_id) - throw invalid_argument("Program::attach_shader"); - - int type; - glGetShaderiv(shader_id, GL_SHADER_TYPE, &type); - switch(type) - { - case GL_VERTEX_SHADER: stage_ids[VERTEX] = shader_id; break; - case GL_GEOMETRY_SHADER: stage_ids[GEOMETRY] = shader_id; break; - case GL_FRAGMENT_SHADER: stage_ids[FRAGMENT] = shader_id; break; - } - - glAttachShader(id, shader_id); - compile_glsl_stage(shader_id); -} - -void Program::attach_shader_owned(Shader *shader) -{ - attach_shader(*shader); - delete shader; -} - -void Program::detach_shader(Shader &) -{ -} - -const vector &Program::get_attached_shaders() const -{ - static vector dummy; - return dummy; -} - -void Program::bind_attribute(unsigned index, const string &name) -{ - static Require _req(ARB_vertex_shader); - glBindAttribLocation(id, index, name.c_str()); -} - -void Program::bind_attribute(VertexAttribute attr, const string &name) -{ - bind_attribute(get_attribute_semantic(attr), name); -} - -void Program::bind_fragment_data(unsigned index, const string &name) -{ - static Require _req(EXT_gpu_shader4); - glBindFragDataLocation(id, index, name.c_str()); -} -#pragma GCC diagnostic pop - void Program::link() { if(!has_stages()) @@ -678,15 +598,6 @@ bool Program::uniform_location_compare(const UniformInfo *uni1, const UniformInf return uni1->locationlocation; } -string Program::get_info_log() const -{ - GLsizei len = get_program_i(id, GL_INFO_LOG_LENGTH); - string log(len+1, 0); - glGetProgramInfoLog(id, len+1, &len, &log[0]); - log.erase(len); - return log; -} - const Program::UniformBlockInfo &Program::get_uniform_block_info(const string &name) const { auto i = find_member(uniform_blocks, name, &UniformBlockInfo::name); @@ -806,12 +717,6 @@ Program::Loader::Loader(Program &p, Collection &c): DataFile::CollectionObjectLoader(p, &c) { add("module", &Loader::module); - - // Deprecated - add("attribute", &Loader::attribute); - add("fragment_shader", &Loader::fragment_shader); - add("geometry_shader", &Loader::geometry_shader); - add("vertex_shader", &Loader::vertex_shader); } void Program::Loader::finish() @@ -827,29 +732,6 @@ void Program::Loader::module(const string &n) obj.add_stages(get_collection().get(n), spec_values); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Program::Loader::attribute(unsigned i, const string &n) -{ - obj.bind_attribute(i, n); -} - -void Program::Loader::fragment_shader(const string &src) -{ - obj.attach_shader_owned(new FragmentShader(src)); -} - -void Program::Loader::geometry_shader(const string &src) -{ - obj.attach_shader_owned(new GeometryShader(src)); -} - -void Program::Loader::vertex_shader(const string &src) -{ - obj.attach_shader_owned(new VertexShader(src)); -} -#pragma GCC diagnostic pop - DataFile::Loader::ActionMap Program::SpecializationLoader::shared_actions;