Merge pull request #2008 from vlj/rsx-refactor

Rsx: Inline some rsx_state member and split some headers.
This commit is contained in:
vlj 2016-07-31 17:16:04 +02:00 committed by GitHub
commit 190fc4301e
10 changed files with 1492 additions and 1457 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
#pragma once
#include "Emu/Memory/vm.h"
#include "gcm_enums.h"
enum
{
@ -23,387 +24,6 @@ enum
CELL_GCM_DISPLAY_FREQUENCY_DISABLE = 3,
};
namespace rsx
{
enum class vertex_base_type : u8
{
s1, ///< signed byte
f, ///< float
sf, ///< half float
ub, ///< unsigned byte interpreted as 0.f and 1.f
s32k, ///< signed 32bits int
cmp, ///< compressed aka X11G11Z10 and always 1. W.
ub256, ///< unsigned byte interpreted as between 0 and 255.
};
vertex_base_type to_vertex_base_type(u8 in);
enum class index_array_type : u8
{
u32,
u16,
};
index_array_type to_index_array_type(u8 in);
enum class primitive_type : u8
{
invalid,
points,
lines,
line_loop, // line strip with last end being joined with first end.
line_strip,
triangles,
triangle_strip,
triangle_fan, // like strip except that every triangle share the first vertex and one instead of 2 from previous triangle.
quads,
quad_strip,
polygon, // convex polygon
};
primitive_type to_primitive_type(u8 in);
enum class surface_target : u8
{
none,
surface_a,
surface_b,
surfaces_a_b,
surfaces_a_b_c,
surfaces_a_b_c_d,
};
surface_target to_surface_target(u8 in);
enum class surface_depth_format : u8
{
z16, // unsigned 16 bits depth
z24s8, // unsigned 24 bits depth + 8 bits stencil
};
surface_depth_format to_surface_depth_format(u8 in);
enum class surface_antialiasing : u8
{
center_1_sample,
diagonal_centered_2_samples,
square_centered_4_samples,
square_rotated_4_samples,
};
surface_antialiasing to_surface_antialiasing(u8 in);
enum class surface_color_format : u8
{
x1r5g5b5_z1r5g5b5,
x1r5g5b5_o1r5g5b5,
r5g6b5,
x8r8g8b8_z8r8g8b8,
x8r8g8b8_o8r8g8b8,
a8r8g8b8,
b8,
g8b8,
w16z16y16x16,
w32z32y32x32,
x32,
x8b8g8r8_z8b8g8r8,
x8b8g8r8_o8b8g8r8,
a8b8g8r8,
};
surface_color_format to_surface_color_format(u8 in);
enum class window_origin : u8
{
top,
bottom
};
window_origin to_window_origin(u8 in);
enum class window_pixel_center : u8
{
half,
integer
};
window_pixel_center to_window_pixel_center(u8 in);
enum class comparison_function : u8
{
never,
less,
equal,
less_or_equal,
greater,
not_equal,
greater_or_equal,
always
};
comparison_function to_comparison_function(u16 in);
enum class fog_mode : u8
{
linear,
exponential,
exponential2,
exponential_abs,
exponential2_abs,
linear_abs
};
fog_mode to_fog_mode(u32 in);
enum class texture_dimension : u8
{
dimension1d,
dimension2d,
dimension3d,
};
texture_dimension to_texture_dimension(u8 in);
enum class texture_wrap_mode : u8
{
wrap,
mirror,
clamp_to_edge,
border,
clamp,
mirror_once_clamp_to_edge,
mirror_once_border,
mirror_once_clamp,
};
texture_wrap_mode to_texture_wrap_mode(u8 in);
enum class texture_max_anisotropy : u8
{
x1,
x2,
x4,
x6,
x8,
x10,
x12,
x16,
};
texture_max_anisotropy to_texture_max_anisotropy(u8 in);
enum class texture_minify_filter : u8
{
nearest, ///< no filtering, mipmap base level
linear, ///< linear filtering, mipmap base level
nearest_nearest, ///< no filtering, closest mipmap level
linear_nearest, ///< linear filtering, closest mipmap level
nearest_linear, ///< no filtering, linear mix between closest mipmap levels
linear_linear, ///< linear filtering, linear mix between closest mipmap levels
convolution_min, ///< Unknown mode but looks close to linear_linear
};
texture_minify_filter to_texture_minify_filter(u8 in);
enum class texture_magnify_filter : u8
{
nearest, ///< no filtering
linear, ///< linear filtering
convolution_mag, ///< Unknown mode but looks close to linear
};
texture_magnify_filter to_texture_magnify_filter(u8 in);
enum class stencil_op : u8
{
keep,
zero,
replace,
incr,
decr,
invert,
incr_wrap,
decr_wrap,
};
stencil_op to_stencil_op(u16 in);
enum class blend_equation : u8
{
add,
min,
max,
substract,
reverse_substract,
reverse_substract_signed,
add_signed,
reverse_add_signed,
};
blend_equation to_blend_equation(u16 in);
enum class blend_factor : u8
{
zero,
one,
src_color,
one_minus_src_color,
dst_color,
one_minus_dst_color,
src_alpha,
one_minus_src_alpha,
dst_alpha,
one_minus_dst_alpha,
src_alpha_saturate,
constant_color,
one_minus_constant_color,
constant_alpha,
one_minus_constant_alpha,
};
blend_factor to_blend_factor(u16 in);
enum class logic_op : u8
{
logic_clear,
logic_and,
logic_and_reverse,
logic_copy,
logic_and_inverted,
logic_noop,
logic_xor,
logic_or,
logic_nor,
logic_equiv,
logic_invert,
logic_or_reverse,
logic_copy_inverted,
logic_or_inverted,
logic_nand,
logic_set,
};
logic_op to_logic_op(u16 in);
enum class front_face : u8
{
cw, /// clockwise
ccw /// counter clockwise
};
front_face to_front_face(u16 in);
enum class cull_face : u8
{
front,
back,
front_and_back,
};
cull_face to_cull_face(u16 in);
enum class user_clip_plane_op : u8
{
disable,
less_than,
greather_or_equal,
};
user_clip_plane_op to_user_clip_plane_op(u8 in);
enum class shading_mode : u8
{
smooth,
flat,
};
shading_mode to_shading_mode(u32 in);
enum class polygon_mode : u8
{
point,
line,
fill,
};
polygon_mode to_polygon_mode(u32 in);
namespace blit_engine
{
enum class transfer_origin : u8
{
center,
corner,
};
transfer_origin to_transfer_origin(u8 in);
enum class transfer_interpolator : u8
{
zoh,
foh,
};
transfer_interpolator to_transfer_interpolator(u8 in);
enum class transfer_operation : u8
{
srccopy_and,
rop_and,
blend_and,
srccopy,
srccopy_premult,
blend_premult,
};
transfer_operation to_transfer_operation(u8 in);
enum class transfer_source_format : u8
{
a1r5g5b5,
x1r5g5b5,
a8r8g8b8,
x8r8g8b8,
cr8yb8cb8ya8,
yb8cr8ya8cb8,
r5g6b5,
y8,
ay8,
eyb8ecr8eya8ecb8,
ecr8eyb8ecb8eya8,
a8b8g8r8,
x8b8g8r8,
};
transfer_source_format to_transfer_source_format(u8 in);
enum class transfer_destination_format : u8
{
r5g6b5,
a8r8g8b8,
y32,
};
transfer_destination_format to_transfer_destination_format(u8 in);
enum class context_surface : u8
{
surface2d,
swizzle2d,
};
context_surface to_context_surface(u32 in);
enum class context_dma : u8
{
to_memory_get_report,
report_location_main,
};
context_dma to_context_dma(u32 in);
}
}
enum
{
CELL_GCM_DISPLAY_FLIP_STATUS_ = 0,

View File

@ -6,11 +6,6 @@
namespace rsx
{
texture::texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r)
{
}
void texture::init()
{
// Offset
@ -248,11 +243,6 @@ namespace rsx
return registers[NV4097_SET_TEXTURE_CONTROL3 + m_index] & 0xfffff;
}
vertex_texture::vertex_texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r)
{
}
void vertex_texture::init()
{
// Offset

View File

@ -21,7 +21,7 @@ namespace rsx
std::array<u32, 0x10000 / 4> &registers;
public:
texture(u8 idx, std::array<u32, 0x10000 / 4> &r);
texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r) { }
texture() = delete;
//initialize texture registers with default values
@ -97,7 +97,7 @@ namespace rsx
std::array<u32, 0x10000 / 4> &registers;
public:
vertex_texture(u8 idx, std::array<u32, 0x10000 / 4> &r);
vertex_texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r) { }
vertex_texture() = delete;
//initialize texture registers with default values

