vulkan: code styling

This commit is contained in:
niki
2022-12-21 17:20:13 +01:00
parent 92b5278b31
commit 30bdb03f3b
5 changed files with 20 additions and 19 deletions
+1 -1
View File
@@ -42,7 +42,7 @@ class Buffer final
, public Volatile , public Volatile
{ {
public: public:
Buffer(love::graphics::Graphics *gfx, const Settings& settings, const std::vector<DataDeclaration> &format, const void *data, size_t size, size_t arraylength); Buffer(love::graphics::Graphics *gfx, const Settings &settings, const std::vector<DataDeclaration> &format, const void *data, size_t size, size_t arraylength);
virtual ~Buffer(); virtual ~Buffer();
virtual bool loadVolatile() override; virtual bool loadVolatile() override;
+4 -4
View File
@@ -1316,7 +1316,7 @@ bool Graphics::checkValidationSupport()
{ {
bool layerFound = false; bool layerFound = false;
for (const auto& layerProperties : availableLayers) for (const auto &layerProperties : availableLayers)
{ {
if (strcmp(layerName, layerProperties.layerName) == 0) if (strcmp(layerName, layerProperties.layerName) == 0)
{ {
@@ -1754,7 +1754,7 @@ VkSurfaceFormatKHR Graphics::chooseSwapSurfaceFormat(const std::vector<VkSurface
// TODO: turn off GammaCorrect if a sRGB format can't be found? // TODO: turn off GammaCorrect if a sRGB format can't be found?
if (isGammaCorrect()) if (isGammaCorrect())
{ {
for (const auto& availableFormat : availableFormats) for (const auto &availableFormat : availableFormats)
// fixme: what if this format and colorspace is not available? // fixme: what if this format and colorspace is not available?
if (availableFormat.format == VK_FORMAT_B8G8R8A8_SRGB && availableFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR) if (availableFormat.format == VK_FORMAT_B8G8R8A8_SRGB && availableFormat.colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
return availableFormat; return availableFormat;
@@ -1969,7 +1969,7 @@ VkFramebuffer Graphics::createFramebuffer(FramebufferConfiguration &configuratio
{ {
std::vector<VkImageView> attachments; std::vector<VkImageView> attachments;
for (const auto& colorView : configuration.colorViews) for (const auto &colorView : configuration.colorViews)
attachments.push_back(colorView); attachments.push_back(colorView);
if (configuration.staticData.depthView) if (configuration.staticData.depthView)
@@ -2323,7 +2323,7 @@ void Graphics::setRenderPass(const RenderTargets &rts, int pixelw, int pixelh, b
// fixme: hasSRGBtexture // fixme: hasSRGBtexture
RenderPassConfiguration renderPassConfiguration{}; RenderPassConfiguration renderPassConfiguration{};
for (const auto& color : rts.colors) for (const auto &color : rts.colors)
renderPassConfiguration.colorAttachments.push_back({ renderPassConfiguration.colorAttachments.push_back({
Vulkan::getTextureFormat(color.texture->getPixelFormat(), isPixelFormatSRGB(color.texture->getPixelFormat())).internalFormat, Vulkan::getTextureFormat(color.texture->getPixelFormat(), isPixelFormatSRGB(color.texture->getPixelFormat())).internalFormat,
false, false,
+13 -12
View File
@@ -70,23 +70,23 @@ struct RenderPassConfiguration
bool resolve = false; bool resolve = false;
} staticData; } staticData;
bool operator==(const RenderPassConfiguration &conf) const bool operator==(const RenderPassConfiguration &conf) const
{ {
return colorAttachments == conf.colorAttachments && return colorAttachments == conf.colorAttachments &&
(memcmp(&staticData, &conf.staticData, sizeof(StaticRenderPassConfiguration)) == 0); (memcmp(&staticData, &conf.staticData, sizeof(StaticRenderPassConfiguration)) == 0);
} }
}; };
struct RenderPassConfigurationHasher struct RenderPassConfigurationHasher
{ {
size_t operator()(const RenderPassConfiguration &configuration) const size_t operator()(const RenderPassConfiguration &configuration) const
{ {
size_t hashes[] = { size_t hashes[] = {
XXH32(configuration.colorAttachments.data(), configuration.colorAttachments.size() * sizeof(VkFormat), 0), XXH32(configuration.colorAttachments.data(), configuration.colorAttachments.size() * sizeof(VkFormat), 0),
XXH32(&configuration.staticData, sizeof(configuration.staticData), 0), XXH32(&configuration.staticData, sizeof(configuration.staticData), 0),
}; };
return XXH32(hashes, sizeof(hashes), 0); return XXH32(hashes, sizeof(hashes), 0);
} }
}; };
struct FramebufferConfiguration struct FramebufferConfiguration
@@ -126,7 +126,8 @@ struct FramebufferConfigurationHasher
struct OptionalInstanceExtensions struct OptionalInstanceExtensions
{ {
bool physicalDeviceProperties2 = false; // VK_KHR_get_physical_device_properties2
bool physicalDeviceProperties2 = false;
}; };
struct OptionalDeviceFeatures struct OptionalDeviceFeatures
@@ -155,7 +156,7 @@ struct OptionalDeviceFeatures
struct GraphicsPipelineConfiguration struct GraphicsPipelineConfiguration
{ {
VkRenderPass renderPass; VkRenderPass renderPass;
VertexAttributes vertexAttributes; VertexAttributes vertexAttributes;
Shader *shader = nullptr; Shader *shader = nullptr;
bool wireFrame; bool wireFrame;
@@ -328,10 +329,10 @@ private:
void createScreenshotCallbackBuffers(); void createScreenshotCallbackBuffers();
void createDefaultRenderPass(); void createDefaultRenderPass();
void createDefaultFramebuffers(); void createDefaultFramebuffers();
VkFramebuffer createFramebuffer(FramebufferConfiguration &configuration); VkFramebuffer createFramebuffer(FramebufferConfiguration &configuration);
VkFramebuffer getFramebuffer(FramebufferConfiguration &configuration); VkFramebuffer getFramebuffer(FramebufferConfiguration &configuration);
void createDefaultShaders(); void createDefaultShaders();
VkRenderPass createRenderPass(RenderPassConfiguration &configuration); VkRenderPass createRenderPass(RenderPassConfiguration &configuration);
VkPipeline createGraphicsPipeline(GraphicsPipelineConfiguration &configuration); VkPipeline createGraphicsPipeline(GraphicsPipelineConfiguration &configuration);
void createColorResources(); void createColorResources();
VkFormat findSupportedFormat(const std::vector<VkFormat> &candidates, VkImageTiling tiling, VkFormatFeatureFlags features); VkFormat findSupportedFormat(const std::vector<VkFormat> &candidates, VkImageTiling tiling, VkFormatFeatureFlags features);
@@ -376,7 +377,7 @@ private:
VkQueue graphicsQueue = VK_NULL_HANDLE; VkQueue graphicsQueue = VK_NULL_HANDLE;
VkQueue presentQueue = VK_NULL_HANDLE; VkQueue presentQueue = VK_NULL_HANDLE;
VkSurfaceKHR surface = VK_NULL_HANDLE; VkSurfaceKHR surface = VK_NULL_HANDLE;
VkSwapchainKHR swapChain = VK_NULL_HANDLE; VkSwapchainKHR swapChain = VK_NULL_HANDLE;
VkSurfaceTransformFlagBitsKHR preTransform = {}; VkSurfaceTransformFlagBitsKHR preTransform = {};
Matrix4 displayRotation; Matrix4 displayRotation;
std::vector<VkImage> swapChainImages; std::vector<VkImage> swapChainImages;
@@ -392,7 +393,7 @@ private:
VmaAllocation depthImageAllocation = VK_NULL_HANDLE; VmaAllocation depthImageAllocation = VK_NULL_HANDLE;
VkRenderPass defaultRenderPass = VK_NULL_HANDLE; VkRenderPass defaultRenderPass = VK_NULL_HANDLE;
std::vector<VkFramebuffer> defaultFramebuffers; std::vector<VkFramebuffer> defaultFramebuffers;
std::unordered_map<RenderPassConfiguration, VkRenderPass, RenderPassConfigurationHasher> renderPasses; std::unordered_map<RenderPassConfiguration, VkRenderPass, RenderPassConfigurationHasher> renderPasses;
std::unordered_map<FramebufferConfiguration, VkFramebuffer, FramebufferConfigurationHasher> framebuffers; std::unordered_map<FramebufferConfiguration, VkFramebuffer, FramebufferConfigurationHasher> framebuffers;
std::unordered_map<GraphicsPipelineConfiguration, VkPipeline, GraphicsPipelineConfigurationHasher> graphicsPipelines; std::unordered_map<GraphicsPipelineConfiguration, VkPipeline, GraphicsPipelineConfigurationHasher> graphicsPipelines;
std::unordered_map<VkRenderPass, bool> renderPassUsages; std::unordered_map<VkRenderPass, bool> renderPassUsages;
@@ -401,7 +402,7 @@ private:
std::unordered_map<uint64, VkSampler> samplers; std::unordered_map<uint64, VkSampler> samplers;
VkCommandPool commandPool = VK_NULL_HANDLE; VkCommandPool commandPool = VK_NULL_HANDLE;
std::vector<VkCommandBuffer> commandBuffers; std::vector<VkCommandBuffer> commandBuffers;
Shader* computeShader = nullptr; Shader *computeShader = nullptr;
std::vector<VkSemaphore> imageAvailableSemaphores; std::vector<VkSemaphore> imageAvailableSemaphores;
std::vector<VkSemaphore> renderFinishedSemaphores; std::vector<VkSemaphore> renderFinishedSemaphores;
std::vector<VkFence> inFlightFences; std::vector<VkFence> inFlightFences;
+1 -1
View File
@@ -340,7 +340,7 @@ void Shader::cmdPushDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBind
uniformWrite.dstArrayElement = 0; uniformWrite.dstArrayElement = 0;
uniformWrite.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; uniformWrite.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
uniformWrite.descriptorCount = 1; uniformWrite.descriptorCount = 1;
uniformWrite.pBufferInfo = &bufferInfo; uniformWrite.pBufferInfo = &bufferInfo;
vkUpdateDescriptorSets(device, 1, &uniformWrite, 0, nullptr); vkUpdateDescriptorSets(device, 1, &uniformWrite, 0, nullptr);
+1 -1
View File
@@ -102,7 +102,7 @@ private:
size_t baseoff, size_t baseoff,
const std::string &basename); const std::string &basename);
void initDescriptorSet(); void initDescriptorSet();
void updateUniform(const UniformInfo* info, int count, bool internal); void updateUniform(const UniformInfo *info, int count, bool internal);
VkDescriptorSet allocateDescriptorSet(); VkDescriptorSet allocateDescriptorSet();