rsx/common/d3d12/gl/vulkan: Set dst stride in write_vertex_array_data_to_buffer.

This commit is contained in:
Vincent Lejeune 2016-04-05 19:12:08 +02:00
parent 2ae5a7ff39
commit 3a3d264cb5
5 changed files with 14 additions and 16 deletions

View File

@ -46,19 +46,17 @@ namespace
}
}
void write_vertex_array_data_to_buffer(gsl::span<gsl::byte> raw_dst_span, const gsl::byte *src_ptr, u32 first, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride)
void write_vertex_array_data_to_buffer(gsl::span<gsl::byte> raw_dst_span, const gsl::byte *src_ptr, u32 first, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride, u8 dst_stride)
{
Expects(vector_element_count > 0);
u32 element_size = rsx::get_vertex_type_size_on_host(type, vector_element_count);
switch (type)
{
case rsx::vertex_base_type::ub:
case rsx::vertex_base_type::ub256:
{
gsl::span<u8> dst_span = as_span_workaround<u8>(raw_dst_span);
copy_whole_attribute_array<u8>(dst_span, src_ptr, vector_element_count, element_size, attribute_src_stride, first, count);
copy_whole_attribute_array<u8>(dst_span, src_ptr, vector_element_count, dst_stride, attribute_src_stride, first, count);
return;
}
case rsx::vertex_base_type::s1:
@ -66,13 +64,13 @@ void write_vertex_array_data_to_buffer(gsl::span<gsl::byte> raw_dst_span, const
case rsx::vertex_base_type::s32k:
{
gsl::span<u16> dst_span = as_span_workaround<u16>(raw_dst_span);
copy_whole_attribute_array<be_t<u16>>(dst_span, src_ptr, vector_element_count, element_size, attribute_src_stride, first, count);
copy_whole_attribute_array<be_t<u16>>(dst_span, src_ptr, vector_element_count, dst_stride, attribute_src_stride, first, count);
return;
}
case rsx::vertex_base_type::f:
{
gsl::span<u32> dst_span = as_span_workaround<u32>(raw_dst_span);
copy_whole_attribute_array<be_t<u32>>(dst_span, src_ptr, vector_element_count, element_size, attribute_src_stride, first, count);
copy_whole_attribute_array<be_t<u32>>(dst_span, src_ptr, vector_element_count, dst_stride, attribute_src_stride, first, count);
return;
}
case rsx::vertex_base_type::cmp:
@ -82,10 +80,10 @@ void write_vertex_array_data_to_buffer(gsl::span<gsl::byte> raw_dst_span, const
{
auto* c_src = (const be_t<u32>*)(src_ptr + attribute_src_stride * (first + i));
const auto& decoded_vector = decode_cmp_vector(*c_src);
dst_span[i * element_size / sizeof(u16)] = decoded_vector[0];
dst_span[i * element_size / sizeof(u16) + 1] = decoded_vector[1];
dst_span[i * element_size / sizeof(u16) + 2] = decoded_vector[2];
dst_span[i * element_size / sizeof(u16) + 3] = decoded_vector[3];
dst_span[i * dst_stride / sizeof(u16)] = decoded_vector[0];
dst_span[i * dst_stride / sizeof(u16) + 1] = decoded_vector[1];
dst_span[i * dst_stride / sizeof(u16) + 2] = decoded_vector[2];
dst_span[i * dst_stride / sizeof(u16) + 3] = decoded_vector[3];
}
return;
}

View File

@ -7,7 +7,7 @@
* Write count vertex attributes from src_ptr starting at first.
* src_ptr array layout is deduced from the type, vector element count and src_stride arguments.
*/
void write_vertex_array_data_to_buffer(gsl::span<gsl::byte> raw_dst_span, const gsl::byte *src_ptr, u32 first, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride);
void write_vertex_array_data_to_buffer(gsl::span<gsl::byte> raw_dst_span, const gsl::byte *src_ptr, u32 first, u32 count, rsx::vertex_base_type type, u32 vector_element_count, u32 attribute_src_stride, u8 dst_stride);
/*
* If primitive mode is not supported and need to be emulated (using an index buffer) returns false.

View File

@ -104,7 +104,7 @@ std::vector<D3D12_SHADER_RESOURCE_VIEW_DESC> D3D12GSRender::upload_vertex_attrib
for (const auto &range : vertex_ranges)
{
gsl::span<gsl::byte> mapped_buffer_span = { (gsl::byte*)mapped_buffer, gsl::narrow_cast<int>(buffer_size) };
write_vertex_array_data_to_buffer(mapped_buffer_span, src_ptr, range.first, range.second, info.type, info.size, info.stride);
write_vertex_array_data_to_buffer(mapped_buffer_span, src_ptr, range.first, range.second, info.type, info.size, info.stride, element_size);
mapped_buffer = (char*)mapped_buffer + range.second * element_size;
}
m_buffer_data.unmap(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size));

View File

@ -319,7 +319,7 @@ void GLGSRender::set_vertex_buffer()
for (const auto &first_count : first_count_commands)
{
write_vertex_array_data_to_buffer(dest_span.subspan(offset), src_ptr, first_count.first, first_count.second, vertex_info.type, vertex_info.size, vertex_info.stride);
write_vertex_array_data_to_buffer(dest_span.subspan(offset), src_ptr, first_count.first, first_count.second, vertex_info.type, vertex_info.size, vertex_info.stride, rsx::get_vertex_type_size_on_host(vertex_info.type, vertex_info.stride));
offset += first_count.second * element_size;
}
}
@ -329,7 +329,7 @@ void GLGSRender::set_vertex_buffer()
gsl::span<gsl::byte> dest_span(vertex_array);
prepare_buffer_for_writing(vertex_array.data(), vertex_info.type, vertex_info.size, vertex_draw_count);
write_vertex_array_data_to_buffer(dest_span, src_ptr, 0, max_index + 1, vertex_info.type, vertex_info.size, vertex_info.stride);
write_vertex_array_data_to_buffer(dest_span, src_ptr, 0, max_index + 1, vertex_info.type, vertex_info.size, vertex_info.stride, rsx::get_vertex_type_size_on_host(vertex_info.type, vertex_info.stride));
}
size_t size = vertex_array.size();

View File

@ -398,7 +398,7 @@ VKGSRender::upload_vertex_data()
for (const auto &first_count : first_count_commands)
{
write_vertex_array_data_to_buffer(dest_span.subspan(offset), src_ptr, first_count.first, first_count.second, vertex_info.type, vertex_info.size, vertex_info.stride);
write_vertex_array_data_to_buffer(dest_span.subspan(offset), src_ptr, first_count.first, first_count.second, vertex_info.type, vertex_info.size, vertex_info.stride, element_size);
offset += first_count.second * element_size;
}
}
@ -409,7 +409,7 @@ VKGSRender::upload_vertex_data()
gsl::span<gsl::byte> dest_span(vertex_array);
vk::prepare_buffer_for_writing(vertex_array.data(), vertex_info.type, vertex_info.size, vertex_draw_count);
write_vertex_array_data_to_buffer(dest_span, src_ptr, 0, max_index + 1, vertex_info.type, vertex_info.size, vertex_info.stride);
write_vertex_array_data_to_buffer(dest_span, src_ptr, 0, max_index + 1, vertex_info.type, vertex_info.size, vertex_info.stride, element_size);
}
std::vector<u8> converted_buffer;