Browse Source

vulkan: code styling

niki 2 years ago
parent
commit
30bdb03f3b

+ 1 - 1
src/modules/graphics/vulkan/Buffer.h

@@ -42,7 +42,7 @@ class Buffer final
 	, public Volatile
 {
 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 bool loadVolatile() override;

+ 4 - 4
src/modules/graphics/vulkan/Graphics.cpp

@@ -1316,7 +1316,7 @@ bool Graphics::checkValidationSupport()
 	{
 		bool layerFound = false;
 
-		for (const auto& layerProperties : availableLayers)
+		for (const auto &layerProperties : availableLayers)
 		{
 			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?
 	if (isGammaCorrect())
 	{
-		for (const auto& availableFormat : availableFormats)
+		for (const auto &availableFormat : availableFormats)
 			// 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)
 				return availableFormat;
@@ -1969,7 +1969,7 @@ VkFramebuffer Graphics::createFramebuffer(FramebufferConfiguration &configuratio
 {
 	std::vector<VkImageView> attachments;
 
-	for (const auto& colorView : configuration.colorViews)
+	for (const auto &colorView : configuration.colorViews)
 		attachments.push_back(colorView);
 
 	if (configuration.staticData.depthView)
@@ -2323,7 +2323,7 @@ void Graphics::setRenderPass(const RenderTargets &rts, int pixelw, int pixelh, b
 
 	// fixme: hasSRGBtexture
 	RenderPassConfiguration renderPassConfiguration{};
-	for (const auto& color : rts.colors)
+	for (const auto &color : rts.colors)
 		renderPassConfiguration.colorAttachments.push_back({ 
 			Vulkan::getTextureFormat(color.texture->getPixelFormat(), isPixelFormatSRGB(color.texture->getPixelFormat())).internalFormat,
 			false, 

+ 13 - 12
src/modules/graphics/vulkan/Graphics.h

@@ -70,23 +70,23 @@ struct RenderPassConfiguration
 		bool resolve = false;
 	} staticData;
 
-    bool operator==(const RenderPassConfiguration &conf) const
+	bool operator==(const RenderPassConfiguration &conf) const
 	{
 		return colorAttachments == conf.colorAttachments && 
 			(memcmp(&staticData, &conf.staticData, sizeof(StaticRenderPassConfiguration)) == 0);
-    }
+	}
 };
 
 struct RenderPassConfigurationHasher
 {
-    size_t operator()(const RenderPassConfiguration &configuration) const
+	size_t operator()(const RenderPassConfiguration &configuration) const
 	{
 		size_t hashes[] = { 
 			XXH32(configuration.colorAttachments.data(), configuration.colorAttachments.size() * sizeof(VkFormat), 0),
 			XXH32(&configuration.staticData, sizeof(configuration.staticData), 0),
 		};
 		return XXH32(hashes, sizeof(hashes), 0);
-    }
+	}
 };
 
 struct FramebufferConfiguration
@@ -126,7 +126,8 @@ struct FramebufferConfigurationHasher
 
 struct OptionalInstanceExtensions
 {
-    bool physicalDeviceProperties2 = false;
+	// VK_KHR_get_physical_device_properties2
+	bool physicalDeviceProperties2 = false;
 };
 
 struct OptionalDeviceFeatures
@@ -155,7 +156,7 @@ struct OptionalDeviceFeatures
 
 struct GraphicsPipelineConfiguration
 {
-    VkRenderPass renderPass;
+	VkRenderPass renderPass;
 	VertexAttributes vertexAttributes;
 	Shader *shader = nullptr;
 	bool wireFrame;
@@ -328,10 +329,10 @@ private:
 	void createScreenshotCallbackBuffers();
 	void createDefaultRenderPass();
 	void createDefaultFramebuffers();
-    VkFramebuffer createFramebuffer(FramebufferConfiguration &configuration);
-    VkFramebuffer getFramebuffer(FramebufferConfiguration &configuration);
+	VkFramebuffer createFramebuffer(FramebufferConfiguration &configuration);
+	VkFramebuffer getFramebuffer(FramebufferConfiguration &configuration);
 	void createDefaultShaders();
-    VkRenderPass createRenderPass(RenderPassConfiguration &configuration);
+	VkRenderPass createRenderPass(RenderPassConfiguration &configuration);
 	VkPipeline createGraphicsPipeline(GraphicsPipelineConfiguration &configuration);
 	void createColorResources();
 	VkFormat findSupportedFormat(const std::vector<VkFormat> &candidates, VkImageTiling tiling, VkFormatFeatureFlags features);
@@ -376,7 +377,7 @@ private:
 	VkQueue graphicsQueue = VK_NULL_HANDLE;
 	VkQueue presentQueue = VK_NULL_HANDLE;
 	VkSurfaceKHR surface = VK_NULL_HANDLE;
-    VkSwapchainKHR swapChain = VK_NULL_HANDLE;
+	VkSwapchainKHR swapChain = VK_NULL_HANDLE;
 	VkSurfaceTransformFlagBitsKHR preTransform = {};
 	Matrix4 displayRotation;
 	std::vector<VkImage> swapChainImages;
@@ -392,7 +393,7 @@ private:
 	VmaAllocation depthImageAllocation = VK_NULL_HANDLE;
 	VkRenderPass defaultRenderPass = VK_NULL_HANDLE;
 	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<GraphicsPipelineConfiguration, VkPipeline, GraphicsPipelineConfigurationHasher> graphicsPipelines;
 	std::unordered_map<VkRenderPass, bool> renderPassUsages;
@@ -401,7 +402,7 @@ private:
 	std::unordered_map<uint64, VkSampler> samplers;
 	VkCommandPool commandPool = VK_NULL_HANDLE;
 	std::vector<VkCommandBuffer> commandBuffers;
-	Shader* computeShader = nullptr;
+	Shader *computeShader = nullptr;
 	std::vector<VkSemaphore> imageAvailableSemaphores;
 	std::vector<VkSemaphore> renderFinishedSemaphores;
 	std::vector<VkFence> inFlightFences;

+ 1 - 1
src/modules/graphics/vulkan/Shader.cpp

@@ -340,7 +340,7 @@ void Shader::cmdPushDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBind
 		uniformWrite.dstArrayElement = 0;
 		uniformWrite.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
 		uniformWrite.descriptorCount = 1;
-		uniformWrite.pBufferInfo = &bufferInfo;			
+		uniformWrite.pBufferInfo = &bufferInfo;
 
 		vkUpdateDescriptorSets(device, 1, &uniformWrite, 0, nullptr);
 

+ 1 - 1
src/modules/graphics/vulkan/Shader.h

@@ -102,7 +102,7 @@ private:
 		size_t baseoff, 
 		const std::string &basename);
 	void initDescriptorSet();
-	void updateUniform(const UniformInfo* info, int count, bool internal);
+	void updateUniform(const UniformInfo *info, int count, bool internal);
 
 	VkDescriptorSet allocateDescriptorSet();