2018-02-12 02:34:20 +00:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-03-17 03:06:24 +00:00
|
|
|
#include <array>
|
2018-03-17 01:32:44 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
2018-03-22 23:47:28 +00:00
|
|
|
#include "common/assert.h"
|
2018-02-12 17:34:41 +00:00
|
|
|
#include "common/bit_field.h"
|
|
|
|
#include "common/common_funcs.h"
|
2018-02-12 02:34:20 +00:00
|
|
|
#include "common/common_types.h"
|
2018-03-24 04:45:24 +00:00
|
|
|
#include "video_core/gpu.h"
|
2018-02-12 17:34:41 +00:00
|
|
|
#include "video_core/memory_manager.h"
|
2018-03-23 23:56:27 +00:00
|
|
|
#include "video_core/textures/texture.h"
|
2018-02-12 02:34:20 +00:00
|
|
|
|
|
|
|
namespace Tegra {
|
|
|
|
namespace Engines {
|
|
|
|
|
2018-02-12 04:44:12 +00:00
|
|
|
class Maxwell3D final {
|
|
|
|
public:
|
2018-02-14 04:47:51 +00:00
|
|
|
explicit Maxwell3D(MemoryManager& memory_manager);
|
2018-02-12 04:44:12 +00:00
|
|
|
~Maxwell3D() = default;
|
2018-02-12 02:34:20 +00:00
|
|
|
|
2018-02-12 17:34:41 +00:00
|
|
|
/// Register structure of the Maxwell3D engine.
|
|
|
|
/// TODO(Subv): This structure will need to be made bigger as more registers are discovered.
|
|
|
|
struct Regs {
|
|
|
|
static constexpr size_t NUM_REGS = 0xE36;
|
|
|
|
|
2018-03-19 21:46:29 +00:00
|
|
|
static constexpr size_t NumRenderTargets = 8;
|
2018-03-24 06:22:19 +00:00
|
|
|
static constexpr size_t NumViewports = 16;
|
2018-03-17 21:17:45 +00:00
|
|
|
static constexpr size_t NumCBData = 16;
|
2018-03-17 03:47:45 +00:00
|
|
|
static constexpr size_t NumVertexArrays = 32;
|
2018-03-21 04:33:56 +00:00
|
|
|
static constexpr size_t NumVertexAttributes = 32;
|
2018-03-17 03:47:45 +00:00
|
|
|
static constexpr size_t MaxShaderProgram = 6;
|
2018-03-17 22:08:26 +00:00
|
|
|
static constexpr size_t MaxShaderStage = 5;
|
2018-03-17 22:06:23 +00:00
|
|
|
// Maximum number of const buffers per shader stage.
|
|
|
|
static constexpr size_t MaxConstBuffers = 16;
|
2018-03-17 03:47:45 +00:00
|
|
|
|
2018-02-12 17:34:41 +00:00
|
|
|
enum class QueryMode : u32 {
|
|
|
|
Write = 0,
|
|
|
|
Sync = 1,
|
|
|
|
};
|
|
|
|
|
2018-03-17 00:23:11 +00:00
|
|
|
enum class ShaderProgram : u32 {
|
|
|
|
VertexA = 0,
|
|
|
|
VertexB = 1,
|
|
|
|
TesselationControl = 2,
|
|
|
|
TesselationEval = 3,
|
|
|
|
Geometry = 4,
|
|
|
|
Fragment = 5,
|
|
|
|
};
|
|
|
|
|
2018-03-17 22:08:26 +00:00
|
|
|
enum class ShaderStage : u32 {
|
2018-03-17 00:23:11 +00:00
|
|
|
Vertex = 0,
|
|
|
|
TesselationControl = 1,
|
|
|
|
TesselationEval = 2,
|
|
|
|
Geometry = 3,
|
|
|
|
Fragment = 4,
|
|
|
|
};
|
|
|
|
|
2018-03-22 23:47:28 +00:00
|
|
|
enum class VertexSize : u32 {
|
|
|
|
Size_32_32_32_32 = 0x01,
|
|
|
|
Size_32_32_32 = 0x02,
|
|
|
|
Size_16_16_16_16 = 0x03,
|
|
|
|
Size_32_32 = 0x04,
|
|
|
|
Size_16_16_16 = 0x05,
|
|
|
|
Size_8_8_8_8 = 0x0a,
|
|
|
|
Size_16_16 = 0x0f,
|
|
|
|
Size_32 = 0x12,
|
|
|
|
Size_8_8_8 = 0x13,
|
|
|
|
Size_8_8 = 0x18,
|
|
|
|
Size_16 = 0x1b,
|
|
|
|
Size_8 = 0x1d,
|
|
|
|
Size_10_10_10_2 = 0x30,
|
|
|
|
Size_11_11_10 = 0x31,
|
|
|
|
};
|
|
|
|
|
|
|
|
static std::string VertexSizeToString(VertexSize vertex_size) {
|
|
|
|
switch (vertex_size) {
|
|
|
|
case VertexSize::Size_32_32_32_32:
|
|
|
|
return "32_32_32_32";
|
|
|
|
case VertexSize::Size_32_32_32:
|
|
|
|
return "32_32_32";
|
|
|
|
case VertexSize::Size_16_16_16_16:
|
|
|
|
return "16_16_16_16";
|
|
|
|
case VertexSize::Size_32_32:
|
|
|
|
return "32_32";
|
|
|
|
case VertexSize::Size_16_16_16:
|
|
|
|
return "16_16_16";
|
|
|
|
case VertexSize::Size_8_8_8_8:
|
|
|
|
return "8_8_8_8";
|
|
|
|
case VertexSize::Size_16_16:
|
|
|
|
return "16_16";
|
|
|
|
case VertexSize::Size_32:
|
|
|
|
return "32";
|
|
|
|
case VertexSize::Size_8_8_8:
|
|
|
|
return "8_8_8";
|
|
|
|
case VertexSize::Size_8_8:
|
|
|
|
return "8_8";
|
|
|
|
case VertexSize::Size_16:
|
|
|
|
return "16";
|
|
|
|
case VertexSize::Size_8:
|
|
|
|
return "8";
|
|
|
|
case VertexSize::Size_10_10_10_2:
|
|
|
|
return "10_10_10_2";
|
|
|
|
case VertexSize::Size_11_11_10:
|
|
|
|
return "11_11_10";
|
|
|
|
}
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
enum class VertexType : u32 {
|
|
|
|
SignedNorm = 1,
|
|
|
|
UnsignedNorm = 2,
|
|
|
|
SignedInt = 3,
|
|
|
|
UnsignedInt = 4,
|
|
|
|
UnsignedScaled = 5,
|
|
|
|
SignedScaled = 6,
|
|
|
|
Float = 7,
|
|
|
|
};
|
|
|
|
|
|
|
|
static std::string VertexTypeToString(VertexType vertex_type) {
|
|
|
|
switch (vertex_type) {
|
|
|
|
case VertexType::SignedNorm:
|
|
|
|
return "SignedNorm";
|
|
|
|
case VertexType::UnsignedNorm:
|
|
|
|
return "UnsignedNorm";
|
|
|
|
case VertexType::SignedInt:
|
|
|
|
return "SignedInt";
|
|
|
|
case VertexType::UnsignedInt:
|
|
|
|
return "UnsignedInt";
|
|
|
|
case VertexType::UnsignedScaled:
|
|
|
|
return "UnsignedScaled";
|
|
|
|
case VertexType::SignedScaled:
|
|
|
|
return "SignedScaled";
|
|
|
|
case VertexType::Float:
|
|
|
|
return "Float";
|
|
|
|
}
|
|
|
|
UNIMPLEMENTED();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
enum class PrimitiveTopology : u32 {
|
|
|
|
Points = 0x0,
|
|
|
|
Lines = 0x1,
|
|
|
|
LineLoop = 0x2,
|
|
|
|
LineStrip = 0x3,
|
|
|
|
Triangles = 0x4,
|
|
|
|
TriangleStrip = 0x5,
|
|
|
|
TriangleFan = 0x6,
|
|
|
|
Quads = 0x7,
|
|
|
|
QuadStrip = 0x8,
|
|
|
|
Polygon = 0x9,
|
|
|
|
LinesAdjacency = 0xa,
|
|
|
|
LineStripAdjacency = 0xb,
|
|
|
|
TrianglesAdjacency = 0xc,
|
|
|
|
TriangleStripAdjacency = 0xd,
|
|
|
|
Patches = 0xe,
|
|
|
|
};
|
|
|
|
|
2018-02-12 17:34:41 +00:00
|
|
|
union {
|
|
|
|
struct {
|
2018-03-19 21:46:29 +00:00
|
|
|
INSERT_PADDING_WORDS(0x200);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 address_high;
|
|
|
|
u32 address_low;
|
2018-03-24 04:45:24 +00:00
|
|
|
u32 width;
|
|
|
|
u32 height;
|
|
|
|
Tegra::RenderTargetFormat format;
|
2018-03-19 21:46:29 +00:00
|
|
|
u32 block_dimensions;
|
|
|
|
u32 array_mode;
|
|
|
|
u32 layer_stride;
|
|
|
|
u32 base_layer;
|
|
|
|
INSERT_PADDING_WORDS(7);
|
|
|
|
|
|
|
|
GPUVAddr Address() const {
|
|
|
|
return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) |
|
|
|
|
address_low);
|
|
|
|
}
|
|
|
|
} rt[NumRenderTargets];
|
|
|
|
|
2018-03-24 06:22:19 +00:00
|
|
|
INSERT_PADDING_WORDS(0x80);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
BitField<0, 16, u32> x;
|
|
|
|
BitField<16, 16, u32> width;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
BitField<0, 16, u32> y;
|
|
|
|
BitField<16, 16, u32> height;
|
|
|
|
};
|
|
|
|
float depth_range_near;
|
|
|
|
float depth_range_far;
|
|
|
|
} viewport[NumViewports];
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0x1D);
|
2018-03-21 04:28:06 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 first;
|
|
|
|
u32 count;
|
|
|
|
} vertex_buffer;
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0x99);
|
2018-03-19 21:49:41 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 address_high;
|
|
|
|
u32 address_low;
|
|
|
|
u32 format;
|
|
|
|
u32 block_dimensions;
|
|
|
|
u32 layer_stride;
|
|
|
|
|
|
|
|
GPUVAddr Address() const {
|
|
|
|
return static_cast<GPUVAddr>((static_cast<GPUVAddr>(address_high) << 32) |
|
|
|
|
address_low);
|
|
|
|
}
|
|
|
|
} zeta;
|
|
|
|
|
2018-03-21 04:33:56 +00:00
|
|
|
INSERT_PADDING_WORDS(0x5B);
|
|
|
|
|
|
|
|
union {
|
|
|
|
BitField<0, 5, u32> buffer;
|
|
|
|
BitField<6, 1, u32> constant;
|
|
|
|
BitField<7, 14, u32> offset;
|
2018-03-22 23:47:28 +00:00
|
|
|
BitField<21, 6, VertexSize> size;
|
|
|
|
BitField<27, 3, VertexType> type;
|
2018-03-21 04:33:56 +00:00
|
|
|
BitField<31, 1, u32> bgra;
|
2018-03-24 06:01:03 +00:00
|
|
|
|
|
|
|
u32 SizeInBytes() const {
|
|
|
|
switch (size) {
|
|
|
|
case VertexSize::Size_32_32_32_32:
|
|
|
|
return 16;
|
|
|
|
case VertexSize::Size_32_32_32:
|
|
|
|
return 12;
|
|
|
|
case VertexSize::Size_16_16_16_16:
|
|
|
|
return 8;
|
|
|
|
case VertexSize::Size_32_32:
|
|
|
|
return 8;
|
|
|
|
case VertexSize::Size_16_16_16:
|
|
|
|
return 6;
|
|
|
|
case VertexSize::Size_8_8_8_8:
|
|
|
|
return 4;
|
|
|
|
case VertexSize::Size_16_16:
|
|
|
|
return 4;
|
|
|
|
case VertexSize::Size_32:
|
|
|
|
return 4;
|
|
|
|
case VertexSize::Size_8_8_8:
|
|
|
|
return 3;
|
|
|
|
case VertexSize::Size_8_8:
|
|
|
|
return 2;
|
|
|
|
case VertexSize::Size_16:
|
|
|
|
return 2;
|
|
|
|
case VertexSize::Size_8:
|
|
|
|
return 1;
|
|
|
|
case VertexSize::Size_10_10_10_2:
|
|
|
|
return 4;
|
|
|
|
case VertexSize::Size_11_11_10:
|
|
|
|
return 4;
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
2018-03-21 04:33:56 +00:00
|
|
|
} vertex_attrib_format[NumVertexAttributes];
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0xF);
|
2018-03-19 21:46:29 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
BitField<0, 4, u32> count;
|
|
|
|
};
|
|
|
|
} rt_control;
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0xCF);
|
2018-03-19 05:36:25 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 tsc_address_high;
|
|
|
|
u32 tsc_address_low;
|
|
|
|
u32 tsc_limit;
|
|
|
|
|
|
|
|
GPUVAddr TSCAddress() const {
|
|
|
|
return static_cast<GPUVAddr>(
|
|
|
|
(static_cast<GPUVAddr>(tsc_address_high) << 32) | tsc_address_low);
|
|
|
|
}
|
|
|
|
} tsc;
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0x3);
|
2018-03-19 05:32:57 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 tic_address_high;
|
|
|
|
u32 tic_address_low;
|
|
|
|
u32 tic_limit;
|
|
|
|
|
|
|
|
GPUVAddr TICAddress() const {
|
|
|
|
return static_cast<GPUVAddr>(
|
|
|
|
(static_cast<GPUVAddr>(tic_address_high) << 32) | tic_address_low);
|
|
|
|
}
|
|
|
|
} tic;
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0x22);
|
|
|
|
|
2018-03-17 00:23:11 +00:00
|
|
|
struct {
|
|
|
|
u32 code_address_high;
|
|
|
|
u32 code_address_low;
|
|
|
|
|
|
|
|
GPUVAddr CodeAddress() const {
|
|
|
|
return static_cast<GPUVAddr>(
|
|
|
|
(static_cast<GPUVAddr>(code_address_high) << 32) | code_address_low);
|
|
|
|
}
|
|
|
|
} code_address;
|
|
|
|
INSERT_PADDING_WORDS(1);
|
2018-03-22 23:47:28 +00:00
|
|
|
|
2018-03-05 00:13:15 +00:00
|
|
|
struct {
|
|
|
|
u32 vertex_end_gl;
|
2018-03-21 04:28:06 +00:00
|
|
|
union {
|
|
|
|
u32 vertex_begin_gl;
|
2018-03-22 23:47:28 +00:00
|
|
|
BitField<0, 16, PrimitiveTopology> topology;
|
2018-03-21 04:28:06 +00:00
|
|
|
};
|
2018-03-05 00:13:15 +00:00
|
|
|
} draw;
|
2018-03-22 23:47:28 +00:00
|
|
|
|
2018-03-05 00:13:15 +00:00
|
|
|
INSERT_PADDING_WORDS(0x139);
|
2018-02-12 17:34:41 +00:00
|
|
|
struct {
|
|
|
|
u32 query_address_high;
|
|
|
|
u32 query_address_low;
|
|
|
|
u32 query_sequence;
|
|
|
|
union {
|
|
|
|
u32 raw;
|
|
|
|
BitField<0, 2, QueryMode> mode;
|
|
|
|
BitField<4, 1, u32> fence;
|
|
|
|
BitField<12, 4, u32> unit;
|
|
|
|
} query_get;
|
|
|
|
|
|
|
|
GPUVAddr QueryAddress() const {
|
|
|
|
return static_cast<GPUVAddr>(
|
|
|
|
(static_cast<GPUVAddr>(query_address_high) << 32) | query_address_low);
|
|
|
|
}
|
|
|
|
} query;
|
2018-03-17 00:23:11 +00:00
|
|
|
|
2018-03-17 03:47:45 +00:00
|
|
|
INSERT_PADDING_WORDS(0x3C);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
BitField<0, 12, u32> stride;
|
|
|
|
BitField<12, 1, u32> enable;
|
|
|
|
};
|
|
|
|
u32 start_high;
|
|
|
|
u32 start_low;
|
|
|
|
u32 divisor;
|
|
|
|
|
|
|
|
GPUVAddr StartAddress() const {
|
|
|
|
return static_cast<GPUVAddr>((static_cast<GPUVAddr>(start_high) << 32) |
|
|
|
|
start_low);
|
|
|
|
}
|
|
|
|
} vertex_array[NumVertexArrays];
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0x40);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 limit_high;
|
|
|
|
u32 limit_low;
|
|
|
|
|
|
|
|
GPUVAddr LimitAddress() const {
|
|
|
|
return static_cast<GPUVAddr>((static_cast<GPUVAddr>(limit_high) << 32) |
|
|
|
|
limit_low);
|
|
|
|
}
|
|
|
|
} vertex_array_limit[NumVertexArrays];
|
2018-03-17 00:23:11 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
BitField<0, 1, u32> enable;
|
|
|
|
BitField<4, 4, ShaderProgram> program;
|
|
|
|
};
|
|
|
|
u32 start_id;
|
|
|
|
INSERT_PADDING_WORDS(1);
|
|
|
|
u32 gpr_alloc;
|
2018-03-17 22:08:26 +00:00
|
|
|
ShaderStage type;
|
2018-03-17 00:23:11 +00:00
|
|
|
INSERT_PADDING_WORDS(9);
|
2018-03-17 03:06:24 +00:00
|
|
|
} shader_config[MaxShaderProgram];
|
2018-03-17 00:23:11 +00:00
|
|
|
|
2018-03-17 21:17:45 +00:00
|
|
|
INSERT_PADDING_WORDS(0x8C);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 cb_size;
|
|
|
|
u32 cb_address_high;
|
|
|
|
u32 cb_address_low;
|
|
|
|
u32 cb_pos;
|
|
|
|
u32 cb_data[NumCBData];
|
2018-03-17 22:06:23 +00:00
|
|
|
|
|
|
|
GPUVAddr BufferAddress() const {
|
|
|
|
return static_cast<GPUVAddr>(
|
|
|
|
(static_cast<GPUVAddr>(cb_address_high) << 32) | cb_address_low);
|
|
|
|
}
|
2018-03-17 21:17:45 +00:00
|
|
|
} const_buffer;
|
|
|
|
|
2018-03-17 21:29:20 +00:00
|
|
|
INSERT_PADDING_WORDS(0x10);
|
2018-03-17 21:17:45 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
union {
|
2018-03-17 22:06:23 +00:00
|
|
|
u32 raw_config;
|
2018-03-17 21:17:45 +00:00
|
|
|
BitField<0, 1, u32> valid;
|
|
|
|
BitField<4, 5, u32> index;
|
|
|
|
};
|
|
|
|
INSERT_PADDING_WORDS(7);
|
2018-03-17 22:08:26 +00:00
|
|
|
} cb_bind[MaxShaderStage];
|
2018-03-17 21:17:45 +00:00
|
|
|
|
2018-03-18 08:13:22 +00:00
|
|
|
INSERT_PADDING_WORDS(0x56);
|
|
|
|
|
|
|
|
u32 tex_cb_index;
|
|
|
|
|
2018-03-18 20:22:06 +00:00
|
|
|
INSERT_PADDING_WORDS(0x395);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
/// Compressed address of a buffer that holds information about bound SSBOs.
|
|
|
|
/// This address is usually bound to c0 in the shaders.
|
|
|
|
u32 buffer_address;
|
|
|
|
|
|
|
|
GPUVAddr BufferAddress() const {
|
|
|
|
return static_cast<GPUVAddr>(buffer_address) << 8;
|
|
|
|
}
|
|
|
|
} ssbo_info;
|
|
|
|
|
2018-03-19 00:03:20 +00:00
|
|
|
INSERT_PADDING_WORDS(0x11);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 address[MaxShaderStage];
|
|
|
|
u32 size[MaxShaderStage];
|
|
|
|
} tex_info_buffers;
|
|
|
|
|
|
|
|
INSERT_PADDING_WORDS(0x102);
|
2018-02-12 17:34:41 +00:00
|
|
|
};
|
|
|
|
std::array<u32, NUM_REGS> reg_array;
|
|
|
|
};
|
|
|
|
} regs{};
|
|
|
|
|
|
|
|
static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Maxwell3D Regs has wrong size");
|
|
|
|
|
2018-03-17 03:06:24 +00:00
|
|
|
struct State {
|
2018-03-17 22:06:23 +00:00
|
|
|
struct ConstBufferInfo {
|
|
|
|
GPUVAddr address;
|
|
|
|
u32 index;
|
|
|
|
u32 size;
|
|
|
|
bool enabled;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ShaderProgramInfo {
|
2018-03-17 22:08:26 +00:00
|
|
|
Regs::ShaderStage stage;
|
2018-03-17 03:06:24 +00:00
|
|
|
Regs::ShaderProgram program;
|
2018-03-17 18:55:42 +00:00
|
|
|
GPUVAddr address;
|
2018-03-17 03:06:24 +00:00
|
|
|
};
|
|
|
|
|
2018-03-17 22:06:23 +00:00
|
|
|
struct ShaderStageInfo {
|
|
|
|
std::array<ConstBufferInfo, Regs::MaxConstBuffers> const_buffers;
|
|
|
|
};
|
|
|
|
|
2018-03-17 22:08:26 +00:00
|
|
|
std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages;
|
2018-03-17 22:06:23 +00:00
|
|
|
std::array<ShaderProgramInfo, Regs::MaxShaderProgram> shader_programs;
|
2018-03-17 03:06:24 +00:00
|
|
|
};
|
|
|
|
|
2018-03-17 21:17:45 +00:00
|
|
|
State state{};
|
2018-03-17 03:06:24 +00:00
|
|
|
|
2018-03-23 23:56:27 +00:00
|
|
|
/// Write the value to the register identified by method.
|
|
|
|
void WriteReg(u32 method, u32 value, u32 remaining_params);
|
|
|
|
|
|
|
|
/// Uploads the code for a GPU macro program associated with the specified entry.
|
|
|
|
void SubmitMacroCode(u32 entry, std::vector<u32> code);
|
|
|
|
|
|
|
|
/// Returns a list of enabled textures for the specified shader stage.
|
2018-03-26 20:46:49 +00:00
|
|
|
std::vector<Texture::FullTextureInfo> GetStageTextures(Regs::ShaderStage stage) const;
|
2018-03-23 23:56:27 +00:00
|
|
|
|
2018-02-12 17:34:41 +00:00
|
|
|
private:
|
2018-03-17 01:32:44 +00:00
|
|
|
MemoryManager& memory_manager;
|
|
|
|
|
2018-03-18 09:17:10 +00:00
|
|
|
std::unordered_map<u32, std::vector<u32>> uploaded_macros;
|
|
|
|
|
2018-03-18 08:13:22 +00:00
|
|
|
/// Macro method that is currently being executed / being fed parameters.
|
|
|
|
u32 executing_macro = 0;
|
|
|
|
/// Parameters that have been submitted to the macro call so far.
|
|
|
|
std::vector<u32> macro_params;
|
|
|
|
|
2018-03-26 20:46:49 +00:00
|
|
|
/// Retrieves information about a specific TIC entry from the TIC buffer.
|
|
|
|
Texture::TICEntry GetTICEntry(u32 tic_index) const;
|
|
|
|
|
|
|
|
/// Retrieves information about a specific TSC entry from the TSC buffer.
|
|
|
|
Texture::TSCEntry GetTSCEntry(u32 tsc_index) const;
|
|
|
|
|
2018-03-18 08:13:22 +00:00
|
|
|
/**
|
2018-03-18 09:17:10 +00:00
|
|
|
* Call a macro on this engine.
|
2018-03-18 08:13:22 +00:00
|
|
|
* @param method Method to call
|
|
|
|
* @param parameters Arguments to the method call
|
|
|
|
*/
|
2018-03-18 09:17:10 +00:00
|
|
|
void CallMacroMethod(u32 method, const std::vector<u32>& parameters);
|
2018-03-18 08:13:22 +00:00
|
|
|
|
2018-02-12 17:34:41 +00:00
|
|
|
/// Handles a write to the QUERY_GET register.
|
|
|
|
void ProcessQueryGet();
|
|
|
|
|
2018-03-18 20:19:47 +00:00
|
|
|
/// Handles a write to the CB_DATA[i] register.
|
|
|
|
void ProcessCBData(u32 value);
|
|
|
|
|
2018-03-17 22:06:23 +00:00
|
|
|
/// Handles a write to the CB_BIND register.
|
2018-03-17 22:08:26 +00:00
|
|
|
void ProcessCBBind(Regs::ShaderStage stage);
|
2018-03-17 22:06:23 +00:00
|
|
|
|
2018-03-05 00:13:15 +00:00
|
|
|
/// Handles a write to the VERTEX_END_GL register, triggering a draw.
|
|
|
|
void DrawArrays();
|
|
|
|
|
2018-03-17 01:32:44 +00:00
|
|
|
/// Method call handlers
|
2018-03-19 00:03:20 +00:00
|
|
|
void BindTextureInfoBuffer(const std::vector<u32>& parameters);
|
2018-03-17 03:06:24 +00:00
|
|
|
void SetShader(const std::vector<u32>& parameters);
|
2018-03-18 20:22:06 +00:00
|
|
|
void BindStorageBuffer(const std::vector<u32>& parameters);
|
2018-03-17 01:32:44 +00:00
|
|
|
|
|
|
|
struct MethodInfo {
|
|
|
|
const char* name;
|
|
|
|
u32 arguments;
|
|
|
|
void (Maxwell3D::*handler)(const std::vector<u32>& parameters);
|
|
|
|
};
|
|
|
|
|
|
|
|
static const std::unordered_map<u32, MethodInfo> method_handlers;
|
2018-02-12 04:44:12 +00:00
|
|
|
};
|
2018-02-12 02:34:20 +00:00
|
|
|
|
2018-02-12 17:34:41 +00:00
|
|
|
#define ASSERT_REG_POSITION(field_name, position) \
|
|
|
|
static_assert(offsetof(Maxwell3D::Regs, field_name) == position * 4, \
|
|
|
|
"Field " #field_name " has invalid position")
|
|
|
|
|
2018-03-19 21:46:29 +00:00
|
|
|
ASSERT_REG_POSITION(rt, 0x200);
|
2018-03-24 06:22:19 +00:00
|
|
|
ASSERT_REG_POSITION(viewport, 0x300);
|
2018-03-21 04:28:06 +00:00
|
|
|
ASSERT_REG_POSITION(vertex_buffer, 0x35D);
|
2018-03-19 21:49:41 +00:00
|
|
|
ASSERT_REG_POSITION(zeta, 0x3F8);
|
2018-03-21 04:33:56 +00:00
|
|
|
ASSERT_REG_POSITION(vertex_attrib_format[0], 0x458);
|
2018-03-19 21:46:29 +00:00
|
|
|
ASSERT_REG_POSITION(rt_control, 0x487);
|
2018-03-19 05:36:25 +00:00
|
|
|
ASSERT_REG_POSITION(tsc, 0x557);
|
2018-03-19 05:32:57 +00:00
|
|
|
ASSERT_REG_POSITION(tic, 0x55D);
|
2018-03-17 00:23:11 +00:00
|
|
|
ASSERT_REG_POSITION(code_address, 0x582);
|
|
|
|
ASSERT_REG_POSITION(draw, 0x585);
|
2018-02-12 17:34:41 +00:00
|
|
|
ASSERT_REG_POSITION(query, 0x6C0);
|
2018-03-17 03:47:45 +00:00
|
|
|
ASSERT_REG_POSITION(vertex_array[0], 0x700);
|
|
|
|
ASSERT_REG_POSITION(vertex_array_limit[0], 0x7C0);
|
2018-03-17 00:23:11 +00:00
|
|
|
ASSERT_REG_POSITION(shader_config[0], 0x800);
|
2018-03-17 21:17:45 +00:00
|
|
|
ASSERT_REG_POSITION(const_buffer, 0x8E0);
|
2018-03-17 21:29:20 +00:00
|
|
|
ASSERT_REG_POSITION(cb_bind[0], 0x904);
|
2018-03-18 08:13:22 +00:00
|
|
|
ASSERT_REG_POSITION(tex_cb_index, 0x982);
|
2018-03-18 20:22:06 +00:00
|
|
|
ASSERT_REG_POSITION(ssbo_info, 0xD18);
|
2018-03-19 00:03:20 +00:00
|
|
|
ASSERT_REG_POSITION(tex_info_buffers.address[0], 0xD2A);
|
|
|
|
ASSERT_REG_POSITION(tex_info_buffers.size[0], 0xD2F);
|
2018-02-12 17:34:41 +00:00
|
|
|
|
|
|
|
#undef ASSERT_REG_POSITION
|
|
|
|
|
2018-02-12 02:34:20 +00:00
|
|
|
} // namespace Engines
|
|
|
|
} // namespace Tegra
|