blob: 3d35524cc810bf8af451ed42ed9532d4b27dc83d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "common/common_types.h"
#include "shader_recompiler/shader_info.h"
#include "video_core/memory_manager.h"
namespace VideoCommon {
/// The texture handle a shader reads from a storage buffer, computed from the current constant
/// buffer and storage buffer words (Shader::Info::handle_programs). cbuf_address(index) is the
/// bound constant buffer's address, 0 when none is bound.
template <typename CbufAddress>
u32 EvaluateTextureHandle(const Shader::Info& info, u32 program, Tegra::MemoryManager& gpu_memory,
CbufAddress&& cbuf_address) {
return Shader::EvaluateHandleProgram(
info.handle_programs[program],
[&](u32 index, u32 offset) -> u32 {
const GPUVAddr base{cbuf_address(index)};
return base != 0 ? gpu_memory.Read<u32>(base + offset) : 0U;
},
[&](u32 binding, u32 offset) -> u32 {
if (binding >= info.storage_buffers_descriptors.size()) {
return 0U;
}
const auto& descriptor{info.storage_buffers_descriptors[binding]};
const GPUVAddr cbuf{cbuf_address(descriptor.cbuf_index)};
if (cbuf == 0) {
return 0U;
}
const GPUVAddr base{gpu_memory.Read<u64>(cbuf + descriptor.cbuf_offset)};
return base != 0 ? gpu_memory.Read<u32>(base + offset) : 0U;
})
.value_or(0U);
}
} // namespace VideoCommon
|