2018-02-11 21:34:20 -05:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-04-23 21:12:40 -04:00
|
|
|
#include <array>
|
|
|
|
#include "common/assert.h"
|
2018-04-23 23:14:08 -04:00
|
|
|
#include "common/bit_field.h"
|
2018-04-23 21:12:40 -04:00
|
|
|
#include "common/common_funcs.h"
|
2018-02-11 21:34:20 -05:00
|
|
|
#include "common/common_types.h"
|
2018-04-23 23:14:08 -04:00
|
|
|
#include "video_core/gpu.h"
|
2018-04-23 21:12:40 -04:00
|
|
|
#include "video_core/memory_manager.h"
|
2018-02-11 21:34:20 -05:00
|
|
|
|
|
|
|
namespace Tegra {
|
|
|
|
namespace Engines {
|
|
|
|
|
2018-04-23 21:12:40 -04:00
|
|
|
#define FERMI2D_REG_INDEX(field_name) \
|
|
|
|
(offsetof(Tegra::Engines::Fermi2D::Regs, field_name) / sizeof(u32))
|
|
|
|
|
2018-02-11 23:44:12 -05:00
|
|
|
class Fermi2D final {
|
|
|
|
public:
|
2018-04-23 21:12:40 -04:00
|
|
|
explicit Fermi2D(MemoryManager& memory_manager);
|
2018-02-11 23:44:12 -05:00
|
|
|
~Fermi2D() = default;
|
2018-02-11 21:34:20 -05:00
|
|
|
|
2018-02-11 23:44:12 -05:00
|
|
|
/// Write the value to the register identified by method.
|
|
|
|
void WriteReg(u32 method, u32 value);
|
2018-04-23 21:12:40 -04:00
|
|
|
|
|
|
|
struct Regs {
|
|
|
|
static constexpr size_t NUM_REGS = 0x258;
|
|
|
|
|
2018-04-23 23:14:08 -04:00
|
|
|
struct Surface {
|
|
|
|
RenderTargetFormat format;
|
|
|
|
BitField<0, 1, u32> linear;
|
|
|
|
union {
|
|
|
|
BitField<0, 4, u32> block_depth;
|
|
|
|
BitField<4, 4, u32> block_height;
|
|
|
|
BitField<8, 4, u32> block_width;
|
|
|
|
};
|
|
|
|
u32 depth;
|
|
|
|
u32 layer;
|
|
|
|
u32 pitch;
|
|
|
|
u32 width;
|
|
|
|
u32 height;
|
|
|
|
u32 address_high;
|
|
|
|
u32 address_low;
|
|
|
|
|
|
|
|
GPUVAddr Address() const {
|
|
|
|
return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) |
|
|
|
|
address_low);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static_assert(sizeof(Surface) == 0x28, "Surface has incorrect size");
|
|
|
|
|
|
|
|
enum class Operation : u32 {
|
|
|
|
SrcCopyAnd = 0,
|
|
|
|
ROPAnd = 1,
|
|
|
|
Blend = 2,
|
|
|
|
SrcCopy = 3,
|
|
|
|
ROP = 4,
|
|
|
|
SrcCopyPremult = 5,
|
|
|
|
BlendPremult = 6,
|
|
|
|
};
|
|
|
|
|
2018-04-23 21:12:40 -04:00
|
|
|
union {
|
|
|
|
struct {
|
2018-04-23 23:14:08 -04:00
|
|
|
INSERT_PADDING_WORDS(0x80);
|
|
|
|
|
|
|
|
Surface dst;
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(2);
|
|
|
|
|
|
|
|
Surface src;
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0x15);
|
|
|
|
|
|
|
|
Operation operation;
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0x9);
|
|
|
|
|
|
|
|
// TODO(Subv): This is only a guess.
|
|
|
|
u32 trigger;
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0x1A3);
|
2018-04-23 21:12:40 -04:00
|
|
|
};
|
|
|
|
std::array<u32, NUM_REGS> reg_array;
|
|
|
|
};
|
|
|
|
} regs{};
|
|
|
|
|
|
|
|
MemoryManager& memory_manager;
|
2018-04-24 23:00:40 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// Performs the copy from the source surface to the destination surface as configured in the
|
|
|
|
/// registers.
|
|
|
|
void HandleSurfaceCopy();
|
2018-02-11 23:44:12 -05:00
|
|
|
};
|
2018-02-11 21:34:20 -05:00
|
|
|
|
2018-04-23 21:12:40 -04:00
|
|
|
#define ASSERT_REG_POSITION(field_name, position) \
|
|
|
|
static_assert(offsetof(Fermi2D::Regs, field_name) == position * 4, \
|
|
|
|
"Field " #field_name " has invalid position")
|
|
|
|
|
2018-04-23 23:14:08 -04:00
|
|
|
ASSERT_REG_POSITION(dst, 0x80);
|
|
|
|
ASSERT_REG_POSITION(src, 0x8C);
|
|
|
|
ASSERT_REG_POSITION(operation, 0xAB);
|
|
|
|
ASSERT_REG_POSITION(trigger, 0xB5);
|
2018-04-23 21:12:40 -04:00
|
|
|
#undef ASSERT_REG_POSITION
|
|
|
|
|
2018-02-11 21:34:20 -05:00
|
|
|
} // namespace Engines
|
|
|
|
} // namespace Tegra
|