Hello all
In my application I am having the setup that I have terrain consisting or larger tiles which are divided into 16x16 chunks. The tiles define all the textures that can be used by the chunks and each chunk can select a maximum of 4 textures from that list. A tile is limited to a total of 64 unique textures. Until now I have been setting up the 4 textures for each chunk in each frame using `PSSetTextures` with the 4 textures. While profiling I could notice that a lot of performance is actually wasted swapping these textures around. Now I had the idea that since 64 textures is much less than the 128 from `D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT` I could bind all of them at the beginning of rendering a tile and then just add a uint4 with the actual indices when rendering a chunk and index the 64 textures array. Now this doesnt work in D3D11, it would in D3D12 I think.
So the other obvious option would be to use a Texture2DArray. It looks ideal however when looking through examples I can see one major issue for me. Realistically tiles have less than 10 textures and there is very small variation between different tiles textures. So it would be very inefficient to reload the same textures over and over again just because the array of textures between two tiles differs in 1 texture (right now they are all cached and only loaded once).
So I am wondering, is there an option to have some kind of caching between texture arrays? Can I reuse the same texture in multiple arrays? Are there other options for my use case?
Thank you very much in advance and best regards
Cromon