#include "builtin.h"
#include "compiler.h"
#include "debug.h"
+#include "deviceinfo.h"
#include "error.h"
#include "finalize.h"
#include "generate.h"
namespace SL {
Compiler::Compiler():
- features(Features::from_context()),
- module(0),
- compiled(false),
- specialized(false)
+ features(DeviceInfo::get_global().glsl_features)
{ }
Compiler::Compiler(const Features &f):
- features(f),
- module(0),
- compiled(false),
- specialized(false)
+ features(f)
{ }
Compiler::~Compiler()
throw key_error(Stage::get_stage_name(stage_type));
}
-vector<UInt32> Compiler::get_combined_spirv() const
+vector<uint32_t> Compiler::get_combined_spirv() const
{
if(!compiled)
throw invalid_operation("Compiler::get_combined_spirv");
return module->shared.uniform_block_bindings;
}
+unsigned Compiler::get_n_clip_distances() const
+{
+ if(!compiled)
+ throw invalid_operation("Compiler::get_n_clip_distances");
+ auto i = find_member(module->stages, Stage::VERTEX, &Stage::type);
+ return (i!=module->stages.end() ? i->n_clip_distances : 0);
+}
+
const SourceMap &Compiler::get_source_map() const
{
return module->source_map;
void Compiler::generate(Stage &stage)
{
- stage.required_features.gl_api = features.gl_api;
+ stage.required_features.target_api = features.target_api;
if(module->shared.required_features.glsl_version>stage.required_features.glsl_version)
stage.required_features.glsl_version = module->shared.required_features.glsl_version;
resolve(stage, RESOLVE_TYPES|RESOLVE_VARIABLES|RESOLVE_FUNCTIONS|RESOLVE_EXPRESSIONS);
any_inlined = true;
}
+ if(AggregateDismantler().apply(stage))
+ {
+ resolve(stage, RESOLVE_TYPES|RESOLVE_VARIABLES|RESOLVE_FUNCTIONS|RESOLVE_EXPRESSIONS);
+ any_inlined = true;
+ }
if(ExpressionInliner().apply(stage))
{
resolve(stage, RESOLVE_VARIABLES|RESOLVE_FUNCTIONS|RESOLVE_EXPRESSIONS);