#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;
}
}
{
std::map<std::string, unsigned> textures;
std::map<std::string, unsigned> blocks;
- std::map<unsigned, int> spec_values;
};
struct UniformCall
unsigned add_stage(Stage);
void add_glsl_stages(const GlslModule &, const std::map<std::string, int> &, TransientData &);
void compile_glsl_stage(const GlslModule &, unsigned);
- void add_spirv_stages(const SpirVModule &, const std::map<std::string, int> &, TransientData &);
+ void add_spirv_stages(const SpirVModule &, const std::map<std::string, int> &);
void finalize(const Module &, TransientData &);
void query_uniforms();
for(Structure &s: structs)
{
for(StructMember &m: s.members)
- {
if(m.struct_type)
{
auto i = struct_indices.find(m.struct_type);
m.struct_type = (i!=struct_indices.end() ? &structs[i->second] : 0);
}
- if(m.array_size_spec)
- {
- auto i = spec_indices.find(m.array_size_spec);
- m.array_size_spec = (i!=spec_indices.end() ? &spec_constants[i->second] : 0);
- }
- }
const StructMember *last_member = &s.members.back();
unsigned last_offset = last_member->offset;
const StructMember *lm = &last_member->struct_type->members.back();
if(last_member->array_size)
last_offset += last_member->array_stride*(last_member->array_size-1);
- else if(last_member->array_size_spec)
- last_offset += last_member->array_stride*(last_member->array_size_spec->i_value-1);
last_offset += lm->offset;
last_member = lm;
}
}
for(Variable &v: variables)
- {
if(v.struct_type)
{
auto i = struct_indices.find(v.struct_type);
v.struct_type = (i!=struct_indices.end() ? &structs[i->second] : 0);
}
- if(v.array_size_spec)
- {
- auto i = spec_indices.find(v.array_size_spec);
- v.array_size_spec = (i!=spec_indices.end() ? &spec_constants[i->second] : 0);
- }
- }
entry_points.reserve(reflection.entry_points.size());
for(const auto &kvp: reflection.entry_points)
type.struct_type = elem.struct_type;
const Constant &size = constants[*(op+3)];
- if(size.constant_id>=0)
- type.array_size_spec = &size;
- else if(size.type==INT || size.type==UNSIGNED_INT)
+ if(size.type==INT || size.type==UNSIGNED_INT)
type.array_size = size.i_value;
}
mem->type = type.type;
mem->struct_type = type.struct_type;
mem->array_size = type.array_size;
- mem->array_size_spec = type.array_size_spec;
mem->array_stride = type.array_stride;
}
}
var.type = type.type;
var.struct_type = type.struct_type;
var.array_size = type.array_size;
- var.array_size_spec = type.array_size_spec;
}
void SpirVModule::Reflection::reflect_decorate(CodeIterator op)
const Structure *struct_type = 0;
unsigned offset = 0;
unsigned array_size = 0;
- const Constant *array_size_spec = 0;
unsigned array_stride = 0;
unsigned matrix_stride = 0;
BuiltinSemantic builtin = NOT_BUILTIN;
StorageClass storage = static_cast<StorageClass>(-1);
DataType type = VOID;
const Structure *struct_type = 0;
- const Constant *array_size_spec = 0;
unsigned array_size = 0;
int location = -1;
int descriptor_set = -1;
{
DataType type = VOID;
const Structure *struct_type = 0;
- const Constant *array_size_spec = 0;
unsigned array_size = 0;
unsigned array_stride = 0;
StorageClass storage = static_cast<StorageClass>(-1);
add_glsl_stages(static_cast<const GlslModule &>(mod), spec_values, transient);
break;
case Module::SPIR_V:
- add_spirv_stages(static_cast<const SpirVModule &>(mod), spec_values, transient);
+ add_spirv_stages(static_cast<const SpirVModule &>(mod), spec_values);
break;
default:
throw invalid_argument("Program::add_stages");
if(mod.get_format()==Module::SPIR_V)
{
- collect_uniforms(static_cast<const SpirVModule &>(mod), transient.spec_values);
+ collect_uniforms(static_cast<const SpirVModule &>(mod));
collect_attributes(static_cast<const SpirVModule &>(mod));
}
require_type(a.type);
}
-void Program::collect_uniforms(const SpirVModule &mod, const map<unsigned, int> &spec_values)
+void Program::collect_uniforms(const SpirVModule &mod)
{
// Prepare the default block
reflect_data.uniform_blocks.push_back(ReflectData::UniformBlockInfo());
if(!v.name.empty())
prefix = v.struct_type->name+".";
block_uniform_names.push_back(vector<string>());
- collect_block_uniforms(*v.struct_type, prefix, 0, spec_values, block_uniform_names.back());
+ collect_block_uniforms(*v.struct_type, prefix, 0, block_uniform_names.back());
}
else if(v.storage==SpirVModule::UNIFORM_CONSTANT && v.location>=0)
{
reflect_data.update_layout_hash();
}
-void Program::collect_block_uniforms(const SpirVModule::Structure &strct, const string &prefix, unsigned base_offset, const map<unsigned, int> &spec_values, vector<string> &uniform_names)
+void Program::collect_block_uniforms(const SpirVModule::Structure &strct, const string &prefix, unsigned base_offset, vector<string> &uniform_names)
{
for(const SpirVModule::StructMember &m: strct.members)
{
unsigned offset = base_offset+m.offset;
if(m.struct_type)
{
- unsigned array_size = m.array_size;
- if(m.array_size_spec)
+ if(m.array_size)
{
- array_size = m.array_size_spec->i_value;
- auto j = spec_values.find(m.array_size_spec->constant_id);
- if(j!=spec_values.end())
- array_size = j->second;
- }
-
- if(array_size)
- {
- for(unsigned j=0; j<array_size; ++j, offset+=m.array_stride)
- collect_block_uniforms(*m.struct_type, format("%s%s[%d].", prefix, m.name, j), offset, spec_values, uniform_names);
+ for(unsigned j=0; j<m.array_size; ++j, offset+=m.array_stride)
+ collect_block_uniforms(*m.struct_type, format("%s%s[%d].", prefix, m.name, j), offset, uniform_names);
}
else
- collect_block_uniforms(*m.struct_type, prefix+m.name+".", offset, spec_values, uniform_names);
+ collect_block_uniforms(*m.struct_type, prefix+m.name+".", offset, uniform_names);
}
else
{
void add_stages(const Module &, const std::map<std::string, int> & = std::map<std::string, int>());
private:
- void collect_uniforms(const SpirVModule &, const std::map<unsigned, int> &);
- void collect_block_uniforms(const SpirVModule::Structure &, const std::string &, unsigned, const std::map<unsigned, int> &, std::vector<std::string> &);
+ void collect_uniforms(const SpirVModule &);
+ void collect_block_uniforms(const SpirVModule::Structure &, const std::string &, unsigned, std::vector<std::string> &);
void collect_attributes(const SpirVModule &);
void collect_builtins(const SpirVModule &);
void collect_builtins(const SpirVModule::Structure &);