Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix app icon not showing when app is started in fullscreen #51

Merged
merged 8 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# refer to the root source directory of the project as ${HELLO_SOURCE_DIR} and
# to the root binary directory of the project as ${HELLO_BINARY_DIR}.
cmake_minimum_required (VERSION 3.4)
set(CMAKE_GENERATOR_PLATFORM x64)

project (VQE)

Expand Down
2 changes: 1 addition & 1 deletion Libs/VQUtils
Submodule VQUtils updated 1 files
+0 −1 CMakeLists.txt
52 changes: 27 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

VQE is **VQEngine**: A DX12 rewrite of [VQEngine-Vanilla](https://github.com/vilbeyli/VQEngine) for fast prototyping of rendering techniques and experimenting with cutting-edge technology.

![](Screenshots/HelloTriangle.png)
![](Screenshots/HelloCube.png)

VQE aims to support
VQE supports

- Automated build & testing
- Multi-threaded, highly parallel execution
- Update & Render Threads
- ThreadPool of worker threads
- Multiple monitors
- HDR display support (WIP)
- Multiple windows on multiple monitors
- HDR displays (WIP)
- Real-time and offline Ray Tracing (WIP)


See [Releases](https://github.com/vilbeyli/VQE/releases) if you want to download the source & pre-built executables.
See [Releases](https://github.com/vilbeyli/VQE/releases) to download the source & pre-built executables.

# Build

Expand All @@ -27,7 +27,7 @@ Make sure to have pre-requisites installed
- [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/)
- [Windows 10 SDK 10.0.18362.0](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk)

Then, run the build scripts in `Build/` folder,
Then, run one of the build scripts in `Build/` folder,

- `GenerateSolutions.bat` to build from source with Visual Studio
- `VQE.sln` can be found in `Build/SolutionFiles` directory
Expand All @@ -37,9 +37,28 @@ Then, run the build scripts in `Build/` folder,

# Run

`VQE.exe` can be configured through a settings file `EngineSettings.ini` in `Data/` folder next to it.
Run `VQE.exe`.

It also supports some command line parameters.
The engine can be configured through the settings file `EngineSettings.ini` in the `Data/` folder next to the executable.

Command line parameters are also supported.

## Settings

VQE can be configured through `Data/EngineConfig.ini` file

| Graphics Settings | |
| :-- | :-- |
| `ResolutionX=<int>` | Sets application render resolution width |
| `ResolutionY=<int>` | Sets application render resolution height |
| `VSync=<bool>` <br/> (TO BE IMPLEMENTED) | Toggles VSync based on the specified `<bool>` |

<br/>

| Engine | |
| :-- | :-- |
| `Width=<int>` | Sets application main window width |
| `Height=<int>` | Sets application main window height |

## Command Line

Expand All @@ -60,23 +79,6 @@ VQE supports the following command line parameters:
| `-TripleBuffering` | Initializes SwapChain with 3 back buffers |
| `-DoubleBuffering` | Initializes SwapChain with 2 back buffers |

<br>

VQE can be configured through `Data/EngineConfig.ini` file

| Graphics Settings | |
| :-- | :-- |
| `ResolutionX=<int>` | Sets application render resolution width |
| `ResolutionY=<int>` | Sets application render resolution height |
| `VSync=<bool>` <br/> (TO BE IMPLEMENTED) | Toggles VSync on/off based on the specified `<bool>` |

<br/>

| Engine | |
| :-- | :-- |
| `Width=<int>` | Sets application main window width |
| `Height=<int>` | Sets application main window height |


**Note:** Command line parameters will override the `EngineSettings.ini` values.

Expand Down
Binary file added Screenshots/HelloCube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 18 additions & 24 deletions Source/Application/VQEngine_Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,39 +297,33 @@ void VQEngine::RenderThread_RenderDebugWindow()
};
pCmd->ClearRenderTargetView(rtvHandle, clearColor, 0, nullptr);

#if 0
#if 1
// Draw Triangle
pCmd->OMSetRenderTargets(1, &rtvHandle, FALSE, NULL);

pCmd->SetPipelineState(mRenderer.GetPSO(EBuiltinPSOs::HELLO_WORLD_TRIANGLE_PSO));
pCmd->SetGraphicsRootSignature(mRenderer.GetRootSignature(EVertexBufferType::COLOR_AND_ALPHA));

#if 0
//pCmd->SetDescriptorHeaps(_countof(), NULL);
//pCmd->SetGraphicsRootDescriptorTable(0, g_MainDescriptorHeap[g_FrameIndex]->GetGPUDescriptorHandleForHeapStart()))
//pCmd->SetGraphicsRootDescriptorTable(2, g_MainDescriptorHeap[g_FrameIndex]->GetGPUDescriptorHandleForHeapStart()))
//pCmd->SetGraphicsRootConstantBufferView(1, )
#endif

const Mesh& TriangleMesh = mBuiltinMeshes[EBuiltInMeshes::TRIANGLE];
const auto& VBIBIDs = TriangleMesh.GetIABufferIDs();
const BufferID& VB_ID = VBIBIDs.first;
const BufferID& IB_ID = VBIBIDs.second;
const VBV& vbv = mRenderer.GetVertexBufferView(VB_ID);
const IBV& ibv = mRenderer.GetIndexBufferView(IB_ID);
const float RenderResolutionX = static_cast<float>(ctx.MainRTResolutionX);
const float RenderResolutionY = static_cast<float>(ctx.MainRTResolutionY);
D3D12_VIEWPORT viewport{ 0.0f, 0.0f, RenderResolutionX, RenderResolutionY, 0.0f, 1.0f };
pCmd->RSSetViewports(1, &viewport);

D3D12_RECT scissorsRect{ 0, 0, (LONG)RenderResolutionX, (LONG)RenderResolutionY };
pCmd->RSSetScissorRects(1, &scissorsRect);

const auto VBIBIDs = mBuiltinMeshes[EBuiltInMeshes::TRIANGLE].GetIABufferIDs();
const BufferID& VB_ID = VBIBIDs.first;
const BufferID& IB_ID = VBIBIDs.second;
const VBV& vb = mRenderer.GetVertexBufferView(VB_ID);
const IBV& ib = mRenderer.GetIndexBufferView(IB_ID);

pCmd->SetPipelineState(mRenderer.GetPSO(EBuiltinPSOs::HELLO_WORLD_TRIANGLE_PSO));
pCmd->SetGraphicsRootSignature(mRenderer.GetRootSignature(0));

pCmd->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
pCmd->IASetVertexBuffers(0, 1, &vb);
pCmd->IASetIndexBuffer(&ib);
pCmd->IASetVertexBuffers(0, 1, &vbv);
pCmd->IASetIndexBuffer(&ibv);

pCmd->DrawIndexedInstanced(3, 1, 0, 0, 0);
pCmd->RSSetViewports(1, &viewport);
pCmd->RSSetScissorRects(1, &scissorsRect);

pCmd->OMSetRenderTargets(1, &rtvHandle, FALSE, NULL);

pCmd->DrawIndexedInstanced(TriangleMesh.GetNumIndices(), 1, 0, 0, 0);
#endif

// Transition SwapChain for Present
Expand Down
2 changes: 1 addition & 1 deletion Source/Application/VQEngine_Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void VQEngine::UpdateThread_PostUpdate()

void VQEngine::Load_SceneData_Dispatch()
{
//mUpdateWorkerThreads.AddTask([&]() { Sleep(2000); Log::Info("Worker SLEEP done!"); }); // simulate 2second loading time
mUpdateWorkerThreads.AddTask([&]() { Sleep(1000); Log::Info("Worker SLEEP done!"); }); // simulate 1second loading time
mUpdateWorkerThreads.AddTask([&]()
{
const int NumBackBuffer_WndMain = mRenderer.GetSwapChainBackBufferCount(mpWinMain);
Expand Down
16 changes: 14 additions & 2 deletions Source/Application/VQEngine_WindowEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "VQEngine.h"

constexpr int MIN_WINDOW_SIZE = 128; // make sure window cannot be resized smaller than 128x128


#define LOG_WINDOW_MESSAGE_EVENTS 0
Expand Down Expand Up @@ -48,7 +49,13 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (pWindow->pOwner) pWindow->pOwner->OnWindowResize(hwnd);
return 0;
}

case WM_GETMINMAXINFO:
{
LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
lpMMI->ptMinTrackSize.x = MIN_WINDOW_SIZE;
lpMMI->ptMinTrackSize.y = MIN_WINDOW_SIZE;
break;
}
case WM_KEYDOWN:
if (pWindow->pOwner) pWindow->pOwner->OnWindowKeyDown(wParam);
return 0;
Expand Down Expand Up @@ -108,7 +115,12 @@ void VQEngine::OnWindowResize(HWND hWnd)
GetClientRect(hWnd, &clientRect);
int w = clientRect.right - clientRect.left;
int h = clientRect.bottom - clientRect.top;


#if 0 // MinWindowSize prevents the crash from h==0, no need for the code below.
if (h == 0) { h = 8; Log::Warning("WND RESIZE TOO SMALL"); }
if (w == 0) { w = 8; Log::Warning("WND RESIZE TOO SMALL"); }
#endif

// Due to multi-threading, this thread will record the events and
// Render Thread will process the queue at the of a render loop
mWinEventQueue.AddItem(std::make_unique<WindowResizeEvent>(w, h, hWnd));
Expand Down
45 changes: 22 additions & 23 deletions Source/Application/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@

#include <dxgi1_6.h>

static RECT CenterScreen(const RECT& screenRect, const RECT& wndRect)
{
RECT centered = {};

const int szWndX = wndRect.right - wndRect.left;
const int szWndY = wndRect.bottom - wndRect.top;
const int offsetX = (screenRect.right - screenRect.left - szWndX) / 2;
const int offsetY = (screenRect.bottom - screenRect.top - szWndY) / 2;

centered.left = screenRect.left + offsetX;
centered.right = centered.left + szWndX;
centered.top = screenRect.top + offsetY;
centered.bottom = centered.top + szWndY;

return centered;
}

///////////////////////////////////////////////////////////////////////////////
IWindow::~IWindow()
{
Expand All @@ -65,14 +82,13 @@ Window::Window(const std::string& title, FWindowDesc& initParams)
, isFullscreen_(initParams.bFullscreen)
{
// https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles
DWORD style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE;
UINT FlagWindowStyle = WS_OVERLAPPEDWINDOW;

::RECT rect;
::SetRect(&rect, 0, 0, width_, height_);
::AdjustWindowRect(&rect, style, FALSE);
::AdjustWindowRect(&rect, FlagWindowStyle, FALSE);

HWND hwnd_parent = NULL;
UINT FlagWindowStyle = WS_OVERLAPPEDWINDOW;

windowClass_.reset(new WindowClass("VQWindowClass", initParams.hInst, initParams.pfnWndProc));

Expand Down Expand Up @@ -111,30 +127,13 @@ Window::Window(const std::string& title, FWindowDesc& initParams)
}
return b;
};
auto fnCenterScreen = [](const RECT& screenRect, const RECT& wndRect) -> RECT
{
RECT centered = {};

const int szWndX = wndRect.right - wndRect.left;
const int szWndY = wndRect.bottom - wndRect.top;
const int offsetX = (screenRect.right - screenRect.left - szWndX) / 2;
const int offsetY = (screenRect.bottom - screenRect.top - szWndY) / 2;

centered.left = screenRect.left + offsetX;
centered.right = centered.left + szWndX;
centered.top = screenRect.top + offsetY;
centered.bottom = centered.top + szWndY;

return centered;
};

EnumDisplayMonitors(NULL, NULL, fnCallbackMonitorEnum, (LPARAM)&p);
const bool bPreferredDisplayNotFound =
(preferredScreenRect.right == preferredScreenRect.left == preferredScreenRect.top == preferredScreenRect.bottom )
&& (preferredScreenRect.right == CW_USEDEFAULT);
RECT centeredRect = bPreferredDisplayNotFound
? preferredScreenRect
: fnCenterScreen(preferredScreenRect, rect);

RECT centeredRect = bPreferredDisplayNotFound ? preferredScreenRect : CenterScreen(preferredScreenRect, rect);

// set fullscreen width & height based on the selected monitor
this->FSwidth_ = preferredScreenRect.right - preferredScreenRect.left;
Expand Down Expand Up @@ -220,7 +219,7 @@ void Window::ToggleWindowedFullscreen(SwapChain* pSwapChain /*= nullptr*/)
GetWindowRect(hwnd_, &rect_);

// Make the window borderless so that the client area can fill the screen.
SetWindowLong(hwnd_, GWL_STYLE, windowStyle_ & ~(WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_THICKFRAME));
SetWindowLong(hwnd_, GWL_STYLE, windowStyle_ & ~(WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME));

RECT fullscreenWindowRect;

Expand Down
1 change: 0 additions & 1 deletion Source/Renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required (VERSION 3.4)
set(CMAKE_GENERATOR_PLATFORM x64)

project (VQRenderer)

Expand Down
4 changes: 1 addition & 3 deletions Source/Renderer/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,7 @@ void VQRenderer::LoadPSOs()
psoDesc.PS = CD3DX12_SHADER_BYTECODE(pixelShader.Get());
psoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
psoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
psoDesc.DepthStencilState.DepthEnable = TRUE;
psoDesc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_LESS;
psoDesc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
psoDesc.DepthStencilState.DepthEnable = FALSE;
psoDesc.DepthStencilState.StencilEnable = FALSE;
psoDesc.DSVFormat = DXGI_FORMAT_D32_FLOAT;
psoDesc.SampleMask = UINT_MAX;
Expand Down
23 changes: 15 additions & 8 deletions Source/Shaders/hello-cube.hlsl
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
//*********************************************************
// VQE
// Copyright(C) 2020 - Volkan Ilbeyli
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
// This program is free software : you can redistribute it and / or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//*********************************************************
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.If not, see <http://www.gnu.org/licenses/>.
//
// Contact: [email protected]

struct PSInput
{
Expand Down