Removed SwiftShader's custom DrawType enum

Replaced DrawType by VkPrimitiveTopology and VkIndexType.

Bug b/118386749

Change-Id: I6cd9a263b823e32c19ab85df7978cd674a757f1f
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/22848
Tested-by: Alexis Hétu <sugoi@google.com>
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Device/Context.cpp b/src/Device/Context.cpp
index adb22d1..c341409 100644
--- a/src/Device/Context.cpp
+++ b/src/Device/Context.cpp
@@ -58,98 +58,56 @@
 
 	bool Context::isDrawPoint() const
 	{
-		switch(drawType)
+		switch(topology)
 		{
-		case DRAW_POINTLIST:
-		case DRAW_INDEXEDPOINTLIST16:
-		case DRAW_INDEXEDPOINTLIST32:
+		case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
 			return true;
-		case DRAW_LINELIST:
-		case DRAW_LINESTRIP:
-		case DRAW_INDEXEDLINELIST16:
-		case DRAW_INDEXEDLINESTRIP16:
-		case DRAW_INDEXEDLINELIST32:
-		case DRAW_INDEXEDLINESTRIP32:
-			return false;
-		case DRAW_TRIANGLELIST:
-		case DRAW_TRIANGLESTRIP:
-		case DRAW_TRIANGLEFAN:
-		case DRAW_INDEXEDTRIANGLELIST16:
-		case DRAW_INDEXEDTRIANGLESTRIP16:
-		case DRAW_INDEXEDTRIANGLEFAN16:
-		case DRAW_INDEXEDTRIANGLELIST32:
-		case DRAW_INDEXEDTRIANGLESTRIP32:
-		case DRAW_INDEXEDTRIANGLEFAN32:
-			return false;
+		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+			break;
 		default:
-			ASSERT(false);
+			UNIMPLEMENTED("topology %d", int(topology));
 		}
-
 		return false;
 	}
 
 	bool Context::isDrawLine() const
 	{
-		switch(drawType)
+		switch(topology)
 		{
-		case DRAW_POINTLIST:
-		case DRAW_INDEXEDPOINTLIST16:
-		case DRAW_INDEXEDPOINTLIST32:
-			return false;
-		case DRAW_LINELIST:
-		case DRAW_LINESTRIP:
-		case DRAW_INDEXEDLINELIST16:
-		case DRAW_INDEXEDLINESTRIP16:
-		case DRAW_INDEXEDLINELIST32:
-		case DRAW_INDEXEDLINESTRIP32:
+		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
 			return true;
-		case DRAW_TRIANGLELIST:
-		case DRAW_TRIANGLESTRIP:
-		case DRAW_TRIANGLEFAN:
-		case DRAW_INDEXEDTRIANGLELIST16:
-		case DRAW_INDEXEDTRIANGLESTRIP16:
-		case DRAW_INDEXEDTRIANGLEFAN16:
-		case DRAW_INDEXEDTRIANGLELIST32:
-		case DRAW_INDEXEDTRIANGLESTRIP32:
-		case DRAW_INDEXEDTRIANGLEFAN32:
-			return false;
+		case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+			break;
 		default:
-			ASSERT(false);
+			UNIMPLEMENTED("topology %d", int(topology));
 		}
-
 		return false;
 	}
 
 	bool Context::isDrawTriangle() const
 	{
-		switch(drawType)
+		switch(topology)
 		{
-		case DRAW_POINTLIST:
-		case DRAW_INDEXEDPOINTLIST16:
-		case DRAW_INDEXEDPOINTLIST32:
-			return false;
-		case DRAW_LINELIST:
-		case DRAW_LINESTRIP:
-		case DRAW_INDEXEDLINELIST16:
-		case DRAW_INDEXEDLINESTRIP16:
-		case DRAW_INDEXEDLINELIST32:
-		case DRAW_INDEXEDLINESTRIP32:
-			return false;
-		case DRAW_TRIANGLELIST:
-		case DRAW_TRIANGLESTRIP:
-		case DRAW_TRIANGLEFAN:
-		case DRAW_INDEXEDTRIANGLELIST16:
-		case DRAW_INDEXEDTRIANGLESTRIP16:
-		case DRAW_INDEXEDTRIANGLEFAN16:
-		case DRAW_INDEXEDTRIANGLELIST32:
-		case DRAW_INDEXEDTRIANGLESTRIP32:
-		case DRAW_INDEXEDTRIANGLEFAN32:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
 			return true;
+		case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+			break;
 		default:
-			ASSERT(false);
+			UNIMPLEMENTED("topology %d", int(topology));
 		}
-
-		return true;
+		return false;
 	}
 
 	void Context::init()
