1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00
Commit Graph

210 Commits

Author SHA1 Message Date
Sergey Lipskiy
33806e7170 Fix depth calculation.
Problem:
N64 formula for screen z is screenZ = z/w*viewport.vscale[2]+viewport.vtrans[2]
OpenGL uses z/w, vscale and vtrans are set in glViewport and they always equal.
viewport.vscale[2] can be not equal to viewport.vtrans[2] and in that case
standard OpenGL z compare does not work correct.

Solution:
use N64 formula for screenZ in fragment shader.

Fixed Twine: wrong depth for the arm #115
2015-05-13 10:18:58 +06:00
Sergey Lipskiy
8a4db59a29 Correct RDRAMtoFrameBuffer::CopyFromRDRAM.
Need to set FBO of found buffer as current draw buffer, otherwise rendering can go
into wrong buffer.
2015-05-13 10:18:55 +06:00
Sergey Lipskiy
88e751b13b Implement FBO height correction. Fixed replays in 1080. 2015-05-13 10:18:54 +06:00
Sergey Lipskiy
1b2b9f9865 Replace gDP.colorImage.changed by FrameBuffer::m_changed 2015-05-13 10:18:53 +06:00
Sergey Lipskiy
bc34838db6 Fix pause screen in Conker BFD.
How it work:
- content of previous main frame buffer is copied into depth buffer area.
- CPU applies blur to th eimage in depth buffer area.
- Depth buffer is used as background texture for pause screen.

Solution:
1. Do not use depth buffer FBO as texture. Image must be load from RDRAM.
2. If current color image is depth image and previous color buffer is used as
texture for it, copy content of color image in RDRAM to depth image area.
2015-05-13 10:18:45 +06:00
Sergey Lipskiy
43eac44f91 Correct RDRAMtoFrameBuffer::CopyFromRDRAM :
fuls and fult for gSP.textureTile[0] should be zero.
2015-05-13 10:18:44 +06:00
Sergey Lipskiy
58799e767f Fix scissor in FrameBufferList::renderBuffer for windowed mode.
Fixed top of the screen being cut.
2015-05-13 10:18:43 +06:00
Sergey Lipskiy
59e86b7794 Fix DepthBufferToRDRAM::CopyToRDRAM when multisampling is on. 2015-05-13 10:18:42 +06:00
Sergey Lipskiy
769ab7ac40 Remove async frame buffer reads - it can cause glitches because of wrong frame read.
Example: F-1 PolePosition 99 car tuning menu.
2015-05-13 10:18:38 +06:00
Sergey Lipskiy
8bd1b96e3c Correct FrameBufferToRDRAM.
Fixed out of memory writes in 1080 replay.
2015-05-13 10:18:34 +06:00
Sergey Lipskiy
d4264e18a4 Don't create frame buffer with zero height.
Fixed load from savestates in 1080.
2015-05-13 10:18:33 +06:00
Sergey Lipskiy
7b730096b3 Fix monochrome frame buffers when FSAA is on.
Fixed shadows in Mario Tennis.
2015-05-13 10:18:31 +06:00
Sergey Lipskiy
2b87c0e131 Correct horisontal bounds for input and output buffers in FrameBufferList::renderBuffer
Fixed wrong right bound in Mario Tennis and other games.
2015-05-13 10:18:30 +06:00
Sergey Lipskiy
b085593d2a Major fixes in RDRAMtoFrameBuffer::CopyFromRDRAM.
Fixed Dr.Mario pills
2015-05-13 10:18:28 +06:00
Sergey Lipskiy
d0073fe3a3 Don't clear frame buffer area when copyFromRDRAM option is on. 2015-05-13 10:18:28 +06:00
Sergey Lipskiy
6f40fa430b Fix frame buffer content check in CheckForFrameBufferTexture.
Frame buffer area is cleared in FrameBufferList::saveBuffer.
If scissor does not equal to frame buffer size, clear is incorrect.
Solution: clear frame buffer area without scissoring.

Fixed background in Dr.Mario
2015-05-13 10:18:26 +06:00
Sergey Lipskiy
f946a82e38 Fix replay in Mario Golf:
replay is copied to a area, which is used for depth buffer.
Added check that found frame buffer is not depth buffer.
2015-05-13 10:18:24 +06:00
Sergey Lipskiy
0efce8bb17 Fix FrameBufferToRDRAM::CopyToRDRAM when multisampling is on. 2015-05-13 10:18:23 +06:00
Sergey Lipskiy
67e26af187 Revert "Use VI.real_height to make copy to RDRAM more safe."
Wrong solution - causes bottom black line when copied image is used as
background.

