2019-01-23 00:49:31 +01:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-03-06 02:25:01 +01:00
|
|
|
#include "common/assert.h"
|
2019-01-23 00:49:31 +01:00
|
|
|
#include "common/logging/log.h"
|
2019-04-23 01:05:43 +02:00
|
|
|
#include "core/core.h"
|
2019-01-23 00:49:31 +01:00
|
|
|
#include "video_core/engines/kepler_compute.h"
|
2019-04-23 01:05:43 +02:00
|
|
|
#include "video_core/engines/maxwell_3d.h"
|
2019-01-23 00:49:31 +01:00
|
|
|
#include "video_core/memory_manager.h"
|
2019-04-23 01:05:43 +02:00
|
|
|
#include "video_core/rasterizer_interface.h"
|
|
|
|
#include "video_core/renderer_base.h"
|
|
|
|
#include "video_core/textures/decoders.h"
|
2019-01-23 00:49:31 +01:00
|
|
|
|
|
|
|
namespace Tegra::Engines {
|
|
|
|
|
2019-04-23 01:05:43 +02:00
|
|
|
KeplerCompute::KeplerCompute(Core::System& system, VideoCore::RasterizerInterface& rasterizer,
|
|
|
|
MemoryManager& memory_manager)
|
|
|
|
: system{system}, rasterizer{rasterizer}, memory_manager{memory_manager}, upload_state{
|
|
|
|
memory_manager,
|
|
|
|
regs.upload} {}
|
2019-01-23 00:49:31 +01:00
|
|
|
|
|
|
|
KeplerCompute::~KeplerCompute() = default;
|
|
|
|
|
|
|
|
void KeplerCompute::CallMethod(const GPU::MethodCall& method_call) {
|
|
|
|
ASSERT_MSG(method_call.method < Regs::NUM_REGS,
|
|
|
|
"Invalid KeplerCompute register, increase the size of the Regs structure");
|
|
|
|
|
|
|
|
regs.reg_array[method_call.method] = method_call.argument;
|
|
|
|
|
|
|
|
switch (method_call.method) {
|
2019-04-23 01:05:43 +02:00
|
|
|
case KEPLER_COMPUTE_REG_INDEX(exec_upload): {
|
|
|
|
upload_state.ProcessExec(regs.exec_upload.linear != 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case KEPLER_COMPUTE_REG_INDEX(data_upload): {
|
2019-04-23 14:02:24 +02:00
|
|
|
const bool is_last_call = method_call.IsLastCall();
|
2019-04-23 01:05:43 +02:00
|
|
|
upload_state.ProcessData(method_call.argument, is_last_call);
|
|
|
|
if (is_last_call) {
|
2019-07-10 21:38:31 +02:00
|
|
|
system.GPU().Maxwell3D().dirty.OnMemoryWrite();
|
2019-04-23 01:05:43 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2019-01-23 00:49:31 +01:00
|
|
|
case KEPLER_COMPUTE_REG_INDEX(launch):
|
2019-04-23 01:05:43 +02:00
|
|
|
ProcessLaunch();
|
2019-01-23 00:49:31 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-23 01:05:43 +02:00
|
|
|
void KeplerCompute::ProcessLaunch() {
|
|
|
|
const GPUVAddr launch_desc_loc = regs.launch_desc_loc.Address();
|
|
|
|
memory_manager.ReadBlockUnsafe(launch_desc_loc, &launch_description,
|
|
|
|
LaunchParams::NUM_LAUNCH_PARAMETERS * sizeof(u32));
|
|
|
|
|
2019-07-15 03:25:13 +02:00
|
|
|
const GPUVAddr code_addr = regs.code_loc.Address() + launch_description.program_start;
|
|
|
|
LOG_TRACE(HW_GPU, "Compute invocation launched at address 0x{:016x}", code_addr);
|
|
|
|
|
|
|
|
rasterizer.DispatchCompute(code_addr);
|
2019-04-23 01:05:43 +02:00
|
|
|
}
|
|
|
|
|
2019-01-23 00:49:31 +01:00
|
|
|
} // namespace Tegra::Engines
|