1063
rpcs3/Emu/RSX/gcm_enums.cpp Normal file

File diff suppressed because it is too large Load Diff

383
rpcs3/Emu/RSX/gcm_enums.h Normal file
View File

@ -0,0 +1,383 @@
#pragma once
#include "Utilities/types.h"
namespace rsx
{
enum class vertex_base_type : u8
{
s1, ///< signed byte
f, ///< float
sf, ///< half float
ub, ///< unsigned byte interpreted as 0.f and 1.f
s32k, ///< signed 32bits int
cmp, ///< compressed aka X11G11Z10 and always 1. W.
ub256, ///< unsigned byte interpreted as between 0 and 255.
};
vertex_base_type to_vertex_base_type(u8 in);
enum class index_array_type : u8
{
u32,
u16,
};
index_array_type to_index_array_type(u8 in);
enum class primitive_type : u8
{
invalid,
points,
lines,
line_loop, // line strip with last end being joined with first end.
line_strip,
triangles,
triangle_strip,
triangle_fan, // like strip except that every triangle share the first vertex and one instead of 2 from previous triangle.
quads,
quad_strip,
polygon, // convex polygon
};
primitive_type to_primitive_type(u8 in);
enum class surface_target : u8
{
none,
surface_a,
surface_b,
surfaces_a_b,
surfaces_a_b_c,
surfaces_a_b_c_d,
};
surface_target to_surface_target(u8 in);
enum class surface_depth_format : u8
{
z16, // unsigned 16 bits depth
z24s8, // unsigned 24 bits depth + 8 bits stencil
};
surface_depth_format to_surface_depth_format(u8 in);
enum class surface_antialiasing : u8
{
center_1_sample,
diagonal_centered_2_samples,
square_centered_4_samples,
square_rotated_4_samples,
};
surface_antialiasing to_surface_antialiasing(u8 in);
enum class surface_color_format : u8
{
x1r5g5b5_z1r5g5b5,
x1r5g5b5_o1r5g5b5,
r5g6b5,
x8r8g8b8_z8r8g8b8,
x8r8g8b8_o8r8g8b8,
a8r8g8b8,
b8,
g8b8,
w16z16y16x16,
w32z32y32x32,
x32,
x8b8g8r8_z8b8g8r8,
x8b8g8r8_o8b8g8r8,
a8b8g8r8,
};
surface_color_format to_surface_color_format(u8 in);
enum class window_origin : u8
{
top,
bottom
};
window_origin to_window_origin(u8 in);
enum class window_pixel_center : u8
{
half,
integer
};
window_pixel_center to_window_pixel_center(u8 in);
enum class comparison_function : u8
{
never,
less,
equal,
less_or_equal,
greater,
not_equal,
greater_or_equal,
always
};
comparison_function to_comparison_function(u16 in);
enum class fog_mode : u8
{
linear,
exponential,
exponential2,
exponential_abs,
exponential2_abs,
linear_abs
};
fog_mode to_fog_mode(u32 in);
enum class texture_dimension : u8
{
dimension1d,
dimension2d,
dimension3d,
};
texture_dimension to_texture_dimension(u8 in);
enum class texture_wrap_mode : u8
{
wrap,
mirror,
clamp_to_edge,
border,
clamp,
mirror_once_clamp_to_edge,
mirror_once_border,
mirror_once_clamp,
};
texture_wrap_mode to_texture_wrap_mode(u8 in);
enum class texture_max_anisotropy : u8
{
x1,
x2,
x4,
x6,
x8,
x10,
x12,
x16,
};
texture_max_anisotropy to_texture_max_anisotropy(u8 in);
enum class texture_minify_filter : u8
{
nearest, ///< no filtering, mipmap base level
linear, ///< linear filtering, mipmap base level
nearest_nearest, ///< no filtering, closest mipmap level
linear_nearest, ///< linear filtering, closest mipmap level
nearest_linear, ///< no filtering, linear mix between closest mipmap levels
linear_linear, ///< linear filtering, linear mix between closest mipmap levels
convolution_min, ///< Unknown mode but looks close to linear_linear
};
texture_minify_filter to_texture_minify_filter(u8 in);
enum class texture_magnify_filter : u8
{
nearest, ///< no filtering
linear, ///< linear filtering
convolution_mag, ///< Unknown mode but looks close to linear
};
texture_magnify_filter to_texture_magnify_filter(u8 in);
enum class stencil_op : u8
{
keep,
zero,
replace,
incr,
decr,
invert,
incr_wrap,
decr_wrap,
};
stencil_op to_stencil_op(u16 in);
enum class blend_equation : u8
{
add,
min,
max,
substract,
reverse_substract,
reverse_substract_signed,
add_signed,
reverse_add_signed,
};
blend_equation to_blend_equation(u16 in);
enum class blend_factor : u8
{
zero,
one,
src_color,
one_minus_src_color,
dst_color,
one_minus_dst_color,
src_alpha,
one_minus_src_alpha,
dst_alpha,
one_minus_dst_alpha,
src_alpha_saturate,
constant_color,
one_minus_constant_color,
constant_alpha,
one_minus_constant_alpha,
};
blend_factor to_blend_factor(u16 in);
enum class logic_op : u8
{
logic_clear,
logic_and,
logic_and_reverse,
logic_copy,
logic_and_inverted,
logic_noop,
logic_xor,
logic_or,
logic_nor,
logic_equiv,
logic_invert,
logic_or_reverse,
logic_copy_inverted,
logic_or_inverted,
logic_nand,
logic_set,
};
logic_op to_logic_op(u16 in);
enum class front_face : u8
{
cw, /// clockwise
ccw /// counter clockwise
};
front_face to_front_face(u16 in);
enum class cull_face : u8
{
front,
back,
front_and_back,
};
cull_face to_cull_face(u16 in);
enum class user_clip_plane_op : u8
{
disable,
less_than,
greather_or_equal,
};
user_clip_plane_op to_user_clip_plane_op(u8 in);
enum class shading_mode : u8
{
smooth,
flat,
};
shading_mode to_shading_mode(u32 in);
enum class polygon_mode : u8
{
point,
line,
fill,
};
polygon_mode to_polygon_mode(u32 in);
namespace blit_engine
{
enum class transfer_origin : u8
{
center,
corner,
};
transfer_origin to_transfer_origin(u8 in);
enum class transfer_interpolator : u8
{
zoh,
foh,
};
transfer_interpolator to_transfer_interpolator(u8 in);
enum class transfer_operation : u8
{
srccopy_and,
rop_and,
blend_and,
srccopy,
srccopy_premult,
blend_premult,
};
transfer_operation to_transfer_operation(u8 in);
enum class transfer_source_format : u8
{
a1r5g5b5,
x1r5g5b5,
a8r8g8b8,
x8r8g8b8,
cr8yb8cb8ya8,
yb8cr8ya8cb8,
r5g6b5,
y8,
ay8,
eyb8ecr8eya8ecb8,
ecr8eyb8ecb8eya8,
a8b8g8r8,
x8b8g8r8,
};
transfer_source_format to_transfer_source_format(u8 in);
enum class transfer_destination_format : u8
{
r5g6b5,
a8r8g8b8,
y32,
};
transfer_destination_format to_transfer_destination_format(u8 in);
enum class context_surface : u8
{
surface2d,
swizzle2d,
};
context_surface to_context_surface(u32 in);
enum class context_dma : u8
{
to_memory_get_report,
report_location_main,
};
context_dma to_context_dma(u32 in);
}
}

