Skip to main content
added 263 characters in body
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

From the book Introduction to 3D Game Programming with DirectX10:

 // Update the vertex buffer with the new solution. Vertex* v = 0;
 HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));
 
 for(DWORD i = 0; i < mNumVertices; ++i) {
     v[i].pos = mCurrSolution[i];
     v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }
 
 mVB->Unmap();

The ID3D10Buffer::Unmap function must be called when you are done updating the buffer. The argument D3D10_MAP_WRITE_DISCARD passed into the first parameter of the Map function instructs the hardware to discard the buffer and return a pointer to a newly allocated buffer; this prevents the hardware from stalling by allowing the hardware to continue rendering from the discarded buffer while we write to the newly allocated buffer.

The bold text says that it's supposed to render while we are writing to the buffer. Doesn't that mean that the Draw() call should happen right after we called the Map() function?

If not, why not?

EDIT:

A second question about dynamic vbuffers: When we don't only want to change the vertices inside the buffer, but we also want to create additional vertices, would it be more performance-friendly to just create a static buffer and recreate the buffer?

From the book Introduction to 3D Game Programming with DirectX10:

 // Update the vertex buffer with the new solution. Vertex* v = 0;
 HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));
 
 for(DWORD i = 0; i < mNumVertices; ++i) {
     v[i].pos = mCurrSolution[i];
     v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }
 
 mVB->Unmap();

The ID3D10Buffer::Unmap function must be called when you are done updating the buffer. The argument D3D10_MAP_WRITE_DISCARD passed into the first parameter of the Map function instructs the hardware to discard the buffer and return a pointer to a newly allocated buffer; this prevents the hardware from stalling by allowing the hardware to continue rendering from the discarded buffer while we write to the newly allocated buffer.

The bold text says that it's supposed to render while we are writing to the buffer. Doesn't that mean that the Draw() call should happen right after we called the Map() function?

If not, why not?

From the book Introduction to 3D Game Programming with DirectX10:

 // Update the vertex buffer with the new solution. Vertex* v = 0;
 HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));
 
 for(DWORD i = 0; i < mNumVertices; ++i) {
     v[i].pos = mCurrSolution[i];
     v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }
 
 mVB->Unmap();

The ID3D10Buffer::Unmap function must be called when you are done updating the buffer. The argument D3D10_MAP_WRITE_DISCARD passed into the first parameter of the Map function instructs the hardware to discard the buffer and return a pointer to a newly allocated buffer; this prevents the hardware from stalling by allowing the hardware to continue rendering from the discarded buffer while we write to the newly allocated buffer.

The bold text says that it's supposed to render while we are writing to the buffer. Doesn't that mean that the Draw() call should happen right after we called the Map() function?

If not, why not?

EDIT:

A second question about dynamic vbuffers: When we don't only want to change the vertices inside the buffer, but we also want to create additional vertices, would it be more performance-friendly to just create a static buffer and recreate the buffer?

Rollback to Revision 2
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

fromFrom the book "Introduction to 3D Game Programming with DirectX10"Introduction to 3D Game Programming with DirectX10:

 // Update the vertex buffer with the new solution. Vertex* v = 0;
 HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));
 
 for(DWORD i = 0; i < mNumVertices; ++i) {
     v[i].pos = mCurrSolution[i];
     v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }
 
 mVB->Unmap();

// Update the vertex buffer with the new solution. Vertex* v = 0; HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));

for(DWORD i = 0; i < mNumVertices; ++i) { v[i].pos = mCurrSolution[i]; v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }

mVB->Unmap();

The ID3D10Buffer::UnmapID3D10Buffer::Unmap function must be called when you are done updating the buffer. The argument D3D10_MAP_WRITE_DISCARDD3D10_MAP_WRITE_DISCARD passed into the first parameter of the Map function instructs the hardware to discard the buffer and return a pointer to a newly allocated buffer; this prevents the hardware from stalling by allowing the hardware to continue rendering from the discarded buffer while we write to the newly allocated buffer.

The bold text says that it's supposed to render while we are writing to the buffer. Doesn't that mean that the Draw() call should happen right after we called the Map() function?

If not, why not?

EDIT: a second question about dynamic vbuffers: When we don't only want to change the vertices inside the buffer, but we also want to create additional vertices, would it be more performance-friendly to just create a static buffer and recreate the buffer?

from the book "Introduction to 3D Game Programming with DirectX10":

// Update the vertex buffer with the new solution. Vertex* v = 0; HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));

for(DWORD i = 0; i < mNumVertices; ++i) { v[i].pos = mCurrSolution[i]; v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }

mVB->Unmap();

The ID3D10Buffer::Unmap function must be called when you are done updating the buffer. The argument D3D10_MAP_WRITE_DISCARD passed into the first parameter of the Map function instructs the hardware to discard the buffer and return a pointer to a newly allocated buffer; this prevents the hardware from stalling by allowing the hardware to continue rendering from the discarded buffer while we write to the newly allocated buffer.

