Repository navigation
Conversation
…HADER-423) Every PhysicalStorageBuffer address the generator builds is one idiom: widen a dword, shift the high word by 32, OR, add or subtract, AND, narrow or shift right by 32, compare two such values, convert to a pointer. lower_addr64 runs on the assembled module: when a shader's only 64-bit integers are that idiom, each value becomes a (low, high) pair of uints with OpIAddCarry / OpISubBorrow into the high word, compares go high word first, and the pair is a uvec2 bitcast to the pointer (as GL_EXT_buffer_reference_uvec2). The module drops OpCapability Int64, so index.json stops listing shaderInt64 for it; devices with buffer device addresses but no shaderInt64 (Intel) can run those modules. A shader with any other 64-bit integer use keeps Int64. --int64-addresses opts out. spirv_mini_interp learns the uint-pair-to-pointer bitcast. Tests: tests/semantic/test_addr64_lowering.py (both forms read the same word with a plain sum, a low-word carry and a 64-bit wrap; dropping the carry is caught; a 64-bit data op keeps Int64). run_gpu_tests.py: 190 shaders pass spirv-val; RTX 5070 Ti 139/185 native, 170/185 emulated; RDNA2 gfx1036 iGPU 170/185; 0 failures. 103 of the 117 shaders that touch memory no longer declare Int64. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Independent Intel + NVIDIA verification at Windows 11 Pro 26300; Intel UHD 31.0.101.4146, shaderInt64 absent; NVIDIA RTX 3050 6GB Laptop 617.14 / 32.0.16.1714. MSVC 19.44.35230, SDK NuGet 10.0.26100.9457 (include/lib directories named 10.0.26100.0), Vulkan headers 1.4.363, native AMDGPU LLVM 23.1.6, SPIRV-Tools 2026.4. Layer and lowering checks
Standalone suite: useful limitations to addressUnmodified
The raw Intel aggregate includes two NVIDIA runs, so it must not be read as 65 Intel passes. I traced the problems rather than treating the table as evidence of a lowering regression:
Also relevant: Scope: synthetic fixtures only, without source changes or game/corpus tests. The core Intel/M3 result is positive; the standalone tool limitations above remain visible for the maintainer's decision. Independent arithmetic/comparison GPU reproducer (synthetic only)Save these two files in the repository root at the reviewed SHA. In a developer PowerShell with Vulkan SDK tools and validation installed: python -I generate_arithmetic_oracle.py --repo .
spirv-as --target-env vulkan1.2 arithmetic-lowered.spvasm -o arithmetic-lowered.spv
spirv-val --target-env vulkan1.2 arithmetic-lowered.spv
cl /nologo /std:c++20 /EHsc /W4 /permissive- /utf-8 /DWIN32_LEAN_AND_MEAN /DNOMINMAX /I runtime/test /I "$env:VULKAN_SDK/Include" arithmetic_gpu.cpp /Fe:arithmetic_gpu.exe
$env:LEONIDA_VK_DEVICE = "Intel"
$env:LEONIDA_VK_VALIDATION = "1"
.\arithmetic_gpu.exe arithmetic-lowered.spv arithmetic-initial.bin arithmetic-expected.binAlso assemble/validate/run generate_arithmetic_oracle.py """Hand-written SPIR-V and Python integer oracle for the PR's actual lowering pass."""
import argparse
from pathlib import Path
import random
import struct
import sys
ROOT = Path(__file__).resolve().parent
p = argparse.ArgumentParser()
p.add_argument("--repo", type=Path, required=True)
TOOLS = p.parse_args().repo.resolve() / "tools"
sys.path.insert(0, str(TOOLS))
import rdna2spirv
M32, M64 = (1 << 32) - 1, (1 << 64) - 1
pairs = [(0, 0), (M32, 1), (M64, 1), (0, 1), (1, M64), (M32, 1 << 32),
(1 << 32, M32), (M64, M64), (1 << 63, (1 << 63) - 1),
(0x12345678FFFFFFFF, 0x1234567800000000), (0x1234567800000000, 0x12345678FFFFFFFF),
(0xFFFFFFFF00000000, 0x100000000), (0x7FFFFFFFFFFFFFFF, 1),
(0x9ABCDEF012345678, 0x76543210FEDCBA98), (0x10FFFFFFF0, 0x200000020), (123, 123)]
rng = random.Random(2463)
while len(pairs) < 512:
a, b = rng.getrandbits(64), rng.getrandbits(64)
if len(pairs) % 4 == 0:
b = (a & (M32 << 32)) | rng.getrandbits(32)
pairs.append((a, b))
initial = [word for a, b in pairs for word in (a & M32, a >> 32, b & M32, b >> 32)]
input_words = len(initial)
initial += [0xCDCDCDCD] * (512 * 20 + 32)
expected = initial.copy()
for i, (a, b) in enumerate(pairs):
values = []
for value in ((a + b) & M64, (a - b) & M64, a & b, a | b, (a << 32) & M64, a >> 32):
values.extend((value & M32, value >> 32))
values += [a & M32] + [int(v) for v in (a < b, a <= b, a > b, a >= b, a == b, a != b)]
expected[input_words + i * 20:input_words + i * 20 + 19] = values
for filename, words in (("arithmetic-initial.bin", initial), ("arithmetic-expected.bin", expected)):
(ROOT / filename).write_bytes(struct.pack("<" + "I" * len(words), *words))
lines = [
"OpCapability Shader", "OpCapability Int64", "OpMemoryModel Logical GLSL450",
'OpEntryPoint GLCompute %main "main" %data %gid', "OpExecutionMode %main LocalSize 32 1 1",
"OpDecorate %gid BuiltIn GlobalInvocationId", "OpDecorate %rarr ArrayStride 4",
"OpMemberDecorate %Data 0 Offset 0", "OpDecorate %Data Block",
"OpDecorate %data DescriptorSet 0", "OpDecorate %data Binding 0",
"%void = OpTypeVoid", "%function = OpTypeFunction %void", "%bool = OpTypeBool",
"%uint = OpTypeInt 32 0", "%ulong = OpTypeInt 64 0", "%long = OpTypeInt 64 1",
"%umul = OpTypeStruct %uint %uint", "%v3uint = OpTypeVector %uint 3",
"%pin = OpTypePointer Input %v3uint", "%rarr = OpTypeRuntimeArray %uint",
"%Data = OpTypeStruct %rarr", "%pdata = OpTypePointer StorageBuffer %Data",
"%pword = OpTypePointer StorageBuffer %uint",
]
lines += [f"%u{v} = OpConstant %uint {v}" for v in sorted(set(range(20)) | {32, input_words})]
lines += ["%z64 = OpConstant %ulong 0", "%s32 = OpConstant %ulong 32",
"%data = OpVariable %pdata StorageBuffer", "%gid = OpVariable %pin Input",
"%main = OpFunction %void None %function", "%entry = OpLabel",
"%id = OpLoad %v3uint %gid", "%idx = OpCompositeExtract %uint %id 0",
"%ib = OpIMul %uint %idx %u4"]
for j in range(4):
lines += [f"%ii{j} = OpIAdd %uint %ib %u{j}", f"%ip{j} = OpAccessChain %pword %data %u0 %ii{j}",
f"%word{j} = OpLoad %uint %ip{j}", f"%wide{j} = OpUConvert %ulong %word{j}"]
lines += ["%ah = OpShiftLeftLogical %ulong %wide1 %s32", "%av = OpBitwiseOr %ulong %ah %wide0",
"%bh = OpShiftLeftLogical %ulong %wide3 %s32", "%bv = OpBitwiseOr %ulong %bh %wide2",
"%ob = OpIMul %uint %idx %u20", f"%obase = OpIAdd %uint %ob %u{input_words}"]
# u20 is used for the stride, declared before the entry point.
at = lines.index("%z64 = OpConstant %ulong 0")
lines.insert(at, "%u20 = OpConstant %uint 20")
results = []
for name, op, rhs in (("add", "OpIAdd", "%bv"), ("sub", "OpISub", "%bv"),
("and", "OpBitwiseAnd", "%bv"), ("or", "OpBitwiseOr", "%bv"),
("left", "OpShiftLeftLogical", "%s32"), ("right", "OpShiftRightLogical", "%s32")):
lines += [f"%{name} = {op} %ulong %av {rhs}", f"%{name}_lo = OpUConvert %uint %{name}",
f"%{name}_shifted = OpShiftRightLogical %ulong %{name} %s32",
f"%{name}_hi = OpUConvert %uint %{name}_shifted"]
results += [f"%{name}_lo", f"%{name}_hi"]
lines.append("%narrow = OpUConvert %uint %av")
results.append("%narrow")
for name, op in (("lt", "OpULessThan"), ("le", "OpULessThanEqual"), ("gt", "OpUGreaterThan"),
("ge", "OpUGreaterThanEqual"), ("eq", "OpIEqual"), ("ne", "OpINotEqual")):
lines += [f"%{name} = {op} %bool %av %bv", f"%{name}_word = OpSelect %uint %{name} %u1 %u0"]
results.append(f"%{name}_word")
for j, result in enumerate(results):
lines += [f"%oi{j} = OpIAdd %uint %obase %u{j}", f"%op{j} = OpAccessChain %pword %data %u0 %oi{j}",
f"OpStore %op{j} {result}"]
lines += ["OpReturn", "OpFunctionEnd"]
text = "\n".join(lines) + "\n"
lowered = rdna2spirv.lower_addr64(text)
assert "OpCapability Int64" not in lowered and "OpTypeInt 64" not in lowered
assert rdna2spirv.lower_addr64(lowered) == lowered
(ROOT / "arithmetic-original.spvasm").write_text(text, encoding="utf-8", newline="\n")
(ROOT / "arithmetic-lowered.spvasm").write_text(lowered, encoding="utf-8", newline="\n")
# Corrupt the borrow specifically; this tests the high-word subtraction edge cases.
import re
bad, count = re.subn(r"(OpISub %uint %a64_\d+g) %a64_\d+c", r"\1 %a64c_0", lowered)
assert count == 1
(ROOT / "arithmetic-bad-borrow.spvasm").write_text(bad, encoding="utf-8", newline="\n")
print(f"Generated {len(pairs)} input pairs, 19 arithmetic/comparison words each; independent Python integer oracle.")arithmetic_gpu.cpp // Independent GPU word oracle for the real PR lowering pass. Synthetic inputs only. AI-assisted.
#include "vk_test_device.h"
#include <fstream>
#include <vector>
#include <cstdint>
#include <cstring>
#define EXPECT(c) do { if (!(c)) { std::printf("failure at line %d\n", __LINE__); return 1; } } while (0)
int main(int argc, char** argv) {
EXPECT(argc == 4);
std::ifstream input(argv[1], std::ios::binary | std::ios::ate);
const auto bytes = input.tellg();
EXPECT(bytes > 0 && bytes % 4 == 0);
std::vector<std::uint32_t> code(std::size_t(bytes) / 4);
input.seekg(0);
EXPECT(bool(input.read(reinterpret_cast<char*>(code.data()), bytes)));
auto read_words = [](const char* path) {
std::ifstream f(path, std::ios::binary | std::ios::ate);
const auto n = f.tellg();
if (n <= 0 || n % 4) return std::vector<std::uint32_t>{};
std::vector<std::uint32_t> data(std::size_t(n) / 4);
f.seekg(0);
if (!f.read(reinterpret_cast<char*>(data.data()), n)) data.clear();
return data;
};
const auto initial = read_words(argv[2]), expected = read_words(argv[3]);
EXPECT(!initial.empty() && initial.size() == expected.size());
const auto output_bytes = initial.size() * sizeof(std::uint32_t);
bool needs_int64 = false;
for (std::size_t at = 5; at < code.size();) {
const auto words = code[at] >> 16, op = code[at] & 0xffff;
EXPECT(words && at + words <= code.size());
needs_int64 |= op == 17 && words == 2 && code[at + 1] == 11;
at += words;
}
vktest::Device d;
const auto state = d.initialize();
if (state == vktest::DeviceStatus::unavailable) return 77;
EXPECT(state == vktest::DeviceStatus::ready);
if (needs_int64 && !d.enabled.shaderInt64) {
std::puts("SKIP: original module needs shaderInt64");
return 77;
}
VkShaderModuleCreateInfo si{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO};
si.codeSize = code.size() * 4; si.pCode = code.data();
VkShaderModule shader{};
EXPECT(d.fn<PFN_vkCreateShaderModule>("vkCreateShaderModule")(d.device, &si, nullptr, &shader) == VK_SUCCESS);
VkDescriptorSetLayoutBinding binding{0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_COMPUTE_BIT};
VkDescriptorSetLayoutCreateInfo di{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO};
di.bindingCount = 1; di.pBindings = &binding;
VkDescriptorSetLayout descriptor_layout{};
EXPECT(d.fn<PFN_vkCreateDescriptorSetLayout>("vkCreateDescriptorSetLayout")(d.device, &di, nullptr, &descriptor_layout) == VK_SUCCESS);
VkPipelineLayoutCreateInfo li{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO};
li.setLayoutCount = 1; li.pSetLayouts = &descriptor_layout;
VkPipelineLayout layout{};
EXPECT(d.fn<PFN_vkCreatePipelineLayout>("vkCreatePipelineLayout")(d.device, &li, nullptr, &layout) == VK_SUCCESS);
VkComputePipelineCreateInfo pi{VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO};
pi.stage = {VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, shader, "main"};
pi.layout = layout;
VkPipeline pipeline{};
EXPECT(d.fn<PFN_vkCreateComputePipelines>("vkCreateComputePipelines")(d.device, VK_NULL_HANDLE, 1, &pi, nullptr, &pipeline) == VK_SUCCESS);
VkDescriptorPoolSize size{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1};
VkDescriptorPoolCreateInfo pool_info{VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO};
pool_info.maxSets = 1; pool_info.poolSizeCount = 1; pool_info.pPoolSizes = &size;
VkDescriptorPool pool{};
EXPECT(d.fn<PFN_vkCreateDescriptorPool>("vkCreateDescriptorPool")(d.device, &pool_info, nullptr, &pool) == VK_SUCCESS);
VkDescriptorSetAllocateInfo allocation{VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO};
allocation.descriptorPool = pool; allocation.descriptorSetCount = 1; allocation.pSetLayouts = &descriptor_layout;
VkDescriptorSet set{};
EXPECT(d.fn<PFN_vkAllocateDescriptorSets>("vkAllocateDescriptorSets")(d.device, &allocation, &set) == VK_SUCCESS);
void* mapped{};
const auto output = d.buffer(output_bytes, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, &mapped);
EXPECT(output && mapped);
std::memcpy(mapped, initial.data(), output_bytes);
VkDescriptorBufferInfo buffer_info{output, 0, output_bytes};
VkWriteDescriptorSet write{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET};
write.dstSet = set; write.descriptorCount = 1; write.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; write.pBufferInfo = &buffer_info;
d.fn<PFN_vkUpdateDescriptorSets>("vkUpdateDescriptorSets")(d.device, 1, &write, 0, nullptr);
EXPECT(d.run([&](VkCommandBuffer cb) {
d.fn<PFN_vkCmdBindPipeline>("vkCmdBindPipeline")(cb, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
d.fn<PFN_vkCmdBindDescriptorSets>("vkCmdBindDescriptorSets")(cb, VK_PIPELINE_BIND_POINT_COMPUTE, layout, 0, 1, &set, 0, nullptr);
d.fn<PFN_vkCmdDispatch>("vkCmdDispatch")(cb, 16, 1, 1);
VkBufferMemoryBarrier2 barrier{VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2};
barrier.srcStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT; barrier.srcAccessMask = VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT;
barrier.dstStageMask = VK_PIPELINE_STAGE_2_HOST_BIT; barrier.dstAccessMask = VK_ACCESS_2_HOST_READ_BIT;
barrier.srcQueueFamilyIndex = barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barrier.buffer = output; barrier.size = VK_WHOLE_SIZE;
VkDependencyInfo dependency{VK_STRUCTURE_TYPE_DEPENDENCY_INFO}; dependency.bufferMemoryBarrierCount = 1; dependency.pBufferMemoryBarriers = &barrier;
d.fn<PFN_vkCmdPipelineBarrier2>("vkCmdPipelineBarrier2")(cb, &dependency);
return true;
}));
const auto* words = static_cast<const std::uint32_t*>(mapped);
unsigned failures = 0;
for (std::size_t i = 0; i < expected.size(); ++i) {
if (words[i] != expected[i]) {
if (failures < 4) std::printf("word %zu: got %08x expected %08x\n", i, words[i], expected[i]);
++failures;
}
}
d.fn<PFN_vkDestroyDescriptorPool>("vkDestroyDescriptorPool")(d.device, pool, nullptr);
d.fn<PFN_vkDestroyPipeline>("vkDestroyPipeline")(d.device, pipeline, nullptr);
d.fn<PFN_vkDestroyPipelineLayout>("vkDestroyPipelineLayout")(d.device, layout, nullptr);
d.fn<PFN_vkDestroyDescriptorSetLayout>("vkDestroyDescriptorSetLayout")(d.device, descriptor_layout, nullptr);
d.fn<PFN_vkDestroyShaderModule>("vkDestroyShaderModule")(d.device, shader, nullptr);
std::printf("%zu expected words (512 pairs plus inputs/sentinels): %u mismatches; %u validation errors\n", expected.size(), failures, d.validation_errors());
return failures || d.validation_errors() ? 1 : 0;
} |
|
Arc A770 16 GB run of
The one failure is |
|
Tested c550d53 on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.
No game files. AI-assisted. |
|
Read the pass and ran it end to end on an AMD GPU (Windows 11, RX 7800 XT, gfx1101, driver 32.0.32029.2010, Vulkan 1.4.363, spirv-val 2026.x). Local results
That is exactly check.py's Two things I would want before this merges
Nit: |
|
Supplementary CPU/type review at
Two small review points would improve the final contribution:
The absence of Minimal reproduction of the interpreter source-type gapRun from the repository root, with SPIRV-Tools on PATH. This uses the existing test fixture to make the original input, then gives the vector proper uint64 components so the validation error is specifically the pointer bitcast rather than mismatched constructor types. import sys
from pathlib import Path
import subprocess
sys.path[:0] = [str(Path("tools").resolve()), str(Path("tests/semantic").resolve())]
import test_addr64_lowering as T
heap, base = 0x1_FFFF_FFF0, 0x20
text = T.translate("cs_probe", T.load_program(base))
original = text
text = text.replace("OpCapability Shader", "OpCapability Shader\nOpCapability Int64", 1)
uint_line = next(x for x in text.splitlines() if x.strip() == "%uint = OpTypeInt 32 0")
text = text.replace(uint_line, uint_line +
"\n%probe_ul = OpTypeInt 64 0\n%probe_v2ul = OpTypeVector %probe_ul 2", 1)
for i, line in enumerate(x for x in original.splitlines()
if "OpCompositeConstruct" in x and "%a64_" in x):
w = line.split()
text = text.replace(line,
f"%probe_l{i} = OpUConvert %probe_ul {w[4]}\n"
f"%probe_h{i} = OpUConvert %probe_ul {w[5]}\n"
f"{w[0]} = OpCompositeConstruct %probe_v2ul %probe_l{i} %probe_h{i}")
scratch = Path("runtime/build/review-pointer-width")
scratch.mkdir(parents=True, exist_ok=True)
asm, spv = scratch / "invalid-width.spvasm", scratch / "invalid-width.spv"
asm.write_text(text, encoding="utf-8", newline="\n")
subprocess.run(["spirv-as", "--target-env", "vulkan1.2", str(asm), "-o", str(spv)], check=True)
assert subprocess.run(["spirv-val", "--target-env", "vulkan1.2", str(spv)]).returncode != 0
memory = {(heap + base) & T.M64: T.MAGIC}
assert T.run(text, heap, memory).get(heap & T.M64) == T.MAGIC
print("validator rejects pointer width; interpreter accepts it") |
|
Tested GPUs:
Unit & SPIR-V capability checks:
Standalone GPU suite (
Rebuilt D3D12 translated-shader CTest suite (
Not tested here: a device lacking Synthetic tests only; no game files. AI-assisted. |
|
128-byte SwiftShader integration check of
This verifies the combination on a software device with both constraints. It covers the standalone compute path and uses only synthetic fixtures. AI-assisted. |
|
Independent check at c550d53 on Windows 11, RTX 3060 12 GB, driver 621.14. All six targeted runtime checks passed: translated draw, M2 textured, M2 formats, M3 frame, M3 first pass and M4 compute. run_gpu_tests.py validated all 190 modules in both modes. Native wave32: 139 passed, 46 skipped, 0 failed. Wave64 emulation: 170 passed, 15 skipped, 0 failed. The ms_w64x_ballot case reported failing on Arc A770 matched all 4,096 pixels here in wave64 emulation. AI-assisted testing and write-up. |
|
Tested Runtime and test programs built from this head (MSVC 14.51, Ninja, RelWithDebInfo), native Windows
On the GPU side, 103 of the 193 modules differ from The failure is That looks like the test pinning the old address form. The atomics still go through the dword array element as it intends, so it probably needs to accept the AI-assisted (Claude Code); I checked the results. |
…eck it in the interpreter, docs wording - tests/test_translate.py test_cs_store_packed_atomic_pointers pinned the OpConvertUToPtr form of the atomics' array pointer; it is the uvec2 OpBitcast since lower_addr64 (OpConvertUToPtr with --int64-addresses), so it accepts both (reported by @zneel on ItsNotRexed#2463). - spirv_mini_interp's pointer bitcast checks the source's declared type (a 2-component 32-bit integer vector), not only the runtime tuple, so an invalid 64-bit pair cannot pass the test oracle (@richardsenra). - docs/design.md: the contract row describes the idiom the pass handles (narrowing and the logical shift by 32 included) and what keeps Int64 (@richardsenra). pytest tests/test_translate.py: 526 passed, 2 skipped. tests/semantic: 2,573 OK. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Pushed
|
|
Tested c550d53 on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:
AI-assisted (Claude Code). |
…s, arithmetic shift by 32) A global_* access with a negative instruction offset sign-extends it through a 64-bit signed integer (OpSConvert %long, OpBitcast %ulong) before the add, and a few paths shift a 64-bit value right arithmetically by 32. The pass now lowers those as well: the sign-extended dword is (value, value >> 31 arithmetic), the shift by 32 is (high, high >> 31), and a bitcast between the 64-bit integer types is the same word pair. The rewrite's 32-bit constants are declared once the body is done (they are made while it is rewritten). Review point from @UNYTIX on ItsNotRexed#2463. tests/semantic/test_addr64_lowering.py: three global_load cases with negative and positive offsets read the same word in both forms, and the lowered module has no Int64 or %long. cs_global_neg_offset now runs without Int64 (RDNA2 gfx1036 iGPU: 170/185, 190/190 spirv-val); 13 of the 117 memory-touching test shaders keep Int64 (was 14). tests/semantic 2,573 OK; pytest tests/test_translate.py 526 passed. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Pushed Tested at this head: |
|
Tested 8b38800 on AMD Radeon RX 9070 XT (RDNA4), Adrenalin 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11 build 26300, LLVM 21.1.8, SPIRV-Tools v2026.4.
Needs a rebase that teaches both tests the pair form (or pins (AI-assisted test run.) |
|
Re-tested
The signed-offset results are from the actual freshly translated fixture, with no shader/oracle weakening. Production source is unchanged by this verification. This refresh covers the checks above; I did not rerun the entire standalone GPU suite or the retail corpus at the new head. The suite/helper findings in the earlier review are separate from these positive layer results. |
|
Tested Since this changes the default address lowering, the question is whether the modules it now emits still run. Full
Every buffer, global, texture and descriptor fixture gives the same words with the 32-bit-pair idiom as with Int64. (The PR is Python-only and its base is our Real corpus, shard 0/12 of my own copy (
Tests: Limit, stated plainly: both devices here have AI-assisted. |
|
Tested 65e64c2 on RTX 4080 SUPER (Ada, subgroup 32), NVIDIA 621.24 (Vulkan 1.4.357), Windows 11 Pro build 26300; MSVC 14.44, Vulkan SDK 1.4.363.0,
(I had also run c550d53 and 8b38800 earlier, with the same results.) |
test_buffer_store_format's emission check accepts the uvec2 OpBitcast of the store's address as well as OpConvertUToPtr (--int64-addresses), and test_loop_ballot_barrier's local interpreter turns a (low, high) uint pair bitcast to a PhysicalStorageBuffer pointer into the same "phys" address OpConvertUToPtr gives (its OpBitcast was the identity, so the pair reached OpAccessChain as a list). Both were added to main after this branch's base (reported by @davidesidoti on ItsNotRexed#2463). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
@davidesidoti thanks, both were tests main gained after this branch's base. Main At this head: |
|
Re-tested after the rebase, head
Identical line by line, not just in totals, so the new default (32-bit-pair address) still gives the same words as The AI-assisted. |
…ion: both PC_TAIL_UBO and ADDR_PAIR)
|
Whole-corpus count at
The other 25,511 modules are byte-identical to So on the retail corpus this covers few Intel shaders yet. On a 10% sample (shards 0, 10, 20, 30, 40, 50 of 60: 2,651 modules, 2,585 with Three more rules cover all of it on the sample. I prototyped them on top of
Edit, the whole corpus with the three rules (same head, same settings): 26,501 / 26,503 translate and pass Checks of the prototype: Prototype diff on
|
|
Round 41 landed a flag on the same CLI line ( At this head: |
Claim: #2300 (comment) (new SHADER item, from @richardsenra's finding in #313, #313 (comment))
What
Every PhysicalStorageBuffer address the translator builds is one idiom: widen a dword (
OpUConvert), shift the high word by 32, OR, add or subtract (64-bit constants included), AND a mask, take a word back (narrow, or shift right by 32), sign-extend a dword (the signed offset of aglobal_*access) and shift it right arithmetically by 32; the NUM_RECORDS bound of a buffer access compares two such values. Until now that made every shader that touches memory declareOpCapability Int64, soindex.jsonlistedshaderInt64for it and the runtime required the feature, which Intel's Vulkan drivers don't offer although they havebufferDeviceAddress(#313, #1825'sps_m3_postfailure).lower_addr64(tools/rdna2spirv.py) runs on the assembled module. When a shader's only 64-bit integers are that idiom, each 64-bit value becomes a (low, high) pair of 32-bit words:OpIAddCarry/OpISubBorrowcarry into the high word, a sign-extended dword is (value, value >> 31), compares go high word first, and the pair is built into auvec2and bitcast to the pointer, asGL_EXT_buffer_reference_uvec2does. The module dropsOpCapability Int64(and the unused%ulong/%longtypes and 64-bit constants);PhysicalStorageBufferAddressesand thePhysicalStorageBuffer64memory model stay. A shader with any other 64-bit integer use (64-bit multiplies, shifts by other amounts, a 64-bitOpPhior variable) is left exactly as it was and keepsInt64.--int64-addressesturns the lowering off.tests/semantic/spirv_mini_interp.pylearns the one new form,OpBitcastof two 32-bit words to a PhysicalStorageBuffer pointer.Tests
tests/semantic/test_addr64_lowering.py(new, 7 tests; the seventh:global_loadwith negative and positive offsets reads the same word in both forms, noInt64or%longin the lowered module): the lowered module has noInt64,%ulongorOpConvertUToPtr;--int64-addresseskeeps the old form; both forms read the same word in the interpreter for a plain sum, a low-word carry (heap0x1_FFFF_FFF0+ pointer0x20) and a 64-bit wrap; dropping the carry from the lowered module is caught (negative control); a program withs_lshl_b64keepsInt64and still runs; the pass is idempotent and leaves modules without 64-bit types alone.python -I -m unittest discover -s tests/semantic: 2,574 tests OK (3 skipped);pytest tests/test_translate.py: 526 passed, 2 skippedpython -I scripts/run_gpu_tests.pyon an NVIDIA GeForce RTX 5070 Ti (621.24, Vulkan 1.4.357, Windows 11 26200): 190 shaders translated, 190 passspirv-val; 139/185 passed, 46 skipped (wave64 tests and fixtures run by the d3d12_* tests), 0 failed; withLEONIDA_W64_EMULATE=1: 170/185 passed, 15 skipped, 0 failedLEONIDA_VK_DEVICE="AMD Radeon"on the RDNA2 gfx1036 iGPU (AMD 25.10.34, native wave64): 170/185 passed, 15 skipped, 0 failedInt64(cs_global_neg_offsetincluded, since 65e64c2) and 13 keep it (cs_w32_salu64,cs_oob_tail,cs_bvh*, the typed-format fixtures,cs_smem_soffset_imm,ps_vcc_x2,ps_vcmpx_forms,ps_fnan_*: 64-bit multiplies and shifts by other amounts); all 190 passspirv-val.ctest --test-dir runtime/build -C RelWithDebInfoafter a rebuild (the M2/M3/M4 and translated-draw fixtures are re-translated by the build): 124/124 passed, 8 skipped (game-file and validation-layer tests);d3d12_translated_draw,d3d12_m2_textured,d3d12_m2_formats,d3d12_m3_frame,d3d12_m3_first_passandd3d12_m4_computeall pass with their 12 re-translated shaders, none of which declaresInt64any more (ps_m3_postincluded, the one that failed on Intel in Runtime tests: separate M3 occlusion counting from MRT exports (D3D-209) #1825)docs/design.md: one contract row, "64-bit addresses withoutInt64".Not covered: the retail corpus (no game files here: a count of modules still declaring
Int64at this head from someone with the package would settle how much of it this reaches), and shaders that use 64-bit data arithmetic, which keepInt64as before.History: c550d53 the pass; 8b38800 review fixes (test_translate accepts the pair bitcast, interpreter type check, docs wording); 65e64c2 the signed-offset idiom. Follow-up if wanted: have
make_game.pysave--int64-addressesnext to the translated shaders like its other fallback flags.No game files. AI-assisted (Claude Code); built and tested on the hardware above.
Known:
tests/test_docs_design_rows.pyfails 3 subtests onmain4947579 too (duplicate topic rows in design.md, README.md, testing.md); this PR adds one row and does not change that count.🤖 Generated with Claude Code