Skip to content

Commit 1c89a5c

Browse files
author
Marcin Kościelnicki
committed
nvhw/pgraph: A little nv03 rop simplification.
1 parent 3ac7e67 commit 1c89a5c

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

nvhw/pgraph.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -765,18 +765,14 @@ uint32_t nv03_pgraph_blend_factor(uint32_t alpha, uint32_t beta) {
765765
return (alpha * beta) >> 1;
766766
}
767767

768-
uint32_t nv03_pgraph_do_blend(uint32_t factor, uint32_t dst, uint32_t src, int is_r5g5b5) {
768+
uint32_t nv03_pgraph_do_blend(uint32_t factor, uint32_t dst, uint32_t src) {
769769
factor >>= 3;
770770
if (factor == 0x1f)
771771
return src;
772772
if (!factor)
773773
return dst;
774774
src >>= 2;
775775
dst >>= 2;
776-
if (is_r5g5b5) {
777-
src &= 0xf8;
778-
dst &= 0xf8;
779-
}
780776
return (dst * (0x20 - factor) + src * factor) >> 3;
781777
}
782778

@@ -796,7 +792,6 @@ uint32_t nv03_pgraph_rop(struct pgraph_state *state, int x, int y, uint32_t pixe
796792
struct pgraph_color d = nv03_pgraph_expand_surf(fmt, pixel);
797793
struct pgraph_color p = nv03_pgraph_pattern_pixel(state, x, y);
798794
if (blend_en) {
799-
int is_r5g5b5 = fmt != 3 && !dither;
800795
uint32_t beta = state->beta >> 23;
801796
uint8_t factor;
802797
if (op >= 0x1b && op != 0x1d)
@@ -817,7 +812,7 @@ uint32_t nv03_pgraph_rop(struct pgraph_state *state, int x, int y, uint32_t pixe
817812
insrt(s.r, 0, 2, extr(s.r, 8, 2));
818813
insrt(s.g, 0, 2, extr(s.g, 8, 2));
819814
insrt(s.b, 0, 2, extr(s.b, 8, 2));
820-
if (fmt != 3 && is_rgb5) {
815+
if (fmt != 3 && (is_rgb5 || !dither)) {
821816
s.r &= 0x3e0;
822817
s.g &= 0x3e0;
823818
s.b &= 0x3e0;
@@ -828,9 +823,9 @@ uint32_t nv03_pgraph_rop(struct pgraph_state *state, int x, int y, uint32_t pixe
828823
d.g &= 0x3e0;
829824
d.b &= 0x3e0;
830825
}
831-
s.r = nv03_pgraph_do_blend(factor, d.r, s.r, is_r5g5b5);
832-
s.g = nv03_pgraph_do_blend(factor, d.g, s.g, is_r5g5b5);
833-
s.b = nv03_pgraph_do_blend(factor, d.b, s.b, is_r5g5b5);
826+
s.r = nv03_pgraph_do_blend(factor, d.r, s.r);
827+
s.g = nv03_pgraph_do_blend(factor, d.g, s.g);
828+
s.b = nv03_pgraph_do_blend(factor, d.b, s.b);
834829
} else {
835830
if (op < 0x16) {
836831
if (op >= 9 && !p.a)
@@ -871,6 +866,7 @@ uint32_t nv03_pgraph_rop(struct pgraph_state *state, int x, int y, uint32_t pixe
871866
}
872867
}
873868
}
869+
uint32_t ropres;
874870
switch (fmt) {
875871
case 1:
876872
return s.i;

0 commit comments

Comments
 (0)