Commit Graph

913 Commits

Author SHA1 Message Date
PatrickvL beac314243 Processed review remarks 2020-11-25 21:33:46 +01:00
Silent 7af503b90c
Do not try to resolve the palettized texture if there is no palette bound
Fixes a crash in DRIV3R
2020-11-25 20:39:03 +01:00
Silent 4d8c4fbb68
Fix D3DDevice_SetPalette and D3DDevice_SetPalette_4 not calling to guest code
Fixes memory leaks in SetPalette functions, as they are now able
to reference count and destroy palette resources.
Also fixes a very poor SetPalette_4 LTCG function
2020-11-24 20:04:53 +01:00
Luke Usher e0b62dde9d d3d: experimental creation of surfaces as textures 2020-11-24 17:06:53 +00:00
Silent 36e6349de5
Fix a wrong NestedCallCounter in D3DDevice_SetRenderTarget_0 2020-11-24 18:04:49 +01:00
Luke Usher 21c27b416f
Merge pull request #2032 from RadWolfie/dsound-fixes
Fix CDirectSoundStream_GetStatus for difference output over time
2020-11-21 12:37:45 +00:00
Luke Usher 9d714c4488
Merge pull request #2033 from NZJenkins/viewport_fixes2
Improve viewport calculations
2020-11-21 12:37:19 +00:00
Anthony 46ec7516fa Improve viewport calculations and 2D rendering
- SetViewport tracks the Xbox viewport values instead of setting the viewport,
so we can calculate what we need from them
- Rework GetViewportOffsetAndScale and scaling methods
- Vertex shader programs do not depend on D3D9 viewport to transform verts
- Account for backbuffer scale
- Add some D3DSWAP flags and LOG_TEST_CASE for unhandled usage
2020-11-21 23:41:16 +13:00
Silent 43eefa8041
Improve the D3D_DestroyResource__LTCG patch
EDI register is unlikely to be trashed, but use a naked function anyway
Added logging, same as the non-LTCG DestroyResource
2020-11-17 20:44:26 +01:00
Silent 74333af9c0
Remove hacks skipping guest resource removal if they are bound
Fixes games running out of guest memory:
- Outrun 2
- Monster Garage
- probably many more

