Skip to content
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
4 changes: 2 additions & 2 deletions Config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ framework\
imgui @ https://github.com/ocornut/imgui/archive/4f9ba19e520bea478f5cb654d37ef45e6404bd52.zip MD5:2d0aa43693cdada8abb9d49a44c1337b
implot @ https://github.com/epezent/implot/archive/f156599faefe316f7dd20fe6c783bf87c8bb6fd9.zip MD5:b95d158f69b1716da2cd7c17d63bdce4
portable-file-dialogs @ https://github.com/samhocevar/portable-file-dialogs/archive/7f852d88a480020d7f91957cbcefe514fc95000c.zip MD5:ec1fd9e86f260b99a50294b8f53f872f
Vulkan-Headers @ https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/v1.4.328.zip
Vulkan-Headers @ https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/v1.4.338.zip
glm @ https://github.com/g-truc/glm/archive/6ad79aae3eb5bf809c30bf1168171e9e55857e45.zip
GameSampleAssets @ https://github.com/SnapdragonStudios/game-assets-for-adreno-gpu-code-samples/archive/0ef8e70049ffd9ee4f9138b43815b21f959497d0.zip
volk @ https://github.com/zeux/volk/archive/1e0ec168f1726e6389b8647435a3018f0cef9428.zip
volk @ https://github.com/zeux/volk/archive/d34b5e0d46b28c22d69b97ee7da074b6e68d9e25.zip
SPIRV-Cross @ https://github.com/KhronosGroup/SPIRV-Cross/archive/7affe74d77f93a622bb5002789d5332d32e512ee.zip
glslang @ https://github.com/KhronosGroup/glslang/archive/3a7f78758f8faa9a6e059b09e25fc64ede7fbfb0.zip
json @ https://github.com/nlohmann/json/releases/download/v3.10.5/json.tar.xz MD5:4b67aba51ddf17c798e80361f527f50e
Expand Down
13 changes: 13 additions & 0 deletions framework/code/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ void Camera::UpdateMatrices()
glm::mat4 Camera::GetProjectionWithJitter(const glm::vec3 jitter) const
//-----------------------------------------------------------------------------
{
#if 0
glm::mat4 jm = glm::translate(jitter);
return jm * m_ProjectionMatrixNoJitter;
#else

// Assumes jitts is in NDC (not pixel).
// Remember to flip jitter y, if needed.
glm::mat4 jitteredProj = m_ProjectionMatrixNoJitter;
for (int col = 0; col < 4; ++col)
{
jitteredProj[col][0] += jitter.x * jitteredProj[col][3];
jitteredProj[col][1] += jitter.y * jitteredProj[col][3];
}
return jitteredProj;
#endif
}
52 changes: 43 additions & 9 deletions framework/code/camera/cameraControllerTouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void CameraControllerTouch::TouchDownEvent(int iPointerID, float xPos, float yPo
m_LookaroundTouchId = iPointerID;
m_LastLookaroundTouchPosition = { xPos, yPos };
m_CurrentLookaroundTouchPosition = m_LastLookaroundTouchPosition;
m_LookDeltaPixelsAccum = glm::vec2(0.0f);
}
else if (xPos < m_ScreenSize.x * 0.5f && m_MovementTouchId == -1)
{
Expand All @@ -65,7 +66,11 @@ void CameraControllerTouch::TouchMoveEvent(int iPointerID, float xPos, float yPo
{
if (iPointerID == m_LookaroundTouchId)
{
m_CurrentLookaroundTouchPosition = { xPos, yPos };
const glm::vec2 new_pos = { xPos, yPos };
const glm::vec2 delta = new_pos - m_CurrentLookaroundTouchPosition;

m_CurrentLookaroundTouchPosition = new_pos;
m_LookDeltaPixelsAccum += delta;
}
else if (iPointerID == m_MovementTouchId)
{
Expand All @@ -81,6 +86,7 @@ void CameraControllerTouch::TouchUpEvent(int iPointerID, float xPos, float yPos)
{
m_LookaroundTouchId = -1;
m_CurrentLookaroundTouchPosition = { xPos, yPos };
m_LookDeltaPixelsAccum = glm::vec2(0.0f);
}
else if (iPointerID == m_MovementTouchId)
{
Expand All @@ -94,24 +100,52 @@ void CameraControllerTouch::TouchUpEvent(int iPointerID, float xPos, float yPos)
void CameraControllerTouch::Update(float frameTime, glm::vec3& position, glm::quat& rot, bool& cut)
{
cut = false;

if (m_LookaroundTouchId != -1)
{
auto mouseDiff = m_LastLookaroundTouchPosition - m_CurrentLookaroundTouchPosition;
auto angleChange = mouseDiff * frameTime * m_RotateSpeed;
const float tau = glm::max(0.0001f, m_LookSmoothTauSec);
const float alpha = 1.0f - glm::exp(-frameTime / tau); // 0..1

const glm::vec2 applyPixels = m_LookDeltaPixelsAccum * alpha;
m_LookDeltaPixelsAccum -= applyPixels;

const glm::vec2 ndcDelta =
{
applyPixels.x / glm::max(1.0f, m_ScreenSize.x),
applyPixels.y / glm::max(1.0f, m_ScreenSize.y)
};

const float yaw = -ndcDelta.x * glm::pi<float>() * m_RotateSpeed;
const float pitch = -ndcDelta.y * glm::pi<float>() * m_RotateSpeed;

const glm::vec3 viewRight = rot * cVecViewRight;

m_LastLookaroundTouchPosition = m_CurrentLookaroundTouchPosition;
// one (touch) rotation axis is relative to the view direction, other is relative to world - prevents camera from 'twisting' although does introduce gimbal when looking along the UP axis and rotationg left/right.
rot = glm::angleAxis( angleChange.x, m_WorldUp ) * rot * glm::angleAxis( angleChange.y, cVecViewRight );
rot = glm::normalize( rot );
rot = glm::angleAxis(yaw, m_WorldUp) * rot;
rot = glm::angleAxis(pitch, viewRight) * rot;
rot = glm::normalize(rot);
}
else
{
m_LookDeltaPixelsAccum = glm::vec2(0.0f);
}

if (m_MovementTouchId != -1)
{
auto mouseDiff = m_LastMovementTouchPosition - m_CurrentMovementTouchPosition;
auto directionChange = mouseDiff * frameTime * m_MoveSpeed * cTouchMoveSpeedMultipler;
#if 1
const auto mouseDiff = m_LastMovementTouchPosition - m_CurrentMovementTouchPosition;
const auto directionChange = mouseDiff * frameTime * m_MoveSpeed * cTouchMoveSpeedMultipler;

position -= rot * cVecViewRight * directionChange.x;
position += rot * cVecViewForward * directionChange.y;
#else
const glm::vec2 mouseDiff = m_LastMovementTouchPosition - m_CurrentMovementTouchPosition;
const glm::vec2 directionChange = mouseDiff * frameTime * m_MoveSpeed * cTouchMoveSpeedMultipler;

position -= rot * cVecViewRight * directionChange.x;
position += rot * cVecViewForward * directionChange.y;

m_LastMovementTouchPosition = m_CurrentMovementTouchPosition;
#endif
}
}

3 changes: 3 additions & 0 deletions framework/code/camera/cameraControllerTouch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ class CameraControllerTouch : public CameraControllerBase

int m_MovementTouchId;
int m_LookaroundTouchId;

glm::vec2 m_LookDeltaPixelsAccum = glm::vec2(0.0f);
float m_LookSmoothTauSec = 0.03f;
};
8 changes: 4 additions & 4 deletions framework/code/graphicsApi/renderTarget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ struct RenderTargetInitializeInfo
std::span<const TextureFormat> LayerFormats = {};
TextureFormat DepthFormat = TextureFormat::UNDEFINED;
RenderTargetBase* InheritedDepthAttachment = nullptr;
const std::span<const TEXTURE_TYPE> TextureTypes = {};
const std::optional<const TEXTURE_TYPE> DepthTextureType = std::nullopt;
std::span<const TEXTURE_TYPE> TextureTypes = {};
std::optional<TEXTURE_TYPE> DepthTextureType = std::nullopt;
std::span<const Msaa> Msaa = {};
const std::span<const TextureFormat> ResolveTextureFormats = {};
const std::span<const SamplerFilter> FilterModes = {};
std::span<const TextureFormat> ResolveTextureFormats = {};
std::span<const SamplerFilter> FilterModes = {};
};

class RenderTargetBase
Expand Down
1 change: 1 addition & 0 deletions framework/code/texture/texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class ImageView final : public ImageViewBase
enum TEXTURE_TYPE
{
TT_NORMAL = 0,
TT_SAMPLED_TRANSFERDST,
TT_RENDER_TARGET,
TT_RENDER_TARGET_WITH_STORAGE,
TT_RENDER_TARGET_TRANSFERSRC,
Expand Down
6 changes: 6 additions & 0 deletions framework/code/texture/vulkan/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,10 @@ Texture<Vulkan> CreateTextureObject<Vulkan>(Vulkan& vulkan, const CreateTexObjec
ImageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;// VK_IMAGE_TILING_LINEAR; // VK_IMAGE_TILING_OPTIMAL
ImageInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
break;
case TT_SAMPLED_TRANSFERDST:
ImageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
ImageInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
break;
case TT_RENDER_TARGET:
// If using VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT then tiling MUST be VK_IMAGE_TILING_OPTIMAL
ImageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
Expand Down Expand Up @@ -581,6 +585,7 @@ Texture<Vulkan> CreateTextureObject<Vulkan>(Vulkan& vulkan, const CreateTexObjec
vulkan.SetImageLayout(vmaImage.GetVkBuffer(), SetupCmdBuffer, VK_IMAGE_ASPECT_COLOR_BIT, ImageInfo.initialLayout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, (VkPipelineStageFlags)0/*unused param*/, (VkPipelineStageFlags)0/*unused param*/, 0, ImageInfo.mipLevels, 0, ImageInfo.arrayLayers);
retImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
break;
case TT_SAMPLED_TRANSFERDST:
case TT_NORMAL:
vulkan.SetImageLayout(vmaImage.GetVkBuffer(), SetupCmdBuffer, VK_IMAGE_ASPECT_COLOR_BIT, ImageInfo.initialLayout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, (VkPipelineStageFlags)0/*unused param*/, (VkPipelineStageFlags)0/*unused param*/, 0, ImageInfo.mipLevels, 0, ImageInfo.arrayLayers);
retImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
Expand Down Expand Up @@ -667,6 +672,7 @@ Texture<Vulkan> CreateTextureObject<Vulkan>(Vulkan& vulkan, const CreateTexObjec
case TT_SHADING_RATE_IMAGE:
case TT_CPU_UPDATE:
case TT_NORMAL:
case TT_SAMPLED_TRANSFERDST:
case TT_RENDER_TARGET:
case TT_RENDER_TARGET_WITH_STORAGE:
case TT_RENDER_TARGET_TRANSFERSRC:
Expand Down
8 changes: 8 additions & 0 deletions framework/code/vulkan/extensionLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,14 @@ namespace ExtensionLib
}
#endif // VK_ARM_data_graph

#if VK_QCOM_data_graph_model
void Ext_VK_QCOM_data_graph_model::PrintFeatures() const
{
LOGI("VK_QCOM_data_graph_model (VkPhysicalDeviceDataGraphModelFeaturesQCOM):");
LOGI(" dataGraphModel: %s", this->AvailableFeatures.dataGraphModel ? "True" : "False");
}
#endif // VK_QCOM_data_graph_model

#if VK_KHR_get_physical_device_properties2

void Ext_VK_KHR_get_physical_device_properties2::LookupFunctionPointers(VkInstance vkInstance)
Expand Down
166 changes: 166 additions & 0 deletions framework/code/vulkan/extensionLib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,32 @@ namespace ExtensionLib

#endif // VK_ARM_data_graph

#if VK_QCOM_data_graph_model

struct Ext_VK_QCOM_data_graph_model : public VulkanFeaturesAndFunctionPointerExtensionHelper<
VkPhysicalDeviceDataGraphModelFeaturesQCOM, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DATA_GRAPH_MODEL_FEATURES_QCOM>
{
using tBase = VulkanFeaturesAndFunctionPointerExtensionHelper;
static constexpr auto Name = VK_QCOM_DATA_GRAPH_MODEL_EXTENSION_NAME;

explicit Ext_VK_QCOM_data_graph_model(VulkanExtensionStatus status = VulkanExtensionStatus::eRequired)
: tBase(Name, status)
{
}

void PopulateRequestedFeatures() override
{
RequestedFeatures.sType = AvailableFeatures.sType;
RequestedFeatures.dataGraphModel = AvailableFeatures.dataGraphModel;
}

void PrintFeatures() const override;
void LookupFunctionPointers(VkInstance vkInstance) override {}
void LookupFunctionPointers(VkDevice, PFN_vkGetDeviceProcAddr) override {}
};

#endif // VK_QCOM_data_graph_model

#if VK_QCOM_tile_properties

struct Ext_VK_QCOM_tile_properties : public VulkanFeaturesAndFunctionPointerExtensionHelper<
Expand Down Expand Up @@ -705,6 +731,146 @@ namespace ExtensionLib

#endif // VK_KHR_get_physical_device_properties2

#if VK_KHR_external_memory_capabilities

// Instance extension: exposes capability queries (buffer/image external memory).
struct Ext_VK_KHR_external_memory_capabilities : public VulkanFunctionPointerExtensionHelper<VulkanExtensionType::eInstance>
{
static constexpr auto Name = VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME;
explicit Ext_VK_KHR_external_memory_capabilities(VulkanExtensionStatus status = VulkanExtensionStatus::eRequired)
: VulkanFunctionPointerExtensionHelper(Name, status)
{
}

// Volk will resolve globally; we keep the overrides for consistency.
void LookupFunctionPointers(VkInstance) override {}
void LookupFunctionPointers(VkDevice, PFN_vkGetDeviceProcAddr) override {}
};

#endif // VK_KHR_external_memory_capabilities

#if VK_KHR_external_memory

// Device extension: enables external memory types/flags. No commands to load.
struct Ext_VK_KHR_external_memory : public VulkanFunctionPointerExtensionHelper<VulkanExtensionType::eDevice>
{
static constexpr auto Name = VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME;
explicit Ext_VK_KHR_external_memory(VulkanExtensionStatus status = VulkanExtensionStatus::eRequired)
: VulkanFunctionPointerExtensionHelper(Name, status)
{
}

void LookupFunctionPointers(VkInstance) override {}
void LookupFunctionPointers(VkDevice, PFN_vkGetDeviceProcAddr) override {}
};

#endif // VK_KHR_external_memory

#if VK_KHR_external_memory_fd

// Device extension: POSIX file descriptor handles for external memory.
struct Ext_VK_KHR_external_memory_fd : public VulkanFunctionPointerExtensionHelper<VulkanExtensionType::eDevice>
{
static constexpr auto Name = VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME;
explicit Ext_VK_KHR_external_memory_fd(VulkanExtensionStatus status = VulkanExtensionStatus::eRequired)
: VulkanFunctionPointerExtensionHelper(Name, status)
{
}

void LookupFunctionPointers(VkInstance) override {}
void LookupFunctionPointers(VkDevice, PFN_vkGetDeviceProcAddr) override {}
};

#endif // VK_KHR_external_memory_fd

#if defined(VK_USE_PLATFORM_WIN32_KHR) && VK_KHR_external_memory_win32

// Device extension: Win32 HANDLEs for external memory.
struct Ext_VK_KHR_external_memory_win32 : public VulkanFunctionPointerExtensionHelper<VulkanExtensionType::eDevice>
{
static constexpr auto Name = VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME;
explicit Ext_VK_KHR_external_memory_win32(VulkanExtensionStatus status = VulkanExtensionStatus::eRequired)
: VulkanFunctionPointerExtensionHelper(Name, status)
{
}

void LookupFunctionPointers(VkInstance) override {}
void LookupFunctionPointers(VkDevice, PFN_vkGetDeviceProcAddr) override {}
};

#endif // VK_USE_PLATFORM_WIN32_KHR && VK_KHR_external_memory_win32


#if VK_KHR_external_semaphore_capabilities

// Instance extension: exposes semaphore external capability queries.
struct Ext_VK_KHR_external_semaphore_capabilities : public VulkanFunctionPointerExtensionHelper<VulkanExtensionType::eInstance>
{
static constexpr auto Name = VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME;
explicit Ext_VK_KHR_external_semaphore_capabilities(VulkanExtensionStatus status = VulkanExtensionStatus::eRequired)
: VulkanFunctionPointerExtensionHelper(Name, status)
{
}

void LookupFunctionPointers(VkInstance) override {}
void LookupFunctionPointers(VkDevice, PFN_vkGetDeviceProcAddr) override {}
};

#endif // VK_KHR_external_semaphore_capabilities

#if VK_KHR_external_semaphore

// Device extension: enables external semaphore types/flags. No commands to load.
struct Ext_VK_KHR_external_semaphore : public VulkanFunctionPointerExtensionHelper<VulkanExtensionType::eDevice>
{
static constexpr auto Name = VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME;
explicit Ext_VK_KHR_external_semaphore(VulkanExtensionStatus status = VulkanExtensionStatus::eRequired)
: VulkanFunctionPointerExtensionHelper(Name, status)
{
}

void LookupFunctionPointers(VkInstance) override {}
void LookupFunctionPointers(VkDevice, PFN_vkGetDeviceProcAddr) override {}
};

#endif // VK_KHR_external_semaphore


#if VK_KHR_external_semaphore_fd

// Device extension: POSIX file descriptor handles for external semaphores.
struct Ext_VK_KHR_external_semaphore_fd : public VulkanFunctionPointerExtensionHelper<VulkanExtensionType::eDevice>
{
static constexpr auto Name = VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME;
explicit Ext_VK_KHR_external_semaphore_fd(VulkanExtensionStatus status = VulkanExtensionStatus::eRequired)
: VulkanFunctionPointerExtensionHelper(Name, status)
{
}

void LookupFunctionPointers(VkInstance) override {}
void LookupFunctionPointers(VkDevice, PFN_vkGetDeviceProcAddr) override {}
};

#endif // VK_KHR_external_semaphore_fd


#if defined(VK_USE_PLATFORM_WIN32_KHR) && VK_KHR_external_semaphore_win32

// Device extension: Win32 HANDLEs for external semaphores.
struct Ext_VK_KHR_external_semaphore_win32 : public VulkanFunctionPointerExtensionHelper<VulkanExtensionType::eDevice>
{
static constexpr auto Name = VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME;
explicit Ext_VK_KHR_external_semaphore_win32(VulkanExtensionStatus status = VulkanExtensionStatus::eRequired)
: VulkanFunctionPointerExtensionHelper(Name, status)
{
}

void LookupFunctionPointers(VkInstance) override {}
void LookupFunctionPointers(VkDevice, PFN_vkGetDeviceProcAddr) override {}
};

#endif // VK_USE_PLATFORM_WIN32_KHR && VK_KHR_external_semaphore_win32

#if VK_KHR_surface

// Instance extension
Expand Down
2 changes: 1 addition & 1 deletion framework/code/vulkan/renderContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ RenderContext<Vulkan>::RenderPassContextData& RenderContext<Vulkan>::RenderPassC
RenderContext<Vulkan>::RenderContext( RenderPass<Vulkan> _renderPass, Pipeline<Vulkan> _pipeline, Framebuffer<Vulkan> _framebuffer, std::string _name ) noexcept
//-----------------------------------------------------------------------------
: v{std::move( RenderPassContextData {
std::move( _renderPass ), std::move( _pipeline ), std::move( _framebuffer ), _framebuffer.GetRenderPassClearData().Copy()
std::move( _renderPass ), std::move( _pipeline ), _framebuffer, _framebuffer.GetRenderPassClearData().Copy()
} )}
, name{std::move( _name )}
{
Expand Down
Loading
Loading