From 72deb773fdcc59b1df9752de4e846422b7bb5280 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 16 Apr 2020 01:34:45 -0300 Subject: shader_ir: Turn classes into data structures --- src/video_core/shader/shader_ir.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 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 c6e7bdf50..ae5e414cb 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -29,12 +29,11 @@ using ProgramCode = std::vector; constexpr u32 MAX_PROGRAM_LENGTH = 0x1000; -class ConstBuffer { -public: - explicit ConstBuffer(u32 max_offset, bool is_indirect) +struct ConstBuffer { + constexpr explicit ConstBuffer(u32 max_offset, bool is_indirect) : max_offset{max_offset}, is_indirect{is_indirect} {} - ConstBuffer() = default; + constexpr ConstBuffer() = default; void MarkAsUsed(u64 offset) { max_offset = std::max(max_offset, static_cast(offset)); @@ -57,8 +56,8 @@ public: } private: - u32 max_offset{}; - bool is_indirect{}; + u32 max_offset = 0; + bool is_indirect = false; }; struct GlobalMemoryUsage { @@ -332,12 +331,13 @@ private: std::optional buffer = std::nullopt); /// Accesses a texture sampler - const Sampler* GetSampler(const Tegra::Shader::Sampler& sampler, - std::optional sampler_info = std::nullopt); + std::optional GetSampler(const Tegra::Shader::Sampler& sampler, + std::optional sampler_info = std::nullopt); /// Accesses a texture sampler for a bindless texture. - const Sampler* GetBindlessSampler(Tegra::Shader::Register reg, Node& index_var, - std::optional sampler_info = std::nullopt); + std::optional GetBindlessSampler( + Tegra::Shader::Register reg, Node& index_var, + std::optional sampler_info = std::nullopt); /// Accesses an image. Image& GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type); -- cgit v1.2.3 From 4fb921ff6bd6f9596c7e7cd9524932f2a44e9490 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 16 Apr 2020 02:07:42 -0300 Subject: shader/texture: Support multiple unknown sampler properties This allows deducing some properties from the texture instruction before asking the runtime. By doing this we can handle type mismatches in some instructions from the renderer instead of the shader decoder. Fixes texelFetch issues with games using 2D texture instructions on a 1D sampler. --- src/video_core/shader/shader_ir.h | 24 +++++++++++++----------- 1 file changed, 13 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 ae5e414cb..748d73087 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -191,10 +191,14 @@ private: friend class ASTDecoder; struct SamplerInfo { - Tegra::Shader::TextureType type; - bool is_array; - bool is_shadow; - bool is_buffer; + std::optional type; + std::optional is_array; + std::optional is_shadow; + std::optional is_buffer; + + constexpr bool IsComplete() const noexcept { + return type && is_array && is_shadow && is_buffer; + } }; void Decode(); @@ -327,17 +331,15 @@ private: OperationCode GetPredicateCombiner(Tegra::Shader::PredOperation operation); /// Queries the missing sampler info from the execution context. - SamplerInfo GetSamplerInfo(std::optional sampler_info, u32 offset, + SamplerInfo GetSamplerInfo(SamplerInfo info, u32 offset, std::optional buffer = std::nullopt); - /// Accesses a texture sampler - std::optional GetSampler(const Tegra::Shader::Sampler& sampler, - std::optional sampler_info = std::nullopt); + /// Accesses a texture sampler. + std::optional GetSampler(Tegra::Shader::Sampler sampler, SamplerInfo info); /// Accesses a texture sampler for a bindless texture. - std::optional GetBindlessSampler( - Tegra::Shader::Register reg, Node& index_var, - std::optional sampler_info = std::nullopt); + std::optional GetBindlessSampler(Tegra::Shader::Register reg, SamplerInfo info, + Node& index_var); /// Accesses an image. Image& GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type); -- cgit v1.2.3