Commit fcbb1450 by Alexis Hetu Committed by Alexis Hétu

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/+/22848Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Presubmit-Ready: Alexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 97e9589a
...@@ -58,98 +58,56 @@ namespace sw ...@@ -58,98 +58,56 @@ namespace sw
bool Context::isDrawPoint() const bool Context::isDrawPoint() const
{ {
switch(drawType) switch(topology)
{ {
case DRAW_POINTLIST: case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
case DRAW_INDEXEDPOINTLIST16:
case DRAW_INDEXEDPOINTLIST32:
return true; return true;
case DRAW_LINELIST: case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
case DRAW_LINESTRIP: case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
case DRAW_INDEXEDLINELIST16: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
case DRAW_INDEXEDLINESTRIP16: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
case DRAW_INDEXEDLINELIST32: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
case DRAW_INDEXEDLINESTRIP32: break;
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;
default: default:
ASSERT(false); UNIMPLEMENTED("topology %d", int(topology));
} }
return false; return false;
} }
bool Context::isDrawLine() const bool Context::isDrawLine() const
{ {
switch(drawType) switch(topology)
{ {
case DRAW_POINTLIST: case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
case DRAW_INDEXEDPOINTLIST16: case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
case DRAW_INDEXEDPOINTLIST32:
return false;
case DRAW_LINELIST:
case DRAW_LINESTRIP:
case DRAW_INDEXEDLINELIST16:
case DRAW_INDEXEDLINESTRIP16:
case DRAW_INDEXEDLINELIST32:
case DRAW_INDEXEDLINESTRIP32:
return true; return true;
case DRAW_TRIANGLELIST: case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
case DRAW_TRIANGLESTRIP: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
case DRAW_TRIANGLEFAN: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
case DRAW_INDEXEDTRIANGLELIST16: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
case DRAW_INDEXEDTRIANGLESTRIP16: break;
case DRAW_INDEXEDTRIANGLEFAN16:
case DRAW_INDEXEDTRIANGLELIST32:
case DRAW_INDEXEDTRIANGLESTRIP32:
case DRAW_INDEXEDTRIANGLEFAN32:
return false;
default: default:
ASSERT(false); UNIMPLEMENTED("topology %d", int(topology));
} }
return false; return false;
} }
bool Context::isDrawTriangle() const bool Context::isDrawTriangle() const
{ {
switch(drawType) switch(topology)
{ {
case DRAW_POINTLIST: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
case DRAW_INDEXEDPOINTLIST16: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
case DRAW_INDEXEDPOINTLIST32: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
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:
return true; return true;
case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
break;
default: default:
ASSERT(false); UNIMPLEMENTED("topology %d", int(topology));
} }
return false;
return true;
} }
void Context::init() void Context::init()
......
...@@ -62,38 +62,6 @@ namespace sw ...@@ -62,38 +62,6 @@ namespace sw
PositionT = 15 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 enum CullMode ENUM_UNDERLYING_TYPE_UNSIGNED_INT
{ {
CULL_NONE, CULL_NONE,
...@@ -165,7 +133,7 @@ namespace sw ...@@ -165,7 +133,7 @@ namespace sw
VkLogicOp colorLogicOp(); VkLogicOp colorLogicOp();
DrawType drawType; VkPrimitiveTopology topology;
bool stencilEnable; bool stencilEnable;
bool twoSidedStencil; bool twoSidedStencil;
......
...@@ -83,6 +83,87 @@ namespace sw ...@@ -83,6 +83,87 @@ namespace sw
} }
} }
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 struct Parameters
{ {
Renderer *renderer; Renderer *renderer;
...@@ -204,7 +285,7 @@ namespace sw ...@@ -204,7 +285,7 @@ namespace sw
sw::deallocate(mem); 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 #ifndef NDEBUG
if(count < minPrimitives || count > maxPrimitives) if(count < minPrimitives || count > maxPrimitives)
...@@ -213,7 +294,7 @@ namespace sw ...@@ -213,7 +294,7 @@ namespace sw
} }
#endif #endif
context->drawType = drawType; context->topology = topology;
updateConfiguration(); updateConfiguration();
...@@ -230,7 +311,7 @@ namespace sw ...@@ -230,7 +311,7 @@ namespace sw
if(update || oldMultiSampleMask != context->multiSampleMask) if(update || oldMultiSampleMask != context->multiSampleMask)
{ {
vertexState = VertexProcessor::update(drawType); vertexState = VertexProcessor::update(topology);
setupState = SetupProcessor::update(); setupState = SetupProcessor::update();
pixelState = PixelProcessor::update(); pixelState = PixelProcessor::update();
...@@ -290,7 +371,8 @@ namespace sw ...@@ -290,7 +371,8 @@ namespace sw
} }
} }
draw->drawType = drawType; draw->topology = topology;
draw->indexType = indexType;
draw->batchSize = batch; draw->batchSize = batch;
vertexRoutine->bind(); vertexRoutine->bind();
...@@ -317,10 +399,7 @@ namespace sw ...@@ -317,10 +399,7 @@ namespace sw
data->stride[i] = context->input[i].vertexStride; data->stride[i] = context->input[i].vertexStride;
} }
if(context->indexBuffer) data->indices = context->indexBuffer;
{
data->indices = context->indexBuffer;
}
if(context->vertexShader->hasBuiltinInput(spv::BuiltInInstanceIndex)) if(context->vertexShader->hasBuiltinInput(spv::BuiltInInstanceIndex))
{ {
...@@ -817,13 +896,15 @@ namespace sw ...@@ -817,13 +896,15 @@ namespace sw
} }
unsigned int batch[128][3]; // FIXME: Adjust to dynamic batch size 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++) for(unsigned int i = 0; i < triangleCount; i++)
{ {
batch[i][0] = index; batch[i][0] = index;
...@@ -832,11 +913,9 @@ namespace sw ...@@ -832,11 +913,9 @@ namespace sw
index += 1; index += 1;
} }
} break;
break; case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
case DRAW_LINELIST: index = 2 * start;
{
unsigned int index = 2 * start;
for(unsigned int i = 0; i < triangleCount; i++) for(unsigned int i = 0; i < triangleCount; i++)
{ {
...@@ -846,12 +925,8 @@ namespace sw ...@@ -846,12 +925,8 @@ namespace sw
index += 2; index += 2;
} }
} break;
break; case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
case DRAW_LINESTRIP:
{
unsigned int index = start;
for(unsigned int i = 0; i < triangleCount; i++) for(unsigned int i = 0; i < triangleCount; i++)
{ {
batch[i][0] = index + 0; batch[i][0] = index + 0;
...@@ -860,11 +935,9 @@ namespace sw ...@@ -860,11 +935,9 @@ namespace sw
index += 1; index += 1;
} }
} break;
break; case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
case DRAW_TRIANGLELIST: index = 3 * start;
{
unsigned int index = 3 * start;
for(unsigned int i = 0; i < triangleCount; i++) for(unsigned int i = 0; i < triangleCount; i++)
{ {
...@@ -874,12 +947,8 @@ namespace sw ...@@ -874,12 +947,8 @@ namespace sw
index += 3; index += 3;
} }
} break;
break; case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
case DRAW_TRIANGLESTRIP:
{
unsigned int index = start;
for(unsigned int i = 0; i < triangleCount; i++) for(unsigned int i = 0; i < triangleCount; i++)
{ {
batch[i][0] = index + 0; batch[i][0] = index + 0;
...@@ -888,12 +957,8 @@ namespace sw ...@@ -888,12 +957,8 @@ namespace sw
index += 1; index += 1;
} }
} break;
break; case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
case DRAW_TRIANGLEFAN:
{
unsigned int index = start;
for(unsigned int i = 0; i < triangleCount; i++) for(unsigned int i = 0; i < triangleCount; i++)
{ {
batch[i][0] = index + 1; batch[i][0] = index + 1;
...@@ -902,175 +967,33 @@ namespace sw ...@@ -902,175 +967,33 @@ namespace sw
index += 1; index += 1;
} }
break;
default:
ASSERT(false);
return;
} }
break; }
case DRAW_INDEXEDPOINTLIST16: else
{ {
const unsigned short *index = (const unsigned short*)indices + start; switch(draw->indexType)
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = *index;
batch[i][1] = *index;
batch[i][2] = *index;
index += 1;
}
}
break;
case DRAW_INDEXEDPOINTLIST32:
{
const unsigned int *index = (const unsigned int*)indices + start;
for(unsigned int i = 0; i < triangleCount; i++)
{
batch[i][0] = *index;
batch[i][1] = *index;
batch[i][2] = *index;
index += 1;
}
}
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;
}
}
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; case VK_INDEX_TYPE_UINT16:
if(!setBatchIndices(batch, topology, static_cast<const uint16_t*>(indices), start, triangleCount))
for(unsigned int i = 0; i < triangleCount; i++)
{ {
batch[i][0] = index[0]; return;
batch[i][1] = index[((start + i) & 1) + 1];
batch[i][2] = index[(~(start + i) & 1) + 1];
index += 1;
} }
} break;
break; case VK_INDEX_TYPE_UINT32:
case DRAW_INDEXEDTRIANGLESTRIP32: if(!setBatchIndices(batch, topology, static_cast<const uint32_t*>(indices), start, triangleCount))
{
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]; return;
batch[i][1] = index[start + i + 2];
batch[i][2] = index[0];
} }
} break;
break; break;
case DRAW_INDEXEDTRIANGLEFAN32: default:
{ ASSERT(false);
const unsigned int *index = (const unsigned int*)indices; return;
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; task->primitiveStart = start;
......
...@@ -225,7 +225,7 @@ namespace sw ...@@ -225,7 +225,7 @@ namespace sw
void *operator new(size_t size); void *operator new(size_t size);
void operator delete(void * mem); 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); void setContext(const sw::Context& context);
...@@ -359,7 +359,8 @@ namespace sw ...@@ -359,7 +359,8 @@ namespace sw
~DrawCall(); ~DrawCall();
AtomicInt drawType; AtomicInt topology;
AtomicInt indexType;
AtomicInt batchSize; AtomicInt batchSize;
Routine *vertexRoutine; Routine *vertexRoutine;
......
...@@ -97,16 +97,29 @@ namespace sw ...@@ -97,16 +97,29 @@ namespace sw
routineCache = new RoutineCache<State>(clamp(cacheSize, 1, 65536)); 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 state;
state.shaderID = context->vertexShader->getSerialID(); state.shaderID = context->vertexShader->getSerialID();
// Note: Quads aren't handled for verticesPerPrimitive, but verticesPerPrimitive is used for transform feedback, switch(topology)
// 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); case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
state.verticesPerPrimitive = 1 + (type >= DRAW_LINELIST) + (type >= DRAW_TRIANGLELIST); 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++) for(int i = 0; i < MAX_VERTEX_INPUTS; i++)
{ {
......
...@@ -92,7 +92,7 @@ namespace sw ...@@ -92,7 +92,7 @@ namespace sw
void setInstanceID(int instanceID); void setInstanceID(int instanceID);
protected: protected:
const State update(DrawType drawType); const State update(VkPrimitiveTopology topology);
Routine *routine(const State &state); Routine *routine(const State &state);
void setRoutineCacheSize(int cacheSize); void setRoutineCacheSize(int cacheSize);
......
...@@ -318,15 +318,11 @@ struct DrawBase : public CommandBuffer::Command ...@@ -318,15 +318,11 @@ struct DrawBase : public CommandBuffer::Command
} }
context.pushConstants = executionState.pushConstants; context.pushConstants = executionState.pushConstants;
auto drawType = context.drawType;
if (indexed) if (indexed)
{ {
context.indexBuffer = Cast(executionState.indexBufferBinding.buffer)->getOffsetPointer( context.indexBuffer = Cast(executionState.indexBufferBinding.buffer)->getOffsetPointer(
executionState.indexBufferBinding.offset + first * bytesPerIndex(executionState)); 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); executionState.renderer->setContext(context);
...@@ -340,7 +336,7 @@ struct DrawBase : public CommandBuffer::Command ...@@ -340,7 +336,7 @@ struct DrawBase : public CommandBuffer::Command
for(uint32_t instance = firstInstance; instance != firstInstance + instanceCount; instance++) for(uint32_t instance = firstInstance; instance != firstInstance + instanceCount; instance++)
{ {
executionState.renderer->setInstanceID(instance); executionState.renderer->setInstanceID(instance);
executionState.renderer->draw(drawType, primitiveCount); executionState.renderer->draw(context.topology, executionState.indexType, primitiveCount);
executionState.renderer->advanceInstanceAttributes(); executionState.renderer->advanceInstanceAttributes();
} }
} }
......
...@@ -25,40 +25,6 @@ ...@@ -25,40 +25,6 @@
namespace 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) sw::StreamType getStreamType(VkFormat format)
{ {
switch(format) switch(format)
...@@ -311,7 +277,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -311,7 +277,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
UNIMPLEMENTED("pCreateInfo->pInputAssemblyState settings"); UNIMPLEMENTED("pCreateInfo->pInputAssemblyState settings");
} }
context.drawType = Convert(assemblyState->topology); context.topology = assemblyState->topology;
const VkPipelineViewportStateCreateInfo* viewportState = pCreateInfo->pViewportState; const VkPipelineViewportStateCreateInfo* viewportState = pCreateInfo->pViewportState;
if(viewportState) if(viewportState)
...@@ -473,22 +439,22 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks* pAllocator, c ...@@ -473,22 +439,22 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks* pAllocator, c
uint32_t GraphicsPipeline::computePrimitiveCount(uint32_t vertexCount) const 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; return vertexCount;
case sw::DRAW_LINELIST: case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
return vertexCount / 2; return vertexCount / 2;
case sw::DRAW_LINESTRIP: case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
return vertexCount - 1; return vertexCount - 1;
case sw::DRAW_TRIANGLELIST: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
return vertexCount / 3; return vertexCount / 3;
case sw::DRAW_TRIANGLESTRIP: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
return vertexCount - 2; return vertexCount - 2;
case sw::DRAW_TRIANGLEFAN: case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
return vertexCount - 2; return vertexCount - 2;
default: default:
UNIMPLEMENTED("drawType"); UNIMPLEMENTED("context.topology %d", int(context.topology));
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment