Skip to content

Commit

Permalink
Enable AlignAfterOpenBracket: BlockIndent formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wunkolo committed Feb 26, 2023
1 parent 350ad67 commit 543d880
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignAfterOpenBracket: BlockIndent
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignConsecutiveBitFields: true
Expand Down
18 changes: 12 additions & 6 deletions include/VulkanUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,45 @@ std::int32_t FindMemoryTypeIndex(
const vk::PhysicalDevice& PhysicalDevice, std::uint32_t MemoryTypeMask,
vk::MemoryPropertyFlags Properties,
vk::MemoryPropertyFlags ExcludeProperties
= vk::MemoryPropertyFlagBits::eProtected);
= vk::MemoryPropertyFlagBits::eProtected
);

// Allocations
std::optional<vk::UniqueDeviceMemory> AllocateDeviceMemory(
vk::Device Device, std::size_t Size, std::uint32_t MemoryTypeIndex,
vk::Buffer DedicatedBuffer = vk::Buffer(),
vk::Image DedicatedImage = vk::Image());
vk::Image DedicatedImage = vk::Image()
);

std::optional<std::tuple<vk::UniqueBuffer, vk::UniqueDeviceMemory>>
AllocateBuffer(
vk::Device Device, vk::PhysicalDevice PhysicalDevice, std::size_t Size,
vk::BufferUsageFlags Usage, vk::MemoryPropertyFlags Properties,
vk::MemoryPropertyFlags ExcludeProperties
= vk::MemoryPropertyFlagBits::eProtected,
vk::SharingMode Sharing = vk::SharingMode::eExclusive);
vk::SharingMode Sharing = vk::SharingMode::eExclusive
);

std::optional<std::tuple<vk::UniqueImage, vk::UniqueDeviceMemory>>
AllocateImage(
vk::Device Device, vk::PhysicalDevice PhysicalDevice,
vk::ImageCreateInfo NewImageInfo, vk::MemoryPropertyFlags Properties,
vk::MemoryPropertyFlags ExcludeProperties
= vk::MemoryPropertyFlagBits::eProtected);
= vk::MemoryPropertyFlagBits::eProtected
);

std::optional<vk::UniqueShaderModule>
LoadShaderModule(const vk::Device& Device, std::span<const std::byte> Code);

vk::MemoryHeap GetLargestPhysicalDeviceHeap(
const vk::PhysicalDevice& PhysicalDevice,
vk::MemoryHeapFlags Flags = vk::MemoryHeapFlagBits::eDeviceLocal);
vk::MemoryHeapFlags Flags = vk::MemoryHeapFlagBits::eDeviceLocal
);

// Debug callback
VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessageCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT MessageSeverity,
VkDebugUtilsMessageTypeFlagsEXT MessageType,
const VkDebugUtilsMessengerCallbackDataEXT* CallbackData, void* UserData);
const VkDebugUtilsMessengerCallbackDataEXT* CallbackData, void* UserData
);
} // namespace VulkanUtils
3 changes: 2 additions & 1 deletion include/Vulkanator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,6 @@ enum
extern "C" {
DllExport PF_Err EntryPoint(
PF_Cmd cmd, PF_InData* in_data, PF_OutData* out_data, PF_ParamDef* params[],
PF_LayerDef* output, void* extra);
PF_LayerDef* output, void* extra
);
}
8 changes: 4 additions & 4 deletions shaders/Vulkanator.frag
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ void main()
FragColor = texture(InputTexture, InCoord).gbar;

// 16 bit colors have to be specially handled
if(RenderParams.Depth == DEPTH16) FragColor *= DEPTH16_LOAD_SCALE;

if( RenderParams.Depth == DEPTH16 )
FragColor *= DEPTH16_LOAD_SCALE;

FragColor *= RenderParams.ColorFactor;


