JSValue ValueRecovery::recover(ExecState* exec) const { switch (technique()) { case DisplacedInJSStack: return exec->r(virtualRegister().offset()).jsValue(); case Int32DisplacedInJSStack: return jsNumber(exec->r(virtualRegister().offset()).unboxedInt32()); case Int52DisplacedInJSStack: return jsNumber(exec->r(virtualRegister().offset()).unboxedInt52()); case StrictInt52DisplacedInJSStack: return jsNumber(exec->r(virtualRegister().offset()).unboxedStrictInt52()); case DoubleDisplacedInJSStack: return jsNumber(exec->r(virtualRegister().offset()).unboxedDouble()); case CellDisplacedInJSStack: return exec->r(virtualRegister().offset()).unboxedCell(); case BooleanDisplacedInJSStack: #if USE(JSVALUE64) return exec->r(virtualRegister().offset()).jsValue(); #else return jsBoolean(exec->r(virtualRegister().offset()).unboxedBoolean()); #endif case Constant: return constant(); default: RELEASE_ASSERT_NOT_REACHED(); return JSValue(); } }
MaterialPtr Material::createWithSingleTechnique(const ShaderProgramPtr& shader, TechniqueCategory category) { TechniquePtr technique(new Technique(shader)); MaterialPtr material(new Material); material->setTechnique(technique, category); return material; }
TechniquePtr Graphics::TechniqueLibrary::loadAsset(std::string const& file) { TechniquePtr technique(new Technique); TechniqueLoader loader; loader.setTarget(*technique); if (!loader.loadFile(file)) { technique.reset(); } return technique; }
void Boid::enable_debug(bool value) { assert(actor_); Stage* stage = actor_->stage(); assert(stage); if(value) { if(!debug_mesh_) { debug_mesh_ = stage->new_mesh(); } auto mesh = stage->mesh(debug_mesh_).lock(); mesh->clear(); auto smi = mesh->new_submesh(kglt::MaterialID(), MESH_ARRANGEMENT_LINE_STRIP, false); normal_points_mesh_ = mesh->new_submesh(kglt::MaterialID(), MESH_ARRANGEMENT_POINTS, false); { auto mat = stage->material(mesh->submesh(normal_points_mesh_).material_id()); mat->technique().pass(0).set_point_size(5); } for(uint32_t i = 0; i < path_.length(); ++i) { mesh->submesh(smi).vertex_data().position(path_.point(i)); mesh->submesh(smi).vertex_data().diffuse(kglt::Colour::blue); mesh->submesh(smi).vertex_data().tex_coord0(kglt::Vec2()); mesh->submesh(smi).vertex_data().tex_coord1(kglt::Vec2()); mesh->submesh(smi).vertex_data().normal(kglt::Vec3()); mesh->submesh(smi).vertex_data().move_next(); mesh->submesh(smi).index_data().index(i); } mesh->submesh(smi).vertex_data().done(); mesh->submesh(smi).index_data().done(); if(!debug_actor_) { debug_actor_ = stage->new_actor(debug_mesh_); } } else { stage->delete_actor(debug_actor_); debug_actor_ = kglt::ActorID(); debug_mesh_ = kglt::MeshID(); } }
//--------------------------------------------------------------- void InstanceLightProbe::add() { COLLADASW::Extra extra(mSW); COLLADASW::Technique technique(mSW); extra.openExtra(); { technique.openTechnique(COLLADAMaya::PROFILE_MAYA); { mSW->openElement(COLLADAMaya::CSW_ELEMENT_INSTANCE_LIGHT_PROBE); { mSW->appendURIAttribute(CSWC::CSW_ATTRIBUTE_URL, mUrl); } mSW->closeElement(); } technique.closeTechnique(); } extra.closeExtra(); }
void RenderSequence::run_pipeline(Pipeline::ptr pipeline_stage) { if(!pipeline_stage->is_active()) { return; } Camera& camera = scene_.camera(pipeline_stage->camera_id()); Viewport& viewport = scene_.window().viewport(pipeline_stage->viewport_id()); viewport.apply(); //FIXME apply shouldn't exist signal_pipeline_started_(*pipeline_stage); if(pipeline_stage->ui_stage_id()) { //This is a UI stage, so just render that auto ui_stage = scene_.ui_stage(pipeline_stage->ui_stage_id()); ui_stage->__resize(viewport.width(), viewport.height()); //FIXME: GL 2.x rubbish glPushMatrix(); glMatrixMode(GL_PROJECTION); glLoadMatrixf(camera.projection_matrix().mat); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ui_stage->__render(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } else { Stage& stage = scene_.stage(pipeline_stage->stage_id()); std::vector<SubActor::ptr> buffers = stage.partitioner().geometry_visible_from(pipeline_stage->camera_id()); /* * Go through the visible objects, sort into queues and for * each material pass add the subactor. The result is that a tree * of material properties (uniforms) will be created with the child nodes * being the meshes */ typedef std::tr1::unordered_map<uint32_t, std::vector<RootGroup::ptr> > QueueGroups; static QueueGroups queues; //Empty the queues for(auto queue: queues) { for(auto group: queue.second) { group->clear(); } } //Go through the visible actors for(SubActor::ptr ent: buffers) { //Get the priority queue for this actor (e.g. RENDER_PRIORITY_BACKGROUND) QueueGroups::mapped_type& priority_queue = queues[(uint32_t)ent->_parent().render_priority()]; auto mat = stage.material(ent->material_id()); //Go through the actors material passes for(uint8_t pass = 0; pass < mat->technique().pass_count(); ++pass) { //Create a new render group if necessary RootGroup::ptr group; if(priority_queue.size() <= pass) { group = RootGroup::ptr(new RootGroup(stage, camera)); priority_queue.push_back(group); } else { group = priority_queue[pass]; } //Insert the actor into the RenderGroup tree group->insert(*ent, pass); } } /* * At this point, we will have a render group tree for each priority level * when we render, we can apply the uniforms/textures/shaders etc. by traversing the * tree and calling bind()/unbind() at each level */ renderer_->set_current_stage(stage.id()); for(RenderPriority priority: RENDER_PRIORITIES) { QueueGroups::mapped_type& priority_queue = queues[priority]; for(RootGroup::ptr pass_group: priority_queue) { std::function<void (SubActor&)> f = [=](SubActor& subactor) { renderer_->render_subactor(subactor, pipeline_stage->camera_id()); }; pass_group->traverse(f); } } renderer_->set_current_stage(StageID()); } /* std::sort(buffers.begin(), buffers.end(), [](SubActor::ptr lhs, SubActor::ptr rhs) { return lhs->_parent().render_priority() < rhs->_parent().render_priority(); }); //TODO: Batched rendering renderer_->set_current_stage(stage.id()); renderer_->render(buffers, stage->camera_id()); renderer_->set_current_stage(StageID());*/ signal_pipeline_finished_(*pipeline_stage); }
void ValueRecovery::dumpInContext(PrintStream& out, DumpContext* context) const { switch (technique()) { case InGPR: out.print(gpr()); return; case UnboxedInt32InGPR: out.print("int32(", gpr(), ")"); return; case UnboxedInt52InGPR: out.print("int52(", gpr(), ")"); return; case UnboxedStrictInt52InGPR: out.print("strictInt52(", gpr(), ")"); return; case UnboxedBooleanInGPR: out.print("bool(", gpr(), ")"); return; case UnboxedCellInGPR: out.print("cell(", gpr(), ")"); return; case UInt32InGPR: out.print("uint32(", gpr(), ")"); return; case InFPR: out.print(fpr()); return; #if USE(JSVALUE32_64) case InPair: out.print("pair(", tagGPR(), ", ", payloadGPR(), ")"); return; #endif case DisplacedInJSStack: out.printf("*%d", virtualRegister().offset()); return; case Int32DisplacedInJSStack: out.printf("*int32(%d)", virtualRegister().offset()); return; case Int52DisplacedInJSStack: out.printf("*int52(%d)", virtualRegister().offset()); return; case StrictInt52DisplacedInJSStack: out.printf("*strictInt52(%d)", virtualRegister().offset()); return; case DoubleDisplacedInJSStack: out.printf("*double(%d)", virtualRegister().offset()); return; case CellDisplacedInJSStack: out.printf("*cell(%d)", virtualRegister().offset()); return; case BooleanDisplacedInJSStack: out.printf("*bool(%d)", virtualRegister().offset()); return; case ArgumentsThatWereNotCreated: out.printf("arguments"); return; case Constant: out.print("[", inContext(constant(), context), "]"); return; case DontKnow: out.printf("!"); return; } RELEASE_ASSERT_NOT_REACHED(); }