سؤال

I have some well known steps in my program:

CreateBuffer

Create..View

CSSet..Views

Dispatch

At which step is the data copied to the GPU?

هل كانت مفيدة؟

المحلول

The reason they down-voted it is because it seems as if you didn't put any effort into a little Google search.

Answer: DirectX usually transfers data from system memory into video memory when the creation methods are called. An example of a creation method is "ID3D11Device::CreateBuffer". This method requires a pointer to the memory location of where the data is so it can be copied from system RAM to video RAM. However, if the pointer that is passed into is a null pointer then it just sets the amount of space to the side so you can copy it later.

Example:

If you create a Dynamic Vertex buffer and you don't pass the data in at first then you will have to use map/unmap to copy the data into video memory.

// Fill in a buffer description.
  D3D11_BUFFER_DESC bufferDesc;
  bufferDesc.Usage            = D3D11_USAGE_DYNAMIC;
  bufferDesc.ByteWidth        = sizeof(Vertex_dynamic) * m_iHowManyVertices;
  bufferDesc.BindFlags        = D3D11_BIND_VERTEX_BUFFER;
  bufferDesc.CPUAccessFlags   = D3D11_CPU_ACCESS_WRITE;
  bufferDesc.MiscFlags        = 0;
  bufferDesc.StructureByteStride = NULL;

  // Fill in the subresource data.
  D3D11_SUBRESOURCE_DATA InitData;
  InitData.pSysMem = &_vData[0];
  InitData.SysMemPitch = NULL;
  InitData.SysMemSlicePitch = NULL;

  // Create the vertex buffer.
/*Data is being copyed right now*/
 m_pDxDevice->CreateBuffer(&bufferDesc, &InitData, &m_pDxVertexBuffer_PiecePos);

نصائح أخرى

DirectX manages the memory for you and the data is copied to the GPU when it needs to be.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top