Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NRGJobro committed May 2, 2023
1 parent 84bf7d5 commit c7c75f8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Minecraft DX12 With Imgui.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{b0e14f64-61ce-4caf-9af0-9f05dc6d1fa8}</ProjectGuid>
<RootNamespace>MinecraftDX12WithImgui</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.22621.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -112,6 +112,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -129,6 +130,7 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
30 changes: 25 additions & 5 deletions Utils/HookImgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,31 +517,51 @@ 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<ID3D12GraphicsCommandList*>(ppCommandLists), true);
oExecuteCommandListsD3D12(queue, NumCommandLists, ppCommandLists);
};

//Instanced
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);
}

//Indexed
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);
}

Expand Down

0 comments on commit c7c75f8

Please sign in to comment.