Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/gfx1013_compute_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,14 @@ State transfer(const Inst &i, State s, bool wave64, bool graphics, bool heap_win
// Both the saved/written destination and the updated EXEC are numeric mask words.
set(i.dst, {});
set(126, {});
} else if (!graphics && i.enc == Encoding::Sop1 && i.name.size() >= 13 &&
(i.name.substr(i.name.size() - 13) == "_saveexec_b64" ||
i.name.substr(i.name.size() - 11) == "_wrexec_b64")) {
// These instructions also overwrite both EXEC words implicitly.
set(i.dst, {});
set(i.dst + 1, {});
set(126, {});
set(127, {});
} else if (i.name == "s_and_b32" || i.name == "s_lshl_b32") {
const auto a = source(i, i.src[0], s), b = source(i, i.src[1], s);
Symbol out{};
Expand Down
7 changes: 7 additions & 0 deletions tests/cmake/native_exec_symbol_b64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if(TARGET compile_dxil AND EXISTS "${INTAKE_PYTHON}" AND
EXISTS "${DXC_BIN_DIR}/dxcompiler.dll" AND EXISTS "${DXC_BIN_DIR}/dxil.dll")
add_test(NAME native_exec_symbol_b64_controls COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/native_exec_symbol_b64_check.py"
controls "$<TARGET_FILE:compile_dxil>" "${DXC_BIN_DIR}")
set_tests_properties(native_exec_symbol_b64_controls PROPERTIES TIMEOUT 60)
endif()
47 changes: 47 additions & 0 deletions tests/native_exec_symbol_b64_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Reject a sampler word copied from EXEC after a 64-bit implicit write."""
from pathlib import Path
import subprocess
import sys
import tempfile

from native_direct_container_check import comparison_program, compute, words


def program(exec_op=None):
code = comparison_program(dim=5)
sampler_address = code[4]
code[3:5] = [
0x7e2c0500, # v_readfirstlane_b32 s22, v0
0xbe970380, # s_mov_b32 s23, 0
0xbefe04ff, sampler_address, # s_mov_b64 exec, comparison sampler word
*(() if exec_op is None else (exec_op,)),
0xbe84037e, # s_mov_b32 s4, exec_lo
]
return compute(words(*code, 0xbf810000), threads=64, table=True, wave32=False)


def controls(cli, sdk):
with tempfile.TemporaryDirectory() as temp:
work = Path(temp)
for name, exec_op in (
("constant-exec", None),
("saveexec", 0xbe982416), # s_and_saveexec_b64 s[24:25], s[22:23]
("wrexec", 0xbe983a16), # s_andn2_wrexec_b64 s[24:25], s[22:23]
):
source = work / (name + ".cdx")
output = source.with_suffix(".cso")
source.write_bytes(program(exec_op))
result = subprocess.run(
[cli, sdk, work / "cache", "gfx1013-container-cs", source, output],
capture_output=True, text=True,
)
if exec_op is None:
assert result.returncode == 0 and output.read_bytes().startswith(b"DXBC"), (name, result.stderr)
else:
assert result.returncode != 0 and "nonconstant sampler" in result.stderr, (name, result.stderr)
assert not output.exists(), output


if __name__ == "__main__":
mode, cli, sdk = sys.argv[1:]
{"controls": controls}[mode](cli, sdk)
Loading