Browse Source

vulkan: document change in changes.txt

niki 2 years ago
parent
commit
fb44ddb546

+ 1 - 0
changes.txt

@@ -15,6 +15,7 @@ Released: N/A
 * Added Joystick:getGamepadType.
 * Added new Gamepad API buttons: "misc1", "paddle1", "paddle2", "paddle3", "paddle4". and "touchpad".
 * Added a Metal backend to love.graphics, available on macOS 10.15+ and iOS 13+.
+* Added a Vulkan backend to love.graphics, available on Windows, Linux, and Android 7+.
 * Added '--renderers a,b,c' and '--excluderenderers a,b,c' command line arguments.
 * Added t.renderers and t.excluderenderers love.conf options.
 * Added t.highdpi startup flag in love.conf, replacing t.window.highdpi and the highdpi flag of love.window.setMode.

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

@@ -15,7 +15,7 @@ namespace vulkan
 
 class Graphics;
 
-class Buffer
+class Buffer final
 	: public love::graphics::Buffer
 	, public Volatile
 {

+ 39 - 10
src/modules/graphics/vulkan/Graphics.cpp

@@ -42,7 +42,11 @@ constexpr bool enableValidationLayers = true;
 
 constexpr int MAX_FRAMES_IN_FLIGHT = 2;
 
+#if defined(VK_VERSION_1_1)
+constexpr uint32_t vulkanApiVersion = VK_API_VERSION_1_1;
+#else
 constexpr uint32_t vulkanApiVersion = VK_API_VERSION_1_0;
+#endif
 
 const char *Graphics::getName() const
 {
@@ -166,7 +170,10 @@ void Graphics::clear(const std::vector<OptionalColorD> &colors, OptionalInt sten
 	rect.rect.extent.width = static_cast<uint32_t>(renderPassState.width);
 	rect.rect.extent.height = static_cast<uint32_t>(renderPassState.height);
 
-	vkCmdClearAttachments(commandBuffers[currentFrame], static_cast<uint32_t>(attachments.size()), attachments.data(), 1, &rect);
+	vkCmdClearAttachments(
+		commandBuffers[currentFrame],
+		static_cast<uint32_t>(attachments.size()), attachments.data(),
+		1, &rect);
 }
 
 void Graphics::discard(const std::vector<bool>& colorbuffers, bool depthstencil)
@@ -387,7 +394,7 @@ bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int
 
 	createDefaultTexture();
 	createDefaultShaders();
-	Shader::current = Shader::standardShaders[graphics::Shader::StandardShader::STANDARD_DEFAULT];
+	Shader::current = Shader::standardShaders[Shader::StandardShader::STANDARD_DEFAULT];
 	createQuadIndexBuffer();
 
 	restoreState(states.back());
@@ -397,7 +404,6 @@ bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int
 	Vulkan::resetShaderSwitches();
 
 	currentFrame = 0;
-
 	created = true;
 	drawCalls = 0;
 	drawCallsBatched = 0;
@@ -561,7 +567,12 @@ void Graphics::draw(const DrawCommand &cmd)
 {
 	prepareDraw(*cmd.attributes, *cmd.buffers, cmd.texture, cmd.primitiveType, cmd.cullMode);
 
-	vkCmdDraw(commandBuffers.at(currentFrame), static_cast<uint32_t>(cmd.vertexCount), static_cast<uint32_t>(cmd.instanceCount), static_cast<uint32_t>(cmd.vertexStart), 0);
+	vkCmdDraw(
+		commandBuffers.at(currentFrame),
+		static_cast<uint32_t>(cmd.vertexCount),
+		static_cast<uint32_t>(cmd.instanceCount),
+		static_cast<uint32_t>(cmd.vertexStart),
+		0);
 	drawCalls++;
 }
 
@@ -569,8 +580,18 @@ void Graphics::draw(const DrawIndexedCommand &cmd)
 {
 	prepareDraw(*cmd.attributes, *cmd.buffers, cmd.texture, cmd.primitiveType, cmd.cullMode);
 
-	vkCmdBindIndexBuffer(commandBuffers.at(currentFrame), (VkBuffer)cmd.indexBuffer->getHandle(), static_cast<VkDeviceSize>(cmd.indexBufferOffset), Vulkan::getVulkanIndexBufferType(cmd.indexType));
-	vkCmdDrawIndexed(commandBuffers.at(currentFrame), static_cast<uint32_t>(cmd.indexCount), static_cast<uint32_t>(cmd.instanceCount), 0, 0, 0);
+	vkCmdBindIndexBuffer(
+		commandBuffers.at(currentFrame),
+		(VkBuffer)cmd.indexBuffer->getHandle(),
+		static_cast<VkDeviceSize>(cmd.indexBufferOffset),
+		Vulkan::getVulkanIndexBufferType(cmd.indexType))
+	vkCmdDrawIndexed(
+		commandBuffers.at(currentFrame),
+		static_cast<uint32_t>(cmd.indexCount),
+		static_cast<uint32_t>(cmd.instanceCount),
+		0,
+		0,
+		0);
 	drawCalls++;
 }
 
@@ -581,7 +602,11 @@ void Graphics::drawQuads(int start, int count, const VertexAttributes &attribute
 
 	prepareDraw(attributes, buffers, texture, PRIMITIVE_TRIANGLES, CULL_BACK);
 
-	vkCmdBindIndexBuffer(commandBuffers.at(currentFrame), (VkBuffer)quadIndexBuffer->getHandle(), 0, Vulkan::getVulkanIndexBufferType(INDEX_UINT16));
+	vkCmdBindIndexBuffer(
+		commandBuffers.at(currentFrame),
+		(VkBuffer)quadIndexBuffer->getHandle(),
+		0,
+		Vulkan::getVulkanIndexBufferType(INDEX_UINT16));
 
 	int baseVertex = start * 4;
 
@@ -589,7 +614,13 @@ void Graphics::drawQuads(int start, int count, const VertexAttributes &attribute
 	{
 		int quadcount = std::min(MAX_QUADS_PER_DRAW, count - quadindex);
 
-		vkCmdDrawIndexed(commandBuffers.at(currentFrame), static_cast<uint32_t>(quadcount * 6), 1, 0, baseVertex, 0);
+		vkCmdDrawIndexed(
+			commandBuffers.at(currentFrame),
+			static_cast<uint32_t>(quadcount * 6),
+			1,
+			0,
+			baseVertex,
+			0);
 		baseVertex += quadcount * 4;
 
 		drawCalls++;
@@ -1958,7 +1989,6 @@ void Graphics::createVulkanVertexFormat(
 		}
 	}
 
-	// do we need to use a constant VertexColor?
 	if (!usesColor)
 	{
 		// FIXME: is there a case where gaps happen between buffer bindings?
@@ -2109,7 +2139,6 @@ void Graphics::setRenderPass(const RenderTargets &rts, int pixelw, int pixelh, b
 		transitionImages.push_back((VkImage) color.texture->getHandle());
 	}
 	if (rts.depthStencil.texture != nullptr)
-		// fixme: layout transition of depth stencil image?
 		configuration.staticData.depthView = (VkImageView)rts.depthStencil.texture->getRenderTargetHandle();
 
 	configuration.staticData.width = static_cast<uint32_t>(pixelw);

+ 9 - 9
src/modules/graphics/vulkan/Graphics.h

@@ -323,9 +323,9 @@ public:
 
 	const VkDeviceSize getMinUniformBufferOffsetAlignment() const;
 	graphics::Texture *getDefaultTexture() const;
-	VkSampler getCachedSampler(const SamplerState &);
+	VkSampler getCachedSampler(const SamplerState &samplerState);
 
-	void setComputeShader(Shader *);
+	void setComputeShader(Shader *computeShader);
 	std::set<Shader*> &getUsedShadersInFrame();
 
 	graphics::Shader::BuiltinUniformData getCurrentBuiltinUniformData();
@@ -361,11 +361,11 @@ private:
 	void createImageViews();
 	void createDefaultRenderPass();
 	void createDefaultFramebuffers();
-    VkFramebuffer createFramebuffer(FramebufferConfiguration &);
-    VkFramebuffer getFramebuffer(FramebufferConfiguration &);
+    VkFramebuffer createFramebuffer(FramebufferConfiguration &configuration);
+    VkFramebuffer getFramebuffer(FramebufferConfiguration &configuration);
 	void createDefaultShaders();
-    VkRenderPass createRenderPass(RenderPassConfiguration &);
-	VkPipeline createGraphicsPipeline(GraphicsPipelineConfiguration &);
+    VkRenderPass createRenderPass(RenderPassConfiguration &configuration);
+	VkPipeline createGraphicsPipeline(GraphicsPipelineConfiguration &configuration);
 	void createColorResources();
 	VkFormat findSupportedFormat(const std::vector<VkFormat> &candidates, VkImageTiling tiling, VkFormatFeatureFlags features);
 	VkFormat findDepthFormat();
@@ -381,9 +381,9 @@ private:
 	void beginFrame();
 	void startRecordingGraphicsCommands(bool newFrame);
 	void endRecordingGraphicsCommands(bool present);
-	void ensureGraphicsPipelineConfiguration(GraphicsPipelineConfiguration &);
+	void ensureGraphicsPipelineConfiguration(GraphicsPipelineConfiguration &configuration);
 	void updatedBatchedDrawBuffers();
-	bool usesConstantVertexColor(const VertexAttributes &);
+	bool usesConstantVertexColor(const VertexAttributes &attribs);
 	void createVulkanVertexFormat(
 		VertexAttributes vertexAttributes, 
 		std::vector<VkVertexInputBindingDescription> &bindingDescriptions, 
@@ -393,7 +393,7 @@ private:
 	void setDefaultRenderPass();
 	void startRenderPass();
 	void endRenderPass();
-	VkSampler createSampler(const SamplerState&);
+	VkSampler createSampler(const SamplerState &samplerState);
 
 	VkInstance instance = VK_NULL_HANDLE;
 	VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;

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

@@ -11,7 +11,7 @@ namespace vulkan
 
 class Graphics;
 
-class GraphicsReadback : public graphics::GraphicsReadback
+class GraphicsReadback final : public graphics::GraphicsReadback
 {
 public:
 	GraphicsReadback(love::graphics::Graphics *gfx, ReadbackMethod method, love::graphics::Buffer *buffer, size_t offset, size_t size, data::ByteData *dest, size_t destoffset);

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

@@ -15,7 +15,7 @@ namespace vulkan
 
 class Graphics;
 
-class StreamBuffer
+class StreamBuffer final
 	: public love::graphics::StreamBuffer
 	, public graphics::Volatile
 {

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

@@ -15,7 +15,7 @@ namespace vulkan
 
 class Graphics;
 
-class Texture
+class Texture final
 	: public graphics::Texture
 	, public Volatile
 {