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