1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

rsx: Properly fix DATA3F_M register alignment

This commit is contained in:
kd-11 2017-12-03 09:43:59 +03:00
parent 9853027f72
commit 970d2a06e0

View File

@ -51,6 +51,7 @@ namespace rsx
template<> struct vertex_data_type_from_element_type<f16> { static const vertex_base_type type = vertex_base_type::sf; };
template<> struct vertex_data_type_from_element_type<u8> { static const vertex_base_type type = vertex_base_type::ub; };
template<> struct vertex_data_type_from_element_type<u16> { static const vertex_base_type type = vertex_base_type::s32k; };
template<> struct vertex_data_type_from_element_type<s16> { static const vertex_base_type type = vertex_base_type::s1; };
namespace nv406e
{
@ -149,10 +150,16 @@ namespace rsx
sema.semaphore[index].timestamp = rsx->timestamp();
}
template<u32 id, u32 index, int count, typename type>
/**
* id = base method register
* index = register index in method
* count = element count per attribute
* register_count = number of registers consumed per attribute. E.g 3-element methods have padding
*/
template<u32 id, u32 index, int count, int register_count, typename type>
void set_vertex_data_impl(thread* rsx, u32 arg)
{
static const size_t increment_per_array_index = (count * sizeof(type)) / sizeof(u32);
static const size_t increment_per_array_index = (register_count * sizeof(type)) / sizeof(u32);
static const size_t attribute_index = index / increment_per_array_index;
static const size_t vertex_subreg = index % increment_per_array_index;
@ -176,7 +183,7 @@ namespace rsx
{
static void impl(thread* rsx, u32 _reg, u32 arg)
{
set_vertex_data_impl<NV4097_SET_VERTEX_DATA4UB_M, index, 4, u8>(rsx, arg);
set_vertex_data_impl<NV4097_SET_VERTEX_DATA4UB_M, index, 4, 4, u8>(rsx, arg);
}
};
@ -185,7 +192,7 @@ namespace rsx
{
static void impl(thread* rsx, u32 _reg, u32 arg)
{
set_vertex_data_impl<NV4097_SET_VERTEX_DATA1F_M, index, 1, f32>(rsx, arg);
set_vertex_data_impl<NV4097_SET_VERTEX_DATA1F_M, index, 1, 1, f32>(rsx, arg);
}
};
@ -194,7 +201,7 @@ namespace rsx
{
static void impl(thread* rsx, u32 _reg, u32 arg)
{
set_vertex_data_impl<NV4097_SET_VERTEX_DATA2F_M, index, 2, f32>(rsx, arg);
set_vertex_data_impl<NV4097_SET_VERTEX_DATA2F_M, index, 2, 2, f32>(rsx, arg);
}
};
@ -203,8 +210,8 @@ namespace rsx
{
static void impl(thread* rsx, u32 _reg, u32 arg)
{
//NOTE: attributes are 16-byte aligned (Rachet & Clank 2)
set_vertex_data_impl<NV4097_SET_VERTEX_DATA3F_M, index, 4, f32>(rsx, arg);
//Register alignment is only 1, 2, or 4 (Rachet & Clank 2)
set_vertex_data_impl<NV4097_SET_VERTEX_DATA3F_M, index, 3, 4, f32>(rsx, arg);
}
};
@ -213,7 +220,7 @@ namespace rsx
{
static void impl(thread* rsx, u32 _reg, u32 arg)
{
set_vertex_data_impl<NV4097_SET_VERTEX_DATA4F_M, index, 4, f32>(rsx, arg);
set_vertex_data_impl<NV4097_SET_VERTEX_DATA4F_M, index, 4, 4, f32>(rsx, arg);
}
};
@ -222,7 +229,7 @@ namespace rsx
{
static void impl(thread* rsx, u32 _reg, u32 arg)
{
set_vertex_data_impl<NV4097_SET_VERTEX_DATA2S_M, index, 2, u16>(rsx, arg);
set_vertex_data_impl<NV4097_SET_VERTEX_DATA2S_M, index, 2, 2, u16>(rsx, arg);
}
};
@ -231,7 +238,7 @@ namespace rsx
{
static void impl(thread* rsx, u32 _reg, u32 arg)
{
set_vertex_data_impl<NV4097_SET_VERTEX_DATA4S_M, index, 4, u16>(rsx, arg);
set_vertex_data_impl<NV4097_SET_VERTEX_DATA4S_M, index, 4, 4, u16>(rsx, arg);
}
};
@ -240,8 +247,7 @@ namespace rsx
{
static void impl(thread* rsx, u32 _reg, u32 arg)
{
LOG_ERROR(RSX, "SCALED_4S vertex data format is not properly implemented");
set_vertex_data_impl<NV4097_SET_VERTEX_DATA4S_M, index, 4, u16>(rsx, arg);
set_vertex_data_impl<NV4097_SET_VERTEX_DATA_SCALED4S_M, index, 4, 4, s16>(rsx, arg);
}
};