Jump to content

  • Log In with Google      Sign In   
  • Create Account


Fastest method to update video to texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Headkaze   Members   -  Reputation: 583

Like
0Likes
Like

Posted 15 November 2012 - 09:38 PM

I have a need to upload video frames to a texture and I have seen two different methods to do this. What I would like to know is which is the fastest method.

Method #1
- hr = m_pDevice->CreateTexture(m_width, m_height, 0, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pTexture, NULL);
- hr = m_pTexture->LockRect(0, &d3dlr, NULL, D3DLOCK_DISCARD);
- Write to d3dlr.pBits;
- m_pTexture->UnlockRect(0);

Method #2
- hr = pDevice->CreateTexture(m_width, m_height, 0, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &m_memTexture,NULL);
- hr = pDevice->CreateTexture(m_width, m_height, 0, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_texture,NULL);
- hr = m_memTexture->LockRect(0, &d3dRect, NULL, D3DLOCK_DISCARD | D3DLOCK_DONOTWAIT);
- Write to d3dlr.pBits;
- hr = m_memTexture->UnlockRect(0);
- hr = pDevice->UpdateTexture(m_memTexture, m_texture);

Edited by Headkaze, 15 November 2012 - 09:41 PM.


Sponsor:

#2 Bacterius   Crossbones+   -  Reputation: 8318

Like
0Likes
Like

Posted 16 November 2012 - 12:10 AM

The difference between the two is that the first one directly locks the texture in GPU texture memory and writes there, whereas the second one creates a temporary texture in system memory, writes there, uploads it to the GPU and performs the copy GPU-side. I'm pretty sure both approaches use DMA ultimately to push the new texture to the GPU (in the first method, the transfer would occur upon UnlockRect, and in the second one, at UpdateTexture), so I don't think it'd make a difference. The first one might be a bit faster, but drivers are pretty smart nowadays.

But you should try and benchmark it just to be sure.

Edited by Bacterius, 16 November 2012 - 12:11 AM.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#3 KingofNoobs   Members   -  Reputation: 301

Like
0Likes
Like

Posted 16 November 2012 - 11:07 AM

Is this D3D9? I don't remember a LockRect() in D3D11.

Edited by KingofNoobs, 16 November 2012 - 11:08 AM.

I wonder as I wander...

http://www.davesgameoflife.com


#4 Headkaze   Members   -  Reputation: 583

Like
0Likes
Like

Posted 16 November 2012 - 06:22 PM

But you should try and benchmark it just to be sure.


I agree. Has anyone else performed any benchmarks using these two methods?

Is this D3D9? I don't remember a LockRect() in D3D11.


Yes, as you can see I tagged my post with D3D9

Edited by Headkaze, 16 November 2012 - 06:24 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS