Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upscaling feature on IIDX 20 to 26 #250

Merged
merged 6 commits into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ include src/main/bstio/Module.mk
include src/main/camhook/Module.mk
include src/main/cconfig/Module.mk
include src/main/config/Module.mk
include src/main/d3d9-util/Module.mk
include src/main/d3d9exhook/Module.mk
include src/main/ddrhook-util/Module.mk
include src/main/ddrhook1/Module.mk
Expand Down Expand Up @@ -133,6 +134,7 @@ include src/main/iidx-bio2-exit-hook/Module.mk
include src/main/iidx-ezusb-exit-hook/Module.mk
include src/main/iidx-ezusb2-exit-hook/Module.mk
include src/main/iidx-irbeat-patch/Module.mk
include src/main/iidxhook-d3d9/Module.mk
include src/main/iidxhook-util/Module.mk
include src/main/iidxhook1/Module.mk
include src/main/iidxhook2/Module.mk
Expand Down
57 changes: 57 additions & 0 deletions doc/dev/journal/2023-04-13-iidx-24-gfx-upscaling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# IIDX 24 GFX upscaling notes

Date: 2023-04-15
Author: icex2

Notes about my work on fixing the upscaling/downscaling feature of bemanitools for IIDX 20 to 26.
I realized that the render backend changed significantly that the old method that worked fine
doesn't work anymore.

The tool used in the screenshots is [apitrace](https://github.com/apitrace/apitrace).

## IIDX 24

The GFX engine in IIDX from 20 to 26 has a changed render loop that includes built-in scaling to
implement the SD and HD/HD* screen settings that are selectable in the operator menu

### Frame 0 - GFX init part

Setting up the context and device, as well as the frame buffer. This also creates the intermediate
texture that is configured as the render target once it begins drawing the scene.

![](2023-04-13-iidx-24-gfx-upscaling/init.png)

### Frame 1 - A clean main render path

Start the scene and set the render target to the intermediate texture.

![](2023-04-13-iidx-24-gfx-upscaling/beginscene.png)

After done drawing the scene, the intermediate texture is blended to the framebuffer. With a target
2D plane having the size of the target resolution, the blending applies linear scaling to either
up- or downscale the final image.

![](2023-04-13-iidx-24-gfx-upscaling/scaling.png)

## IIDX 10

A recap of the old stuff, see also [my previous notes](2019-10-07-iidx-gfx-rendering-loops.md),
as I had to look at everything again to properly understand the differences.

### Frame 0 - GFX init part

Setting up the context and device, as well as the frame buffer. Renders directly to the frame
buffer.

![](2023-04-13-iidx-24-gfx-upscaling/init10.png)

### Frame 1 - A clean main render path

Beginning the scene excerpt. The viewport needs to match the target resolution to display the
final image correctly.

![](2023-04-13-iidx-24-gfx-upscaling/beginscene10.png)

Ending the scene excerpt, nothing fancy here, just swapping the back buffer.

![](2023-04-13-iidx-24-gfx-upscaling/endscene10.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/main/camhook/cam.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ bool convert_path_to_fakesym(const char *path, wchar_t *sym, char *extra_o)
pidstr,
mistr,
extra);

mbstowcs(sym, buffer, CAMERA_DATA_STRING_SIZE);

return true;
Expand Down Expand Up @@ -837,7 +837,8 @@ void camhook_init(struct camhook_config_cam *config_cam)
NULL, "Mf.dll", camhook_mf_syms, lengthof(camhook_mf_syms));

log_info("Inserted cam hooks for %d cams", (int) num_setup);
// If the user has manually disabled all cams, don't print this in the log
// If the user has manually disabled all cams, don't print this in the
// log
} else if (num_addressed_cams != config_cam->num_devices) {
log_info("No cams detected, not hooking");
}
Expand Down
27 changes: 14 additions & 13 deletions src/main/camhook/config-cam.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ const char *camhook_config_disable_camera[CAMHOOK_CONFIG_CAM_MAX] = {
"cam.disable_camera2",
};

const int camhook_config_disable_camera_default_values[CAMHOOK_CONFIG_CAM_MAX] = {
false,
false,
const int camhook_config_disable_camera_default_values[CAMHOOK_CONFIG_CAM_MAX] =
{
false,
false,
};

const char *camhook_config_device_id_keys[CAMHOOK_CONFIG_CAM_MAX] = {
Expand Down Expand Up @@ -83,16 +84,16 @@ void camhook_config_cam_get(
camhook_config_disable_camera_default_values[i]);
}
if (!cconfig_util_get_str(
config,
camhook_config_device_id_keys[i],
config_cam->device_id[i],
sizeof(config_cam->device_id[i]) - 1,
camhook_config_device_default_values[i])) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
camhook_config_device_id_keys[i],
camhook_config_device_default_values[i]);
config,
camhook_config_device_id_keys[i],
config_cam->device_id[i],
sizeof(config_cam->device_id[i]) - 1,
camhook_config_device_default_values[i])) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
camhook_config_device_id_keys[i],
camhook_config_device_default_values[i]);
}
}
}
6 changes: 6 additions & 0 deletions src/main/d3d9-util/Module.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
libs += d3d9-util

libs_d3d9-util := \

src_d3d9-util := \
dxerr9.c \
Loading