This reverts commit 2186d12c9230be48b1824aaabbee56f135f54d4d.
2015-05-13 10:18:21 +06:00
Sergey Lipskiy
bbeb149df4 Correct FrameBufferList::removeBuffer - set m_pCurrent to NULL if current color buffer isd removed. 2015-05-13 10:18:19 +06:00
Sergey Lipskiy
907a29e313 Fix division by zero in FrameBufferList::renderBuffer
Fixed crash with FB enabled in Top Gear Hyperbike
2015-05-13 10:18:17 +06:00
Sergey Lipskiy
975b54810f Emulate VI manipulations with REG.VI_H_START register.
This emulates horizontal slide effect in Top Gear Overdrive menu.
Fixed issue #17
2015-05-13 10:18:17 +06:00
Sergey Lipskiy
db649b5341 Fix FrameBufferToRDRAM::CopyToRDRAM:
copy to provided address, not to the cached one.

Fixed Top Gear Hyper Bike with FB to RDRAM on.
2015-05-13 10:18:15 +06:00
Sergey Lipskiy
bb6a9b3549 Correct frame buffer end address calculation in FrameBufferList::saveBuffer.
Fixed gfx not showing with fb emulation on in Top Gear Hyper Bike #45
2015-05-13 10:18:15 +06:00
Sergey Lipskiy
34d638a0a3 Don't copy depth buffer if it was not cleared.
Uncleared depth buffer most likely is used as auxilary color buffer.

Fix pause screen in Mickey USA when copy depth to RDRAM is enabled, issue #85.
2015-05-13 10:18:14 +06:00
Sergey Lipskiy
b9257e33b1 Fix RDRAMtoFrameBuffer::CopyFromRDRAM.
Fixed flicker in StarCraft64 logos.
2015-05-13 10:18:12 +06:00
Sergey Lipskiy
47e4f4e8e4 Switch from shader based pseudo-random simplex noise to texture based one. 2015-05-13 10:18:09 +06:00
Sergey Lipskiy
7ed2ed1365 Use VI.real_height to make copy to RDRAM more safe.
VI.height can be larger than actual buffer height. Example: The New Tetris.
2015-05-13 10:18:06 +06:00
Sergey Lipskiy
8c0aa1c804 Fix FrameBufferToRDRAM::CopyToRDRAM when multisampling is enabled. 2015-05-13 10:18:00 +06:00
Sergey Lipskiy
06c7877208 Fix vOffset calculation in FrameBufferList. 2015-05-13 10:17:57 +06:00
Sergey Lipskiy
17b2db7031 Workaround for Mupen64Plus issue with initialization 2015-05-13 10:17:54 +06:00
Sergey Lipskiy
8b570cb273 Fix multisampling. 2015-05-13 10:17:48 +06:00
Sergey Lipskiy
10c4fb801c Implement FBO multisampling. 2015-05-13 10:17:47 +06:00
Sergey Lipskiy
501e8a44b0 Fix FBO in DepthBufferToRDRAM. 2015-05-13 10:17:26 +06:00
Sergey Lipskiy
5af3ed1197 Implement multi-pass bloom post-processing effect. 2015-05-13 10:17:23 +06:00
Sergey Lipskiy
4f1a636c20 Implement PostProcessor class for image post processing effects. 2015-05-13 10:17:22 +06:00
Sergey Lipskiy
fca44abb5f Do not create DepthImageTexture when N64DepthCompare option is off. 2015-05-13 10:17:20 +06:00
Sergey Lipskiy
6ab92eac4f Move zLUT initialization to DepthBufferList::init(). 2015-05-13 10:17:18 +06:00
Sergey Lipskiy
cd758aed08 Rewrite DepthBufferToRDRAM 2015-05-13 10:17:18 +06:00
Sergey Lipskiy
afe91d47d9 Switch to depth texture 2015-05-13 10:17:17 +06:00
Sergey Lipskiy
5460cb32f6 Don't allocate frame buffer with zero height. 2015-05-13 10:17:10 +06:00
Sergey Lipskiy
99b0bc1e59 Fix fb texture offsetS.
Fixed IR scanner in Perfect Dark.
2015-05-13 10:17:08 +06:00
Sergey Lipskiy
17f2195801 Remove combiner update from FrameBufferList::attachDepthBuffer().
WEIRD:
If new combiner is created on CombinerInfo::get().update(), it than
works incorrect. Example: pause screen in Banjo Tooie.
!!!
2015-05-13 10:17:06 +06:00
Sergey Lipskiy
ac5159fe68 Fix RDRAMtoFrameBuffer::CopyFromRDRAM :
restore CHANGED_CPU_FB_WRITE flag after the draw.

