diff --git a/sources/Core/Image.cpp b/sources/Core/Image.cpp index d5cd22c679..cd718d996a 100644 --- a/sources/Core/Image.cpp +++ b/sources/Core/Image.cpp @@ -315,17 +315,17 @@ void Image::ReadPixels(const Offset3D& offset, const Extent3D& extent, const Dst ValidateImageDataSize(extent, imageDesc); /* Get source image parameters */ - const auto bpp = GetBytesPerPixel(); - const auto srcRowStride = bpp * GetExtent().width; - const auto srcDepthStride = srcRowStride * GetExtent().height; - auto src = data_.get() + GetDataPtrOffset(offset); + const std::uint32_t bpp = GetBytesPerPixel(); + const std::uint32_t srcRowStride = bpp * GetExtent().width; + const std::uint32_t srcDepthStride = srcRowStride * GetExtent().height; + const char* src = data_.get() + GetDataPtrOffset(offset); if (GetFormat() == imageDesc.format && GetDataType() == imageDesc.dataType) { /* Get destination image parameters */ - const auto dstRowStride = bpp * extent.width; - const auto dstDepthStride = dstRowStride * extent.height; - auto dst = reinterpret_cast(imageDesc.data); + const std::uint32_t dstRowStride = bpp * extent.width; + const std::uint32_t dstDepthStride = dstRowStride * extent.height; + char* dst = reinterpret_cast(imageDesc.data); /* Blit region into destination image */ BitBlit( @@ -337,7 +337,7 @@ void Image::ReadPixels(const Offset3D& offset, const Extent3D& extent, const Dst else { /* Copy region into temporary sub-image */ - Image subImage { extent, GetFormat(), GetDataType() }; + Image subImage{ extent, GetFormat(), GetDataType() }; BitBlit( extent, bpp, @@ -362,17 +362,17 @@ void Image::WritePixels(const Offset3D& offset, const Extent3D& extent, const Sr ValidateImageDataSize(extent, imageDesc); /* Get destination image parameters */ - const auto bpp = GetBytesPerPixel(); - const auto dstRowStride = bpp * GetExtent().width; - const auto dstDepthStride = dstRowStride * GetExtent().height; - auto dst = data_.get() + GetDataPtrOffset(offset); + const std::uint32_t bpp = GetBytesPerPixel(); + const std::uint32_t dstRowStride = bpp * GetExtent().width; + const std::uint32_t dstDepthStride = dstRowStride * GetExtent().height; + char* dst = data_.get() + GetDataPtrOffset(offset); if (GetFormat() == imageDesc.format && GetDataType() == imageDesc.dataType) { /* Get source image parameters */ - const auto srcRowStride = bpp * extent.width; - const auto srcDepthStride = srcRowStride * extent.height; - auto src = reinterpret_cast(imageDesc.data); + const std::uint32_t srcRowStride = bpp * extent.width; + const std::uint32_t srcDepthStride = srcRowStride * extent.height; + const char* src = reinterpret_cast(imageDesc.data); /* Blit source image into region */ BitBlit( @@ -384,7 +384,7 @@ void Image::WritePixels(const Offset3D& offset, const Extent3D& extent, const Sr else { /* Copy input data into sub-image into */ - Image subImage { extent, imageDesc.format, imageDesc.dataType }; + Image subImage{ extent, imageDesc.format, imageDesc.dataType }; ::memcpy(subImage.GetData(), imageDesc.data, imageDesc.dataSize); /* Convert sub-image */ diff --git a/sources/Platform/Win32/Win32WindowCallback.cpp b/sources/Platform/Win32/Win32WindowCallback.cpp index cffd0dfce0..37d12ee8ce 100644 --- a/sources/Platform/Win32/Win32WindowCallback.cpp +++ b/sources/Platform/Win32/Win32WindowCallback.cpp @@ -1,6 +1,6 @@ /* * Win32WindowCallback.cpp - * + * * Copyright (c) 2015 Lukas Hermanns. All rights reserved. * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). */ @@ -14,6 +14,7 @@ #ifndef HID_USAGE_PAGE_GENERIC # define HID_USAGE_PAGE_GENERIC ((USHORT)0x01) #endif + #ifndef HID_USAGE_GENERIC_MOUSE # define HID_USAGE_GENERIC_MOUSE ((USHORT)0x02) #endif @@ -45,15 +46,15 @@ static void PostKeyEvent(Window& window, Key keyCode, bool isDown) static void PostKeyEvent(HWND wnd, WPARAM wParam, LPARAM lParam, bool isDown, bool isSysKey) { /* Get window object from window handle */ - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { /* Extract key code */ - auto keyCodeSys = static_cast(wParam); - auto keyCodeOEM = static_cast(lParam & (0xff << 16)) >> 16; - bool isExtendedKey = ((lParam & (1 << 24)) != 0); + const DWORD keyCodeSys = static_cast(wParam); + const DWORD keyCodeOEM = static_cast(lParam & (0xff << 16)) >> 16; + const bool isExtendedKey = ((lParam & (1 << 24)) != 0); /* Get key code mapping first */ - auto keyCode = MapKey(static_cast(keyCodeSys)); + const Key keyCode = MapKey(static_cast(keyCodeSys)); /* Check for extended keys */ switch (keyCode) @@ -96,15 +97,15 @@ static void ReleaseMouseCapture() } } -static void CaptureMouseButton(HWND wnd, Key keyCode, bool doubleClick = false) +static void CaptureMouseButton(HWND wnd, Key keyCode, bool isDoubleClick = false) { /* Get window object from window handle */ - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { /* Post key events and capture mouse */ window->PostKeyDown(keyCode); - if (doubleClick) + if (isDoubleClick) window->PostDoubleClick(keyCode); if (++g_mouseCaptureCounter == 1) @@ -115,7 +116,7 @@ static void CaptureMouseButton(HWND wnd, Key keyCode, bool doubleClick = false) static void ReleaseMouseButton(HWND wnd, Key keyCode) { /* Get window object from window handle */ - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { /* Post key event and release mouse capture */ window->PostKeyUp(keyCode); @@ -134,7 +135,7 @@ static void ReleaseMouseButton(HWND wnd, Key keyCode) static void PostLocalMouseMotion(HWND wnd, LPARAM lParam) { /* Get window object from window handle */ - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { /* Extract mouse position from event parameter */ int x = GET_X_LPARAM(lParam); @@ -148,7 +149,7 @@ static void PostLocalMouseMotion(HWND wnd, LPARAM lParam) static void PostGlobalMouseMotion(HWND wnd, LPARAM lParam) { /* Get window object from window handle */ - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { RAWINPUT raw; UINT rawSize = sizeof(raw); @@ -160,7 +161,7 @@ static void PostGlobalMouseMotion(HWND wnd, LPARAM lParam) if (raw.header.dwType == RIM_TYPEMOUSE) { - const auto& mouse = raw.data.mouse; + const RAWMOUSE& mouse = raw.data.mouse; if (mouse.usFlags == MOUSE_MOVE_RELATIVE) { @@ -200,11 +201,11 @@ LRESULT CALLBACK Win32WindowCallback(HWND wnd, UINT msg, WPARAM wParam, LPARAM l case WM_SIZE: { /* Post resize event to window */ - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { WORD width = LOWORD(lParam); WORD height = HIWORD(lParam); - window->PostResize({ static_cast(width), static_cast(height) }); + window->PostResize(Extent2D{ width, height }); } } break; @@ -212,14 +213,14 @@ LRESULT CALLBACK Win32WindowCallback(HWND wnd, UINT msg, WPARAM wParam, LPARAM l case WM_CLOSE: { /* Post close event to window */ - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) window->PostQuit(); } break; case WM_SETFOCUS: { - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) window->PostGetFocus(); } break; @@ -227,7 +228,7 @@ LRESULT CALLBACK Win32WindowCallback(HWND wnd, UINT msg, WPARAM wParam, LPARAM l case WM_KILLFOCUS: { ReleaseMouseCapture(); - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) window->PostLostFocus(); } break; @@ -260,7 +261,7 @@ LRESULT CALLBACK Win32WindowCallback(HWND wnd, UINT msg, WPARAM wParam, LPARAM l case WM_CHAR: { - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) window->PostChar(static_cast(wParam)); } return 0; @@ -329,7 +330,7 @@ LRESULT CALLBACK Win32WindowCallback(HWND wnd, UINT msg, WPARAM wParam, LPARAM l case WM_MOUSEWHEEL: { - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) window->PostWheelMotion(GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA); } return 0; @@ -351,7 +352,7 @@ LRESULT CALLBACK Win32WindowCallback(HWND wnd, UINT msg, WPARAM wParam, LPARAM l case WM_ERASEBKGND: { /* Do not erase background to avoid flickering when user resizes the window */ - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { if (window->GetBehavior().disableClearOnResize) return 0; @@ -361,7 +362,7 @@ LRESULT CALLBACK Win32WindowCallback(HWND wnd, UINT msg, WPARAM wParam, LPARAM l case WM_ENTERSIZEMOVE: { - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { auto timerID = window->GetBehavior().moveAndResizeTimerID; if (timerID != Constants::invalidTimerID) @@ -375,7 +376,7 @@ LRESULT CALLBACK Win32WindowCallback(HWND wnd, UINT msg, WPARAM wParam, LPARAM l case WM_EXITSIZEMOVE: { - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { auto timerID = window->GetBehavior().moveAndResizeTimerID; if (timerID != Constants::invalidTimerID) @@ -389,7 +390,7 @@ LRESULT CALLBACK Win32WindowCallback(HWND wnd, UINT msg, WPARAM wParam, LPARAM l case WM_TIMER: { - if (auto window = GetWindowFromUserData(wnd)) + if (Win32Window* window = GetWindowFromUserData(wnd)) { auto timerID = static_cast(wParam); window->PostTimer(timerID); diff --git a/sources/Renderer/Direct3D11/Direct3D11.h b/sources/Renderer/Direct3D11/Direct3D11.h index 230eb869ef..c17d05c082 100644 --- a/sources/Renderer/Direct3D11/Direct3D11.h +++ b/sources/Renderer/Direct3D11/Direct3D11.h @@ -1,6 +1,6 @@ /* * Direct3D11.h - * + * * Copyright (c) 2015 Lukas Hermanns. All rights reserved. * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). */ diff --git a/sources/Renderer/Direct3D12/D3D12SwapChain.cpp b/sources/Renderer/Direct3D12/D3D12SwapChain.cpp index 17b6d46437..98356edca0 100644 --- a/sources/Renderer/Direct3D12/D3D12SwapChain.cpp +++ b/sources/Renderer/Direct3D12/D3D12SwapChain.cpp @@ -80,7 +80,7 @@ void D3D12SwapChain::SetName(const char* name) void D3D12SwapChain::Present() { /* Present swap-chain with vsync interval */ - auto hr = swapChainDXGI_->Present(syncInterval_, 0); + HRESULT hr = swapChainDXGI_->Present(syncInterval_, 0); DXThrowIfFailed(hr, "failed to present DXGI swap chain"); /* Advance frame counter */ @@ -357,7 +357,7 @@ void D3D12SwapChain::CreateDescriptorHeaps(const D3D12Device& device, std::uint3 } } -void D3D12SwapChain::CreateResolutionDependentResources(const Extent2D& resolution) +HRESULT D3D12SwapChain::CreateResolutionDependentResources(const Extent2D& resolution) { ID3D12Device* device = renderSystem_.GetDXDevice(); @@ -378,7 +378,7 @@ void D3D12SwapChain::CreateResolutionDependentResources(const Extent2D& resoluti if (swapChainDXGI_) { /* Resize swap chain */ - auto hr = swapChainDXGI_->ResizeBuffers( + HRESULT hr = swapChainDXGI_->ResizeBuffers( numColorBuffers_, resolution.width, resolution.height, @@ -389,7 +389,7 @@ void D3D12SwapChain::CreateResolutionDependentResources(const Extent2D& resoluti if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) { /* Do not continue execution of this method, device resources will be destroyed and re-created */ - return; + return hr; } else DXThrowIfFailed(hr, "failed to resize DXGI swap chain buffers"); @@ -429,6 +429,8 @@ void D3D12SwapChain::CreateResolutionDependentResources(const Extent2D& resoluti /* Create depth-stencil buffer (is used) */ if (HasDepthBuffer()) CreateDepthStencil(device, resolution); + + return S_OK; } void D3D12SwapChain::CreateColorBufferRTVs(ID3D12Device* device, const Extent2D& resolution) @@ -437,7 +439,7 @@ void D3D12SwapChain::CreateColorBufferRTVs(ID3D12Device* device, const Extent2D& for_range(i, numColorBuffers_) { /* Get render target resource from swap-chain buffer */ - auto hr = swapChainDXGI_->GetBuffer(i, IID_PPV_ARGS(colorBuffers_[i].native.ReleaseAndGetAddressOf())); + HRESULT hr = swapChainDXGI_->GetBuffer(i, IID_PPV_ARGS(colorBuffers_[i].native.ReleaseAndGetAddressOf())); DXThrowIfCreateFailed(hr, "ID3D12Resource", "for swap-chain color buffer"); colorBuffers_[i].SetInitialState(D3D12_RESOURCE_STATE_PRESENT); @@ -460,7 +462,7 @@ void D3D12SwapChain::CreateColorBufferRTVs(ID3D12Device* device, const Extent2D& for_range(i, numColorBuffers_) { /* Create render target resource */ - auto hr = device->CreateCommittedResource( + HRESULT hr = device->CreateCommittedResource( &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT), D3D12_HEAP_FLAG_NONE, &tex2DMSDesc, @@ -499,7 +501,7 @@ void D3D12SwapChain::CreateDepthStencil(ID3D12Device* device, const Extent2D& re (D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL | D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE) ); - auto hr = device->CreateCommittedResource( + HRESULT hr = device->CreateCommittedResource( &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT), D3D12_HEAP_FLAG_NONE, &tex2DDesc, diff --git a/sources/Renderer/Direct3D12/D3D12SwapChain.h b/sources/Renderer/Direct3D12/D3D12SwapChain.h index 9063bc69ae..f37b52261a 100644 --- a/sources/Renderer/Direct3D12/D3D12SwapChain.h +++ b/sources/Renderer/Direct3D12/D3D12SwapChain.h @@ -95,7 +95,7 @@ class D3D12SwapChain final : public SwapChain void CreateDescriptorHeaps(const D3D12Device& device, std::uint32_t samples); - void CreateResolutionDependentResources(const Extent2D& resolution); + HRESULT CreateResolutionDependentResources(const Extent2D& resolution); void CreateColorBufferRTVs(ID3D12Device* device, const Extent2D& resolution); void CreateDepthStencil(ID3D12Device* device, const Extent2D& resolution);