Removes "Skipping Release of..." test cases
2020-11-17 20:33:34 +01:00
Silent 6892591084
Take vertex stream offset into the account when caching VBs
Fixes exploding vertices in TOCA Race Driver.
2020-11-16 23:52:18 +01:00
RadWolfie 1c2c02f47b dsound: fix CDirectSoundStream_GetStatus for difference output over time 2020-11-15 16:38:03 -06:00
Silent 770d062014
Fix a merge error in CxbxImpl_SetViewPort 2020-11-15 22:03:43 +01:00
Silent 67c31c650b
Const qualify a few parameters in XbVertexShader.cpp functions
No functional change, just preventing future me from a typo I made.
Const-qualifying those parameters would have prevented it.
2020-11-15 22:03:43 +01:00
Silent dab1da6caf
Fix X_VERTEXSHADER_FLAG_PROGRAM flag for XDK-3948
In this XDK X_VERTEXSHADER_FLAG_PROGRAM appears to have a value of 4,
not 16. Adjusted the code accordingly and added test cases to verify
that assumption.
2020-11-15 22:03:43 +01:00
Silent c3568f6ea3
Fix D3DDevice_SetVertexShader_0 not calling a trampoline
Fixes NASCAR Heat 2002 rendering (again)
2020-11-15 20:28:24 +01:00
patrickvl 561f76c067 Fixes after rebase
Write our viewport constants after copying dirty constants from PGRAPH
Fixes geometry flickering in some titles
Miscellaneous cleanup (renaming, indentation, function inlining)
Start stream offset from slot offset rather than vertex stride
Vertex declaration debug logging
Xbox clamps fog in pixel shader (not vertex shader)
Fix typos
Introduce HostStreamNumber, to use Xbox stream index on host
Pass HostStreamNumber to Activate
Let CountActiveD3DStreams return an actual count
Call ConvertStream with a regular counter instead of pretended stream index
For clarity in ConvertStream, discern between XboxStreamNumber and HostStreamNumber (even though they're the same value)
Don't check CxbxVertexDeclarationNeedsPatching in GetNbrStreams
Remove now unused CxbxVertexDeclarationNeedsPatching
Rename IndexOfStream into StreamIndex
Remove unused DeclPosition
Rename CurrentStreamNumber into XboxStreamIndex
Reduce size of VertexElements array to X_VSH_MAX_ATTRIBUTES (16)
Rename StreamNumber into XboxStreamNumber
Set XboxStreamIndex only once
Assert VertexStreams won't be accessed outside it's size
Assert VertexElements won't be accessed outside it's size
For AUTONORMAL, set UsageIndex to 0 instead of (according to docs) incorrect 1
Derive NeedPatching from XboxVertexElementByteSize, instead of setting it alongside
Set dummy vertex buffers using HostStreamNumber argument name
Clamp output fog in vertex shader HLSL.

Also, cleanup passthrough HLSL to write outputs identical to vertex shader template HLSL
Turns out, the scale and offset we send to the Xbox passthrough program, should just be identity, regardless resolution or scale.

This seems to fix sub-pixel differences, noticeable when F7-toggling passthrough mode between our dedicated HLSL vs the Xbox program.
Let F7 toggle passthrough based rendering between an Xbox (-derived) shader or our dedicated HLSL shader. Also fixed the index of the -96 and -95 (scale and offset) passthrough constants. F7-toggling, you can see a slight sub-pixel difference between the two modes, probably related to how scale and offset are calculated and used differently between the two approaches. With this, we can postpone the decision on how we should handle passthrough mode.
Fixup use render target width rather than backbuffer width
Multiply instead of divide in ReverseScreenspaceTransform
Don't scale Z in passthrough
test case GTA III sprites
Scale viewport X and Y as well as height.
Fixes cases where X and Y are nonzero e.g. DoA3 character select
Tidy and simplify GetViewPortOffsetAndScale a bit
Refactor passthrough HLSL to call reverseScreenspaceTransform, which not only uses offset and scale constants, but is now also configurable to handle RHW transformed positions.

This takes us one step closer to merging passthrough HLSL with our generic vertex shader HLSL
- IVB passes the position register in full (FLOAT4 instead of FLOAT3)
Fixes samples that pack 2d coords and texcoord into position
- Remove POSITIONT semantic, as we don't expect it in our shaders or pass it to the fixed function pipeline
scaley
rhw
Don't scale texcoords by default. Not all texcoords are used for texture fetches
LoadVertexShader_4 avoids trashing EAX parameter
Apply g_RenderScaleFactor to passthrough constants.

Also renamed ViewPort into HostViewPort. Added Comments, fixed typo's, marked unused code.
Extract D3DDevice_SetViewPort into CxbxImpl_SetViewPort

Also fix build
Extract D3DDevice_SetRenderTarget into CxbxImpl_SetRenderTarget, and call that from Direct3D_CreateDevice_End
Split off CxbxUpdateHostTextureScaling()
Typos
Separate setting host textures from texture coord scaling
Call UpdateHostTextures before state apply calls
Fix build
Prepare for more accurate calculation of passthrough constants zero and one (not functional yet).

Plus some cleanup
While at it, implement the conversion of remaining TextureStageStates in a similar way as TextureCoordinateIndex (mentioning known values explicitly in code, LOG_TEST_CASE or EmuLog for unsupported/unexpected input values).
Fix TSS_TCI conversion (and some typos, and reordering of code)
Map texture coordinate indices in fixed function mode only

(cherry picked from commit 32878cac2fc3682ac057af4f74f495d994fa13b8)
- Revert to scaling coordinates for linear textures
- Use texture state to map from stages to texcoord indices
- Add Get method to XboxTextureState

(cherry picked from commit 39dd0144851e49ea2452506293dca5e1f532ac97)
Fix XDK Ripple sample regression in CxbxSetVertexShaderPassthroughProgram, by not setting our own calculations in constant zero and one (and instead rely on Xbox code setting those through pushbuffer commands)
Remove texture normalization from vertex buffer conversion.
Instead, apply the texture scale factor in our vertex shader HLSL
This removed yet another reason for buffer patching, simplifying code more and speeding up rendering a little.

The Ripple XDK sample regressed because of this (or an earlier commit?), which might (or might not) be related to vertex explosions seen in some games.

(That, or it has something to do with the use of non-standard registers for passing in texture coordinates - in any case, a fix for this will probably improve a few games as well).
Set vertex shader constants based on pgraph (and write then to there as well)
Set constant zero and one for passthrough programs
For this, introduce and call CxbxImpl_SetScreenSpaceOffset
Renamed all host update functions to : CxbxUpdateHost...
As it turns out, texture normalization only applies to pre-transformed (X_D3DFVF_XYZRHW) vertex declarations (not just FVF based declarations)!

So, replace final use of VshHandleIsFVF (allowing removal of it's declaration) with GetXboxVertexAttributeFormat(), and update CxbxVertexBufferConverter::ConvertStream to use the Xbox AttributeFormat (instead of decoding FVF's).
With this, there's also no more use for DxbxFVF_GetNumberOfTextureCoordinates nor DxbxFVFToVertexSizeInBytes, so these are now removed as well.

I verified this still renders all XDK samples identically, but some games might improve due to this (especially if they have separate sets of texture-coordinates in a single stream). There's a low chance for regressions.
Remove our final SetFVF call on host, by composing an Xbox vertex attribute format according to the registers that have been written to in CxbxImpl_SetVertexData4f

This also allowed to clean up the code that copies data from g_InlineVertexBuffer_Table to g_InlineVertexBuffer_pData (a pass that we might even be able to skip?)
Extract the code from our D3DDevice_Begin patch towards CxbxImpl_Begin
Rename EmuFlushIVB into CxbxImpl_End
With this, all use of g_InlineVertexBuffer* symbols is limited to XbVertexBuffer.cpp
So, remove all extern declarations on g_InlineVertexBuffer* symbols.

Remove implementation and calls to HLE_write_NV2A_vertex_attribute_slot,
because CxbxSetVertexAttribute already does that with less overhead,
which is already called in CxbxImpl_SetVertexData4f.
Some comments on how we might handle vertex shader constants later on
Disable two LOG_TEST_CASE's
Simplify CxbxSetVertexAttribute
Extract CxbxImpl_SetVertexData4f from our D3DDevice_SetVertexData4f patch
Move the implementation to XbVertexBuffer.cpp
There, extract the part about setting default register values towards a separate function, called CxbxSetVertexAttribute
In CxbxImpl_SetVertexData4f, read starting values for all attributes
For this, refactored HLE_read_NV2A_vertex_attribute_slot into HLE_get_NV2A_vertex_attribute_value_pointer
Convert it's float pointer result to required data type per g_InlineVertexBuffer_Table field.
Use the same function in CxbxSetVertexAttribute to write default attribute values
In CxbxImpl_SetVertexShader, call CxbxSetVertexAttribute to set default values for attributes missing from vertex shader
Remove duplicate reset of g_Xbox_VertexShader_FunctionSlots_StartAddress
Remove bNeedRHWReset remnants
Don't set fixed function mode when we don't know what to do
Fixes Amped menu graphics
Make sure we process stream elements in order of offset
Use clamped reciprocal for defined behavour with rcp(0)
Remove FVF vertex buffer fixups
Reset vertex shader address when setting the passthrough program
Revert "Postpone calling EmuParseVshFunction until after shader cache miss, this should speed up rendering a little"

This reverts commit a4b647e6fe365ca414815afcf813431e7080546d.

Reason : EmuParseVshFunction sets the size needed for ComputeHash, so we can't avoid it!
Silence compiler warning
Reset g_Xbox_VertexShader_FunctionSlots_StartAddress to zero for passthrough mode

Also prepared storing g_Xbox_VertexShader_Ptr (See CXBX_USE_GLOBAL_VERTEXSHADER_POINTER).
Postpone calling EmuParseVshFunction until after shader cache miss, this should speed up rendering a little
Avoid calling trampoline when not assigned
Write binary Xbox shader to our slots for passthrough shaders
Use a version-dependent getter for shader tokens
Make sure EmuParseVshFunction never goes out of bounds (by putting a FLD_FINAL at slot 136 in CxbxSetVertexShaderSlots)
Document vertex shader flags and set more of them in XboxVertexShaderFromFVF
Oops
Took some stuff from NZJenkins dca881d61f
Postpone host update of vertex declaration and shader towards draw-time.
Introduce new fixed-function status boolean
Conversion of FVF to internal vertex shader INCLUDING texture Dimensions.
Avoid treating internal vertex shader as older version
Some more cleanup

Status of this is, that some XDK samples lack geometry, not sure if this is the result of this commit or a prior one. NZJenkins has a branch that shares history with this one, that does show geometry, so perhaps we should mix & match the best parts of these two branches, and continue with the result?!?
Call UpdateViewPortOffsetAndScaleConstants only from CxbxUpdateNativeD3DResources (and after CxbxTransferVertexShaderConstants)
Extracted code into CxbxTransferVertexShaderConstants function, using new (renamed) HLE_read_NV2A_vertex_constant_float4_ptr function
Introduce HLE_read_NV2A_vertex_program_slot and HLE_read_NV2A_vertex_constant_slot functions
Fix missing nv2a registers
Differentiate between two versions of X_D3DVertexShader
In HLE_write_NV2A_vertex_attribute_slot assert failure in pgraph_handle_method()
Call HLE_init_pgraph_plugins() from a better suitable place (EmuD3DInit)
Processed code review comments : Fixed a few typo's, document SetVertexShaderInput test-cases, rename inaccurate symbol names, add more comments, add LOG_TEST_CASE("Limiting FVF to 4 textures")
Start using GetXboxVertexStreamInput everywhere g_Xbox_SetStreamSource was accessed
Removed CreateVertexShader patch and implementation
Cache VertexDeclarations based on hash of their contents
Store FVF based VertexAttributeFormat in global variable
GetXboxVertexAttributeFormat returns a pointer now
A lot of cleanup (like IsValidCurrentShader and VshHandleIsValidShader are no longer needed)
Fix post-processing of elements for D3DDECLMETHOD_CROSSUV (normal tesselation)
Move and rename global variables.

Also, partly picked conversion of tesselation-declarations.
Reorder and comment vertex-shader related types
Removed now-obsolete CxbxVertexShader struct, instead use CxbxVertexDeclaration and renamed all references to that.
Start using GetXboxVertexAttributes, which calls the new (temporary) XboxFVFToXboxVertexAttributeFormat function for FVF vertex shader handles)

