mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2024-11-30 17:24:30 +01:00
iidxhook-util: Major refactoring of d3d9 module
Uses the hook/d3d9 module with IRP handlers now. All previously available features are implemented. Furthermore, a new overhauled up-/downscaling method is implemented which supports all IIDX versions now.
This commit is contained in:
parent
d169ee84b3
commit
c5d39d82d5
File diff suppressed because it is too large
Load Diff
@ -1,78 +1,101 @@
|
||||
#ifndef IIDXHOOK_D3D9_H
|
||||
#define IIDXHOOK_D3D9_H
|
||||
|
||||
/**
|
||||
* This module hooks into various D3D9 calls implementing a large set of features for IIDX games such as:
|
||||
* window mode, frame buffer up-/downscaling, software rate limiting, software monitor check,...
|
||||
*
|
||||
* @author icex2
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hook/d3d9.h"
|
||||
|
||||
/**
|
||||
* Filter types for scaling back buffer, e.g. upscaling for higher resolution monitors.
|
||||
*/
|
||||
enum d3d9_back_buffer_scale_filter {
|
||||
D3D9_BACK_BUFFER_SCALE_FILTER_NONE = 0,
|
||||
D3D9_BACK_BUFFER_SCALE_FILTER_LINEAR = 1,
|
||||
D3D9_BACK_BUFFER_SCALE_FILTER_POINT = 2,
|
||||
enum iidxhook_util_d3d9_back_buffer_scale_filter {
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_NONE = 0,
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_LINEAR = 1,
|
||||
IIDXHOOK_UTIL_D3D9_BACK_BUFFER_SCALE_FILTER_POINT = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback function to receive resulting refresh rate of monitor check.
|
||||
*/
|
||||
typedef void (*d3d9_monitor_check_result_callback_t)(double refresh_rate);
|
||||
typedef void (*iidxhook_util_d3d9_monitor_check_result_callback_t)(double refresh_rate);
|
||||
|
||||
/**
|
||||
* Hook some d3d9 functions to patch gfx related stuff
|
||||
* like enabling window mode.
|
||||
*
|
||||
* Games using d3d9:
|
||||
* - IIDX: Gold to Copula
|
||||
* Config structure for this module. Enable/disable supported features.
|
||||
*/
|
||||
void d3d9_hook_init(void);
|
||||
|
||||
struct iidxhook_util_d3d9_config {
|
||||
/**
|
||||
* Set the game to window mode.
|
||||
*
|
||||
* @param framed True to add a window frame and make the window
|
||||
* movable, resizable, minizable. False for no frame.
|
||||
* @param width Width of the window. -1 to keep original width.
|
||||
* @param height Height of the window. -1 to keep original height.
|
||||
* Enable/disable window mode. Consider combining with framed.
|
||||
*/
|
||||
void d3d9_set_windowed(bool framed, int32_t width, int32_t height);
|
||||
bool windowed;
|
||||
|
||||
/**
|
||||
* Patch the GPU device ID detection to allow running the game with
|
||||
* other GPUs than the ones it is locked to.
|
||||
*
|
||||
* @param vid Vendor ID to patch.
|
||||
* @param pid Product ID to patch.
|
||||
* Enable a window frame and make the window movable, resizable, minizable.
|
||||
*/
|
||||
void d3d9_set_pci_id(uint16_t vid, uint16_t pid);
|
||||
bool framed;
|
||||
|
||||
/**
|
||||
* Set a framerate limit for the rendering loop.
|
||||
*
|
||||
* Override the default window height which is determined by the frame buffer size.
|
||||
* Set this to 0 to disable the override.
|
||||
*/
|
||||
uint16_t override_window_width;
|
||||
|
||||
/**
|
||||
* Override the default window width which is determined by the frame buffer size.
|
||||
* Set this to 0 to disable the override.
|
||||
*/
|
||||
uint16_t override_window_height;
|
||||
|
||||
/**
|
||||
* Set a software driven framerate limit for the rendering loop and lock to the specified refresh rate, e.g. 59.94.
|
||||
* Use this if the game won't sync up properly with vsync enabled.
|
||||
*
|
||||
* @limit Number of frames to limit the rendering loop to
|
||||
*/
|
||||
void d3d9_set_frame_rate_limit(float limit);
|
||||
float framerate_limit;
|
||||
|
||||
/**
|
||||
* Enable a software a "monitor check" which determines the (avg.) refresh rate
|
||||
* of the game. Ensure that your GPU is outputting a stable refresh rate to
|
||||
* your monitor. Otherwise, the resulting values fluctuate a lot
|
||||
* Override the GPU vendor ID identifier on display device enumeration.
|
||||
* Use this to disable locking to specific GPU cards.
|
||||
* Combine with the pci_pid parameter.
|
||||
*
|
||||
* @param cb Callback to a function that receives the result of the monitor
|
||||
* check once it completed.
|
||||
* Vendor ATI: 1002
|
||||
*/
|
||||
void d3d9_enable_monitor_check(d3d9_monitor_check_result_callback_t cb);
|
||||
uint16_t pci_vid;
|
||||
|
||||
/**
|
||||
* Override the GPU product ID identifier on display device enumeration.
|
||||
* Use this to disable locking to specific GPU cards.
|
||||
* Combine with the pci_pid parameter.
|
||||
*
|
||||
* PIDs:
|
||||
* 7146: RV515 [Radeon X1300]
|
||||
* 95C5: RV620 LE [Radeon HD 3450]
|
||||
*/
|
||||
uint16_t pci_pid;
|
||||
|
||||
/**
|
||||
* Enable a software "monitor check" which determines the (avg.) refresh rate
|
||||
* of the game. Ensure that your GPU is outputting a stable refresh rate to
|
||||
* your monitor. Otherwise, the resulting values fluctuate a lot.
|
||||
*
|
||||
* Callback to a function that receives the result of the monitor check once it completed.
|
||||
*/
|
||||
iidxhook_util_d3d9_monitor_check_result_callback_t iidx09_to_19_monitor_check_cb;
|
||||
|
||||
/**
|
||||
* Ported from d3d8 module to enable this when using d3d8to9.
|
||||
*
|
||||
* Fixes UV coordinates for background videos on
|
||||
* IIDX Red to DD. Use this if you experience the game
|
||||
* stretching the background videos
|
||||
* (see implementation for further details)
|
||||
* Fixes UV coordinates for background videos on IIDX Red to DD and a quad seam issue for 14 to 17.
|
||||
* Use this if you experience the game stretching the background videos or seeing a quad seam
|
||||
* (see implementation for further details).
|
||||
*/
|
||||
void d3d9_iidx_fix_stretched_bg_videos(void);
|
||||
bool iidx11_to_17_fix_uvs_bg_videos;
|
||||
|
||||
/**
|
||||
* Ported from d3d8 module to enable this when using d3d8to9.
|
||||
@ -82,7 +105,7 @@ void d3d9_iidx_fix_stretched_bg_videos(void);
|
||||
* is caused by buggy fog rendering. Fog is used to hide the rings appearing
|
||||
* but that's quite 'far away' so disabling fog doesn't look bad.
|
||||
*/
|
||||
void d3d9_iidx_fix_12_song_select_bg(void);
|
||||
bool iidx12_fix_song_select_bg;
|
||||
|
||||
/**
|
||||
* Ported from d3d8 module to enable this when using d3d8to9.
|
||||
@ -92,20 +115,13 @@ void d3d9_iidx_fix_12_song_select_bg(void);
|
||||
* is caused by buggy lighting. Disabling (dynamic) lighting sets the whole
|
||||
* scene to ambient lighting which displays everything properly.
|
||||
*/
|
||||
void d3d9_iidx_fix_13_song_select_bg(void);
|
||||
bool iidx13_fix_song_select_bg;
|
||||
|
||||
/**
|
||||
* Fixes a parameter on CreateTexture calls causing the game to crash with
|
||||
* NVIDIA cards (on GOLD and possible newer)
|
||||
*/
|
||||
void d3d9_enable_nvidia_fix(void);
|
||||
|
||||
/**
|
||||
* Fixes UV coordinates for background videos on
|
||||
* (similar to the d3d8 games). But, this fixes the quad seam issue on 14 to
|
||||
* 17, only.
|
||||
*/
|
||||
void d3d9_bg_video_seams_fix(void);
|
||||
bool iidx14_to_19_nvidia_fix;
|
||||
|
||||
/**
|
||||
* Scale the back buffer after a frame got rendered. This allows you to up-/downscale the final frame to display
|
||||
@ -115,9 +131,50 @@ void d3d9_bg_video_seams_fix(void);
|
||||
*
|
||||
* @param width Target width to scale the frame to. 0 disables scaling entirely.
|
||||
* @param height Target height to scale the frame to. 0 disables scaling entirely.
|
||||
* @param filter Filtering method to use for scaling. Depending on how you scale, this can have an impact on the final
|
||||
* image quality.
|
||||
* @param filter Filtering method to use for scaling. Depending on how you scale, this can have an impact on the
|
||||
* final image quality.
|
||||
*/
|
||||
void d3d9_scale_back_buffer(uint16_t width, uint16_t height, enum d3d9_back_buffer_scale_filter filter);
|
||||
uint16_t scale_back_buffer_width;
|
||||
|
||||
/**
|
||||
* Back buffer scale height, see parameter scale_back_buffer_width for full doc.
|
||||
*/
|
||||
uint16_t scale_back_buffer_height;
|
||||
|
||||
/**
|
||||
* Back buffer scale filter to apply, see parameter scale_back_buffer_width for full doc.
|
||||
*/
|
||||
enum iidxhook_util_d3d9_back_buffer_scale_filter scale_back_buffer_filter;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize this hook module. Must be called before any other function of this module.
|
||||
*
|
||||
* Games using d3d9: IIDX 14 (Gold) to IIDX 27 (Rootage)
|
||||
* For d3d8 based games (IIDX 9 to 13): use d3d8to9 wrapper to allow usage of this module.
|
||||
*/
|
||||
void iidxhook_util_d3d9_hook_init(void);
|
||||
|
||||
/**
|
||||
* Initialize the provided config struct with default values.
|
||||
*
|
||||
* @param config Pointer to an initialized struct to write default values to.
|
||||
*/
|
||||
void iidxhook_util_d3d9_init_config(struct iidxhook_util_d3d9_config* config);
|
||||
|
||||
/**
|
||||
* Configure this module by applying the provided config.
|
||||
*
|
||||
* @param config Config to apply.
|
||||
*/
|
||||
void iidxhook_util_d3d9_configure(const struct iidxhook_util_d3d9_config* config);
|
||||
|
||||
/**
|
||||
* Main IRP handler call for this module. Must be set up with the hook/d3d9 module to receive calls from d3d9.
|
||||
*
|
||||
* @param irp Pointer to a valid IRP.
|
||||
* @return S_OK on success, error otherwise (depending on the irp op).
|
||||
*/
|
||||
HRESULT iidxhook_util_d3d9_irp_handler(struct hook_d3d9_irp* irp);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user