Skip to content

Commit

Permalink
rsx: Enable primitive restart index only when needed (#6889)
Browse files Browse the repository at this point in the history
* rsx: Enable primitive restart index only when needed

* rsx: Use if with initializer in read_put()
  • Loading branch information
elad335 authored and Nekotekina committed Oct 28, 2019
1 parent 83cf6e6 commit 42fc698
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 35 deletions.
9 changes: 3 additions & 6 deletions rpcs3/Emu/RSX/RSXFIFO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ namespace rsx
}
else
{
u32 put = m_ctrl->put;
if (LIKELY((put & 3) == 0))
if (u32 put = m_ctrl->put; LIKELY((put & 3) == 0))
{
return put;
}
else
{
return m_ctrl->put.and_fetch(~3);
}

return m_ctrl->put.and_fetch(~3);
}
}

Expand Down
10 changes: 0 additions & 10 deletions rpcs3/Emu/RSX/gcm_enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

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)
{
switch (in)
Expand Down
6 changes: 2 additions & 4 deletions rpcs3/Emu/RSX/gcm_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ namespace rsx

enum class index_array_type : u8
{
u32,
u16,
u32 = 0, // CELL_GCM_DRAW_INDEX_ARRAY_TYPE_32
u16 = 1, // CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16
};

index_array_type to_index_array_type(u8 in);

enum class primitive_type : u8
{
invalid,
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/RSX/rsx_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -3357,7 +3357,7 @@ struct registers_decoder<NV4097_SET_INDEX_ARRAY_DMA>
private:
u32 value;

u32 type_raw() const { return bf_decoder<4, 28>(value); }
u8 type_raw() const { return bf_decoder<4, 8>(value); }

public:
decoded_type(u32 value) : value(value) {}
Expand All @@ -3369,8 +3369,8 @@ struct registers_decoder<NV4097_SET_INDEX_ARRAY_DMA>

index_array_type type() const
{
// Why truncate??
return to_index_array_type(static_cast<u8>(type_raw()));
// Must be a valid value
return static_cast<index_array_type>(type_raw());
}
};

Expand Down
35 changes: 23 additions & 12 deletions rpcs3/Emu/RSX/rsx_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,37 @@ namespace rsx
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
{
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
{
return decode<NV4097_SET_ZSTENCIL_CLEAR_VALUE>().clear_z(is_depth_stencil);
Expand All @@ -695,16 +716,6 @@ namespace rsx
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
{
if (index == 0)
Expand Down

0 comments on commit 42fc698

Please sign in to comment.