[Base] Support sign-extension in bitfield
This commit is contained in:
parent
d914791afe
commit
f8319ec12f
|
@ -19,20 +19,28 @@ namespace xe {
|
||||||
// Bitfield, where position starts at the LSB.
|
// Bitfield, where position starts at the LSB.
|
||||||
template <typename T, size_t position, size_t n_bits>
|
template <typename T, size_t position, size_t n_bits>
|
||||||
struct bf {
|
struct bf {
|
||||||
bf() = default;
|
|
||||||
inline operator T() const { return value(); }
|
|
||||||
|
|
||||||
inline T value() const {
|
|
||||||
return static_cast<T>((storage & mask()) >> position);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For enum values, we strip them down to an underlying type.
|
// For enum values, we strip them down to an underlying type.
|
||||||
typedef
|
typedef
|
||||||
typename std::conditional<std::is_enum<T>::value, std::underlying_type<T>,
|
typename std::conditional<std::is_enum<T>::value, std::underlying_type<T>,
|
||||||
std::remove_reference<T>>::type::type
|
std::remove_reference<T>>::type::type
|
||||||
value_type;
|
value_type;
|
||||||
|
|
||||||
|
bf() = default;
|
||||||
|
inline operator T() const { return value(); }
|
||||||
|
|
||||||
|
inline T value() const {
|
||||||
|
auto value = (storage & mask()) >> position;
|
||||||
|
if (std::is_signed<value_type>::value) {
|
||||||
|
// If the value is signed, sign-extend it.
|
||||||
|
value_type sign_mask = value_type(1) << (n_bits - 1);
|
||||||
|
value = (sign_mask ^ value) - sign_mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
return static_cast<T>(value);
|
||||||
|
}
|
||||||
|
|
||||||
inline value_type mask() const {
|
inline value_type mask() const {
|
||||||
return (((value_type)~0) >> (8 * sizeof(value_type) - n_bits)) << position;
|
return ((value_type(1) << n_bits) - 1) << position;
|
||||||
}
|
}
|
||||||
|
|
||||||
value_type storage;
|
value_type storage;
|
||||||
|
|
|
@ -912,15 +912,8 @@ bool VulkanCommandProcessor::IssueCopy() {
|
||||||
// vtx_window_offset_enable
|
// vtx_window_offset_enable
|
||||||
assert_true(regs[XE_GPU_REG_PA_SU_SC_MODE_CNTL].u32 & 0x00010000);
|
assert_true(regs[XE_GPU_REG_PA_SU_SC_MODE_CNTL].u32 & 0x00010000);
|
||||||
uint32_t window_offset = regs[XE_GPU_REG_PA_SC_WINDOW_OFFSET].u32;
|
uint32_t window_offset = regs[XE_GPU_REG_PA_SC_WINDOW_OFFSET].u32;
|
||||||
int16_t window_offset_x = window_offset & 0x7FFF;
|
int32_t window_offset_x = window_regs->window_offset.window_x_offset;
|
||||||
int16_t window_offset_y = (window_offset >> 16) & 0x7FFF;
|
int32_t window_offset_y = window_regs->window_offset.window_y_offset;
|
||||||
// Sign-extension
|
|
||||||
if (window_offset_x & 0x4000) {
|
|
||||||
window_offset_x |= 0x8000;
|
|
||||||
}
|
|
||||||
if (window_offset_y & 0x4000) {
|
|
||||||
window_offset_y |= 0x8000;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t dest_texel_size = uint32_t(GetTexelSize(copy_dest_format));
|
uint32_t dest_texel_size = uint32_t(GetTexelSize(copy_dest_format));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue