rsx: Enable primitive restart index only when needed (#6889)

* rsx: Enable primitive restart index only when needed

* rsx: Use if with initializer in read_put()
This commit is contained in:
Eladash 2019-10-28 22:16:27 +02:00 committed by Ivan
commit 42fc698186
5 changed files with 31 additions and 35 deletions

View file

@ -39,17 +39,14 @@ namespace rsx
} }
else else
{ {
u32 put = m_ctrl->put; if (u32 put = m_ctrl->put; LIKELY((put & 3) == 0))
if (LIKELY((put & 3) == 0))
{ {
return put; return put;
} }
else
{
return m_ctrl->put.and_fetch(~3); return m_ctrl->put.and_fetch(~3);
} }
} }
}
void FIFO_control::set_put(u32 put) void FIFO_control::set_put(u32 put)
{ {

View file

@ -17,16 +17,6 @@ rsx::vertex_base_type rsx::to_vertex_base_type(u8 in)
fmt::throw_exception("Unknown vertex base type %d" HERE, in); fmt::throw_exception("Unknown vertex base type %d" HERE, in);
} }
rsx::index_array_type rsx::to_index_array_type(u8 in)
{
switch (in)
{
case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_32: return rsx::index_array_type::u32;
case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16: return rsx::index_array_type::u16;
}
fmt::throw_exception("Unknown index array type %d" HERE, in);
}
rsx::primitive_type rsx::to_primitive_type(u8 in) rsx::primitive_type rsx::to_primitive_type(u8 in)
{ {
switch (in) switch (in)

View file

@ -18,12 +18,10 @@ namespace rsx
enum class index_array_type : u8 enum class index_array_type : u8
{ {
u32, u32 = 0, // CELL_GCM_DRAW_INDEX_ARRAY_TYPE_32
u16, u16 = 1, // CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16
}; };
index_array_type to_index_array_type(u8 in);
enum class primitive_type : u8 enum class primitive_type : u8
{ {
invalid, invalid,

View file

@ -3357,7 +3357,7 @@ struct registers_decoder<NV4097_SET_INDEX_ARRAY_DMA>
private: private:
u32 value; u32 value;
u32 type_raw() const { return bf_decoder<4, 28>(value); } u8 type_raw() const { return bf_decoder<4, 8>(value); }
public: public:
decoded_type(u32 value) : value(value) {} decoded_type(u32 value) : value(value) {}
@ -3369,8 +3369,8 @@ struct registers_decoder<NV4097_SET_INDEX_ARRAY_DMA>
index_array_type type() const index_array_type type() const
{ {
// Why truncate?? // Must be a valid value
return to_index_array_type(static_cast<u8>(type_raw())); return static_cast<index_array_type>(type_raw());
} }
}; };

View file

@ -665,9 +665,14 @@ namespace rsx
return decode<NV4097_SET_STENCIL_TEST_ENABLE>().stencil_test_enabled(); return decode<NV4097_SET_STENCIL_TEST_ENABLE>().stencil_test_enabled();
} }
bool restart_index_enabled() const u8 index_array_location() const
{ {
return decode<NV4097_SET_RESTART_INDEX_ENABLE>().restart_index_enabled(); return decode<NV4097_SET_INDEX_ARRAY_DMA>().index_dma();
}
rsx::index_array_type index_type() const
{
return decode<NV4097_SET_INDEX_ARRAY_DMA>().type();
} }
u32 restart_index() const u32 restart_index() const
@ -675,6 +680,22 @@ namespace rsx
return decode<NV4097_SET_RESTART_INDEX>().restart_index(); return decode<NV4097_SET_RESTART_INDEX>().restart_index();
} }
bool restart_index_enabled_raw() const
{
return decode<NV4097_SET_RESTART_INDEX_ENABLE>().restart_index_enabled();
}
bool restart_index_enabled() const
{
if (!restart_index_enabled_raw())
{
return false;
}
return restart_index() <= (index_type() == rsx::index_array_type::u16 ? 0xffff : 0xfffff);
}
u32 z_clear_value(bool is_depth_stencil) const u32 z_clear_value(bool is_depth_stencil) const
{ {
return decode<NV4097_SET_ZSTENCIL_CLEAR_VALUE>().clear_z(is_depth_stencil); return decode<NV4097_SET_ZSTENCIL_CLEAR_VALUE>().clear_z(is_depth_stencil);
@ -695,16 +716,6 @@ namespace rsx
return decode<NV4097_SET_FOG_PARAMS + 1>().fog_param_1(); return decode<NV4097_SET_FOG_PARAMS + 1>().fog_param_1();
} }
u8 index_array_location() const
{
return decode<NV4097_SET_INDEX_ARRAY_DMA>().index_dma();
}
rsx::index_array_type index_type() const
{
return decode<NV4097_SET_INDEX_ARRAY_DMA>().type();
}
bool color_mask_b(int index) const bool color_mask_b(int index) const
{ {
if (index == 0) if (index == 0)