Vulkan: fix guest storage image and render-state handling (#332)

This commit is contained in:
lilp
2026-07-17 20:54:52 -03:00
committed by GitHub
parent b479dc0466
commit c9d018db8e
8 changed files with 806 additions and 147 deletions
@@ -1576,11 +1576,37 @@ public static class Gen5ShaderTranslator
private static bool IsMimgInstruction(string name) =>
name.StartsWith("Image", StringComparison.Ordinal);
public static bool IsImageLoadOperation(string name) =>
name.StartsWith("ImageLoad", StringComparison.Ordinal);
public static bool IsStorageImageOperation(string name) =>
name.StartsWith("ImageLoad", StringComparison.Ordinal) ||
name.StartsWith("ImageStore", StringComparison.Ordinal) ||
name.StartsWith("ImageAtomic", StringComparison.Ordinal);
public static bool RequiresStorageImage(
Gen5ImageBinding binding,
IReadOnlyList<Gen5ImageBinding> stageBindings)
{
if (IsStorageImageOperation(binding.Opcode))
{
return true;
}
if (!IsImageLoadOperation(binding.Opcode))
{
return false;
}
// IMAGE_LOAD itself is read-only and maps naturally to OpImageFetch,
// including for block-compressed textures which Vulkan cannot expose
// as storage images. Keep it as storage only when the same resolved
// descriptor is also written in this shader stage, preserving coherent
// read/write access through one storage-image representation.
return stageBindings.Any(candidate =>
IsStorageImageOperation(candidate.Opcode) &&
binding.ResourceDescriptor.SequenceEqual(candidate.ResourceDescriptor));
}
public static bool IsDataShareAtomic(string name) => name switch
{
"DsAddU32" or "DsSubU32" or "DsIncU32" or "DsDecU32" or