diff options
| author | 2020-04-16 01:34:45 -0300 | |
|---|---|---|
| committer | 2020-04-23 18:00:06 -0300 | |
| commit | 72deb773fdcc59b1df9752de4e846422b7bb5280 (patch) | |
| tree | 524006956b6dbb6789831652129013e54f185f16 /src/video_core/shader/node.h | |
| parent | Merge pull request #3768 from H27CK/cmd-title-fmt (diff) | |
| download | yuzu-72deb773fdcc59b1df9752de4e846422b7bb5280.tar.gz yuzu-72deb773fdcc59b1df9752de4e846422b7bb5280.tar.xz yuzu-72deb773fdcc59b1df9752de4e846422b7bb5280.zip | |
shader_ir: Turn classes into data structures
Diffstat (limited to 'src/video_core/shader/node.h')
| -rw-r--r-- | src/video_core/shader/node.h | 129 |
1 files changed, 25 insertions, 104 deletions
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h index 3eee961f5..d0656b581 100644 --- a/src/video_core/shader/node.h +++ b/src/video_core/shader/node.h | |||
| @@ -265,76 +265,30 @@ class ArraySamplerNode; | |||
| 265 | using TrackSamplerData = std::variant<BindlessSamplerNode, ArraySamplerNode>; | 265 | using TrackSamplerData = std::variant<BindlessSamplerNode, ArraySamplerNode>; |
| 266 | using TrackSampler = std::shared_ptr<TrackSamplerData>; | 266 | using TrackSampler = std::shared_ptr<TrackSamplerData>; |
| 267 | 267 | ||
| 268 | class Sampler { | 268 | struct Sampler { |
| 269 | public: | 269 | /// Bound samplers constructor |
| 270 | /// This constructor is for bound samplers | ||
| 271 | constexpr explicit Sampler(u32 index, u32 offset, Tegra::Shader::TextureType type, | 270 | constexpr explicit Sampler(u32 index, u32 offset, Tegra::Shader::TextureType type, |
| 272 | bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) | 271 | bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) |
| 273 | : index{index}, offset{offset}, type{type}, is_array{is_array}, is_shadow{is_shadow}, | 272 | : index{index}, offset{offset}, type{type}, is_array{is_array}, is_shadow{is_shadow}, |
| 274 | is_buffer{is_buffer}, is_indexed{is_indexed} {} | 273 | is_buffer{is_buffer}, is_indexed{is_indexed} {} |
| 275 | 274 | ||
| 276 | /// This constructor is for bindless samplers | 275 | /// Bindless samplers constructor |
| 277 | constexpr explicit Sampler(u32 index, u32 offset, u32 buffer, Tegra::Shader::TextureType type, | 276 | constexpr explicit Sampler(u32 index, u32 offset, u32 buffer, Tegra::Shader::TextureType type, |
| 278 | bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) | 277 | bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) |
| 279 | : index{index}, offset{offset}, buffer{buffer}, type{type}, is_array{is_array}, | 278 | : index{index}, offset{offset}, buffer{buffer}, type{type}, is_array{is_array}, |
| 280 | is_shadow{is_shadow}, is_buffer{is_buffer}, is_bindless{true}, is_indexed{is_indexed} {} | 279 | is_shadow{is_shadow}, is_buffer{is_buffer}, is_bindless{true}, is_indexed{is_indexed} {} |
| 281 | 280 | ||
| 282 | constexpr u32 GetIndex() const { | 281 | u32 index = 0; ///< Emulated index given for the this sampler. |
| 283 | return index; | 282 | u32 offset = 0; ///< Offset in the const buffer from where the sampler is being read. |
| 284 | } | 283 | u32 buffer = 0; ///< Buffer where the bindless sampler is being read (unused on bound samplers). |
| 285 | 284 | u32 size = 1; ///< Size of the sampler. | |
| 286 | constexpr u32 GetOffset() const { | ||
| 287 | return offset; | ||
| 288 | } | ||
| 289 | |||
| 290 | constexpr u32 GetBuffer() const { | ||
| 291 | return buffer; | ||
| 292 | } | ||
| 293 | |||
| 294 | constexpr Tegra::Shader::TextureType GetType() const { | ||
| 295 | return type; | ||
| 296 | } | ||
| 297 | |||
| 298 | constexpr bool IsArray() const { | ||
| 299 | return is_array; | ||
| 300 | } | ||
| 301 | |||
| 302 | constexpr bool IsShadow() const { | ||
| 303 | return is_shadow; | ||
| 304 | } | ||
| 305 | |||
| 306 | constexpr bool IsBuffer() const { | ||
| 307 | return is_buffer; | ||
| 308 | } | ||
| 309 | |||
| 310 | constexpr bool IsBindless() const { | ||
| 311 | return is_bindless; | ||
| 312 | } | ||
| 313 | |||
| 314 | constexpr bool IsIndexed() const { | ||
| 315 | return is_indexed; | ||
| 316 | } | ||
| 317 | |||
| 318 | constexpr u32 Size() const { | ||
| 319 | return size; | ||
| 320 | } | ||
| 321 | |||
| 322 | constexpr void SetSize(u32 new_size) { | ||
| 323 | size = new_size; | ||
| 324 | } | ||
| 325 | |||
| 326 | private: | ||
| 327 | u32 index{}; ///< Emulated index given for the this sampler. | ||
| 328 | u32 offset{}; ///< Offset in the const buffer from where the sampler is being read. | ||
| 329 | u32 buffer{}; ///< Buffer where the bindless sampler is being read (unused on bound samplers). | ||
| 330 | u32 size{1}; ///< Size of the sampler. | ||
| 331 | 285 | ||
| 332 | Tegra::Shader::TextureType type{}; ///< The type used to sample this texture (Texture2D, etc) | 286 | Tegra::Shader::TextureType type{}; ///< The type used to sample this texture (Texture2D, etc) |
| 333 | bool is_array{}; ///< Whether the texture is being sampled as an array texture or not. | 287 | bool is_array = false; ///< Whether the texture is being sampled as an array texture or not. |
| 334 | bool is_shadow{}; ///< Whether the texture is being sampled as a depth texture or not. | 288 | bool is_shadow = false; ///< Whether the texture is being sampled as a depth texture or not. |
| 335 | bool is_buffer{}; ///< Whether the texture is a texture buffer without sampler. | 289 | bool is_buffer = false; ///< Whether the texture is a texture buffer without sampler. |
| 336 | bool is_bindless{}; ///< Whether this sampler belongs to a bindless texture or not. | 290 | bool is_bindless = false; ///< Whether this sampler belongs to a bindless texture or not. |
| 337 | bool is_indexed{}; ///< Whether this sampler is an indexed array of textures. | 291 | bool is_indexed = false; ///< Whether this sampler is an indexed array of textures. |
| 338 | }; | 292 | }; |
| 339 | 293 | ||
| 340 | /// Represents a tracked bindless sampler into a direct const buffer | 294 | /// Represents a tracked bindless sampler into a direct const buffer |
| @@ -379,13 +333,13 @@ private: | |||
| 379 | u32 offset; | 333 | u32 offset; |
| 380 | }; | 334 | }; |
| 381 | 335 | ||
| 382 | class Image final { | 336 | struct Image { |
| 383 | public: | 337 | public: |
| 384 | /// This constructor is for bound images | 338 | /// Bound images constructor |
| 385 | constexpr explicit Image(u32 index, u32 offset, Tegra::Shader::ImageType type) | 339 | constexpr explicit Image(u32 index, u32 offset, Tegra::Shader::ImageType type) |
| 386 | : index{index}, offset{offset}, type{type} {} | 340 | : index{index}, offset{offset}, type{type} {} |
| 387 | 341 | ||
| 388 | /// This constructor is for bindless samplers | 342 | /// Bindless samplers constructor |
| 389 | constexpr explicit Image(u32 index, u32 offset, u32 buffer, Tegra::Shader::ImageType type) | 343 | constexpr explicit Image(u32 index, u32 offset, u32 buffer, Tegra::Shader::ImageType type) |
| 390 | : index{index}, offset{offset}, buffer{buffer}, type{type}, is_bindless{true} {} | 344 | : index{index}, offset{offset}, buffer{buffer}, type{type}, is_bindless{true} {} |
| 391 | 345 | ||
| @@ -403,53 +357,20 @@ public: | |||
| 403 | is_atomic = true; | 357 | is_atomic = true; |
| 404 | } | 358 | } |
| 405 | 359 | ||
| 406 | constexpr u32 GetIndex() const { | 360 | u32 index = 0; |
| 407 | return index; | 361 | u32 offset = 0; |
| 408 | } | 362 | u32 buffer = 0; |
| 409 | |||
| 410 | constexpr u32 GetOffset() const { | ||
| 411 | return offset; | ||
| 412 | } | ||
| 413 | |||
| 414 | constexpr u32 GetBuffer() const { | ||
| 415 | return buffer; | ||
| 416 | } | ||
| 417 | |||
| 418 | constexpr Tegra::Shader::ImageType GetType() const { | ||
| 419 | return type; | ||
| 420 | } | ||
| 421 | |||
| 422 | constexpr bool IsBindless() const { | ||
| 423 | return is_bindless; | ||
| 424 | } | ||
| 425 | |||
| 426 | constexpr bool IsWritten() const { | ||
| 427 | return is_written; | ||
| 428 | } | ||
| 429 | |||
| 430 | constexpr bool IsRead() const { | ||
| 431 | return is_read; | ||
| 432 | } | ||
| 433 | |||
| 434 | constexpr bool IsAtomic() const { | ||
| 435 | return is_atomic; | ||
| 436 | } | ||
| 437 | |||
| 438 | private: | ||
| 439 | u32 index{}; | ||
| 440 | u32 offset{}; | ||
| 441 | u32 buffer{}; | ||
| 442 | 363 | ||
| 443 | Tegra::Shader::ImageType type{}; | 364 | Tegra::Shader::ImageType type{}; |
| 444 | bool is_bindless{}; | 365 | bool is_bindless = false; |
| 445 | bool is_written{}; | 366 | bool is_written = false; |
| 446 | bool is_read{}; | 367 | bool is_read = false; |
| 447 | bool is_atomic{}; | 368 | bool is_atomic = false; |
| 448 | }; | 369 | }; |
| 449 | 370 | ||
| 450 | struct GlobalMemoryBase { | 371 | struct GlobalMemoryBase { |
| 451 | u32 cbuf_index{}; | 372 | u32 cbuf_index = 0; |
| 452 | u32 cbuf_offset{}; | 373 | u32 cbuf_offset = 0; |
| 453 | 374 | ||
| 454 | bool operator<(const GlobalMemoryBase& rhs) const { | 375 | bool operator<(const GlobalMemoryBase& rhs) const { |
| 455 | return std::tie(cbuf_index, cbuf_offset) < std::tie(rhs.cbuf_index, rhs.cbuf_offset); | 376 | return std::tie(cbuf_index, cbuf_offset) < std::tie(rhs.cbuf_index, rhs.cbuf_offset); |
| @@ -463,7 +384,7 @@ struct MetaArithmetic { | |||
| 463 | 384 | ||
| 464 | /// Parameters describing a texture sampler | 385 | /// Parameters describing a texture sampler |
| 465 | struct MetaTexture { | 386 | struct MetaTexture { |
| 466 | const Sampler& sampler; | 387 | Sampler sampler; |
| 467 | Node array; | 388 | Node array; |
| 468 | Node depth_compare; | 389 | Node depth_compare; |
| 469 | std::vector<Node> aoffi; | 390 | std::vector<Node> aoffi; |