The bold text says that it's supposed to render while we are writing to the buffer. Doesn't that mean that the Draw() call should happen right after we called the Map() function?

If not, why not?

EDIT: a second question about dynamic vbuffers: When we don't only want to change the vertices inside the buffer, but we also want to create additional vertices, would it be more performance-friendly to just create a static buffer and recreate the buffer?

From the book Introduction to 3D Game Programming with DirectX10:

 // Update the vertex buffer with the new solution. Vertex* v = 0;
 HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));
 
 for(DWORD i = 0; i < mNumVertices; ++i) {
     v[i].pos = mCurrSolution[i];
     v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }
 
 mVB->Unmap();

The ID3D10Buffer::Unmap function must be called when you are done updating the buffer. The argument D3D10_MAP_WRITE_DISCARD passed into the first parameter of the Map function instructs the hardware to discard the buffer and return a pointer to a newly allocated buffer; this prevents the hardware from stalling by allowing the hardware to continue rendering from the discarded buffer while we write to the newly allocated buffer.

The bold text says that it's supposed to render while we are writing to the buffer. Doesn't that mean that the Draw() call should happen right after we called the Map() function?

If not, why not?

added 259 characters in body; edited title
Source Link
xcrypt
  • 498
  • 1
  • 8
  • 24

Fromfrom the book Introduction to 3D Game Programming with DirectX10"Introduction to 3D Game Programming with DirectX10":

 // Update the vertex buffer with the new solution. Vertex* v = 0;
 HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));
 
 for(DWORD i = 0; i < mNumVertices; ++i) {
     v[i].pos = mCurrSolution[i];
     v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }
 
 mVB->Unmap();

The// Update the vertex buffer with the new solution. Vertex* v = 0; HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, ID3D10Buffer::Unmap(void**)&v ));

for(DWORD i = 0; i < mNumVertices; ++i) { v[i].pos = mCurrSolution[i]; v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }

mVB->Unmap();

The ID3D10Buffer::Unmap function must be called when you are done updating the buffer. The argument D3D10_MAP_WRITE_DISCARDD3D10_MAP_WRITE_DISCARD passed into the first parameter of the Map function instructs the hardware to discard the buffer and return a pointer to a newly allocated buffer; this prevents the hardware from stalling by allowing the hardware to continue rendering from the discarded buffer while we write to the newly allocated buffer.

The bold text says that it's supposed to render while we are writing to the buffer. Doesn't that mean that the Draw() call should happen right after we called the Map() function?

If not, why not?

EDIT: a second question about dynamic vbuffers: When we don't only want to change the vertices inside the buffer, but we also want to create additional vertices, would it be more performance-friendly to just create a static buffer and recreate the buffer?

From the book Introduction to 3D Game Programming with DirectX10:

 // Update the vertex buffer with the new solution. Vertex* v = 0;
 HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));
 
 for(DWORD i = 0; i < mNumVertices; ++i) {
     v[i].pos = mCurrSolution[i];
     v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }
 
 mVB->Unmap();

The ID3D10Buffer::Unmap function must be called when you are done updating the buffer. The argument D3D10_MAP_WRITE_DISCARD passed into the first parameter of the Map function instructs the hardware to discard the buffer and return a pointer to a newly allocated buffer; this prevents the hardware from stalling by allowing the hardware to continue rendering from the discarded buffer while we write to the newly allocated buffer.

The bold text says that it's supposed to render while we are writing to the buffer. Doesn't that mean that the Draw() call should happen right after we called the Map() function?

If not, why not?

from the book "Introduction to 3D Game Programming with DirectX10":

// Update the vertex buffer with the new solution. Vertex* v = 0; HR(mVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&v ));

for(DWORD i = 0; i < mNumVertices; ++i) { v[i].pos = mCurrSolution[i]; v[i].color = D3DXCOLOR(0.0f, 0.0f, 0.0f, 1.0f); }

mVB->Unmap();

The ID3D10Buffer::Unmap function must be called when you are done updating the buffer. The argument D3D10_MAP_WRITE_DISCARD passed into the first parameter of the Map function instructs the hardware to discard the buffer and return a pointer to a newly allocated buffer; this prevents the hardware from stalling by allowing the hardware to continue rendering from the discarded buffer while we write to the newly allocated buffer.

The bold text says that it's supposed to render while we are writing to the buffer. Doesn't that mean that the Draw() call should happen right after we called the Map() function?

If not, why not?

EDIT: a second question about dynamic vbuffers: When we don't only want to change the vertices inside the buffer, but we also want to create additional vertices, would it be more performance-friendly to just create a static buffer and recreate the buffer?

added 30 characters in body; edited title
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276
Loading
Source Link
xcrypt
  • 498
  • 1
  • 8
  • 24
Loading