summaryrefslogtreecommitdiff
path: root/src/video_core/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/shader')
-rw-r--r--src/video_core/shader/const_buffer_locker.cpp7
-rw-r--r--src/video_core/shader/const_buffer_locker.h11
-rw-r--r--src/video_core/shader/decode.cpp18
-rw-r--r--src/video_core/shader/track.cpp9
4 files changed, 17 insertions, 28 deletions
diff --git a/src/video_core/shader/const_buffer_locker.cpp b/src/video_core/shader/const_buffer_locker.cpp
index 0638be8cb..c859dd7ca 100644
--- a/src/video_core/shader/const_buffer_locker.cpp
+++ b/src/video_core/shader/const_buffer_locker.cpp
@@ -14,8 +14,9 @@ namespace VideoCommon::Shader {
14 14
15using Tegra::Engines::SamplerDescriptor; 15using Tegra::Engines::SamplerDescriptor;
16 16
17ConstBufferLocker::ConstBufferLocker(Tegra::Engines::ShaderType shader_stage) 17ConstBufferLocker::ConstBufferLocker(Tegra::Engines::ShaderType shader_stage,
18 : stage{shader_stage} {} 18 VideoCore::GuestDriverProfile stored_guest_driver_profile)
19 : stage{shader_stage}, stored_guest_driver_profile{stored_guest_driver_profile} {}
19 20
20ConstBufferLocker::ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, 21ConstBufferLocker::ConstBufferLocker(Tegra::Engines::ShaderType shader_stage,
21 Tegra::Engines::ConstBufferEngineInterface& engine) 22 Tegra::Engines::ConstBufferEngineInterface& engine)
@@ -97,7 +98,7 @@ void ConstBufferLocker::SetBoundBuffer(u32 buffer) {
97 98
98bool ConstBufferLocker::IsConsistent() const { 99bool ConstBufferLocker::IsConsistent() const {
99 if (!engine) { 100 if (!engine) {
100 return false; 101 return true;
101 } 102 }
102 return std::all_of(keys.begin(), keys.end(), 103 return std::all_of(keys.begin(), keys.end(),
103 [this](const auto& pair) { 104 [this](const auto& pair) {
diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/const_buffer_locker.h
index d3ea11087..7c6f7bbdd 100644
--- a/src/video_core/shader/const_buffer_locker.h
+++ b/src/video_core/shader/const_buffer_locker.h
@@ -26,7 +26,8 @@ using BindlessSamplerMap =
26 */ 26 */
27class ConstBufferLocker { 27class ConstBufferLocker {
28public: 28public:
29 explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage); 29 explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage,
30 VideoCore::GuestDriverProfile stored_guest_driver_profile);
30 31
31 explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, 32 explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage,
32 Tegra::Engines::ConstBufferEngineInterface& engine); 33 Tegra::Engines::ConstBufferEngineInterface& engine);
@@ -83,15 +84,13 @@ public:
83 } 84 }
84 85
85 /// Obtains access to the guest driver's profile. 86 /// Obtains access to the guest driver's profile.
86 VideoCore::GuestDriverProfile* AccessGuestDriverProfile() const { 87 VideoCore::GuestDriverProfile& AccessGuestDriverProfile() {
87 if (engine) { 88 return engine ? engine->AccessGuestDriverProfile() : stored_guest_driver_profile;
88 return &engine->AccessGuestDriverProfile();
89 }
90 return nullptr;
91 } 89 }
92 90
93private: 91private:
94 const Tegra::Engines::ShaderType stage; 92 const Tegra::Engines::ShaderType stage;
93 VideoCore::GuestDriverProfile stored_guest_driver_profile;
95 Tegra::Engines::ConstBufferEngineInterface* engine = nullptr; 94 Tegra::Engines::ConstBufferEngineInterface* engine = nullptr;
96 KeyMap keys; 95 KeyMap keys;
97 BoundSamplerMap bound_samplers; 96 BoundSamplerMap bound_samplers;
diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp
index 6b697ed5d..af4490d66 100644
--- a/src/video_core/shader/decode.cpp
+++ b/src/video_core/shader/decode.cpp
@@ -34,13 +34,9 @@ constexpr bool IsSchedInstruction(u32 offset, u32 main_offset) {
34 return (absolute_offset % SchedPeriod) == 0; 34 return (absolute_offset % SchedPeriod) == 0;
35} 35}
36 36
37void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver, 37void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile& gpu_driver,
38 const std::list<Sampler>& used_samplers) { 38 const std::list<Sampler>& used_samplers) {
39 if (gpu_driver == nullptr) { 39 if (gpu_driver.IsTextureHandlerSizeKnown() || used_samplers.size() <= 1) {
40 LOG_CRITICAL(HW_GPU, "GPU driver profile has not been created yet");
41 return;
42 }
43 if (gpu_driver->TextureHandlerSizeKnown() || used_samplers.size() <= 1) {
44 return; 40 return;
45 } 41 }
46 u32 count{}; 42 u32 count{};
@@ -53,17 +49,13 @@ void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver,
53 bound_offsets.emplace_back(sampler.GetOffset()); 49 bound_offsets.emplace_back(sampler.GetOffset());
54 } 50 }
55 if (count > 1) { 51 if (count > 1) {
56 gpu_driver->DeduceTextureHandlerSize(std::move(bound_offsets)); 52 gpu_driver.DeduceTextureHandlerSize(std::move(bound_offsets));
57 } 53 }
58} 54}
59 55
60std::optional<u32> TryDeduceSamplerSize(const Sampler& sampler_to_deduce, 56std::optional<u32> TryDeduceSamplerSize(const Sampler& sampler_to_deduce,
61 VideoCore::GuestDriverProfile* gpu_driver, 57 VideoCore::GuestDriverProfile& gpu_driver,
62 const std::list<Sampler>& used_samplers) { 58 const std::list<Sampler>& used_samplers) {
63 if (gpu_driver == nullptr) {
64 LOG_CRITICAL(HW_GPU, "GPU Driver profile has not been created yet");
65 return std::nullopt;
66 }
67 const u32 base_offset = sampler_to_deduce.GetOffset(); 59 const u32 base_offset = sampler_to_deduce.GetOffset();
68 u32 max_offset{std::numeric_limits<u32>::max()}; 60 u32 max_offset{std::numeric_limits<u32>::max()};
69 for (const auto& sampler : used_samplers) { 61 for (const auto& sampler : used_samplers) {
@@ -77,7 +69,7 @@ std::optional<u32> TryDeduceSamplerSize(const Sampler& sampler_to_deduce,
77 if (max_offset == std::numeric_limits<u32>::max()) { 69 if (max_offset == std::numeric_limits<u32>::max()) {
78 return std::nullopt; 70 return std::nullopt;
79 } 71 }
80 return ((max_offset - base_offset) * 4) / gpu_driver->GetTextureHandlerSize(); 72 return ((max_offset - base_offset) * 4) / gpu_driver.GetTextureHandlerSize();
81} 73}
82 74
83} // Anonymous namespace 75} // Anonymous namespace
diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp
index 15e22b9fa..b1a0aa00c 100644
--- a/src/video_core/shader/track.cpp
+++ b/src/video_core/shader/track.cpp
@@ -94,13 +94,10 @@ std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, cons
94 } 94 }
95 auto [gpr, base_offset] = *pair; 95 auto [gpr, base_offset] = *pair;
96 const auto offset_inm = std::get_if<ImmediateNode>(&*base_offset); 96 const auto offset_inm = std::get_if<ImmediateNode>(&*base_offset);
97 auto gpu_driver = locker.AccessGuestDriverProfile(); 97 const auto& gpu_driver = locker.AccessGuestDriverProfile();
98 if (gpu_driver == nullptr) {
99 return {};
100 }
101 const u32 bindless_cv = NewCustomVariable(); 98 const u32 bindless_cv = NewCustomVariable();
102 const Node op = Operation(OperationCode::UDiv, NO_PRECISE, gpr, 99 const Node op =
103 Immediate(gpu_driver->GetTextureHandlerSize())); 100 Operation(OperationCode::UDiv, gpr, Immediate(gpu_driver.GetTextureHandlerSize()));
104 101
105 const Node cv_node = GetCustomVariable(bindless_cv); 102 const Node cv_node = GetCustomVariable(bindless_cv);
106 Node amend_op = Operation(OperationCode::Assign, cv_node, std::move(op)); 103 Node amend_op = Operation(OperationCode::Assign, cv_node, std::move(op));