Previous Thread
Next Thread
Print Thread
Joined: Jun 2014
Posts: 32
T
tjcbs Offline OP
Member
OP Offline
Member
T
Joined: Jun 2014
Posts: 32
Whether the value is 0 or 1, the output is point-filtered. Using 0.173 on windows.

Incidentally, I found a thread from 2007 complaining about this. Was this always broken, or did it regress recently?

Joined: Jun 2014
Posts: 32
T
tjcbs Offline OP
Member
OP Offline
Member
T
Joined: Jun 2014
Posts: 32
Or wait... it seems to do (glitchy) filtering if no shader is set.

Is this setting for some built-in filtering? If so, how do you enable hardware filtering, alongside a shader?

Joined: Mar 2001
Posts: 16,892
Likes: 51
R
Very Senior Member
Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,892
Likes: 51
The shader you use has to support that setting. The 3rd-party ones (CRT-geom, Lottes) don't.

This is one of many reasons opengl and D3D are going away.

Joined: Jun 2014
Posts: 32
T
tjcbs Offline OP
Member
OP Offline
Member
T
Joined: Jun 2014
Posts: 32
Ugh, I'm so sorry, the setting I was really interested is "filter".

"filter 1" does not have the desired effect, the src texture is still point sampled.

I don't care about D3D, but I really hope opengl isn't going away anytime soon!! Unless it is possible to run a shader other than "HLSL" on bgfx... honestly I don't really understand bgfx at all....

Joined: Mar 2001
Posts: 16,892
Likes: 51
R
Very Senior Member
Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,892
Likes: 51
BGFX lets you run the same shaders and code on D3D9, D3D11, D3D12, OpenGL, OpenGL-ES, Vulkan, or Metal. The upshot is that it lets you use a version of the HLSL features on Mac and Linux, and unlike traditional HLSL you can also add your own shaders. And unlike OpenGL, user-added shaders can define sliders to appear in the menu and in your ini file.

Last edited by R. Belmont; 05/31/16 07:49 PM.
Joined: Jun 2014
Posts: 32
T
tjcbs Offline OP
Member
OP Offline
Member
T
Joined: Jun 2014
Posts: 32
I see. It looks interesting, since it looks like I will be able to do things like write and read from a secondary buffer, which I've wanted to do for a while.

I was confused though, since looking in the directory I didn't see any actual shaders, just JSON files. And yet it still ran, leading me to believe the shaders were built into mame somehow.

Is there any documentation or tutorial on how to use your own shader with bgfx?

As for glsl, for my own purposes, I fixed my problem by removing the check
Code:
(PRIMFLAG_GET_SCREENTEX(flags)) && 
from the below code in drawogl.cpp. I'm not sure what the intention is, or if it is still needed.

Code:
	if ((PRIMFLAG_GET_SCREENTEX(flags)) && video_config.filter)
	{
		assert( glsl_shader_feature == GLSL_SHADER_FEAT_PLAIN );

		// screen textures get the user's choice of filtering
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	}
	else
	{
		// non-screen textures will never be filtered
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	}

Joined: Mar 2001
Posts: 16,892
Likes: 51
R
Very Senior Member
Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,892
Likes: 51
That check prevents things that aren't the game image from being filtered, like artwork/bezels/UI elements/etc. It's very much needed because you don't want those things to go blurry.

Joined: May 2011
Posts: 41
S
Member
Offline
Member
S
Joined: May 2011
Posts: 41
Originally Posted By tjcbs
I see. It looks interesting, since it looks like I will be able to do things like write and read from a secondary buffer, which I've wanted to do for a while.

I was confused though, since looking in the directory I didn't see any actual shaders, just JSON files. And yet it still ran, leading me to believe the shaders were built into mame somehow.

Is there any documentation or tutorial on how to use your own shader with bgfx?


I don't know about any tutorial. But if you look in:
/mame/src/osd/modules/render/bgfx/shaders/chains
you'll find the shader source.

You really need to write three sets of files:

Shader Source files: In a subfolder of /mame/src/osd/modules/render/bgfx/shaders/chains -- This is where you write your shader source for each shader.

Effect files: In a subfolder of /mame/bgfx/effects -- These are *.json files that define the uniforms for each shader effect as well as the name of the compiled shader.

Shader Chain file: In a subfolder of /mame/bgfx/chains -- This the the user visible "Shader Chain". It's another json file that defines all of your render targets and shader passes. In addition, there are a bunch of fancy things you can do here. You can set up sliders so users can change parameters from the user interface. You can have an effect take input from any previous effect if you haven't overwritten the target. You have access to the current and previous emulated frames. There's really a ton of stuff you can do with this system that you could never do before.

So what you have to do looks something like:
  • You write the vertex and fragment shaders in the subfolder of "/mame/src/osd/modules/render/bgfx/shaders/chains" that you create. There are plenty of simple shaders to look at to see how things are done. Like the color, defocus, etc in the "hlsl" shader chain folder. Don't forget the "varying.def.sc".
  • Then you need to compile your shader using "make shaders" from the root of the mame source. note: I can't currently compile shaders in windows and I still haven't figured out what I broke... Hopefully you'll do better.
  • Then you need to drop the compiled shaders (they'll be ".bin" extension) to the mame/bgfx/shaders/TYPE/chains/yourshader folder. Where "TYPE" is dx9, dx11, gles, glsl, metal.
  • Then for each individual shader effect you need a *.json file in mame/bgfx/effects/yourshader. You can copy/paste most of it. You mostly need to include the uniforms you're using and the correct names of the vertex and fragment shaders. The shader names need to match the *.bin files from the previous step.
  • Finally, you can create a "Shader Chain" file. This is another *.json file but in the folde /mame/bgfx/chains/yourshader. This is the file that will define up your render targets and set the inputs/outputs/uniforms for all your shader passes.


It's a lot more work than writing the glsl shaders. But you can do a lot more with it.


Moderated by  R. Belmont 

Link Copied to Clipboard
Who's Online Now
2 members (Rik, 1 invisible), 23 guests, and 2 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,071
Posts118,945
Members5,014
Most Online890
Jan 17th, 2020
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Forum hosted by www.retrogamesformac.com