mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-10-12 02:09:17 +00:00
RSX: Use 32-bit generated indices
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include "util/v128.hpp"
|
||||
#include "util/simd.hpp"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
#if defined(ARCH_X64)
|
||||
#include "BufferUtils_avx512.h"
|
||||
#endif
|
||||
@@ -514,25 +516,6 @@ namespace
|
||||
return primitive_restart_impl::upload_untouched(src, dst, static_cast<U>(primitive_restart_index));
|
||||
}
|
||||
|
||||
void iota16(u16* dst, u32 count)
|
||||
{
|
||||
unsigned i = 0;
|
||||
#if defined(ARCH_X64) || defined(ARCH_ARM64)
|
||||
const unsigned step = 8; // We do 8 entries per step
|
||||
const __m128i vec_step = _mm_set1_epi16(8); // Constant to increment the raw values
|
||||
__m128i values = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0);
|
||||
__m128i* vec_ptr = utils::bless<__m128i>(dst);
|
||||
|
||||
for (; (i + step) <= count; i += step, vec_ptr++)
|
||||
{
|
||||
_mm_stream_si128(vec_ptr, values);
|
||||
values = _mm_add_epi16(values, vec_step);
|
||||
}
|
||||
#endif
|
||||
for (; i < count; ++i)
|
||||
dst[i] = i;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::tuple<T, T, u32> expand_indexed_triangle_fan(std::span<to_be_t<const T>> src, std::span<T> dst, bool is_primitive_restart_enabled, u32 primitive_restart_index)
|
||||
{
|
||||
@@ -697,11 +680,11 @@ u32 get_index_type_size(rsx::index_array_type type)
|
||||
|
||||
void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, rsx::primitive_type draw_mode, unsigned count)
|
||||
{
|
||||
auto typedDst = reinterpret_cast<u16*>(dst);
|
||||
auto typedDst = reinterpret_cast<u32*>(dst);
|
||||
switch (draw_mode)
|
||||
{
|
||||
case rsx::primitive_type::line_loop:
|
||||
iota16(typedDst, count);
|
||||
std::iota(typedDst, typedDst + count, 0u);
|
||||
typedDst[count] = 0;
|
||||
return;
|
||||
case rsx::primitive_type::triangle_fan:
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace
|
||||
const auto element_count = get_index_count(primitive_mode, vertex_count);
|
||||
ensure(!gl::is_primitive_native(primitive_mode));
|
||||
|
||||
auto mapping = dst.alloc_from_heap(element_count * sizeof(u16), 256);
|
||||
auto mapping = dst.alloc_from_heap(element_count * sizeof(u32), 256);
|
||||
auto mapped_buffer = static_cast<char*>(mapping.first);
|
||||
|
||||
write_index_array_for_non_indexed_non_native_primitive_to_buffer(mapped_buffer, primitive_mode, vertex_count);
|
||||
@@ -77,7 +77,7 @@ namespace
|
||||
rsx::method_registers.current_draw_clause.primitive, m_index_ring_buffer,
|
||||
rsx::method_registers.current_draw_clause.get_elements_count());
|
||||
|
||||
return{ false, min_index, max_index, index_count, 0, std::make_tuple(static_cast<GLenum>(GL_UNSIGNED_SHORT), offset_in_index_buffer) };
|
||||
return{ false, min_index, max_index, index_count, 0, std::make_tuple(static_cast<GLenum>(GL_UNSIGNED_INT), offset_in_index_buffer) };
|
||||
}
|
||||
|
||||
return{ false, min_index, max_index, vertex_count, 0, std::optional<std::tuple<GLenum, u32>>() };
|
||||
@@ -138,7 +138,7 @@ namespace
|
||||
std::tie(index_count, offset_in_index_buffer) = get_index_array_for_emulated_non_indexed_draw(
|
||||
rsx::method_registers.current_draw_clause.primitive, m_index_ring_buffer, vertex_count);
|
||||
|
||||
return{ false, 0, vertex_count, index_count, 0, std::make_tuple(static_cast<GLenum>(GL_UNSIGNED_SHORT), offset_in_index_buffer) };
|
||||
return{ false, 0, vertex_count, index_count, 0, std::make_tuple(static_cast<GLenum>(GL_UNSIGNED_INT), offset_in_index_buffer) };
|
||||
}
|
||||
|
||||
return{ false, 0, vertex_count, vertex_count, 0, std::optional<std::tuple<GLenum, u32>>() };
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace rsx
|
||||
case index_emulate:
|
||||
ensure(writing);
|
||||
address = m_current_job->dst;
|
||||
range = get_index_count(static_cast<rsx::primitive_type>(m_current_job->aux_param0), m_current_job->length) * sizeof(u16);
|
||||
range = get_index_count(static_cast<rsx::primitive_type>(m_current_job->aux_param0), m_current_job->length) * sizeof(u32);
|
||||
break;
|
||||
default:
|
||||
fmt::throw_exception("Unreachable");
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace
|
||||
vk::data_heap& m_index_buffer_ring_info)
|
||||
{
|
||||
u32 index_count = get_index_count(clause.primitive, vertex_count);
|
||||
u32 upload_size = index_count * sizeof(u16);
|
||||
u32 upload_size = index_count * sizeof(u32);
|
||||
|
||||
VkDeviceSize offset_in_index_buffer = m_index_buffer_ring_info.alloc<256>(upload_size);
|
||||
void* buf = m_index_buffer_ring_info.map(offset_in_index_buffer, upload_size);
|
||||
@@ -71,7 +71,7 @@ namespace
|
||||
|
||||
m_index_buffer_ring_info.unmap();
|
||||
return std::make_tuple(
|
||||
index_count, std::make_tuple(offset_in_index_buffer, VK_INDEX_TYPE_UINT16));
|
||||
index_count, std::make_tuple(offset_in_index_buffer, VK_INDEX_TYPE_UINT32));
|
||||
}
|
||||
|
||||
struct vertex_input_state
|
||||
|
||||
Reference in New Issue
Block a user