View File

@ -780,41 +780,6 @@ namespace rsx
}
}
template<typename T, size_t... N, typename Args>
std::array<T, sizeof...(N)> fill_array(Args&& arg, std::index_sequence<N...> seq)
{
return{ T(N, std::forward<Args>(arg))... };
}
rsx_state & rsx_state::operator=(const rsx_state & in)
{
registers = in.registers;
transform_program = in.transform_program;
transform_constants = in.transform_constants;
register_vertex_info = in.register_vertex_info;
for (int i = 0; i < 16; i++)
{
vertex_arrays_info[i].size = in.vertex_arrays_info[i].size;
vertex_arrays_info[i].stride = in.vertex_arrays_info[i].stride;
vertex_arrays_info[i].frequency = in.vertex_arrays_info[i].frequency;
vertex_arrays_info[i].type = in.vertex_arrays_info[i].type;
}
return *this;
}
rsx_state::rsx_state() :
fragment_textures(fill_array<texture>(registers, std::make_index_sequence<16>())),
vertex_textures(fill_array<vertex_texture>(registers, std::make_index_sequence<4>())),
vertex_arrays_info(fill_array<data_array_format_info>(registers, std::make_index_sequence<16>()))
{
}
rsx_state::~rsx_state()
{
}
void rsx_state::reset()
{
//setup method registers

View File

@ -75,9 +75,18 @@ namespace rsx
}
};
namespace
{
template<typename T, size_t... N, typename Args>
std::array<T, sizeof...(N)> fill_array(Args&& arg, std::index_sequence<N...> seq)
{
return{ T(N, std::forward<Args>(arg))... };
}
}
struct rsx_state
{
private:
protected:
std::array<u32, 0x10000 / 4> registers;
template<u32 opcode>
@ -91,7 +100,21 @@ namespace rsx
}
public:
rsx_state &operator=(const rsx_state& in);
rsx_state &operator=(const rsx_state& in)
{
registers = in.registers;
transform_program = in.transform_program;
transform_constants = in.transform_constants;
register_vertex_info = in.register_vertex_info;
for (int i = 0; i < 16; i++)
{
vertex_arrays_info[i].size = in.vertex_arrays_info[i].size;
vertex_arrays_info[i].stride = in.vertex_arrays_info[i].stride;
vertex_arrays_info[i].frequency = in.vertex_arrays_info[i].frequency;
vertex_arrays_info[i].type = in.vertex_arrays_info[i].type;
}
return *this;
}
std::array<texture, 16> fragment_textures;
std::array<vertex_texture, 4> vertex_textures;
@ -119,8 +142,13 @@ namespace rsx
std::array<register_vertex_data_info, 16> register_vertex_info;
std::array<data_array_format_info, 16> vertex_arrays_info;
rsx_state();
~rsx_state();
rsx_state() :
fragment_textures(fill_array<texture>(registers, std::make_index_sequence<16>())),
vertex_textures(fill_array<vertex_texture>(registers, std::make_index_sequence<4>())),
vertex_arrays_info(fill_array<data_array_format_info>(registers, std::make_index_sequence<16>()))
{ }
~rsx_state() { }
void decode(u32 reg, u32 value);
@ -600,7 +628,7 @@ namespace rsx
return decode<NV4097_SET_ALPHA_REF>().alpha_ref();
}
surface_target surface_color_target()
surface_target surface_color_target() const
{
return decode<NV4097_SET_SURFACE_COLOR_TARGET>().target();
}