diff --git a/src/Device/Context.hpp b/src/Device/Context.hpp
index 2f3a0f4..ac63a89 100644
--- a/src/Device/Context.hpp
+++ b/src/Device/Context.hpp
@@ -62,38 +62,6 @@
 		PositionT = 15
 	};
 
-	enum DrawType ENUM_UNDERLYING_TYPE_UNSIGNED_INT
-	{
-		// These types must stay ordered by vertices per primitive. Also, if these basic types
-		// are modified, verify the value assigned to task->verticesPerPrimitive in Renderer.cpp
-		DRAW_POINTLIST     = 0x00,
-		DRAW_LINELIST      = 0x01,
-		DRAW_LINESTRIP     = 0x02,
-		DRAW_TRIANGLELIST  = 0x03,
-		DRAW_TRIANGLESTRIP = 0x04,
-		DRAW_TRIANGLEFAN   = 0x05,
-
-		DRAW_NONINDEXED = 0x00,
-		DRAW_INDEXED16  = 0x20,
-		DRAW_INDEXED32  = 0x30,
-
-		DRAW_INDEXEDPOINTLIST16 = DRAW_POINTLIST | DRAW_INDEXED16,
-		DRAW_INDEXEDLINELIST16  = DRAW_LINELIST  | DRAW_INDEXED16,
-		DRAW_INDEXEDLINESTRIP16 = DRAW_LINESTRIP | DRAW_INDEXED16,
-		DRAW_INDEXEDTRIANGLELIST16  = DRAW_TRIANGLELIST  | DRAW_INDEXED16,
-		DRAW_INDEXEDTRIANGLESTRIP16 = DRAW_TRIANGLESTRIP | DRAW_INDEXED16,
-		DRAW_INDEXEDTRIANGLEFAN16   = DRAW_TRIANGLEFAN   | DRAW_INDEXED16,
-
-		DRAW_INDEXEDPOINTLIST32 = DRAW_POINTLIST | DRAW_INDEXED32,
-		DRAW_INDEXEDLINELIST32  = DRAW_LINELIST  | DRAW_INDEXED32,
-		DRAW_INDEXEDLINESTRIP32 = DRAW_LINESTRIP | DRAW_INDEXED32,
-		DRAW_INDEXEDTRIANGLELIST32  = DRAW_TRIANGLELIST  | DRAW_INDEXED32,
-		DRAW_INDEXEDTRIANGLESTRIP32 = DRAW_TRIANGLESTRIP | DRAW_INDEXED32,
-		DRAW_INDEXEDTRIANGLEFAN32   = DRAW_TRIANGLEFAN   | DRAW_INDEXED32,
-
-		DRAW_LAST = DRAW_INDEXEDTRIANGLEFAN32
-	};
-
 	enum CullMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
 	{
 		CULL_NONE,
@@ -165,7 +133,7 @@
 
 		VkLogicOp colorLogicOp();
 
-		DrawType drawType;
+		VkPrimitiveTopology topology;
 
 		bool stencilEnable;
 		bool twoSidedStencil;
diff --git a/src/Device/Renderer.cpp b/src/Device/Renderer.cpp
index 765e594..4a77700 100644
--- a/src/Device/Renderer.cpp
+++ b/src/Device/Renderer.cpp
@@ -83,6 +83,87 @@
 		}
 	}
 
