From c7c75f8f946b8946021c1b7c915b4f110887ab53 Mon Sep 17 00:00:00 2001
From: NRGJobro <85864573+NRGJobro@users.noreply.github.com>
Date: Mon, 1 May 2023 21:00:29 -0400
Subject: [PATCH] Tests
---
Minecraft DX12 With Imgui.vcxproj | 4 +++-
Utils/HookImgui.h | 30 +++++++++++++++++++++++++-----
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/Minecraft DX12 With Imgui.vcxproj b/Minecraft DX12 With Imgui.vcxproj
index e818de0..99ea34e 100644
--- a/Minecraft DX12 With Imgui.vcxproj
+++ b/Minecraft DX12 With Imgui.vcxproj
@@ -23,7 +23,7 @@
Win32Proj
{b0e14f64-61ce-4caf-9af0-9f05dc6d1fa8}
MinecraftDX12WithImgui
- 10.0
+ 10.0.22621.0
@@ -112,6 +112,7 @@
true
NotUsing
pch.h
+ stdcpp20
Windows
@@ -129,6 +130,7 @@
true
NotUsing
pch.h
+ stdcpp20
Windows
diff --git a/Utils/HookImgui.h b/Utils/HookImgui.h
index 15ddd1c..12f8fa7 100644
--- a/Utils/HookImgui.h
+++ b/Utils/HookImgui.h
@@ -517,13 +517,35 @@ HRESULT hookPresentD3D12(IDXGISwapChain3* ppSwapChain, UINT syncInterval, UINT f
return oPresentD3D12(ppSwapChain, syncInterval, flags);
};
+void SetWireframeMode(ID3D12GraphicsCommandList* dCommandList, bool enable) {
+ D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
+ //dCommandList->GetPipelineState(&psoDesc); // cant fix :cry:
+
+ if (psoDesc.RasterizerState.FillMode == (enable ? D3D12_FILL_MODE_WIREFRAME : D3D12_FILL_MODE_SOLID)) {
+ return;
+ }
+
+ psoDesc.RasterizerState.FillMode = enable ? D3D12_FILL_MODE_WIREFRAME
+ : D3D12_FILL_MODE_SOLID;
+
+ ID3D12PipelineState* pso = nullptr;
+ ID3D12Device* device = nullptr;
+ dCommandList->GetDevice(IID_PPV_ARGS(&device));
+ device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&pso));
+
+ dCommandList->SetPipelineState(pso);
+
+ pso->Release();
+ device->Release();
+}
+
//CommandList
typedef void(__thiscall* ExecuteCommandListsD3D12)(ID3D12CommandQueue*, UINT, ID3D12CommandList*);
ExecuteCommandListsD3D12 oExecuteCommandListsD3D12;
void hookExecuteCommandListsD3D12(ID3D12CommandQueue* queue, UINT NumCommandLists, ID3D12CommandList* ppCommandLists) {
if (!d3d12CommandQueue)
d3d12CommandQueue = queue;
-
+ //SetWireframeMode(reinterpret_cast(ppCommandLists), true);
oExecuteCommandListsD3D12(queue, NumCommandLists, ppCommandLists);
};
@@ -531,6 +553,7 @@ void hookExecuteCommandListsD3D12(ID3D12CommandQueue* queue, UINT NumCommandList
typedef void(__stdcall* D3D12DrawInstanced)(ID3D12GraphicsCommandList* dCommandList, UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation);
D3D12DrawInstanced o_D12DrawInstanced = NULL;
void __stdcall hkDrawInstancedD12(ID3D12GraphicsCommandList* dCommandList, UINT VertexCountPerInstance, UINT InstanceCount, UINT StartVertexLocation, UINT StartInstanceLocation) {
+ //SetWireframeMode(dCommandList, true);
return o_D12DrawInstanced(dCommandList, VertexCountPerInstance, InstanceCount, StartVertexLocation, StartInstanceLocation);
}
@@ -538,10 +561,7 @@ void __stdcall hkDrawInstancedD12(ID3D12GraphicsCommandList* dCommandList, UINT
typedef void(__stdcall* D3D12DrawIndexedInstanced)(ID3D12GraphicsCommandList* dCommandList, UINT IndexCount, UINT InstanceCount, UINT StartIndex, INT BaseVertex);
D3D12DrawIndexedInstanced o_D12DrawIndexedInstanced = NULL;
void __stdcall hkDrawIndexedInstancedD12(ID3D12GraphicsCommandList* dCommandList, UINT IndexCount, UINT InstanceCount, UINT StartIndex, INT BaseVertex) {
-
- if (countnum == IndexCount / 100)
- return;
-
+ //SetWireframeMode(dCommandList, true);
return o_D12DrawIndexedInstanced(dCommandList, IndexCount, InstanceCount, StartIndex, BaseVertex);
}