// 16 bit colors have to be specially handled
if(RenderParams.Depth == DEPTH16) FragColor = mix((0.0).xxxx, DEPTH16_STORE_SCALE.xxxx, FragColor);
if( RenderParams.Depth == DEPTH16 )
FragColor = mix((0.0).xxxx, DEPTH16_STORE_SCALE.xxxx, FragColor);

// After effects stores things in ARGB order (/_\)
FragColor = FragColor.argb;
Expand Down
6 changes: 3 additions & 3 deletions shaders/Vulkanator.glsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#extension GL_EXT_shader_explicit_arithmetic_types : require

const uint32_t DEPTH08 = 8u / 16u;
const uint32_t DEPTH08 = 8u / 16u;
const uint32_t DEPTH16 = 16u / 16u;
const uint32_t DEPTH32 = 32u / 16u;

Expand All @@ -13,6 +13,6 @@ const float32_t DEPTH16_STORE_SCALE = DEPTH16MAX / float(0x10000);
struct VulkanatorRenderParams
{
uint32_t Depth;
f32mat4 Transform;
f32vec4 ColorFactor;
f32mat4 Transform;
f32vec4 ColorFactor;
};
4 changes: 1 addition & 3 deletions shaders/Vulkanator.vert
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ layout(binding = 0) uniform Uniforms
void main()
{
gl_Position = f32vec4(
(RenderParams.Transform * f32vec4(InPosition, 0.0, 1.0)).xy,
0.0,
1.0
(RenderParams.Transform * f32vec4(InPosition, 0.0, 1.0)).xy, 0.0, 1.0
);
OutCoord = InCoord;
}
38 changes: 25 additions & 13 deletions source/VulkanUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace VulkanUtils
std::int32_t FindMemoryTypeIndex(
const vk::PhysicalDevice& PhysicalDevice, std::uint32_t MemoryTypeMask,
vk::MemoryPropertyFlags Properties,
vk::MemoryPropertyFlags ExcludeProperties)
vk::MemoryPropertyFlags ExcludeProperties
)
{
const vk::PhysicalDeviceMemoryProperties DeviceMemoryProperties
= PhysicalDevice.getMemoryProperties();
Expand All @@ -38,7 +39,8 @@ std::int32_t FindMemoryTypeIndex(

std::optional<vk::UniqueDeviceMemory> AllocateDeviceMemory(
vk::Device Device, std::size_t Size, std::uint32_t MemoryTypeIndex,
vk::Buffer DedicatedBuffer, vk::Image DedicatedImage)
vk::Buffer DedicatedBuffer, vk::Image DedicatedImage
)
{
vk::StructureChain<vk::MemoryAllocateInfo, vk::MemoryDedicatedAllocateInfo>
AllocSettings;
Expand Down Expand Up @@ -72,7 +74,8 @@ std::optional<std::tuple<vk::UniqueBuffer, vk::UniqueDeviceMemory>>
AllocateBuffer(
vk::Device Device, vk::PhysicalDevice PhysicalDevice, std::size_t Size,
vk::BufferUsageFlags Usage, vk::MemoryPropertyFlags Properties,
vk::MemoryPropertyFlags ExcludeProperties, vk::SharingMode Sharing)
vk::MemoryPropertyFlags ExcludeProperties, vk::SharingMode Sharing
)
{
// Create the buffer object
vk::BufferCreateInfo NewBufferInfo = {};
Expand All @@ -99,15 +102,17 @@ std::optional<std::tuple<vk::UniqueBuffer, vk::UniqueDeviceMemory>>

const auto BufferMemoryIndex = FindMemoryTypeIndex(
PhysicalDevice, NewBufferRequirements.memoryTypeBits, Properties,
ExcludeProperties);
ExcludeProperties
);

if( BufferMemoryIndex < 0 )
return std::nullopt;

vk::UniqueDeviceMemory NewBufferDeviceMemory{};
if( auto NewDeviceMemory = AllocateDeviceMemory(
Device, NewBufferRequirements.size, BufferMemoryIndex,
NewBuffer.get(), vk::Image());
NewBuffer.get(), vk::Image()
);
NewDeviceMemory.has_value() )
{
NewBufferDeviceMemory = std::move(NewDeviceMemory.value());
Expand All @@ -118,22 +123,25 @@ std::optional<std::tuple<vk::UniqueBuffer, vk::UniqueDeviceMemory>>
}

