vulkan: implement setWireframe

This commit is contained in:
niki
2022-07-13 15:55:14 +02:00
parent 0834408b90
commit 4190807a20
2 changed files with 25 additions and 3 deletions
+22 -2
View File
@@ -249,6 +249,7 @@ namespace love {
updatedBatchedDrawBuffers(); updatedBatchedDrawBuffers();
Shader::current = Shader::standardShaders[graphics::Shader::StandardShader::STANDARD_DEFAULT]; Shader::current = Shader::standardShaders[graphics::Shader::StandardShader::STANDARD_DEFAULT];
currentPolygonMode = VK_POLYGON_MODE_FILL;
return true; return true;
} }
@@ -350,6 +351,21 @@ namespace love {
states.back().color = c; states.back().color = c;
} }
void Graphics::setWireframe(bool enable) {
std::cout << "setWireframe ";
flushBatchedDraws();
if (enable) {
currentPolygonMode = VK_POLYGON_MODE_LINE;
}
else {
currentPolygonMode = VK_POLYGON_MODE_FILL;
}
states.back().wireframe = enable;
}
PixelFormat Graphics::getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const { PixelFormat Graphics::getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const {
std::cout << "getSizedFormat "; std::cout << "getSizedFormat ";
@@ -1194,6 +1210,7 @@ namespace love {
GraphicsPipelineConfiguration configuration; GraphicsPipelineConfiguration configuration;
configuration.shader = (Shader*)Shader::current; configuration.shader = (Shader*)Shader::current;
configuration.primitiveType = primitiveType; configuration.primitiveType = primitiveType;
configuration.polygonMode = currentPolygonMode;
std::vector<VkBuffer> bufferVector; std::vector<VkBuffer> bufferVector;
std::vector<VkDeviceSize> offsets; std::vector<VkDeviceSize> offsets;
@@ -1265,8 +1282,8 @@ namespace love {
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterizer.depthClampEnable = VK_FALSE; rasterizer.depthClampEnable = VK_FALSE;
rasterizer.rasterizerDiscardEnable = VK_FALSE; rasterizer.rasterizerDiscardEnable = VK_FALSE;
rasterizer.polygonMode = VK_POLYGON_MODE_FILL; rasterizer.polygonMode = configuration.polygonMode;
rasterizer.lineWidth = 2.0f; rasterizer.lineWidth = 1.0f;
rasterizer.cullMode = VK_CULL_MODE_FRONT_BIT; rasterizer.cullMode = VK_CULL_MODE_FRONT_BIT;
rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE; rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
rasterizer.depthBiasEnable = VK_FALSE; rasterizer.depthBiasEnable = VK_FALSE;
@@ -1449,6 +1466,9 @@ namespace love {
} }
bool operator==(const GraphicsPipelineConfiguration& first, const GraphicsPipelineConfiguration& other) { bool operator==(const GraphicsPipelineConfiguration& first, const GraphicsPipelineConfiguration& other) {
if (first.polygonMode != other.polygonMode) {
return false;
}
if (first.primitiveType != other.primitiveType) { if (first.primitiveType != other.primitiveType) {
return false; return false;
} }
+3 -1
View File
@@ -24,6 +24,7 @@ namespace love {
std::vector<VkVertexInputAttributeDescription> vertexInputAttributeDescriptions; std::vector<VkVertexInputAttributeDescription> vertexInputAttributeDescriptions;
Shader* shader = nullptr; Shader* shader = nullptr;
PrimitiveType primitiveType = PRIMITIVE_MAX_ENUM; PrimitiveType primitiveType = PRIMITIVE_MAX_ENUM;
VkPolygonMode polygonMode = VK_POLYGON_MODE_FILL;
friend static bool operator==(const GraphicsPipelineConfiguration& first, const GraphicsPipelineConfiguration& other); friend static bool operator==(const GraphicsPipelineConfiguration& first, const GraphicsPipelineConfiguration& other);
}; };
@@ -102,7 +103,7 @@ namespace love {
void setColorMask(ColorChannelMask mask) override { std::cout << "setColorMask "; } void setColorMask(ColorChannelMask mask) override { std::cout << "setColorMask "; }
void setBlendState(const BlendState& blend) override { std::cout << "setBlendState "; } void setBlendState(const BlendState& blend) override { std::cout << "setBlendState "; }
void setPointSize(float size) override { std::cout << "setPointSize "; } void setPointSize(float size) override { std::cout << "setPointSize "; }
void setWireframe(bool enable) override { std::cout << "setWireframe "; } void setWireframe(bool enable) override;
PixelFormat getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const override; PixelFormat getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const override;
bool isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB = false) override; bool isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB = false) override;
Renderer getRenderer() const override; Renderer getRenderer() const override;
@@ -214,6 +215,7 @@ namespace love {
graphics::Texture* currentTexture = nullptr; graphics::Texture* currentTexture = nullptr;
std::vector<std::pair<graphics::Shader::BuiltinUniformData, graphics::StreamBuffer*>> uniformBufferMap; std::vector<std::pair<graphics::Shader::BuiltinUniformData, graphics::StreamBuffer*>> uniformBufferMap;
std::vector<std::pair<DecriptorSetConfiguration, std::vector<VkDescriptorSet>>> descriptorSetsMap; std::vector<std::pair<DecriptorSetConfiguration, std::vector<VkDescriptorSet>>> descriptorSetsMap;
VkPolygonMode currentPolygonMode = VK_POLYGON_MODE_FILL;
}; };
} }
} }