Files
LibretroAdmin e3cdcbe82b menu: the menu installs its effects; drivers draw any effect
The six XMB background effects (ribbon, simple ribbon, simple snow,
snow, bokeh, snowflake) were baked into every video driver as fixed
shader slots, VIDEO_SHADER_MENU to VIDEO_SHADER_MENU_6. Each driver
carried its own copies of the sources, built them whether or not a menu
used them, and had a case per slot in its draw code.

Now the menu owns them. XMB keeps one table of the effects
(menu/drivers/xmb_effects.h) with each effect's sources for every
backend - GLSL (legacy and core), SPIR-V, HLSL SM3 and SM4, Metal and
GX2 - and how it draws (a mesh or a quad, its blend, whether it takes
the ribbon data, whether it flips Y). XMB installs them through
gfx_display_effect_install() and draws one by handing the draw its
effect. The drivers have a single generic path: an effect_install
callback that makes a program from the backend's source, and a draw
that goes by the effect's flags. VIDEO_SHADER_MENU..MENU_6 are gone,
and so is the shader backend's init_menu_shaders.

Installs are kept in a small lock-free table in gfx_display. The
programs are made on the drawing thread when the first effect is
drawn, all at once, so nothing is compiled while an effect is on
screen. When the video driver goes away the programs are dropped and
made again under the next one.

What this removes or speeds up:
- Menus that draw no effect (Ozone, MaterialUI, RGUI, XMB with the
  effect off) build no effect programs at all.
- GL: effect draws use their own program with every uniform and
  attribute location looked up once at compile. Before, every effect
  draw looked up "time", "Ribbon" and "OutputSize" by name through
  the shader backend, with prefix retries, each frame. The quads draw
  from the full-screen mesh's buffer, as the ribbon draws from its
  own: no vertices are uploaded per draw, and nothing is read from
  client memory, which a core profile does not allow.
- GL core: effects no longer switch to and from the shader chain's
  program through the chain path; the chain program is put back only
  after an effect was drawn.
- D3D9 (HLSL and Cg): the constant registers/parameters are found once
  when an effect is compiled, not on every draw.
- Vulkan: display.pipelines shrinks from 9 to 3 (plastic stays at its
  own slot); the effect pipelines are made from the effect's own
  SPIR-V and remade with the passes.
- D3D12: effect bytecode is compiled once; only the PSOs are remade
  when the render target format changes.
- The seven Cg effect sources (gl_shaders/pipeline_*.cg.h) are gone.

Unchanged: the plastic effect and the stock shaders keep their ids;
fonts and other menus use them, and moving them buys nothing.

Behaviour notes:
- GL (gl2) effects need GLSL; a Cg-only GL build no longer draws
  them.
- GL core draws effects only when built with slang (they come from
  the SPIR-V); without it the background is plain.
- D3D9 HLSL no longer falls back to stock shading when an effect
  fails to compile; the effect is skipped instead.

Tests:
- samples/gfx/menu_effects (new): every effect carries a source for
  every backend, its flags hold together, and each source names the
  inputs and uniforms the drivers set for those flags. Each GLSL
  program is made through shader_glsl.c as gl2 makes it - GL legacy
  and core profile, GLES 3 and 2, on Mesa's EGL device - its
  locations checked and drawn once into a framebuffer. The SPIR-V goes
  through spirv-val. Cross-built with mingw-w64, the HLSL is compiled
  under Wine as D3D9 (SM3), D3D10/11 (SM4) and D3D12 (SM5) compile it;
  what Wine's compiler does not yet support (SM1 branches and loops,
  atan) is reported as skipped. Run in samples-gfx and
  samples-gfx-d3d.
- samples/gfx/gfx_display_mesh covers install-once, re-making after
  the driver is lost, and no draw without an install.
- samples/gfx/d3d9_failed_lock's ribbon test follows the new ids.
2026-11-16 08:42:12 +01:00
..
2024-04-23 15:53:35 -07:00
2015-09-20 15:49:19 +02:00
2018-07-12 21:33:18 -07:00