summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-01-24 15:44:34 +0100
committerFernandoS27 <fsahmkow27@gmail.com>2020-01-25 14:04:59 +0100
commitbb8eb15d392d69693f8cda0427669d011e23db97 (patch)
treecebd080530de75e7b5400f46c25c307a80e3c222 /src/video_core/shader
parentShader_IR: Change name of TrackSampler function so it does not confuse with the type. (diff)
downloadyuzu-bb8eb15d392d69693f8cda0427669d011e23db97.tar
yuzu-bb8eb15d392d69693f8cda0427669d011e23db97.tar.gz
yuzu-bb8eb15d392d69693f8cda0427669d011e23db97.tar.bz2
yuzu-bb8eb15d392d69693f8cda0427669d011e23db97.tar.lz
yuzu-bb8eb15d392d69693f8cda0427669d011e23db97.tar.xz
yuzu-bb8eb15d392d69693f8cda0427669d011e23db97.tar.zst
yuzu-bb8eb15d392d69693f8cda0427669d011e23db97.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/shader/const_buffer_locker.h2
-rw-r--r--src/video_core/shader/decode.cpp31
-rw-r--r--src/video_core/shader/decode/texture.cpp3
-rw-r--r--src/video_core/shader/node.h14
-rw-r--r--src/video_core/shader/shader_ir.cpp3
-rw-r--r--src/video_core/shader/shader_ir.h2
-rw-r--r--src/video_core/shader/track.cpp9
7 files changed, 33 insertions, 31 deletions
diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/const_buffer_locker.h
index fd1bb476a..d3ea11087 100644
--- a/src/video_core/shader/const_buffer_locker.h
+++ b/src/video_core/shader/const_buffer_locker.h
@@ -77,10 +77,12 @@ public:
return bindless_samplers;
}
+ /// Gets bound buffer used on this shader
u32 GetBoundBuffer() const {
return bound_buffer;
}
+ /// Obtains access to the guest driver's profile.
VideoCore::GuestDriverProfile* AccessGuestDriverProfile() const {
if (engine) {
return &engine->AccessGuestDriverProfile();
diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp
index d4a10eee5..6b697ed5d 100644
--- a/src/video_core/shader/decode.cpp
+++ b/src/video_core/shader/decode.cpp
@@ -35,9 +35,9 @@ constexpr bool IsSchedInstruction(u32 offset, u32 main_offset) {
}
void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver,
- std::list<Sampler>& used_samplers) {
+ const std::list<Sampler>& used_samplers) {
if (gpu_driver == nullptr) {
- LOG_CRITICAL(HW_GPU, "GPU Driver profile has not been created yet");
+ LOG_CRITICAL(HW_GPU, "GPU driver profile has not been created yet");
return;
}
if (gpu_driver->TextureHandlerSizeKnown() || used_samplers.size() <= 1) {
@@ -57,9 +57,9 @@ void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile* gpu_driver,
}
}
-std::optional<u32> TryDeduceSamplerSize(Sampler& sampler_to_deduce,
+std::optional<u32> TryDeduceSamplerSize(const Sampler& sampler_to_deduce,
VideoCore::GuestDriverProfile* gpu_driver,
- std::list<Sampler>& used_samplers) {
+ const std::list<Sampler>& used_samplers) {
if (gpu_driver == nullptr) {
LOG_CRITICAL(HW_GPU, "GPU Driver profile has not been created yet");
return std::nullopt;
@@ -367,17 +367,18 @@ void ShaderIR::PostDecode() {
auto gpu_driver = locker.AccessGuestDriverProfile();
DeduceTextureHandlerSize(gpu_driver, used_samplers);
// Deduce Indexed Samplers
- if (uses_indexed_samplers) {
- for (auto& sampler : used_samplers) {
- if (sampler.IsIndexed()) {
- auto size = TryDeduceSamplerSize(sampler, gpu_driver, used_samplers);
- if (size) {
- sampler.SetSize(*size);
- } else {
- LOG_CRITICAL(HW_GPU, "Failed to deduce size of indexed sampler");
- sampler.SetSize(1);
- }
- }
+ if (!uses_indexed_samplers) {
+ return;
+ }
+ for (auto& sampler : used_samplers) {
+ if (!sampler.IsIndexed()) {
+ continue;
+ }
+ if (const auto size = TryDeduceSamplerSize(sampler, gpu_driver, used_samplers)) {
+ sampler.SetSize(*size);
+ } else {
+ LOG_CRITICAL(HW_GPU, "Failed to deduce size of indexed sampler");
+ sampler.SetSize(1);
}
}
}
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp
index 6da9668fe..d980535b1 100644
--- a/src/video_core/shader/decode/texture.cpp
+++ b/src/video_core/shader/decode/texture.cpp
@@ -201,7 +201,8 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
}
for (u32 element = 0; element < values.size(); ++element) {
- MetaTexture meta{*sampler, array_node, {}, {}, {}, derivates, {}, {}, {}, element, index_var};
+ MetaTexture meta{*sampler, array_node, {}, {}, {}, derivates,
+ {}, {}, {}, element, index_var};
values[element] = Operation(OperationCode::TextureGradient, std::move(meta), coords);
}
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h
index d75453458..53a551d27 100644
--- a/src/video_core/shader/node.h
+++ b/src/video_core/shader/node.h
@@ -291,7 +291,7 @@ public:
return size;
}
- void SetSize(u32 new_size) {
+ constexpr void SetSize(u32 new_size) {
size = new_size;
}
@@ -315,15 +315,15 @@ public:
explicit ArraySamplerNode(u32 index, u32 base_offset, u32 bindless_var)
: index{index}, base_offset{base_offset}, bindless_var{bindless_var} {}
- u32 GetIndex() const {
+ constexpr u32 GetIndex() const {
return index;
}
- u32 GetBaseOffset() const {
+ constexpr u32 GetBaseOffset() const {
return base_offset;
}
- u32 GetIndexVar() const {
+ constexpr u32 GetIndexVar() const {
return bindless_var;
}
@@ -338,11 +338,11 @@ class BindlessSamplerNode final {
public:
explicit BindlessSamplerNode(u32 index, u32 offset) : index{index}, offset{offset} {}
- u32 GetIndex() const {
+ constexpr u32 GetIndex() const {
return index;
}
- u32 GetOffset() const {
+ constexpr u32 GetOffset() const {
return offset;
}
@@ -557,7 +557,7 @@ class CustomVarNode final {
public:
explicit constexpr CustomVarNode(u32 index) : index{index} {}
- u32 GetIndex() const {
+ constexpr u32 GetIndex() const {
return index;
}
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp
index 94972d57f..3a5d280a9 100644
--- a/src/video_core/shader/shader_ir.cpp
+++ b/src/video_core/shader/shader_ir.cpp
@@ -458,8 +458,7 @@ std::size_t ShaderIR::DeclareAmend(Node new_amend) {
}
u32 ShaderIR::NewCustomVariable() {
- const u32 id = num_custom_variables++;
- return id;
+ return num_custom_variables++;
}
} // namespace VideoCommon::Shader
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index 43672b41c..b0851c3be 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -180,7 +180,7 @@ public:
return amend_code[index];
}
- u32 GetCustomVariablesAmount() const {
+ u32 GetNumCustomVariables() const {
return num_custom_variables;
}
diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp
index 4db721f69..ea39bca54 100644
--- a/src/video_core/shader/track.cpp
+++ b/src/video_core/shader/track.cpp
@@ -36,7 +36,6 @@ std::pair<Node, s64> FindOperation(const NodeBlock& code, s64 cursor,
}
return {};
}
-} // Anonymous namespace
std::optional<std::pair<Node, Node>> DecoupleIndirectRead(const OperationNode& operation) {
if (operation.GetCode() != OperationCode::UAdd) {
@@ -44,9 +43,7 @@ std::optional<std::pair<Node, Node>> DecoupleIndirectRead(const OperationNode& o
}
Node gpr{};
Node offset{};
- if (operation.GetOperandsCount() != 2) {
- return std::nullopt;
- }
+ ASSERT(operation.GetOperandsCount() == 2);
for (std::size_t i = 0; i < operation.GetOperandsCount(); i++) {
Node operand = operation[i];
if (std::holds_alternative<ImmediateNode>(*operand)) {
@@ -56,7 +53,7 @@ std::optional<std::pair<Node, Node>> DecoupleIndirectRead(const OperationNode& o
}
}
if (offset && gpr) {
- return {std::make_pair(gpr, offset)};
+ return std::make_pair(gpr, offset);
}
return std::nullopt;
}
@@ -72,6 +69,8 @@ bool AmendNodeCv(std::size_t amend_index, Node node) {
return false;
}
+} // Anonymous namespace
+
std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, const NodeBlock& code,
s64 cursor) {
if (const auto cbuf = std::get_if<CbufNode>(&*tracked)) {