Vulkan: Fix Namespace Collision Between Shader Resources #112511

Merged
Jeroen Bakker merged 1 commits from Jeroen-Bakker/blender:vulkan/shader-resource-collision into main 2023-09-18 13:41:58 +02:00

1 Commits

Author SHA1 Message Date
Jeroen Bakker ae56788d42 Vulkan: Fix Namespace Collision Between Shader Resources
Previous implemetation had some limitations that were not working
for complex shaders. This limitations included:

* All bindings should be bound to a location < 16.
* Collision could happen when image locations where read that
  overlapped with the texture locations.

This PR replaces the fixed binding locations with a dynamic vector.
When allocating locations for images the image offset is determined
that it is always clear if the requested locations is already
offsetted or not. This is done by ensuring the offset to larger than
the max slot of samplers, but also of image slots.

When using Eevee-next materials the slot numbers can be very high
as the location of the first material texture is set to
`GPU_max_textures_frag()` On current NVIDIA drivers this number is
set to 1K. Images are stored after the textures slots upwards.

In the future driver could set this to MAX_INT which will not work
with the new implementation. This isn't the case at this moment
and perhaps also not realistic. We don't check for this situation yet.
2023-09-18 12:20:30 +02:00