public void CmdBindIndexBuffer(IMgBuffer buffer, UInt64 offset, MgIndexType indexType) { var bBuffer = (VkBuffer)buffer; Debug.Assert(bBuffer != null); Interops.vkCmdBindIndexBuffer(this.Handle, bBuffer.Handle, offset, (VkIndexType)indexType); }
static All GetIndexBufferType(MgIndexType indexType) { switch (indexType) { case MgIndexType.UINT16: return(All.UnsignedShort); case MgIndexType.UINT32: return(All.UnsignedInt); default: throw new NotSupportedException(); } }
static DrawElementsType GetElementType(MgIndexType indexType) { switch (indexType) { case MgIndexType.UINT16: return(DrawElementsType.UnsignedShort); case MgIndexType.UINT32: return(DrawElementsType.UnsignedInt); default: throw new NotSupportedException(); } }
public void DrawIndexedIndirect(MgPrimitiveTopology topology, MgIndexType indexType, IntPtr indirect, uint count, uint stride) { // typedef struct VkDrawIndexedIndirectCommand { // uint32_t indexCount; // uint32_t instanceCount; // uint32_t firstIndex; // int32_t vertexOffset; // uint32_t firstInstance; // } VkDrawIndexedIndirectCommand; // void glMultiDrawElementsIndirect(GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); // indirect => buffer + offset (IntPtr) // drawcount => drawcount // stride => stride // glDrawElementsInstancedBaseVertexBaseInstance(mode, // cmd->count, // type, // cmd->firstIndex * size-of-type, // cmd->instanceCount, // cmd->baseVertex, // cmd->baseInstance); // typedef struct { // uint count; // uint instanceCount; // uint firstIndex; // uint baseVertex; // TODO: negetive index // uint baseInstance; // } DrawElementsIndirectCommand; //mDrawCommands.Add (mIncompleteDrawCommand); if (count >= (uint)int.MaxValue) { throw new ArgumentOutOfRangeException("count", "count >= int.MaxValue"); } if (stride >= (uint)int.MaxValue) { throw new ArgumentOutOfRangeException("stride", "stride >= int.MaxValue"); } GL.MultiDrawElementsIndirect((PrimitiveType)GetPrimitiveType(topology), (DrawElementsType)GetIndexBufferType(indexType), indirect, (int)count, (int)stride); }
public void DrawIndexed(MgPrimitiveTopology topology, MgIndexType indexType, uint first, uint count, uint instanceCount, int vertexOffset) { // void glDrawElementsInstancedBaseVertex(GLenum mode, GLsizei count, GLenum type, GLvoid *indices, GLsizei primcount, GLint basevertex); // count => indexCount Specifies the number of elements to be rendered. (divide by elements) // indices => firstIndex Specifies a byte offset (cast to a pointer type) (multiple by data size) // primcount => instanceCount Specifies the number of instances of the indexed geometry that should be drawn. // basevertex => vertexOffset Specifies a constant that should be added to each element of indices when chosing elements from the enabled vertex arrays. // TODO : need to handle negetive offset //mDrawCommands.Add (mIncompleteDrawCommand); if (count >= (uint)int.MaxValue) { throw new ArgumentOutOfRangeException("count", "count >= int.MaxValue"); } if (instanceCount >= (uint)int.MaxValue) { throw new ArgumentOutOfRangeException("instanceCount", "instanceCount >= int.MaxValue"); } GL.DrawElementsInstancedBaseVertex(GetPrimitiveType(topology), (int)count, GetElementType(indexType), GetByteOffset(first, indexType), (int)instanceCount, vertexOffset); }
public void DrawIndexedIndirect(MgPrimitiveTopology topology, MgIndexType indexType, IntPtr indirect, uint count, uint stride) { }
public void DrawIndexed(MgPrimitiveTopology topology, MgIndexType indexType, uint first, uint count, uint instanceCount, int vertexOffset) { }
public void CmdBindIndexBuffer(IMgBuffer buffer, ulong offset, MgIndexType indexType) { throw new NotImplementedException(); }
public void CmdBindIndexBuffer(IMgBuffer buffer, ulong offset, MgIndexType indexType) { mCommandEncoder.Graphics.BindIndexBuffer(buffer, offset, indexType); }
static IntPtr GetByteOffset(uint first, MgIndexType indexType) { int elementSize = (indexType == MgIndexType.UINT32) ? 4 : 2; return(new IntPtr(first * elementSize)); }