Also removed the now-obsolete SetCxbxVertexShaderHandle() and SetCxbxVertexDeclaration() functions
Introduce GetXboxVertexShader and GetXboxVertexAttributes getters (both not yet used)
In D3DDevice_SwitchTexture use a switch statement instead of an array plus for-loop
Implement our patch on SetVertexShaderInput and introduce GetXboxVertexStreamInput, a getter that honors this g_Xbox_SetStreamSource override (not yet used)
Disabled patches on D3DDevice_GetVertexShaderInput and D3DDevice_SetVertexShaderInputDirect.
Call trampoline in D3DDevice_SetVertexShaderInput (and add a LOG_TEST_CASE)
Disabled patch on D3DDevice_SelectVertexShaderDirect (since all it does, is forward to D3DDevice_SelectVertexShader, which we DO patch)
Call trampoline in D3DDevice_SetVertexShader
CxbxImpl_LoadVertexShader must not skip first program DWORD
Explicit padding in X_VERTEXSHADERINPUT to avoid potential alignment issue
Make Xb2PCRegisterType more compact, and let it support D3DDECLUSAGE_POSITIONT
WIP
Introduce CxbxFVFToXboxVertexAttributeFormat, a function that converts an Xbox FVF handle to the Xbox Vertex attribute format struct. This, so that in a next step we can convert the Xbox Vertex attribute format struct to a CxbxVertexDeclaration (or maybe just straight to a host declaration)
Implement CxbxImpl_LoadVertexShader much closer to reality
Define X_D3DVertexShader.Flags values
CxbxImpl_SelectVertexShader : Only store Handle when it's non-NULL (which must always be a VertexShader, so LOG_TEST_CASE when not)
Use CxbxSetVertexShaderSlots tooling function to reduce duplicate code
2020-11-02 21:39:40 +01:00
Silent 2875342b5c
Fix a resource leak in D3DDevice_Swap 2020-11-02 17:52:56 +01:00
Silent 65d5abc813
Implement D3DDevice_DeleteVertexShader_0
Test case now can be removed, as it existed only due
to no known games using this function.
2020-11-02 17:52:56 +01:00
Silent feef6ffb3d
Refactor LTCG versions of Direct3D_CreateDevice
* Make Direct3D_CreateDevice_4 naked to remove
   the risk of trashing parameters
