diff options
| author | 2021-04-23 17:47:54 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:30 -0400 | |
| commit | 7ecc6de56ae01602b25408db8b6658d7a41a419a (patch) | |
| tree | 2bff17b5b55e9f37ac5e4031c77962216813d5d5 /src/shader_recompiler/frontend/ir | |
| parent | shader: Initial OpenGL implementation (diff) | |
| download | yuzu-7ecc6de56ae01602b25408db8b6658d7a41a419a.tar.gz yuzu-7ecc6de56ae01602b25408db8b6658d7a41a419a.tar.xz yuzu-7ecc6de56ae01602b25408db8b6658d7a41a419a.zip | |
shader: Implement Int32 SUATOM/SURED
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.cpp | 89 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.h | 26 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/microinstruction.cpp | 33 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/opcodes.inc | 38 |
4 files changed, 186 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index 5913fdeff..354d72c9b 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -1869,6 +1869,95 @@ void IREmitter::ImageWrite(const Value& handle, const Value& coords, const Value | |||
| 1869 | Inst(op, Flags{info}, handle, coords, color); | 1869 | Inst(op, Flags{info}, handle, coords, color); |
| 1870 | } | 1870 | } |
| 1871 | 1871 | ||
| 1872 | Value IREmitter::ImageAtomicIAdd(const Value& handle, const Value& coords, const Value& value, | ||
| 1873 | TextureInstInfo info) { | ||
| 1874 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicIAdd32 | ||
| 1875 | : Opcode::BindlessImageAtomicIAdd32}; | ||
| 1876 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1877 | } | ||
| 1878 | |||
| 1879 | Value IREmitter::ImageAtomicSMin(const Value& handle, const Value& coords, const Value& value, | ||
| 1880 | TextureInstInfo info) { | ||
| 1881 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicSMin32 | ||
| 1882 | : Opcode::BindlessImageAtomicSMin32}; | ||
| 1883 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1884 | } | ||
| 1885 | |||
| 1886 | Value IREmitter::ImageAtomicUMin(const Value& handle, const Value& coords, const Value& value, | ||
| 1887 | TextureInstInfo info) { | ||
| 1888 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicUMin32 | ||
| 1889 | : Opcode::BindlessImageAtomicUMin32}; | ||
| 1890 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1891 | } | ||
| 1892 | |||
| 1893 | Value IREmitter::ImageAtomicIMin(const Value& handle, const Value& coords, const Value& value, | ||
| 1894 | bool is_signed, TextureInstInfo info) { | ||
| 1895 | return is_signed ? ImageAtomicSMin(handle, coords, value, info) | ||
| 1896 | : ImageAtomicUMin(handle, coords, value, info); | ||
| 1897 | } | ||
| 1898 | |||
| 1899 | Value IREmitter::ImageAtomicSMax(const Value& handle, const Value& coords, const Value& value, | ||
| 1900 | TextureInstInfo info) { | ||
| 1901 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicSMax32 | ||
| 1902 | : Opcode::BindlessImageAtomicSMax32}; | ||
| 1903 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1904 | } | ||
| 1905 | |||
| 1906 | Value IREmitter::ImageAtomicUMax(const Value& handle, const Value& coords, const Value& value, | ||
| 1907 | TextureInstInfo info) { | ||
| 1908 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicUMax32 | ||
| 1909 | : Opcode::BindlessImageAtomicUMax32}; | ||
| 1910 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1911 | } | ||
| 1912 | |||
| 1913 | Value IREmitter::ImageAtomicIMax(const Value& handle, const Value& coords, const Value& value, | ||
| 1914 | bool is_signed, TextureInstInfo info) { | ||
| 1915 | return is_signed ? ImageAtomicSMax(handle, coords, value, info) | ||
| 1916 | : ImageAtomicUMax(handle, coords, value, info); | ||
| 1917 | } | ||
| 1918 | |||
| 1919 | Value IREmitter::ImageAtomicInc(const Value& handle, const Value& coords, const Value& value, | ||
| 1920 | TextureInstInfo info) { | ||
| 1921 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicInc32 | ||
| 1922 | : Opcode::BindlessImageAtomicInc32}; | ||
| 1923 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1924 | } | ||
| 1925 | |||
| 1926 | Value IREmitter::ImageAtomicDec(const Value& handle, const Value& coords, const Value& value, | ||
| 1927 | TextureInstInfo info) { | ||
| 1928 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicDec32 | ||
| 1929 | : Opcode::BindlessImageAtomicDec32}; | ||
| 1930 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1931 | } | ||
| 1932 | |||
| 1933 | Value IREmitter::ImageAtomicAnd(const Value& handle, const Value& coords, const Value& value, | ||
| 1934 | TextureInstInfo info) { | ||
| 1935 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicAnd32 | ||
| 1936 | : Opcode::BindlessImageAtomicAnd32}; | ||
| 1937 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1938 | } | ||
| 1939 | |||
| 1940 | Value IREmitter::ImageAtomicOr(const Value& handle, const Value& coords, const Value& value, | ||
| 1941 | TextureInstInfo info) { | ||
| 1942 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicOr32 | ||
| 1943 | : Opcode::BindlessImageAtomicOr32}; | ||
| 1944 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1945 | } | ||
| 1946 | |||
| 1947 | Value IREmitter::ImageAtomicXor(const Value& handle, const Value& coords, const Value& value, | ||
| 1948 | TextureInstInfo info) { | ||
| 1949 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicXor32 | ||
| 1950 | : Opcode::BindlessImageAtomicXor32}; | ||
| 1951 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1952 | } | ||
| 1953 | |||
| 1954 | Value IREmitter::ImageAtomicExchange(const Value& handle, const Value& coords, const Value& value, | ||
| 1955 | TextureInstInfo info) { | ||
| 1956 | const Opcode op{handle.IsImmediate() ? Opcode::BoundImageAtomicExchange32 | ||
| 1957 | : Opcode::BindlessImageAtomicExchange32}; | ||
| 1958 | return Inst(op, Flags{info}, handle, coords, value); | ||
| 1959 | } | ||
| 1960 | |||
| 1872 | U1 IREmitter::VoteAll(const U1& value) { | 1961 | U1 IREmitter::VoteAll(const U1& value) { |
| 1873 | return Inst<U1>(Opcode::VoteAll, value); | 1962 | return Inst<U1>(Opcode::VoteAll, value); |
| 1874 | } | 1963 | } |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index a12919283..4e614d424 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -334,6 +334,32 @@ public: | |||
| 334 | [[nodiscard]] void ImageWrite(const Value& handle, const Value& coords, const Value& color, | 334 | [[nodiscard]] void ImageWrite(const Value& handle, const Value& coords, const Value& color, |
| 335 | TextureInstInfo info); | 335 | TextureInstInfo info); |
| 336 | 336 | ||
| 337 | [[nodiscard]] Value ImageAtomicIAdd(const Value& handle, const Value& coords, | ||
| 338 | const Value& value, TextureInstInfo info); | ||
| 339 | [[nodiscard]] Value ImageAtomicSMin(const Value& handle, const Value& coords, | ||
| 340 | const Value& value, TextureInstInfo info); | ||
| 341 | [[nodiscard]] Value ImageAtomicUMin(const Value& handle, const Value& coords, | ||
| 342 | const Value& value, TextureInstInfo info); | ||
| 343 | [[nodiscard]] Value ImageAtomicIMin(const Value& handle, const Value& coords, | ||
| 344 | const Value& value, bool is_signed, TextureInstInfo info); | ||
| 345 | [[nodiscard]] Value ImageAtomicSMax(const Value& handle, const Value& coords, | ||
| 346 | const Value& value, TextureInstInfo info); | ||
| 347 | [[nodiscard]] Value ImageAtomicUMax(const Value& handle, const Value& coords, | ||
| 348 | const Value& value, TextureInstInfo info); | ||
| 349 | [[nodiscard]] Value ImageAtomicIMax(const Value& handle, const Value& coords, | ||
| 350 | const Value& value, bool is_signed, TextureInstInfo info); | ||
| 351 | [[nodiscard]] Value ImageAtomicInc(const Value& handle, const Value& coords, const Value& value, | ||
| 352 | TextureInstInfo info); | ||
| 353 | [[nodiscard]] Value ImageAtomicDec(const Value& handle, const Value& coords, const Value& value, | ||
| 354 | TextureInstInfo info); | ||
| 355 | [[nodiscard]] Value ImageAtomicAnd(const Value& handle, const Value& coords, const Value& value, | ||
| 356 | TextureInstInfo info); | ||
| 357 | [[nodiscard]] Value ImageAtomicOr(const Value& handle, const Value& coords, const Value& value, | ||
| 358 | TextureInstInfo info); | ||
| 359 | [[nodiscard]] Value ImageAtomicXor(const Value& handle, const Value& coords, const Value& value, | ||
| 360 | TextureInstInfo info); | ||
| 361 | [[nodiscard]] Value ImageAtomicExchange(const Value& handle, const Value& coords, | ||
| 362 | const Value& value, TextureInstInfo info); | ||
| 337 | [[nodiscard]] U1 VoteAll(const U1& value); | 363 | [[nodiscard]] U1 VoteAll(const U1& value); |
| 338 | [[nodiscard]] U1 VoteAny(const U1& value); | 364 | [[nodiscard]] U1 VoteAny(const U1& value); |
| 339 | [[nodiscard]] U1 VoteEqual(const U1& value); | 365 | [[nodiscard]] U1 VoteEqual(const U1& value); |
diff --git a/src/shader_recompiler/frontend/ir/microinstruction.cpp b/src/shader_recompiler/frontend/ir/microinstruction.cpp index dba902186..616ef17d4 100644 --- a/src/shader_recompiler/frontend/ir/microinstruction.cpp +++ b/src/shader_recompiler/frontend/ir/microinstruction.cpp | |||
| @@ -166,6 +166,39 @@ bool Inst::MayHaveSideEffects() const noexcept { | |||
| 166 | case Opcode::BindlessImageWrite: | 166 | case Opcode::BindlessImageWrite: |
| 167 | case Opcode::BoundImageWrite: | 167 | case Opcode::BoundImageWrite: |
| 168 | case Opcode::ImageWrite: | 168 | case Opcode::ImageWrite: |
| 169 | case IR::Opcode::BindlessImageAtomicIAdd32: | ||
| 170 | case IR::Opcode::BindlessImageAtomicSMin32: | ||
| 171 | case IR::Opcode::BindlessImageAtomicUMin32: | ||
| 172 | case IR::Opcode::BindlessImageAtomicSMax32: | ||
| 173 | case IR::Opcode::BindlessImageAtomicUMax32: | ||
| 174 | case IR::Opcode::BindlessImageAtomicInc32: | ||
| 175 | case IR::Opcode::BindlessImageAtomicDec32: | ||
| 176 | case IR::Opcode::BindlessImageAtomicAnd32: | ||
| 177 | case IR::Opcode::BindlessImageAtomicOr32: | ||
| 178 | case IR::Opcode::BindlessImageAtomicXor32: | ||
| 179 | case IR::Opcode::BindlessImageAtomicExchange32: | ||
| 180 | case IR::Opcode::BoundImageAtomicIAdd32: | ||
| 181 | case IR::Opcode::BoundImageAtomicSMin32: | ||
| 182 | case IR::Opcode::BoundImageAtomicUMin32: | ||
| 183 | case IR::Opcode::BoundImageAtomicSMax32: | ||
| 184 | case IR::Opcode::BoundImageAtomicUMax32: | ||
| 185 | case IR::Opcode::BoundImageAtomicInc32: | ||
| 186 | case IR::Opcode::BoundImageAtomicDec32: | ||
| 187 | case IR::Opcode::BoundImageAtomicAnd32: | ||
| 188 | case IR::Opcode::BoundImageAtomicOr32: | ||
| 189 | case IR::Opcode::BoundImageAtomicXor32: | ||
| 190 | case IR::Opcode::BoundImageAtomicExchange32: | ||
| 191 | case IR::Opcode::ImageAtomicIAdd32: | ||
| 192 | case IR::Opcode::ImageAtomicSMin32: | ||
| 193 | case IR::Opcode::ImageAtomicUMin32: | ||
| 194 | case IR::Opcode::ImageAtomicSMax32: | ||
| 195 | case IR::Opcode::ImageAtomicUMax32: | ||
| 196 | case IR::Opcode::ImageAtomicInc32: | ||
| 197 | case IR::Opcode::ImageAtomicDec32: | ||
| 198 | case IR::Opcode::ImageAtomicAnd32: | ||
| 199 | case IR::Opcode::ImageAtomicOr32: | ||
| 200 | case IR::Opcode::ImageAtomicXor32: | ||
| 201 | case IR::Opcode::ImageAtomicExchange32: | ||
| 169 | return true; | 202 | return true; |
| 170 | default: | 203 | default: |
| 171 | return false; | 204 | return false; |
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc index b14719c51..9165421f8 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.inc +++ b/src/shader_recompiler/frontend/ir/opcodes.inc | |||
| @@ -496,6 +496,44 @@ OPCODE(ImageGradient, F32x4, Opaq | |||
| 496 | OPCODE(ImageRead, U32x4, Opaque, Opaque, ) | 496 | OPCODE(ImageRead, U32x4, Opaque, Opaque, ) |
| 497 | OPCODE(ImageWrite, Void, Opaque, Opaque, U32x4, ) | 497 | OPCODE(ImageWrite, Void, Opaque, Opaque, U32x4, ) |
| 498 | 498 | ||
| 499 | // Atomic Image operations | ||
| 500 | |||
| 501 | OPCODE(BindlessImageAtomicIAdd32, U32, U32, Opaque, U32, ) | ||
| 502 | OPCODE(BindlessImageAtomicSMin32, U32, U32, Opaque, U32, ) | ||
| 503 | OPCODE(BindlessImageAtomicUMin32, U32, U32, Opaque, U32, ) | ||
| 504 | OPCODE(BindlessImageAtomicSMax32, U32, U32, Opaque, U32, ) | ||
| 505 | OPCODE(BindlessImageAtomicUMax32, U32, U32, Opaque, U32, ) | ||
| 506 | OPCODE(BindlessImageAtomicInc32, U32, U32, Opaque, U32, ) | ||
| 507 | OPCODE(BindlessImageAtomicDec32, U32, U32, Opaque, U32, ) | ||
| 508 | OPCODE(BindlessImageAtomicAnd32, U32, U32, Opaque, U32, ) | ||
| 509 | OPCODE(BindlessImageAtomicOr32, U32, U32, Opaque, U32, ) | ||
| 510 | OPCODE(BindlessImageAtomicXor32, U32, U32, Opaque, U32, ) | ||
| 511 | OPCODE(BindlessImageAtomicExchange32, U32, U32, Opaque, U32, ) | ||
| 512 | |||
| 513 | OPCODE(BoundImageAtomicIAdd32, U32, U32, Opaque, U32, ) | ||
| 514 | OPCODE(BoundImageAtomicSMin32, U32, U32, Opaque, U32, ) | ||
| 515 | OPCODE(BoundImageAtomicUMin32, U32, U32, Opaque, U32, ) | ||
| 516 | OPCODE(BoundImageAtomicSMax32, U32, U32, Opaque, U32, ) | ||
| 517 | OPCODE(BoundImageAtomicUMax32, U32, U32, Opaque, U32, ) | ||
| 518 | OPCODE(BoundImageAtomicInc32, U32, U32, Opaque, U32, ) | ||
| 519 | OPCODE(BoundImageAtomicDec32, U32, U32, Opaque, U32, ) | ||
| 520 | OPCODE(BoundImageAtomicAnd32, U32, U32, Opaque, U32, ) | ||
| 521 | OPCODE(BoundImageAtomicOr32, U32, U32, Opaque, U32, ) | ||
| 522 | OPCODE(BoundImageAtomicXor32, U32, U32, Opaque, U32, ) | ||
| 523 | OPCODE(BoundImageAtomicExchange32, U32, U32, Opaque, U32, ) | ||
| 524 | |||
| 525 | OPCODE(ImageAtomicIAdd32, U32, Opaque, Opaque, U32, ) | ||
| 526 | OPCODE(ImageAtomicSMin32, U32, Opaque, Opaque, U32, ) | ||
| 527 | OPCODE(ImageAtomicUMin32, U32, Opaque, Opaque, U32, ) | ||
| 528 | OPCODE(ImageAtomicSMax32, U32, Opaque, Opaque, U32, ) | ||
| 529 | OPCODE(ImageAtomicUMax32, U32, Opaque, Opaque, U32, ) | ||
| 530 | OPCODE(ImageAtomicInc32, U32, Opaque, Opaque, U32, ) | ||
| 531 | OPCODE(ImageAtomicDec32, U32, Opaque, Opaque, U32, ) | ||
| 532 | OPCODE(ImageAtomicAnd32, U32, Opaque, Opaque, U32, ) | ||
| 533 | OPCODE(ImageAtomicOr32, U32, Opaque, Opaque, U32, ) | ||
| 534 | OPCODE(ImageAtomicXor32, U32, Opaque, Opaque, U32, ) | ||
| 535 | OPCODE(ImageAtomicExchange32, U32, Opaque, Opaque, U32, ) | ||
| 536 | |||
| 499 | // Warp operations | 537 | // Warp operations |
| 500 | OPCODE(LaneId, U32, ) | 538 | OPCODE(LaneId, U32, ) |
| 501 | OPCODE(VoteAll, U1, U1, ) | 539 | OPCODE(VoteAll, U1, U1, ) |