// internal void asCScriptFunction::JITCompile() { if( funcType != asFUNC_SCRIPT ) return; asASSERT( scriptData ); asIJITCompiler *jit = engine->GetJITCompiler(); if( !jit ) return; // Make sure the function has been compiled with JitEntry instructions // For functions that has JitEntry this will be a quick test asUINT length; asDWORD *byteCode = GetByteCode(&length); asDWORD *end = byteCode + length; bool foundJitEntry = false; while( byteCode < end ) { // Determine the instruction asEBCInstr op = asEBCInstr(*(asBYTE*)byteCode); if( op == asBC_JitEntry ) { foundJitEntry = true; break; } // Move to next instruction byteCode += asBCTypeSize[asBCInfo[op].type]; } if( !foundJitEntry ) { asCString msg; msg.Format(TXT_NO_JIT_IN_FUNC_s, GetDeclaration()); engine->WriteMessage("", 0, 0, asMSGTYPE_WARNING, msg.AddressOf()); } // Release the previous function, if any if( scriptData->jitFunction ) { engine->jitCompiler->ReleaseJITFunction(scriptData->jitFunction); scriptData->jitFunction = 0; } // Compile for native system int r = jit->CompileFunction(this, &scriptData->jitFunction); if( r < 0 ) asASSERT( scriptData->jitFunction == 0 ); }
void FMeshParticleVertexFactory::InitRHI() { FVertexDeclarationElementList Elements; const bool bInstanced = GetFeatureLevel() >= ERHIFeatureLevel::SM4; if (Data.bInitialized) { if(bInstanced) { // Stream 0 - Instance data { checkf(DynamicVertexStride != -1, TEXT("FMeshParticleVertexFactory does not have a valid DynamicVertexStride - likely an empty one was made, but SetStrides was not called")); FVertexStream VertexStream; VertexStream.VertexBuffer = NULL; VertexStream.Stride = 0; VertexStream.Offset = 0; Streams.Add(VertexStream); // @todo metal: this will need a valid stride when we get to instanced meshes! Elements.Add(FVertexElement(0, Data.TransformComponent[0].Offset, Data.TransformComponent[0].Type, 8, DynamicVertexStride, Data.TransformComponent[0].bUseInstanceIndex)); Elements.Add(FVertexElement(0, Data.TransformComponent[1].Offset, Data.TransformComponent[1].Type, 9, DynamicVertexStride, Data.TransformComponent[1].bUseInstanceIndex)); Elements.Add(FVertexElement(0, Data.TransformComponent[2].Offset, Data.TransformComponent[2].Type, 10, DynamicVertexStride, Data.TransformComponent[2].bUseInstanceIndex)); Elements.Add(FVertexElement(0, Data.SubUVs.Offset, Data.SubUVs.Type, 11, DynamicVertexStride, Data.SubUVs.bUseInstanceIndex)); Elements.Add(FVertexElement(0, Data.SubUVLerpAndRelTime.Offset, Data.SubUVLerpAndRelTime.Type, 12, DynamicVertexStride, Data.SubUVLerpAndRelTime.bUseInstanceIndex)); Elements.Add(FVertexElement(0, Data.ParticleColorComponent.Offset, Data.ParticleColorComponent.Type, 14, DynamicVertexStride, Data.ParticleColorComponent.bUseInstanceIndex)); Elements.Add(FVertexElement(0, Data.VelocityComponent.Offset, Data.VelocityComponent.Type, 15, DynamicVertexStride, Data.VelocityComponent.bUseInstanceIndex)); } // Stream 1 - Dynamic parameter { checkf(DynamicParameterVertexStride != -1, TEXT("FMeshParticleVertexFactory does not have a valid DynamicParameterVertexStride - likely an empty one was made, but SetStrides was not called")); FVertexStream VertexStream; VertexStream.VertexBuffer = NULL; VertexStream.Stride = 0; VertexStream.Offset = 0; Streams.Add(VertexStream); Elements.Add(FVertexElement(1, 0, VET_Float4, 13, DynamicParameterVertexStride, true)); } } if(Data.PositionComponent.VertexBuffer != NULL) { Elements.Add(AccessStreamComponent(Data.PositionComponent,0)); } // only tangent,normal are used by the stream. the binormal is derived in the shader uint8 TangentBasisAttributes[2] = { 1, 2 }; for(int32 AxisIndex = 0;AxisIndex < 2;AxisIndex++) { if(Data.TangentBasisComponents[AxisIndex].VertexBuffer != NULL) { Elements.Add(AccessStreamComponent(Data.TangentBasisComponents[AxisIndex],TangentBasisAttributes[AxisIndex])); } } // Vertex color if(Data.VertexColorComponent.VertexBuffer != NULL) { Elements.Add(AccessStreamComponent(Data.VertexColorComponent,3)); } else { //If the mesh has no color component, set the null color buffer on a new stream with a stride of 0. //This wastes 4 bytes of bandwidth per vertex, but prevents having to compile out twice the number of vertex factories. FVertexStreamComponent NullColorComponent(&GNullColorVertexBuffer, 0, 0, VET_Color); Elements.Add(AccessStreamComponent(NullColorComponent,3)); } if(Data.TextureCoordinates.Num()) { const int32 BaseTexCoordAttribute = 4; for(int32 CoordinateIndex = 0;CoordinateIndex < Data.TextureCoordinates.Num();CoordinateIndex++) { Elements.Add(AccessStreamComponent( Data.TextureCoordinates[CoordinateIndex], BaseTexCoordAttribute + CoordinateIndex )); } for(int32 CoordinateIndex = Data.TextureCoordinates.Num();CoordinateIndex < MAX_TEXCOORDS;CoordinateIndex++) { Elements.Add(AccessStreamComponent( Data.TextureCoordinates[Data.TextureCoordinates.Num() - 1], BaseTexCoordAttribute + CoordinateIndex )); } } if(Streams.Num() > 0) { InitDeclaration(Elements,Data); check(IsValidRef(GetDeclaration())); } } }
void ScriptEngine::generateReference() { if (!m_engine) return; std::ofstream out("AngelScript reference.txt"); out << "*** Globals ***" << std::endl << std::endl; int nb = m_engine->GetGlobalFunctionCount(); for (int i = 0; i < nb; ++i) { auto func = m_engine->GetGlobalFunctionByIndex(i); out << "\t" << func->GetDeclaration(true, false, true) << std::endl; } out << std::endl << "*** Types ***" << std::endl << std::endl; nb = m_engine->GetObjectTypeCount(); for (int i = 0; i < nb; ++i) { auto info = m_engine->GetObjectTypeByIndex(i); out << " * " << info->GetName() << std::endl; int nb2 = info->GetPropertyCount(); for (int j = 0; j < nb2; ++j) { const char* name; int typeId; bool isPrivate, isProtected, isReference; auto prop = info->GetProperty(j, &name, &typeId, &isPrivate, &isProtected, nullptr, &isReference); out << "\t"; if (isProtected) out << "protected "; if (isPrivate) out << "private "; out << m_engine->GetTypeDeclaration(typeId); if (isReference) out << "&"; out << " "; out << name << std::endl; } if (nb2 != 0) out << std::endl; nb2 = info->GetBehaviourCount(); bool hasBehaviour = false; for (int j = 0; j < nb2; ++j) { asEBehaviours behaviour; auto func = info->GetBehaviourByIndex(j, &behaviour); if (behaviour == asBEHAVE_CONSTRUCT || behaviour == asBEHAVE_DESTRUCT) { hasBehaviour = true; out << "\t" << func->GetDeclaration(false, false, true) << std::endl; } } if (hasBehaviour) out << std::endl; nb2 = info->GetFactoryCount(); for (int j = 0; j < nb2; ++j) { auto func = info->GetFactoryByIndex(j); out << "\t" << func->GetDeclaration(false, false, true) << std::endl; } if (nb2 != 0) out << std::endl; nb2 = info->GetMethodCount(); for (int j = 0; j < nb2; ++j) { auto func = info->GetMethodByIndex(j); out << "\t" << func->GetDeclaration(false, false, true) << std::endl; } out << std::endl; } }