Commit Graph

75 Commits

Author SHA1 Message Date
Matt Borgerson 880bea3e5e nv2a/gl: Cache shader modules 2025-07-02 20:11:30 -07:00
Matt Borgerson 80f7efaba5 nv2a/glsl: Define inlineValue uniform only when necessary 2025-06-28 16:09:06 -07:00
Matt Borgerson 1dbfc3e21a nv2a/glsl: Fix duplicate inlineValue uniform declaration 2025-06-28 16:09:06 -07:00
Matt Borgerson 41a4b3f2a3 nv2a/glsl: Fix push constant range 2025-06-28 16:09:06 -07:00
Matt Borgerson 8cc83dfc43 nv2a/glsl: Remove some more redundant comments 2025-06-28 00:18:28 -07:00
Matt Borgerson f2c5b80951 nv2a/glsl: Simplify some mstring uses in pgraph_glsl_gen_vsh 2025-06-28 00:18:28 -07:00
Matt Borgerson 8a606ae37f nv2a/glsl: Simplify some mstring uses in pgraph_glsl_gen_geom 2025-06-28 00:18:28 -07:00
Matt Borgerson 1489253c68 nv2a/glsl: Add glsl_ prefix to public functions 2025-06-28 00:18:28 -07:00
Matt Borgerson cbcb7c2181 nv2a/glsl: Factor out geometry state to GeomState 2025-06-28 00:18:28 -07:00
Matt Borgerson 3e6e9c9d6c nv2a/glsl: Clean up some includes 2025-06-28 00:18:28 -07:00
Matt Borgerson 7804fc0656 nv2a/glsl: Move clipRange value calc to helper func 2025-06-28 00:18:28 -07:00
Matt Borgerson d17be812ea nv2a/glsl: Unify dirty shader state check 2025-06-28 00:18:28 -07:00
Matt Borgerson b7eb957e65 nv2a/glsl: Move append_skinning_code up 2025-06-28 00:18:28 -07:00
Matt Borgerson 0e29758036 nv2a/glsl: Clean up some whitespace 2025-06-28 00:18:28 -07:00
Matt Borgerson df4d8cc027 nv2a/glsl: Simplify pgraph_gen_vsh_prog_glsl mstring use 2025-06-28 00:18:28 -07:00
Matt Borgerson 368b9f5346 nv2a: Move some VSH definitions to vsh_regs.h 2025-06-28 00:18:28 -07:00
Matt Borgerson b72119da41 nv2a/glsl: Remove some redundant comments 2025-06-28 00:18:28 -07:00
Matt Borgerson fc28b9c817 nv2a: Move PSH definitions to psh_regs.h 2025-06-28 00:18:28 -07:00
Matt Borgerson 4e6c6518f9 nv2a: Add _regs suffix to vsh.h and psh.h 2025-06-28 00:18:28 -07:00
Matt Borgerson 55705002c5 nv2a/glsl: Be consistent in name of state parameter 2025-06-28 00:18:28 -07:00
Matt Borgerson 22b242b2d6 nv2a/glsl: Let pgraph_gen_vsh_glsl take a pointer to PshState 2025-06-28 00:18:28 -07:00
Matt Borgerson 1930934908 nv2a/glsl: Clean up some includes 2025-06-28 00:18:28 -07:00
Matt Borgerson b8fd711012 nv2a/glsl/vsh-prog.h: Include mstring.h 2025-06-28 00:18:28 -07:00
Matt Borgerson afadedf90b nv2a/glsl/vsh-prog.h: Drop 'Based on' claim 2025-06-28 00:18:28 -07:00
Matt Borgerson 34e8c62a42 nv2a: Move {Vsh,Psh}State generation into glsl subdir 2025-06-28 00:18:28 -07:00
Matt Borgerson bebffc7d64 nv2a/glsl: Let pgraph_gen_geom_glsl take VshState and GlslOptions 2025-06-28 00:18:28 -07:00
Matt Borgerson 8bda9507bd nv2a/glsl: Invert fog gen blocks for readability 2025-06-28 00:18:28 -07:00
Matt Borgerson 45724b34e6 nv2a: Drop some unnecessary comments 2025-06-28 00:18:28 -07:00
Matt Borgerson c88bac1706 nv2a: Simplify shader uniform declaration and update
This patch moves uniform declaration into {vsh, psh}.h headers, using
macros to generate accessory definitions. Mapping of PGRAPH state to
uniform values is factored out of parallel paths in GL/Vk renderers into
common renderer-agnostic helper functions, with renderer-specific
uniform value update paths being automated.
2025-06-28 00:18:28 -07:00
Matt Borgerson 18872f2eb9 nv2a: Update various copyright headers 2025-06-28 00:18:28 -07:00
Matt Borgerson 4977e65bd5 nv2a/vk: Clean up layout binding ids 2025-06-28 00:18:28 -07:00
Matt Borgerson 9020913e29 nv2a: Extract GLSL generation options from {Vsh,Psh}State 2025-06-28 00:18:28 -07:00
Matt Borgerson c575b08b5f nv2a: Extract VshState from ShaderState 2025-06-28 00:18:28 -07:00
Erik Abair 634577c753 nv2a: Clamp fog factor to valid float range 2025-06-26 14:20:20 -07:00
Erik Abair 348b03d6ce
nv2a: Handle PGRAPH color keying 2025-06-21 13:25:24 -07:00
Erik Abair 8667193001 nv2a: Prevent NaN in specular power factor calculation 2025-05-20 13:28:39 -07:00
coldhex ce936bccdd nv2a/gl: y-flipped rendering to framebuffer object
Render scenes upside-down to framebuffer objects (FBO). The strange thing
about rendering to OpenGL FBO is that it follows the bottom-left triangle
rasterization rule with common PC GPUs. At least Intel and AMD. NVIDIA to
be tested. My raster-rule-test github gist demonstrates this.

