New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hlsl bgfx screen chain making screen red #4396

Open
belegdol opened this Issue Dec 11, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@belegdol
Copy link
Contributor

belegdol commented Dec 11, 2018

As of 0.204 enabling hlsl screen chain with bgfx on Fedora 29 x86_64 makes the video red. Here is the mame -verbose output:

$ mame -verbose mk3
Available videodrivers: x11 wayland KMSDRM dummy 
Current Videodriver: x11
	Display #0
		Renderdrivers:
			    opengl (0x0)
			 opengles2 (0x0)
			  software (0x0)
Available audio drivers: 
	pulseaudio          
	alsa                
	dsp                 
	jack                
	disk                
	dummy               
Build version:      0.204 (unknown)
Build architecure:  
Build defines 1:    SDLMAME_UNIX=1 SDLMAME_X11=1 SDLMAME_LINUX=1 
Build defines 1:    LSB_FIRST=1 PTR64=1 
SDL/OpenGL defines: SDL_COMPILEDVERSION=2009 USE_OPENGL=1 
Compiler defines A: __GNUC__=8 __GNUC_MINOR__=2 __GNUC_PATCHLEVEL__=1 __VERSION__="8.2.1 20181105 (Red Hat 8.2.1-5)" 
Compiler defines B: __amd64__=1 __x86_64__=1 __unix__=1 
Compiler defines C: _FORTIFY_SOURCE=2 __USE_FORTIFY_LEVEL=2 
Enter init_monitors
Adding monitor screen0 (1920 x 1080)
Leave init_monitors
Enter sdlwindow_init

Hints:
	SDL_FRAMEBUFFER_ACCELERATION             (null)
	SDL_RENDER_DRIVER                        (null)
	SDL_RENDER_OPENGL_SHADERS                (null)
	SDL_RENDER_SCALE_QUALITY                 (null)
	SDL_RENDER_VSYNC                         (null)
	SDL_VIDEO_X11_XVIDMODE                   (null)
	SDL_VIDEO_X11_XINERAMA                   (null)
	SDL_VIDEO_X11_XRANDR                     (null)
	SDL_GRAB_KEYBOARD                        (null)
	SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS         (null)
	SDL_IOS_IDLE_TIMER_DISABLED              (null)
	SDL_IOS_ORIENTATIONS                     (null)
	SDL_XINPUT_ENABLED                       (null)
	SDL_GAMECONTROLLERCONFIG                 (null)
	SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS     (null)
	SDL_ALLOW_TOPMOST                        (null)
	SDL_TIMER_RESOLUTION                     (null)
	SDL_RENDER_DIRECT3D_THREADSAFE           (null)
	SDL_VIDEO_ALLOW_SCREENSAVER              (null)
	SDL_ACCELEROMETER_AS_JOYSTICK            (null)
	SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK   (null)
	SDL_VIDEO_WIN_D3DCOMPILER                (null)
	SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT      (null)
	SDL_VIDEO_MAC_FULLSCREEN_SPACES          (null)
	SDL_MOUSE_RELATIVE_MODE_WARP             (null)
	SDL_RENDER_DIRECT3D11_DEBUG              (null)
	SDL_VIDEO_HIGHDPI_DISABLED               (null)
	SDL_WINRT_PRIVACY_POLICY_URL             (null)
	SDL_WINRT_PRIVACY_POLICY_LABEL           (null)
	SDL_WINRT_HANDLE_BACK_BUTTON             (null)
