First, your direct question:
You can technically set the pixels in the texture. To do this, you will need to use LockRect and the UnlockRect API.
In the context of D3D, “locking” generally refers to transferring a resource from the GPU memory to system memory (thereby disabling its participation in rendering operations). After locking, you can change the filled buffer as you wish, and then unlock it - that is, transfer the changed data back to the GPU. Locking was generally considered a very expensive operation, but since PCIe 2.0 , this is probably not the main problem. You can also specify a small (even 1-pixel) RECT as the second LockRect argument, thereby requiring data transfer with a small amount of data, and we hope that the driver is really smart enough to transmit exactly that (I know that the fact is that in the old nVidia drivers it wasn’t).
A more efficient (and with code) way to achieve this, indeed, never leaves the GPU. If you create your texture as a RenderTarget (that is, specify D3DUSAGE_RENDERTARGET as use ), you could set it as the destination of the pipeline before making any call calls and write a shader (possibly passing parameters ) to paint your pixels. This use of rendering targets is considered standard, and you should be able to find a lot of code samples, but if you are not already experiencing performance issues, I would say that this is an excess for one 2D billboard.
NTN.
source share