* Split Direct3D_CreateDevice_16 into two separate functions
   with different calling convention
2020-11-02 17:52:55 +01:00
Silent cbe534cb54
Patch D3D_CommonSetRenderTarget 2020-11-02 17:52:55 +01:00
Silent 62af56b67a
Fix D3DDevice_SetPixelShader_0 corrupting the stack 2020-11-02 17:52:54 +01:00
Silent 8b7f4a5027
Patch D3DDevice_SetRenderTarget_0 and factorize implementations
CreateDevice would try to call an inexistant guest trampoline,
but in fact we only needed to call the host implementation
2020-10-31 14:44:13 +01:00
Silent 16efb84eb9
Fix affinity for EmuCreateDeviceProxy thread 2020-10-28 17:47:34 +01:00
Luke Usher 5fe769b906
Merge pull request #2002 from PatrickvL/ps_const_simplfy
Simplfy pixel shader constant handling;
2020-10-28 13:40:57 +00:00
PatrickvL 44f0aee5d4
Merge pull request #2012 from CookiePLMonster/interlocked-lockcounts
Interlocked lockcounts
2020-10-28 11:20:11 +01:00
patrickvl c09a90e459 Remap host pixel shader constant indexes, so that all constants can be set using just one call to SetPixelShaderConstantsF
Also, added more notes and code on the PSDef.PSTextureMode field (which lies outside of the render state pixel shader range), and skip the values of the final combiner constants when checking for uniqueness of pixel shader definitions.
2020-10-27 18:22:59 +01:00
patrickvl eae97f3f07 Optimize setting host pixel shader constants, by collecting all values and set them using a single call.
Also remove one more unused variable
2020-10-27 18:22:59 +01:00
patrickvl 337946db25 Simplfy pixel shader constant handling;
Since we've ported over to Direct3D 9, and we're using pixel shader version 1.4, we've got more than enough constants available to remove the need for constant packing.

Also, there was a left-over patch on SetPixelShaderConstant which must no longer be applied, since nowadays we read constant values straight from their corresponding render state slots.
This also implies we no longer need to declare the final combiner constants as part of the shader assembly, because these 2 are also read from their corresponding xbox render state slots, and thus can be transferred to host on each update.

This will likely improve the output of pixel shaders which stay otherwise unchanged but rely on changing constant values.
2020-10-27 18:22:58 +01:00
RadWolfie f8593e692d
Merge pull request #1993 from CookiePLMonster/dsound-improvements-alt
DSound improvements (alternative volume heuristics)
2020-10-26 17:29:31 -05:00
Silent dd0e331528
Thread safety fixes for ERWLOCK 2020-10-26 20:55:24 +01:00
Silent 4323e401d8
Thread safety fixes for RtlCriticalSection 2020-10-26 20:51:19 +01:00
Silent 4dd9aaeed7
Guard against nested SetTransform/MultiplyTransform calls
In the case of 25 to Life, MultiplyTransform calls SetTransform
which corrupted the host's internal state. Introduce a guard variable
to ensure we call to host only once per the patch chain and keep
the internal state pristine
2020-10-26 18:54:39 +01:00
Silent acff986fe1
Add NestedPatchCounter 2020-10-26 18:50:54 +01:00
Silent e81c9fecb8
Unpatch D3DDevice_GetTransform and call to guest in SetTransform and MultiplyTransform
Fixes (not yet visible) rendering in Burnout 3, possibly because to it
having an unpatched LTCG-specific GetTransform or reading from
the D3D state directly.
2020-10-25 18:53:34 +01:00
Silent 5592f81c02
Implement D3D_BlockOnTime_4 2020-10-25 18:52:20 +01:00
Luke Usher 9a773ef7ac
Merge pull request #2003 from CookiePLMonster/fix-apu-timer
Fix APU timer ticking at wrong frequency
2020-10-25 01:41:56 +01:00
Silent d5adbb2ab3
Refactor APU, TSC and ACPI timers to use shared code 2020-10-24 23:53:15 +02:00
Silent 709a3508ee
Pre-divide reverse scale in reverseScreenspaceTransform
This should improve numerical stability of the reverse transformation
when D24 depth is used by the game, as this caused viewport.z
to be very large (0xFFFFFF).
2020-10-24 23:18:59 +02:00
Silent 9b2c1ba2ce
Submit viewport scale and offset in one batch 2020-10-24 22:36:56 +02:00
Silent 0f88b77bfe
Fix APU timer ticking at wrong frequency 2020-10-24 13:09:37 +02:00
patrickvl a412c80b24 Fix how our current pixel shader conversion calculates the final combiner special purpose register 'sum' : it was accidentally multiplying instead of adding it's arguments! 2020-10-23 01:05:24 +02:00
Luke Usher 1ee123900b
Merge pull request #1982 from ergo720/InlineVertexBuffer_as_vector
Use std::vector for g_InlineVertexBuffer_Table instead of realloc
2020-10-21 08:38:02 +01:00
Luke Usher 4e6068f6b4
Merge pull request #1998 from CookiePLMonster/thread-creation-delay
Simplify thread creation logic, remove hardcoded delays and tighten affinity changes
2020-10-21 08:36:10 +01:00
ergo720 a4d1807b4c Use std::fill and std::copy where possible 2020-10-20 21:26:43 +02:00
ergo720 47ea099a92 Use std::vector for g_InlineVertexBuffer_Table instead of realloc 2020-10-20 21:26:43 +02:00
Silent ea98d4bdea
Add a fallback to CopyRects for cases which StretchRect can't handle
Fixes menus in World Racing 2 because CopyRects tries to copy
a texture to texture.
2020-10-20 19:40:46 +02:00
Silent b7b2c24fdb
Start child threads suspended and finalize their initialization before resuming
* Closes a possible race condition where a child thread uses
ThreadHandle or dwThreadId AND starts before _beginthreadex even returns
* Allows to remove hardcoded sleeps "slowing down" parent thread
execution in favour of more reliable affinity mask changes on the child thread