Leave sdlwindow_init
Enter sdl_info::create
Audio: Start initialization
Audio: Driver is pulseaudio
Audio: frequency: 48000, channels: 2, samples: 256
sdl_create_buffers: creating stream buffer of 25600 bytes
Audio: End initialization
Keyboard: Start initialization
Input: Adding keyboard #0: System keyboard (device id: System keyboard)
Keyboard: Registered System keyboard
Keyboard: End initialization
Mouse: Start initialization
Input: Adding mouse #0: System mouse (device id: System mouse)
Mouse: Registered System mouse
Mouse: End initialization
Joystick mapping: Logical id 1: MicrosoftX-BoxOnepad(Firmware2015)
Joystick: Start initialization
Input: Adding joystick #0: MicrosoftX-BoxOnepad(Firmware2015) (device id: MicrosoftX-BoxOnepad(Firmware2015))
Joystick: (null)
Joystick:   ...  -1 axes, -1 buttons -1 hats -1 balls
Joystick:   ...  Physical id -1 mapped to logical id 1
Joystick:   ...  Does not have haptic capability
Input: Adding joystick #1: NC1 (device id: NC1)
Input: Adding joystick #2: NC2 (device id: NC2)
Input: Adding joystick #3: NC3 (device id: NC3)
Input: Adding joystick #4: NC4 (device id: NC4)
Input: Adding joystick #5: NC5 (device id: NC5)
Input: Adding joystick #6: NC6 (device id: NC6)
Input: Adding joystick #7: NC7 (device id: NC7)
Input: Adding joystick #8: NC8 (device id: NC8)
Input: Adding joystick #9: NC9 (device id: NC9)
Input: Adding joystick #10: NC10 (device id: NC10)
Input: Adding joystick #11: NC11 (device id: NC11)
Input: Adding joystick #12: NC12 (device id: NC12)
Input: Adding joystick #13: NC13 (device id: NC13)
Input: Adding joystick #14: NC14 (device id: NC14)
Input: Adding joystick #15: NC15 (device id: NC15)
Joystick: End initialization
Searching font Liberation Sans in -/usr/share/mame/fonts path/s
Matching font: /usr/share/fonts/liberation/LiberationSans-Regular.ttf
Region ':dcs' created
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: found $HOME/data/mame/roms/mk3.zip ECD
unzip: $HOME/data/mame/roms/mk3.zip has no ZIP64 ECD locator
unzip: read $HOME/data/mame/roms/mk3.zip central directory
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
Region ':maincpu' created
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
Region ':gfxrom' created
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
unzip: found $HOME/data/mame/roms/mk3.zip in cache
unzip: opened archive file $HOME/data/mame/roms/mk3.zip
unzip: closing archive file $HOME/data/mame/roms/mk3.zip and sending to cache
Optional device ':serial_security' not found
Optional device ':adpcm' not found
Optional device ':cvsd' not found
Optional device ':maincpu:finder_dummy_tag' not found
Optional memory region ':nvram' not found
Optional memory region ':palette:finder_dummy_tag' not found
Optional device ':screen:finder_dummy_tag' not found
Optional device ':screen:finder_dummy_tag' not found
Optional device ':dcs:data_map_bank' not found
Optional device ':dcs:dcs:finder_dummy_tag' not found
Optional device ':dcs:dcs:finder_dummy_tag' not found
Optional device ':dcs:dcs:finder_dummy_tag' not found
Optional device ':dcs:dcs:finder_dummy_tag' not found
Starting Mortal Kombat 3 (rev 2.1) ':'
  (missing dependencies; rescheduling)
Starting TMS34010 ':maincpu'
  (missing dependencies; rescheduling)
Starting NVRAM ':nvram'
Starting palette ':palette'
Starting Video Screen ':screen'
Starting DCS Audio 8K ':dcs'
  (missing dependencies; rescheduling)
Starting Analog Devices ADSP-2105 ':dcs:dcs'
Starting Timer ':dcs:dcs_reg_timer'
Starting Timer ':dcs:dcs_int_timer'
Starting Speaker ':dcs:mono'
  (missing dependencies; rescheduling)
Starting DMA-driven DAC ':dcs:dac'
Starting Midway Serial PIC Simulation ':serial_security_sim'
Starting Mortal Kombat 3 (rev 2.1) ':'
  (missing dependencies; rescheduling)
Starting TMS34010 ':maincpu'
Starting DCS Audio 8K ':dcs'
Starting Speaker ':dcs:mono'
Starting Mortal Kombat 3 (rev 2.1) ':'
Attempting to parse: default.cfg
Attempting to parse: mk3.cfg
Average speed: 100.00% (3 seconds)
sdl_kill: closing audio
Enter sdlwindow_exit
Leave sdlwindow_exit
@belegdol

This comment has been minimized.

Copy link
Contributor

belegdol commented Dec 11, 2018

zrzut ekranu z 2018-12-11 22-47-05

@couriersud

This comment has been minimized.

Copy link
Contributor

couriersud commented Jan 1, 2019

The issue is caused by src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc

In line 26 the XYZ_TO_sRGB matrix has to be transposed:

	const mat3 XYZ_TO_sRGB = mat3(
		vec3( 3.2406, -0.9689,  0.0557),
		vec3(-1.5372,  1.8758, -0.2040),
	 	vec3(-0.4986,  0.0415,  1.0570)
	);

Can somebody with more knowledge about the bgfx shader system please apply this change?

The shader can be build with the following command:
make shaders CHAIN=hlsl

Just "make shaders" will produce a cryptic error message when compiling the xbr chain. I failed to identify the error.

@algestam

This comment has been minimized.

Copy link
Contributor

algestam commented Jan 8, 2019

I experience the same issue on Ubuntu 18.04 running 0.205.

This is a screenshot with bgfx and hlsl enabled:
outrun_before_change

The game is started with this command: ./mame64 -window -video bgfx -bgfx_screen_chains hlsl outrun

Transposing the matrix in src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc and rebuilding the shaders according to the comment by @couriersud resolves the issue for me. This is a screenshot after the change:
outrun_after_change

I will create a PR with the change but it will need to be reviewed by someone familiar with the bgfx and hlsl systems.

@MooglyGuy

This comment has been minimized.

Copy link
Contributor

MooglyGuy commented Jan 8, 2019

Sounds like a perfectly valid fix. Once you submit the PR I'll apply it and then check if it breaks anything on Windows. If it does, there'll need to be some kind of #define magic.

@algestam

This comment has been minimized.

Copy link
Contributor

algestam commented Jan 8, 2019

Thanks @MooglyGuy. The PR has been submitted, please let me know if you get a chance to test it and if there are any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment