Skip to content

Commit

Permalink
添加D3D9On12和DXVK选项
Browse files Browse the repository at this point in the history
需要把dxvk的d3d9.dll改名为dxvk.dll放在启动器exe旁边
  • Loading branch information
RERASER committed Nov 8, 2024
1 parent d93ad9b commit fb3a700
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 84 deletions.
14 changes: 12 additions & 2 deletions assets/launcher-ui/src/modules/iidx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { launcher, VersionState } from "./launcher";
import dedent from "dedent";
import type { TupleType } from "typescript";

export enum GraphicsAPI {
Native = 0,
D3D9On12 = 1,
DXVK = 1,
}

export enum IIDXDisplayMode {
Fullscreen = 0,
BorderlessWindowed = 1,
Expand Down Expand Up @@ -30,6 +36,7 @@ export interface IIDXConfig {
asioDevice: string;
useGsm: boolean;
language: IIDXLanguage;
graphicsAPI: GraphicsAPI;
}

export class IIDX {
Expand All @@ -43,7 +50,7 @@ export class IIDX {
}

installed() {
return this.GameMeta.value?.installed??false;
return this.GameMeta.value?.installed ?? false;
}

async UpdateMeta() {
Expand Down Expand Up @@ -96,6 +103,7 @@ export class IIDX {
asioDevice: devices[0],
useGsm: true,
language: IIDXLanguage.English,
graphicsAPI: GraphicsAPI.Native,
}

this._dirty = true;
Expand Down Expand Up @@ -130,7 +138,8 @@ export class IIDX {
this._config.value.resolution === undefined ||
this._config.value.soundMode === undefined ||
this._config.value.useGsm === undefined ||
this._config.value.language === undefined
this._config.value.language === undefined ||
this._config.value.graphicsAPI === undefined
) {
window.laochan.alert.show('IIDX 设置已被重置, 请前往额外设置重新设置', '#B64040', 2000);
await this.resetConfig();
Expand All @@ -156,6 +165,7 @@ export class IIDX {

window.laochan.setParam('IIDX_RESOLTION_W', JSON.stringify(config.resolution.w)),
window.laochan.setParam('IIDX_RESOLTION_H', JSON.stringify(config.resolution.h)),
window.laochan.setParam('IIDX_GRAPHICS_API',JSON.stringify(config.graphicsAPI)),
]);
}

Expand Down
21 changes: 20 additions & 1 deletion assets/launcher-ui/src/views/IIDXSettingView.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { faCompactDisc, faDisplay, faLanguage, faLightbulb, faMicrochip, faTelevision, faUpRightAndDownLeftFromCenter, faVolumeHigh } from '@fortawesome/free-solid-svg-icons';
import { faCompactDisc, faComputer, faDisplay, faLanguage, faLightbulb, faMicrochip, faTelevision, faUpRightAndDownLeftFromCenter, faVolumeHigh } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { onMounted, ref, type Ref } from 'vue';
import { iidx, IIDXDisplayMode, IIDXSoundMode } from '@/modules/iidx';
Expand Down Expand Up @@ -116,6 +116,14 @@ function updateDisplayMode(e: Event) {
iidx.config.value.displayMode = parseInt((e.target as HTMLInputElement).value);
}
function updateGraphicsAPI(e: Event) {
if (!iidx.config.value) {
return;
}
iidx.config.value.graphicsAPI = parseInt((e.target as HTMLInputElement).value);
}
function updateResoltion(e: Event) {
if (!iidx.config.value) {
return;
Expand Down Expand Up @@ -191,6 +199,17 @@ async function save() {
<option value="2">窗口化</option>
</select>
</div>
<div class="item">
<h3>
<FontAwesomeIcon :icon="faComputer"></FontAwesomeIcon>
图形API
</h3>
<select class="text-input" v-bind:value="iidx.config.value?.graphicsAPI" @change="updateGraphicsAPI">
<option value="0">原生D3D9</option>
<option value="1">D3D9On12</option>
<option value="2">DXVK</option>
</select>
</div>
<div class="item optional" :class="{ show: iidx.config.value?.displayMode != IIDXDisplayMode.BorderlessWindowed }">
<h3>
<FontAwesomeIcon :icon="faUpRightAndDownLeftFromCenter"></FontAwesomeIcon>
Expand Down
48 changes: 45 additions & 3 deletions src/client/component/iidx/custom_resolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,56 @@ namespace iidx::custom_resolution
return h;
}

int graphicsAPI() {
static auto api = std::stoi(game::environment::get_param("IIDX_GRAPHICS_API"));
return api;
}

namespace
{
HRESULT WINAPI create_d3d9ex(UINT SDKVersion, IDirect3D9Ex** ppD3D9Ex)
{
IDirect3D9Ex* d3d9ex = nullptr;

auto hr = Direct3DCreate9Ex(SDKVersion, &d3d9ex);

HRESULT hr = 0;
switch (graphicsAPI())
{
case 0:
{
hr = Direct3DCreate9Ex(SDKVersion, &d3d9ex);
break;
}
case 1:
{
ID3D12Device* device = nullptr;
auto d3d12hr = D3D12CreateDevice(nullptr, D3D_FEATURE_LEVEL_11_1, __uuidof(ID3D12Device), (void**)&device);
if (!SUCCEEDED(d3d12hr))
{
return d3d12hr;
}
_D3D9ON12_ARGS arg;
arg.Enable9On12 = TRUE;
arg.pD3D12Device = device;
arg.NumQueues = 0;
hr = Direct3DCreate9On12Ex(SDKVersion, &arg, 1, &d3d9ex);
break;
}
case 2:
{
auto dxvk = LoadLibraryW(L"dxvk.dll");
if (!dxvk)
{
return -1;
}
auto dxvkDirect3DCreate9Ex = GetProcAddress(dxvk, "Direct3DCreate9Ex");
hr = ((HRESULT(*)(UINT SDKVersion, IDirect3D9Ex * *ppD3D9Ex))dxvkDirect3DCreate9Ex)(SDKVersion, &d3d9ex);
break;
}
default:
{
hr = Direct3DCreate9Ex(SDKVersion, &d3d9ex);
break;
}
}
if (SUCCEEDED(hr))
{
*ppD3D9Ex = new d3d9ex_proxy(d3d9ex);
Expand Down
6 changes: 3 additions & 3 deletions src/client/resource.g.rc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
ID_ASSET_0 RCDATA "resources/ui-dist/favicon.ico"
ID_ASSET_1 RCDATA "resources/ui-dist/index.html"
ID_ASSET_2 RCDATA "resources/ui-dist/assets/gitadora-cQ1BqJ9U.webm"
ID_ASSET_3 RCDATA "resources/ui-dist/assets/howler-BNH429fS.js"
ID_ASSET_3 RCDATA "resources/ui-dist/assets/howler-CTWA-ZGT.js"
ID_ASSET_4 RCDATA "resources/ui-dist/assets/iidx-BAOXvOlX.jpg"
ID_ASSET_5 RCDATA "resources/ui-dist/assets/index-i3wpVxTJ.css"
ID_ASSET_6 RCDATA "resources/ui-dist/assets/index-xFWPT9M3.js"
ID_ASSET_5 RCDATA "resources/ui-dist/assets/index-BGCGHj6k.css"
ID_ASSET_6 RCDATA "resources/ui-dist/assets/index-D1NvJlV7.js"
ID_ASSET_7 RCDATA "resources/ui-dist/assets/moai-bg-BU2gdkgA.jpg"
ID_ASSET_8 RCDATA "resources/ui-dist/assets/msyhsb-CG5zefP1.woff2"
ID_ASSET_9 RCDATA "resources/ui-dist/assets/num-BvRoq2n1.png"
Expand Down
6 changes: 3 additions & 3 deletions src/client/resources/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ namespace laochan::embedded
rtn.emplace("", saucer::embedded_file{"text/html", root});

rtn.emplace("assets/gitadora-cQ1BqJ9U.webm", saucer::embedded_file{"video/webm", read_resource(ID_ASSET_2)});
rtn.emplace("assets/howler-BNH429fS.js", saucer::embedded_file{"text/javascript", read_resource(ID_ASSET_3)});
rtn.emplace("assets/howler-CTWA-ZGT.js", saucer::embedded_file{"text/javascript", read_resource(ID_ASSET_3)});
rtn.emplace("assets/iidx-BAOXvOlX.jpg", saucer::embedded_file{"image/jpeg", read_resource(ID_ASSET_4)});
rtn.emplace("assets/index-i3wpVxTJ.css", saucer::embedded_file{"text/css", read_resource(ID_ASSET_5)});
rtn.emplace("assets/index-xFWPT9M3.js", saucer::embedded_file{"text/javascript", read_resource(ID_ASSET_6)});
rtn.emplace("assets/index-BGCGHj6k.css", saucer::embedded_file{"text/css", read_resource(ID_ASSET_5)});
rtn.emplace("assets/index-D1NvJlV7.js", saucer::embedded_file{"text/javascript", read_resource(ID_ASSET_6)});
rtn.emplace("assets/moai-bg-BU2gdkgA.jpg", saucer::embedded_file{"image/jpeg", read_resource(ID_ASSET_7)});
rtn.emplace("assets/msyhsb-CG5zefP1.woff2", saucer::embedded_file{"font/woff2", read_resource(ID_ASSET_8)});
rtn.emplace("assets/num-BvRoq2n1.png", saucer::embedded_file{"image/png", read_resource(ID_ASSET_9)});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/client/resources/ui-dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
<script type="module" crossorigin src="/assets/index-xFWPT9M3.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-i3wpVxTJ.css">
<script type="module" crossorigin src="/assets/index-D1NvJlV7.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BGCGHj6k.css">
</head>
<body>
<div id="app"></div>
Expand Down
3 changes: 3 additions & 0 deletions src/client/std_include.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#include <iphlpapi.h>
#include <wincrypt.h>
#include <d3d9.h>
#include <d3d9on12.h>
#include <d3d12.h>

// min and max is required by gdi, therefore NOMINMAX won't work
#ifdef max
Expand Down Expand Up @@ -109,6 +111,7 @@
#pragma comment(lib, "dwmapi.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3d12.lib")

#include "resource.hpp"

Expand Down

0 comments on commit fb3a700

Please sign in to comment.