mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 19:45:20 +00:00
rsx: Improve performance by using an integral type to indicate error
This commit is contained in:
parent
f6027719d2
commit
a272f3e3b9
3 changed files with 37 additions and 13 deletions
|
@ -5,13 +5,37 @@
|
|||
|
||||
namespace rsx
|
||||
{
|
||||
template <typename E>
|
||||
concept ErrorType = requires (E& e)
|
||||
{
|
||||
{ e.empty() } -> std::same_as<bool>;
|
||||
};
|
||||
namespace exception_utils
|
||||
{
|
||||
enum soft_exception_error_code
|
||||
{
|
||||
none = 0,
|
||||
range_exception = 1,
|
||||
invalid_enum = 2
|
||||
};
|
||||
|
||||
template <typename T, ErrorType E = std::string>
|
||||
struct soft_exception_t
|
||||
{
|
||||
soft_exception_error_code error = soft_exception_error_code::none;
|
||||
|
||||
soft_exception_t() = default;
|
||||
soft_exception_t(soft_exception_error_code code)
|
||||
: error(code) {}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return error == soft_exception_error_code::none;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <typename E>
|
||||
concept ErrorType = requires (E & e)
|
||||
{
|
||||
{ e.empty() } -> std::same_as<bool>;
|
||||
};
|
||||
|
||||
template <typename T, ErrorType E = exception_utils::soft_exception_t>
|
||||
class expected
|
||||
{
|
||||
T value;
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace rsx
|
|||
|
||||
rsx::comparison_function fragment_texture::zfunc() const
|
||||
{
|
||||
return static_cast<rsx::comparison_function>((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 28) & 0xf);
|
||||
return rsx::to_comparison_function((registers[NV4097_SET_TEXTURE_ADDRESS + (m_index * 8)] >> 28) & 0xf);
|
||||
}
|
||||
|
||||
u8 fragment_texture::unsigned_remap() const
|
||||
|
|
|
@ -973,7 +973,7 @@ namespace rsx
|
|||
return static_cast<T>(value);
|
||||
}
|
||||
|
||||
return fmt::format("Enum out of range 0x%x", value);
|
||||
return exception_utils::soft_exception_t{ rsx::exception_utils::invalid_enum };
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -987,7 +987,7 @@ namespace rsx
|
|||
}
|
||||
}
|
||||
|
||||
return fmt::format("Invalid enum value 0x%x", value);
|
||||
return exception_utils::soft_exception_t{ rsx::exception_utils::invalid_enum };
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -1001,7 +1001,7 @@ namespace rsx
|
|||
}
|
||||
}
|
||||
|
||||
return fmt::format("Enum is out of range 0x%x", value);
|
||||
return exception_utils::soft_exception_t{ rsx::exception_utils::invalid_enum };
|
||||
}
|
||||
|
||||
enum class vertex_base_type : u8
|
||||
|
@ -1083,8 +1083,8 @@ namespace rsx
|
|||
|
||||
enum class surface_depth_format2 : u8
|
||||
{
|
||||
z16_uint, // unsigned 16 bits depth
|
||||
z24s8_uint, // unsigned 24 bits depth + 8 bits stencil
|
||||
z16_uint = surface_depth_format::z16, // unsigned 16 bits depth
|
||||
z24s8_uint = surface_depth_format::z24s8, // unsigned 24 bits depth + 8 bits stencil
|
||||
z16_float, // floating point 16 bits depth
|
||||
z24s8_float, // floating point 24 bits depth + 8 bits stencil
|
||||
};
|
||||
|
@ -1270,7 +1270,7 @@ namespace rsx
|
|||
{
|
||||
return gcm_enum_cast<
|
||||
texture_wrap_mode,
|
||||
CELL_GCM_TEXTURE_CLAMP,
|
||||
CELL_GCM_TEXTURE_WRAP,
|
||||
CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP>(in);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue