diff --git a/materialsystem/vulkan/commands/draw.cpp b/materialsystem/vulkan/commands/draw.cpp index 1857aad..ff8bea2 100644 --- a/materialsystem/vulkan/commands/draw.cpp +++ b/materialsystem/vulkan/commands/draw.cpp @@ -3,7 +3,6 @@ #include "materialsystem/imaterialsystem.h" #include "tier0/platform.h" #include "tier1/utlvector.h" -#include "vulkan/vulkan_core.h" DECLARE_VULKAN_COMMAND(ClearColor) diff --git a/materialsystem/vulkan/libraries/raster.cpp b/materialsystem/vulkan/libraries/raster.cpp index b23976a..b7ab323 100644 --- a/materialsystem/vulkan/libraries/raster.cpp +++ b/materialsystem/vulkan/libraries/raster.cpp @@ -9,13 +9,20 @@ BEGIN_BUILD_PIPELINE_LIBRARY(VertexDescription) library.flags = VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT; VkPipelineVertexInputStateCreateInfo vertexInput = {}; + VkPipelineInputAssemblyStateCreateInfo inputAssembly = {}; + vertexInput.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vertexInput.vertexBindingDescriptionCount = layouts.GetSize(); vertexInput.pVertexBindingDescriptions = layouts.GetData(); vertexInput.vertexAttributeDescriptionCount = attributes.GetSize(); vertexInput.pVertexAttributeDescriptions = attributes.GetData(); + inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; + inputAssembly.primitiveRestartEnable = VK_FALSE; + inputAssembly.topology = m_eTopology; + pipeline.pVertexInputState = &vertexInput; + pipeline.pInputAssemblyState = &inputAssembly; END_BUILD_PIPELINE_LIBRARY() void CVkVertexDescriptionPipelineLibrary::AddLayout( int iIndex, int iStride ) @@ -39,5 +46,5 @@ void CVkVertexDescriptionPipelineLibrary::AddAttribute( int iBufferIndex, int iL void CVkVertexDescriptionPipelineLibrary::SetTopology( ETopologyMode eTopology ) { - + m_eTopology = VulkanGetTopology(eTopology); } diff --git a/materialsystem/vulkan/raster_libraries.h b/materialsystem/vulkan/raster_libraries.h index 410eff4..bea395e 100644 --- a/materialsystem/vulkan/raster_libraries.h +++ b/materialsystem/vulkan/raster_libraries.h @@ -7,11 +7,13 @@ BEGIN_DEFINE_PIPELINE_LIBRARY(VertexDescription) void AddAttribute( int iBufferIndex, int iLocation, EVertexFormat eFormat, int iOffset ); void SetTopology( ETopologyMode eTopology ); + VkPrimitiveTopology m_eTopology; CUtlVector attributes; CUtlVector layouts; END_DEFINE_PIPELINE_LIBRARY() BEGIN_DEFINE_PIPELINE_LIBRARY(VertexTransform) + END_DEFINE_PIPELINE_LIBRARY() BEGIN_DEFINE_PIPELINE_LIBRARY(PixelShade) diff --git a/materialsystem/vulkan/rendercontext.cpp b/materialsystem/vulkan/rendercontext.cpp index 16fd159..ff561d9 100644 --- a/materialsystem/vulkan/rendercontext.cpp +++ b/materialsystem/vulkan/rendercontext.cpp @@ -480,11 +480,13 @@ void CVkRenderContext::Init() pCommand->g = 0; pCommand->AddSwapchainDependency( (IRenderingObject**)g_vkSwapchainImages.GetData(), DEPENDENCY_MODE_COLOR_CLEAR_DESTINATION ); - CVkVertexDescriptionPipelineLibrary functions = {}; - functions.AddAttribute(0, 0, VERTEX_FORMAT_XYZ32_SFLOAT, 0); - functions.AddLayout(0, 12); - functions.SetTopology(TOPOLOGY_MODE_TRIANGLE_LIST); - functions.Build(); + CVkVertexDescriptionPipelineLibrary vertexDescription = {}; + vertexDescription.AddAttribute(0, 0, VERTEX_FORMAT_XYZ32_SFLOAT, 0); + vertexDescription.AddLayout(0, 12); + vertexDescription.SetTopology(TOPOLOGY_MODE_TRIANGLE_LIST); + vertexDescription.Build(); + + CVkVertexTransformPipelineLibrary vertexTransform = {}; CVkEmptyCommand *pPresentCommand = (CVkEmptyCommand*)g_pCommandBufferManager->CreateCommand("Empty"); pPresentCommand->AddSwapchainDependency( (IRenderingObject**)g_vkSwapchainImages.GetData(), DEPENDENCY_MODE_IMAGE_PRESENT ); diff --git a/materialsystem/vulkan/utils.cpp b/materialsystem/vulkan/utils.cpp index 8aa2ec8..da08fde 100644 --- a/materialsystem/vulkan/utils.cpp +++ b/materialsystem/vulkan/utils.cpp @@ -1,3 +1,4 @@ +#include "materialsystem/imaterialsystem.h" #include "vulkan_state.h" IRenderingObject *VulkanGetObject( VkFrameObject_t stObject, int iIndex ) @@ -60,3 +61,15 @@ VkFormat VulkanGetVertexFormat( EVertexFormat eFormat ) return VK_FORMAT_UNDEFINED; } } + +VkPrimitiveTopology VulkanGetTopology( ETopologyMode eMode ) +{ + switch ( eMode ) + { + case TOPOLOGY_MODE_POINT_LIST: return VK_PRIMITIVE_TOPOLOGY_POINT_LIST; + case TOPOLOGY_MODE_LINE_LIST: return VK_PRIMITIVE_TOPOLOGY_LINE_LIST; + case TOPOLOGY_MODE_LINE_STRIP: return VK_PRIMITIVE_TOPOLOGY_LINE_STRIP; + case TOPOLOGY_MODE_TRIANGLE_LIST: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + case TOPOLOGY_MODE_TRIANGLE_STRIP: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; + } +} diff --git a/materialsystem/vulkan/vulkan_state.h b/materialsystem/vulkan/vulkan_state.h index a5cab19..59d8f3a 100644 --- a/materialsystem/vulkan/vulkan_state.h +++ b/materialsystem/vulkan/vulkan_state.h @@ -273,4 +273,5 @@ VkAccessFlags2 VulkanGetAccessFlags( EDependencyMode eMode ); VkPipelineStageFlags2 VulkanGetStageFlags( EDependencyMode eMode ); VkImageLayout VulkanGetImageLayout( EDependencyMode eMode ); VkFormat VulkanGetVertexFormat( EVertexFormat eFormat ); +VkPrimitiveTopology VulkanGetTopology( ETopologyMode eMode ); #endif