This commit flips coordinates in y-direction, which effectively turns the
bottom-left rule into top-left rule needed for Xbox compatibility.

This (together with the previous commit) fixes Midtown Madness 3 Seine
water rectangular seam rendering artifacts (and the remaining seams are
present with Xbox hardware too.) May fix similar artifacts in other games.
2025-05-20 13:15:12 -07:00
coldhex a316d74872 nv2a: Use trunc in vertex rounding instead of floor
Xbox seems to truncate instead of flooring, which can be inferred from
interpolated depth buffer values.
2025-05-20 13:15:12 -07:00
coldhex 11dcae01b9 nv2a: implement screen coordinate rounding to 4 bit fractional precision
Xbox triangle rasterization appears to follow the usual top-left rule.
However, since Xemu renders to an OpenGL framebuffer object (FBO) instead
of directly to the default framebuffer, Xemu actually has what could be
called the bottom-left triangle rasterization rule. I'll address that in
another commit.

Also, note that the ProjAdjacentGeometry_0.5625 test in nxdk_pgraph_tests
is very sensitive to floating point rounding errors. For example, the
nxdk_pgraph_tests commit 66b32a0b1feba32a0db7a95d6358e84f7a6246ad changed
the math library which caused the test result to change also on real Xbox
hardware due to floating point rounding error differences in matrix
inverse computation. Apart from the bottom-left rasterization issue, the
differing result between Xbox and the rounding I am proposing here for
Xemu seems to stem from floating point rounding that happens in screen
coordinate calculations before the rounding to 4 bit precision takes place.
Fixing such rounding issues would require carrying all preceding floating
point computations exactly in the same order and with same precision as
Xbox. Note that Xbox Direct3D library seems to add 0.03125 (1/32) to
screen coordinates by default. Likely the idea there was to make floating
point screen coordinates round to the nearest screen coordinates in
4 bit fixed point precision. So the Xbox Direct3D library (and therefore
games) already mitigate against precarious rounding when exactly
half-integer coordinates are used by games. Actually they would use
integer coordinates because it is Direct3D 8, but since nv2a appears to
rasterize at half-integer coordinates like OpenGL, Xbox Direct3D
also adds 0.5 to screen coordinates in addition to 1/32.
2025-05-20 13:15:12 -07:00
Erik Abair c720af00bb
nv2a/vsh: Replace NaN with 1.0 for Bx, Dx, Fog outputs and MUL zero-check 2025-05-15 12:54:56 -07:00
Erik Abair d593869429
nv2a: Move point params to uniforms
Co-authored-by: Matt Borgerson <contact@mborgerson.com>
2025-04-30 23:43:38 -07:00
Matt Borgerson 6e513ed948 nv2a/psh: Fix 2D texture addressing in DOT_STR_3D mode 2025-04-29 23:41:05 -07:00
Erik Abair 89185e6937 nv2a/psh: Fix default alpha for unbound texture samplers 2025-04-22 20:16:15 -07:00
Erik Abair 679f6d06bd nv2a: Handle LOCALEYE light control 2025-04-16 18:24:46 -07:00
Erik Abair 34ed0f75de nv2a: Handle LOCAL_RANGE 2025-04-16 18:24:46 -07:00
Erik Abair 69c8df2a3e nv2a: Partial implementation of SET_SPECULAR_PARAMS 2025-04-16 18:24:46 -07:00
Erik Abair 7a34eedd6f nv2a: Partially handle SET_LIGHT_CONTROL 2025-04-16 18:24:46 -07:00
Erik Abair ebec5e3028 nv2a: Fix assert when setting fog gen mode to fog_x 2025-04-08 16:24:50 -07:00
Erik Abair 672e9cd553 nv2a: Handle SET_SPECULAR_ENABLE 2025-03-28 02:18:42 -07:00
coldhex 02659dd3cc nv2a: Fix cubemap fourth texture coordinate component handling
Xbox hardware ignores fourth texture coordinate component for cubemaps.
2025-03-17 11:37:41 -07:00