View File

@ -259,6 +259,9 @@
<ClCompile Include="Emu\RSX\Common\TextureUtils.cpp" />
<ClCompile Include="Emu\RSX\Common\VertexProgramDecompiler.cpp" />
<ClCompile Include="Emu\RSX\GCM.cpp" />
<ClCompile Include="Emu\RSX\gcm_enums.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Emu\RSX\Null\NullGSRender.cpp" />
<ClCompile Include="Emu\RSX\rsx_cache.cpp" />
<ClCompile Include="Emu\RSX\rsx_methods.cpp" />
@ -599,6 +602,7 @@
<ClInclude Include="Emu\CPU\CPUThread.h" />
<ClInclude Include="Emu\DbgCommand.h" />
<ClInclude Include="Emu\Memory\wait_engine.h" />
<ClInclude Include="Emu\RSX\gcm_enums.h" />
<ClInclude Include="Emu\RSX\rsx_cache.h" />
<ClInclude Include="Emu\RSX\rsx_decode.h" />
<ClInclude Include="Emu\RSX\rsx_trace.h" />

View File

@ -881,6 +881,9 @@
<ClCompile Include="Emu\Cell\PPUAnalyser.cpp">
<Filter>Emu\Cell</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\gcm_enums.cpp">
<Filter>Emu\GPU\RSX</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Crypto\aes.h">
@ -1696,5 +1699,8 @@
<ClInclude Include="..\Utilities\SleepQueue.h">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\gcm_enums.h">
<Filter>Emu\GPU\RSX</Filter>
</ClInclude>
</ItemGroup>
</Project>