mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
Compare commits
14 commits
dev
...
release/v0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08df43628d | ||
|
|
dc719bcc65 | ||
|
|
64f67d9517 | ||
|
|
7a7f7ef9dd | ||
|
|
2660489250 | ||
|
|
f843ed530e |
||
|
|
dd743ad557 | ||
|
|
f711309ddf | ||
|
|
92a656b36c | ||
|
|
c231abe376 | ||
|
|
9ee4e90da7 | ||
|
|
5610c23424 |
||
|
|
3d0a655db1 | ||
|
|
5eb4ff606d |
19 changed files with 119 additions and 104 deletions
|
|
@ -62,8 +62,8 @@ float4 Pass1(float2 pos) {
|
|||
float ss = SPATIAL_SIGMA;
|
||||
|
||||
for (uint i = 0; i < KERNELLEN; i++) {
|
||||
float2 ipos = pos + GETOFFSET(i) * float2(inputPtX, inputPtY);
|
||||
float3 v = INPUT.Sample(sam, ipos).rgb;
|
||||
int2 ipos = GETOFFSET(i);
|
||||
float3 v = INPUT.Sample(sam, pos + ipos * float2(inputPtX, inputPtY)).rgb;
|
||||
float3 d = gaussian_vec(v, is, vc) * gaussian(length(ipos), ss, 0.0);
|
||||
sum += d * v;
|
||||
n += d;
|
||||
|
|
|
|||
|
|
@ -102,9 +102,10 @@ float4 Pass2(float2 pos) {
|
|||
uint i;
|
||||
|
||||
for (i = 0; i < KERNELLEN; i++) {
|
||||
float2 ipos = pos + GETOFFSET(i) * float2(inputPtX, inputPtY);
|
||||
histogram_v[i] = INPUT.Sample(sam, ipos).rgb;
|
||||
histogram_l[i] = lumaTex.Sample(sam, ipos).x;
|
||||
int2 ipos = GETOFFSET(i);
|
||||
float2 ppos = pos + ipos * float2(inputPtX, inputPtY);
|
||||
histogram_v[i] = INPUT.Sample(sam, ppos).rgb;
|
||||
histogram_l[i] = lumaTex.Sample(sam, ppos).x;
|
||||
histogram_w[i] = gaussian(histogram_l[i], is, vc) * gaussian(length(ipos), ss, 0.0);
|
||||
n += histogram_w[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,9 +82,10 @@ float4 Pass2(float2 pos) {
|
|||
uint i;
|
||||
|
||||
for (i = 0; i < KERNELLEN; i++) {
|
||||
float2 ipos = pos + GETOFFSET(i) * float2(inputPtX, inputPtY);
|
||||
histogram_v[i] = INPUT.Sample(sam, ipos).rgb;
|
||||
histogram_l[i] = lumaTex.Sample(sam, ipos).x;
|
||||
int2 ipos = GETOFFSET(i);
|
||||
float2 ppos = pos + ipos * float2(inputPtX, inputPtY);
|
||||
histogram_v[i] = INPUT.Sample(sam, ppos).rgb;
|
||||
histogram_l[i] = lumaTex.Sample(sam, ppos).x;
|
||||
histogram_w[i] = gaussian(histogram_l[i], is, vc) * gaussian(length(ipos), ss, 0.0);
|
||||
histogram_wn[i] = 0.0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,13 +154,13 @@ float4 Pass4(float2 pos) {
|
|||
}
|
||||
|
||||
//!PASS 5
|
||||
//!BIND tex1
|
||||
//!SAVE tex2
|
||||
//!BIND tex2
|
||||
//!SAVE tex1
|
||||
|
||||
float4 Pass5(float2 pos) {
|
||||
float l = tex1.Sample(sam, float2(pos.x - inputPtX, pos.y)).x;
|
||||
float c = tex1.Sample(sam, pos).x;
|
||||
float r = tex1.Sample(sam, float2(pos.x + inputPtX, pos.y)).x;
|
||||
float l = tex2.Sample(sam, float2(pos.x - inputPtX, pos.y)).x;
|
||||
float c = tex2.Sample(sam, pos).x;
|
||||
float r = tex2.Sample(sam, float2(pos.x + inputPtX, pos.y)).x;
|
||||
|
||||
float xgrad = (-l + r);
|
||||
float ygrad = (l + c + c + r);
|
||||
|
|
@ -169,13 +169,13 @@ float4 Pass5(float2 pos) {
|
|||
}
|
||||
|
||||
//!PASS 6
|
||||
//!BIND tex2
|
||||
//!SAVE tex1
|
||||
//!BIND tex1
|
||||
//!SAVE tex2
|
||||
|
||||
float4 Pass6(float2 pos) {
|
||||
float2 t = tex2.Sample(sam, float2(pos.x, pos.y - inputPtY)).xy;
|
||||
float cx = tex2.Sample(sam, pos).x;
|
||||
float2 b = tex2.Sample(sam, float2(pos.x, pos.y + inputPtY)).xy;
|
||||
float2 t = tex1.Sample(sam, float2(pos.x, pos.y - inputPtY)).xy;
|
||||
float cx = tex1.Sample(sam, pos).x;
|
||||
float2 b = tex1.Sample(sam, float2(pos.x, pos.y + inputPtY)).xy;
|
||||
|
||||
float xgrad = (t.x + cx + cx + b.x) / 8.0;
|
||||
|
||||
|
|
@ -186,18 +186,18 @@ float4 Pass6(float2 pos) {
|
|||
}
|
||||
|
||||
//!PASS 7
|
||||
//!BIND tex1, INPUT
|
||||
//!BIND tex2, INPUT
|
||||
|
||||
#define STRENGTH strength
|
||||
#define ITERATIONS iterations
|
||||
|
||||
float4 Pass7(float2 pos) {
|
||||
float2 d = {inputPtX, inputPtY};
|
||||
float2 d = { inputPtX, inputPtY };
|
||||
|
||||
float relstr = inputHeight / 1080.0 * STRENGTH;
|
||||
|
||||
for (int i = 0; i < ITERATIONS; i++) {
|
||||
float2 dn = tex1.SampleLevel(sam1, pos, 0).xy;
|
||||
float2 dn = tex2.SampleLevel(sam1, pos, 0).xy;
|
||||
float2 dd = (dn / (length(dn) + 0.01)) * d * relstr; //Quasi-normalization for large vectors, avoids divide by zero
|
||||
pos -= dd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,12 +83,6 @@ Texture2D tex7;
|
|||
//!FORMAT R16G16B16A16_FLOAT
|
||||
Texture2D tex8;
|
||||
|
||||
//!TEXTURE
|
||||
//!WIDTH INPUT_WIDTH
|
||||
//!HEIGHT INPUT_HEIGHT
|
||||
//!FORMAT R16G16B16A16_FLOAT
|
||||
Texture2D tex9;
|
||||
|
||||
|
||||
//!PASS 1
|
||||
//!BIND INPUT
|
||||
|
|
@ -480,7 +474,7 @@ void Pass5(float2 pos, out float4 target1, out float4 target2, out float4 target
|
|||
|
||||
//!PASS 6
|
||||
//!BIND tex7, tex1, tex3, tex2, tex4, tex5
|
||||
//!SAVE tex8, tex9
|
||||
//!SAVE tex6, tex8
|
||||
|
||||
void Pass6(float2 pos, out float4 target1, out float4 target2) {
|
||||
// [ a, d, g ]
|
||||
|
|
@ -591,21 +585,21 @@ void Pass6(float2 pos, out float4 target1, out float4 target2) {
|
|||
|
||||
|
||||
//!PASS 7
|
||||
//!BIND tex8, tex9, INPUT
|
||||
//!BIND tex6, tex8, INPUT
|
||||
|
||||
float4 Pass7(float2 pos) {
|
||||
// [ a, d, g ]
|
||||
// [ b, e, h ]
|
||||
// [ c, f, i ]
|
||||
float4 a1 = tex8.Sample(sam1, pos + float2(-outputPtX, -outputPtY));
|
||||
float4 b1 = tex8.Sample(sam1, pos + float2(-outputPtX, 0));
|
||||
float4 c1 = tex8.Sample(sam1, pos + float2(-outputPtX, outputPtY));
|
||||
float4 d1 = tex8.Sample(sam1, pos + float2(0, -outputPtY));
|
||||
float4 e1 = tex8.Sample(sam1, pos);
|
||||
float4 f1 = tex8.Sample(sam1, pos + float2(0, outputPtY));
|
||||
float4 g1 = tex8.Sample(sam1, pos + float2(outputPtX, -outputPtY));
|
||||
float4 h1 = tex8.Sample(sam1, pos + float2(outputPtX, 0));
|
||||
float4 i1 = tex8.Sample(sam1, pos + float2(outputPtX, outputPtY));
|
||||
float4 a1 = tex6.Sample(sam1, pos + float2(-outputPtX, -outputPtY));
|
||||
float4 b1 = tex6.Sample(sam1, pos + float2(-outputPtX, 0));
|
||||
float4 c1 = tex6.Sample(sam1, pos + float2(-outputPtX, outputPtY));
|
||||
float4 d1 = tex6.Sample(sam1, pos + float2(0, -outputPtY));
|
||||
float4 e1 = tex6.Sample(sam1, pos);
|
||||
float4 f1 = tex6.Sample(sam1, pos + float2(0, outputPtY));
|
||||
float4 g1 = tex6.Sample(sam1, pos + float2(outputPtX, -outputPtY));
|
||||
float4 h1 = tex6.Sample(sam1, pos + float2(outputPtX, 0));
|
||||
float4 i1 = tex6.Sample(sam1, pos + float2(outputPtX, outputPtY));
|
||||
|
||||
float4 na1 = max(-a1, 0);
|
||||
float4 nb1 = max(-b1, 0);
|
||||
|
|
@ -627,15 +621,15 @@ float4 Pass7(float2 pos) {
|
|||
h1 = max(h1, 0);
|
||||
i1 = max(i1, 0);
|
||||
|
||||
float4 a2 = tex9.Sample(sam1, pos + float2(-outputPtX, -outputPtY));
|
||||
float4 b2 = tex9.Sample(sam1, pos + float2(-outputPtX, 0));
|
||||
float4 c2 = tex9.Sample(sam1, pos + float2(-outputPtX, outputPtY));
|
||||
float4 d2 = tex9.Sample(sam1, pos + float2(0, -outputPtY));
|
||||
float4 e2 = tex9.Sample(sam1, pos);
|
||||
float4 f2 = tex9.Sample(sam1, pos + float2(0, outputPtY));
|
||||
float4 g2 = tex9.Sample(sam1, pos + float2(outputPtX, -outputPtY));
|
||||
float4 h2 = tex9.Sample(sam1, pos + float2(outputPtX, 0));
|
||||
float4 i2 = tex9.Sample(sam1, pos + float2(outputPtX, outputPtY));
|
||||
float4 a2 = tex8.Sample(sam1, pos + float2(-outputPtX, -outputPtY));
|
||||
float4 b2 = tex8.Sample(sam1, pos + float2(-outputPtX, 0));
|
||||
float4 c2 = tex8.Sample(sam1, pos + float2(-outputPtX, outputPtY));
|
||||
float4 d2 = tex8.Sample(sam1, pos + float2(0, -outputPtY));
|
||||
float4 e2 = tex8.Sample(sam1, pos);
|
||||
float4 f2 = tex8.Sample(sam1, pos + float2(0, outputPtY));
|
||||
float4 g2 = tex8.Sample(sam1, pos + float2(outputPtX, -outputPtY));
|
||||
float4 h2 = tex8.Sample(sam1, pos + float2(outputPtX, 0));
|
||||
float4 i2 = tex8.Sample(sam1, pos + float2(outputPtX, outputPtY));
|
||||
|
||||
float4 na2 = max(-a2, 0);
|
||||
float4 nb2 = max(-b2, 0);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Magpie {
|
|||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application {
|
||||
public static readonly Version APP_VERSION = new("0.8.1.0");
|
||||
public static readonly Version APP_VERSION = new("0.8.2.0");
|
||||
public static readonly string SCALE_MODELS_JSON_PATH = ".\\ScaleModels.json";
|
||||
public static readonly string LOGS_FOLDER = ".\\logs\\";
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
<PackageReference Include="MouseKeyHook" Version="5.6.0">
|
||||
<NoWarn>NU1701</NoWarn>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NLog" Version="4.7.12" />
|
||||
<PackageReference Include="NLog" Version="4.7.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ using System.Windows;
|
|||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.8.1.0")]
|
||||
[assembly: AssemblyFileVersion("0.8.1.0")]
|
||||
[assembly: AssemblyVersion("0.8.2.0")]
|
||||
[assembly: AssemblyFileVersion("0.8.2.0")]
|
||||
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
🌍 **简体中文** | [English](./README_EN.md)
|
||||
|
||||
**此分支维护一个支持 Direct3D 功能级别 10 的版本,不再添加新功能。**
|
||||
|
||||
Magpie 可以将任意窗口放大至全屏,内置大量缩放算法/滤镜。主要用于游戏窗口的放大显示,适用于不支持全屏模式,或者内置的全屏模式会使画面模糊的情况。
|
||||
|
||||
使用中遇到问题请提交 issue。
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ bool App::Run(
|
|||
if (_srcFrameRect == RECT{}) {
|
||||
// FrameSource 初始化完成后计算窗口边框,因为初始化过程中可能改变窗口位置
|
||||
if (!UpdateSrcFrameRect()) {
|
||||
SPDLOG_LOGGER_ERROR(logger, "UpdateSrcFrameRect 失败");
|
||||
SPDLOG_LOGGER_CRITICAL(logger, "UpdateSrcFrameRect 失败");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -144,13 +144,6 @@ bool App::Run(
|
|||
SPDLOG_LOGGER_INFO(logger, fmt::format("源窗口尺寸:{}x{}",
|
||||
_srcFrameRect.right - _srcFrameRect.left, _srcFrameRect.bottom - _srcFrameRect.top));
|
||||
|
||||
if (!_renderer->InitializeEffectsAndCursor(effectsJson)) {
|
||||
SPDLOG_LOGGER_CRITICAL(logger, "初始化效果失败,即将退出");
|
||||
Close();
|
||||
_Run();
|
||||
return false;
|
||||
}
|
||||
|
||||
// 禁用窗口圆角
|
||||
if (_frameSource->HasRoundCornerInWin11()) {
|
||||
const auto& version = Utils::GetOSVersion();
|
||||
|
|
@ -170,6 +163,22 @@ bool App::Run(
|
|||
}
|
||||
}
|
||||
|
||||
if (IsDisableDirectFlip() && !IsBreakpointMode()) {
|
||||
// 在此处创建的 DDF 窗口不会立刻显示
|
||||
if (!_DisableDirectFlip()) {
|
||||
SPDLOG_LOGGER_ERROR(logger, "_DisableDirectFlip 失败");
|
||||
}
|
||||
}
|
||||
|
||||
if (!_renderer->InitializeEffectsAndCursor(effectsJson)) {
|
||||
SPDLOG_LOGGER_CRITICAL(logger, "初始化效果失败,即将退出");
|
||||
Close();
|
||||
_Run();
|
||||
return false;
|
||||
}
|
||||
|
||||
ShowWindow(_hwndHost, SW_NORMAL);
|
||||
|
||||
_Run();
|
||||
|
||||
return true;
|
||||
|
|
@ -192,12 +201,14 @@ void App::_Run() {
|
|||
|
||||
_renderer->Render();
|
||||
|
||||
// 第二帧(等待时或完成后)创建 DDF 窗口
|
||||
// 第二帧(等待时或完成后)显示 DDF 窗口
|
||||
// 如果在 Run 中创建会有短暂的灰屏
|
||||
// 选择第二帧的原因:当 GetFrameCount() 返回 1 时第一帧可能处于等待状态而没有渲染,见 Renderer::Render()
|
||||
if (_renderer->GetTimer().GetFrameCount() == 2 && !_hwndDDF && IsDisableDirectFlip() && !IsBreakpointMode()) {
|
||||
if (!_DisableDirectFlip()) {
|
||||
SPDLOG_LOGGER_ERROR(logger, "_DisableDirectFlip 失败");
|
||||
if (_renderer->GetTimer().GetFrameCount() == 2 && _hwndDDF) {
|
||||
ShowWindow(_hwndDDF, SW_NORMAL);
|
||||
|
||||
if (!SetWindowPos(_hwndDDF, _hwndHost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, MakeWin32ErrorMsg("SetWindowPos 失败"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -355,8 +366,8 @@ bool App::_CreateHostWnd() {
|
|||
}
|
||||
|
||||
// 主窗口没有覆盖 Virtual Screen 则使用多屏幕模式
|
||||
// 打开断点模式时不使用多屏幕模式
|
||||
_isMultiMonitorMode = !IsBreakpointMode() && GetMultiMonitorUsage() != 2 &&
|
||||
// 启用“在 3D 游戏中限制光标”或断点模式时不使用多屏幕模式
|
||||
_isMultiMonitorMode = !IsConfineCursorIn3DGames() && !IsBreakpointMode() && GetMultiMonitorUsage() != 2 &&
|
||||
((_hostWndRect.right - _hostWndRect.left) < GetSystemMetrics(SM_CXVIRTUALSCREEN) ||
|
||||
(_hostWndRect.bottom - _hostWndRect.top) < GetSystemMetrics(SM_CYVIRTUALSCREEN));
|
||||
|
||||
|
|
@ -364,7 +375,7 @@ bool App::_CreateHostWnd() {
|
|||
(IsBreakpointMode() ? 0 : WS_EX_TOPMOST) | WS_EX_NOACTIVATE | WS_EX_LAYERED | WS_EX_TRANSPARENT,
|
||||
HOST_WINDOW_CLASS_NAME,
|
||||
HOST_WINDOW_TITLE,
|
||||
WS_CLIPCHILDREN | WS_POPUP | WS_VISIBLE,
|
||||
WS_POPUP,
|
||||
_hostWndRect.left,
|
||||
_hostWndRect.top,
|
||||
_hostWndRect.right - _hostWndRect.left,
|
||||
|
|
@ -388,10 +399,6 @@ bool App::_CreateHostWnd() {
|
|||
SPDLOG_LOGGER_ERROR(logger, MakeWin32ErrorMsg("SetLayeredWindowAttributes 失败"));
|
||||
}
|
||||
|
||||
if (!ShowWindow(_hwndHost, SW_NORMAL)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, MakeWin32ErrorMsg("ShowWindow 失败"));
|
||||
}
|
||||
|
||||
SPDLOG_LOGGER_INFO(logger, "已创建主窗口");
|
||||
return true;
|
||||
}
|
||||
|
|
@ -403,7 +410,7 @@ bool App::_DisableDirectFlip() {
|
|||
WS_EX_NOACTIVATE | WS_EX_LAYERED | WS_EX_TRANSPARENT,
|
||||
DDF_WINDOW_CLASS_NAME,
|
||||
NULL,
|
||||
WS_CLIPCHILDREN | WS_POPUP | WS_VISIBLE,
|
||||
WS_POPUP,
|
||||
_hostWndRect.left,
|
||||
_hostWndRect.top,
|
||||
_hostWndRect.right - _hostWndRect.left,
|
||||
|
|
@ -434,14 +441,6 @@ bool App::_DisableDirectFlip() {
|
|||
}
|
||||
}
|
||||
|
||||
if (!ShowWindow(_hwndDDF, SW_NORMAL)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, MakeWin32ErrorMsg("ShowWindow 失败"));
|
||||
}
|
||||
|
||||
if (!SetWindowPos(_hwndDDF, _hwndHost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW)) {
|
||||
SPDLOG_LOGGER_ERROR(logger, MakeWin32ErrorMsg("SetWindowPos 失败"));
|
||||
}
|
||||
|
||||
SPDLOG_LOGGER_INFO(logger, "已创建 DDF 主窗口");
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ Texture2D originTex : register(t0);
|
|||
Texture2D maskTex : register(t1);
|
||||
SamplerState sam : register(s0);
|
||||
|
||||
float4 main(float4 pos : SV_POSITION, float2 coord : TEXCOORD) : SV_Target{
|
||||
float4 main(float2 coord : TEXCOORD) : SV_Target{
|
||||
float2 masks = maskTex.Sample(sam, coord).xy;
|
||||
if (masks.x > 0.5) {
|
||||
float3 origin = originTex.Sample(sam, coord).rgb;
|
||||
|
|
|
|||
|
|
@ -30,5 +30,5 @@ private:
|
|||
|
||||
// 缓存版本
|
||||
// 当缓存文件结构有更改时将更新它,使得所有旧缓存失效
|
||||
static constexpr const UINT _VERSION = 2;
|
||||
static constexpr const UINT _VERSION = 3;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -955,11 +955,11 @@ UINT ResolvePass(std::string_view block, EffectDesc& desc, std::vector<std::stri
|
|||
|
||||
// main 函数
|
||||
if (passDesc.outputs.size() <= 1) {
|
||||
passHlsl.append(fmt::format("float4 __M(float4 p:SV_POSITION,float2 c:TEXCOORD):SV_TARGET"
|
||||
passHlsl.append(fmt::format("float4 __M(float2 c:TEXCOORD):SV_TARGET"
|
||||
"{{return Pass{}(c);}}", index));
|
||||
} else {
|
||||
// 多渲染目标
|
||||
passHlsl.append("void __M(float4 p:SV_POSITION,float2 c:TEXCOORD,out float4 t0:SV_TARGET0,out float4 t1:SV_TARGET1");
|
||||
passHlsl.append("void __M(float2 c:TEXCOORD,out float4 t0:SV_TARGET0,out float4 t1:SV_TARGET1");
|
||||
for (int i = 2; i < passDesc.outputs.size(); ++i) {
|
||||
passHlsl.append(fmt::format(",out float4 t{0}:SV_TARGET{0}", i));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
#include "EffectCompiler.h"
|
||||
#include <rapidjson/document.h>
|
||||
|
||||
#pragma push_macro("GetObject")
|
||||
#undef GetObject
|
||||
#include <rapidjson/document.h>
|
||||
|
||||
extern std::shared_ptr<spdlog::logger> logger;
|
||||
|
||||
|
|
@ -110,7 +113,7 @@ bool Renderer::GetShaderResourceView(ID3D11Texture2D* texture, ID3D11ShaderResou
|
|||
|
||||
bool Renderer::SetFillVS() {
|
||||
if (!_fillVS) {
|
||||
const char* src = "void m(uint i:SV_VERTEXID,out float4 p:SV_POSITION,out float2 c:TEXCOORD){c=float2(i&1,i>>1)*2;p=float4(c.x*2-1,-c.y*2+1,0,1);}";
|
||||
const char* src = "void m(uint i:SV_VERTEXID,out float2 c:TEXCOORD,out float4 p:SV_POSITION){c=float2(i&1,i>>1)*2;p=float4(c.x*2-1,-c.y*2+1,0,1);}";
|
||||
|
||||
ComPtr<ID3DBlob> blob;
|
||||
if (!CompileShader(true, src, "m", &blob, "FillVS")) {
|
||||
|
|
@ -135,7 +138,7 @@ bool Renderer::SetFillVS() {
|
|||
|
||||
bool Renderer::SetCopyPS(ID3D11SamplerState* sampler, ID3D11ShaderResourceView* input) {
|
||||
if (!_copyPS) {
|
||||
const char* src = "Texture2D t:register(t0);SamplerState s:register(s0);float4 m(float4 p:SV_POSITION,float2 c:TEXCOORD):SV_Target{return t.Sample(s,c);}";
|
||||
const char* src = "Texture2D t:register(t0);SamplerState s:register(s0);float4 m(float2 c:TEXCOORD):SV_Target{return t.Sample(s,c);}";
|
||||
|
||||
ComPtr<ID3DBlob> blob;
|
||||
if (!CompileShader(false, src, "m", &blob, "CopyPS")) {
|
||||
|
|
@ -160,7 +163,7 @@ bool Renderer::SetCopyPS(ID3D11SamplerState* sampler, ID3D11ShaderResourceView*
|
|||
|
||||
bool Renderer::SetSimpleVS(ID3D11Buffer* simpleVB) {
|
||||
if (!_simpleVS) {
|
||||
const char* src = "void m(float4 p:SV_POSITION,float2 c:TEXCOORD,out float4 q:SV_POSITION,out float2 d:TEXCOORD) {q=p;d=c;}";
|
||||
const char* src = "void m(float4 p:SV_POSITION,float2 c:TEXCOORD,out float2 d:TEXCOORD,out float4 q:SV_POSITION) {q=p;d=c;}";
|
||||
|
||||
ComPtr<ID3DBlob> blob;
|
||||
if (!CompileShader(true, src, "m", &blob, "SimpleVS")) {
|
||||
|
|
@ -316,7 +319,13 @@ bool Renderer::IsDebugLayersAvailable() {
|
|||
}
|
||||
|
||||
bool Renderer::_InitD3D() {
|
||||
HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(_dxgiFactory.ReleaseAndGetAddressOf()));
|
||||
#ifdef _DEBUG
|
||||
UINT flag = DXGI_CREATE_FACTORY_DEBUG;
|
||||
#else
|
||||
UINT flag = 0;
|
||||
#endif // _DEBUG
|
||||
|
||||
HRESULT hr = CreateDXGIFactory2(flag, IID_PPV_ARGS(_dxgiFactory.ReleaseAndGetAddressOf()));
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -333,6 +342,7 @@ bool Renderer::_InitD3D() {
|
|||
SPDLOG_LOGGER_WARN(logger, MakeComErrorMsg("CheckFeatureSupport 失败", hr));
|
||||
}
|
||||
}
|
||||
_supportTearing = !!supportTearing;
|
||||
|
||||
SPDLOG_LOGGER_INFO(logger, fmt::format("可变刷新率支持:{}", supportTearing ? "是" : "否"));
|
||||
|
||||
|
|
@ -448,8 +458,13 @@ bool Renderer::_CreateSwapChain() {
|
|||
sd.SampleDesc.Quality = 0;
|
||||
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT;
|
||||
sd.BufferCount = (App::GetInstance().IsDisableLowLatency() && App::GetInstance().GetFrameRate() == 0) ? 3 : 2;
|
||||
sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
sd.Flags = App::GetInstance().GetFrameRate() != 0 ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
// 使用 DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL 而不是 DXGI_SWAP_EFFECT_FLIP_DISCARD
|
||||
// 不渲染四周(可能存在的)黑边,因此必须保证交换链缓冲区不被改变
|
||||
// 否则将不得不在每帧渲染前清空后缓冲区,这个操作在一些显卡上比较耗时
|
||||
sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
|
||||
// 只要显卡支持始终启用 DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING
|
||||
sd.Flags = (_supportTearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0)
|
||||
| (App::GetInstance().GetFrameRate() == 0 ? DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT : 0);
|
||||
|
||||
ComPtr<IDXGISwapChain1> dxgiSwapChain = nullptr;
|
||||
HRESULT hr = _dxgiFactory->CreateSwapChainForHwnd(
|
||||
|
|
@ -1022,3 +1037,5 @@ bool Renderer::GetSampler(EffectSamplerFilterType filterType, EffectSamplerAddre
|
|||
*result = *sampler;
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma pop_macro("GetObject")
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ private:
|
|||
RECT _srcWndRect{};
|
||||
|
||||
D3D_FEATURE_LEVEL _featureLevel = D3D_FEATURE_LEVEL_10_0;
|
||||
bool _supportTearing = false;
|
||||
|
||||
ComPtr<IDXGIFactory2> _dxgiFactory;
|
||||
ComPtr<IDXGIDevice1> _dxgiDevice;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,8,1,0
|
||||
PRODUCTVERSION 0,8,1,0
|
||||
FILEVERSION 0,8,2,0
|
||||
PRODUCTVERSION 0,8,2,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
|
@ -42,12 +42,12 @@ BEGIN
|
|||
BEGIN
|
||||
BLOCK "040004b0"
|
||||
BEGIN
|
||||
VALUE "FileVersion", "0.8.1.0"
|
||||
VALUE "FileVersion", "0.8.2.0"
|
||||
VALUE "InternalName", "Runtime.dll"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2021 Liu Xu"
|
||||
VALUE "OriginalFilename", "Runtime.dll"
|
||||
VALUE "ProductName", "Magpie"
|
||||
VALUE "ProductVersion", "0.8.1.0"
|
||||
VALUE "ProductVersion", "0.8.2.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props')" />
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
|
|
@ -205,17 +205,17 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\packages\Microsoft.XAudio2.Redist.1.2.8\build\native\Microsoft.XAudio2.Redist.targets" Condition="Exists('..\packages\Microsoft.XAudio2.Redist.1.2.8\build\native\Microsoft.XAudio2.Redist.targets')" />
|
||||
<Import Project="..\packages\directxtk_desktop_2017.2021.11.8.1\build\native\directxtk_desktop_2017.targets" Condition="Exists('..\packages\directxtk_desktop_2017.2021.11.8.1\build\native\directxtk_desktop_2017.targets')" />
|
||||
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets')" />
|
||||
<Import Project="..\packages\directxtk_desktop_2017.2022.3.24.2\build\native\directxtk_desktop_2017.targets" Condition="Exists('..\packages\directxtk_desktop_2017.2022.3.24.2\build\native\directxtk_desktop_2017.targets')" />
|
||||
</ImportGroup>
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.211028.7\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.XAudio2.Redist.1.2.8\build\native\Microsoft.XAudio2.Redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.XAudio2.Redist.1.2.8\build\native\Microsoft.XAudio2.Redist.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\directxtk_desktop_2017.2021.11.8.1\build\native\directxtk_desktop_2017.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\directxtk_desktop_2017.2021.11.8.1\build\native\directxtk_desktop_2017.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.220418.1\build\native\Microsoft.Windows.CppWinRT.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\directxtk_desktop_2017.2022.3.24.2\build\native\directxtk_desktop_2017.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\directxtk_desktop_2017.2022.3.24.2\build\native\directxtk_desktop_2017.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
[requires]
|
||||
fmt/8.0.1
|
||||
spdlog/1.9.1
|
||||
fmt/8.1.1
|
||||
spdlog/1.10.0
|
||||
muparser/2.3.2
|
||||
yas/7.1.0
|
||||
rapidjson/cci.20200410
|
||||
rapidjson/cci.20211112
|
||||
|
||||
[generators]
|
||||
visual_studio
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="directxtk_desktop_2017" version="2021.11.8.1" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.211028.7" targetFramework="native" />
|
||||
<package id="directxtk_desktop_2017" version="2022.3.24.2" targetFramework="native" />
|
||||
<package id="Microsoft.Windows.CppWinRT" version="2.0.220418.1" targetFramework="native" />
|
||||
<package id="Microsoft.XAudio2.Redist" version="1.2.8" targetFramework="native" />
|
||||
</packages>
|
||||
Loading…
Add table
Add a link
Reference in a new issue