gonetz / GLideN64

A new generation, open-source graphics plugin for N64 emulators.
Other
770 stars 179 forks source link

Lack of dithering in N64 framebuffer causing color banding #2173

Closed TorutheRedFox closed 4 years ago

TorutheRedFox commented 4 years ago

Dithering is honestly necessary to produce a correct (and actually somewhat good looking) N64 framebuffer, as it's quantized with no dithering, which deviates from hardware, which does infact have dithering

dankcushions commented 4 years ago

getting build error with this on rpi4:

/home/pi/RetroPie-Setup/tmp/build/mupen64plus/GLideN64/src/BufferCopy/BlueNoiseTexture.cpp:533:1: error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]
 };
 ^

(repeats many times for same line for some reason)

gizmo98 commented 4 years ago

@dankcushions Maybe we should use s8 instead of char here: https://github.com/gonetz/GLideN64/blob/master/src/BufferCopy/BlueNoiseTexture.h#L5

@gonetz Wouldn‘t it be better to use stdint.h with standard types like int8_t and uint8_t instead of Types.h?

gonetz commented 4 years ago

Wouldn‘t it be better to use stdint.h with standard types like int8_t and uint8_t instead of Types.h?

It would be better to use stdint.h from the start, but now I see no sense to do such refactoring.

gonetz commented 4 years ago

Maybe we should use s8 instead of char here:

It can help indeed. -1 is valid value for signed char. Strange that narrowing conversion is an error and not a warning.

gizmo98 commented 4 years ago

@gonetz A error message seems to be default for G++ and C++11: https://gcc.gnu.org/wiki/FAQ#Wnarrowing

Char is unigned by default for ARM targets. https://answers.launchpad.net/gcc-arm-embedded/+question/428043 http://www.keil.com/support/man/docs/armcc/armcc_chr1359125009502.htm https://www.arm.linux.org.uk/docs/faqs/signedchar.php

So s8 or compiler switch "-fsigned-char" should solve the problem.

gonetz commented 4 years ago

@gizmo98 Thanks for explanations! I changed type to signed char: 0cca2fa2f

dankcushions commented 4 years ago

great, compiles and works!

however definitely dropping some frames on RPI4 with dithering and the rest at default (blue noise etc), but cool for devices with more horsepower!