Fixed CFB mode.
2015-05-13 10:17:04 +06:00
Sergey Lipskiy
3f6e52b62a Fix flicker in interlaced mode. 2015-05-13 10:16:01 +06:00
Sergey Lipskiy
887504c301 Switch to non-POT textures. 2015-05-13 10:15:25 +06:00
Sergey Lipskiy
99e3869056 Fix drawTexturedRect usage for alternative FrameBufferList::renderBuffer 2015-05-13 10:15:01 +06:00
Sergey Lipskiy
6e01ed9a34 Pass parameters to OGLRender::drawTexturedRect via special structure TexturedRectParams. 2015-05-13 10:14:21 +06:00
Sergey Lipskiy
bc1a5a1f1f Fix frame buffer allocation again.
Check for all possible intersections of frame buffers address space,
remove all buffers, intersected with the new one.
2015-05-13 10:14:18 +06:00
Sergey Lipskiy
ea713f8e0c Remove assync depth copy functionality.
It is important to copy current depth buffer to RDRAM.
Otherwise coronas in PD does not work when in movement.
2015-05-13 10:14:12 +06:00
Sergey Lipskiy
a3d702a4dd Fix detection of frame buffers address space intersection.
Fixed problem of growing frame buffers number.
2015-05-13 10:14:11 +06:00
Sergey Lipskiy
efdfa31eda Make FrameBuffer_CopyDepthBuffer() return bool. 2015-05-13 10:14:09 +06:00
Sergey Lipskiy
c3a8148d0e Fix DepthBufferToRDRAM::CopyToRDRAM - limit max value by 0xfffc. 2015-05-13 10:14:08 +06:00
Sergey Lipskiy
39cbd870ff Add check for NULL pointers in FrameBuffer_ActivateBufferTexture. 2015-05-13 10:14:07 +06:00
Sergey Lipskiy
a6a8d810fb Fix CopyToRDRAM.
Need to set scissor off before using glBlitFramebuffer.
2015-05-13 10:14:05 +06:00
Sergey Lipskiy
7835cfb180 Fix color image height detection for height = 1. 2015-05-13 10:14:02 +06:00
Sergey Lipskiy
3a27056759 Don't write buffer address to RDRAM for CFB buffers. 2015-05-13 10:14:01 +06:00
Sergey Lipskiy
09eea95270 Add separate define for ImageTextures.
Set it on for platforms, which support this functionality.
2015-05-13 10:13:55 +06:00
Sergey Lipskiy
94c381f734 Fix code duplication in FrameBuffer.cpp 2015-05-13 10:13:54 +06:00
Sergey Lipskiy
72ce00157b Code cleanup: Fix class members initialization order in ctors. 2015-05-13 10:13:54 +06:00
Sergey Lipskiy
17479ccbe4 Rewrite FrameBufferList::renderBuffer
Use new method for destination coordinates calculation.
2015-05-13 10:13:47 +06:00
Sergey Lipskiy
0d35f461df Fix integer-float mismatch in FrameBuffer.cpp 2015-05-13 10:13:46 +06:00
Sergey Lipskiy
b31b4cc3f6 Correct renderBuffer usage in FrameBuffer_ActivateBufferTexture. 2015-05-13 10:13:34 +06:00
Sergey Lipskiy
f637e91f22 Replace _SHIFTR( *REG.VI_H_START, 0, 10 ) == 0 check by VI.width == 0 one
Fixed glError in Knockout Kings 2000. The game sets h_start==h_end at start,
thus VI.width is zero but *REG.VI_H_START is not.
2015-05-13 10:13:32 +06:00
Sergey Lipskiy
e21f455686 Don't call glBindImageTexture if it is not supported. 2015-05-13 10:13:28 +06:00
Sergey Lipskiy
768430a234 Implement screen aspect ratio support. 2015-05-13 10:13:26 +06:00
Sergey Lipskiy
6bf0302f19 Fix errors found by code analizer. 2015-05-13 10:13:19 +06:00
Sergey Lipskiy
7548922cfd Add CombinerInfo::update().
Call it in FrameBufferList::attachDepthBuffer() before currentCombiner()->updateDepthInfo
to avoid glError caused by wrong shader program set.

Fixed glError with MarioTennis character selection.
2015-05-13 10:13:18 +06:00
Sergey Lipskiy
805cef4225 Correct isLowerField calculation in FrameBufferList::renderBuffer.
It did not work correct for Donkey Kong (E).
2015-05-13 10:13:14 +06:00
Sergey Lipskiy
2454f70568 Don't call gDPFillRDRAM for frame buffers created in VI_UpdateScreen(),
because VI_ORIGIN is not correct address of frame buffer start.
2015-05-13 10:13:12 +06:00
Sergey Lipskiy
5eac0797f0 Remove VI emulation code, which can't be tested for now.
Star Wars Ep. 1 Racer (E) is fixed.
2015-05-13 10:13:11 +06:00
Sergey Lipskiy
8733c2b3e7 Set m_drawBuffer = GL_BACK in FrameBufferList::destroy().
Fixed crash on rom reset.
2015-05-13 10:13:10 +06:00
Sergey Lipskiy
d121144760 Disable frame buffer activiti when H width is zero. 2015-05-13 10:13:08 +06:00
Sergey Lipskiy
de5c0120ed Fix FrameBufferList::renderBuffer for interlaced modes. 2015-05-13 10:13:08 +06:00
Sergey Lipskiy
5ac57395e9 Fix FrameBufferList::renderBuffer compilation errors. 2015-05-13 10:13:07 +06:00
Sergey Lipskiy
4499a6f966 Fix *BufferToRDRAM destroy().
Fixed run 4mb games after 8mb ones.
2015-05-13 10:13:04 +06:00
Sergey Lipskiy
86cde946e9 Refactor: replace C style OGL_* functions by OGLRender and OGLVideo classes.
OGLRender performs rendering operations.