+	template<typename T>
+	inline bool setBatchIndices(unsigned int batch[128][3], VkPrimitiveTopology topology, const T* indices, unsigned int start, unsigned int triangleCount)
+	{
+		const T *index = indices + start;
+
+		switch(topology)
+		{
+		case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+			for(unsigned int i = 0; i < triangleCount; i++)
+			{
+				batch[i][0] = *index;
+				batch[i][1] = *index;
+				batch[i][2] = *index;
+
+				index += 1;
+			}
+			break;
+		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+			index += start;
+
+			for(unsigned int i = 0; i < triangleCount; i++)
+			{
+				batch[i][0] = index[0];
+				batch[i][1] = index[1];
+				batch[i][2] = index[1];
+
+				index += 2;
+			}
+			break;
+		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+			for(unsigned int i = 0; i < triangleCount; i++)
+			{
+				batch[i][0] = index[0];
+				batch[i][1] = index[1];
+				batch[i][2] = index[1];
+
+				index += 1;
+			}
+			break;
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+			index += start + start;
+
+			for(unsigned int i = 0; i < triangleCount; i++)
+			{
+				batch[i][0] = index[0];
+				batch[i][1] = index[1];
+				batch[i][2] = index[2];
+
+				index += 3;
+			}
+			break;
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+			for(unsigned int i = 0; i < triangleCount; i++)
+			{
+				batch[i][0] = index[0];
+				batch[i][1] = index[((start + i) & 1) + 1];
+				batch[i][2] = index[(~(start + i) & 1) + 1];
+
+				index += 1;
+			}
+			break;
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+			index += 1;
+
+			for(unsigned int i = 0; i < triangleCount; i++)
+			{
+				batch[i][0] = index[0];
+				batch[i][1] = index[1];
+				batch[i][2] = indices[0];
+
+				index += 1;
+			}
+			break;
+		default:
+			ASSERT(false);
+			return false;
+		}
+
+		return true;
+	}
+
 	struct Parameters
 	{
 		Renderer *renderer;
@@ -204,7 +285,7 @@
 		sw::deallocate(mem);
 	}
 
-	void Renderer::draw(DrawType drawType, unsigned int count, bool update)
+	void Renderer::draw(VkPrimitiveTopology topology, VkIndexType indexType, unsigned int count, bool update)
 	{
 		#ifndef NDEBUG
 			if(count < minPrimitives || count > maxPrimitives)
@@ -213,7 +294,7 @@
 			}
 		#endif
 
-		context->drawType = drawType;
+		context->topology = topology;
 
 		updateConfiguration();
 
@@ -230,7 +311,7 @@
 
 		if(update || oldMultiSampleMask != context->multiSampleMask)
 		{
-			vertexState = VertexProcessor::update(drawType);
+			vertexState = VertexProcessor::update(topology);
 			setupState = SetupProcessor::update();
 			pixelState = PixelProcessor::update();
 
@@ -290,7 +371,8 @@
 			}
 		}
 
-		draw->drawType = drawType;
+		draw->topology = topology;
+		draw->indexType = indexType;
 		draw->batchSize = batch;
 
 		vertexRoutine->bind();
@@ -317,10 +399,7 @@
 			data->stride[i] = context->input[i].vertexStride;
 		}
 
-		if(context->indexBuffer)
-		{
-			data->indices = context->indexBuffer;
-		}
+		data->indices = context->indexBuffer;
 
 		if(context->vertexShader->hasBuiltinInput(spv::BuiltInInstanceIndex))
 		{
@@ -817,13 +896,15 @@
 		}
 
 		unsigned int batch[128][3];   // FIXME: Adjust to dynamic batch size
+		VkPrimitiveTopology topology = static_cast<VkPrimitiveTopology>(static_cast<int>(draw->topology));
 
