I'm trying to create a system where I can instance a quad to the screen, however I've run into a problem. Like I said, I'm trying to instance the quad, so I'm trying to use the same geometry several times, and I'm trying to do it in one draw call. The issue is, I want some quads to use different textures, but I can't figure out how to get the data into a sampler so I can use it in the pixel shader. I figured that since we can simply pass in the 4 bytes of our IDirect3DTexture9* to set the global texture, I can do so when passing in my dynamic buffer. (Which also stores each objects world matrix and UV data) Now that I'm sending the data, I can't figure how to get it into the sampler, and I really want to assume that it's simply not possible. Is there any way I could achieve this?
With D3D9 you can't use a texture array (which otherwise would have been my recommendation) so I'd suggest that you put your textures into a texture atlas instead. That can be ideal if you're drawing sprites or GUI items.
If that's not an option for you (e.g. you may need mipmapped or repeated textures), you could potentially call SetTexture with a different Stage for each texture you wish to use (SM3 will allow you up to 16 simultaneous textures), then add a per-instance attribute to your vertex declaration identifying the Stage to read from in your shader. That's potentially a bit messier, but it can work.