summaryrefslogtreecommitdiff
path: root/src/video_core/shader/node.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/shader/node.h')
-rw-r--r--src/video_core/shader/node.h57
1 files changed, 43 insertions, 14 deletions
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h
index b29aedce8..b47b201cf 100644
--- a/src/video_core/shader/node.h
+++ b/src/video_core/shader/node.h
@@ -7,6 +7,7 @@
7#include <array> 7#include <array>
8#include <cstddef> 8#include <cstddef>
9#include <memory> 9#include <memory>
10#include <optional>
10#include <string> 11#include <string>
11#include <tuple> 12#include <tuple>
12#include <utility> 13#include <utility>
@@ -148,7 +149,14 @@ enum class OperationCode {
148 TextureQueryLod, /// (MetaTexture, float[N] coords) -> float4 149 TextureQueryLod, /// (MetaTexture, float[N] coords) -> float4
149 TexelFetch, /// (MetaTexture, int[N], int) -> float4 150 TexelFetch, /// (MetaTexture, int[N], int) -> float4
150 151
151 ImageStore, /// (MetaImage, float[N] coords) -> void 152 ImageStore, /// (MetaImage, int[N] values) -> void
153 AtomicImageAdd, /// (MetaImage, int[N] coords) -> void
154 AtomicImageMin, /// (MetaImage, int[N] coords) -> void
155 AtomicImageMax, /// (MetaImage, int[N] coords) -> void
156 AtomicImageAnd, /// (MetaImage, int[N] coords) -> void
157 AtomicImageOr, /// (MetaImage, int[N] coords) -> void
158 AtomicImageXor, /// (MetaImage, int[N] coords) -> void
159 AtomicImageExchange, /// (MetaImage, int[N] coords) -> void
152 160
153 Branch, /// (uint branch_target) -> void 161 Branch, /// (uint branch_target) -> void
154 BranchIndirect, /// (uint branch_target) -> void 162 BranchIndirect, /// (uint branch_target) -> void
@@ -275,25 +283,32 @@ private:
275 283
276class Image final { 284class Image final {
277public: 285public:
278 constexpr explicit Image(u64 offset, std::size_t index, Tegra::Shader::ImageType type) 286 constexpr explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type,
279 : offset{offset}, index{index}, type{type}, is_bindless{false} {} 287 std::optional<Tegra::Shader::ImageAtomicSize> size)
288 : offset{offset}, index{index}, type{type}, is_bindless{false}, size{size} {}
280 289
281 constexpr explicit Image(u32 cbuf_index, u32 cbuf_offset, std::size_t index, 290 constexpr explicit Image(u32 cbuf_index, u32 cbuf_offset, std::size_t index,
282 Tegra::Shader::ImageType type) 291 Tegra::Shader::ImageType type,
292 std::optional<Tegra::Shader::ImageAtomicSize> size)
283 : offset{(static_cast<u64>(cbuf_index) << 32) | cbuf_offset}, index{index}, type{type}, 293 : offset{(static_cast<u64>(cbuf_index) << 32) | cbuf_offset}, index{index}, type{type},
284 is_bindless{true} {} 294 is_bindless{true}, size{size} {}
285 295
286 constexpr explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type, 296 constexpr explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type,
287 bool is_bindless, bool is_written, bool is_read) 297 bool is_bindless, bool is_written, bool is_read,
298 std::optional<Tegra::Shader::ImageAtomicSize> size)
288 : offset{offset}, index{index}, type{type}, is_bindless{is_bindless}, 299 : offset{offset}, index{index}, type{type}, is_bindless{is_bindless},
289 is_written{is_written}, is_read{is_read} {} 300 is_written{is_written}, is_read{is_read}, size{size} {}
301
302 void MarkWrite() {
303 is_written = true;
304 }
290 305
291 void MarkRead() { 306 void MarkRead() {
292 is_read = true; 307 is_read = true;
293 } 308 }
294 309
295 void MarkWrite() { 310 void SetSize(Tegra::Shader::ImageAtomicSize size_) {
296 is_written = true; 311 size = size_;
297 } 312 }
298 313
299 constexpr std::size_t GetOffset() const { 314 constexpr std::size_t GetOffset() const {
@@ -312,25 +327,39 @@ public:
312 return is_bindless; 327 return is_bindless;
313 } 328 }
314 329
315 constexpr bool IsRead() const {
316 return is_read;
317 }
318
319 constexpr bool IsWritten() const { 330 constexpr bool IsWritten() const {
320 return is_written; 331 return is_written;
321 } 332 }
322 333
334 constexpr bool IsRead() const {
335 return is_read;
336 }
337
323 constexpr std::pair<u32, u32> GetBindlessCBuf() const { 338 constexpr std::pair<u32, u32> GetBindlessCBuf() const {
324 return {static_cast<u32>(offset >> 32), static_cast<u32>(offset)}; 339 return {static_cast<u32>(offset >> 32), static_cast<u32>(offset)};
325 } 340 }
326 341
342 constexpr bool IsSizeKnown() const {
343 return size.has_value();
344 }
345
346 constexpr Tegra::Shader::ImageAtomicSize GetSize() const {
347 return size.value();
348 }
349
350 constexpr bool operator<(const Image& rhs) const {
351 return std::tie(offset, index, type, size, is_bindless) <
352 std::tie(rhs.offset, rhs.index, rhs.type, rhs.size, rhs.is_bindless);
353 }
354
327private: 355private:
328 u64 offset{}; 356 u64 offset{};
329 std::size_t index{}; 357 std::size_t index{};
330 Tegra::Shader::ImageType type{}; 358 Tegra::Shader::ImageType type{};
331 bool is_bindless{}; 359 bool is_bindless{};
332 bool is_read{};
333 bool is_written{}; 360 bool is_written{};
361 bool is_read{};
362 std::optional<Tegra::Shader::ImageAtomicSize> size{};
334}; 363};
335 364
336struct GlobalMemoryBase { 365struct GlobalMemoryBase {