From 603c861532ed1a89254556ff84bbe121bd700765 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 5 Jan 2020 15:23:24 -0400 Subject: Shader_IR: Implement initial code for tracking indexed samplers. --- src/video_core/shader/node.h | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/video_core/shader/node.h') diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h index 075c7d07c..b370df8f9 100644 --- a/src/video_core/shader/node.h +++ b/src/video_core/shader/node.h @@ -230,6 +230,12 @@ using Node = std::shared_ptr; using Node4 = std::array; using NodeBlock = std::vector; +class BindlessSamplerNode; +class ArraySamplerNode; + +using TrackSamplerData = std::variant; +using TrackSampler = std::shared_ptr; + class Sampler { public: /// This constructor is for bound samplers @@ -288,6 +294,48 @@ private: bool is_bindless{}; ///< Whether this sampler belongs to a bindless texture or not. }; +/// Represents a tracked bindless sampler into a direct const buffer +class ArraySamplerNode final { +public: + explicit ArraySamplerNode(u32 index, u32 base_offset, u32 bindless_var) + : index{index}, base_offset{base_offset}, bindless_var{bindless_var} {} + + u32 GetIndex() const { + return index; + } + + u32 GetBaseOffset() const { + return base_offset; + } + + u32 GetIndexVar() const { + return bindless_var; + } + +private: + u32 index; + u32 base_offset; + u32 bindless_var; +}; + +/// Represents a tracked bindless sampler into a direct const buffer +class BindlessSamplerNode final { +public: + explicit BindlessSamplerNode(u32 index, u32 offset) : index{index}, offset{offset} {} + + u32 GetIndex() const { + return index; + } + + u32 GetOffset() const { + return offset; + } + +private: + u32 index; + u32 offset; +}; + class Image final { public: /// This constructor is for bound images -- cgit v1.2.3 From 037ea431ceb93e93274fdcf9fb724819639d04fd Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 5 Jan 2020 18:36:21 -0400 Subject: Shader_IR: deduce size of indexed samplers --- src/video_core/shader/node.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/video_core/shader/node.h') diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h index b370df8f9..2f29b9506 100644 --- a/src/video_core/shader/node.h +++ b/src/video_core/shader/node.h @@ -240,15 +240,15 @@ class Sampler { public: /// This constructor is for bound samplers constexpr explicit Sampler(u32 index, u32 offset, Tegra::Shader::TextureType type, - bool is_array, bool is_shadow, bool is_buffer) + bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) : index{index}, offset{offset}, type{type}, is_array{is_array}, is_shadow{is_shadow}, - is_buffer{is_buffer} {} + is_buffer{is_buffer}, is_indexed{is_indexed} {} /// This constructor is for bindless samplers constexpr explicit Sampler(u32 index, u32 offset, u32 buffer, Tegra::Shader::TextureType type, - bool is_array, bool is_shadow, bool is_buffer) + bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) : index{index}, offset{offset}, buffer{buffer}, type{type}, is_array{is_array}, - is_shadow{is_shadow}, is_buffer{is_buffer}, is_bindless{true} {} + is_shadow{is_shadow}, is_buffer{is_buffer}, is_bindless{true}, is_indexed{is_indexed} {} constexpr u32 GetIndex() const { return index; @@ -282,16 +282,30 @@ public: return is_bindless; } + constexpr bool IsIndexed() const { + return is_indexed; + } + + constexpr u32 Size() const { + return size; + } + + void SetSize(u32 new_size) { + size = new_size; + } + private: u32 index{}; ///< Emulated index given for the this sampler. u32 offset{}; ///< Offset in the const buffer from where the sampler is being read. u32 buffer{}; ///< Buffer where the bindless sampler is being read (unused on bound samplers). + u32 size{}; ///< Size of the sampler if indexed. Tegra::Shader::TextureType type{}; ///< The type used to sample this texture (Texture2D, etc) bool is_array{}; ///< Whether the texture is being sampled as an array texture or not. bool is_shadow{}; ///< Whether the texture is being sampled as a depth texture or not. bool is_buffer{}; ///< Whether the texture is a texture buffer without sampler. bool is_bindless{}; ///< Whether this sampler belongs to a bindless texture or not. + bool is_indexed{}; ///< Whether this sampler is an indexed array of textures. }; /// Represents a tracked bindless sampler into a direct const buffer -- cgit v1.2.3 From 3c34678627eeb1b48375cf70ec38b72691fedd1e Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 7 Jan 2020 14:53:46 -0400 Subject: Shader_IR: Implement Injectable Custom Variables to the IR. --- src/video_core/shader/node.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/video_core/shader/node.h') diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h index 2f29b9506..db06767f6 100644 --- a/src/video_core/shader/node.h +++ b/src/video_core/shader/node.h @@ -212,6 +212,7 @@ enum class MetaStackClass { class OperationNode; class ConditionalNode; class GprNode; +class CustomVarNode; class ImmediateNode; class InternalFlagNode; class PredicateNode; @@ -223,7 +224,7 @@ class SmemNode; class GmemNode; class CommentNode; -using NodeData = std::variant; using Node = std::shared_ptr; @@ -550,6 +551,20 @@ private: Tegra::Shader::Register index{}; }; +/// A custom variable +class CustomVarNode final { +public: + explicit constexpr CustomVarNode(u32 index) : index{index} {} + + u32 GetIndex() const { + return index; + } + +private: + u32 index{}; +}; + + /// A 32-bits value that represents an immediate value class ImmediateNode final { public: -- cgit v1.2.3 From 7c530e06661d760eb6366724d109468423363072 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 7 Jan 2020 17:45:12 -0400 Subject: Shader_IR: Propagate bindless index into the GL compiler. --- src/video_core/shader/node.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/video_core/shader/node.h') diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h index db06767f6..d75453458 100644 --- a/src/video_core/shader/node.h +++ b/src/video_core/shader/node.h @@ -445,6 +445,7 @@ struct MetaTexture { Node lod; Node component{}; u32 element{}; + Node index{}; }; struct MetaImage { @@ -564,7 +565,6 @@ private: u32 index{}; }; - /// A 32-bits value that represents an immediate value class ImmediateNode final { public: -- cgit v1.2.3 From bb8eb15d392d69693f8cda0427669d011e23db97 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 24 Jan 2020 10:44:34 -0400 Subject: Shader_IR: Address feedback. --- src/video_core/shader/node.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/video_core/shader/node.h') diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h index d75453458..53a551d27 100644 --- a/src/video_core/shader/node.h +++ b/src/video_core/shader/node.h @@ -291,7 +291,7 @@ public: return size; } - void SetSize(u32 new_size) { + constexpr void SetSize(u32 new_size) { size = new_size; } @@ -315,15 +315,15 @@ public: explicit ArraySamplerNode(u32 index, u32 base_offset, u32 bindless_var) : index{index}, base_offset{base_offset}, bindless_var{bindless_var} {} - u32 GetIndex() const { + constexpr u32 GetIndex() const { return index; } - u32 GetBaseOffset() const { + constexpr u32 GetBaseOffset() const { return base_offset; } - u32 GetIndexVar() const { + constexpr u32 GetIndexVar() const { return bindless_var; } @@ -338,11 +338,11 @@ class BindlessSamplerNode final { public: explicit BindlessSamplerNode(u32 index, u32 offset) : index{index}, offset{offset} {} - u32 GetIndex() const { + constexpr u32 GetIndex() const { return index; } - u32 GetOffset() const { + constexpr u32 GetOffset() const { return offset; } @@ -557,7 +557,7 @@ class CustomVarNode final { public: explicit constexpr CustomVarNode(u32 index) : index{index} {} - u32 GetIndex() const { + constexpr u32 GetIndex() const { return index; } -- cgit v1.2.3