summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-01-05 12:08:39 -0400
committerGravatar FernandoS272020-01-24 16:43:29 -0400
commitdc5cfa8d287757dede737553b6f1f8521971c6e2 (patch)
treeba57a2e25d25d46aae22d18f032ac9e70d982ed7 /src
parentGuest_driver: Correct compiling errors in GCC. (diff)
downloadyuzu-dc5cfa8d287757dede737553b6f1f8521971c6e2.tar.gz
yuzu-dc5cfa8d287757dede737553b6f1f8521971c6e2.tar.xz
yuzu-dc5cfa8d287757dede737553b6f1f8521971c6e2.zip
Shader_IR: Address Feedback
Diffstat (limited to 'src')
-rw-r--r--src/video_core/guest_driver.cpp7
-rw-r--r--src/video_core/guest_driver.h2
-rw-r--r--src/video_core/shader/const_buffer_locker.h1
-rw-r--r--src/video_core/shader/decode.cpp40
4 files changed, 29 insertions, 21 deletions
diff --git a/src/video_core/guest_driver.cpp b/src/video_core/guest_driver.cpp
index 55b9bd021..1ded52905 100644
--- a/src/video_core/guest_driver.cpp
+++ b/src/video_core/guest_driver.cpp
@@ -1,8 +1,9 @@
1// Copyright 2019 yuzu Emulator Project 1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <climits>
6 7
7#include "video_core/guest_driver.h" 8#include "video_core/guest_driver.h"
8 9
@@ -12,13 +13,13 @@ void GuestDriverProfile::DeduceTextureHandlerSize(std::vector<u32>&& bound_offse
12 if (texture_handler_size_deduced) { 13 if (texture_handler_size_deduced) {
13 return; 14 return;
14 } 15 }
15 std::size_t size = bound_offsets.size(); 16 const std::size_t size = bound_offsets.size();
16 if (size < 2) { 17 if (size < 2) {
17 return; 18 return;
18 } 19 }
19 std::sort(bound_offsets.begin(), bound_offsets.end(), 20 std::sort(bound_offsets.begin(), bound_offsets.end(),
20 [](const u32& a, const u32& b) { return a < b; }); 21 [](const u32& a, const u32& b) { return a < b; });
21 u32 min_val = 0xFFFFFFFF; // set to highest possible 32 bit integer; 22 u32 min_val = UINT_MAX;
22 for (std::size_t i = 1; i < size; i++) { 23 for (std::size_t i = 1; i < size; i++) {
23 if (bound_offsets[i] == bound_offsets[i - 1]) { 24 if (bound_offsets[i] == bound_offsets[i - 1]) {
24 continue; 25 continue;
diff --git a/src/video_core/guest_driver.h b/src/video_core/guest_driver.h
index 7687a0434..e08588ee9 100644
--- a/src/video_core/guest_driver.h
+++ b/src/video_core/guest_driver.h
@@ -1,4 +1,4 @@
1// Copyright 2019 yuzu Emulator Project 1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/const_buffer_locker.h
index f26cce2ce..c7b72fa5e 100644
--- a/src/video_core/shader/const_buffer_locker.h
+++ b/src/video_core/shader/const_buffer_locker.h
@@ -53,7 +53,6 @@ public:
53 void InsertBindlessSampler(u32 buffer, u32 offset, Tegra::Engines::SamplerDescriptor sampler); 53 void InsertBindlessSampler(u32 buffer, u32 offset, Tegra::Engines::SamplerDescriptor sampler);
54 54
55 /// Set the bound buffer for this locker. 55 /// Set the bound buffer for this locker.
56
57 void SetBoundBuffer(u32 buffer); 56 void SetBoundBuffer(u32 buffer);
58 57
59 /// Checks keys and samplers against engine's current const buffers. Returns true if they are 58 /// Checks keys and samplers against engine's current const buffers. Returns true if they are
diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp
index aed35a9b8..c702c7629 100644
--- a/src/video_core/shader/decode.cpp
+++ b/src/video_core/shader/decode.cpp
@@ -315,25 +315,33 @@ u32 ShaderIR::DecodeInstr(NodeBlock& bb, u32 pc) {
315 return pc + 1; 315 return pc + 1;
316} 316}
317 317
318void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver,
319 std::list<Sampler>& used_samplers) {
320 if (gpu_driver == nullptr) {
321 LOG_CRITICAL(HW_GPU, "GPU Driver profile has not been created yet");
322 return;
323 }
324 if (gpu_driver->TextureHandlerSizeKnown() || used_samplers.size() <= 1) {
325 return;
326 }
327 u32 count{};
328 std::vector<u32> bound_offsets;
329 for (const auto& sampler : used_samplers) {
330 if (sampler.IsBindless()) {
331 continue;
332 }
333 count++;
334 bound_offsets.emplace_back(sampler.GetOffset());
335 }
336 if (count > 1) {
337 gpu_driver->DeduceTextureHandlerSize(std::move(bound_offsets));
338 }
339}
340
318void ShaderIR::PostDecode() { 341void ShaderIR::PostDecode() {
319 // Deduce texture handler size if needed 342 // Deduce texture handler size if needed
320 auto* gpu_driver = locker.AccessGuestDriverProfile(); 343 auto* gpu_driver = locker.AccessGuestDriverProfile();
321 if (gpu_driver) { 344 DeduceTextureHandlerSize(gpu_driver, used_samplers);
322 if (!gpu_driver->TextureHandlerSizeKnown() && used_samplers.size() > 1) {
323 u32 count{};
324 std::vector<u32> bound_offsets;
325 for (const auto& sampler : used_samplers) {
326 if (sampler.IsBindless()) {
327 continue;
328 }
329 count++;
330 bound_offsets.emplace_back(sampler.GetOffset());
331 }
332 if (count > 1) {
333 gpu_driver->DeduceTextureHandlerSize(std::move(bound_offsets));
334 }
335 }
336 }
337} 345}
338 346
339} // namespace VideoCommon::Shader 347} // namespace VideoCommon::Shader