Skip to content

Commit

Permalink
Add SGSR sample
Browse files Browse the repository at this point in the history
Signed-off-by: Rodrigo Holztrattner <[email protected]>
  • Loading branch information
RodrigoHolztrattner-QuIC committed Feb 7, 2024
1 parent 8d95c2c commit 7136950
Show file tree
Hide file tree
Showing 48 changed files with 2,082 additions and 133 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,7 @@ samples/hello-gltf/assets_tmp/
samples/rotatedCopy/assets_tmp/
samples/shaderResolveTonemap/assets_tmp/
samples/SubPass/assets_tmp/
samples/BloomImageProcessing/assets_tmp/
project/tools/ktx.dll
project/tools/ktxinfo.exe
project/tools/toktx.exe
4 changes: 2 additions & 2 deletions framework/code/graphicsApi/graphicsApiBase.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//============================================================================================================
//
//
// Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
//============================================================================================================
Expand Down Expand Up @@ -58,7 +58,7 @@ auto* apiCast(T* rBase) {
template<class T_GFXAPI, typename T>
auto apiCast(std::unique_ptr<T>&& rBase) {
using tDerived = typename T::template tApiDerived<T_GFXAPI>;
return std::unique_ptr<tDerived>(static_cast<tDerived*>(rBase.get()));
return std::unique_ptr<tDerived>(static_cast<tDerived*>(rBase.release()));
}


Expand Down
8 changes: 7 additions & 1 deletion framework/code/main/frameworkApplicationBase.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//============================================================================================================
//
//
// Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
//============================================================================================================
Expand All @@ -13,7 +13,13 @@
#include "system/os_common.h"

// Bring in the timestamp (and assign to a variable)
// Temporary fix for Android not building the timestamp, upstream cmake update will fix this in a future update
#if defined(_WIN32)
#include "../../project/buildtimestamp.h"
#else
#define BUILD_TIMESTAMP "UNDEFINED"
#endif

const char* const FrameworkApplicationBase::sm_BuildTimestamp = BUILD_TIMESTAMP;


Expand Down
7 changes: 6 additions & 1 deletion framework/code/mesh/instanceGenerator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//============================================================================================================
//
//
// Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
//============================================================================================================
Expand All @@ -11,6 +11,11 @@
#include <glm/gtx/norm.hpp>
#define EIGEN_INITIALIZE_MATRICES_BY_ZERO
#define EIGEN_MPL2_ONLY

#if defined(_WIN32)
#define EIGEN_HAS_STD_RESULT_OF 0
#endif

#include <eigen/Eigen/Dense>
#include <map>
#include <algorithm>
Expand Down
8 changes: 4 additions & 4 deletions framework/code/texture/texture.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//============================================================================================================
//
//
// Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
//============================================================================================================
Expand Down Expand Up @@ -202,18 +202,18 @@ std::unique_ptr<Texture> CreateTextureObject(GraphicsApiBase& gfxApi, const Crea

/// Create texture from a memory buffer.
template<typename T_GFXAPI>
TextureT<T_GFXAPI> CreateTextureFromBuffer( T_GFXAPI& gfxApi, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName = nullptr )
TextureT<T_GFXAPI> CreateTextureFromBuffer( T_GFXAPI& gfxApi, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName = nullptr, uint32_t extraFlags = 0 )
{
assert( 0 && "Expecting CreateTextureFromBuffer (per graphics api) to be used" );
return {};
}

/// Create texture (unique_ptr) (generally for render target usage). Uses CreateTexObjectInfo structure to define texture creation parameters.
template<typename T_GFXAPI>
std::unique_ptr<Texture> CreateTextureFromBuffer( GraphicsApiBase& gfxApi, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName = nullptr )
std::unique_ptr<Texture> CreateTextureFromBuffer( GraphicsApiBase& gfxApi, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName = nullptr, uint32_t extraFlags = 0 )
{
auto pTexture = std::make_unique<TextureT<T_GFXAPI>>();
*pTexture = std::move( CreateTextureFromBuffer( static_cast<T_GFXAPI&>( gfxApi ), pData, DataSize, Width, Height, Depth, Format, SamplerMode, Filter, pName ) );
*pTexture = std::move( CreateTextureFromBuffer( static_cast<T_GFXAPI&>( gfxApi ), pData, DataSize, Width, Height, Depth, Format, SamplerMode, Filter, pName, extraFlags) );
return pTexture;
}

Expand Down
4 changes: 2 additions & 2 deletions framework/code/texture/textureManager.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//============================================================================================================
//
//
// Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
//============================================================================================================
Expand Down Expand Up @@ -81,7 +81,7 @@ class TextureManager
virtual std::unique_ptr<Texture> CreateTextureObjectView( GraphicsApiBase& gfxApi, const Texture& original, TextureFormat viewFormat ) = 0;

/// Create texture from a block of texture data in memory (with correct format, span etc).
virtual std::unique_ptr<Texture> CreateTextureFromBuffer( GraphicsApiBase&, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName) = 0;
virtual std::unique_ptr<Texture> CreateTextureFromBuffer( GraphicsApiBase&, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName, uint32_t extraFlags = 0) = 0;

/// Get a 'default' sampler for the given address mode (all other sampler settings assumed to be 'normal' ie linearly sampled etc)
virtual const Sampler* const GetSampler( SamplerAddressMode ) const = 0;
Expand Down
5 changes: 3 additions & 2 deletions framework/code/texture/vulkan/texture.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//============================================================================================================
//
//
// Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
//============================================================================================================
Expand Down Expand Up @@ -730,7 +730,7 @@ TextureT<Vulkan> CreateTextureObjectView( Vulkan& vulkan, const TextureT<Vulkan>

//-----------------------------------------------------------------------------
template<>
TextureT<Vulkan> CreateTextureFromBuffer<Vulkan>( Vulkan& vulkan, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName )
TextureT<Vulkan> CreateTextureFromBuffer<Vulkan>( Vulkan& vulkan, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName, uint32_t extraFlags )
//-----------------------------------------------------------------------------
{
if (pName == nullptr)
Expand All @@ -742,6 +742,7 @@ TextureT<Vulkan> CreateTextureFromBuffer<Vulkan>( Vulkan& vulkan, const void* pD
uint32_t MipLevels = 1;
VkFormat vkFormat = TextureFormatToVk( Format );
VkImageUsageFlags FinalUsage = ( VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT );
FinalUsage |= (VkImageUsageFlags)extraFlags;
VkImageLayout FinalLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;

// Image creation info. Will change below based on need
Expand Down
4 changes: 2 additions & 2 deletions framework/code/texture/vulkan/texture.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//============================================================================================================
//
//
// Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
//============================================================================================================
Expand Down Expand Up @@ -110,7 +110,7 @@ TextureT<Vulkan> CreateTextureObject<Vulkan>( Vulkan&, const CreateTexObjectInfo

/// Template specialization for Vulkan CreateTextureFromBuffer
template<>
TextureT<Vulkan> CreateTextureFromBuffer<Vulkan>( Vulkan&, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName );
TextureT<Vulkan> CreateTextureFromBuffer<Vulkan>( Vulkan&, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName, uint32_t extraFlags );

/// Create a texture that views (aliases) another texture but using a different texture format (must be 'related' formats, which formats are related is dependant on graphics api)
TextureT<Vulkan> CreateTextureObjectView( Vulkan&, const TextureT<Vulkan>& original, TextureFormat viewFormat );
Expand Down
6 changes: 3 additions & 3 deletions framework/code/texture/vulkan/textureManager.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//============================================================================================================
//
//
// Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
//============================================================================================================
Expand Down Expand Up @@ -200,11 +200,11 @@ std::unique_ptr<Texture> TextureManagerT<Vulkan>::CreateTextureObject(GraphicsAp
}

//-----------------------------------------------------------------------------
std::unique_ptr<Texture> TextureManagerT<Vulkan>::CreateTextureFromBuffer( GraphicsApiBase& gfxApi, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName )
std::unique_ptr<Texture> TextureManagerT<Vulkan>::CreateTextureFromBuffer( GraphicsApiBase& gfxApi, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName, uint32_t extraFlags)
//-----------------------------------------------------------------------------
{
auto pTexture = std::make_unique<TextureT<Vulkan>>();
*pTexture = ::CreateTextureFromBuffer( static_cast<Vulkan&>( gfxApi ), pData, DataSize, Width, Height, Depth, Format, SamplerMode, Filter, pName );
*pTexture = ::CreateTextureFromBuffer( static_cast<Vulkan&>( gfxApi ), pData, DataSize, Width, Height, Depth, Format, SamplerMode, Filter, pName, extraFlags);
return pTexture;
}

Expand Down
4 changes: 2 additions & 2 deletions framework/code/texture/vulkan/textureManager.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//============================================================================================================
//
//
// Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
//
//============================================================================================================
Expand Down Expand Up @@ -49,7 +49,7 @@ class TextureManagerT<Vulkan> final : public TextureManager

/// Create texture from a block of texture data in memory (with correct format, span etc).
/// Implements the base class virtual function.
std::unique_ptr<Texture> CreateTextureFromBuffer( GraphicsApiBase&, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName ) override;
std::unique_ptr<Texture> CreateTextureFromBuffer( GraphicsApiBase&, const void* pData, size_t DataSize, uint32_t Width, uint32_t Height, uint32_t Depth, TextureFormat Format, SamplerAddressMode SamplerMode, SamplerFilter Filter, const char* pName, uint32_t extraFlags = 0 ) override;

/// Create a texture that views (aliases) another texture but using a different texture format (must be 'related' formats, which formats are related is dependant on graphics api)
/// Implements the base class virtual function.
Expand Down
5 changes: 3 additions & 2 deletions project/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include ':empty', ':hello-gltf', ':hdrSwapchain', ':SubPass', ':shaderResolveTonemap', ':rotatedCopy', ':BloomImageProcessing', ':rayQueryShadows',':rayReflections'
include ':empty', ':hello-gltf', ':hdrSwapchain', ':SubPass', ':shaderResolveTonemap', ':rotatedCopy', ':BloomImageProcessing', ':rayQueryShadows',':rayReflections',':sgsr'

project(':empty').projectDir = new File('../../samples/empty')
project(':hello-gltf').projectDir = new File('../../samples/hello-gltf')
Expand All @@ -8,4 +8,5 @@ project(':shaderResolveTonemap').projectDir = new File('../../samples/shaderReso
project(':rotatedCopy').projectDir = new File('../../samples/rotatedCopy')
project(':BloomImageProcessing').projectDir = new File('../../samples/BloomImageProcessing')
project(':rayQueryShadows').projectDir = new File('../../samples/rayQueryShadows')
project(':rayReflections').projectDir = new File('../../samples/rayReflections')
project(':rayReflections').projectDir = new File('../../samples/rayReflections')
project(':sgsr').projectDir = new File('../../samples/sgsr')
1 change: 1 addition & 0 deletions project/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ if(FRAMEWORK_ENABLE_VULKAN)
add_subdirectory(../../samples/BloomImageProcessing/ samples/BloomImageProcessing)
add_subdirectory(../../samples/rayQueryShadows/ samples/rayQueryShadows)
add_subdirectory(../../samples/rayReflections/ samples/rayReflections)
add_subdirectory(../../samples/sgsr/ samples/sgsr)
endif()
53 changes: 0 additions & 53 deletions samples/BloomImageProcessing/01_CompileShaders.bat

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ adb uninstall com.quic.BloomImageProcessing
@echo ****************************************
@echo Install ..\..\build\android\BloomImageProcessing\outputs\apk\debug\BloomImageProcessing-debug.apk
@echo ****************************************
adb install -r ..\..\build\android\BloomImageProcessing\outputs\apk\debug\BloomImageProcessing-debug.apk
adb install -r -g ..\..\build\android\BloomImageProcessing\outputs\apk\debug\BloomImageProcessing-debug.apk

@echo.
@echo ****************************************
Expand Down
18 changes: 2 additions & 16 deletions samples/BloomImageProcessing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ The following dependencies must be installed and the appropriate locations shoul
* CMake
* Android Studio

### Pre-Build

Compile the underlying shaders to .spv by running the batch file below:

```
01_CompileShaders.bat
```

And convert the needed textures to the correct format using the batch file below:

```
02_PrepareMedia.bat
```

### Build

Once the dependencies are installed and shaders compiled, building this sample .apk/.exe is as simple as running any of the batch files from the framework root directory, accordingly to your target system:
Expand All @@ -45,13 +31,13 @@ Once the dependencies are installed and shaders compiled, building this sample .
To deploy the media files and the .apk to a connected device, run the batch file below:

```
03_Install_APK.bat
01_Install_APK.bat
```

Optionally you can change the default configurations for this sample by upating the file **app_config.txt** and running the batch file below:

```
04_InstallConfig.bat
02_InstallConfig.bat
```

## Android Studio
Expand Down
Loading

0 comments on commit 7136950

Please sign in to comment.