Commit Graph

4450 Commits

Author SHA1 Message Date
James Benton
2efc29c929 coreinit: Fix fastMutexHardLock not updating owner thread's fastMutexQueue. 2016-08-24 18:04:16 +01:00
James Benton
ac5bae43ec coreinit: Check fastMutexQueue in calculateThreadPriorityNoLock. 2016-08-24 18:04:16 +01:00
James Benton
52440e43aa coreinit: Add some asserts to check for valid pointer to coreinit_mutex.cpp 2016-08-24 18:04:16 +01:00
James Benton
7ced9d7108 coreinit: Fix OSCancelThread not checking cancel state before exiting. 2016-08-24 18:04:16 +01:00
James Benton
15aafda7fe coreinit: Fix OSSetThreadCancelState implementation. 2016-08-24 18:04:16 +01:00
James Benton
7eab94b164 coreinit: Cleanup semaphore functions.
All the previous commit did was make it harder to read... :/
2016-08-24 18:04:16 +01:00
James Benton
211708aea0 coreinit: Re-re-reverse event objects. 2016-08-24 18:04:16 +01:00
James Benton
219c41faa5 decaf-sdl: Fix implicit cast warning. 2016-08-24 18:04:16 +01:00
James
d1fd706862 Merge pull request #355 from achurch/drawbuffers
opengl: Avoid unnecessary glDrawBuffers() calls.
2016-08-24 12:37:00 +01:00
Brett Lawson
5836891e1f Re-reverse OSSemaphore for coreinit.rpl accuracy. 2016-08-23 19:42:05 -07:00
Brett Lawson
f1956660cc Re-reverse OSEvent to improve coreinit.rpl accuracy. 2016-08-23 19:41:49 -07:00
Brett Lawson
da32585b09 Implement OSFastMutex and OSFastCond.
Fuck me, these were a pain in the ass.  Let's see if they
cause any regressions...  My god...
2016-08-24 00:42:15 -07:00
Andrew Church
3938b329f1 opengl: Avoid unnecessary glDrawBuffers() calls. 2016-08-24 04:00:31 +09:00
Brett Lawson
eedc9ae660 Improve handling of GLSL endian-swap generation.
It now handles the case where 8-In-32 swapping is used on
FMT_8_8_8_8 by essentially swizzling the components to
effect the needed swapping.
2016-08-23 11:25:44 -07:00
Brett Lawson
40c009b0c0 Drop strided memcpy code which is no longer used. 2016-08-23 11:25:44 -07:00
Brett Lawson
0fc6b15456 Fix backwards detached thread shutdown logic. 2016-08-23 11:25:44 -07:00
Andrew Church
1349825103 opengl: Suppress glCheckFramebufferStatus() if framebuffer is unchanged. 2016-08-23 18:44:29 +09:00
Andrew Church
3c5c43e98d opengl: Cache additional GL state data.
This reduces the number of GL calls per frame by around 25-75%
depending on frame complexity.
2016-08-23 18:44:29 +09:00
Andrew Church
ff69d4d583 opengl: Perform EVENT_WRITE_EOP immediately instead of saving it.
The "end of pipeline" referred to by this command is the internal
hardware pipeline, not the entire command stream.  The current
OpenGL driver has no pipeline, so the command should be executed
immediately.
2016-08-23 02:26:14 -07:00
Brett Lawson
5c956487bb Added logging for thread starting/stopping. 2016-08-23 02:26:04 -07:00
Brett Lawson
ecfa12d3c5 Implement stub for MIXUpdateSettings.
A lot of games SPAM this call making it hard to debug...
2016-08-23 02:26:04 -07:00
Brett Lawson
22fb31ec5b Use an assertion rather than blank if for thread deallocators.
This will allow us to catch cases where we are not giving
notifications back to PPC code when they expect it.
2016-08-23 02:26:04 -07:00
Brett Lawson
cb3153659c Reimplement OSExitThread to be more CafeOS accurate. 2016-08-23 02:26:03 -07:00
Brett Lawson
e124d13599 Correct issue with interrupt handling across thread switches.
True coreinit.rpl behaviour is that interrupt are disabled whenever
there is a scheduler lock active.  We have elided this due to our
C++ code being uninteruptible, but this causes issues when games
already have interrupts disabled and then do a rescheduling
operation.  We have to force-enable them for the switch instead.
2016-08-23 02:26:03 -07:00
Brett Lawson
410f18a5fe Cleanup GHS exception initialisation. 2016-08-23 02:26:03 -07:00
Brett Lawson
07d519ca3c Fix alignment issue with teenyheap.
This caused allocations that fit exactly to fail to be
allocated due to adjSize being increased to allow alignment
as a pre-step.  This modifies it to check for the ability
to do alignment on a per-block basis instead.
2016-08-23 02:26:03 -07:00
Brett Lawson
8ce36d95c2 Fix bug with DCZeroRange rounding in wrong the direction. 2016-08-23 02:26:03 -07:00
Brett Lawson
79adccba44 Do not check for interrupt state during lockScheduler. 2016-08-23 00:31:41 -07:00
Brett Lawson
ab45111301 Merge pull request #347 from achurch/shader-endian
opengl: Use pack/unpack instructions for endian conversion in shaders.
2016-08-22 23:04:51 -07:00
Brett Lawson
4c5c575ee0 Merge pull request #346 from achurch/shader-updates
opengl: Detect changes to shader memory and recreate as appropriate.
2016-08-22 23:03:52 -07:00
Brett Lawson
36c39967fd Reimplemented OSMutex and OSCondition completely.
This is a re-reverse of the above mentioned structures based
on all knowledge gained since their first pass.  This fixes
some minor differences which were not caught before.
2016-08-22 23:02:13 -07:00
Brett Lawson
be5b38c7f6 Implement thread deallocator thread. 2016-08-22 22:16:31 -07:00
Andrew Church
b2611ef021 opengl: Use pack/unpack instructions for endian conversion in shaders. 2016-08-23 07:42:03 +09:00
James
4da65e2fa7 Merge pull request #344 from achurch/uniform-upload
opengl: Only upload uniform registers which have been recently written.
2016-08-22 23:34:19 +01:00
Andrew Church
6a8ad8ce6e opengl: Detect changes to shader memory and recreate as appropriate. 2016-08-23 06:39:04 +09:00
James
b262c33a79 Merge pull request #345 from achurch/alpha-test-early-z
opengl: Disable early-Z when alpha tests are enabled.
2016-08-22 22:19:17 +01:00
James Benton
cfb8ad034f gx2: Handle GX2Invalidate on aperture addresses. 2016-08-22 22:17:31 +01:00
Andrew Church
d3d3727122 opengl: Fix transform feedback buffer offset update for non-points.
The meaning of the OpenGL query TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
is not well-defined by the specification, and the API reference
documentation claims that it returns a vertex count, but in fact it
returns a primitive count as the name suggests, so we need to
calculate the vertex count ourselves when updating buffer offsets.
2016-08-22 22:10:43 +01:00
Andrew Church
a8064e43d5 opengl: Fix failure to sync with driver before reading data buffers.
Since safely reading from a persistently mapped buffer requires a
glFinish() call, we instead avoid maps entirely for output buffers
and call glGetNamedBufferSubData() to let the driver sync for us
(with potentially finer granularity).
2016-08-22 22:10:41 +01:00
Andrew Church
ce4d631280 opengl: Reduce frequency of transform feedback queries.
If the program performs several draw operations in a row before calling
GX2SaveStreamOutContext(), we don't need to update our copy of the
current offset on every draw.

