rsx: Emulated index buffers are based on vertex 0 with no disjoint ranges

- Drop the 'first' argument as it is unused for now
This commit is contained in:
kd-11 2017-06-27 00:34:22 +03:00
parent 74d8619240
commit 47e5074dc5
5 changed files with 19 additions and 26 deletions

View File

@ -648,7 +648,7 @@ u32 get_index_type_size(rsx::index_array_type type)
fmt::throw_exception("Wrong index type" HERE);
}
void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, rsx::primitive_type draw_mode, unsigned first, unsigned count)
void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, rsx::primitive_type draw_mode, unsigned count)
{
unsigned short *typedDst = (unsigned short *)(dst);
switch (draw_mode)

View File

@ -39,7 +39,7 @@ std::tuple<u32, u32> write_index_array_data_to_buffer(gsl::span<gsl::byte> dst,
/**
* Write index data needed to emulate non indexed non native primitive mode.
*/
void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, rsx::primitive_type draw_mode, unsigned first, unsigned count);
void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, rsx::primitive_type draw_mode, unsigned count);
/**
* Stream a 128 bits vector to dst.

View File

@ -235,15 +235,13 @@ namespace
void* mapped_buffer =
m_buffer_data.map<void>(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size));
size_t first = 0;
for (const auto& pair : vertex_ranges) {
size_t element_count =
get_index_count(rsx::method_registers.current_draw_clause.primitive, pair.second);
write_index_array_for_non_indexed_non_native_primitive_to_buffer((char*)mapped_buffer,
rsx::method_registers.current_draw_clause.primitive, (u32)first, (u32)pair.second);
mapped_buffer = (char*)mapped_buffer + element_count * sizeof(u16);
first += pair.second;
}
size_t vertex_count = 0;
for (const auto& pair : vertex_ranges)
vertex_count += pair.second;
write_index_array_for_non_indexed_non_native_primitive_to_buffer((char *)mapped_buffer, rsx::method_registers.current_draw_clause.primitive, vertex_count);
m_buffer_data.unmap(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size));
D3D12_INDEX_BUFFER_VIEW index_buffer_view = {
m_buffer_data.get_heap()->GetGPUVirtualAddress() + heap_offset, (UINT)buffer_size,

View File

@ -146,27 +146,22 @@ namespace
// return vertex count if primitive type is not native (empty array otherwise)
std::tuple<u32, u32> get_index_array_for_emulated_non_indexed_draw(const std::vector<std::pair<u32, u32>> &first_count_commands, rsx::primitive_type primitive_mode, gl::ring_buffer &dst)
{
u32 vertex_draw_count = 0;
u32 element_count = 0;
verify(HERE), !gl::is_primitive_native(primitive_mode);
for (const auto &pair : first_count_commands)
{
vertex_draw_count += (u32)get_index_count(primitive_mode, pair.second);
}
element_count += (u32)get_index_count(primitive_mode, pair.second);
u32 first = 0;
auto mapping = dst.alloc_from_heap(vertex_draw_count * sizeof(u16), 256);
auto mapping = dst.alloc_from_heap(element_count * sizeof(u16), 256);
char *mapped_buffer = (char *)mapping.first;
for (const auto &pair : first_count_commands)
{
size_t element_count = get_index_count(primitive_mode, pair.second);
write_index_array_for_non_indexed_non_native_primitive_to_buffer(mapped_buffer, primitive_mode, first, pair.second);
mapped_buffer = (char*)mapped_buffer + element_count * sizeof(u16);
first += pair.second;
}
//This is an emulated buffer, so our indices only range from 0->original_vertex_array_length
u32 vertex_count = 0;
for (auto &first_count : first_count_commands)
vertex_count += first_count.second;
return std::make_tuple(vertex_draw_count, mapping.second);
write_index_array_for_non_indexed_non_native_primitive_to_buffer(mapped_buffer, primitive_mode, vertex_count);
return std::make_tuple(element_count, mapping.second);
}
std::tuple<u32, u32, u32> upload_index_buffer(gsl::span<const gsl::byte> raw_index_buffer, void *ptr, rsx::index_array_type type, rsx::primitive_type draw_mode, const std::vector<std::pair<u32, u32>> first_count_commands, u32 initial_vertex_count)

View File

@ -240,7 +240,7 @@ namespace
void* buf = m_index_buffer_ring_info.map(offset_in_index_buffer, upload_size);
write_index_array_for_non_indexed_non_native_primitive_to_buffer(
reinterpret_cast<char*>(buf), clause.primitive, 0, vertex_count);
reinterpret_cast<char*>(buf), clause.primitive, vertex_count);
m_index_buffer_ring_info.unmap();
return std::make_tuple(