diff --git a/src/modules/graphics/vulkan/Graphics.cpp b/src/modules/graphics/vulkan/Graphics.cpp index d1ea9f541..e6ffe11a7 100644 --- a/src/modules/graphics/vulkan/Graphics.cpp +++ b/src/modules/graphics/vulkan/Graphics.cpp @@ -250,7 +250,6 @@ bool Graphics::setMode(void* context, int width, int height, int pixelwidth, int updatedBatchedDrawBuffers(); Shader::current = Shader::standardShaders[graphics::Shader::StandardShader::STANDARD_DEFAULT]; - currentPolygonMode = VK_POLYGON_MODE_FILL; restoreState(states.back()); setViewportSize(width, height, pixelwidth, pixelheight); @@ -428,13 +427,6 @@ void Graphics::setScissor() { void Graphics::setWireframe(bool enable) { flushBatchedDraws(); - if (enable) { - currentPolygonMode = VK_POLYGON_MODE_LINE; - } - else { - currentPolygonMode = VK_POLYGON_MODE_FILL; - } - states.back().wireframe = enable; } @@ -876,6 +868,7 @@ void Graphics::createLogicalDevice() { VkPhysicalDeviceFeatures deviceFeatures{}; deviceFeatures.samplerAnisotropy = VK_TRUE; + deviceFeatures.fillModeNonSolid = VK_TRUE; VkDeviceCreateInfo createInfo{}; createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; @@ -1176,7 +1169,7 @@ void Graphics::prepareDraw(const VertexAttributes& attributes, const BufferBindi configuration.vertexAttributes = attributes; configuration.shader = (Shader*)Shader::current; configuration.primitiveType = primitiveType; - configuration.polygonMode = currentPolygonMode; + configuration.wireFrame = states.back().wireframe; configuration.blendState = states.back().blend; configuration.colorChannelMask = states.back().colorMask; configuration.winding = states.back().winding; @@ -1319,7 +1312,7 @@ VkPipeline Graphics::createGraphicsPipeline(GraphicsPipelineConfiguration config rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterizer.depthClampEnable = VK_FALSE; rasterizer.rasterizerDiscardEnable = VK_FALSE; - rasterizer.polygonMode = configuration.polygonMode; + rasterizer.polygonMode = Vulkan::getPolygonMode(configuration.wireFrame); rasterizer.lineWidth = 1.0f; rasterizer.cullMode = Vulkan::getCullMode(configuration.cullmode); rasterizer.frontFace = Vulkan::getFrontFace(configuration.winding); diff --git a/src/modules/graphics/vulkan/Graphics.h b/src/modules/graphics/vulkan/Graphics.h index edd150d82..dc88144bc 100644 --- a/src/modules/graphics/vulkan/Graphics.h +++ b/src/modules/graphics/vulkan/Graphics.h @@ -28,7 +28,7 @@ struct GraphicsPipelineConfiguration { VertexAttributes vertexAttributes; Shader* shader = nullptr; PrimitiveType primitiveType = PRIMITIVE_MAX_ENUM; - VkPolygonMode polygonMode = VK_POLYGON_MODE_FILL; + bool wireFrame; BlendState blendState; ColorChannelMask colorChannelMask; Winding winding; @@ -230,7 +230,6 @@ private: // just like batchedDrawBuffers we need a vector for each frame in flight. std::vector>> cleanUpFunctions; graphics::Texture* currentTexture = nullptr; - VkPolygonMode currentPolygonMode = VK_POLYGON_MODE_FILL; // render pass variables. VkFormat currentFramebufferOutputFormat = VK_FORMAT_UNDEFINED; diff --git a/src/modules/graphics/vulkan/Vulkan.cpp b/src/modules/graphics/vulkan/Vulkan.cpp index 2041a18ee..3a7054a81 100644 --- a/src/modules/graphics/vulkan/Vulkan.cpp +++ b/src/modules/graphics/vulkan/Vulkan.cpp @@ -481,6 +481,14 @@ VkImageViewType Vulkan::getImageViewType(TextureType textureType) { } } +VkPolygonMode Vulkan::getPolygonMode(bool wireframe) { + if (wireframe) { + return VK_POLYGON_MODE_LINE; + } else { + return VK_POLYGON_MODE_FILL; + } +} + void Vulkan::cmdTransitionImageLayout(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t baseLevel, uint32_t levelCount, uint32_t baseLayer, uint32_t layerCount) { VkImageMemoryBarrier barrier{}; diff --git a/src/modules/graphics/vulkan/Vulkan.h b/src/modules/graphics/vulkan/Vulkan.h index efe64bb29..4e01157d8 100644 --- a/src/modules/graphics/vulkan/Vulkan.h +++ b/src/modules/graphics/vulkan/Vulkan.h @@ -43,6 +43,7 @@ public: static VkCullModeFlags getCullMode(CullMode); static VkImageType getImageType(TextureType); static VkImageViewType getImageViewType(TextureType); + static VkPolygonMode getPolygonMode(bool wireframe); static void cmdTransitionImageLayout( VkCommandBuffer, VkImage, VkImageLayout oldLayout, VkImageLayout newLayout,