Also move transform-feedback code to its own source file to make it
easier to locate.
2016-08-22 22:10:40 +01:00
Andrew Church
da35ee9461 opengl: Don't abort on overlapping occlusion queries.
We could potentially see a query started without the previous query
having ended, if the program decides to reset the GPU (on a timeout,
for example) in the middle of the previous query.
2016-08-22 22:10:28 +01:00
Andrew Church
0c4797f2d9 coreinit: Signal a store to the graphics driver for LCStoreDMABlocks().
This operates outside the normal data cache behavior and is effectively
an uncached write to the destination buffer.
2016-08-22 22:07:47 +01:00
Andrew Church
51e7707e74 opengl: Use DCFlush()/DCStore() as the dirty-resource signal. 2016-08-22 22:07:36 +01:00
Andrew Church
2d35fdd70d opengl: Disable early-Z when alpha tests are enabled.
Hardware alpha test is implemented with OpenGL discard instructions,
so we need to disable early-Z even if KILL_ENABLE is not set.
2016-08-23 05:49:41 +09:00
Brett Lawson
79f41cf063 Fix OSUnlockMutex allowing cancel while still holding lock.
This also removes an unneccessary reschedule.  Since if the
thread still owns the mutex and only decremented its recursive
count, then no other thread can take it yet anyways.
2016-08-22 12:27:22 -07:00
Andrew Church
b7173fb088 opengl: Only upload uniform registers which have been recently written.
"Recently" is defined by an update generation counter; the counter is
stored with each uniform(*) when one of its component registers is
written, and is incremented and saved with a shader after uploading
changed uniforms, where "changed" is detected as a uniform whose last
write generation is not less than the shader's last upload generation.

(*) To be precise, uniform change state is tracked in groups of 16
uniform vectors (64 registers), as a balance between the cost of
uploading too much unchanged data to the host GPU and the cost of
checking the changed status of each uniform individually.

In addition to reducing the amount of data uploaded to the host GPU,
this typically reduces the number of GL calls per frame by 5-10% (due
to cases where no uniforms have changed at all), and as a bonus it
significantly improves the replay speed of GL trace files.
2016-08-23 02:33:35 +09:00
Andrew Church
6bb05c8955 opengl: Don't divide blend color components by 255.
The register values are already floats, so they should be used as is.
2016-08-22 21:39:46 +09:00
Brett Lawson
239032f62c Oddly GX2InitDepthBufferRegs allows invalid surface formats... 2016-08-22 02:42:41 -07:00
Brett Lawson
932a70ae5a Fix semantic binding to behave properly at the end.
Semantic bindings appear to use 0xff as a end delimiter,
so looping should stop when we encounter it.
2016-08-22 02:42:41 -07:00
Brett Lawson
340d5b8de7 Fix GX2Invalidate failing with no modes set.
There should not be a packet dispatched when now mode
invalidation is actually occuring (as per gx2.rpl).
2016-08-22 02:42:41 -07:00