Hey Guys,
We all know that Texture resources are normally swizzled in GPU memory for better cache hit rate, since normally we read texture with neighbor data. In order to see how much this would impact the performance, I write a volume rendering program to profile it.
The program is in DX12, and I modified the Microsoft MiniEngine to build this demo based on it and added GPU profiler and ImGUI. If you run it in Profile and Debug build you should see GPU perf graph on top of the window which timed each GPU tasks. The scene is simple: A dynamic volumetric cube is updated and rendered while it is rotating constantly. every frame the volumetric cube content is updated through a compute shader, and then rendered using raycasting algorithm running on pixel shader. The GUI give you the ability to switch between Typedbuffer volume, StructuredBuffer volume and Texture3D volume each effectively have 4 32bit data for every voxel. For detail information you could look through the code:
https://github.com/pengliu916/Texture3D_StructuredBuffer.git
The result I got is strange:
when the virtual camera is far enough, everything works as expected: StructuredBuffer/TypedBuffer volume have huge variance render time as the cube keeps rotating (since volume data is not swizzled, from some point of view, cache hit rate may be very bad) Texture3D volume render time is almost constant, and always faster than StructuredBuffer/TypedBuffer(which is as expected).
The weird thing is when virtual camera get close to volume, StructuredBuffer/TypedBuffer volume render time still varying, Texture3D volume render time still very stable, but it get much slower as camera get close to volume. Please see this video for the result:
I can't understand why Texture3D volume render time will be much slower than StructuredBuffer/TypedBuffer when camera get close. It will be greatly appreciated if someone could run this test to confirm this is not related to my hardware, and provide some insights why this may happen this way.
Thanks
Peng