Rsx: fix unknown cull faces

This commit is contained in:
eladash 2018-08-26 15:18:55 +03:00 committed by kd-11
parent 38a72cc6ee
commit acf1286b49
5 changed files with 30 additions and 39 deletions

View file

@ -232,7 +232,7 @@ namespace rsx
case cull_face::front: return "front";
case cull_face::front_and_back: return "front and back";
}
fmt::throw_exception("Unexpected enum found" HERE);
return "Unknown cull face value";
}
std::string to_string(surface_target target)
@ -827,17 +827,6 @@ rsx::front_face rsx::to_front_face(u16 in)
fmt::throw_exception("Unknown front face 0x%x" HERE, in);
}
rsx::cull_face rsx::to_cull_face(u16 in)
{
switch (in)
{
case CELL_GCM_FRONT_AND_BACK: return rsx::cull_face::front_and_back;
case CELL_GCM_FRONT: return rsx::cull_face::front;
case CELL_GCM_BACK: return rsx::cull_face::back;
}
fmt::throw_exception("Unknown cull face 0x%x" HERE, in);
}
enum
{
CELL_GCM_TRANSFER_ORIGIN_CENTER = 1,

View file

@ -271,15 +271,13 @@ namespace rsx
front_face to_front_face(u16 in);
enum class cull_face : u8
enum class cull_face : u32
{
front,
back,
front_and_back,
front = 0x0404, // CELL_GCM_FRONT
back = 0x0405, // CELL_GCM_BACK
front_and_back = 0x0408, // CELL_GCM_FRONT_AND_BACK
};
cull_face to_cull_face(u16 in);
enum class user_clip_plane_op : u8
{
disable,

View file

@ -2927,14 +2927,13 @@ struct registers_decoder<NV4097_SET_CULL_FACE>
union
{
u32 raw_value;
bitfield_decoder_t<0, 32> cull_face_mode;
} m_data;
public:
decoded_type(u32 raw_value) { m_data.raw_value = raw_value; }
cull_face cull_face_mode() const
{
return to_cull_face(m_data.cull_face_mode);
return static_cast<cull_face>(m_data.raw_value);
}
};

View file

@ -158,6 +158,20 @@ namespace rsx
}
}
void set_cull_face(thread* rsx, u32 reg, u32 arg)
{
switch(arg)
{
case CELL_GCM_FRONT_AND_BACK: return;
case CELL_GCM_FRONT: return;
case CELL_GCM_BACK: return;
default: break;
}
// Ignore value if unknown
method_registers.registers[reg] = method_registers.register_previous_value;
}
void texture_read_semaphore_release(thread* rsx, u32 _reg, u32 arg)
{
// Pipeline barrier seems to be equivalent to a SHADER_READ stage barrier
@ -381,17 +395,17 @@ namespace rsx
}
};
void set_transform_program_start(thread* rsx, u32, u32)
void set_transform_program_start(thread* rsx, u32 reg, u32)
{
if (method_registers.register_change_flag)
if (method_registers.registers[reg] != method_registers.register_previous_value)
{
rsx->m_graphics_state |= rsx::pipeline_state::vertex_program_dirty;
}
}
void set_vertex_attribute_output_mask(thread* rsx, u32, u32)
void set_vertex_attribute_output_mask(thread* rsx, u32 reg, u32)
{
if (method_registers.register_change_flag)
if (method_registers.registers[reg] != method_registers.register_previous_value)
{
rsx->m_graphics_state |= rsx::pipeline_state::vertex_program_dirty | rsx::pipeline_state::fragment_program_dirty;
}
@ -1325,16 +1339,8 @@ namespace rsx
void rsx_state::decode(u32 reg, u32 value)
{
auto& old_value = registers[reg];
if (old_value != value)
{
register_change_flag = true;
old_value = value;
}
else
{
register_change_flag = false;
}
// Store new value and save previous
register_previous_value = std::exchange(registers[reg], value);
}
bool rsx_state::test(u32 reg, u32 value) const
@ -1747,6 +1753,7 @@ namespace rsx
bind<NV406E_SEMAPHORE_RELEASE, nv406e::semaphore_release>();
// NV4097
bind<NV4097_SET_CULL_FACE, nv4097::set_cull_face>();
bind<NV4097_TEXTURE_READ_SEMAPHORE_RELEASE, nv4097::texture_read_semaphore_release>();
bind<NV4097_BACK_END_WRITE_SEMAPHORE_RELEASE, nv4097::back_end_write_semaphore_release>();
bind<NV4097_SET_BEGIN_END, nv4097::set_begin_end>();

View file

@ -127,8 +127,9 @@ namespace rsx
struct rsx_state
{
protected:
std::array<u32, 0x10000 / 4> registers;
public:
std::array<u32, 0x10000 / 4> registers{};
u32 register_previous_value;
template<u32 opcode>
using decoded_type = typename registers_decoder<opcode>::decoded_type;
@ -140,7 +141,6 @@ namespace rsx
return decoded_type<opcode>(register_value);
}
public:
rsx_state &operator=(const rsx_state& in)
{
registers = in.registers;
@ -159,8 +159,6 @@ namespace rsx
draw_clause current_draw_clause;
bool register_change_flag;
/**
* RSX can sources vertex attributes from 2 places:
* 1. Immediate values passed by NV4097_SET_VERTEX_DATA*_M + ARRAY_ID write.