Commit Graph

38333 Commits

Author SHA1 Message Date
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 428c975f09 nv2a: Allow multiframe RenderDoc captures with nv2a traces
Allows multiple frames to be captured at once by holding shift while pressing
F10.

Temporarily toggles nv2a trace messages if control is held while pressing F10.
2025-05-15 08:37:13 -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
Matt Borgerson 0c2a617819 nv2a: Bump vmstate version for new NV2A_MAX_BATCH_LENGTH 2025-04-18 11:58:22 -07:00
Erik Abair 270dbe01ea nv2a: Increase MAX_BATCH_LENGTH beyond highest known retail use 2025-04-18 10:46:43 -07:00
Matt Borgerson 5685a6290c nv2a/vk: Set specular power uniform 2025-04-16 20:26:22 -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 86c85023e6 nv2a: Handle SET_FOG_COORD and SET_WEIGHT* commands 2025-04-16 14:09:13 -07:00
Matt Borgerson 2cc926588b nv2a/gl: Fix COLOR_LE_G8B8 GL surface format type 2025-04-11 04:18:28 -07:00
Erik Abair ebec5e3028 nv2a: Fix assert when setting fog gen mode to fog_x 2025-04-08 16:24:50 -07:00
Matt Borgerson 57cdee770e mcpx/dsp: Fix some formatting/spelling nits 2025-03-31 12:40:31 -07:00
Matt Borgerson 9439f605a8 mcpx/dsp: Drop redundant value/address assertions 2025-03-31 12:40:31 -07:00
Matt Borgerson e08011b772 mcpx/dsp: Rename *.inl -> *.c.inc 2025-03-31 12:40:31 -07:00
Matt Borgerson 4b81c28901 mcpx/dsp: Migrate some DPRINTFs to trace events 2025-03-31 12:40:31 -07:00
Matt Borgerson 31d8237ee3 mcpx/dsp: Remove dsp56k_execute_one_disasm_instruction 2025-03-31 12:40:31 -07:00
Matt Borgerson 8dafd513b9 mcpx/dsp: Move some debug functions out to debug.c 2025-03-31 12:40:31 -07:00
Matt Borgerson d18125994c mcpx/dsp: Drop some dead code 2025-03-31 12:40:31 -07:00
Matt Borgerson f8cbcbadaa mcpx/dsp: Move dma reg defs to a header 2025-03-31 12:40:31 -07:00
Matt Borgerson c68cdd9479 mcpx/dsp: Fix minor header issues 2025-03-31 12:40:31 -07:00
Matt Borgerson 31c491a702 mcpx/dsp: Move cpu reg defs to a header 2025-03-31 12:40:31 -07:00
Matt Borgerson 5ba2ef790c mcpx/dsp: Factor out debug bits to a header 2025-03-31 12:40:31 -07:00
Matt Borgerson 148f04e1c7 mcpx/dsp: Replace printf -> DPRINTF 2025-03-31 12:40:31 -07:00
Matt Borgerson 115456f255 mcpx/dsp: Bring back disassembly 2025-03-31 12:40:31 -07:00
Matt Borgerson 89f98947f6 mcpx/dsp: Fix dprintf use 2025-03-31 12:40:31 -07:00
Matt Borgerson 9af3c1a005 mcpx/dsp: Add missing copyright 2025-03-31 12:40:31 -07:00
Matt Borgerson bf51af891d mcpx/dsp: Move to a library 2025-03-31 12:40:31 -07:00
Erik Abair 672e9cd553 nv2a: Handle SET_SPECULAR_ENABLE 2025-03-28 02:18:42 -07:00
Matt Borgerson 312bd94573 mcpx: Move voice_list_regs to apu.c 2025-03-27 23:33:40 -07:00
Matt Borgerson 2d73e8aafe nv2a: Use root-relative paths to reference parent dir headers 2025-03-27 23:33:40 -07:00
Matt Borgerson 0e18d11d90 nv2a: Rename methods.h -> methods.h.inc 2025-03-27 23:33:40 -07:00
Matt Borgerson a830cc4526 xbox: Disable clang-format for deliberately aligned reg defs 2025-03-27 23:33:40 -07:00
Matt Borgerson 1893b56c38 nv2a/vk: Fix vertex ram buffer dirty bit check 2025-03-19 02:25:33 -07:00
Matt Borgerson b929d4eced nv2a: Drop surface compat clip constraint 2025-03-17 14:48:47 -07:00
Matt Borgerson c3a8b9569f nv2a: Simplify surface clip to scissor size calculation 2025-03-17 14:48:47 -07:00
Logan Stromberg 860bccb722
nv2a: Fix surface clip to scissor origin 2025-03-17 14:32:40 -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
wilkovatch a00820746f
nv2a: Handle texture dimensions not divisible by 4 in S3TC decoder 2025-03-14 18:44:25 -07:00
Matt Borgerson a143f66ce4 nv2a/psh: Handle 3D textures in PROJECT2D mode 2025-03-10 16:13:09 -07:00
Matt Borgerson 6e3dfb36d8 nv2a/vk: Don't set compressed, swizzled when attribute is uniform 2025-03-10 14:23:43 -07:00
Matt Borgerson 4665515d80 nv2a: Group attributes in pgraph_get_glsl_vtx_header 2025-03-10 12:30:16 -07:00
coldhex 3eb22b6b81 nv2a: Explicit float representation for RCC and vertex shader W range 2025-03-08 14:54:18 -07:00
coldhex 63cb75ce84 nv2a: Fix -0.0 clamping of RCC instruction and vertex shader W-output
Xbox rounds -0.0 to the negative range and 0.0 to the positive range. This
commit also restores RCC instruction clamping to be done on the output of
reciprocal calculation (which current Xemu release does) with fix for the
input=Infinity case.
2025-03-08 14:54:18 -07:00