Test case: The Warriors and its race condition on event creation
(child thread waits on the event parent thread creates AFTER spawning
the child thread)
2020-10-19 23:59:22 +02:00
Silent b04980a150
Remove hStartedEvent
It doesn't seem to be useful anymore (does not protect any thread-unsafe
initialization), and it was encouraging the OS scheduler to keep executing
the child thread before returning the parent thread from PsCreateSystemThreadEx

Test case: The Warriors and its race condition on event creation
(child thread waits on the event parent thread creates AFTER spawning
the child thread)
2020-10-19 21:49:46 +02:00
Silent 6f27d335f7
Change ThreadId parameter type to PWORD
Purely cosmetic change, does not change any functionality.
2020-10-19 21:27:16 +02:00
Silent 2d33a1bb6b
Implement better Blue-to-Alpha
Fixes pixel shaders decoding BINK videos (together with the previous commits).
Cleaned up a few TODOs.
2020-10-18 16:46:57 +02:00
Silent cc98adb38c
Fix SimplifyLRP remapping to wrong intermediate registers 2020-10-18 15:49:17 +02:00
Silent 21092a5d38
Support multiple rects in Clear 2020-10-17 14:15:53 +02:00
Anthony Miles 4b85f0949a
Scale viewport X and Y as well as height.
Fixes cases where X and Y are nonzero e.g. DoA3 character select
2020-10-17 14:06:29 +02:00
Silent fa10dcfd29
Refactor SetMixBinVolumes
* Clears the code up
* Picks the buffer volume from the maximum speaker volume
2020-10-17 12:40:57 +02:00
RadWolfie d9ec4342d7
Merge pull request #1995 from CookiePLMonster/dsound-improvements-split
Dsound improvements (split)
2020-10-17 05:37:41 -05:00
Silent 6d2e598c8c
IDirectSoundBuffer_SetBufferData: Fix 0 byte buffers not stoppping audio
NASCAR Heat 2002 (and probably plenty of other titles) submit
an empty buffer to stop audio. Handling this properly fixes
issues with audio samples lingering throughout the session.
2020-10-17 12:33:44 +02:00
Silent 3dcf1e67e0
Fix a copypaste typo in GetFormat_4034_lower and change its signature
Allows GetFormat() to be used more cleanly
2020-10-17 12:31:26 +02:00
Silent 0f7ce3b527
Treat identical X_D3DResource objects with a different address as one
This fixes issues where resource objects got relocated in memory or
reused without having been released properly first.

Fixes black cars in NASCAR Heat 2002
2020-10-17 12:24:49 +02:00
Luke Usher 8ae094d730
Merge pull request #1986 from x1nixmzeng/debugger-multi-xbe
Update cxbx-debugger to support switching XBEs during emulation
2020-10-15 08:08:49 +01:00
medievil1 a7a69f5108 Update DirectSound.hpp 2020-10-15 02:26:10 -04:00
ergo720 b34165d63b Avoid false rdtsc negative in 25 to life 2020-10-14 23:17:24 +02:00
Luke Usher 8a87fd8376
Merge pull request #1978 from CookiePLMonster/msaa-improvements
MSAA improvements basing on xdk-3911 behaviour
2020-10-14 21:49:47 +01:00
ergo720 621960258d Fix crash in Stranger's Wrath caused by false rdtsc positives 2020-10-14 21:34:24 +02:00
Luke Usher efe42f4eba
Merge pull request #1985 from CookiePLMonster/fix-rdtsc-overflow
Make RDTSC and ACPI timers stateful to fix overflows
2020-10-13 19:16:29 +01:00
Silent f42009a27e
Implement MSAA scaling to be closer to Xbox
Now scales clears, and applies scaling based on a bound render target.
X/Y scale masks now also match the xbox runtime (at least xdk-3911)
2020-10-12 20:25:14 +02:00
Silent 190ef8c3d5
Implement X_D3DRS_MULTISAMPLETYPE 2020-10-12 20:14:58 +02:00
Silent 0d1a8e3afd
Make RDTSC and ACPI timers stateful to fix overflows
Stateless RDTSC and ACPI timers were ticking relative
to the host QPC and multiplied to nanoseconds.
This resulted in values so huge they would overflow since
20-30 minutes.

