mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
rsx: Support more base types for immediate rendering
fix alignment
This commit is contained in:
parent
ba968048c9
commit
70d3a6d840
@ -332,10 +332,10 @@ namespace rsx
|
||||
in_begin_end = true;
|
||||
}
|
||||
|
||||
void thread::append_to_push_buffer(u32 attribute, u32 size, u32 subreg_index, u32 value)
|
||||
void thread::append_to_push_buffer(u32 attribute, u32 size, u32 subreg_index, vertex_base_type type, u32 value)
|
||||
{
|
||||
vertex_push_buffers[attribute].size = size;
|
||||
vertex_push_buffers[attribute].append_vertex_data(subreg_index, value);
|
||||
vertex_push_buffers[attribute].append_vertex_data(subreg_index, type, value);
|
||||
}
|
||||
|
||||
u32 thread::get_push_buffer_vertex_count()
|
||||
|
@ -277,7 +277,7 @@ namespace rsx
|
||||
* Immediate mode rendering requires a temp push buffer to hold attrib values
|
||||
* Appends a value to the push buffer (currently only supports 32-wide types)
|
||||
*/
|
||||
void append_to_push_buffer(u32 attribute, u32 size, u32 subreg_index, u32 value);
|
||||
void append_to_push_buffer(u32 attribute, u32 size, u32 subreg_index, vertex_base_type type, u32 value);
|
||||
u32 get_push_buffer_vertex_count();
|
||||
|
||||
private:
|
||||
|
@ -116,12 +116,14 @@ namespace rsx
|
||||
static const size_t attribute_index = index / increment_per_array_index;
|
||||
static const size_t vertex_subreg = index % increment_per_array_index;
|
||||
|
||||
const auto vtype = vertex_data_type_from_element_type<type>::type;
|
||||
|
||||
if (rsx->in_begin_end)
|
||||
rsx->append_to_push_buffer(attribute_index, count, vertex_subreg, arg);
|
||||
rsx->append_to_push_buffer(attribute_index, count, vertex_subreg, vtype, arg);
|
||||
|
||||
auto& info = rsx::method_registers.register_vertex_info[attribute_index];
|
||||
|
||||
info.type = vertex_data_type_from_element_type<type>::type;
|
||||
info.type = vtype;
|
||||
info.size = count;
|
||||
info.frequency = 0;
|
||||
info.stride = 0;
|
||||
@ -191,6 +193,16 @@ namespace rsx
|
||||
}
|
||||
};
|
||||
|
||||
template<u32 index>
|
||||
struct set_vertex_data_scaled4s_m
|
||||
{
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
void draw_arrays(thread* rsx, u32 _reg, u32 arg)
|
||||
{
|
||||
rsx::method_registers.current_draw_clause.command = rsx::draw_command::array;
|
||||
@ -1278,6 +1290,7 @@ namespace rsx
|
||||
bind<NV4097_DRAW_ARRAYS, nv4097::draw_arrays>();
|
||||
bind<NV4097_DRAW_INDEX_ARRAY, nv4097::draw_index_array>();
|
||||
bind<NV4097_INLINE_ARRAY, nv4097::draw_inline_array>();
|
||||
bind_range<NV4097_SET_VERTEX_DATA_SCALED4S_M, 1, 32, nv4097::set_vertex_data_scaled4s_m>();
|
||||
bind_range<NV4097_SET_VERTEX_DATA4UB_M, 1, 16, nv4097::set_vertex_data4ub_m>();
|
||||
bind_range<NV4097_SET_VERTEX_DATA1F_M, 1, 16, nv4097::set_vertex_data1f_m>();
|
||||
bind_range<NV4097_SET_VERTEX_DATA2F_M, 1, 32, nv4097::set_vertex_data2f_m>();
|
||||
|
@ -74,20 +74,58 @@ struct push_buffer_vertex_info
|
||||
vertex_count = 0;
|
||||
}
|
||||
|
||||
void append_vertex_data(u32 sub_index, u32 arg)
|
||||
u8 get_vertex_size_in_dwords(vertex_base_type type)
|
||||
{
|
||||
//NOTE: Types are always provided to fit into 32-bits
|
||||
//i.e no less than 4 8-bit values and no less than 2 16-bit values
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case vertex_base_type::f:
|
||||
return size;
|
||||
case vertex_base_type::ub:
|
||||
case vertex_base_type::ub256:
|
||||
return 1;
|
||||
case vertex_base_type::s32k:
|
||||
return size / 2;
|
||||
default:
|
||||
fmt::throw_exception("Unsupported vertex base type %d", (u8)type);
|
||||
}
|
||||
}
|
||||
|
||||
void append_vertex_data(u32 sub_index, vertex_base_type type, u32 arg)
|
||||
{
|
||||
const u32 element_mask = (1 << sub_index);
|
||||
const u8 vertex_size = get_vertex_size_in_dwords(type);
|
||||
|
||||
if (attribute_mask & element_mask)
|
||||
{
|
||||
attribute_mask = 0;
|
||||
|
||||
vertex_count++;
|
||||
data.resize(vertex_count * size);
|
||||
data.resize(vertex_count * vertex_size);
|
||||
}
|
||||
|
||||
attribute_mask |= element_mask;
|
||||
u32* dst = data.data() + ((vertex_count - 1) * size) + sub_index;
|
||||
*dst = se_storage<u32>::swap(arg);
|
||||
|
||||
void* dst = data.data() + ((vertex_count - 1) * vertex_size) + sub_index;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case vertex_base_type::f:
|
||||
*(u32*)dst = se_storage<u32>::swap(arg);
|
||||
break;
|
||||
case vertex_base_type::ub:
|
||||
case vertex_base_type::ub256:
|
||||
*(u32*)dst = arg;
|
||||
break;
|
||||
case vertex_base_type::s32k:
|
||||
((u16*)dst)[0] = se_storage<u16>::swap((u16)(arg & 0xffff));
|
||||
((u16*)dst)[1] = se_storage<u16>::swap((u16)(arg >> 16));
|
||||
break;
|
||||
default:
|
||||
fmt::throw_exception("Unsupported vertex base type %d", (u8)type);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user