summaryrefslogtreecommitdiff
path: root/src/video_core/regs.h
diff options
context:
space:
mode:
authorGravatar James Rowe2018-01-11 20:07:44 -0700
committerGravatar James Rowe2018-01-12 19:11:03 -0700
commit1d28b2e142f845773e2b90e267d9632e196a99b9 (patch)
tree027a3586a0fc927731afb3711c328c6dafc8551f /src/video_core/regs.h
parentMassive removal of unused modules (diff)
downloadyuzu-1d28b2e142f845773e2b90e267d9632e196a99b9.tar.gz
yuzu-1d28b2e142f845773e2b90e267d9632e196a99b9.tar.xz
yuzu-1d28b2e142f845773e2b90e267d9632e196a99b9.zip
Remove references to PICA and rasterizers in video_core
Diffstat (limited to 'src/video_core/regs.h')
-rw-r--r--src/video_core/regs.h149
1 files changed, 0 insertions, 149 deletions
diff --git a/src/video_core/regs.h b/src/video_core/regs.h
deleted file mode 100644
index 6d5f98cac..000000000
--- a/src/video_core/regs.h
+++ /dev/null
@@ -1,149 +0,0 @@
1// Copyright 2017 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <array>
8#include <cstddef>
9#include <string>
10#ifndef _MSC_VER
11#include <type_traits> // for std::enable_if
12#endif
13
14#include "common/common_funcs.h"
15#include "common/common_types.h"
16#include "video_core/regs_framebuffer.h"
17#include "video_core/regs_lighting.h"
18#include "video_core/regs_pipeline.h"
19#include "video_core/regs_rasterizer.h"
20#include "video_core/regs_shader.h"
21#include "video_core/regs_texturing.h"
22
23namespace Pica {
24
25// Returns index corresponding to the Regs member labeled by field_name
26// TODO: Due to Visual studio bug 209229, offsetof does not return constant expressions
27// when used with array elements (e.g. PICA_REG_INDEX(vs_uniform_setup.set_value[1])).
28// For details cf.
29// https://connect.microsoft.com/VisualStudio/feedback/details/209229/offsetof-does-not-produce-a-constant-expression-for-array-members
30// Hopefully, this will be fixed sometime in the future.
31// For lack of better alternatives, we currently hardcode the offsets when constant
32// expressions are needed via PICA_REG_INDEX_WORKAROUND (on sane compilers, static_asserts
33// will then make sure the offsets indeed match the automatically calculated ones).
34#define PICA_REG_INDEX(field_name) (offsetof(Pica::Regs, field_name) / sizeof(u32))
35#if defined(_MSC_VER)
36#define PICA_REG_INDEX_WORKAROUND(field_name, backup_workaround_index) (backup_workaround_index)
37#else
38// NOTE: Yeah, hacking in a static_assert here just to workaround the lacking MSVC compiler
39// really is this annoying. This macro just forwards its first argument to PICA_REG_INDEX
40// and then performs a (no-op) cast to size_t iff the second argument matches the expected
41// field offset. Otherwise, the compiler will fail to compile this code.
42#define PICA_REG_INDEX_WORKAROUND(field_name, backup_workaround_index) \
43 ((typename std::enable_if<backup_workaround_index == PICA_REG_INDEX(field_name), \
44 size_t>::type)PICA_REG_INDEX(field_name))
45#endif // _MSC_VER
46
47struct Regs {
48 static constexpr size_t NUM_REGS = 0x300;
49
50 union {
51 struct {
52 INSERT_PADDING_WORDS(0x10);
53 u32 trigger_irq;
54 INSERT_PADDING_WORDS(0x2f);
55 RasterizerRegs rasterizer;
56 TexturingRegs texturing;
57 FramebufferRegs framebuffer;
58 LightingRegs lighting;
59 PipelineRegs pipeline;
60 ShaderRegs gs;
61 ShaderRegs vs;
62 INSERT_PADDING_WORDS(0x20);
63 };
64 std::array<u32, NUM_REGS> reg_array;
65 };
66
67 /// Map register indices to names readable by humans
68 static const char* GetRegisterName(u16 index);
69};
70
71static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Regs struct has wrong size");
72
73// TODO: MSVC does not support using offsetof() on non-static data members even though this
74// is technically allowed since C++11. This macro should be enabled once MSVC adds
75// support for that.
76#ifndef _MSC_VER
77#define ASSERT_REG_POSITION(field_name, position) \
78 static_assert(offsetof(Regs, field_name) == position * 4, \
79 "Field " #field_name " has invalid position")
80
81ASSERT_REG_POSITION(trigger_irq, 0x10);
82
83ASSERT_REG_POSITION(rasterizer, 0x40);
84ASSERT_REG_POSITION(rasterizer.cull_mode, 0x40);
85ASSERT_REG_POSITION(rasterizer.viewport_size_x, 0x41);
86ASSERT_REG_POSITION(rasterizer.viewport_size_y, 0x43);
87ASSERT_REG_POSITION(rasterizer.viewport_depth_range, 0x4d);
88ASSERT_REG_POSITION(rasterizer.viewport_depth_near_plane, 0x4e);
89ASSERT_REG_POSITION(rasterizer.vs_output_attributes[0], 0x50);
90ASSERT_REG_POSITION(rasterizer.vs_output_attributes[1], 0x51);
91ASSERT_REG_POSITION(rasterizer.scissor_test, 0x65);
92ASSERT_REG_POSITION(rasterizer.viewport_corner, 0x68);
93ASSERT_REG_POSITION(rasterizer.depthmap_enable, 0x6D);
94
95ASSERT_REG_POSITION(texturing, 0x80);
96ASSERT_REG_POSITION(texturing.main_config, 0x80);
97ASSERT_REG_POSITION(texturing.texture0, 0x81);
98ASSERT_REG_POSITION(texturing.texture0_format, 0x8e);
99ASSERT_REG_POSITION(texturing.fragment_lighting_enable, 0x8f);
100ASSERT_REG_POSITION(texturing.texture1, 0x91);
101ASSERT_REG_POSITION(texturing.texture1_format, 0x96);
102ASSERT_REG_POSITION(texturing.texture2, 0x99);
103ASSERT_REG_POSITION(texturing.texture2_format, 0x9e);
104ASSERT_REG_POSITION(texturing.proctex, 0xa8);
105ASSERT_REG_POSITION(texturing.proctex_noise_u, 0xa9);
106ASSERT_REG_POSITION(texturing.proctex_noise_v, 0xaa);
107ASSERT_REG_POSITION(texturing.proctex_noise_frequency, 0xab);
108ASSERT_REG_POSITION(texturing.proctex_lut, 0xac);
109ASSERT_REG_POSITION(texturing.proctex_lut_offset, 0xad);
110ASSERT_REG_POSITION(texturing.proctex_lut_config, 0xaf);
111ASSERT_REG_POSITION(texturing.tev_stage0, 0xc0);
112ASSERT_REG_POSITION(texturing.tev_stage1, 0xc8);
113ASSERT_REG_POSITION(texturing.tev_stage2, 0xd0);
114ASSERT_REG_POSITION(texturing.tev_stage3, 0xd8);
115ASSERT_REG_POSITION(texturing.tev_combiner_buffer_input, 0xe0);
116ASSERT_REG_POSITION(texturing.fog_mode, 0xe0);
117ASSERT_REG_POSITION(texturing.fog_color, 0xe1);
118ASSERT_REG_POSITION(texturing.fog_lut_offset, 0xe6);
119ASSERT_REG_POSITION(texturing.fog_lut_data, 0xe8);
120ASSERT_REG_POSITION(texturing.tev_stage4, 0xf0);
121ASSERT_REG_POSITION(texturing.tev_stage5, 0xf8);
122ASSERT_REG_POSITION(texturing.tev_combiner_buffer_color, 0xfd);
123
124ASSERT_REG_POSITION(framebuffer, 0x100);
125ASSERT_REG_POSITION(framebuffer.output_merger, 0x100);
126ASSERT_REG_POSITION(framebuffer.framebuffer, 0x110);
127
128ASSERT_REG_POSITION(lighting, 0x140);
129
130ASSERT_REG_POSITION(pipeline, 0x200);
131ASSERT_REG_POSITION(pipeline.vertex_attributes, 0x200);
132ASSERT_REG_POSITION(pipeline.index_array, 0x227);
133ASSERT_REG_POSITION(pipeline.num_vertices, 0x228);
134ASSERT_REG_POSITION(pipeline.vertex_offset, 0x22a);
135ASSERT_REG_POSITION(pipeline.trigger_draw, 0x22e);
136ASSERT_REG_POSITION(pipeline.trigger_draw_indexed, 0x22f);
137ASSERT_REG_POSITION(pipeline.vs_default_attributes_setup, 0x232);
138ASSERT_REG_POSITION(pipeline.command_buffer, 0x238);
139ASSERT_REG_POSITION(pipeline.gpu_mode, 0x245);
140ASSERT_REG_POSITION(pipeline.triangle_topology, 0x25e);
141ASSERT_REG_POSITION(pipeline.restart_primitive, 0x25f);
142
143ASSERT_REG_POSITION(gs, 0x280);
144ASSERT_REG_POSITION(vs, 0x2b0);
145
146#undef ASSERT_REG_POSITION
147#endif // !defined(_MSC_VER)
148
149} // namespace Pica