static int __init rawdata_init(void) { /* Just register the driver. No kernel boot options used. */ printk(KERN_INFO "%s Init: Inserting Xilinx driver in kernel.\n", MYNAME); DriverState = INITIALIZED; spin_lock_init(&RawLock); /* First allocate the buffer pool and set the driver state * because GetPkt routine can potentially be called immediately * after Register is done. */ //printk("PAGE_SIZE is %ld\n", PAGE_SIZE); msleep(5); InitBuffers(&TxBufs); InitBuffers(&RxBufs); /* Start polling routine - change later !!!! */ printk(KERN_INFO "%s Init: Starting poll routine with %x\n", MYNAME, polldata); init_timer(&poll_timer); poll_timer.expires=jiffies+(HZ/5); poll_timer.data=(unsigned long) polldata; poll_timer.function = poll_routine; add_timer(&poll_timer); return 0; }
int EncoderMFC::Initialize(int width, int height,int codec,float rate,int bitrate,int in_bufs,int out_bufs, int stream_b_size){ if(state!=MFC_ST_OPEN) return -1; if(SetFormat(width,height)<0) return -1; if(SetCodec(codec,stream_b_size)<0) return -1; SetRate(rate); if(bitrate>0) SetBitRate(bitrate); if(InitBuffers(DIR_IN,in_bufs)<0) return -1; if(InitBuffers(DIR_OUT,out_bufs)<0) return -1; for (int bi=0;bi<out_bufs;bi++){ struct v4l2_buffer buf; struct v4l2_plane planes[MFC_MAX_PLANES]; buf.type = io_dir_to_type(DIR_OUT); buf.memory = V4L2_MEMORY_MMAP; buf.m.planes = planes; buf.length = NPPBuf[DIR_OUT]; buf.index=bi; for (u_int i = 0; i < NPPBuf[DIR_OUT]; i++){ planes[i].length=PlanesLen[DIR_OUT][i]; planes[i].bytesused=0; planes[i].m.userptr=(u_long)BufAddr[DIR_OUT][bi][i]; } int ret = ioctl(fd, VIDIOC_QBUF, &buf); if (ret != 0) { printf("\nEncoderMFC: Init, Queue buffer %d error! %s\n",buf.index,strerror(errno)); } } BufInx[DIR_OUT]=0; state=MFC_ST_OK; return 0; }
void TMagnify::ScreenChanged(BRect, color_space) { int32 width, height; fParent->PixelCount(&width, &height); InitBuffers(width, height, fParent->PixelSize(), fParent->ShowGrid()); }
Mesh::Mesh(Program &program, const char *filename) : Drawable(program) , vbuffer(-1) , nbuffer(-1) , tbuffer(-1) , fbuffer(-1) , texture(NULL) { FILE *fp = fopen(filename, "r"); if(!fp) { std::cout << "Could not open file: " << filename << " :" << strerror(errno) << std::endl; exit(-1); } int num_vertices, num_faces; bool have_normals = false; bool have_tex = false; //Read the header ReadHeader(fp, num_vertices, num_faces, have_normals, have_tex); ReadVertexData(fp, num_vertices, have_normals, have_tex); ReadFaceData(fp, num_faces); InitBuffers(); }
//calls buffer initialisation bool Model::Init(ID3D11Device* device, char* modelFilename, WCHAR* textureFilename1) //UPDATED ARG IN 0.17 { bool result; // Load in model data, new for 0.6 result = LoadModel(modelFilename); if(!result) { return false; } // Init vertex and index buffer that hold geometry for triangle. result = InitBuffers(device); if(!result) { return false; } // Load texture for this model. result = LoadTexture(device, textureFilename1); if(!result) { return false; } return true; }
void StVKReducedInternalForces::InitComputation(int r, double * U, VolumetricMesh * volumetricMesh) { this->volumetricMesh = volumetricMesh; this->U = U; this->r = r; numElementVertices = volumetricMesh->getNumElementVertices(); n = volumetricMesh->getNumVertices(); r2 = r * r; // allocate room for coefficients, r linear coefficients per each of the r components linearSize = GetLinearSize(r); linearCoef_ = (double*) calloc (r * linearSize, sizeof(double)); // allocate room for coefficients, r*(r+1)/2 quadratic coefficients per each of the r components quadraticSize = GetQuadraticSize(r); quadraticCoef_ = (double*) calloc ( r * quadraticSize, sizeof(double)); // allocate room for coefficients, r*(r+1)*(r+2)/6 cubic coefficients per each of the r components cubicSize = GetCubicSize(r); cubicCoef_ = (double*) calloc (r * cubicSize, sizeof(double)); InitBuffers(); if (verbose >= 1) { printf("Number of vertices is: %d\n",n); printf("Number of nonlinear modes is: %d\n",r); printf("Computation initialization completed.\n"); } }
ParticleSystemComponent::ParticleSystemComponent(D3D& d3d, const std::string& effectFile) : m_engagedParticles(), m_maxParticleCount(), m_currentParticleCount(), m_emissionFreq(), m_timeBetweenEmissions(), m_timeSinceLastEmission(), m_systemLifetime(), m_currentLifetime(0.0f), m_startPosition(), m_startPositionDeviation(), m_startVelocity(), m_startVelocityDeviation(), m_startColor(), m_startColorDeviation(), m_colorChangePerSec(), m_startSize(), m_startSizeDeviation(), m_sizeChangePerSec(), m_texture(0), m_effectName("NoEffectLoaded"), m_vertexCount(0), m_indexCount(0), m_vertices(0), m_vertexBuffer(0), m_indexBuffer(0), m_tweakBarSetup(false), m_emitting(false) { LoadFromFile("Assets\\ParticleEffects\\" + effectFile, d3d); InitBuffers(d3d); SetShader(G_ShaderManager().GetShader("Particle")); //Start(); }
PleoraVideo::PleoraVideo(Params& p): size_bytes(0), lPvSystem(0), lDevice(0), lStream(0), lDeviceParams(0), lStart(0), lStop(0), lTemperatureCelcius(0), getTemp(false), lStreamParams(0), validGrabbedBuffers(0) { std::string sn; std::string mn; int index = 0; size_t buffer_count = PleoraVideo::DEFAULT_BUFFER_COUNT; Params device_params; for(Params::ParamMap::iterator it = p.params.begin(); it != p.params.end(); it++) { if(it->first == "model"){ mn = it->second; } else if(it->first == "sn"){ sn = it->second; } else if(it->first == "idx"){ index = p.Get<int>("idx", 0); } else if(it->first == "buffers"){ buffer_count = p.Get<size_t>("buffers", PleoraVideo::DEFAULT_BUFFER_COUNT); } else { device_params.Set(it->first, it->second); } } InitDevice(mn.empty() ? 0 : mn.c_str(), sn.empty() ? 0 : sn.c_str(), index); SetDeviceParams(device_params); InitStream(); InitPangoStreams(); InitBuffers(buffer_count); Start(); }
void Model::InitPolygon(Effect* aEffect) { myEffect = aEffect; D3D11_INPUT_ELEMENT_DESC vertexDesc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; D3DX11_PASS_DESC passDesc; myEffect->GetTechnique()->GetPassByIndex(0)->GetDesc(&passDesc); Engine::GetInstance()->GetDevice()->CreateInputLayout(vertexDesc, ARRAYSIZE(vertexDesc), passDesc.pIAInputSignature, passDesc.IAInputSignatureSize, &myVertexLayout); Engine::GetInstance()->GetContex()->IASetInputLayout(myVertexLayout); //myVertices.Add({ { 0.0f, 0.5f, 0.5f }, { 1.f, 0.f, 0.f, 1.f } }); //myVertices.Add({ { 0.5f, -0.5f, 0.5 }, { 0.f, 1.f, 0.f, 1.f } }); //myVertices.Add({ { -0.5f, -0.5f, 0.5f }, { 0.f, 0.f, 1.f, 1.f } }); myVerticeIndices.Add(0); myVerticeIndices.Add(1); myVerticeIndices.Add(2); InitBuffers(VertexType::POS_NORM_UV); }
bool VideoOutputVDPAU::Init(int width, int height, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id) { // Attempt to free up as much video memory as possible // only works when using the VDPAU painter for the UI MythPainter *painter = GetMythPainter(); if (painter) painter->FreeResources(); m_win = winid; QMutexLocker locker(&m_lock); window.SetNeedRepaint(true); bool ok = VideoOutput::Init(width, height, aspect, winid, win_rect,codec_id); if (db_vdisp_profile) db_vdisp_profile->SetVideoRenderer("vdpau"); InitDisplayMeasurements(width, height, true); ParseOptions(); if (ok) ok = InitRender(); if (ok) ok = InitBuffers(); if (!ok) { TearDown(); return ok; } InitPictureAttributes(); MoveResize(); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created VDPAU context (%1 decode)") .arg(codec_is_std(video_codec_id) ? "software" : "GPU")); return ok; }
HRESULT CDecoder::CodeReal (ISequentialInStream **inStreams, const UInt64 **inSizes/* inSizes */, UInt32 numInStreams, ISequentialOutStream **outStreams, const UInt64 ** /* outSizes */, UInt32 numOutStreams, ICompressProgressInfo *progress) { if (numInStreams != 3 || numOutStreams != 1) return E_INVALIDARG; if (!InitBuffers ()) return E_OUTOFMEMORY; m_progress = progress; m_outBuffer.SetStream (outStreams[0]); m_outBuffer.Init (); m_mainBuffer.SetStream (inStreams[0]); m_mainBuffer.Init (); m_headersBuffer.SetStream (inStreams[1]); m_headersBuffer.Init (); m_sideInfoBuffer.SetStream (inStreams[2]); m_sideInfoBuffer.Init (); CCoderReleaser releaser (this); return DecodeFrames (); }
Mesh::Mesh(Program &program) : Drawable(program) , vbuffer(-1) , nbuffer(-1) , tbuffer(-1) , fbuffer(-1) , texture(NULL) { AddVertex(-1.0, -1.0, -1.0); AddVertex(-1.0, 1.0, -1.0); AddVertex(1.0, 1.0, -1.0); AddVertex(1.0, -1.0, -1.0); AddTexcoord(0, 1); AddTexcoord(0, 0); AddTexcoord(1, 0); AddTexcoord(1, 1); AddColour(1.0, 0.0, 0.0); AddColour(0.0, 1.0, 0.0); AddColour(0.0, 0.0, 1.0); AddColour(1.0, 1.0, 1.0); AddNormal(0.0, 0.0, 1.0); AddNormal(0.0, 0.0, 1.0); AddNormal(0.0, 0.0, 1.0); AddNormal(0.0, 0.0, 1.0); AddFace(0, 1, 2); AddFace(2, 3, 0); InitBuffers(); }
CGSolver::CGSolver(SparseMatrix * A_): A(A_) { numRows = A->GetNumRows(); InitBuffers(); multiplicator = CGSolver::DefaultMultiplicator; multiplicatorData = (void*)A; invDiagonal = NULL; }
StVKReducedStiffnessMatrix::StVKReducedStiffnessMatrix(char * filename) { FILE * fin = fopen(filename,"rb"); if (!fin) { printf("Error: couldn't read from input stiffness matrix file.\n"); return; } if ((int)(fread(&r,sizeof(int),1,fin)) < 1) { printf("Error: couldn't read from input stiffness matrix file.\n"); return; } r2 = r * r; if ((int)(fread(&linearSize,sizeof(int),1,fin)) < 1) { printf("Error: couldn't read from input stiffness matrix file.\n"); return; } if ((int)(fread(&quadraticSize,sizeof(int),1,fin)) < 1) { printf("Error: couldn't read from input stiffness matrix file.\n"); return; } freeCoef_ = (double*) malloc (sizeof(double) * r*(r+1)/2); if ((int)(fread(freeCoef_,sizeof(double),r*(r+1)/2,fin)) < r*(r+1)/2) { printf("Error: couldn't read from input stiffness matrix file.\n"); return; } linearCoef_ = (double*) malloc (sizeof(double) * r*(r+1)/2 * linearSize); if ((int)(fread(linearCoef_,sizeof(double),r*(r+1)/2*linearSize,fin)) < r*(r+1)/2*linearSize) { printf("Error: couldn't read from input stiffness matrix file.\n"); return; } quadraticCoef_ = (double*) malloc (sizeof(double) * r*(r+1)/2 * quadraticSize); if ((int)(fread(quadraticCoef_,sizeof(double),r*(r+1)/2*quadraticSize,fin)) < r*(r+1)/2*quadraticSize) { printf("Error: couldn't read from input stiffness matrix file.\n"); return; } fclose(fin); InitBuffers(); }
SphereMesh::SphereMesh(ID3D11Device* device, WCHAR* textureFilename, int resolution) { m_resolution = resolution; // Initialize the vertex and index buffer that hold the geometry for the triangle. InitBuffers(device); // Load the texture for this model. LoadTexture(device, textureFilename); }
bool VAAPIContext::CreateBuffers(void) { bool ok = true; CREATE_CHECK(!m_size.isEmpty(), "Invalid size"); CREATE_CHECK(InitBuffers(), "Failed to create buffers."); CREATE_CHECK(InitContext(), "Failed to create context"); if (ok) LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Created %1 buffers").arg(m_numSurfaces)); return ok; }
bool ModelClass::Init(ID3D11Device* device, char* filename, WCHAR* modelName) { LoadModel(modelName); bool res = InitBuffers(device); if (!res) { LOG_MSGERR("Problem with init buffers in ModelClass"); } LoadTexture(device, filename); return res; }
/// Sets the number of frames worth of data contained in the shared VBO /// \param numFrames number of frames worth of data that will be held within the VBO /// \note Must not be called between calls to BeginUpdate()/EndUpdate(). void NvSharedVBOGL_Pooled::SetNumFrames(uint32_t numFrames) { // After changing these values, we'll have to create a new buffer, so // ensure we're not in the middle of using any portion of the VBO first Finish(); m_numFrames = numFrames; m_bufferSize = m_dataSize * m_numFrames; // Recreate the VBO with the new settings InitBuffers(); }
/* * InitMsgBase() * * This function opens the msg base(s), inits the msg buffers. */ void InitMsgBase() { SYS_FILE name; makeSysName(name, "ctdlmsg.sys", &cfg.msgArea); openFile(name, &msgfl); if (cfg.BoolFlags.mirror) { makeSysName(name, "ctdlmsg.sys", &cfg.msg2Area); openFile(name, &msgfl2); } InitBuffers(); }
StaticMesh::StaticMesh(const std::string& filename, D3D& d3d) : m_filename(filename), m_vertexCount(0), m_indexCount(0), m_vertexBuffer(0), m_indexBuffer(0), m_modelData(), m_modelDataTanBin(), m_includeTanBin(false) { LoadObj(filename); InitBuffers(d3d); }
WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { m_Parent = parent; m_RecreateToolbar = FALSE; m_AliasLocation = -1; m_CurrentFieldId = 0; InitBuffers(); Create(parent, id, caption, pos, size, style); SetTitle(m_Title); }
StVKReducedHessianTensor::StVKReducedHessianTensor(const char * filename) { FILE * fin = fopen(filename,"rb"); if (!fin) { printf("Error: couldn't read from input Hessian tensor file.\n"); return; } if ((int)(fread(&r,sizeof(int),1,fin)) < 1) { printf("Error: couldn't read from input Hessian tensor file.\n"); return; } r2 = r * r; if ((int)(fread(&linearSize,sizeof(int),1,fin)) < 1) { printf("Error: couldn't read from input Hessian tensor file.\n"); return; } if ((int)(fread(&quadraticSize,sizeof(int),1,fin)) < 1) { printf("Error: couldn't read from input Hessian tensor file.\n"); return; } freeCoef_ = (double*) malloc (sizeof(double) * quadraticSize*r); if ((int)(fread(freeCoef_,sizeof(double),quadraticSize*r,fin)) < quadraticSize*r) { printf("Error: couldn't read from input Hessian tensor file.\n"); return; } linearCoef_ = (double*) malloc (sizeof(double) * quadraticSize * r * r); if ((int)(fread(linearCoef_,sizeof(double),quadraticSize*r*r,fin)) < quadraticSize*r*r) { printf("Error: couldn't read from input Hessian tensor file.\n"); return; } fclose(fin); InitBuffers(); }
/// Sets the size of each sub-range contained in the shared VBO /// \param subRangeSize Size, in bytes, of each sub-range that will be held within the VBO /// \note Must not be called between calls to BeginUpdate()/EndUpdate(). void NvSharedVBOGL_Pooled::SetSubRangeSize(uint32_t subRangeSize) { // After changing these values, we'll have to create a new buffer, so // ensure we're not in the middle of using any portion of the VBO first Finish(); m_subRangeSize = subRangeSize; // Round the buffer size up to multiples of 4 bytes m_dataSize = ((m_numSubRanges * m_subRangeSize) + 3) & 0xFFFFFFFC; m_bufferSize = m_dataSize * m_numFrames; // Recreate the VBO with the new settings InitBuffers(); }
StaticMesh::StaticMesh(const std::string& filename, D3D& d3d, bool includeTanBin) : m_filename(filename), m_vertexCount(0), m_indexCount(0), m_vertexBuffer(0), m_indexBuffer(0), m_modelData(), m_modelDataTanBin(), m_includeTanBin(includeTanBin) { LoadObj(filename); m_includeTanBin ? CalculateModelVectors() : ""; m_includeTanBin ? InitBuffersTanBin(d3d) : InitBuffers(d3d); }
HRESULT Heightmap::init(ID3D11Device* device,ID3D11DeviceContext* deviceContext,Shader* shader,char* heightMapPath, DWORD m, DWORD n, float dx) { HRESULT hr = S_OK; mDevice = device; mDeviceContext = deviceContext; mShader = shader; hr = D3DX11CreateShaderResourceViewFromFile(device,"../Textures/ggrass.dds",0,0,&mAlbedoMap,0); mNumRows = m; mNumCols = n; mCellSpacing = dx; mNumVertices = mNumRows*mNumCols; mNumFaces = (mNumRows-1)*(mNumCols-1)*2; mHeightOffset = -1.5; mHeightScale = 0.25; loadHeightMap(heightMapPath); smooth(); Vertex* vertexArray = new Vertex[mNumVertices]; float halfWidth = (mNumCols-1)*mCellSpacing*0.5f; float halfDepth = (mNumRows-1)*mCellSpacing*0.5f; float du = 1.0f / (mNumCols-1); float dv = 1.0f / (mNumRows-1); for(DWORD i = 0; i < mNumRows; ++i) { float z = halfDepth - i*dx; for(DWORD j = 0; j < mNumCols; ++j) { int vIndex = i*mNumCols+j; vertexArray[vIndex].pos = D3DXVECTOR3(-halfWidth + j*dx, mHeightmap[i*mNumCols+j]-5, z); vertexArray[vIndex].texC = D3DXVECTOR2(j*du, i*dv); vertexArray[vIndex].normal = D3DXVECTOR3(); } } CalculateNormals(vertexArray); InitBuffers(vertexArray); delete vertexArray; return hr; }
Smoke::Smoke(ID3D11Device* device,D3DXVECTOR3 pos,ID3D11DeviceContext* deviceContext): ParticleSystem(device,deviceContext) { mPosition = pos; srand(time(0)); SystemProperties(); InitParticles(); InitBuffers(device); InitTexture(device); }
CGSolver::CGSolver(int numRows_, blackBoxProductType callBackFunction_, void * data_, double * diagonal): numRows(numRows_), multiplicator(callBackFunction_), multiplicatorData(data_), A(NULL) { InitBuffers(); invDiagonal = (double*) malloc (sizeof(double) * numRows); if (diagonal == NULL) { for(int i=0; i<numRows; i++) invDiagonal[i] = 1.0; } else { for(int i=0; i<numRows; i++) invDiagonal[i] = 1.0 / diagonal[i]; } }
void TMagnify::AttachedToWindow() { int32 width, height; fParent->PixelCount(&width, &height); InitBuffers(width, height, fParent->PixelSize(), fParent->ShowGrid()); fThread = spawn_thread(TMagnify::MagnifyTask, "MagnifyTask", B_NORMAL_PRIORITY, this); resume_thread(fThread); SetViewColor(B_TRANSPARENT_32_BIT); MakeFocus(); }
/* find the end marker for the last buffer we will be sending */ static A_UINT16 GetEndMarker(void) { A_UINT8 *pBuffer; BUFFER_PROC_LIST checkList[BUFFER_PROC_LIST_DEPTH]; /* fill up buffers with the normal counting pattern */ InitBuffers(FILL_COUNTING); /* assemble the list we will be sending down */ AssembleBufferList(checkList); /* point to the last 2 bytes of the last buffer */ pBuffer = &(checkList[BUFFER_PROC_LIST_DEPTH - 1].pBuffer[(checkList[BUFFER_PROC_LIST_DEPTH - 1].length) - 2]); /* the last count in the last buffer is the marker */ return (A_UINT16)pBuffer[0] | ((A_UINT16)pBuffer[1] << 8); }
WinEDA_ComponentPropertiesFrame::WinEDA_ComponentPropertiesFrame( WinEDA_SchematicFrame* parent, EDA_SchComponentStruct * cmp, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { m_Parent = parent; m_Cmp = cmp; m_LibEntry = FindLibPart(m_Cmp->m_ChipName.GetData(), wxEmptyString, FIND_ROOT); InitBuffers(); Create(parent, id, caption, pos, size, style); if ( m_LibEntry == NULL ) { SetTitle(_("Component properties (Not found in lib)")); } }