Introducing state allows to multiply to nanoseconds only over
a delta value, which should be reasonably small in almost call cases.
2020-10-12 18:26:29 +02:00
Luke Usher 7767250624
Merge pull request #1987 from ergo720/mem_page_usage_fix
Memory manager fixes
2020-10-12 08:46:08 +01:00
Luke Usher 756ad91cbe
Merge pull request #1976 from CookiePLMonster/set-texture-ltcg
Add several D3D8LTCG function variations for xdk-3911
2020-10-12 08:41:01 +01:00
ergo720 dd5a029ee6 Restore correctly the pfn database during reboots when using the debug layout 2020-10-11 23:33:43 +02:00
ergo720 cd918389a4 Restore correct page usage upon xbe reboot 2020-10-11 21:29:49 +02:00
ergo720 0a3dd68191 Use UnknownType page usage for the pfn pages 2020-10-11 19:38:08 +02:00
RadWolfie 216b5c274e
Merge pull request #1983 from CookiePLMonster/mixbin-improvements
Improvements to old style (mask based) mixbin
2020-10-11 09:27:58 -05:00
Silent 2d649c969f
Improve mixbin handling for Revision 1 mixbin
Added an union combining both a pointer to new mixbins
and a mixbin mask, and a function to convert to the new format.
This allows to initialize mixbins for Revision 1 XDKs too.

Implements IDirectSoundBuffer_SetMixBinVolumes_12 and
CDirectSoundStream_SetMixBinVolumes_12.
2020-10-11 15:43:38 +02:00
RadWolfie 24c4e3d0a7
Merge pull request #1970 from LukeUsher/optional-maintain-aspect-ratio
Allow users to disable aspect ratio correction
2020-10-11 07:07:59 -05:00
x1nixmzeng 3a740d7933 Report relaunching with another Xbe to the debugger 2020-10-11 12:13:03 +01:00
Silent a4c4719a19
IDirectSoundBuffer_SetBufferData: Stop the sound before waiting for it to end 2020-10-11 12:20:44 +02:00
Silent ad6438f936
Fix issues related to volume getting/setting
Not adding headroom to volume in HybridDirectSoundBuffer_SetMixBinVolumes_8
caused the sound to be attenuated by the headroom value every time
it was updated.
2020-10-11 00:21:46 +02:00
Silent fd490e9929
Actually zero g_InlineVertexBuffer_Table[0]
Operator= invoked default constructors where available,
and a default constructor for D3DXVECTOR4 does nothing.
memset/memcpy zeroes and copies the entire structure for real.
2020-10-09 22:15:15 +02:00
Silent 665dc37877
Implemented D3DDevice_SetVertexShader_0
LTCG version of D3DDevice_SetVertexShader which passes
Handle in EBX
2020-10-07 19:11:02 +02:00
Silent 13d79192c8
Implemented D3DDevice_DrawVerticesUP_12
LTCG version of D3DDevice_DrawVerticesUP which passes
pVertexStreamZeroData in EBX
2020-10-07 18:56:29 +02:00
Silent ad3c042df2
Add a new rdtsc pattern based on NASCAR Heat 2002 logs
New pattern detects the following:

