Skip to content

Commit

Permalink
gpu: extend resource evaluation rules to handle relative resources
Browse files Browse the repository at this point in the history
implement evaluation of x16 dword loads
fixed evaluation of binary expressions
  • Loading branch information
DHrpcs3 committed Nov 13, 2024
1 parent b85c6e6 commit f4994f6
Show file tree
Hide file tree
Showing 7 changed files with 419 additions and 116 deletions.
18 changes: 14 additions & 4 deletions rpcsx/gpu/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ static ConverterFn *getPrimConverterFn(gnm::PrimitiveType primType,
static_cast<unsigned>(primType));
}
}
shader::eval::Value Cache::ShaderResources::eval(shader::ir::Value op) {
if (op == ir::sop2::ADD_U32 || op == ir::sop2::ADDC_U32) {
return eval(op.getOperand(1)) + eval(op.getOperand(2));
}

return Evaluator::eval(op);
}

void Cache::ShaderResources::loadResources(
gcn::Resources &res, std::span<const std::uint32_t> userSgprs) {
Expand Down Expand Up @@ -454,8 +461,11 @@ Cache::ShaderResources::eval(ir::InstructionId instId,
case 32:
result = readPointer<std::array<std::uint32_t, 8>>(address);
break;
case 64:
result = readPointer<std::array<std::uint32_t, 16>>(address);
break;
default:
rx::die("unexpected pointer load size");
rx::die("unexpected pointer load size %u", loadSize);
}

return result;
Expand Down Expand Up @@ -1275,9 +1285,9 @@ Cache::Shader Cache::Tag::getShader(const ShaderKey &key,

// deserialized.print(std::cerr, context.ns);

converted = gcn::convertToSpv(context, deserialized,
mParent->mDevice->gcnSemanticModuleInfo,
key.stage, env);
converted = gcn::convertToSpv(
context, deserialized, mParent->mDevice->gcnSemantic,
mParent->mDevice->gcnSemanticModuleInfo, key.stage, env);
if (!converted) {
return {};
}
Expand Down
2 changes: 1 addition & 1 deletion rpcsx/gpu/lib/gcn-shader/include/shader/GcnConverter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ struct ConvertedShader {

std::optional<ConvertedShader>
convertToSpv(Context &context, ir::Region body,
const SemanticInfo &semanticInfo,
const SemanticModuleInfo &semanticModule, Stage stage,
const Environment &state);

} // namespace shader::gcn
15 changes: 6 additions & 9 deletions rpcsx/gpu/lib/gcn-shader/include/shader/analyze.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ CFG buildCFG(ir::Instruction firstInstruction,
MemorySSA buildMemorySSA(CFG &cfg, ModuleInfo *moduleInfo = nullptr);

MemorySSA buildMemorySSA(CFG &cfg, const SemanticInfo &instructionSemantic,
std::function<ir::Value(int)> getRegisterVarCb);
std::function<ir::Value(int)> getRegisterVarCb,
ModuleInfo *moduleInfo = nullptr);

bool dominates(ir::Instruction a, ir::Instruction b, bool isPostDom,
graph::DomTree<ir::Value> &domTree);
Expand Down Expand Up @@ -385,10 +386,8 @@ struct Construct {
CFG &getCfg() {
return analysis.get<CFG>([this] {
if (parent != nullptr) {
return parent->getCfg().buildView(
header,
&parent->getPostDomTree(),
{header, merge});
return parent->getCfg().buildView(header, &parent->getPostDomTree(),
{header, merge});
}

return buildCFG(header);
Expand All @@ -402,10 +401,8 @@ struct Construct {

return analysis.get<Tag<CFG, kWithoutContinue>>([this] {
if (parent != nullptr) {
return parent->getCfg().buildView(
header,
&parent->getPostDomTree(),
{header, merge}, loopContinue);
return parent->getCfg().buildView(header, &parent->getPostDomTree(),
{header, merge}, loopContinue);
}

return buildCFG(header, {}, loopContinue);
Expand Down
5 changes: 3 additions & 2 deletions rpcsx/gpu/lib/gcn-shader/include/shader/eval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "Vector.hpp"
#include "ir/Value.hpp"
#include <array>
#include <cstdint>
#include <variant>
#include <array>

namespace shader::eval {
struct Value {
Expand All @@ -15,7 +15,8 @@ struct Value {
u16vec2, u16vec3, u16vec4, i16vec2, i16vec3, i16vec4, u32vec2, u32vec3,
u32vec4, i32vec2, i32vec3, i32vec4, u64vec2, u64vec3, u64vec4, i64vec2,
i64vec3, i64vec4, f32vec2, f32vec3, f32vec4, f64vec2, f64vec3, f64vec4,
f16vec2, f16vec3, f16vec4, bool, bvec2, bvec3, bvec4, std::array<uint32_t, 8>>;
f16vec2, f16vec3, f16vec4, bool, bvec2, bvec3, bvec4,
std::array<uint32_t, 8>, std::array<std::uint32_t, 16>>;
static constexpr auto StorageSize = std::variant_size_v<Storage>;
Storage storage;

Expand Down
Loading

0 comments on commit f4994f6

Please sign in to comment.