twiddle: use both src and dst value masks
This commit is contained in:
parent
15839ae6ca
commit
dc85cad8b0
@ -59,15 +59,15 @@ uint32_t transform(ta_parameter_writer& parameter,
|
|||||||
|
|
||||||
auto polygon = global_polygon_type_0(texture_address);
|
auto polygon = global_polygon_type_0(texture_address);
|
||||||
polygon.parameter_control_word = para_control::para_type::polygon_or_modifier_volume
|
polygon.parameter_control_word = para_control::para_type::polygon_or_modifier_volume
|
||||||
| para_control::list_type::opaque
|
| para_control::list_type::opaque
|
||||||
| obj_control::col_type::packed_color
|
| obj_control::col_type::packed_color
|
||||||
| obj_control::texture;
|
| obj_control::texture;
|
||||||
|
|
||||||
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
|
polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one
|
||||||
| tsp_instruction_word::dst_alpha_instr::zero
|
| tsp_instruction_word::dst_alpha_instr::zero
|
||||||
| tsp_instruction_word::fog_control::no_fog
|
| tsp_instruction_word::fog_control::no_fog
|
||||||
| tsp_instruction_word::texture_u_size::from_int(texture_width)
|
| tsp_instruction_word::texture_u_size::from_int(texture_width)
|
||||||
| tsp_instruction_word::texture_v_size::from_int(texture_height);
|
| tsp_instruction_word::texture_v_size::from_int(texture_height);
|
||||||
|
|
||||||
polygon.texture_control_word = texture_control_word::pixel_format::_8bpp_palette
|
polygon.texture_control_word = texture_control_word::pixel_format::_8bpp_palette
|
||||||
| texture_control_word::scan_order::twiddled
|
| texture_control_word::scan_order::twiddled
|
||||||
@ -266,10 +266,11 @@ void main()
|
|||||||
|
|
||||||
auto parameter = ta_parameter_writer(ta_parameter_buf);
|
auto parameter = ta_parameter_writer(ta_parameter_buf);
|
||||||
|
|
||||||
|
/*
|
||||||
transform2(parameter,
|
transform2(parameter,
|
||||||
font->texture_width, font->texture_height);
|
font->texture_width, font->texture_height);
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
transform(parameter,
|
transform(parameter,
|
||||||
font->texture_width, font->texture_height,
|
font->texture_width, font->texture_height,
|
||||||
font->first_char_code,
|
font->first_char_code,
|
||||||
@ -283,7 +284,6 @@ void main()
|
|||||||
glyphs,
|
glyphs,
|
||||||
cabal, 26,
|
cabal, 26,
|
||||||
font->glyph_height * 1);
|
font->glyph_height * 1);
|
||||||
*/
|
|
||||||
|
|
||||||
parameter.append<global_end_of_list>() = global_end_of_list();
|
parameter.append<global_end_of_list>() = global_end_of_list();
|
||||||
|
|
||||||
|
@ -183,17 +183,21 @@ void texture3(volatile T * dst, const U * src,
|
|||||||
constexpr uint32_t pixels_per_u = u_bits / src_bits_per_pixel;
|
constexpr uint32_t pixels_per_u = u_bits / src_bits_per_pixel;
|
||||||
static_assert(pixels_per_u == 1 || pixels_per_u == 2 || pixels_per_u == 4 || pixels_per_u == 8 || pixels_per_u == 16 || pixels_per_u == 32);
|
static_assert(pixels_per_u == 1 || pixels_per_u == 2 || pixels_per_u == 4 || pixels_per_u == 8 || pixels_per_u == 16 || pixels_per_u == 32);
|
||||||
|
|
||||||
|
constexpr uint32_t src_val_mask = ((1 << src_bits_per_pixel) - 1);
|
||||||
|
constexpr uint32_t dst_val_mask = ((1 << dst_bits_per_pixel) - 1);
|
||||||
|
constexpr uint32_t dst_src_shift = (dst_bits_per_pixel < src_bits_per_pixel) ? (src_bits_per_pixel - dst_bits_per_pixel) : 0;
|
||||||
|
|
||||||
T dst_val = 0;
|
T dst_val = 0;
|
||||||
for (uint32_t curve_ix = 0; curve_ix <= curve_end_ix; curve_ix++) {
|
for (uint32_t curve_ix = 0; curve_ix <= curve_end_ix; curve_ix++) {
|
||||||
auto [x, y] = from_ix(curve_ix);
|
auto [x, y] = from_ix(curve_ix);
|
||||||
const uint32_t src_ix = y * src_stride + (x / pixels_per_u);
|
const uint32_t src_ix = y * src_stride + (x / pixels_per_u);
|
||||||
const uint32_t src_ix_mod = x & (pixels_per_u - 1);
|
const uint32_t src_ix_mod = x & (pixels_per_u - 1);
|
||||||
const U src_val = (src[src_ix] >> (src_bits_per_pixel * src_ix_mod)) & ((1 << src_bits_per_pixel) - 1);
|
const U src_val = (src[src_ix] >> (src_bits_per_pixel * src_ix_mod)) & src_val_mask;
|
||||||
if constexpr (pixels_per_t == 1) {
|
if constexpr (pixels_per_t == 1) {
|
||||||
dst[curve_ix] = src_val;
|
dst[curve_ix] = src_val;
|
||||||
} else {
|
} else {
|
||||||
const uint32_t curve_ix_mod = curve_ix & (pixels_per_t - 1);
|
const uint32_t curve_ix_mod = curve_ix & (pixels_per_t - 1);
|
||||||
dst_val |= src_val << (dst_bits_per_pixel * curve_ix_mod);
|
dst_val |= ((src_val >> dst_src_shift) & dst_val_mask) << (dst_bits_per_pixel * curve_ix_mod);
|
||||||
|
|
||||||
if (curve_ix_mod == (pixels_per_t - 1)) {
|
if (curve_ix_mod == (pixels_per_t - 1)) {
|
||||||
dst[curve_ix / pixels_per_t] = dst_val;
|
dst[curve_ix / pixels_per_t] = dst_val;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user