2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-09-08 22:58:20 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
2019-03-06 02:25:01 +01:00
|
|
|
#include <cstddef>
|
2018-09-08 22:58:20 +02:00
|
|
|
#include "common/bit_field.h"
|
|
|
|
#include "common/common_funcs.h"
|
|
|
|
#include "common/common_types.h"
|
2020-04-28 03:47:58 +02:00
|
|
|
#include "video_core/engines/engine_interface.h"
|
2019-04-23 00:50:56 +02:00
|
|
|
#include "video_core/engines/engine_upload.h"
|
2018-09-08 22:58:20 +02:00
|
|
|
|
2019-02-16 04:05:17 +01:00
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2019-04-06 00:21:15 +02:00
|
|
|
namespace Tegra {
|
|
|
|
class MemoryManager;
|
|
|
|
}
|
|
|
|
|
2022-01-29 22:00:49 +01:00
|
|
|
namespace VideoCore {
|
|
|
|
class RasterizerInterface;
|
|
|
|
}
|
|
|
|
|
2018-09-08 22:58:20 +02:00
|
|
|
namespace Tegra::Engines {
|
|
|
|
|
2019-04-23 14:44:52 +02:00
|
|
|
/**
|
|
|
|
* This Engine is known as P2MF. Documentation can be found in:
|
|
|
|
* https://github.com/envytools/envytools/blob/master/rnndb/graph/gk104_p2mf.xml
|
|
|
|
* https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/nouveau/nvc0/nve4_p2mf.xml.h
|
|
|
|
*/
|
|
|
|
|
2018-09-08 22:58:20 +02:00
|
|
|
#define KEPLERMEMORY_REG_INDEX(field_name) \
|
|
|
|
(offsetof(Tegra::Engines::KeplerMemory::Regs, field_name) / sizeof(u32))
|
|
|
|
|
2020-04-28 03:47:58 +02:00
|
|
|
class KeplerMemory final : public EngineInterface {
|
2018-09-08 22:58:20 +02:00
|
|
|
public:
|
2020-12-04 20:39:12 +01:00
|
|
|
explicit KeplerMemory(Core::System& system_, MemoryManager& memory_manager);
|
2021-04-12 15:49:04 +02:00
|
|
|
~KeplerMemory() override;
|
2018-09-08 22:58:20 +02:00
|
|
|
|
2022-01-29 22:00:49 +01:00
|
|
|
/// Binds a rasterizer to this engine.
|
|
|
|
void BindRasterizer(VideoCore::RasterizerInterface* rasterizer);
|
|
|
|
|
2018-09-08 22:58:20 +02:00
|
|
|
/// Write the value to the register identified by method.
|
2020-04-28 03:47:58 +02:00
|
|
|
void CallMethod(u32 method, u32 method_argument, bool is_last_call) override;
|
2018-09-08 22:58:20 +02:00
|
|
|
|
2020-04-20 08:16:56 +02:00
|
|
|
/// Write multiple values to the register identified by method.
|
2020-04-28 19:53:47 +02:00
|
|
|
void CallMultiMethod(u32 method, const u32* base_start, u32 amount,
|
|
|
|
u32 methods_pending) override;
|
2020-04-20 08:16:56 +02:00
|
|
|
|
2018-09-08 22:58:20 +02:00
|
|
|
struct Regs {
|
|
|
|
static constexpr size_t NUM_REGS = 0x7F;
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
2021-01-15 08:25:40 +01:00
|
|
|
INSERT_PADDING_WORDS_NOINIT(0x60);
|
2018-09-08 22:58:20 +02:00
|
|
|
|
2019-04-25 18:57:10 +02:00
|
|
|
Upload::Registers upload;
|
2018-09-08 22:58:20 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
BitField<0, 1, u32> linear;
|
|
|
|
};
|
|
|
|
} exec;
|
|
|
|
|
|
|
|
u32 data;
|
|
|
|
|
2021-01-15 08:25:40 +01:00
|
|
|
INSERT_PADDING_WORDS_NOINIT(0x11);
|
2018-09-08 22:58:20 +02:00
|
|
|
};
|
|
|
|
std::array<u32, NUM_REGS> reg_array;
|
|
|
|
};
|
|
|
|
} regs{};
|
|
|
|
|
|
|
|
private:
|
2022-11-27 00:58:06 +01:00
|
|
|
void ConsumeSinkImpl() override;
|
|
|
|
|
2019-02-16 04:05:17 +01:00
|
|
|
Core::System& system;
|
2019-04-23 00:50:56 +02:00
|
|
|
Upload::State upload_state;
|
2018-09-08 22:58:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ASSERT_REG_POSITION(field_name, position) \
|
|
|
|
static_assert(offsetof(KeplerMemory::Regs, field_name) == position * 4, \
|
|
|
|
"Field " #field_name " has invalid position")
|
|
|
|
|
2019-04-23 00:50:56 +02:00
|
|
|
ASSERT_REG_POSITION(upload, 0x60);
|
2018-09-08 22:58:20 +02:00
|
|
|
ASSERT_REG_POSITION(exec, 0x6C);
|
|
|
|
ASSERT_REG_POSITION(data, 0x6D);
|
|
|
|
#undef ASSERT_REG_POSITION
|
|
|
|
|
|
|
|
} // namespace Tegra::Engines
|