rdtsc
mov address, eax
2020-10-06 21:30:58 +02:00
Silent 05bae29ec3
Add a proper D3DDevice_SetStreamSource for xdk-391 LTCG
The signature was correct, but it was redirecting to a wrong
version of SetStreamSource. The correct version passes the first
argument in EDX.
2020-10-06 21:04:06 +02:00
Silent 556a65f1dc
Fix wrong D3DDevice_SetVertexShaderConstant_8 implementation
The assumption that one of the parameters has to be taken from EDX
was correct, but the function was not implemented properly
2020-10-06 19:22:02 +02:00
Silent 3fdfa89812
Implement LTCG D3DDevice::SetTexture for xdk-3911
Test case: NASCAR Heat 2002
2020-10-06 19:22:02 +02:00
Silent 24fa7dc935
D3DDevice_SetTexture_4: Fix Xbox implementation call 2020-10-06 18:50:39 +02:00
ergo720 13bd79f930
Use fixed width types for xbox types + restructured kernel header files (#1969)
* VOID -> void_xt

* CHAR, CCHAR -> char_xt, cchar_xt

* UCHAR -> uchar_xt

* BYTE, BOOLEAN -> byte_xt, boolean_xt

* Fix bogus intellisense errors in the kernel headers

* SHORT, CSHORT, USHORT -> short_xt, cshort_xt, ushort_xt

* LONG -> long_xt

* WORD, DWORD -> word_xt, dword_xt

* HRESULT -> hresult_xt

* ULONG -> ulong_xt

* SIZE_T, ACCESS_MASK, PHYSICAL_ADDRESS -> size_xt, access_mask_xt, physical_address_xt

* UINT, INT -> uint_xt, int_xt

* LONG_PTR, ULONG_PTR, INT_PTR -> long_ptr_xt, ulong_ptr_xt, int_ptr_xt

* LONGLONG, ULONGLONG -> longlong_xt, ulonglong_xt

* WCHAR, QUAD, BOOL, FLOAT -> wchar_xt, quad_xt, bool_xt, float_xt

* Updated types in xonline.h + reverted some type changes + moved kernel header files in cxbxr source tree

* Use char16_t instead of wchar_t for wchar_xt xbox type

* Fixed macro redefinition warnings from ntstatus macros in types.h
  Fixed macro redefinition warnings from NT_SUCCESS and FIELD_OFFSET
  Fixed macro redefinition warnings from the REG_ macros used by the eeprom

* NTSTATUS -> ntstatus_xt
2020-10-06 05:33:16 -05:00
Luke Usher 8a1e4b1beb
Merge pull request #1974 from RadWolfie/symbolscan-fix
Fix Symbol Scan's Kernel Thunk Bug
2020-10-06 10:11:50 +01:00
Silent 0a46366c22
Add an rdtsc false positive check for Group S Challenge [CC-005] [1.05] 2020-10-05 21:45:59 +02:00
RadWolfie 746a7e6450 hle: move MapThunkTable after EmuHLEIntercept plus fix hidden xbeType bug to use directly xbe type than system type. 2020-10-05 11:24:22 -05:00
RadWolfie 200c614d21 hle: fix a crash if move before MapThunkTable call 2020-10-05 11:24:22 -05:00
RadWolfie 31fd0600b6 hle: let EmuLog handler handle debug messages 2020-10-05 11:08:59 -05:00
Silent bd759e5858
PsCreateSystemThreadEx: Fill dwThreadId immediately after creating the thread 2020-10-04 23:47:10 +02:00
Luke Usher ecc6669158 Allow users to disable aspect ratio correction
This replaces the unused 'Hardware YUV overlay' option in the video settings.
2020-10-01 08:57:57 +01:00
RadWolfie 5aad40ce9d move xxHash to submodule 2020-09-25 03:38:29 -05:00
RadWolfie eaeb521bd9 update XbSymbolDatabase submodule 2020-09-24 14:10:24 -05:00
ergo720 cb2bd277cd Hide the mouse cursor when hovering on the rendering window 2020-09-23 12:02:00 +02:00
ergo720 fc888cac2d Addressed review remarks 2020-09-21 15:12:12 +02:00
ergo720 dd24225477 Ignore K/M input when the cursor is outside of the rendering window 2020-09-20 22:58:04 +02:00
ergo720 4c47d5a6d9 Store ClipCursor flag in EmuShared 2020-09-20 17:57:16 +02:00
ergo720 01382d7e1d Lock the mouse cursor to the rendering window when the user presses F3 key 2020-09-20 14:58:11 +02:00
ergo720 fa6387a545
Merge pull request #1955 from RadWolfie/fix-dsound-namespace
Fix Xbox DSound Namespace
2020-09-08 13:40:58 +02:00
RadWolfie e3b1cffd3a dsound: remove todo comment 2020-09-08 04:53:29 -05:00
RadWolfie 0b32d66e37 dsound: move HybridDirectSoundBuffer_SetMixBins to original location 2020-09-08 04:53:29 -05:00
RadWolfie 4cd89d77b8 dsound: remove extra parameter from HybridDirectSoundBuffer_SetMixBins 2020-09-08 04:53:29 -05:00
RadWolfie e6f875b7a7 dsound: updated to use without depend on windows' dsound header file for xbox usage 2020-09-08 04:53:29 -05:00
Anthony Miles 5272b1de12 Reduce aliasing in CopyRects 2020-09-02 23:29:47 +12:00
Anthony Miles fc655cdca5 CopyRects accounts for host resource scaling
Fixes Crash Tag Team Racing resolution scaling issue
2020-09-02 23:05:23 +12:00
Luke Usher ee6a61c364
d3d: apply aspect ratio correction to the backbuffer (#1956)
* d3d: apply aspect ratio correction to the backbuffer

* d3d: optimise aspect ratio correction + allow run-time aspect change (eg: dashboard)

* d3d: fix typo

* d3d: fix borders on aspect ratio change + apply aspect ratio correction to FMV

* d3d: fix indenting in SetAspectRatioScale

* d3d: add comment to explain clear
2020-09-02 04:45:04 -05:00
ergo720 b304e538c6
Introduce xbox namespace + deduplicate xbox types (#1942)
* Introduced new xbox namespace + moved inside it xbox pointer/address types

* Replaced xboxkrnl namespace with xbox namespace

* Moved kernel types from xboxkrnl.h to xbox_types.h

* Replaced XTL namespace with xbox namespace

* Fix a conflict with the VOID macro imported by Windows.h

* Fixed misalignment issues + renamed xtl_prefix
2020-08-24 13:29:48 -05:00
RadWolfie f9084d9b2e hotfix: fix dsound string patches typos 2020-08-23 12:55:49 -05:00
RadWolfie b10d242b80 fix pr 1945 normalize 2020-08-23 11:52:04 -05:00
Luke Usher ffe3b95323
Merge pull request #1946 from RadWolfie/line-ending-renormalize
Setup Force Source Files to LF Line Ending and Renormalize
2020-08-23 14:58:19 +01:00
Luke Usher 967f53ad6f
Merge pull request #1945 from LukeUsher/d3d-dont-create-invalid-buffers
d3d: don't attempt to create 0 sized vertex buffers
2020-08-23 14:49:39 +01:00
RadWolfie 3550fa4ed1 setup force source files to lf line ending and renormalize 2020-08-22 20:17:07 -05:00
Luke Usher d961d4e7e7 d3d: don't attempt to create 0 sized vertex buffers 2020-08-21 20:13:23 +01:00
PatrickvL cdb3b13756
Merge pull request #1943 from LukeUsher/fix-iocreatefile
krnl: IoCreateFile should return INVALID_HANDLE_VALUE on failure
2020-08-21 16:54:39 +02:00
Luke Usher dd36bce933 krnl: IoCreateFile should return INVALID_HANDLE_VALUE on failure 2020-08-21 15:05:01 +01:00
RadWolfie 8861b845d7 chrono: replace duration_cast to duration 2020-08-20 15:51:12 -05:00
RadWolfie e0f6d75cd0 chrono: use steady_clock than high_resolution_clock 2020-08-20 14:50:02 -05:00
ergo720 f46bcd6875 Use xboxkrnl namespace inside xboxkrnl header file 2020-08-18 17:02:19 +02:00
Luke Usher 2695d91496
Merge pull request #1913 from RadWolfie/improve-compiler-support
Improve SEH/VEH support for compilers
2020-08-18 14:55:08 +01:00
RadWolfie d51743a132
Merge pull request #1934 from LukeUsher/avoid-debug-overflow
kernel: avoid potential buffer overflow on DbgPrint
2020-08-17 12:12:10 -05:00
Luke Usher b0ebc8b332 kernel: avoid potential buffer overflow on DbgPrint 2020-08-17 17:21:10 +01:00
Luke Usher de92e5048b hle: Disable RaiseException patch, let the kernel handle it. 2020-08-15 20:43:16 +01:00
RadWolfie e1c53ac304 add verbose arg output for DSound's main class 2020-06-29 14:26:29 -05:00
RadWolfie c06817d8fa add verbose arg output for DSound's stream class 2020-06-29 14:26:24 -05:00
RadWolfie a6a95072a9 add verbose arg output for DSound's buffer class 2020-06-29 14:26:20 -05:00
ergo720 9e90a2df50 Show a popup when xbe sections are corrupted 2020-06-23 22:24:52 +02:00
RadWolfie 6de2d464c4 fix disabled code to sync with new change. 2020-06-20 04:44:50 -05:00
RadWolfie 4043ac1b01 rewording APIs for review remarks 2020-06-20 03:40:54 -05:00
RadWolfie 9f593237fe add voids whenever not using return values 2020-06-13 16:41:48 -05:00
RadWolfie ce3626eb9d replace CxbxShowError to CxbxPopupMsg prefix to include in log record 2020-06-11 12:54:31 -05:00
RadWolfie 77d469ddb5 suppress popups while in exclusive fullscreen mode 2020-06-11 12:38:28 -05:00
RadWolfie c0f2d60a3f fix compiler warning to use enum class instead of enum 2020-06-11 12:38:28 -05:00
RadWolfie dbae5dbb79 move popup message to logging file 2020-06-11 12:38:28 -05:00
RadWolfie 9bee8ea17b add testcase popup option 2020-06-11 12:38:27 -05:00
Luke Usher f1d09aff15
Merge pull request #1917 from Fisherman166/HalReadSMCTrayState
Rewrite HalReadSMCTrayState to match original kernel implementation.
2020-06-08 15:22:32 +01:00
RadWolfie a216c3d90e rename bOverrideException to bOverrideEmuException 2020-06-07 23:27:08 -05:00
RadWolfie b5358508d6 update Windows' SEH, fix overflow exception, and non-Windows platform support 2020-06-07 23:27:08 -05:00
RadWolfie 64f69f78ae add exception manager 2020-06-07 22:38:01 -05:00
PatrickvL d3544f7b5f
Merge pull request #1918 from Fisherman166/FsSetCacheSize
Update FscSetCacheSize to match original kernel
2020-06-07 18:51:45 +02:00
Fisherman166 a981607e51 Add g_ prefix to FscCacheEvent. 2020-06-07 09:40:55 -07:00
PatrickvL 0afcf04c06
Merge pull request #1915 from Fisherman166/KeReleaseSemaphore
Implement KeReleaseSemaphore
2020-06-07 08:10:40 +02:00
RadWolfie e166b97cd7 check for 3D audio to use mono channel by default instead of stereo 2020-06-07 00:45:05 -05:00
Fisherman166 326f645b8f Initialize FscCacheEvent at emulation start to match the real kernel implementation. 2020-06-06 16:09:01 -07:00
Fisherman166 6d8d692b7c Implement FscSetCacheSize matching original kernel implementation. 2020-06-06 13:34:40 -07:00
Fisherman166 857b8f933e Rewrite HalReadSMCTrayState to match original kernel implementation. Keeps the TRAY_OPEN hack for the time being. 2020-06-06 13:27:54 -07:00
RadWolfie 503ce9b825 fix applications using IDirectSoundBuffer_Lock incorrectly 2020-06-05 20:23:52 -05:00