#include <msp/gl/extensions/khr_debug.h>
#include <msp/gl/extensions/nv_non_square_matrices.h>
#include <msp/io/print.h>
+#include "device.h"
#include "error.h"
#include "program.h"
#include "program_backend.h"
id = glCreateProgram();
}
+OpenGLProgram::OpenGLProgram(OpenGLProgram &&other):
+ id(other.id),
+ linked(other.linked),
+ uniform_calls(move(other.uniform_calls)),
+ debug_name(move(other.debug_name))
+{
+ move(other.stage_ids, other.stage_ids+MAX_STAGES, stage_ids);
+ other.id = 0;
+ fill(other.stage_ids, other.stage_ids+MAX_STAGES, 0);
+}
+
OpenGLProgram::~OpenGLProgram()
{
for(unsigned i=0; i<MAX_STAGES; ++i)
void OpenGLProgram::add_glsl_stages(const GlslModule &mod, const map<string, int> &spec_values, TransientData &transient)
{
- SL::Compiler compiler;
+ SL::Compiler compiler(Device::get_current().get_info().glsl_features);
compiler.set_source(mod.get_prepared_source(), "<module>");
compiler.specialize(spec_values);
compiler.compile(SL::Compiler::PROGRAM);
#endif
}
-void OpenGLProgram::add_spirv_stages(const SpirVModule &mod, const map<string, int> &spec_values, TransientData &transient)
+void OpenGLProgram::add_spirv_stages(const SpirVModule &mod, const map<string, int> &spec_values)
{
static Require _req(ARB_gl_spirv);
static Require _req2(ARB_ES2_compatibility);
{
spec_id_array.push_back(c.constant_id);
spec_value_array.push_back(i->second);
- transient.spec_values[c.constant_id] = i->second;
}
}
if(len>3 && !strcmp(name+len-3, "[0]"))
name[len-3] = 0;
- rd.uniforms.push_back(ReflectData::UniformInfo());
+ rd.uniforms.emplace_back();
ReflectData::UniformInfo &info = rd.uniforms.back();
info.name = name;
info.tag = name;
query_uniform_blocks(uniforms_by_index);
}
- rd.uniform_blocks.push_back(ReflectData::UniformBlockInfo());
+ rd.uniform_blocks.emplace_back();
ReflectData::UniformBlockInfo &default_block = rd.uniform_blocks.back();
for(ReflectData::UniformInfo &u: rd.uniforms)
char name[128];
int len;
glGetActiveUniformBlockName(id, i, sizeof(name), &len, name);
- rd.uniform_blocks.push_back(ReflectData::UniformBlockInfo());
+ rd.uniform_blocks.emplace_back();
ReflectData::UniformBlockInfo &info = rd.uniform_blocks.back();
info.name = name;
if(len>3 && !strcmp(name+len-3, "[0]"))
name[len-3] = 0;
- rd.attributes.push_back(ReflectData::AttributeInfo());
+ rd.attributes.emplace_back();
ReflectData::AttributeInfo &info = rd.attributes.back();
info.name = name;
info.location = glGetAttribLocation(id, name);
if(func)
uniform_calls.push_back(UniformCall(u->location, u->array_size, func));
}
+
+ if(i->data_size<=0)
+ {
+ const ReflectData::UniformInfo &last = *i->uniforms.back();
+ i->data_size = last.location*16+last.array_size*get_type_size(last.type);
+ }
}
}