summaryrefslogtreecommitdiff
path: root/src/video_core/shader/node.h
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-12-30 02:25:23 -0300
committerGravatar ReinUsesLisp2020-12-30 03:38:50 -0300
commit9764c13d6d2977903f407761b27d847c0056e1c4 (patch)
treef6f5d6d6379b0404147969e7d1f548ed3d49ca01 /src/video_core/shader/node.h
parentvideo_core: Add a delayed destruction ring abstraction (diff)
downloadyuzu-9764c13d6d2977903f407761b27d847c0056e1c4.tar.gz
yuzu-9764c13d6d2977903f407761b27d847c0056e1c4.tar.xz
yuzu-9764c13d6d2977903f407761b27d847c0056e1c4.zip
video_core: Rewrite the texture cache
The current texture cache has several points that hurt maintainability and performance. It's easy to break unrelated parts of the cache when doing minor changes. The cache can easily forget valuable information about the cached textures by CPU writes or simply by its normal usage.The current texture cache has several points that hurt maintainability and performance. It's easy to break unrelated parts of the cache when doing minor changes. The cache can easily forget valuable information about the cached textures by CPU writes or simply by its normal usage. This commit aims to address those issues.
Diffstat (limited to 'src/video_core/shader/node.h')
-rw-r--r--src/video_core/shader/node.h33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h
index 8db9e1de7..b54d33763 100644
--- a/src/video_core/shader/node.h
+++ b/src/video_core/shader/node.h
@@ -282,25 +282,24 @@ struct SeparateSamplerNode;
282using TrackSamplerData = std::variant<BindlessSamplerNode, SeparateSamplerNode, ArraySamplerNode>; 282using TrackSamplerData = std::variant<BindlessSamplerNode, SeparateSamplerNode, ArraySamplerNode>;
283using TrackSampler = std::shared_ptr<TrackSamplerData>; 283using TrackSampler = std::shared_ptr<TrackSamplerData>;
284 284
285struct Sampler { 285struct SamplerEntry {
286 /// Bound samplers constructor 286 /// Bound samplers constructor
287 constexpr explicit Sampler(u32 index_, u32 offset_, Tegra::Shader::TextureType type_, 287 explicit SamplerEntry(u32 index_, u32 offset_, Tegra::Shader::TextureType type_, bool is_array_,
288 bool is_array_, bool is_shadow_, bool is_buffer_, bool is_indexed_) 288 bool is_shadow_, bool is_buffer_, bool is_indexed_)
289 : index{index_}, offset{offset_}, type{type_}, is_array{is_array_}, is_shadow{is_shadow_}, 289 : index{index_}, offset{offset_}, type{type_}, is_array{is_array_}, is_shadow{is_shadow_},
290 is_buffer{is_buffer_}, is_indexed{is_indexed_} {} 290 is_buffer{is_buffer_}, is_indexed{is_indexed_} {}
291 291
292 /// Separate sampler constructor 292 /// Separate sampler constructor
293 constexpr explicit Sampler(u32 index_, std::pair<u32, u32> offsets_, 293 explicit SamplerEntry(u32 index_, std::pair<u32, u32> offsets, std::pair<u32, u32> buffers,
294 std::pair<u32, u32> buffers_, Tegra::Shader::TextureType type_, 294 Tegra::Shader::TextureType type_, bool is_array_, bool is_shadow_,
295 bool is_array_, bool is_shadow_, bool is_buffer_) 295 bool is_buffer_)
296 : index{index_}, offset{offsets_.first}, secondary_offset{offsets_.second}, 296 : index{index_}, offset{offsets.first}, secondary_offset{offsets.second},
297 buffer{buffers_.first}, secondary_buffer{buffers_.second}, type{type_}, 297 buffer{buffers.first}, secondary_buffer{buffers.second}, type{type_}, is_array{is_array_},
298 is_array{is_array_}, is_shadow{is_shadow_}, is_buffer{is_buffer_}, is_separated{true} {} 298 is_shadow{is_shadow_}, is_buffer{is_buffer_}, is_separated{true} {}
299 299
300 /// Bindless samplers constructor 300 /// Bindless samplers constructor
301 constexpr explicit Sampler(u32 index_, u32 offset_, u32 buffer_, 301 explicit SamplerEntry(u32 index_, u32 offset_, u32 buffer_, Tegra::Shader::TextureType type_,
302 Tegra::Shader::TextureType type_, bool is_array_, bool is_shadow_, 302 bool is_array_, bool is_shadow_, bool is_buffer_, bool is_indexed_)
303 bool is_buffer_, bool is_indexed_)
304 : index{index_}, offset{offset_}, buffer{buffer_}, type{type_}, is_array{is_array_}, 303 : index{index_}, offset{offset_}, buffer{buffer_}, type{type_}, is_array{is_array_},
305 is_shadow{is_shadow_}, is_buffer{is_buffer_}, is_bindless{true}, is_indexed{is_indexed_} { 304 is_shadow{is_shadow_}, is_buffer{is_buffer_}, is_bindless{true}, is_indexed{is_indexed_} {
306 } 305 }
@@ -340,14 +339,14 @@ struct BindlessSamplerNode {
340 u32 offset; 339 u32 offset;
341}; 340};
342 341
343struct Image { 342struct ImageEntry {
344public: 343public:
345 /// Bound images constructor 344 /// Bound images constructor
346 constexpr explicit Image(u32 index_, u32 offset_, Tegra::Shader::ImageType type_) 345 explicit ImageEntry(u32 index_, u32 offset_, Tegra::Shader::ImageType type_)
347 : index{index_}, offset{offset_}, type{type_} {} 346 : index{index_}, offset{offset_}, type{type_} {}
348 347
349 /// Bindless samplers constructor 348 /// Bindless samplers constructor
350 constexpr explicit Image(u32 index_, u32 offset_, u32 buffer_, Tegra::Shader::ImageType type_) 349 explicit ImageEntry(u32 index_, u32 offset_, u32 buffer_, Tegra::Shader::ImageType type_)
351 : index{index_}, offset{offset_}, buffer{buffer_}, type{type_}, is_bindless{true} {} 350 : index{index_}, offset{offset_}, buffer{buffer_}, type{type_}, is_bindless{true} {}
352 351
353 void MarkWrite() { 352 void MarkWrite() {
@@ -391,7 +390,7 @@ struct MetaArithmetic {
391 390
392/// Parameters describing a texture sampler 391/// Parameters describing a texture sampler
393struct MetaTexture { 392struct MetaTexture {
394 Sampler sampler; 393 SamplerEntry sampler;
395 Node array; 394 Node array;
396 Node depth_compare; 395 Node depth_compare;
397 std::vector<Node> aoffi; 396 std::vector<Node> aoffi;
@@ -405,7 +404,7 @@ struct MetaTexture {
405}; 404};
406 405
407struct MetaImage { 406struct MetaImage {
408 const Image& image; 407 const ImageEntry& image;
409 std::vector<Node> values; 408 std::vector<Node> values;
410 u32 element{}; 409 u32 element{};
411}; 410};