49
49
#include < atlbase.h>
50
50
51
51
52
- #define FAR_VERSION_NUM L" 0.6.2.4 "
52
+ #define FAR_VERSION_NUM L" 0.7.0 "
53
53
#define FAR_VERSION_STR L" FAR v " FAR_VERSION_NUM
54
54
55
55
// Block until update finishes, otherwise the update dialog
@@ -321,42 +321,15 @@ SK_FAR_CheckVersion (LPVOID user)
321
321
__stdcall
322
322
SK_UpdateSoftware (const wchar_t * wszProduct);
323
323
324
- if (SK_FetchVersionInfo (L" FAR" ))
325
- SK_UpdateSoftware (L" FAR" );
324
+ if (SK_FetchVersionInfo (L" FAR/dinput8 " ))
325
+ SK_UpdateSoftware (L" FAR/dinput8 " );
326
326
327
327
return 0 ;
328
328
}
329
329
330
330
#include < ../depends/include/glm/glm.hpp>
331
331
332
332
333
- struct far_scatter_param_s
334
- {
335
- union
336
- {
337
- struct
338
- {
339
- float Near_Far_Stepnum [4 ][4 ];
340
- float LightColor [4 ][4 ];
341
- float LightDirView_Range15 [4 ];
342
- float ScatterParam_Range7 [4 ];
343
- };
344
-
345
- float data [40 ];
346
- };
347
-
348
- far_scatter_param_s (LPCVOID pData)
349
- {
350
- if (pData != nullptr )
351
- memcpy (&data [0 ], pData, sizeof far_scatter_param_s);
352
- else
353
- memset (&data [0 ], 0 , sizeof far_scatter_param_s);
354
- }
355
- };
356
-
357
- std::map <ID3D11Buffer*, far_scatter_param_s> scatter_buffers;
358
- std::map <ID3D11Buffer*, far_scatter_param_s> scatter_buffers_ovr;
359
-
360
333
HRESULT
361
334
WINAPI
362
335
SK_FAR_CreateBuffer (
@@ -439,21 +412,7 @@ SK_FAR_CreateBuffer (
439
412
return D3D11Dev_CreateBuffer_Original (This, &new_desc, pInitialData, ppBuffer);
440
413
}
441
414
442
- HRESULT hr =
443
- D3D11Dev_CreateBuffer_Original (This, pDesc, pInitialData, ppBuffer);
444
-
445
- if (SUCCEEDED (hr) && ppBuffer != nullptr )
446
- {
447
- if ( pDesc != nullptr && pDesc->ByteWidth == sizeof (far_scatter_param_s) &&
448
- pDesc->BindFlags & D3D11_BIND_CONSTANT_BUFFER &&
449
- pInitialData )
450
- {
451
- scatter_buffers.emplace (std::make_pair (*ppBuffer, far_scatter_param_s (pInitialData->pSysMem )));
452
- scatter_buffers_ovr.emplace (std::make_pair (*ppBuffer, far_scatter_param_s (pInitialData->pSysMem )));
453
- }
454
- }
455
-
456
- return hr;
415
+ return D3D11Dev_CreateBuffer_Original (This, pDesc, pInitialData, ppBuffer);
457
416
}
458
417
459
418
HRESULT
@@ -505,20 +464,6 @@ SK_FAR_PSSetConstantBuffers (
505
464
_In_ UINT NumBuffers,
506
465
_In_opt_ ID3D11Buffer *const *ppConstantBuffers )
507
466
{
508
- if (ppConstantBuffers)
509
- {
510
- for (UINT i = 0 ; i < NumBuffers; i++)
511
- {
512
- if (StartSlot + i == 8 )
513
- {
514
- if (scatter_buffers.count (ppConstantBuffers [i]))
515
- {
516
- dll_log.Log (L" NEAT" );
517
- }
518
- }
519
- }
520
- }
521
-
522
467
D3D11_PSSetConstantBuffers_Original (This, StartSlot, NumBuffers, ppConstantBuffers );
523
468
}
524
469
@@ -537,28 +482,6 @@ extern LPVOID __SK_end_img_addr;
537
482
extern void * __stdcall SK_Scan (const uint8_t * pattern, size_t len, const uint8_t * mask);
538
483
539
484
540
-
541
- typedef _Return_type_success_ (return >= 0 ) LONG NTSTATUS;
542
-
543
- typedef NTSTATUS (NTAPI *NtQueryTimerResolution_pfn)
544
- (
545
- OUT PULONG MinimumResolution,
546
- OUT PULONG MaximumResolution,
547
- OUT PULONG CurrentResolution
548
- );
549
-
550
- typedef NTSTATUS (NTAPI *NtSetTimerResolution_pfn)
551
- (
552
- IN ULONG DesiredResolution,
553
- IN BOOLEAN SetResolution,
554
- OUT PULONG CurrentResolution
555
- );
556
-
557
- HMODULE NtDll = 0 ;
558
-
559
- NtQueryTimerResolution_pfn NtQueryTimerResolution = nullptr ;
560
- NtSetTimerResolution_pfn NtSetTimerResolution = nullptr ;
561
-
562
485
void
563
486
SK_FAR_SetFramerateCap (bool enable)
564
487
{
@@ -908,7 +831,7 @@ WINAPI
908
831
SK_FAR_OSD_Disclaimer (LPVOID user)
909
832
{
910
833
while ((volatile bool &)config.osd .show )
911
- Sleep (66 );
834
+ SleepEx (66 , FALSE );
912
835
913
836
far_osd_disclaimer->set_value (false );
914
837
far_osd_disclaimer->store ();
@@ -1026,7 +949,7 @@ STDMETHODCALLTYPE
1026
949
SK_FAR_PresentFirstFrame (IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
1027
950
{
1028
951
// Wait for the mod to init, it may be held up during version check
1029
- while (! InterlockedAdd (&__FAR_init, 0 )) Sleep (16 );
952
+ while (! InterlockedAdd (&__FAR_init, 0 )) SleepEx (16 , FALSE );
1030
953
1031
954
{
1032
955
game_state.enforce_cap = (! far_uncap_fps->get_value ());
@@ -1494,11 +1417,6 @@ SK_FAR_UpdateSubresource (
1494
1417
_In_ UINT SrcRowPitch,
1495
1418
_In_ UINT SrcDepthPitch)
1496
1419
{
1497
- if (scatter_buffers.count ((ID3D11Buffer *)pDstResource))
1498
- {
1499
- memcpy (scatter_buffers.at ((ID3D11Buffer *)pDstResource).data , pSrcData, sizeof (far_scatter_param_s));
1500
- }
1501
-
1502
1420
return D3D11_UpdateSubresource_Original ( This, pDstResource, DstSubresource,
1503
1421
pDstBox, pSrcData, SrcRowPitch,
1504
1422
SrcDepthPitch );
@@ -1732,32 +1650,6 @@ SK_FAR_InitPlugin (void)
1732
1650
{
1733
1651
SK_SetPluginName (FAR_VERSION_STR);
1734
1652
1735
- if (NtDll == 0 )
1736
- {
1737
- NtDll = LoadLibrary (L" ntdll.dll" );
1738
-
1739
- NtQueryTimerResolution =
1740
- (NtQueryTimerResolution_pfn)
1741
- GetProcAddress (NtDll, " NtQueryTimerResolution" );
1742
-
1743
- NtSetTimerResolution =
1744
- (NtSetTimerResolution_pfn)
1745
- GetProcAddress (NtDll, " NtSetTimerResolution" );
1746
-
1747
- if (NtQueryTimerResolution != nullptr &&
1748
- NtSetTimerResolution != nullptr )
1749
- {
1750
- ULONG min, max, cur;
1751
- NtQueryTimerResolution (&min, &max, &cur);
1752
- dll_log.Log ( L" [ Timing ] Kernel resolution.: %f ms" ,
1753
- (float )(cur * 100 )/1000000 .0f );
1754
- NtSetTimerResolution (max, TRUE , &cur);
1755
- dll_log.Log ( L" [ Timing ] New resolution....: %f ms" ,
1756
- (float )(cur * 100 )/1000000 .0f );
1757
-
1758
- }
1759
- }
1760
-
1761
1653
SK_CreateFuncHook ( L" ID3D11Device::CreateBuffer" ,
1762
1654
D3D11Dev_CreateBuffer_Override,
1763
1655
SK_FAR_CreateBuffer,
@@ -1942,25 +1834,25 @@ typedef void (WINAPI *D3D11_DrawInstancedIndirect_pfn)(
1942
1834
far_rtss_warned->store ();
1943
1835
}
1944
1836
1945
- far_slow_state_cache =
1946
- dynamic_cast <sk::ParameterBool *>
1947
- (far_factory.create_parameter <bool > (L" Disable D3D11.1 Interop Stateblocks" ));
1948
-
1949
- far_slow_state_cache->register_to_ini ( far_prefs,
1950
- L" FAR.Compatibility" ,
1951
- L" NoD3D11Interop" );
1952
-
1953
- extern bool SK_DXGI_FullStateCache;
1954
-
1955
- if (! far_slow_state_cache->load ())
1956
- SK_DXGI_FullStateCache = false ;
1957
- else
1958
- SK_DXGI_FullStateCache = far_slow_state_cache->get_value ();
1959
-
1960
- config.render .dxgi .full_state_cache = SK_DXGI_FullStateCache;
1837
+ // far_slow_state_cache =
1838
+ // dynamic_cast <sk::ParameterBool *>
1839
+ // (far_factory.create_parameter <bool> (L"Disable D3D11.1 Interop Stateblocks"));
1840
+ //
1841
+ // far_slow_state_cache->register_to_ini ( far_prefs,
1842
+ // L"FAR.Compatibility",
1843
+ // L"NoD3D11Interop" );
1844
+ //
1845
+ // extern bool SK_DXGI_FullStateCache;
1846
+ //
1847
+ // if (! far_slow_state_cache->load ())
1848
+ // SK_DXGI_FullStateCache = false;
1849
+ // else
1850
+ // SK_DXGI_FullStateCache = far_slow_state_cache->get_value ();
1851
+ //
1852
+ // config.render.dxgi.full_state_cache = SK_DXGI_FullStateCache;
1961
1853
1962
- far_slow_state_cache->set_value (SK_DXGI_FullStateCache);
1963
- far_slow_state_cache->store ();
1854
+ // far_slow_state_cache->set_value (SK_DXGI_FullStateCache);
1855
+ // far_slow_state_cache->store ();
1964
1856
1965
1857
1966
1858
far_osd_disclaimer =
@@ -2436,75 +2328,6 @@ SK_FAR_ControlPanel (void)
2436
2328
ImGui::TreePop ();
2437
2329
}
2438
2330
2439
- if (ImGui::CollapsingHeader (" Light Scattering" ))
2440
- {
2441
- static int idx = 0 ;
2442
- static far_scatter_param_s scatter_data (nullptr );
2443
- static ID3D11Resource* scatter_res = nullptr ;
2444
-
2445
- ImGui::TreePush (" " );
2446
-
2447
- if (ImGui::SliderInt (" Scatter Buffer" , &idx, 0 , scatter_buffers.size ()))
2448
- {
2449
- int scatter_idx = 0 ;
2450
-
2451
- for (auto it : scatter_buffers)
2452
- {
2453
- if (scatter_idx == idx)
2454
- {
2455
- ID3D11DeviceContext* pCtx = nullptr ;
2456
-
2457
- ((ID3D11Device *)SK_GetCurrentRenderBackend ().device )->GetImmediateContext (&pCtx);
2458
-
2459
- memcpy (scatter_data.data , it.second .data , sizeof far_scatter_param_s);
2460
- scatter_res = it.first ;
2461
- break ;
2462
- }
2463
- ++scatter_idx;
2464
- }
2465
- }
2466
-
2467
- static bool update = false ;
2468
-
2469
- update |= ImGui::DragFloat4 (" Near_Far_Numsteps [0]" , scatter_data.Near_Far_Stepnum [0 ]);
2470
- update |= ImGui::DragFloat4 (" Near_Far_Numsteps [1]" , scatter_data.Near_Far_Stepnum [1 ]);
2471
- update |= ImGui::DragFloat4 (" Near_Far_Numsteps [2]" , scatter_data.Near_Far_Stepnum [2 ]);
2472
- update |= ImGui::DragFloat4 (" Near_Far_Numsteps [3]" , scatter_data.Near_Far_Stepnum [3 ]);
2473
-
2474
- ImGui::Separator ();
2475
-
2476
- update |= ImGui::ColorEdit4 (" LightColor [0]" , scatter_data.LightColor [0 ]);
2477
- update |= ImGui::ColorEdit4 (" LightColor [1]" , scatter_data.LightColor [1 ]);
2478
- update |= ImGui::ColorEdit4 (" LightColor [2]" , scatter_data.LightColor [2 ]);
2479
- update |= ImGui::ColorEdit4 (" LightColor [3]" , scatter_data.LightColor [3 ]);
2480
-
2481
- ImGui::Separator ();
2482
-
2483
- update |= ImGui::DragFloat4 (" LightDirView_Range15" , scatter_data.LightDirView_Range15 );
2484
- update |= ImGui::DragFloat4 (" ScatterParam_Range7" , scatter_data.ScatterParam_Range7 );
2485
-
2486
- ImGui::Separator ();
2487
-
2488
- if (scatter_res && update)
2489
- {
2490
- // if (ImGui::Button ("Update Scatter Buffer"))
2491
- // {
2492
- ID3D11DeviceContext* pCtx = nullptr ;
2493
-
2494
- ((ID3D11Device *)SK_GetCurrentRenderBackend ().device )->GetImmediateContext (&pCtx);
2495
-
2496
- for (auto it : scatter_buffers)
2497
- {
2498
- D3D11_UpdateSubresource_Original (pCtx, it.first , 0 , nullptr , scatter_data.data , 0 , 0 );
2499
- }
2500
-
2501
- // update = false;
2502
- // }
2503
- }
2504
-
2505
- ImGui::TreePop ();
2506
- }
2507
-
2508
2331
if (ImGui::CollapsingHeader (" Framerate" , ImGuiTreeNodeFlags_DefaultOpen))
2509
2332
{
2510
2333
ImGui::TreePush (" " );
0 commit comments