mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
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:
parent
74d8619240
commit
47e5074dc5
5 changed files with 19 additions and 26 deletions
|
@ -648,7 +648,7 @@ u32 get_index_type_size(rsx::index_array_type type)
|
||||||
fmt::throw_exception("Wrong index type" HERE);
|
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);
|
unsigned short *typedDst = (unsigned short *)(dst);
|
||||||
switch (draw_mode)
|
switch (draw_mode)
|
||||||
|
|
|
@ -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.
|
* 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.
|
* Stream a 128 bits vector to dst.
|
||||||
|
|
|
@ -235,15 +235,13 @@ namespace
|
||||||
|
|
||||||
void* mapped_buffer =
|
void* mapped_buffer =
|
||||||
m_buffer_data.map<void>(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size));
|
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 vertex_count = 0;
|
||||||
size_t element_count =
|
for (const auto& pair : vertex_ranges)
|
||||||
get_index_count(rsx::method_registers.current_draw_clause.primitive, pair.second);
|
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, (u32)first, (u32)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);
|
||||||
mapped_buffer = (char*)mapped_buffer + element_count * sizeof(u16);
|
|
||||||
first += pair.second;
|
|
||||||
}
|
|
||||||
m_buffer_data.unmap(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size));
|
m_buffer_data.unmap(CD3DX12_RANGE(heap_offset, heap_offset + buffer_size));
|
||||||
D3D12_INDEX_BUFFER_VIEW index_buffer_view = {
|
D3D12_INDEX_BUFFER_VIEW index_buffer_view = {
|
||||||
m_buffer_data.get_heap()->GetGPUVirtualAddress() + heap_offset, (UINT)buffer_size,
|
m_buffer_data.get_heap()->GetGPUVirtualAddress() + heap_offset, (UINT)buffer_size,
|
||||||
|
|
|
@ -146,27 +146,22 @@ namespace
|
||||||
// return vertex count if primitive type is not native (empty array otherwise)
|
// 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)
|
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);
|
verify(HERE), !gl::is_primitive_native(primitive_mode);
|
||||||
|
|
||||||
for (const auto &pair : first_count_commands)
|
for (const auto &pair : first_count_commands)
|
||||||
{
|
element_count += (u32)get_index_count(primitive_mode, pair.second);
|
||||||
vertex_draw_count += (u32)get_index_count(primitive_mode, pair.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 first = 0;
|
auto mapping = dst.alloc_from_heap(element_count * sizeof(u16), 256);
|
||||||
auto mapping = dst.alloc_from_heap(vertex_draw_count * sizeof(u16), 256);
|
|
||||||
char *mapped_buffer = (char *)mapping.first;
|
char *mapped_buffer = (char *)mapping.first;
|
||||||
|
|
||||||
for (const auto &pair : first_count_commands)
|
//This is an emulated buffer, so our indices only range from 0->original_vertex_array_length
|
||||||
{
|
u32 vertex_count = 0;
|
||||||
size_t element_count = get_index_count(primitive_mode, pair.second);
|
for (auto &first_count : first_count_commands)
|
||||||
write_index_array_for_non_indexed_non_native_primitive_to_buffer(mapped_buffer, primitive_mode, first, pair.second);
|
vertex_count += first_count.second;
|
||||||
mapped_buffer = (char*)mapped_buffer + element_count * sizeof(u16);
|
|
||||||
first += pair.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)
|
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)
|
||||||
|
|
|
@ -240,7 +240,7 @@ namespace
|
||||||
void* buf = m_index_buffer_ring_info.map(offset_in_index_buffer, upload_size);
|
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(
|
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();
|
m_index_buffer_ring_info.unmap();
|
||||||
return std::make_tuple(
|
return std::make_tuple(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue