Skip to content

Commit

Permalink
Update dependencies. Fix black screen when both slang_shader and slan…
Browse files Browse the repository at this point in the history
…g_shader_3d are set. Added readme and license.
  • Loading branch information
xzn committed Jul 24, 2019
1 parent d6927bb commit a8a38fe
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 23 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 jsdeck

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ else
endif
cc := $(cross_prefix)gcc
cxx := $(cross_prefix)g++
smhasher_src := smhasher/src/MurmurHash3.cpp
smhasher_obj := $(smhasher_src:smhasher/src/%.cpp=obj/smhasher/%.o)
smhasher_src := smhasher/MurmurHash3.cpp
smhasher_obj := $(smhasher_src:smhasher/%.cpp=obj/smhasher/%.o)
smhasher_dir := $(sort $(dir $(smhasher_obj)))
HLSLcc_src := $(wildcard HLSLcc/src/*.cpp)
HLSLcc_obj := $(HLSLcc_src:HLSLcc/src/%.cpp=obj/HLSLcc/%.o)
Expand Down Expand Up @@ -95,7 +95,7 @@ $(retroarch_hdr_sen): RetroArch/gfx/common/common.diff | $(retroarch_hdr_src) $(
obj/%.o: src/%.cpp | $(dir)
$(cxx_all) -Werror -Wall $(retroarch_flg) -IRetroArch/RetroArch/gfx/common

obj/smhasher/%.o: smhasher/src/%.cpp | $(smhasher_dir)
obj/smhasher/%.o: smhasher/%.cpp | $(smhasher_dir)
$(cxx_all)

obj/HLSLcc/%.o: HLSLcc/src/%.cpp | $(HLSLcc_dir)
Expand Down
88 changes: 88 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Mega Man X Legacy Collection `d3d10.dll` wrapper mod

Features:

- Let you use [slang-shaders](https://github.com/libretro/slang-shaders) with Capcom's Mega Man X Legacy Collection.
- Fixes scaling artifact due to nearest-neighbour upscaling.

## Building from source

Using i686-w64-mingw32-gcc (cross compiling should work too):

```bash
# Download source
git clone https://github.com/xzn/d3d10-mmxlc.git
cd d3d10-mmxlc
git submodule update --init --recursive

# Create symlinks and patch files
make prep

# Build the dll
make -j$(nproc) dll
```

Some options to pass to make

```bash
# disable optimizations and prevents stripping
make o3=0 dll

# disable lto (keep -O3)
make lto=0 dll
```

## Install

Copy `dinput8.dll`, `interp-mod.ini`, and the `slang-shaders\` directory to your game folders, e.g.:

`SteamLibrary\steamapps\common\Mega Man X Legacy Collection`
`SteamLibrary\steamapps\common\Mega Man X Legacy Collection 2`

## Configuration

`interp-mod.ini` contains options to configure the mod.

```ini
; Log API calls to interp-mod.log,
; Should be left disabled. Really slow and for the most part isn't useful for debugging.
; [logging]
; enabled=true
; hotkey_toggle=VK_CONTROL+O
; hotkey_frame=VK_CONTROL+P

; Change interpolation mode and set up custom shaders.
[graphics]
; Recommended, even if slang-shader is not used.
; Get rid of nearest-neighbour upscaling artifact.
interp=true
; Not recommended, very slow.
; When using Type 1 filter, run the default 2x upscale shader multiple times until it covers the size of the screen.
; enhanced=true
; Set up custom shader for X1~X6, and 3d shader for X7~X8. Need Type 1 filter to be set in-game.
slang_shader=slang-shaders/xbr/xbr-lv2.slangp
slang_shader_3d=slang-shaders/anti-aliasing/fxaa.slangp
; Currently broken, couldn't figure out how to get this to work yet. Do not use.
; render_3d_width=
; render_3d_height=
; display_width=
; display_height=
```

If all goes well you should now be able to start the game and see the overlay on top-left of the screen showing the status of the mod.

`interp-mod.ini` can be edited and have its options applied while the game is running.

## License

Source code for this mod, without its dependencies, is available under MIT. Dependencies such as `RetroArch` are released under GPL.

- `RetroArch` is needed only for `slang_shader` support.
- `SPIRV-Cross` and `glslang` are used for `slang_shader` support.
- `HLSLcc` is used for debugging.

Other dependencies are more or less required:

- `minhook` is used for intercepting calls to `d3d10.dll`.
- `imgui` is used for overlay display.
- `smhasher` is technically optional. Currently used for identifying the built-in Type 1 filter shader.
40 changes: 21 additions & 19 deletions src/d3d10device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "log.h"
#include "overlay.h"
#include "tex.h"
#include "../smhasher/src/MurmurHash3.h"
#include "../smhasher/MurmurHash3.h"

#define LOGGER default_logger
#define LOG_MFUN(_, ...) LOG_MFUN_DEF(MyID3D10Device, ## __VA_ARGS__)
Expand Down Expand Up @@ -584,24 +584,26 @@ if constexpr (ENABLE_SLANG_SHADER) {
filter_next = filter_next && srv_tex == filter_state.rtv_tex;
bool x4 = false;
D3D10_TEXTURE2D_DESC &srv_tex_desc = srv_tex->desc;
if (!filter_next) {
if (
srv_tex_desc.Width == X1_WIDTH &&
srv_tex_desc.Height == X1_HEIGHT
) { // SNES
} else if (
srv_tex_desc.Width == X4_WIDTH &&
srv_tex_desc.Height == X4_HEIGHT
) { // PlayStation
x4 = true;
} else if (
x8 &&
srv_tex->orig_width == orig_size.render_3d_width &&
srv_tex->orig_height == orig_size.render_3d_height
) { // PlayStation 2
} else {
goto end;
}
if (filter_next) {
x8 = false;
} else if (
srv_tex_desc.Width == X1_WIDTH &&
srv_tex_desc.Height == X1_HEIGHT
) { // SNES
x8 = false;
} else if (
srv_tex_desc.Width == X4_WIDTH &&
srv_tex_desc.Height == X4_HEIGHT
) { // PlayStation
x8 = false;
x4 = true;
} else if (
x8 &&
srv_tex->orig_width == orig_size.render_3d_width &&
srv_tex->orig_height == orig_size.render_3d_height
) { // PlayStation 2
} else {
goto end;
}

MyID3D10RenderTargetView *rtv = current_rtv;
Expand Down

0 comments on commit a8a38fe

Please sign in to comment.