diff options
| author | 2023-05-02 23:52:21 +0100 | |
|---|---|---|
| committer | 2023-05-02 23:52:21 +0100 | |
| commit | f902cc2a2b5875eb20a403390ed849af68e094f0 (patch) | |
| tree | 69f21919b2bf649e23eee3ce154f214f8f3945c8 /src/video_core/shader_environment.cpp | |
| parent | Merge pull request #10133 from lat9nq/clang-shadow-and-fallthrough (diff) | |
| download | yuzu-f902cc2a2b5875eb20a403390ed849af68e094f0.tar.gz yuzu-f902cc2a2b5875eb20a403390ed849af68e094f0.tar.xz yuzu-f902cc2a2b5875eb20a403390ed849af68e094f0.zip | |
Fix code resize to use word size rather than byte size
Diffstat (limited to 'src/video_core/shader_environment.cpp')
| -rw-r--r-- | src/video_core/shader_environment.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp index 574760f80..c7cb56243 100644 --- a/src/video_core/shader_environment.cpp +++ b/src/video_core/shader_environment.cpp | |||
| @@ -170,15 +170,19 @@ std::optional<u64> GenericEnvironment::Analyze() { | |||
| 170 | void GenericEnvironment::SetCachedSize(size_t size_bytes) { | 170 | void GenericEnvironment::SetCachedSize(size_t size_bytes) { |
| 171 | cached_lowest = start_address; | 171 | cached_lowest = start_address; |
| 172 | cached_highest = start_address + static_cast<u32>(size_bytes); | 172 | cached_highest = start_address + static_cast<u32>(size_bytes); |
| 173 | code.resize(CachedSize()); | 173 | code.resize(CachedSizeWords()); |
| 174 | gpu_memory->ReadBlock(program_base + cached_lowest, code.data(), code.size() * sizeof(u64)); | 174 | gpu_memory->ReadBlock(program_base + cached_lowest, code.data(), code.size() * sizeof(u64)); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | size_t GenericEnvironment::CachedSize() const noexcept { | 177 | size_t GenericEnvironment::CachedSizeWords() const noexcept { |
| 178 | return cached_highest - cached_lowest + INST_SIZE; | 178 | return CachedSizeBytes() / INST_SIZE; |
| 179 | } | 179 | } |
| 180 | 180 | ||
| 181 | size_t GenericEnvironment::ReadSize() const noexcept { | 181 | size_t GenericEnvironment::CachedSizeBytes() const noexcept { |
| 182 | return static_cast<size_t>(cached_highest) - cached_lowest + INST_SIZE; | ||
| 183 | } | ||
| 184 | |||
| 185 | size_t GenericEnvironment::ReadSizeBytes() const noexcept { | ||
| 182 | return read_highest - read_lowest + INST_SIZE; | 186 | return read_highest - read_lowest + INST_SIZE; |
| 183 | } | 187 | } |
| 184 | 188 | ||
| @@ -187,7 +191,7 @@ bool GenericEnvironment::CanBeSerialized() const noexcept { | |||
| 187 | } | 191 | } |
| 188 | 192 | ||
| 189 | u64 GenericEnvironment::CalculateHash() const { | 193 | u64 GenericEnvironment::CalculateHash() const { |
| 190 | const size_t size{ReadSize()}; | 194 | const size_t size{ReadSizeBytes()}; |
| 191 | const auto data{std::make_unique<char[]>(size)}; | 195 | const auto data{std::make_unique<char[]>(size)}; |
| 192 | gpu_memory->ReadBlock(program_base + read_lowest, data.get(), size); | 196 | gpu_memory->ReadBlock(program_base + read_lowest, data.get(), size); |
| 193 | return Common::CityHash64(data.get(), size); | 197 | return Common::CityHash64(data.get(), size); |
| @@ -198,7 +202,7 @@ void GenericEnvironment::Dump(u64 hash) { | |||
| 198 | } | 202 | } |
| 199 | 203 | ||
| 200 | void GenericEnvironment::Serialize(std::ofstream& file) const { | 204 | void GenericEnvironment::Serialize(std::ofstream& file) const { |
| 201 | const u64 code_size{static_cast<u64>(CachedSize())}; | 205 | const u64 code_size{static_cast<u64>(CachedSizeBytes())}; |
| 202 | const u64 num_texture_types{static_cast<u64>(texture_types.size())}; | 206 | const u64 num_texture_types{static_cast<u64>(texture_types.size())}; |
| 203 | const u64 num_texture_pixel_formats{static_cast<u64>(texture_pixel_formats.size())}; | 207 | const u64 num_texture_pixel_formats{static_cast<u64>(texture_pixel_formats.size())}; |
| 204 | const u64 num_cbuf_values{static_cast<u64>(cbuf_values.size())}; | 208 | const u64 num_cbuf_values{static_cast<u64>(cbuf_values.size())}; |