Sample a Texture2D with the CPU
#1 Members - Reputation: 263
Posted 13 June 2012 - 07:03 AM
Unfortunately I can't find any way of sampling a Texture2D outside of HLSL or using Texture2D.SaveToStream() and skipping through to the pixels I want manually.
Is there a simpler way of doing it? Something similar to HLSL's Texture2D.Sample(sampler,coords) or am I going to have to wade through the data stream?
Thanks
PhD student working on medical imaging at the University of Southampton.
Enjoyer of games, films, books and cider.
#2 Members - Reputation: 3828
Posted 13 June 2012 - 09:23 AM
BUT.
Are you really quite certain about the "I don't want to use the GPU as it's already very busy doing other things" part? Chances are that it's nowhere near as busy as you think it is, and even if so, the bottleneck on your program from creating procedural textures at runtime on the CPU (and then having to upload them to the GPU as dynamic texture resources) is very likely going to be FAR higher than doing so on the GPU.
In other words you're talking about something in the region of accepting a 100% performance overhead on the CPU side (especially if the CPU needs to block while uploading one of those textures) in exchange for something like a 5% or 10% performance saving on the GPU. That seems like it's the wrong way around to me.
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
#3 Members - Reputation: 263
Posted 13 June 2012 - 01:08 PM
PhD student working on medical imaging at the University of Southampton.
Enjoyer of games, films, books and cider.
#4 Members - Reputation: 515
Posted 14 June 2012 - 02:02 AM
i mean, the gpu have like 1k cores, Or more/less depending on chip. but it´s far more than 8 cores.
So i have to agree with what mhagain said, it sounds wrong to do it on the cpu.
you could have the cpu to calculate what the gpu should do on the other thread but not build the texture itself.
#5 Members - Reputation: 263
Posted 14 June 2012 - 03:58 AM
PhD student working on medical imaging at the University of Southampton.
Enjoyer of games, films, books and cider.
#6 Members - Reputation: 515
Posted 14 June 2012 - 05:32 AM
That, Sir, is a excellent approach! and make sure to post the results!Hmm I see your point, I'll do a GPU implementation for now then and when it comes to optimization later I'll write up a CPU implementation and test them side by side.
Edited by Tordin, 14 June 2012 - 05:33 AM.