-		switch(draw->drawType)
+		if(!indices)
 		{
-		case DRAW_POINTLIST:
-			{
-				unsigned int index = start;
+			unsigned int index = start;
 
+			switch(topology)
+			{
+			case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
 				for(unsigned int i = 0; i < triangleCount; i++)
 				{
 					batch[i][0] = index;
@@ -832,11 +913,9 @@
 
 					index += 1;
 				}
-			}
-			break;
-		case DRAW_LINELIST:
-			{
-				unsigned int index = 2 * start;
+				break;
+			case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+				index = 2 * start;
 
 				for(unsigned int i = 0; i < triangleCount; i++)
 				{
@@ -846,12 +925,8 @@
 
 					index += 2;
 				}
-			}
-			break;
-		case DRAW_LINESTRIP:
-			{
-				unsigned int index = start;
-
+				break;
+			case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
 				for(unsigned int i = 0; i < triangleCount; i++)
 				{
 					batch[i][0] = index + 0;
@@ -860,11 +935,9 @@
 
 					index += 1;
 				}
-			}
-			break;
-		case DRAW_TRIANGLELIST:
-			{
-				unsigned int index = 3 * start;
+				break;
+			case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+				index = 3 * start;
 
 				for(unsigned int i = 0; i < triangleCount; i++)
 				{
@@ -874,12 +947,8 @@
 
 					index += 3;
 				}
-			}
-			break;
-		case DRAW_TRIANGLESTRIP:
-			{
-				unsigned int index = start;
-
+				break;
+			case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
 				for(unsigned int i = 0; i < triangleCount; i++)
 				{
 					batch[i][0] = index + 0;
@@ -888,12 +957,8 @@
 
 					index += 1;
 				}
-			}
-			break;
-		case DRAW_TRIANGLEFAN:
-			{
-				unsigned int index = start;
-
+				break;
+			case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
 				for(unsigned int i = 0; i < triangleCount; i++)
 				{
 					batch[i][0] = index + 1;
@@ -902,175 +967,33 @@
 
 					index += 1;
 				}
+				break;
+			default:
+				ASSERT(false);
+				return;
 			}
-			break;
-		case DRAW_INDEXEDPOINTLIST16:
+		}
+		else
+		{
+			switch(draw->indexType)
 			{
-				const unsigned short *index = (const unsigned short*)indices + start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
+			case VK_INDEX_TYPE_UINT16:
+				if(!setBatchIndices(batch, topology, static_cast<const uint16_t*>(indices), start, triangleCount))
 				{
-					batch[i][0] = *index;
-					batch[i][1] = *index;
-					batch[i][2] = *index;
-
-					index += 1;
+					return;
 				}
-			}
-			break;
-		case DRAW_INDEXEDPOINTLIST32:
-			{
-				const unsigned int *index = (const unsigned int*)indices + start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
+				break;
+			case VK_INDEX_TYPE_UINT32:
+				if(!setBatchIndices(batch, topology, static_cast<const uint32_t*>(indices), start, triangleCount))
 				{
-					batch[i][0] = *index;
-					batch[i][1] = *index;
-					batch[i][2] = *index;
-
-					index += 1;
+					return;
 				}
-			}
+				break;
 			break;
-		case DRAW_INDEXEDLINELIST16:
-			{
-				const unsigned short *index = (const unsigned short*)indices + 2 * start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[0];
-					batch[i][1] = index[1];
-					batch[i][2] = index[1];
-
-					index += 2;
-				}
+			default:
+				ASSERT(false);
+				return;
 			}
-			break;
-		case DRAW_INDEXEDLINELIST32:
-			{
-				const unsigned int *index = (const unsigned int*)indices + 2 * start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[0];
-					batch[i][1] = index[1];
-					batch[i][2] = index[1];
-
-					index += 2;
-				}
-			}
-			break;
-		case DRAW_INDEXEDLINESTRIP16:
-			{
-				const unsigned short *index = (const unsigned short*)indices + start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[0];
-					batch[i][1] = index[1];
-					batch[i][2] = index[1];
-
-					index += 1;
-				}
-			}
-			break;
-		case DRAW_INDEXEDLINESTRIP32:
-			{
-				const unsigned int *index = (const unsigned int*)indices + start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[0];
-					batch[i][1] = index[1];
-					batch[i][2] = index[1];
-
-					index += 1;
-				}
-			}
-			break;
-		case DRAW_INDEXEDTRIANGLELIST16:
-			{
-				const unsigned short *index = (const unsigned short*)indices + 3 * start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[0];
-					batch[i][1] = index[1];
-					batch[i][2] = index[2];
-
-					index += 3;
-				}
-			}
-			break;
-		case DRAW_INDEXEDTRIANGLELIST32:
-			{
-				const unsigned int *index = (const unsigned int*)indices + 3 * start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[0];
-					batch[i][1] = index[1];
-					batch[i][2] = index[2];
-
-					index += 3;
-				}
-			}
-			break;
-		case DRAW_INDEXEDTRIANGLESTRIP16:
-			{
-				const unsigned short *index = (const unsigned short*)indices + start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[0];
-					batch[i][1] = index[((start + i) & 1) + 1];
-					batch[i][2] = index[(~(start + i) & 1) + 1];
-
-					index += 1;
-				}
-			}
-			break;
-		case DRAW_INDEXEDTRIANGLESTRIP32:
-			{
-				const unsigned int *index = (const unsigned int*)indices + start;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[0];
-					batch[i][1] = index[((start + i) & 1) + 1];
-					batch[i][2] = index[(~(start + i) & 1) + 1];
-
-					index += 1;
-				}
-			}
-			break;
-		case DRAW_INDEXEDTRIANGLEFAN16:
-			{
-				const unsigned short *index = (const unsigned short*)indices;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[start + i + 1];
-					batch[i][1] = index[start + i + 2];
-					batch[i][2] = index[0];
-				}
-			}
-			break;
-		case DRAW_INDEXEDTRIANGLEFAN32:
-			{
-				const unsigned int *index = (const unsigned int*)indices;
-
-				for(unsigned int i = 0; i < triangleCount; i++)
-				{
-					batch[i][0] = index[start + i + 1];
-					batch[i][1] = index[start + i + 2];
-					batch[i][2] = index[0];
-				}
-			}
-			break;
-		default:
-			ASSERT(false);
-			return;
 		}
 
 		task->primitiveStart = start;
