mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(shader): implement the 64-bit LDS atomics
ds_add/sub/rsub/inc/dec_u64, ds_min/max_i64/u64, ds_and/or/xor/mskor_b64, ds_cmpst_b64/f64, ds_min/max_f64, their _rtn forms and ds_wrxchg_rtn_b64 threw in the decoder. LDS is a 32-bit workgroup array, so the two dwords are read and written under a lock dword placed after the guest LDS, which is cleared with a workgroup barrier at entry. The lock is acquired and released in the same loop iteration, so lanes of one subgroup cannot deadlock on it. Stages whose LDS is a function variable update it directly. 64-bit GDS atomics throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp"
|
||||
#include "prx/libSceAgcDriver/Graphics/include/Draw.hpp"
|
||||
#include "Recompiler.hpp"
|
||||
#include "VulkanTestDevice.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
using AgcDriver::Graphics::Require;
|
||||
using ShaderRecompiler::ShaderStage;
|
||||
|
||||
constexpr std::uint32_t Threads = 32;
|
||||
constexpr std::uint32_t Inputs = 8;
|
||||
constexpr std::uint32_t Results = 128;
|
||||
constexpr std::uint32_t Operations = 35;
|
||||
constexpr std::uint32_t ReturningOperations = 18;
|
||||
alignas(256) std::array<std::uint32_t, Threads * Inputs> Input{};
|
||||
alignas(256) std::array<std::uint32_t, Threads * Results> Output{};
|
||||
|
||||
alignas(256) constexpr std::array<std::uint32_t, 473> Code{
|
||||
0x34020085, 0x34060089, 0x34040083, 0x7ef80280, 0x7efa0280, 0x7efc0280, 0xe0301000, 0x80000401,
|
||||
0xe0301004, 0x80000501, 0xe0301008, 0x80000601, 0xe030100c, 0x80000701, 0xe0301010, 0x80000801,
|
||||
0xe0301014, 0x80000901, 0xbf8c3f70, 0xd9340000, 0x00000402, 0xd9340100, 0x00000402, 0xd9340200,
|
||||
0x00000402, 0xd9340300, 0x00000402, 0xd9340400, 0x00000402, 0xd9340500, 0x00000402, 0xd9340600,
|
||||
0x00000402, 0xd9340700, 0x00000402, 0xd9340800, 0x00000402, 0xd9340900, 0x00000402, 0xd9340a00,
|
||||
0x00000402, 0xd9340b00, 0x00000402, 0xd9340c00, 0x00000402, 0xd9340d00, 0x00000402, 0xd9340e00,
|
||||
0x00000402, 0xd9340f00, 0x00000402, 0xd9341000, 0x00000402, 0xd9341100, 0x00000402, 0xd9341200,
|
||||
0x00000402, 0xd9341300, 0x00000402, 0xd9341400, 0x00000402, 0xd9341500, 0x00000402, 0xd9341600,
|
||||
0x00000402, 0xd9341700, 0x00000402, 0xd9341800, 0x00000402, 0xd9341900, 0x00000402, 0xd9341a00,
|
||||
0x00000402, 0xd9341b00, 0x00000402, 0xd9341c00, 0x00000402, 0xd9341d00, 0x00000402, 0xd9341e00,
|
||||
0x00000402, 0xd9341f00, 0x00000402, 0xd9342000, 0x00000402, 0xd9342100, 0x00000402, 0xd9342200,
|
||||
0x00000402, 0xd9342300, 0x00007c7e, 0xd9342308, 0x00007c7e, 0xbf8cc07f, 0xd9000000, 0x00000602,
|
||||
0xd9040100, 0x00000602, 0xd9080200, 0x00000602, 0xd90c0300, 0x00000602, 0xd9100400, 0x00000602,
|
||||
0xd9140500, 0x00000602, 0xd9180600, 0x00000602, 0xd91c0700, 0x00000602, 0xd9200800, 0x00000602,
|
||||
0xd9240900, 0x00000602, 0xd9280a00, 0x00000602, 0xd92c0b00, 0x00000602, 0xd9300c00, 0x00080602,
|
||||
0xd9400d00, 0x00080602, 0xd9440e00, 0x00080602, 0xd9480f00, 0x00000602, 0xd94c1000, 0x00000602,
|
||||
0xd9801100, 0x0a000602, 0xd9841200, 0x0c000602, 0xd9881300, 0x0e000602, 0xd98c1400, 0x10000602,
|
||||
0xd9901500, 0x12000602, 0xd9941600, 0x14000602, 0xd9981700, 0x16000602, 0xd99c1800, 0x18000602,
|
||||
0xd9a01900, 0x1a000602, 0xd9a41a00, 0x1c000602, 0xd9a81b00, 0x1e000602, 0xd9ac1c00, 0x20000602,
|
||||
0xd9b01d00, 0x22080602, 0xd9b41e00, 0x24000602, 0xd9c01f00, 0x26080602, 0xd9c42000, 0x28080602,
|
||||
0xd9c82100, 0x2a000602, 0xd9cc2200, 0x2c000602, 0xd9802300, 0x2e00067e, 0xd9a02308, 0x3000087e,
|
||||
0xbf8cc07f, 0xd9d80000, 0x32000002, 0xd9d80100, 0x34000002, 0xd9d80200, 0x36000002, 0xd9d80300,
|
||||
0x38000002, 0xd9d80400, 0x3a000002, 0xd9d80500, 0x3c000002, 0xd9d80600, 0x3e000002, 0xd9d80700,
|
||||
0x40000002, 0xd9d80800, 0x42000002, 0xd9d80900, 0x44000002, 0xd9d80a00, 0x46000002, 0xd9d80b00,
|
||||
0x48000002, 0xd9d80c00, 0x4a000002, 0xd9d80d00, 0x4c000002, 0xd9d80e00, 0x4e000002, 0xd9d80f00,
|
||||
0x50000002, 0xd9d81000, 0x52000002, 0xd9d81100, 0x54000002, 0xd9d81200, 0x56000002, 0xd9d81300,
|
||||
0x58000002, 0xd9d81400, 0x5a000002, 0xd9d81500, 0x5c000002, 0xd9d81600, 0x5e000002, 0xd9d81700,
|
||||
0x60000002, 0xd9d81800, 0x62000002, 0xd9d81900, 0x64000002, 0xd9d81a00, 0x66000002, 0xd9d81b00,
|
||||
0x68000002, 0xd9d81c00, 0x6a000002, 0xd9d81d00, 0x6c000002, 0xd9d81e00, 0x6e000002, 0xd9d81f00,
|
||||
0x70000002, 0xd9d82000, 0x72000002, 0xd9d82100, 0x74000002, 0xd9d82200, 0x76000002, 0xd9d82300,
|
||||
0x7800007e, 0xd9d82308, 0x7a00007e, 0xbf8cc07f, 0xe0701000, 0x80013203, 0xe0701004, 0x80013303,
|
||||
0xe0701008, 0x80013403, 0xe070100c, 0x80013503, 0xe0701010, 0x80013603, 0xe0701014, 0x80013703,
|
||||
0xe0701018, 0x80013803, 0xe070101c, 0x80013903, 0xe0701020, 0x80013a03, 0xe0701024, 0x80013b03,
|
||||
0xe0701028, 0x80013c03, 0xe070102c, 0x80013d03, 0xe0701030, 0x80013e03, 0xe0701034, 0x80013f03,
|
||||
0xe0701038, 0x80014003, 0xe070103c, 0x80014103, 0xe0701040, 0x80014203, 0xe0701044, 0x80014303,
|
||||
0xe0701048, 0x80014403, 0xe070104c, 0x80014503, 0xe0701050, 0x80014603, 0xe0701054, 0x80014703,
|
||||
0xe0701058, 0x80014803, 0xe070105c, 0x80014903, 0xe0701060, 0x80014a03, 0xe0701064, 0x80014b03,
|
||||
0xe0701068, 0x80014c03, 0xe070106c, 0x80014d03, 0xe0701070, 0x80014e03, 0xe0701074, 0x80014f03,
|
||||
0xe0701078, 0x80015003, 0xe070107c, 0x80015103, 0xe0701080, 0x80015203, 0xe0701084, 0x80015303,
|
||||
0xe0701088, 0x80015403, 0xe070108c, 0x80015503, 0xe0701090, 0x80015603, 0xe0701094, 0x80015703,
|
||||
0xe0701098, 0x80015803, 0xe070109c, 0x80015903, 0xe07010a0, 0x80015a03, 0xe07010a4, 0x80015b03,
|
||||
0xe07010a8, 0x80015c03, 0xe07010ac, 0x80015d03, 0xe07010b0, 0x80015e03, 0xe07010b4, 0x80015f03,
|
||||
0xe07010b8, 0x80016003, 0xe07010bc, 0x80016103, 0xe07010c0, 0x80016203, 0xe07010c4, 0x80016303,
|
||||
0xe07010c8, 0x80016403, 0xe07010cc, 0x80016503, 0xe07010d0, 0x80016603, 0xe07010d4, 0x80016703,
|
||||
0xe07010d8, 0x80016803, 0xe07010dc, 0x80016903, 0xe07010e0, 0x80016a03, 0xe07010e4, 0x80016b03,
|
||||
0xe07010e8, 0x80016c03, 0xe07010ec, 0x80016d03, 0xe07010f0, 0x80016e03, 0xe07010f4, 0x80016f03,
|
||||
0xe07010f8, 0x80017003, 0xe07010fc, 0x80017103, 0xe0701100, 0x80017203, 0xe0701104, 0x80017303,
|
||||
0xe0701108, 0x80017403, 0xe070110c, 0x80017503, 0xe0701110, 0x80017603, 0xe0701114, 0x80017703,
|
||||
0xe0701118, 0x80017803, 0xe070111c, 0x80017903, 0xe0701120, 0x80017a03, 0xe0701124, 0x80017b03,
|
||||
0xe0701128, 0x80010a03, 0xe070112c, 0x80010b03, 0xe0701130, 0x80010c03, 0xe0701134, 0x80010d03,
|
||||
0xe0701138, 0x80010e03, 0xe070113c, 0x80010f03, 0xe0701140, 0x80011003, 0xe0701144, 0x80011103,
|
||||
0xe0701148, 0x80011203, 0xe070114c, 0x80011303, 0xe0701150, 0x80011403, 0xe0701154, 0x80011503,
|
||||
0xe0701158, 0x80011603, 0xe070115c, 0x80011703, 0xe0701160, 0x80011803, 0xe0701164, 0x80011903,
|
||||
0xe0701168, 0x80011a03, 0xe070116c, 0x80011b03, 0xe0701170, 0x80011c03, 0xe0701174, 0x80011d03,
|
||||
0xe0701178, 0x80011e03, 0xe070117c, 0x80011f03, 0xe0701180, 0x80012003, 0xe0701184, 0x80012103,
|
||||
0xe0701188, 0x80012203, 0xe070118c, 0x80012303, 0xe0701190, 0x80012403, 0xe0701194, 0x80012503,
|
||||
0xe0701198, 0x80012603, 0xe070119c, 0x80012703, 0xe07011a0, 0x80012803, 0xe07011a4, 0x80012903,
|
||||
0xe07011a8, 0x80012a03, 0xe07011ac, 0x80012b03, 0xe07011b0, 0x80012c03, 0xe07011b4, 0x80012d03,
|
||||
0xe07011b8, 0x80012e03, 0xe07011bc, 0x80012f03, 0xe07011c0, 0x80013003, 0xe07011c4, 0x80013103,
|
||||
0xbf810000,
|
||||
};
|
||||
|
||||
constexpr std::uint64_t Sign = 0x8000000000000000ull;
|
||||
|
||||
bool Nan(std::uint64_t bits) { return (bits & ~Sign) > 0x7ff0000000000000ull; }
|
||||
std::uint64_t OrderKey(std::uint64_t bits) { return (bits & Sign) != 0u ? ~bits : bits | Sign; }
|
||||
std::uint64_t MinMax(std::uint64_t old, std::uint64_t data, bool max) {
|
||||
if (Nan(old)) return data;
|
||||
if (Nan(data)) return old;
|
||||
return (max ? OrderKey(data) > OrderKey(old) : OrderKey(data) < OrderKey(old)) ? data : old;
|
||||
}
|
||||
bool FloatEqual(std::uint64_t a, std::uint64_t b) {
|
||||
return (a == b && !Nan(a)) || ((a | b) & ~Sign) == 0u;
|
||||
}
|
||||
|
||||
std::uint64_t Word(const std::uint32_t* words, std::uint32_t index) {
|
||||
return words[index * 2u] | (static_cast<std::uint64_t>(words[index * 2u + 1u]) << 32u);
|
||||
}
|
||||
|
||||
void Fill(std::uint32_t tid, std::uint32_t* words) {
|
||||
constexpr std::array<std::uint64_t, 12> floats{
|
||||
0x0000000000000000ull, 0x8000000000000000ull, 0x3ff0000000000000ull, 0xbff0000000000000ull,
|
||||
0x7ff8000000000000ull, 0x7ff0000000000000ull, 0x4004000000000000ull, 0xc008000000000000ull,
|
||||
0x0000000000000001ull, 0x7ff0000000000001ull, 0xfff0000000000000ull, 0x800fffffffffffffull,
|
||||
};
|
||||
const std::uint32_t kind = tid % 4u;
|
||||
const std::uint64_t seed = (tid + 1u) * 0x9e3779b97f4a7c15ull;
|
||||
std::array<std::uint64_t, 3> values{};
|
||||
if (kind == 0u) values = {seed, seed * 0xbf58476d1ce4e5b9ull, seed ^ 0x94d049bb133111ebull};
|
||||
if (kind == 1u) values = {tid % 7u, (tid * 3u) % 7u, tid % 5u};
|
||||
if (kind == 2u) values = {floats[tid % 12u], floats[(tid / 2u + 3u) % 12u], floats[(tid + 5u) % 12u]};
|
||||
if (kind == 3u) values = {seed, (tid & 4u) != 0u ? seed : seed + 0x100000000ull, seed * 3u};
|
||||
for (std::uint32_t i = 0; i < values.size(); ++i) {
|
||||
words[i * 2u] = static_cast<std::uint32_t>(values[i]);
|
||||
words[i * 2u + 1u] = static_cast<std::uint32_t>(values[i] >> 32u);
|
||||
}
|
||||
}
|
||||
|
||||
std::array<std::uint32_t, 4> BufferDescriptor(const void* data, std::uint32_t bytes) {
|
||||
const auto address = reinterpret_cast<std::uintptr_t>(data);
|
||||
return {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>((address >> 32u) & 0xffffu), bytes, 0x01016facu};
|
||||
}
|
||||
|
||||
std::string Hex(std::uint64_t value) {
|
||||
char text[24];
|
||||
std::snprintf(text, sizeof(text), "0x%016llx", static_cast<unsigned long long>(value));
|
||||
return text;
|
||||
}
|
||||
|
||||
void Expect(std::uint32_t tid, std::uint64_t actual, std::uint64_t expected, const std::string& name) {
|
||||
Require(actual == expected, "lds 64-bit atomics: lane " + std::to_string(tid) + " " + name + " is " + Hex(actual) + ", expected " + Hex(expected));
|
||||
}
|
||||
|
||||
void Run(AgcDriver::VulkanDevice& device) {
|
||||
for (std::uint32_t tid = 0; tid < Threads; ++tid) Fill(tid, &Input[tid * Inputs]);
|
||||
Output.fill(0xdeadbeefu);
|
||||
std::vector<std::uint32_t> userData(8, 0u);
|
||||
const auto input = BufferDescriptor(Input.data(), static_cast<std::uint32_t>(Input.size() * 4u));
|
||||
const auto output = BufferDescriptor(Output.data(), static_cast<std::uint32_t>(Output.size() * 4u));
|
||||
std::copy(input.begin(), input.end(), userData.begin());
|
||||
std::copy(output.begin(), output.end(), userData.begin() + 4);
|
||||
const std::span<const std::uint32_t> code(Code);
|
||||
const std::array<ShaderRecompiler::MemoryRegion, 1> memory{{{reinterpret_cast<std::uintptr_t>(code.data()), std::as_bytes(code)}}};
|
||||
const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 2244u, {false, false, false}, false, 1};
|
||||
ShaderRecompiler::RecompileRequest request{
|
||||
{ShaderStage::Compute, reinterpret_cast<std::uintptr_t>(code.data()), code, 0, {}},
|
||||
{32, 0, userData, compute, std::nullopt, std::nullopt, memory},
|
||||
device.Target(),
|
||||
{0, 0, 0, 128}
|
||||
};
|
||||
request.useCache = false;
|
||||
const auto result = ShaderRecompiler::Recompile(request);
|
||||
device.Dispatch(result, 1, 1, 1, {}, reinterpret_cast<std::uintptr_t>(code.data()));
|
||||
device.WaitIdle();
|
||||
}
|
||||
|
||||
void CheckLanes() {
|
||||
constexpr std::array<const char*, Operations> names{
|
||||
"ds_add_u64", "ds_sub_u64", "ds_rsub_u64", "ds_inc_u64", "ds_dec_u64", "ds_min_i64", "ds_max_i64", "ds_min_u64", "ds_max_u64",
|
||||
"ds_and_b64", "ds_or_b64", "ds_xor_b64", "ds_mskor_b64", "ds_cmpst_b64", "ds_cmpst_f64", "ds_min_f64", "ds_max_f64",
|
||||
"ds_add_rtn_u64", "ds_sub_rtn_u64", "ds_rsub_rtn_u64", "ds_inc_rtn_u64", "ds_dec_rtn_u64", "ds_min_rtn_i64", "ds_max_rtn_i64",
|
||||
"ds_min_rtn_u64", "ds_max_rtn_u64", "ds_and_rtn_b64", "ds_or_rtn_b64", "ds_xor_rtn_b64", "ds_mskor_rtn_b64", "ds_wrxchg_rtn_b64",
|
||||
"ds_cmpst_rtn_b64", "ds_cmpst_rtn_f64", "ds_min_rtn_f64", "ds_max_rtn_f64",
|
||||
};
|
||||
for (std::uint32_t tid = 0; tid < Threads; ++tid) {
|
||||
const std::uint32_t* in = &Input[tid * Inputs];
|
||||
const std::uint32_t* out = &Output[tid * Results];
|
||||
const std::uint64_t a = Word(in, 0);
|
||||
const std::uint64_t b = Word(in, 1);
|
||||
const std::uint64_t c = Word(in, 2);
|
||||
const auto sa = static_cast<std::int64_t>(a);
|
||||
const auto sb = static_cast<std::int64_t>(b);
|
||||
const std::array<std::uint64_t, 17> common{
|
||||
a + b, a - b, b - a, a >= b ? 0u : a + 1u, (a == 0u || a > b) ? b : a - 1u,
|
||||
sb < sa ? b : a, sb > sa ? b : a, b < a ? b : a, b > a ? b : a,
|
||||
a & b, a | b, a ^ b, (a & ~b) | c, a == b ? c : a, FloatEqual(a, b) ? c : a,
|
||||
MinMax(a, b, false), MinMax(a, b, true),
|
||||
};
|
||||
std::array<std::uint64_t, Operations> memory{};
|
||||
std::copy(common.begin(), common.end(), memory.begin());
|
||||
std::copy(common.begin(), common.begin() + 13, memory.begin() + 17);
|
||||
memory[30] = b;
|
||||
std::copy(common.begin() + 13, common.end(), memory.begin() + 31);
|
||||
for (std::uint32_t j = 0; j < Operations; ++j) Expect(tid, Word(out, j), memory[j], names[j]);
|
||||
for (std::uint32_t j = 0; j < ReturningOperations; ++j) Expect(tid, Word(out, Operations + 2u + j), a, std::string(names[17u + j]) + " returned value");
|
||||
}
|
||||
}
|
||||
|
||||
void CheckContention() {
|
||||
std::uint64_t total = 0;
|
||||
std::uint64_t maximum = 0;
|
||||
std::vector<std::uint32_t> pending;
|
||||
for (std::uint32_t tid = 0; tid < Threads; ++tid) {
|
||||
total += Word(&Input[tid * Inputs], 1);
|
||||
maximum = std::max(maximum, Word(&Input[tid * Inputs], 2));
|
||||
pending.push_back(tid);
|
||||
}
|
||||
Expect(0, Word(Output.data(), Operations), total, "contended ds_add_rtn_u64 total");
|
||||
Expect(0, Word(Output.data(), Operations + 1u), maximum, "contended ds_max_rtn_u64 result");
|
||||
std::uint64_t current = 0;
|
||||
while (!pending.empty()) {
|
||||
auto next = pending.end();
|
||||
for (auto it = pending.begin(); it != pending.end(); ++it) {
|
||||
if (Word(&Output[*it * Results], Operations + 2u + ReturningOperations) != current) continue;
|
||||
if (next == pending.end() || Word(&Input[*it * Inputs], 1) == 0u) next = it;
|
||||
}
|
||||
Require(next != pending.end(), "lds 64-bit atomics: contended ds_add_rtn_u64 returned values do not form one serial order at " + Hex(current));
|
||||
current += Word(&Input[*next * Inputs], 1);
|
||||
pending.erase(next);
|
||||
}
|
||||
for (std::uint32_t tid = 0; tid < Threads; ++tid) {
|
||||
const std::uint64_t old = Word(&Output[tid * Results], Operations + 3u + ReturningOperations);
|
||||
bool seen = old == 0u;
|
||||
for (std::uint32_t lane = 0; lane < Threads; ++lane) seen |= Word(&Input[lane * Inputs], 2) == old;
|
||||
Require(seen && old <= maximum, "lds 64-bit atomics: contended ds_max_rtn_u64 returned " + Hex(old));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
try {
|
||||
const auto device = OpenVulkanTestDevice();
|
||||
if (!device) return VulkanTestSkipped;
|
||||
Run(*device);
|
||||
CheckLanes();
|
||||
CheckContention();
|
||||
std::puts("lds 64-bit atomics tests passed");
|
||||
return 0;
|
||||
} catch (const std::exception& error) {
|
||||
std::cerr << error.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+18
@@ -364,6 +364,24 @@ enum class IrOpcode : std::uint16_t {
|
||||
SharedAtomicCmpstF32,
|
||||
SharedAtomicMskor32,
|
||||
SharedAtomicWrap32,
|
||||
SharedAtomicSwap64,
|
||||
SharedAtomicIAdd64,
|
||||
SharedAtomicISub64,
|
||||
SharedAtomicRsub64,
|
||||
SharedAtomicInc64,
|
||||
SharedAtomicDec64,
|
||||
SharedAtomicSMin64,
|
||||
SharedAtomicUMin64,
|
||||
SharedAtomicSMax64,
|
||||
SharedAtomicUMax64,
|
||||
SharedAtomicAnd64,
|
||||
SharedAtomicOr64,
|
||||
SharedAtomicXor64,
|
||||
SharedAtomicFMin64,
|
||||
SharedAtomicFMax64,
|
||||
SharedAtomicCmpst64,
|
||||
SharedAtomicCmpstF64,
|
||||
SharedAtomicMskor64,
|
||||
DataAppend,
|
||||
DataConsume,
|
||||
SwizzleU32,
|
||||
|
||||
@@ -405,6 +405,24 @@ constexpr std::array<OpcodeMeta, static_cast<std::size_t>(IrOpcode::Count)> Meta
|
||||
makeMeta("SharedAtomicCmpstF32", U32, U32, U32, U32, U1),
|
||||
makeMeta("SharedAtomicMskor32", U32, U32, U32, U32, U1),
|
||||
makeMeta("SharedAtomicWrap32", U32, U32, U32, U32, U1),
|
||||
makeMeta("SharedAtomicSwap64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicIAdd64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicISub64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicRsub64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicInc64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicDec64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicSMin64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicUMin64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicSMax64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicUMax64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicAnd64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicOr64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicXor64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicFMin64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicFMax64", U64, U32, U64, U1),
|
||||
makeMeta("SharedAtomicCmpst64", U64, U32, U64, U64, U1),
|
||||
makeMeta("SharedAtomicCmpstF64", U64, U32, U64, U64, U1),
|
||||
makeMeta("SharedAtomicMskor64", U64, U32, U64, U64, U1),
|
||||
makeMeta("DataAppend", U32, U32, U1, U32, U32),
|
||||
makeMeta("DataConsume", U32, U32, U1, U32, U32),
|
||||
makeMeta("SwizzleU32", U32, U32, U32, U1),
|
||||
@@ -595,6 +613,24 @@ SharedAccess SharedAccessOf(IrOpcode opcode) {
|
||||
case IrOpcode::SharedAtomicCmpstF32:
|
||||
case IrOpcode::SharedAtomicMskor32:
|
||||
case IrOpcode::SharedAtomicWrap32:
|
||||
case IrOpcode::SharedAtomicSwap64:
|
||||
case IrOpcode::SharedAtomicIAdd64:
|
||||
case IrOpcode::SharedAtomicISub64:
|
||||
case IrOpcode::SharedAtomicRsub64:
|
||||
case IrOpcode::SharedAtomicInc64:
|
||||
case IrOpcode::SharedAtomicDec64:
|
||||
case IrOpcode::SharedAtomicSMin64:
|
||||
case IrOpcode::SharedAtomicUMin64:
|
||||
case IrOpcode::SharedAtomicSMax64:
|
||||
case IrOpcode::SharedAtomicUMax64:
|
||||
case IrOpcode::SharedAtomicAnd64:
|
||||
case IrOpcode::SharedAtomicOr64:
|
||||
case IrOpcode::SharedAtomicXor64:
|
||||
case IrOpcode::SharedAtomicFMin64:
|
||||
case IrOpcode::SharedAtomicFMax64:
|
||||
case IrOpcode::SharedAtomicCmpst64:
|
||||
case IrOpcode::SharedAtomicCmpstF64:
|
||||
case IrOpcode::SharedAtomicMskor64:
|
||||
return SharedAccess::Atomic;
|
||||
case IrOpcode::DataAppend:
|
||||
return SharedAccess::Append;
|
||||
@@ -609,6 +645,24 @@ std::uint32_t SharedComponentCount(IrOpcode opcode) {
|
||||
switch (opcode) {
|
||||
case IrOpcode::LoadSharedU32x2:
|
||||
case IrOpcode::WriteSharedU32x2:
|
||||
case IrOpcode::SharedAtomicSwap64:
|
||||
case IrOpcode::SharedAtomicIAdd64:
|
||||
case IrOpcode::SharedAtomicISub64:
|
||||
case IrOpcode::SharedAtomicRsub64:
|
||||
case IrOpcode::SharedAtomicInc64:
|
||||
case IrOpcode::SharedAtomicDec64:
|
||||
case IrOpcode::SharedAtomicSMin64:
|
||||
case IrOpcode::SharedAtomicUMin64:
|
||||
case IrOpcode::SharedAtomicSMax64:
|
||||
case IrOpcode::SharedAtomicUMax64:
|
||||
case IrOpcode::SharedAtomicAnd64:
|
||||
case IrOpcode::SharedAtomicOr64:
|
||||
case IrOpcode::SharedAtomicXor64:
|
||||
case IrOpcode::SharedAtomicFMin64:
|
||||
case IrOpcode::SharedAtomicFMax64:
|
||||
case IrOpcode::SharedAtomicCmpst64:
|
||||
case IrOpcode::SharedAtomicCmpstF64:
|
||||
case IrOpcode::SharedAtomicMskor64:
|
||||
return 2u;
|
||||
case IrOpcode::LoadSharedU32x3:
|
||||
case IrOpcode::WriteSharedU32x3:
|
||||
|
||||
@@ -826,6 +826,41 @@ enum class RdnaOpcode : std::uint16_t {
|
||||
DsCmpstRtnB32,
|
||||
DsCmpstRtnF32,
|
||||
DsWrapRtnB32,
|
||||
DsAddU64,
|
||||
DsSubU64,
|
||||
DsRsubU64,
|
||||
DsIncU64,
|
||||
DsDecU64,
|
||||
DsMinI64,
|
||||
DsMaxI64,
|
||||
DsMinU64,
|
||||
DsMaxU64,
|
||||
DsAndB64,
|
||||
DsOrB64,
|
||||
DsXorB64,
|
||||
DsMskorB64,
|
||||
DsCmpstB64,
|
||||
DsCmpstF64,
|
||||
DsMinF64,
|
||||
DsMaxF64,
|
||||
DsAddRtnU64,
|
||||
DsSubRtnU64,
|
||||
DsRsubRtnU64,
|
||||
DsIncRtnU64,
|
||||
DsDecRtnU64,
|
||||
DsMinRtnI64,
|
||||
DsMaxRtnI64,
|
||||
DsMinRtnU64,
|
||||
DsMaxRtnU64,
|
||||
DsAndRtnB64,
|
||||
DsOrRtnB64,
|
||||
DsXorRtnB64,
|
||||
DsMskorRtnB64,
|
||||
DsWrxchgRtnB64,
|
||||
DsCmpstRtnB64,
|
||||
DsCmpstRtnF64,
|
||||
DsMinRtnF64,
|
||||
DsMaxRtnF64,
|
||||
DsNop,
|
||||
DsReadU8D16,
|
||||
DsReadU8D16Hi,
|
||||
|
||||
@@ -203,6 +203,41 @@ constexpr MemoryOpcodeInfo dsOpcodes[] = {
|
||||
{0x33u, RdnaOpcode::DsMaxRtnF32, 1, 32, false, false, false},
|
||||
{0x34u, RdnaOpcode::DsWrapRtnB32, 1, 32, false, false, false},
|
||||
{0x55u, RdnaOpcode::DsAddRtnF32, 1, 32, false, false, false},
|
||||
{0x40u, RdnaOpcode::DsAddU64, 2, 32, false, false, false},
|
||||
{0x41u, RdnaOpcode::DsSubU64, 2, 32, false, false, false},
|
||||
{0x42u, RdnaOpcode::DsRsubU64, 2, 32, false, false, false},
|
||||
{0x43u, RdnaOpcode::DsIncU64, 2, 32, false, false, false},
|
||||
{0x44u, RdnaOpcode::DsDecU64, 2, 32, false, false, false},
|
||||
{0x45u, RdnaOpcode::DsMinI64, 2, 32, false, false, false},
|
||||
{0x46u, RdnaOpcode::DsMaxI64, 2, 32, false, false, false},
|
||||
{0x47u, RdnaOpcode::DsMinU64, 2, 32, false, false, false},
|
||||
{0x48u, RdnaOpcode::DsMaxU64, 2, 32, false, false, false},
|
||||
{0x49u, RdnaOpcode::DsAndB64, 2, 32, false, false, false},
|
||||
{0x4au, RdnaOpcode::DsOrB64, 2, 32, false, false, false},
|
||||
{0x4bu, RdnaOpcode::DsXorB64, 2, 32, false, false, false},
|
||||
{0x4cu, RdnaOpcode::DsMskorB64, 2, 32, false, false, false},
|
||||
{0x50u, RdnaOpcode::DsCmpstB64, 2, 32, false, false, false},
|
||||
{0x51u, RdnaOpcode::DsCmpstF64, 2, 32, false, false, false},
|
||||
{0x52u, RdnaOpcode::DsMinF64, 2, 32, false, false, false},
|
||||
{0x53u, RdnaOpcode::DsMaxF64, 2, 32, false, false, false},
|
||||
{0x60u, RdnaOpcode::DsAddRtnU64, 2, 32, false, false, false},
|
||||
{0x61u, RdnaOpcode::DsSubRtnU64, 2, 32, false, false, false},
|
||||
{0x62u, RdnaOpcode::DsRsubRtnU64, 2, 32, false, false, false},
|
||||
{0x63u, RdnaOpcode::DsIncRtnU64, 2, 32, false, false, false},
|
||||
{0x64u, RdnaOpcode::DsDecRtnU64, 2, 32, false, false, false},
|
||||
{0x65u, RdnaOpcode::DsMinRtnI64, 2, 32, false, false, false},
|
||||
{0x66u, RdnaOpcode::DsMaxRtnI64, 2, 32, false, false, false},
|
||||
{0x67u, RdnaOpcode::DsMinRtnU64, 2, 32, false, false, false},
|
||||
{0x68u, RdnaOpcode::DsMaxRtnU64, 2, 32, false, false, false},
|
||||
{0x69u, RdnaOpcode::DsAndRtnB64, 2, 32, false, false, false},
|
||||
{0x6au, RdnaOpcode::DsOrRtnB64, 2, 32, false, false, false},
|
||||
{0x6bu, RdnaOpcode::DsXorRtnB64, 2, 32, false, false, false},
|
||||
{0x6cu, RdnaOpcode::DsMskorRtnB64, 2, 32, false, false, false},
|
||||
{0x6du, RdnaOpcode::DsWrxchgRtnB64, 2, 32, false, false, false},
|
||||
{0x70u, RdnaOpcode::DsCmpstRtnB64, 2, 32, false, false, false},
|
||||
{0x71u, RdnaOpcode::DsCmpstRtnF64, 2, 32, false, false, false},
|
||||
{0x72u, RdnaOpcode::DsMinRtnF64, 2, 32, false, false, false},
|
||||
{0x73u, RdnaOpcode::DsMaxRtnF64, 2, 32, false, false, false},
|
||||
{0x01u, RdnaOpcode::DsSubU32, 1, 32, false, false, false},
|
||||
{0x05u, RdnaOpcode::DsMinI32, 1, 32, false, false, false},
|
||||
{0x06u, RdnaOpcode::DsMaxI32, 1, 32, false, false, false},
|
||||
@@ -418,6 +453,35 @@ bool isDsAtomicOpcode(RdnaOpcode opcode) {
|
||||
case RdnaOpcode::DsMinRtnF32:
|
||||
case RdnaOpcode::DsMaxRtnF32:
|
||||
case RdnaOpcode::DsAddRtnF32:
|
||||
case RdnaOpcode::DsAddU64:
|
||||
case RdnaOpcode::DsSubU64:
|
||||
case RdnaOpcode::DsRsubU64:
|
||||
case RdnaOpcode::DsIncU64:
|
||||
case RdnaOpcode::DsDecU64:
|
||||
case RdnaOpcode::DsMinI64:
|
||||
case RdnaOpcode::DsMaxI64:
|
||||
case RdnaOpcode::DsMinU64:
|
||||
case RdnaOpcode::DsMaxU64:
|
||||
case RdnaOpcode::DsAndB64:
|
||||
case RdnaOpcode::DsOrB64:
|
||||
case RdnaOpcode::DsXorB64:
|
||||
case RdnaOpcode::DsMinF64:
|
||||
case RdnaOpcode::DsMaxF64:
|
||||
case RdnaOpcode::DsAddRtnU64:
|
||||
case RdnaOpcode::DsSubRtnU64:
|
||||
case RdnaOpcode::DsRsubRtnU64:
|
||||
case RdnaOpcode::DsIncRtnU64:
|
||||
case RdnaOpcode::DsDecRtnU64:
|
||||
case RdnaOpcode::DsMinRtnI64:
|
||||
case RdnaOpcode::DsMaxRtnI64:
|
||||
case RdnaOpcode::DsMinRtnU64:
|
||||
case RdnaOpcode::DsMaxRtnU64:
|
||||
case RdnaOpcode::DsAndRtnB64:
|
||||
case RdnaOpcode::DsOrRtnB64:
|
||||
case RdnaOpcode::DsXorRtnB64:
|
||||
case RdnaOpcode::DsWrxchgRtnB64:
|
||||
case RdnaOpcode::DsMinRtnF64:
|
||||
case RdnaOpcode::DsMaxRtnF64:
|
||||
return true;
|
||||
default: return false;
|
||||
}
|
||||
@@ -435,7 +499,13 @@ std::uint32_t dsSourceCount(RdnaOpcode opcode) {
|
||||
case RdnaOpcode::DsMskorRtnB32:
|
||||
case RdnaOpcode::DsCmpstRtnB32:
|
||||
case RdnaOpcode::DsCmpstRtnF32:
|
||||
case RdnaOpcode::DsWrapRtnB32: return 3u;
|
||||
case RdnaOpcode::DsWrapRtnB32:
|
||||
case RdnaOpcode::DsMskorB64:
|
||||
case RdnaOpcode::DsCmpstB64:
|
||||
case RdnaOpcode::DsCmpstF64:
|
||||
case RdnaOpcode::DsMskorRtnB64:
|
||||
case RdnaOpcode::DsCmpstRtnB64:
|
||||
case RdnaOpcode::DsCmpstRtnF64: return 3u;
|
||||
case RdnaOpcode::DsMinF32:
|
||||
case RdnaOpcode::DsMaxF32: return 2u;
|
||||
case RdnaOpcode::DsNop: return 0u;
|
||||
|
||||
@@ -16,9 +16,11 @@ struct SpirvRequirements {
|
||||
bool computeDerivatives = false;
|
||||
bool imageGatherExtended = false;
|
||||
bool functionLds = false;
|
||||
bool ldsLock = false;
|
||||
bool functionScratch = false;
|
||||
bool pixelValidMask = false;
|
||||
bool bufferInt64Atomics = false;
|
||||
bool sharedInt64Atomics = false;
|
||||
bool float64 = false;
|
||||
bool coherentBuffers = false;
|
||||
std::vector<std::uint32_t> capabilities;
|
||||
|
||||
@@ -96,6 +96,7 @@ std::uint32_t StorageBufferPackedStride(const SpirvEmitterState& state, const Me
|
||||
IrBufferFormat StorageBufferFormat(const SpirvEmitterState& state, const MemoryInfo& mem);
|
||||
void EmitMemoryOffsets(SpirvEmitterState& state);
|
||||
std::uint32_t LdsDwordCount(const SpirvEmitterState& state);
|
||||
std::uint32_t EmitLdsLockPointer(SpirvEmitterState& state);
|
||||
MemoryResourceAccess PrepareMemoryResourceAccess(SpirvEmitterState& state, const MemoryInfo& mem);
|
||||
MemoryResourceAccess PrepareStorageBufferResourceAccess(SpirvEmitterState& state, const MemoryInfo& mem, std::uint32_t variable, std::uint32_t pointerType);
|
||||
std::uint32_t EmitMemoryElementIndex(SpirvEmitterState& state, const MemoryResourceAccess& access, std::uint32_t rawIndex);
|
||||
|
||||
@@ -313,6 +313,24 @@ std::uint32_t EmitSharedAtomicCmpst32(SpirvValueEmitContext& ctx, const IrValue&
|
||||
std::uint32_t EmitSharedAtomicCmpstF32(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicMskor32(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicWrap32(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicSwap64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicIAdd64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicISub64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicRsub64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicInc64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicDec64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicSMin64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicUMin64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicSMax64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicUMax64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicAnd64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicOr64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicXor64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicFMin64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicFMax64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicCmpst64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicCmpstF64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitSharedAtomicMskor64(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitDataAppend(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
std::uint32_t EmitDataConsume(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
void EmitImageQueryDimensions(SpirvValueEmitContext& ctx, const IrValue& inst);
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ std::uint32_t StorageBufferPackedStride(const SpirvEmitterState& state, const Me
|
||||
IrBufferFormat StorageBufferFormat(const SpirvEmitterState& state, const MemoryInfo& mem);
|
||||
void EmitMemoryOffsets(SpirvEmitterState& state);
|
||||
std::uint32_t LdsDwordCount(const SpirvEmitterState& state);
|
||||
std::uint32_t EmitLdsLockPointer(SpirvEmitterState& state);
|
||||
MemoryResourceAccess PrepareStorageBufferResourceAccess(SpirvEmitterState& state, const MemoryInfo& mem, std::uint32_t variable, std::uint32_t pointerType);
|
||||
MemoryResourceAccess PrepareMemoryResourceAccess(SpirvEmitterState& state, const MemoryInfo& mem);
|
||||
std::uint32_t EmitMemoryElementIndex(SpirvEmitterState& state, const MemoryResourceAccess& access, std::uint32_t rawIndex);
|
||||
|
||||
@@ -113,6 +113,9 @@ SpirvRequirements AnalyzeProgramRequirements(const IrProgram& program) {
|
||||
}
|
||||
}
|
||||
const auto sharedAccess = SharedAccessOf(inst->Opcode());
|
||||
if (sharedAccess == SharedAccess::Atomic && inst->Type() == IrType::U64) {
|
||||
requirements.sharedInt64Atomics = true;
|
||||
}
|
||||
if (sharedAccess != SharedAccess::None) {
|
||||
const auto index = inst->Flags<MemoryFlags>().index;
|
||||
if (index >= program.Resources().memoryInfo.size()) {
|
||||
@@ -124,6 +127,8 @@ SpirvRequirements AnalyzeProgramRequirements(const IrProgram& program) {
|
||||
}
|
||||
if (program.Resources().stage != IrShaderStage::Compute && program.Resources().stage != IrShaderStage::Mesh && kind == ResourceKind::Lds) {
|
||||
requirements.functionLds = true;
|
||||
} else if (sharedAccess == SharedAccess::Atomic && inst->Type() == IrType::U64 && kind == ResourceKind::Lds) {
|
||||
requirements.ldsLock = true;
|
||||
}
|
||||
if (sharedAccess == SharedAccess::Append || sharedAccess == SharedAccess::Consume) {
|
||||
requirements.subgroupBallot = true;
|
||||
|
||||
@@ -538,6 +538,24 @@ void EmitDirectInstruction(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
case IrOpcode::SharedAtomicCmpstF32: return Invoke(EmitSharedAtomicCmpstF32, ctx, inst);
|
||||
case IrOpcode::SharedAtomicMskor32: return Invoke(EmitSharedAtomicMskor32, ctx, inst);
|
||||
case IrOpcode::SharedAtomicWrap32: return Invoke(EmitSharedAtomicWrap32, ctx, inst);
|
||||
case IrOpcode::SharedAtomicSwap64: return Invoke(EmitSharedAtomicSwap64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicIAdd64: return Invoke(EmitSharedAtomicIAdd64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicISub64: return Invoke(EmitSharedAtomicISub64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicRsub64: return Invoke(EmitSharedAtomicRsub64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicInc64: return Invoke(EmitSharedAtomicInc64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicDec64: return Invoke(EmitSharedAtomicDec64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicSMin64: return Invoke(EmitSharedAtomicSMin64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicUMin64: return Invoke(EmitSharedAtomicUMin64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicSMax64: return Invoke(EmitSharedAtomicSMax64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicUMax64: return Invoke(EmitSharedAtomicUMax64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicAnd64: return Invoke(EmitSharedAtomicAnd64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicOr64: return Invoke(EmitSharedAtomicOr64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicXor64: return Invoke(EmitSharedAtomicXor64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicFMin64: return Invoke(EmitSharedAtomicFMin64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicFMax64: return Invoke(EmitSharedAtomicFMax64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicCmpst64: return Invoke(EmitSharedAtomicCmpst64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicCmpstF64: return Invoke(EmitSharedAtomicCmpstF64, ctx, inst);
|
||||
case IrOpcode::SharedAtomicMskor64: return Invoke(EmitSharedAtomicMskor64, ctx, inst);
|
||||
case IrOpcode::DataAppend: return Invoke(EmitDataAppend, ctx, inst);
|
||||
case IrOpcode::DataConsume: return Invoke(EmitDataConsume, ctx, inst);
|
||||
case IrOpcode::SwizzleU32: return Invoke(EmitSwizzleU32, ctx, inst);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace {
|
||||
if (ShaderWorkgroupInput(state) == nullptr) {
|
||||
FailEmit("function LDS was not prepared before function emission");
|
||||
}
|
||||
state.ldsVariable = state.module.DefineGlobalVariable(TypeU32ArrayPointer(state, spv::StorageClassWorkgroup, LdsDwordCount(state)), spv::StorageClassWorkgroup);
|
||||
state.ldsVariable = state.module.DefineGlobalVariable(TypeU32ArrayPointer(state, spv::StorageClassWorkgroup, LdsDwordCount(state) + (state.requirements.ldsLock ? 1u : 0u)), spv::StorageClassWorkgroup);
|
||||
state.module.AddName(state.ldsVariable, "lds_dwords");
|
||||
}
|
||||
|
||||
@@ -99,6 +99,16 @@ std::uint32_t LdsDwordCount(const SpirvEmitterState& state) {
|
||||
return workgroup != nullptr ? workgroup->ldsSizeDwords : FunctionLdsDwords;
|
||||
}
|
||||
|
||||
std::uint32_t EmitLdsLockPointer(SpirvEmitterState& state) {
|
||||
if (!state.requirements.ldsLock) {
|
||||
FailEmit("LDS lock was not requested by the program analysis");
|
||||
}
|
||||
EnsureLdsStorage(state);
|
||||
const auto pointer = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpAccessChain, TypeU32ElementPointer(state, spv::StorageClassWorkgroup), pointer, state.ldsVariable, ConstantU32(state, LdsDwordCount(state)));
|
||||
return pointer;
|
||||
}
|
||||
|
||||
MemoryResourceAccess PrepareStorageBufferResourceAccess(SpirvEmitterState& state, const MemoryInfo& mem, std::uint32_t variable, std::uint32_t pointerType) {
|
||||
if (variable == 0) {
|
||||
ExitDescriptorBindingFailure(state, DescriptorBindingKind::Buffers, mem.resource, "storage buffer descriptor array was not emitted");
|
||||
|
||||
@@ -1086,6 +1086,106 @@ std::uint32_t AppendConsume(SpirvValueEmitContext& ctx, const IrValue& inst, boo
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename TUpdate>
|
||||
std::uint32_t LockedLdsUpdate(SpirvEmitterState& state, TUpdate&& update) {
|
||||
const auto lock = EmitLdsLockPointer(state);
|
||||
const auto header = state.module.AllocateId();
|
||||
const auto body = state.module.AllocateId();
|
||||
const auto critical = state.module.AllocateId();
|
||||
const auto after = state.module.AllocateId();
|
||||
const auto cont = state.module.AllocateId();
|
||||
const auto merge = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpBranch, header);
|
||||
EmitLabel(state, header);
|
||||
state.module.AddFunction(spv::OpLoopMerge, merge, cont, spv::LoopControlMaskNone);
|
||||
state.module.AddFunction(spv::OpBranch, body);
|
||||
EmitLabel(state, body);
|
||||
const auto previous = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpAtomicCompareExchange, TypeU32(state), previous, lock, ConstantU32(state, spv::ScopeWorkgroup), ConstantU32(state, spv::MemorySemanticsAcquireMask | spv::MemorySemanticsWorkgroupMemoryMask), ConstantU32(state, spv::MemorySemanticsMaskNone), ConstantU32(state, 1u), ConstantU32(state, 0u));
|
||||
const auto acquired = Binary(state, spv::OpIEqual, TypeBool(state), previous, ConstantU32(state, 0u));
|
||||
state.module.AddFunction(spv::OpSelectionMerge, after, spv::SelectionControlMaskNone);
|
||||
state.module.AddFunction(spv::OpBranchConditional, acquired, critical, after);
|
||||
EmitLabel(state, critical);
|
||||
const auto old = update();
|
||||
state.module.AddFunction(spv::OpAtomicStore, lock, ConstantU32(state, spv::ScopeWorkgroup), ConstantU32(state, spv::MemorySemanticsReleaseMask | spv::MemorySemanticsWorkgroupMemoryMask), ConstantU32(state, 0u));
|
||||
const auto criticalExit = state.currentLabel;
|
||||
state.module.AddFunction(spv::OpBranch, after);
|
||||
EmitLabel(state, after);
|
||||
const auto result = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpPhi, TypeU64(state), result, old, criticalExit, ConstantU64(state, 0u), body);
|
||||
state.module.AddFunction(spv::OpBranchConditional, acquired, merge, cont);
|
||||
EmitLabel(state, cont);
|
||||
state.module.AddFunction(spv::OpBranch, header);
|
||||
EmitLabel(state, merge);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename TReplacement>
|
||||
std::uint32_t SharedAtomic64(SpirvValueEmitContext& ctx, const IrValue& inst, TReplacement&& replacement) {
|
||||
auto& state = ctx.state;
|
||||
const auto& mem = SharedMemory(ctx, inst);
|
||||
return EmitValueOrDefaultIfCondition(state, ActiveArgument(ctx, inst), TypeU64(state), ConstantU64(state, 0u), [&]() {
|
||||
const auto resource = PrepareMemoryResourceAccess(state, mem);
|
||||
const auto rawIndex = DwordIndex(ctx, inst, mem);
|
||||
const auto low = EmitMemoryElementIndex(state, resource, rawIndex);
|
||||
const auto high = EmitMemoryElementIndex(state, resource, Binary(state, spv::OpIAdd, TypeU32(state), rawIndex, ConstantU32(state, 1u)));
|
||||
return EmitValueOrDefaultIfCondition(state, EmitMemoryElementInBounds(state, resource, high), TypeU64(state), ConstantU64(state, 0u), [&]() {
|
||||
const auto update = [&]() {
|
||||
const auto lowPointer = EmitMemoryElementPointer(state, resource, low);
|
||||
const auto highPointer = EmitMemoryElementPointer(state, resource, high);
|
||||
const auto lowValue = state.module.AllocateId();
|
||||
const auto highValue = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpLoad, TypeU32(state), lowValue, lowPointer);
|
||||
state.module.AddFunction(spv::OpLoad, TypeU32(state), highValue, highPointer);
|
||||
const auto old = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpCompositeConstruct, TypeU64(state), old, lowValue, highValue);
|
||||
const auto next = Unary(state, spv::OpBitcast, TypeU64(state), replacement(state, Unary(state, spv::OpBitcast, TypeScalarU64(state), old)));
|
||||
const auto nextLow = state.module.AllocateId();
|
||||
const auto nextHigh = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpCompositeExtract, TypeU32(state), nextLow, next, 0u);
|
||||
state.module.AddFunction(spv::OpCompositeExtract, TypeU32(state), nextHigh, next, 1u);
|
||||
state.module.AddFunction(spv::OpStore, lowPointer, nextLow);
|
||||
state.module.AddFunction(spv::OpStore, highPointer, nextHigh);
|
||||
return old;
|
||||
};
|
||||
return state.requirements.ldsLock ? LockedLdsUpdate(state, update) : update();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
template<typename TOperation>
|
||||
std::uint32_t SharedAtomic64Binary(SpirvValueEmitContext& ctx, const IrValue& inst, TOperation&& operation) {
|
||||
const auto data = ScalarU64Argument(ctx, inst, 2u);
|
||||
return SharedAtomic64(ctx, inst, [&](SpirvEmitterState& state, std::uint32_t old) {
|
||||
return operation(state, old, data);
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t SharedAtomic64Op(SpirvValueEmitContext& ctx, const IrValue& inst, spv::Op opcode, bool dataFirst) {
|
||||
return SharedAtomic64Binary(ctx, inst, [&](SpirvEmitterState& state, std::uint32_t old, std::uint32_t data) {
|
||||
return dataFirst ? Binary(state, opcode, TypeScalarU64(state), data, old) : Binary(state, opcode, TypeScalarU64(state), old, data);
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t SharedAtomic64Select(SpirvValueEmitContext& ctx, const IrValue& inst, spv::Op compare) {
|
||||
return SharedAtomic64Binary(ctx, inst, [&](SpirvEmitterState& state, std::uint32_t old, std::uint32_t data) {
|
||||
return Select(state, TypeScalarU64(state), Binary(state, compare, TypeBool(state), data, old), data, old);
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t SharedFloatMinMax64(SpirvValueEmitContext& ctx, const IrValue& inst, bool maxValue) {
|
||||
return SharedAtomic64Binary(ctx, inst, [&](SpirvEmitterState& state, std::uint32_t old, std::uint32_t data) {
|
||||
const AtomicFloatBits bits{state, true};
|
||||
auto result = bits.select(bits.test(maxValue ? spv::OpUGreaterThan : spv::OpULessThan, bits.orderKey(data), bits.orderKey(old)), data, old);
|
||||
result = bits.select(bits.nan(data), old, result);
|
||||
return bits.select(bits.nan(old), data, result);
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t ScalarU64Constant(SpirvEmitterState& state, std::uint32_t value) {
|
||||
return state.module.Constant(spv::OpConstant, TypeScalarU64(state), value, 0u);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::uint32_t AtomicIncrement(SpirvEmitterState& state, std::uint32_t old, std::uint32_t limit) {
|
||||
@@ -1499,6 +1599,99 @@ std::uint32_t EmitSharedAtomicWrap32(SpirvValueEmitContext& ctx, const IrValue&
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicSwap64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Binary(ctx, inst, [](SpirvEmitterState&, std::uint32_t, std::uint32_t data) { return data; });
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicIAdd64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Op(ctx, inst, spv::OpIAdd, false);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicISub64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Op(ctx, inst, spv::OpISub, false);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicRsub64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Op(ctx, inst, spv::OpISub, true);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicInc64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Binary(ctx, inst, [](SpirvEmitterState& state, std::uint32_t old, std::uint32_t limit) {
|
||||
const auto wrap = Binary(state, spv::OpUGreaterThanEqual, TypeBool(state), old, limit);
|
||||
return Select(state, TypeScalarU64(state), wrap, ScalarU64Constant(state, 0u), Binary(state, spv::OpIAdd, TypeScalarU64(state), old, ScalarU64Constant(state, 1u)));
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicDec64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Binary(ctx, inst, [](SpirvEmitterState& state, std::uint32_t old, std::uint32_t limit) {
|
||||
const auto zero = Binary(state, spv::OpIEqual, TypeBool(state), old, ScalarU64Constant(state, 0u));
|
||||
const auto wrap = Binary(state, spv::OpLogicalOr, TypeBool(state), zero, Binary(state, spv::OpUGreaterThan, TypeBool(state), old, limit));
|
||||
return Select(state, TypeScalarU64(state), wrap, limit, Binary(state, spv::OpISub, TypeScalarU64(state), old, ScalarU64Constant(state, 1u)));
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicSMin64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Select(ctx, inst, spv::OpSLessThan);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicUMin64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Select(ctx, inst, spv::OpULessThan);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicSMax64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Select(ctx, inst, spv::OpSGreaterThan);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicUMax64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Select(ctx, inst, spv::OpUGreaterThan);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicAnd64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Op(ctx, inst, spv::OpBitwiseAnd, false);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicOr64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Op(ctx, inst, spv::OpBitwiseOr, false);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicXor64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedAtomic64Op(ctx, inst, spv::OpBitwiseXor, false);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicFMin64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedFloatMinMax64(ctx, inst, false);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicFMax64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return SharedFloatMinMax64(ctx, inst, true);
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicCmpst64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
const auto compare = ScalarU64Argument(ctx, inst, 3u);
|
||||
const auto source = ScalarU64Argument(ctx, inst, 2u);
|
||||
return SharedAtomic64(ctx, inst, [&](SpirvEmitterState& state, std::uint32_t old) {
|
||||
return Select(state, TypeScalarU64(state), Binary(state, spv::OpIEqual, TypeBool(state), old, compare), source, old);
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicCmpstF64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
const auto compare = ScalarU64Argument(ctx, inst, 3u);
|
||||
const auto source = ScalarU64Argument(ctx, inst, 2u);
|
||||
return SharedAtomic64(ctx, inst, [&](SpirvEmitterState& state, std::uint32_t old) {
|
||||
const AtomicFloatBits bits{state, true};
|
||||
return bits.select(bits.equal(old, compare), source, old);
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t EmitSharedAtomicMskor64(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
const auto mask = ScalarU64Argument(ctx, inst, 3u);
|
||||
const auto source = ScalarU64Argument(ctx, inst, 2u);
|
||||
return SharedAtomic64(ctx, inst, [&](SpirvEmitterState& state, std::uint32_t old) {
|
||||
const auto kept = Binary(state, spv::OpBitwiseAnd, TypeScalarU64(state), old, Unary(state, spv::OpNot, TypeScalarU64(state), mask));
|
||||
return Binary(state, spv::OpBitwiseOr, TypeScalarU64(state), kept, source);
|
||||
});
|
||||
}
|
||||
|
||||
std::uint32_t EmitBufferAtomicInc32(SpirvValueEmitContext& ctx, const IrValue& inst) {
|
||||
return EmitAtomicUpdate(ctx, inst, BufferMemory(ctx, inst), AtomicIncrement);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,9 @@ void DefineModule(SpirvEmitterState& state) {
|
||||
state.module.EmitCapability(spv::CapabilityInt64);
|
||||
state.module.EmitCapability(spv::CapabilityInt64Atomics);
|
||||
}
|
||||
if (state.requirements.sharedInt64Atomics) {
|
||||
state.module.EmitCapability(spv::CapabilityInt64);
|
||||
}
|
||||
if (state.clipDistanceVariable != 0) {
|
||||
state.module.EmitCapability(spv::CapabilityClipDistance);
|
||||
}
|
||||
|
||||
@@ -916,6 +916,10 @@ void EmitProgram(SpirvEmitterState& state) {
|
||||
state.module.AddFunction(spv::OpVariable, TypePointer(state, spv::StorageClassFunction, TypeU32(state)), lane.scratchU32Variable, spv::StorageClassFunction);
|
||||
}
|
||||
}
|
||||
if (state.requirements.ldsLock) {
|
||||
state.module.AddFunction(spv::OpStore, EmitLdsLockPointer(state), ConstantU32(state, 0u));
|
||||
state.module.AddFunction(spv::OpControlBarrier, ConstantU32(state, spv::ScopeWorkgroup), ConstantU32(state, spv::ScopeWorkgroup), ConstantU32(state, spv::MemorySemanticsAcquireReleaseMask | spv::MemorySemanticsWorkgroupMemoryMask));
|
||||
}
|
||||
if (state.gdsVariable != 0u) {
|
||||
state.gdsLength = state.module.AllocateId();
|
||||
state.module.AddFunction(spv::OpArrayLength, TypeU32(state), state.gdsLength, state.gdsVariable, 0u);
|
||||
|
||||
@@ -108,6 +108,7 @@ private:
|
||||
bool dsWrite(const RdnaInstruction& inst);
|
||||
bool dsWrite2(const RdnaInstruction& inst);
|
||||
bool dsAtomic2(const RdnaInstruction& inst, IrOpcode opcode, bool returnsValue);
|
||||
bool dsAtomic64(const RdnaInstruction& inst, IrOpcode opcode, bool returnsValue);
|
||||
bool dsAppendConsume(const RdnaInstruction& inst, IrOpcode opcode);
|
||||
bool dsAddtid(const RdnaInstruction& inst, bool write);
|
||||
bool globalLoadAddtid(const RdnaInstruction& inst);
|
||||
|
||||
+70
@@ -276,6 +276,76 @@ bool TranslationContext::emitMemory(const RdnaInstruction& inst) {
|
||||
return dsAtomic2(inst, IrOpcode::SharedAtomicCmpstF32, true);
|
||||
case RdnaOpcode::DsWrapRtnB32:
|
||||
return dsAtomic2(inst, IrOpcode::SharedAtomicWrap32, true);
|
||||
case RdnaOpcode::DsAddU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicIAdd64, false);
|
||||
case RdnaOpcode::DsAddRtnU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicIAdd64, true);
|
||||
case RdnaOpcode::DsSubU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicISub64, false);
|
||||
case RdnaOpcode::DsSubRtnU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicISub64, true);
|
||||
case RdnaOpcode::DsRsubU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicRsub64, false);
|
||||
case RdnaOpcode::DsRsubRtnU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicRsub64, true);
|
||||
case RdnaOpcode::DsIncU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicInc64, false);
|
||||
case RdnaOpcode::DsIncRtnU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicInc64, true);
|
||||
case RdnaOpcode::DsDecU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicDec64, false);
|
||||
case RdnaOpcode::DsDecRtnU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicDec64, true);
|
||||
case RdnaOpcode::DsMinI64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicSMin64, false);
|
||||
case RdnaOpcode::DsMinRtnI64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicSMin64, true);
|
||||
case RdnaOpcode::DsMaxI64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicSMax64, false);
|
||||
case RdnaOpcode::DsMaxRtnI64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicSMax64, true);
|
||||
case RdnaOpcode::DsMinU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicUMin64, false);
|
||||
case RdnaOpcode::DsMinRtnU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicUMin64, true);
|
||||
case RdnaOpcode::DsMaxU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicUMax64, false);
|
||||
case RdnaOpcode::DsMaxRtnU64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicUMax64, true);
|
||||
case RdnaOpcode::DsAndB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicAnd64, false);
|
||||
case RdnaOpcode::DsAndRtnB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicAnd64, true);
|
||||
case RdnaOpcode::DsOrB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicOr64, false);
|
||||
case RdnaOpcode::DsOrRtnB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicOr64, true);
|
||||
case RdnaOpcode::DsXorB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicXor64, false);
|
||||
case RdnaOpcode::DsXorRtnB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicXor64, true);
|
||||
case RdnaOpcode::DsMskorB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicMskor64, false);
|
||||
case RdnaOpcode::DsMskorRtnB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicMskor64, true);
|
||||
case RdnaOpcode::DsCmpstB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicCmpst64, false);
|
||||
case RdnaOpcode::DsCmpstRtnB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicCmpst64, true);
|
||||
case RdnaOpcode::DsCmpstF64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicCmpstF64, false);
|
||||
case RdnaOpcode::DsCmpstRtnF64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicCmpstF64, true);
|
||||
case RdnaOpcode::DsMinF64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicFMin64, false);
|
||||
case RdnaOpcode::DsMinRtnF64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicFMin64, true);
|
||||
case RdnaOpcode::DsMaxF64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicFMax64, false);
|
||||
case RdnaOpcode::DsMaxRtnF64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicFMax64, true);
|
||||
case RdnaOpcode::DsWrxchgRtnB64:
|
||||
return dsAtomic64(inst, IrOpcode::SharedAtomicSwap64, true);
|
||||
case RdnaOpcode::DsNop:
|
||||
emitControlNop();
|
||||
return true;
|
||||
|
||||
+19
@@ -182,6 +182,25 @@ bool TranslationContext::dsAtomic2(const RdnaInstruction& inst, IrOpcode opcode,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TranslationContext::dsAtomic64(const RdnaInstruction& inst, IrOpcode opcode, bool returnsValue) {
|
||||
if (inst.gds) {
|
||||
throw std::runtime_error("64-bit GDS atomics are not supported");
|
||||
}
|
||||
const MemoryInfo memory = sharedMemoryInfoFromInstruction(inst);
|
||||
const IrU32 address = readU32(inst.source0);
|
||||
const IrU64 data0 = readU64(inst.source1);
|
||||
IrValue& active = ir.GetExec();
|
||||
IrValue* old;
|
||||
if (IrOpcodeOperandCount(opcode) == 4u) {
|
||||
const IrU64 data1 = readU64(inst.source2);
|
||||
old = &ir.Emit(opcode, IrOpcodeType(opcode), {&address.Value(), &data0.Value(), &data1.Value(), &active}, addMemoryInfo(memory, inst.programCounter));
|
||||
} else {
|
||||
old = &ir.Emit(opcode, IrOpcodeType(opcode), {&address.Value(), &data0.Value(), &active}, addMemoryInfo(memory, inst.programCounter));
|
||||
}
|
||||
if (returnsValue) writeOperand(inst.destination, old);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TranslationContext::dsAppendConsume(const RdnaInstruction& inst, IrOpcode opcode) {
|
||||
const MemoryInfo memory = sharedMemoryInfoFromInstruction(inst);
|
||||
const IrU32 address = readU32(makeM0Operand());
|
||||
|
||||
@@ -70,3 +70,4 @@ Throughout the project, every function at every stage either **does exactly what
|
||||
- [libSceAudiodec](../../core/libs/prx/libSceAudiodec/Export.cpp) throws for the 24-bit PCM word size (`iBwPcm` 0): its sample layout is unknown. ATRAC9 decoding is covered only by configuration and error tests, as no ATRAC9 encoder is available for a fixture.
|
||||
- [libScePngEnc](../../core/libs/prx/libScePngEnc/Export.cpp) honours `filter_type` only as all filters (adaptive) or a single filter: the [PNG encoder](../../core/Decoder/Png/src/Png.cpp) (stb) cannot restrict adaptive filtering to a subset, so the first filter in the mask is used.
|
||||
- [libScePlayerInvitationDialog](../../core/libs/prx/libScePlayerInvitationDialog/libScePlayerInvitationDialog.cpp) simulates dialog completion without displaying UI or sending invitations; its parameter ABI remains unverified.
|
||||
- [64-bit LDS atomics](../../core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp) (`ds_*_u64`, `ds_*_b64`, `ds_*_f64`) read and write the two dwords under a workgroup lock stored after the guest LDS, as LDS is a 32-bit array without 64-bit atomics. They are atomic with respect to each other only: 32-bit accesses to the same dwords issued concurrently are not ordered by the lock. 64-bit GDS atomics throw. `ds_min/max(_rtn)_f64` and `ds_cmpst(_rtn)_f64` follow the NaN and signed-zero rules measured for the f32 forms; the f64 forms were not measured on hardware.
|
||||
|
||||
Reference in New Issue
Block a user