diff options
Diffstat (limited to 'src/video_core/shader/node.h')
| -rw-r--r-- | src/video_core/shader/node.h | 101 |
1 files changed, 40 insertions, 61 deletions
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h index 447fb5c1d..4300d9ff4 100644 --- a/src/video_core/shader/node.h +++ b/src/video_core/shader/node.h | |||
| @@ -230,62 +230,49 @@ using NodeBlock = std::vector<Node>; | |||
| 230 | class Sampler { | 230 | class Sampler { |
| 231 | public: | 231 | public: |
| 232 | /// This constructor is for bound samplers | 232 | /// This constructor is for bound samplers |
| 233 | explicit Sampler(std::size_t offset, std::size_t index, Tegra::Shader::TextureType type, | 233 | constexpr explicit Sampler(u32 index, u32 offset, Tegra::Shader::TextureType type, |
| 234 | bool is_array, bool is_shadow) | 234 | bool is_array, bool is_shadow) |
| 235 | : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow}, | 235 | : index{index}, offset{offset}, type{type}, is_array{is_array}, is_shadow{is_shadow} {} |
| 236 | is_bindless{false} {} | ||
| 237 | 236 | ||
| 238 | /// This constructor is for bindless samplers | 237 | /// This constructor is for bindless samplers |
| 239 | explicit Sampler(u32 cbuf_index, u32 cbuf_offset, std::size_t index, | 238 | constexpr explicit Sampler(u32 index, u32 offset, u32 buffer, Tegra::Shader::TextureType type, |
| 240 | Tegra::Shader::TextureType type, bool is_array, bool is_shadow) | 239 | bool is_array, bool is_shadow) |
| 241 | : offset{(static_cast<u64>(cbuf_index) << 32) | cbuf_offset}, index{index}, type{type}, | 240 | : index{index}, offset{offset}, buffer{buffer}, type{type}, is_array{is_array}, |
| 242 | is_array{is_array}, is_shadow{is_shadow}, is_bindless{true} {} | 241 | is_shadow{is_shadow}, is_bindless{true} {} |
| 243 | 242 | ||
| 244 | /// This constructor is for serialization/deserialization | 243 | constexpr u32 GetIndex() const { |
| 245 | explicit Sampler(std::size_t offset, std::size_t index, Tegra::Shader::TextureType type, | 244 | return index; |
| 246 | bool is_array, bool is_shadow, bool is_bindless) | 245 | } |
| 247 | : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow}, | 246 | |
| 248 | is_bindless{is_bindless} {} | 247 | constexpr u32 GetOffset() const { |
| 249 | |||
| 250 | std::size_t GetOffset() const { | ||
| 251 | return offset; | 248 | return offset; |
| 252 | } | 249 | } |
| 253 | 250 | ||
| 254 | std::size_t GetIndex() const { | 251 | constexpr u32 GetBuffer() const { |
| 255 | return index; | 252 | return buffer; |
| 256 | } | 253 | } |
| 257 | 254 | ||
| 258 | Tegra::Shader::TextureType GetType() const { | 255 | constexpr Tegra::Shader::TextureType GetType() const { |
| 259 | return type; | 256 | return type; |
| 260 | } | 257 | } |
| 261 | 258 | ||
| 262 | bool IsArray() const { | 259 | constexpr bool IsArray() const { |
| 263 | return is_array; | 260 | return is_array; |
| 264 | } | 261 | } |
| 265 | 262 | ||
| 266 | bool IsShadow() const { | 263 | constexpr bool IsShadow() const { |
| 267 | return is_shadow; | 264 | return is_shadow; |
| 268 | } | 265 | } |
| 269 | 266 | ||
| 270 | bool IsBindless() const { | 267 | constexpr bool IsBindless() const { |
| 271 | return is_bindless; | 268 | return is_bindless; |
| 272 | } | 269 | } |
| 273 | 270 | ||
| 274 | std::pair<u32, u32> GetBindlessCBuf() const { | ||
| 275 | return {static_cast<u32>(offset >> 32), static_cast<u32>(offset)}; | ||
| 276 | } | ||
| 277 | |||
| 278 | bool operator<(const Sampler& rhs) const { | ||
| 279 | return std::tie(index, offset, type, is_array, is_shadow, is_bindless) < | ||
| 280 | std::tie(rhs.index, rhs.offset, rhs.type, rhs.is_array, rhs.is_shadow, | ||
| 281 | rhs.is_bindless); | ||
| 282 | } | ||
| 283 | |||
| 284 | private: | 271 | private: |
| 285 | /// Offset in TSC memory from which to read the sampler object, as specified by the sampling | 272 | u32 index{}; ///< Emulated index given for the this sampler. |
| 286 | /// instruction. | 273 | u32 offset{}; ///< Offset in the const buffer from where the sampler is being read. |
| 287 | std::size_t offset{}; | 274 | u32 buffer{}; ///< Buffer where the bindless sampler is being read (unused on bound samplers). |
| 288 | std::size_t index{}; ///< Value used to index into the generated GLSL sampler array. | 275 | |
| 289 | Tegra::Shader::TextureType type{}; ///< The type used to sample this texture (Texture2D, etc) | 276 | Tegra::Shader::TextureType type{}; ///< The type used to sample this texture (Texture2D, etc) |
| 290 | bool is_array{}; ///< Whether the texture is being sampled as an array texture or not. | 277 | bool is_array{}; ///< Whether the texture is being sampled as an array texture or not. |
| 291 | bool is_shadow{}; ///< Whether the texture is being sampled as a depth texture or not. | 278 | bool is_shadow{}; ///< Whether the texture is being sampled as a depth texture or not. |
| @@ -294,18 +281,13 @@ private: | |||
| 294 | 281 | ||
| 295 | class Image final { | 282 | class Image final { |
| 296 | public: | 283 | public: |
| 297 | constexpr explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type) | 284 | /// This constructor is for bound images |
| 298 | : offset{offset}, index{index}, type{type}, is_bindless{false} {} | 285 | constexpr explicit Image(u32 index, u32 offset, Tegra::Shader::ImageType type) |
| 299 | 286 | : index{index}, offset{offset}, type{type} {} | |
| 300 | constexpr explicit Image(u32 cbuf_index, u32 cbuf_offset, std::size_t index, | ||
| 301 | Tegra::Shader::ImageType type) | ||
| 302 | : offset{(static_cast<u64>(cbuf_index) << 32) | cbuf_offset}, index{index}, type{type}, | ||
| 303 | is_bindless{true} {} | ||
| 304 | 287 | ||
| 305 | constexpr explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type, | 288 | /// This constructor is for bindless samplers |
| 306 | bool is_bindless, bool is_written, bool is_read, bool is_atomic) | 289 | constexpr explicit Image(u32 index, u32 offset, u32 buffer, Tegra::Shader::ImageType type) |
| 307 | : offset{offset}, index{index}, type{type}, is_bindless{is_bindless}, | 290 | : index{index}, offset{offset}, buffer{buffer}, type{type}, is_bindless{true} {} |
| 308 | is_written{is_written}, is_read{is_read}, is_atomic{is_atomic} {} | ||
| 309 | 291 | ||
| 310 | void MarkWrite() { | 292 | void MarkWrite() { |
| 311 | is_written = true; | 293 | is_written = true; |
| @@ -321,12 +303,16 @@ public: | |||
| 321 | is_atomic = true; | 303 | is_atomic = true; |
| 322 | } | 304 | } |
| 323 | 305 | ||
| 324 | constexpr std::size_t GetOffset() const { | 306 | constexpr u32 GetIndex() const { |
| 307 | return index; | ||
| 308 | } | ||
| 309 | |||
| 310 | constexpr u32 GetOffset() const { | ||
| 325 | return offset; | 311 | return offset; |
| 326 | } | 312 | } |
| 327 | 313 | ||
| 328 | constexpr std::size_t GetIndex() const { | 314 | constexpr u32 GetBuffer() const { |
| 329 | return index; | 315 | return buffer; |
| 330 | } | 316 | } |
| 331 | 317 | ||
| 332 | constexpr Tegra::Shader::ImageType GetType() const { | 318 | constexpr Tegra::Shader::ImageType GetType() const { |
| @@ -349,18 +335,11 @@ public: | |||
| 349 | return is_atomic; | 335 | return is_atomic; |
| 350 | } | 336 | } |
| 351 | 337 | ||
| 352 | constexpr std::pair<u32, u32> GetBindlessCBuf() const { | ||
| 353 | return {static_cast<u32>(offset >> 32), static_cast<u32>(offset)}; | ||
| 354 | } | ||
| 355 | |||
| 356 | constexpr bool operator<(const Image& rhs) const { | ||
| 357 | return std::tie(offset, index, type, is_bindless) < | ||
| 358 | std::tie(rhs.offset, rhs.index, rhs.type, rhs.is_bindless); | ||
| 359 | } | ||
| 360 | |||
| 361 | private: | 338 | private: |
| 362 | u64 offset{}; | 339 | u32 index{}; |
| 363 | std::size_t index{}; | 340 | u32 offset{}; |
| 341 | u32 buffer{}; | ||
| 342 | |||
| 364 | Tegra::Shader::ImageType type{}; | 343 | Tegra::Shader::ImageType type{}; |
| 365 | bool is_bindless{}; | 344 | bool is_bindless{}; |
| 366 | bool is_written{}; | 345 | bool is_written{}; |