From e28fd3d0a533695242d17350dd929ad3bb56c429 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 26 Mar 2019 17:05:23 -0400 Subject: Implement Bindless Samplers and TEX_B in the IR. --- src/video_core/shader/shader_ir.h | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/video_core/shader/shader_ir.h') diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 4888998d3..712dc3ddb 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -196,9 +196,12 @@ enum class ExitMethod { class Sampler { public: + Sampler() = default; explicit Sampler(std::size_t offset, std::size_t index, Tegra::Shader::TextureType type, - bool is_array, bool is_shadow) - : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow} {} + bool is_array, bool is_shadow, bool is_bindless) + : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow}, is_bindless{is_bindless} {} + + ~Sampler() = default; std::size_t GetOffset() const { return offset; @@ -233,6 +236,7 @@ private: 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_bindless{}; ///< Whether this sampler belongs to a bindless texture or not. }; class ConstBuffer { @@ -730,6 +734,10 @@ private: const Sampler& GetSampler(const Tegra::Shader::Sampler& sampler, Tegra::Shader::TextureType type, bool is_array, bool is_shadow); + // Accesses a texture sampler for a bindless texture. + const Sampler& GetBindlessSampler(const Tegra::Shader::Register& reg, Tegra::Shader::TextureType type, + bool is_array, bool is_shadow); + /// Extracts a sequence of bits from a node Node BitfieldExtract(Node value, u32 offset, u32 bits); @@ -741,9 +749,11 @@ private: void WriteTexsInstructionHalfFloat(NodeBlock& bb, Tegra::Shader::Instruction instr, const Node4& components); - Node4 GetTexCode(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, - Tegra::Shader::TextureProcessMode process_mode, bool depth_compare, - bool is_array, bool is_aoffi); + Node4 GetTexCode( + Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, + Tegra::Shader::TextureProcessMode process_mode, bool depth_compare, bool is_array, + bool is_aoffi, bool is_bindless = false, + Tegra::Shader::Register bindless_reg = static_cast(0)); Node4 GetTexsCode(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, Tegra::Shader::TextureProcessMode process_mode, bool depth_compare, @@ -760,10 +770,12 @@ private: bool lod_bias_enabled, std::size_t max_coords, std::size_t max_inputs); std::vector GetAoffiCoordinates(Node aoffi_reg, std::size_t coord_count, bool is_tld4); - - Node4 GetTextureCode(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, - Tegra::Shader::TextureProcessMode process_mode, std::vector coords, - Node array, Node depth_compare, u32 bias_offset, std::vector aoffi); + + Node4 GetTextureCode( + Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, + Tegra::Shader::TextureProcessMode process_mode, std::vector coords, Node array, + Node depth_compare, u32 bias_offset, std::vector aoffi, bool is_bindless = false, + Tegra::Shader::Register bindless_reg = static_cast(0)); Node GetVideoOperand(Node op, bool is_chunk, bool is_signed, Tegra::Shader::VideoType type, u64 byte_height); @@ -833,6 +845,7 @@ private: std::set used_output_attributes; std::map used_cbufs; std::set used_samplers; + std::map, Sampler> used_bindless_samplers; std::array used_clip_distances{}; std::set used_global_memory_bases; -- cgit v1.2.3 From fe392fff2425c10c9683a4058c779d352b9855ec Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 26 Mar 2019 17:56:16 -0400 Subject: Unify both sampler types. --- src/video_core/shader/shader_ir.h | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/video_core/shader/shader_ir.h') diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 712dc3ddb..773c71fa5 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -196,12 +196,24 @@ enum class ExitMethod { class Sampler { public: - Sampler() = default; + // Use this constructor for binded Samplers + explicit Sampler(std::size_t offset, std::size_t index, Tegra::Shader::TextureType type, + bool is_array, bool is_shadow) + : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow}, + is_bindless{false} {} + + // Use this constructor for bindless Samplers + explicit Sampler(u32 cbuf_index, u32 cbuf_offset, std::size_t index, + Tegra::Shader::TextureType type, bool is_array, bool is_shadow) + : offset{(static_cast(cbuf_index) << 32) | cbuf_offset}, index{index}, type{type}, is_array{is_array}, + is_shadow{is_shadow}, is_bindless{true} {} + + // Use this only for serialization/deserialization explicit Sampler(std::size_t offset, std::size_t index, Tegra::Shader::TextureType type, bool is_array, bool is_shadow, bool is_bindless) - : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow}, is_bindless{is_bindless} {} + : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow}, + is_bindless{is_bindless} {} - ~Sampler() = default; std::size_t GetOffset() const { return offset; @@ -223,6 +235,14 @@ public: return is_shadow; } + bool IsBindless() const { + return is_bindless; + } + + std::pair GetBindlessCBuf() { + return {offset >> 32, offset & 0x00000000FFFFFFFFULL}; + } + bool operator<(const Sampler& rhs) const { return std::tie(offset, index, type, is_array, is_shadow) < std::tie(rhs.offset, rhs.index, rhs.type, rhs.is_array, rhs.is_shadow); @@ -234,8 +254,8 @@ private: std::size_t offset{}; std::size_t index{}; ///< Value used to index into the generated GLSL sampler array. 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_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_bindless{}; ///< Whether this sampler belongs to a bindless texture or not. }; @@ -735,8 +755,9 @@ private: Tegra::Shader::TextureType type, bool is_array, bool is_shadow); // Accesses a texture sampler for a bindless texture. - const Sampler& GetBindlessSampler(const Tegra::Shader::Register& reg, Tegra::Shader::TextureType type, - bool is_array, bool is_shadow); + const Sampler& GetBindlessSampler(const Tegra::Shader::Register& reg, + Tegra::Shader::TextureType type, bool is_array, + bool is_shadow); /// Extracts a sequence of bits from a node Node BitfieldExtract(Node value, u32 offset, u32 bits); @@ -845,7 +866,6 @@ private: std::set used_output_attributes; std::map used_cbufs; std::set used_samplers; - std::map, Sampler> used_bindless_samplers; std::array used_clip_distances{}; std::set used_global_memory_bases; -- cgit v1.2.3 From 7af82ca022fd6f02583e5686d5c69baf0b6a3611 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 26 Mar 2019 18:18:54 -0400 Subject: Implement Bindless Handling on SetupTexture --- src/video_core/shader/shader_ir.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/video_core/shader/shader_ir.h') diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 773c71fa5..ed321cfe5 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -205,8 +205,8 @@ public: // Use this constructor for bindless Samplers explicit Sampler(u32 cbuf_index, u32 cbuf_offset, std::size_t index, Tegra::Shader::TextureType type, bool is_array, bool is_shadow) - : offset{(static_cast(cbuf_index) << 32) | cbuf_offset}, index{index}, type{type}, is_array{is_array}, - is_shadow{is_shadow}, is_bindless{true} {} + : offset{(static_cast(cbuf_index) << 32) | cbuf_offset}, index{index}, type{type}, + is_array{is_array}, is_shadow{is_shadow}, is_bindless{true} {} // Use this only for serialization/deserialization explicit Sampler(std::size_t offset, std::size_t index, Tegra::Shader::TextureType type, @@ -214,7 +214,6 @@ public: : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow}, is_bindless{is_bindless} {} - std::size_t GetOffset() const { return offset; } @@ -239,7 +238,7 @@ public: return is_bindless; } - std::pair GetBindlessCBuf() { + std::pair GetBindlessCBuf() const { return {offset >> 32, offset & 0x00000000FFFFFFFFULL}; } -- cgit v1.2.3 From fd4e994de3196dfdd2a3f2caf4ca8934e719c296 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 27 Mar 2019 07:11:50 -0400 Subject: Refactor GetTextureCode and GetTexCode to use an optional instead of optional parameters --- src/video_core/shader/shader_ir.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/video_core/shader/shader_ir.h') diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index ed321cfe5..11495799f 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -769,11 +769,10 @@ private: void WriteTexsInstructionHalfFloat(NodeBlock& bb, Tegra::Shader::Instruction instr, const Node4& components); - Node4 GetTexCode( - Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, - Tegra::Shader::TextureProcessMode process_mode, bool depth_compare, bool is_array, - bool is_aoffi, bool is_bindless = false, - Tegra::Shader::Register bindless_reg = static_cast(0)); + Node4 GetTexCode(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, + Tegra::Shader::TextureProcessMode process_mode, bool depth_compare, + bool is_array, bool is_aoffi, + std::optional bindless_reg); Node4 GetTexsCode(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, Tegra::Shader::TextureProcessMode process_mode, bool depth_compare, @@ -790,12 +789,11 @@ private: bool lod_bias_enabled, std::size_t max_coords, std::size_t max_inputs); std::vector GetAoffiCoordinates(Node aoffi_reg, std::size_t coord_count, bool is_tld4); - - Node4 GetTextureCode( - Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, - Tegra::Shader::TextureProcessMode process_mode, std::vector coords, Node array, - Node depth_compare, u32 bias_offset, std::vector aoffi, bool is_bindless = false, - Tegra::Shader::Register bindless_reg = static_cast(0)); + + Node4 GetTextureCode(Tegra::Shader::Instruction instr, Tegra::Shader::TextureType texture_type, + Tegra::Shader::TextureProcessMode process_mode, std::vector coords, + Node array, Node depth_compare, u32 bias_offset, std::vector aoffi, + std::optional bindless_reg); Node GetVideoOperand(Node op, bool is_chunk, bool is_signed, Tegra::Shader::VideoType type, u64 byte_height); -- cgit v1.2.3 From 492040bd9ce40f86f9845699d68104d31d272155 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 7 Apr 2019 08:30:26 -0400 Subject: Move ConstBufferAccessor to Maxwell3d, correct mistakes and clang format. --- src/video_core/shader/shader_ir.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/video_core/shader/shader_ir.h') diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 11495799f..249024167 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -196,7 +196,7 @@ enum class ExitMethod { class Sampler { public: - // Use this constructor for binded Samplers + // Use this constructor for bounded Samplers explicit Sampler(std::size_t offset, std::size_t index, Tegra::Shader::TextureType type, bool is_array, bool is_shadow) : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow}, @@ -239,7 +239,7 @@ public: } std::pair GetBindlessCBuf() const { - return {offset >> 32, offset & 0x00000000FFFFFFFFULL}; + return {static_cast(offset >> 32), static_cast(offset)}; } bool operator<(const Sampler& rhs) const { -- cgit v1.2.3