Originally Posted By cgwg
Shaderc does already compile on Linux. Lacking in clean makefile magic, I had to make the following changes in order for "make shaders" to work:
  • In src/osd/modules/render/bgfx/shaders/makefile, comment out the lines that contain TARGET=n, except for the case n=4.
  • In src/osd/modules/render/bgfx/shaders/shader.mk, add a backslash before the semicolon in the lines
    Code:
    VS_FLAGS+=-i $(THISDIR)../src/;$(THISDIR)../examples/common/
    FS_FLAGS+=-i $(THISDIR)../src/;$(THISDIR)../examples/common/

For a first try, I've ported my CRT shader to bgfx; get it here in uncompiled form. Note that this has only been tested on Linux/GLSL with an Nvidia card.


Neat!

But dx9 and dx11 shaders won't compile right now because bgfx has some annoying constraints (bgfx itself, not MAME).

Look here: https://bkaradzic.github.io/bgfx/tools.html

and you'll see:
Code:
No bool/int uniforms, all uniforms must be float.
Attributes and varyings can be accessed only from main() function.
Must use SAMPLER2D/3D/CUBE/etc. macros instead of sampler2D/3D/Cube/etc. tokens.
Must use vec2/3/4_splat(<value>) instead of vec2/3/4(<value>).
Must use mul(x, y) when multiplying vectors and matrices.
Must use varying.def.sc to define input/output semantic and precission instead of using attribute/in and varying/in/out.
$input/$output tokens must appear at the begining of shader.



So for crt-geom to work we need:

  • all the "vec2(0.5)" type things updated to vec2(0.5, 0.5) or I guess vec2_splat(0.5)
  • the matrix multiply for the transformtation to use mul(x,y)
  • all access of varying parameters to be in main() ONLY


The last one is a bit of a pain for your shader because you expect sinangle, cosangle, stretch, etc to be available everywhere. The shader will need those passed into every function that uses them. Also, even though the varying parameters aren't accessible in functions that aren't main(), you still can't use those variable names in the helper functions. So you can't for example do this:
Code:
float intersect(vec2 xy, vec2 sinangle, vec2 cosangle)

because the compiler will bitch about the name sinangle and cosangle.

And somewhere you have a variable called "point" that is some kind of reserved name or something. So that needs changing too.

I'm not trying to force you to make all these changes, I could probably do it if I have a few minutes later. But I wanted to list the required changes here in case you wanted to make the modifications yourself, but didn't have access to a Windows PC with MAME build tools.

Good work though. HLSL is too slow to run on integrated graphics and CRT-geom isn't. So it definitely is useful to have available.