Merge pull request #3693 from ReinUsesLisp/clean-samplers

shader/texture: Support multiple unknown sampler properties
This commit is contained in:
bunnei
2020-05-02 00:45:41 -04:00
committed by GitHub
13 changed files with 260 additions and 337 deletions

View File

@ -28,12 +28,11 @@ struct ShaderBlock;
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<u32>(offset));
@ -56,8 +55,8 @@ public:
}
private:
u32 max_offset{};
bool is_indirect{};
u32 max_offset = 0;
bool is_indirect = false;
};
struct GlobalMemoryUsage {
@ -191,10 +190,14 @@ private:
friend class ASTDecoder;
struct SamplerInfo {
Tegra::Shader::TextureType type;
bool is_array;
bool is_shadow;
bool is_buffer;
std::optional<Tegra::Shader::TextureType> type;
std::optional<bool> is_array;
std::optional<bool> is_shadow;
std::optional<bool> is_buffer;
constexpr bool IsComplete() const noexcept {
return type && is_array && is_shadow && is_buffer;
}
};
void Decode();
@ -327,16 +330,15 @@ private:
OperationCode GetPredicateCombiner(Tegra::Shader::PredOperation operation);
/// Queries the missing sampler info from the execution context.
SamplerInfo GetSamplerInfo(std::optional<SamplerInfo> sampler_info, u32 offset,
SamplerInfo GetSamplerInfo(SamplerInfo info, u32 offset,
std::optional<u32> buffer = std::nullopt);
/// Accesses a texture sampler
const Sampler* GetSampler(const Tegra::Shader::Sampler& sampler,
std::optional<SamplerInfo> sampler_info = std::nullopt);
/// Accesses a texture sampler.
std::optional<Sampler> GetSampler(Tegra::Shader::Sampler sampler, SamplerInfo info);
/// Accesses a texture sampler for a bindless texture.
const Sampler* GetBindlessSampler(Tegra::Shader::Register reg, Node& index_var,
std::optional<SamplerInfo> sampler_info = std::nullopt);
std::optional<Sampler> GetBindlessSampler(Tegra::Shader::Register reg, SamplerInfo info,
Node& index_var);
/// Accesses an image.
Image& GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type);