mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 14:48:37 +00:00
Merge pull request #2395 from Matheus Gomes
This commit is contained in:
10
runtime/test/shaders/cs_f64_add.asm
Normal file
10
runtime/test/shaders/cs_f64_add.asm
Normal file
@ -0,0 +1,10 @@
|
||||
; group: 1,1,1
|
||||
; Store binary64 (0.75 + 0.5) * 2 = 2.5 as low/high words: 0x00000000, 0x40040000.
|
||||
v_mov_b32 v0, 0
|
||||
v_mov_b32 v1, 0x3fe80000
|
||||
v_mov_b32 v2, 0
|
||||
v_mov_b32 v3, 0x3fe00000
|
||||
v_add_f64 v[4:5], v[0:1], v[2:3] mul:2
|
||||
v_mov_b32 v6, 0
|
||||
buffer_store_dwordx2 v[4:5], v6, s[0:3], 0 offen
|
||||
s_endpgm
|
||||
@ -153,6 +153,13 @@ int main(int argc, char** argv) {
|
||||
std::fprintf(stderr, "full 64-wide compute subgroups unavailable\n");
|
||||
return 77;
|
||||
}
|
||||
std::ifstream f(argv[1], std::ios::binary);
|
||||
std::vector<char> code((std::istreambuf_iterator<char>(f)), {});
|
||||
const bool needs_float64 = leonida::vk_test::spirv_declares_capability(code.data(), code.size(), 10); // Float64
|
||||
if (needs_float64 && !f2q.features.shaderFloat64) {
|
||||
std::fprintf(stderr, "unsupported: %s uses Float64 and the device has no shaderFloat64\n", argv[1]);
|
||||
return 77;
|
||||
}
|
||||
VkPhysicalDeviceVulkan13Features f13{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES};
|
||||
VkPhysicalDeviceVulkan12Features f12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES};
|
||||
f12.bufferDeviceAddress = VK_TRUE;
|
||||
@ -163,6 +170,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
VkPhysicalDeviceFeatures2 f2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2};
|
||||
f2.features.shaderInt64 = VK_TRUE;
|
||||
f2.features.shaderFloat64 = needs_float64;
|
||||
f2.pNext = &f12;
|
||||
// OpFmaKHR (rdna2spirv.py --fma khr): VK_KHR_shader_fma, when the device has it.
|
||||
leonida::vk_test::ShaderFma fma;
|
||||
@ -229,8 +237,6 @@ int main(int argc, char** argv) {
|
||||
bai.buffer = buf;
|
||||
const uint64_t heap = vkGetBufferDeviceAddress(dev, &bai);
|
||||
|
||||
std::ifstream f(argv[1], std::ios::binary);
|
||||
std::vector<char> code((std::istreambuf_iterator<char>(f)), {});
|
||||
if (!fma.accepts(code.data(), code.size(), argv[1])) return 77;
|
||||
VkShaderModuleCreateInfo smi{VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO};
|
||||
smi.codeSize = code.size(); smi.pCode = reinterpret_cast<const uint32_t*>(code.data());
|
||||
|
||||
@ -21,14 +21,14 @@ inline constexpr bool shader_fma_in_headers = true;
|
||||
inline constexpr bool shader_fma_in_headers = false;
|
||||
#endif
|
||||
|
||||
// OpCapability (17) FMAKHR (6030; spirv/unified1/spirv.h).
|
||||
inline bool spirv_needs_fma(const void* data, std::size_t bytes) {
|
||||
// Find OpCapability (17) in a binary module.
|
||||
inline bool spirv_declares_capability(const void* data, std::size_t bytes, std::uint32_t capability) {
|
||||
if (bytes < 20 || bytes % 4) return false;
|
||||
std::vector<std::uint32_t> words(bytes / 4);
|
||||
std::memcpy(words.data(), data, bytes);
|
||||
for (std::size_t i = 5; i < words.size() && (words[i] >> 16);) {
|
||||
const std::uint32_t op = words[i] & 0xffff, count = words[i] >> 16;
|
||||
if (op == 17 && count == 2 && i + 1 < words.size() && words[i + 1] == 6030) return true;
|
||||
if (op == 17 && count == 2 && i + 1 < words.size() && words[i + 1] == capability) return true;
|
||||
i += count;
|
||||
}
|
||||
return false;
|
||||
@ -93,7 +93,7 @@ struct ShaderFma {
|
||||
// True when the module can be used: it does not need FMAKHR, or the device enables shaderFmaFloat32.
|
||||
// Otherwise says so and the caller returns 77.
|
||||
bool accepts(const void* code, std::size_t bytes, const char* name) const {
|
||||
if (float32 || !spirv_needs_fma(code, bytes)) return true;
|
||||
if (float32 || !spirv_declares_capability(code, bytes, 6030)) return true; // FMAKHR
|
||||
std::fprintf(stderr, "unsupported: %s needs OpFmaKHR (VK_KHR_shader_fma, shaderFmaFloat32) and the device "
|
||||
"lacks it; translate with --fma glsl\n", name);
|
||||
return false;
|
||||
|
||||
@ -875,6 +875,14 @@ def run_suite(a, work: str) -> int:
|
||||
vals = words[:len(USER_SGPRS_WORDS)] if words else []
|
||||
results.append((name, rc == 0 and vals == USER_SGPRS_WORDS,
|
||||
" ".join(hex(x) for x in vals) if vals else msg))
|
||||
elif name == "cs_f64_add":
|
||||
rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env)
|
||||
if rc == 77:
|
||||
results.append((name, None, "SKIP (no shaderFloat64 on this device)"))
|
||||
else:
|
||||
ok, detail = judge_cs_dump(rc, msg, [0, 0x40040000], wave64=False, partial=False, emulated=False,
|
||||
hexwords=True)
|
||||
results.append((name, ok, detail))
|
||||
elif name == "cs_cvt_f32_sat":
|
||||
# #300's saturating float -> int conversions: one dispatch per input word in s4 (VKC_SGPRS).
|
||||
wrong = []
|
||||
|
||||
Reference in New Issue
Block a user