Undocumented features of .cgp files, like wrap_mode?

I noticed that rgui.cgp makes use of a wrap_mode0 key, which is set to “clamp_to_border,” but it isn’t mentioned in the Cg Shader Spec here. What are the other values it can be set to? Specifically, is there a way to set the texture read mode to tile or repeat or similar? Does this apply for any texture read throughout the course of the affected pass, or can externally provided textures be set to use their own wrap_mode?

I made another thread earlier under the assumption that Retroarch imposed a hard 8-pass limit, but hunterk corrected me, and I’m wondering just how many undocumented shader features I don’t know about. Off the top of my head, I’m wondering (having trouble with the list BBCode here, but…):

[ul] [li]Is there any other document/URL I should know about which details features not codified in the spec?[/:m:tgs3jqvn][/li][li]Another assumption I made in my earlier post was it’s impossible to get Retroarch to use mipmapping, trilinear, or anisotropic filtering for textures (which lookups with calculated coordinates could sometimes benefit from). Is this actually true?[/:m:tgs3jqvn][/li][li]Is there a way to get the size of the final viewport (after all passes) in an earlier shader pass with a different-sized framebuffer?[/:m:tgs3jqvn][/li][]Is there a way to pass constants from .cgp files to any/all passes or have a .cgp file tell a .cg file to #include a particular file? There probably isn’t based on how Maister organized the NTSC shader permutations, but I figured it was worth asking.[/*:m:tgs3jqvn][/ul]

For undocumented features, I think your best bet will be to skim through the source code (assuming you can read/parse C; EDIT: I think gfx/gl.c would be the place to look). I think there may be ‘edge’ and ‘repeat’ wrappings but I’m not sure about that. Perhaps maister can chime in.

Filtering for LUTs and FBOs is confined to bilinear and nearest neighbor, AFAIK

I don’t think there’s any way to get the final output size in an earlier shader, but I could be wrong.

cgp files can’t trickle down constants or force an ‘include’ but you can see from maister’s NTSC shader that individual Cg files can #include other files. For example, you could have each Cg file ‘#include tweakables.inc’ which would then be a file full of #defines for users to easily modify.

#include “user-config.inc” is actually exactly how I’m setting things up. (By the way, is “.inc” standard, or just what Maister used for lack of a standard? I’ve been using “.cgh”) There’s a user config file for all of the parameters, but I was wanting to see if I could improve this by distributing a number of preset config files that could be selected from the .cgp file without all the individual passes having to be modified to #include a different settings file.

If that were possible, users could switch between .cgp files that used different preset configurations without a new copy having to be made of every single pass to support the preset system…which created an unscalable combinatorial explosion for Maister’s NTSC shader. I guess that’s just food for thought regarding future improvements. :slight_smile: As it stands, I guess users will just have to manually rename whatever configuration file they want to use at the moment to e.g. “user-config.inc,” which all the passes #include. Sadly, that restricts any semblance of configurability to PC users only, who have the power to manually edit and rename config files.

I always hesitate to dive into the source code for a large project like this, since it would take forever to get a mental model of how it fits together, but /gfx/shader_parse.c actually answered my question about wrap_mode in particular. The following four modes work: “clamp_to_border” “clamp_to_edge” “repeat” “mirrored_repeat” I actually recall reading this a few months ago too, but “repeat” never seemed to work for me in the past, and it turns out I was being stupid: I tested by shifting an FBO and zooming in on the top-left corner, and I mistook the black padding inside the texture for a failure to repeat. :o

For anyone who finds this through search, setting wrap_modeX for pass X will not affect external (e.g. LUT) textures (maybe it only applies to the input of pass X? I haven’t checked if it applies to loading earlier FBO’s, e.g. ORIG.texture). If you want to make an external texture repeat/wrap/tile, use the following .cgp lines: textures = “some_texture_name” some_texture_name = “some_texture_file.png” some_texture_name_wrap_mode = “repeat”