OGLVideo initializes OpenGL and performes operations with graphics context.
It has platform-dependent implementations.
2015-05-13 10:13:00 +06:00
Sergey Lipskiy
8719d245a4 Fix frame buffer endAddress calculation. 2015-05-13 10:12:58 +06:00
Sergey Lipskiy
604d290fec Fix FrameBufferList::attachDepthBuffer() :
fixed GL_INVALID_ENUM error in glDrawBuffers call.
2015-05-13 10:12:54 +06:00
Sergey Lipskiy
f6ebb311a1 Massive refactoring: move API or OS dependent code to separate files.
Include/enable necessary source files in project files.
2015-05-13 10:12:51 +06:00
Sergey Lipskiy
3352193632 Depth buffer refactor 2015-05-13 10:12:48 +06:00
Sergey Lipskiy
fbf660d4ec Refactor: Make DepthBufferList singleton. 2015-05-13 10:12:48 +06:00
Sergey Lipskiy
d7f4e44674 Frame buffer refactor.
Use std::list as container for frame buffers.
2015-05-13 10:12:46 +06:00
Sergey Lipskiy
bd8b73d5b5 Refactor: Make frame buffer singleton 2015-05-13 10:12:45 +06:00
Sergey Lipskiy
7f6d7e2772 Refactor: rewrite TextureCache.
Store normal textures and frame buffer textures in separate maps.
Replace TextureCache_* functions by methods of TextureCache.
2015-05-13 10:12:44 +06:00
Sergey Lipskiy
23f7f24d35 Refactor: replace CombinerInfo::get().getCurrent() by inline function currentCombiner() 2015-05-13 10:12:39 +06:00
Sergey Lipskiy
0f176dcc4c Refactor: rename ShaderCombiner methods - name starts from lower case letter. 2015-05-13 10:12:37 +06:00
Sergey Lipskiy
7b3423d7de Code cleanup: fix idents for FrameBuffer.cpp 2015-05-13 10:12:35 +06:00
Sergey Lipskiy
2e5ad21ddd Refactor: remove combiner update methods from CombinerInfo and call them
directly for ShaderCombiner object.
2015-05-13 10:12:34 +06:00
Sergey Lipskiy
709f631cbf Refactor: Make Combiner_* functions as members of CombinerInfo. 2015-05-13 10:12:32 +06:00
Sergey Lipskiy
92eb61572e Fix scissor related problems:
- scissor dissable/enable in FrameBuffer_RenderBuffer()
- scissor height in OGL_UpdateStates()
2015-05-13 10:12:20 +06:00
Sergey Lipskiy
a3f9fe2186 Disable scissor in FrameBuffer_RenderBuffer(). 2015-05-13 10:12:09 +06:00
Sergey Lipskiy
e784ea7205 GLES2 fixes in frame/depth buffer initialization. 2015-05-13 10:12:05 +06:00
Sergey Lipskiy
898a189f89 Fixed Combiner_UpdateCombineFBInfo() call. 2015-05-13 10:12:03 +06:00
Sergey Lipskiy
7166d0aacf Fix hardware lighting. 2015-05-13 10:11:41 +06:00
Sergey Lipskiy
3d9e48230a Fix FrameBuffer_RenderBuffer for GLES2. 2015-05-13 10:11:39 +06:00
Sergey Lipskiy
caf4353295 Guard GLES2 incompatible code in FrameBuffer.cpp and gSP.cpp 2015-05-13 10:11:39 +06:00
Sergey Lipskiy
889b889847 Replace GL_DRAW_FRAMEBUFFER by GL_FRAMEBUFFER in GLES2 compatible code. 2015-05-13 10:11:38 +06:00
Sergey Lipskiy
90f8e4c2f3 Remove glDisable( GL_FOG ). 2015-05-13 10:11:37 +06:00
Sergey Lipskiy
6219ee02bf Rewrite RDRAMtoFrameBuffer::CopyFromRDRAM
Use OGL_DrawTexturedRect to render the texture.
2015-05-13 10:11:37 +06:00