if( auto BindResult = Device.bindBufferMemory(
NewBuffer.get(), NewBufferDeviceMemory.get(), 0);
NewBuffer.get(), NewBufferDeviceMemory.get(), 0
);
BindResult != vk::Result::eSuccess )
{
// Error binding buffer object to device memory
return std::nullopt;
}

return std::make_tuple(
std::move(NewBuffer), std::move(NewBufferDeviceMemory));
std::move(NewBuffer), std::move(NewBufferDeviceMemory)
);
}

std::optional<std::tuple<vk::UniqueImage, vk::UniqueDeviceMemory>>
AllocateImage(
vk::Device Device, vk::PhysicalDevice PhysicalDevice,
vk::ImageCreateInfo NewImageInfo, vk::MemoryPropertyFlags Properties,
vk::MemoryPropertyFlags ExcludeProperties)
vk::MemoryPropertyFlags ExcludeProperties
)
{
vk::UniqueImage NewImage = {};

Expand All @@ -155,7 +163,8 @@ std::optional<std::tuple<vk::UniqueImage, vk::UniqueDeviceMemory>>

const auto ImageMemoryIndex = FindMemoryTypeIndex(
PhysicalDevice, NewImageRequirements.memoryTypeBits, Properties,
ExcludeProperties);
ExcludeProperties
);

if( ImageMemoryIndex < 0 )
{
Expand All @@ -166,7 +175,7 @@ std::optional<std::tuple<vk::UniqueImage, vk::UniqueDeviceMemory>>
if( auto NewDeviceMemory = AllocateDeviceMemory(
Device, NewImageRequirements.size, ImageMemoryIndex, vk::Buffer(),
NewImage.get() // ShouldDedicate ? NewImage.get() : vk::Image()
) )
) )
{
NewImageDeviceMemory = std::move(NewDeviceMemory.value());
}
Expand All @@ -183,7 +192,8 @@ std::optional<std::tuple<vk::UniqueImage, vk::UniqueDeviceMemory>>
return std::nullopt;
}
return std::make_tuple(
std::move(NewImage), std::move(NewImageDeviceMemory));
std::move(NewImage), std::move(NewImageDeviceMemory)
);
}

std::optional<vk::UniqueShaderModule>
Expand Down Expand Up @@ -216,7 +226,8 @@ std::optional<vk::UniqueShaderModule>
}

vk::MemoryHeap GetLargestPhysicalDeviceHeap(
const vk::PhysicalDevice& PhysicalDevice, vk::MemoryHeapFlags Flags)
const vk::PhysicalDevice& PhysicalDevice, vk::MemoryHeapFlags Flags
)
{
const vk::PhysicalDeviceMemoryProperties PhysicalDeviceMemoryProperties
= PhysicalDevice.getMemoryProperties();
Expand Down Expand Up @@ -244,7 +255,8 @@ vk::MemoryHeap GetLargestPhysicalDeviceHeap(
VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessageCallback(
VkDebugUtilsMessageSeverityFlagBitsEXT MessageSeverity,
VkDebugUtilsMessageTypeFlagsEXT MessageType,
const VkDebugUtilsMessengerCallbackDataEXT* CallbackData, void* UserData)
const VkDebugUtilsMessengerCallbackDataEXT* CallbackData, void* UserData
)
{
switch( vk::DebugUtilsMessageSeverityFlagBitsEXT(MessageSeverity) )
{
Expand Down
Loading

0 comments on commit 543d880

Please sign in to comment.