diff --git a/src/Device/Renderer.hpp b/src/Device/Renderer.hpp
index b65cea4..63a5b55 100644
--- a/src/Device/Renderer.hpp
+++ b/src/Device/Renderer.hpp
@@ -225,7 +225,7 @@
 		void *operator new(size_t size);
 		void operator delete(void * mem);
 
-		void draw(DrawType drawType, unsigned int count, bool update = true);
+		void draw(VkPrimitiveTopology topology, VkIndexType indexType, unsigned int count, bool update = true);
 
 		void setContext(const sw::Context& context);
 
@@ -359,7 +359,8 @@
 
 		~DrawCall();
 
-		AtomicInt drawType;
+		AtomicInt topology;
+		AtomicInt indexType;
 		AtomicInt batchSize;
 
 		Routine *vertexRoutine;
diff --git a/src/Device/VertexProcessor.cpp b/src/Device/VertexProcessor.cpp
index 47ce148..9805e40 100644
--- a/src/Device/VertexProcessor.cpp
+++ b/src/Device/VertexProcessor.cpp
@@ -97,16 +97,29 @@
 		routineCache = new RoutineCache<State>(clamp(cacheSize, 1, 65536));
 	}
 
-	const VertexProcessor::State VertexProcessor::update(DrawType drawType)
+	const VertexProcessor::State VertexProcessor::update(VkPrimitiveTopology topology)
 	{
 		State state;
 
 		state.shaderID = context->vertexShader->getSerialID();
 
-		// Note: Quads aren't handled for verticesPerPrimitive, but verticesPerPrimitive is used for transform feedback,
-		//       which is an OpenGL ES 3.0 feature, and OpenGL ES 3.0 doesn't support quads as a primitive type.
-		DrawType type = static_cast<DrawType>(static_cast<unsigned int>(drawType) & 0xF);
-		state.verticesPerPrimitive = 1 + (type >= DRAW_LINELIST) + (type >= DRAW_TRIANGLELIST);
+		switch(topology)
+		{
+		case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
+			state.verticesPerPrimitive = 1;
+			break;
+		case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
+			state.verticesPerPrimitive = 2;
+			break;
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
+		case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
+			state.verticesPerPrimitive = 3;
+			break;
+		default:
+			UNIMPLEMENTED("topology %d", int(topology));
+		}
 
 		for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
 		{
diff --git a/src/Device/VertexProcessor.hpp b/src/Device/VertexProcessor.hpp
index 28c0996..6d57e71 100644
--- a/src/Device/VertexProcessor.hpp
+++ b/src/Device/VertexProcessor.hpp
@@ -92,7 +92,7 @@
 		void setInstanceID(int instanceID);
 
 	protected:
-		const State update(DrawType drawType);
+		const State update(VkPrimitiveTopology topology);
 		Routine *routine(const State &state);
 
 		void setRoutineCacheSize(int cacheSize);
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp
index 65e8331..cd3f72f 100644
--- a/src/Vulkan/VkCommandBuffer.cpp
+++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -318,15 +318,11 @@
 		}
 
 		context.pushConstants = executionState.pushConstants;
-		auto drawType = context.drawType;
 
 		if (indexed)
 		{
 			context.indexBuffer = Cast(executionState.indexBufferBinding.buffer)->getOffsetPointer(
 					executionState.indexBufferBinding.offset + first * bytesPerIndex(executionState));
-
-			drawType = static_cast<sw::DrawType>(executionState.indexType == VK_INDEX_TYPE_UINT16
-					   ? (context.drawType | sw::DRAW_INDEXED16) : (context.drawType | sw::DRAW_INDEXED32));
 		}
 
 		executionState.renderer->setContext(context);
@@ -340,7 +336,7 @@
 		for(uint32_t instance = firstInstance; instance != firstInstance + instanceCount; instance++)
 		{
 			executionState.renderer->setInstanceID(instance);
-			executionState.renderer->draw(drawType, primitiveCount);
+			executionState.renderer->draw(context.topology, executionState.indexType, primitiveCount);
 			executionState.renderer->advanceInstanceAttributes();
 		}
 	}
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index 039ff9a..4cb0240 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -25,40 +25,6 @@
 namespace
 {
 
-sw::DrawType Convert(VkPrimitiveTopology topology)
-{
-	switch(topology)
-	{
-	case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
-		return sw::DRAW_POINTLIST;
-	case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
-		return sw::DRAW_LINELIST;
-	case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
-		return sw::DRAW_LINESTRIP;
-	case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
-		return sw::DRAW_TRIANGLELIST;
-	case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
-		return sw::DRAW_TRIANGLESTRIP;
-	case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
-		return sw::DRAW_TRIANGLEFAN;
-	case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY:
-	case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY:
-	case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY:
-	case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY:
-		// geometry shader specific
-		ASSERT(false);
-		break;
-	case VK_PRIMITIVE_TOPOLOGY_PATCH_LIST:
-		// tesselation shader specific
-		ASSERT(false);
-		break;
-	default:
-		UNIMPLEMENTED("topology");
-	}
-
-	return sw::DRAW_TRIANGLELIST;
-}
-
 sw::StreamType getStreamType(VkFormat format)
 {
 	switch(format)
@@ -311,7 +277,7 @@
 		UNIMPLEMENTED("pCreateInfo->pInputAssemblyState settings");
 	}
 
-	context.drawType = Convert(assemblyState->topology);
+	context.topology = assemblyState->topology;
 
 	const VkPipelineViewportStateCreateInfo* viewportState = pCreateInfo->pViewportState;
 	if(viewportState)
@@ -473,22 +439,22 @@
 
 uint32_t GraphicsPipeline::computePrimitiveCount(uint32_t vertexCount) const
 {
-	switch(context.drawType)
+	switch(context.topology)
 	{
-	case sw::DRAW_POINTLIST:
+	case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
 		return vertexCount;
-	case sw::DRAW_LINELIST:
+	case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
 		return vertexCount / 2;
-	case sw::DRAW_LINESTRIP:
+	case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
 		return vertexCount - 1;
-	case sw::DRAW_TRIANGLELIST:
+	case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
 		return vertexCount / 3;
-	case sw::DRAW_TRIANGLESTRIP:
+	case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
 		return vertexCount - 2;
-	case sw::DRAW_TRIANGLEFAN:
+	case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
 		return vertexCount - 2;
 	default:
-		UNIMPLEMENTED("drawType");
+		UNIMPLEMENTED("context.topology %d", int(context.topology));
 	}
 
 	return 0;