2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2019-04-23 00:50:56 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-08-14 11:36:36 +02:00
|
|
|
#include <span>
|
2022-12-19 00:09:59 +01:00
|
|
|
|
2019-04-23 00:50:56 +02:00
|
|
|
#include "common/bit_field.h"
|
|
|
|
#include "common/common_types.h"
|
2022-12-19 00:09:59 +01:00
|
|
|
#include "common/scratch_buffer.h"
|
2019-04-23 00:50:56 +02:00
|
|
|
|
|
|
|
namespace Tegra {
|
|
|
|
class MemoryManager;
|
|
|
|
}
|
|
|
|
|
2022-01-29 22:00:49 +01:00
|
|
|
namespace VideoCore {
|
|
|
|
class RasterizerInterface;
|
|
|
|
}
|
|
|
|
|
2019-04-23 00:50:56 +02:00
|
|
|
namespace Tegra::Engines::Upload {
|
|
|
|
|
2019-04-25 18:57:10 +02:00
|
|
|
struct Registers {
|
2019-04-23 00:50:56 +02:00
|
|
|
u32 line_length_in;
|
|
|
|
u32 line_count;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 address_high;
|
|
|
|
u32 address_low;
|
|
|
|
u32 pitch;
|
|
|
|
union {
|
|
|
|
BitField<0, 4, u32> block_width;
|
|
|
|
BitField<4, 4, u32> block_height;
|
|
|
|
BitField<8, 4, u32> block_depth;
|
|
|
|
};
|
|
|
|
u32 width;
|
|
|
|
u32 height;
|
|
|
|
u32 depth;
|
2022-08-14 11:36:36 +02:00
|
|
|
u32 layer;
|
2019-04-23 00:50:56 +02:00
|
|
|
u32 x;
|
|
|
|
u32 y;
|
|
|
|
|
|
|
|
GPUVAddr Address() const {
|
2022-11-29 14:04:40 +01:00
|
|
|
return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
|
2019-04-23 00:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 BlockWidth() const {
|
2019-06-13 22:41:16 +02:00
|
|
|
return block_width.Value();
|
2019-04-23 00:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 BlockHeight() const {
|
2019-06-13 22:41:16 +02:00
|
|
|
return block_height.Value();
|
2019-04-23 00:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 BlockDepth() const {
|
2019-06-13 22:41:16 +02:00
|
|
|
return block_depth.Value();
|
2019-04-23 00:50:56 +02:00
|
|
|
}
|
|
|
|
} dest;
|
|
|
|
};
|
|
|
|
|
|
|
|
class State {
|
|
|
|
public:
|
2020-12-04 20:39:12 +01:00
|
|
|
explicit State(MemoryManager& memory_manager_, Registers& regs_);
|
2019-05-14 19:41:34 +02:00
|
|
|
~State();
|
2019-04-23 00:50:56 +02:00
|
|
|
|
2020-12-04 20:39:12 +01:00
|
|
|
void ProcessExec(bool is_linear_);
|
2019-05-14 19:40:05 +02:00
|
|
|
void ProcessData(u32 data, bool is_last_call);
|
2022-08-14 11:36:36 +02:00
|
|
|
void ProcessData(const u32* data, size_t num_data);
|
2019-04-23 00:50:56 +02:00
|
|
|
|
2022-01-29 22:00:49 +01:00
|
|
|
/// Binds a rasterizer to this engine.
|
|
|
|
void BindRasterizer(VideoCore::RasterizerInterface* rasterizer);
|
|
|
|
|
2019-04-23 00:50:56 +02:00
|
|
|
private:
|
2022-08-14 11:36:36 +02:00
|
|
|
void ProcessData(std::span<const u8> read_buffer);
|
|
|
|
|
2019-04-23 00:50:56 +02:00
|
|
|
u32 write_offset = 0;
|
|
|
|
u32 copy_size = 0;
|
2022-12-19 00:09:59 +01:00
|
|
|
Common::ScratchBuffer<u8> inner_buffer;
|
|
|
|
Common::ScratchBuffer<u8> tmp_buffer;
|
2019-04-25 18:57:10 +02:00
|
|
|
bool is_linear = false;
|
|
|
|
Registers& regs;
|
2019-04-23 00:50:56 +02:00
|
|
|
MemoryManager& memory_manager;
|
2022-01-29 22:00:49 +01:00
|
|
|
VideoCore::RasterizerInterface* rasterizer = nullptr;
|
2019-04-23 00:50:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Tegra::Engines::Upload
|