コード例 #1
0
bool CIndexBuffer::Cache(CDisplayDevice *poDisplayDevice) {
#if RENDER == DX9
	IDirect3DIndexBuffer9* IB;

	int len = sizeof(unsigned short) * m_iNumIndices; 
	HRESULT result = poDisplayDevice->m_pDevice->CreateIndexBuffer(
		len, 
		D3DUSAGE_WRITEONLY,
		D3DFMT_INDEX16, 
		D3DPOOL_SYSTEMMEM,
		&IB, 
		0);

	if (result != D3D_OK)
		return false;

	char *buffer;
	IB->Lock(0, 0, (void **)&buffer, 0);
	memcpy(buffer, GetIndexBuffer(), len);
	IB->Unlock();

	m_pCachedData = IB;
#endif

	return true;
}
コード例 #2
0
ファイル: SubMesh.cpp プロジェクト: Moumou38/NazaraEngine
unsigned int NzSubMesh::GetTriangleCount() const
{
	const NzIndexBuffer* indexBuffer = GetIndexBuffer();
	unsigned int indexCount;
	if (indexBuffer)
		indexCount = indexBuffer->GetIndexCount();
	else
		indexCount = GetVertexCount();

	switch (m_primitiveMode)
	{
		case nzPrimitiveMode_LineList:
		case nzPrimitiveMode_LineStrip:
		case nzPrimitiveMode_PointList:
			return 0;

		case nzPrimitiveMode_TriangleFan:
			return (indexCount - 1) / 2;

		case nzPrimitiveMode_TriangleList:
			return indexCount / 3;

		case nzPrimitiveMode_TriangleStrip:
			return indexCount - 2;
	}

	NazaraError("Primitive mode not handled (0x" + NzString::Number(m_primitiveMode, 16) + ')');
	return 0;
}
コード例 #3
0
ファイル: GrAARectRenderer.cpp プロジェクト: Jichao/skia
    void generateGeometry(GrBatchTarget* batchTarget, const GrPipeline* pipeline) override {
        bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage();

        // Local matrix is ignored if we don't have local coords.  If we have localcoords we only
        // batch with identical view matrices
        SkMatrix localMatrix;
        if (this->usesLocalCoords() && !this->viewMatrix().invert(&localMatrix)) {
            SkDebugf("Cannot invert\n");
            return;
        }

        SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_rect_gp(canTweakAlphaForCoverage,
                                                                       localMatrix,
                                                                       this->usesLocalCoords(),
                                                                       this->coverageIgnored()));

        batchTarget->initDraw(gp, pipeline);

        size_t vertexStride = gp->getVertexStride();

        SkASSERT(canTweakAlphaForCoverage ?
                 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAttr) :
                 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCoverageAttr));
        int innerVertexNum = 4;
        int outerVertexNum = this->miterStroke() ? 4 : 8;
        int verticesPerInstance = (outerVertexNum + innerVertexNum) * 2;
        int indicesPerInstance = this->miterStroke() ? kMiterIndexCnt : kBevelIndexCnt;
        int instanceCount = fGeoData.count();

        const SkAutoTUnref<const GrIndexBuffer> indexBuffer(
            GetIndexBuffer(batchTarget->resourceProvider(), this->miterStroke()));
        InstancedHelper helper;
        void* vertices = helper.init(batchTarget, kTriangles_GrPrimitiveType, vertexStride,
                                     indexBuffer, verticesPerInstance,  indicesPerInstance,
                                     instanceCount);
        if (!vertices || !indexBuffer) {
             SkDebugf("Could not allocate vertices\n");
             return;
         }

        for (int i = 0; i < instanceCount; i++) {
            const Geometry& args = fGeoData[i];
            this->generateAAStrokeRectGeometry(vertices,
                                               i * verticesPerInstance * vertexStride,
                                               vertexStride,
                                               outerVertexNum,
                                               innerVertexNum,
                                               args.fColor,
                                               args.fDevOutside,
                                               args.fDevOutsideAssist,
                                               args.fDevInside,
                                               args.fMiterStroke,
                                               canTweakAlphaForCoverage);
        }
        helper.issueDraw(batchTarget);
    }
コード例 #4
0
void VertexArrayBuffer::RenderRange(IndicesRange const & range)
{
  if (!(m_staticBuffers.empty() && m_dynamicBuffers.empty()) && GetIndexCount() > 0)
  {
    ASSERT(m_program != nullptr, ("Somebody not call Build. It's very bad. Very very bad"));
    /// if OES_vertex_array_object is supported than all bindings already saved in VAO
    /// and we need only bind VAO. In Bind method have ASSERT("bind already called")
    if (GLExtensionsList::Instance().IsSupported(GLExtensionsList::VertexArrayObject))
      Bind();
    else
      BindStaticBuffers();

    BindDynamicBuffers();
    GetIndexBuffer()->Bind();
    GLFunctions::glDrawElements(dp::IndexStorage::SizeOfIndex(), range.m_idxCount, range.m_idxStart);
  }
}
コード例 #5
0
ファイル: VertexManager.cpp プロジェクト: Chiri23/dolphin
void VertexManager::PrepareDrawBuffers()
{
	D3D11_MAPPED_SUBRESOURCE map;

	UINT vSize = UINT(s_pCurBufferPointer - s_pBaseBufferPointer);
	D3D11_MAP MapType = D3D11_MAP_WRITE_NO_OVERWRITE;
	if (m_vertex_buffer_cursor + vSize >= VBUFFER_SIZE)
	{
		// Wrap around
		m_current_vertex_buffer = (m_current_vertex_buffer + 1) % MAX_VBUFFER_COUNT;
		m_vertex_buffer_cursor = 0;
		MapType = D3D11_MAP_WRITE_DISCARD;
	}

	D3D::context->Map(m_vertex_buffers[m_current_vertex_buffer], 0, MapType, 0, &map);

	memcpy((u8*)map.pData + m_vertex_buffer_cursor, s_pBaseBufferPointer, vSize);
	D3D::context->Unmap(m_vertex_buffers[m_current_vertex_buffer], 0);
	m_vertex_draw_offset = m_vertex_buffer_cursor;
	m_vertex_buffer_cursor += vSize;

	UINT iCount = IndexGenerator::GetIndexLen();
	MapType = D3D11_MAP_WRITE_NO_OVERWRITE;
	if (m_index_buffer_cursor + iCount >= (IBUFFER_SIZE / sizeof(u16)))
	{
		// Wrap around
		m_current_index_buffer = (m_current_index_buffer + 1) % MAX_VBUFFER_COUNT;
		m_index_buffer_cursor = 0;
		MapType = D3D11_MAP_WRITE_DISCARD;
	}
	D3D::context->Map(m_index_buffers[m_current_index_buffer], 0, MapType, 0, &map);

	memcpy((u16*)map.pData + m_index_buffer_cursor, GetIndexBuffer(), sizeof(u16) * IndexGenerator::GetIndexLen());
	D3D::context->Unmap(m_index_buffers[m_current_index_buffer], 0);
	m_index_draw_offset = m_index_buffer_cursor;
	m_index_buffer_cursor += iCount;

	ADDSTAT(stats.thisFrame.bytesVertexStreamed, vSize);
	ADDSTAT(stats.thisFrame.bytesIndexStreamed, iCount*sizeof(u16));
}
コード例 #6
0
ファイル: VertexManager.cpp プロジェクト: 70michal19/dolphin
void VertexManager::PrepareDrawBuffers(u32 stride)
{
	D3D11_MAPPED_SUBRESOURCE map;

	u32 vertexBufferSize = u32(s_pCurBufferPointer - s_pBaseBufferPointer);
	u32 indexBufferSize = IndexGenerator::GetIndexLen() * sizeof(u16);
	u32 totalBufferSize = vertexBufferSize + indexBufferSize;

	u32 cursor = m_bufferCursor;
	u32 padding = m_bufferCursor % stride;
	if (padding)
	{
		cursor += stride - padding;
	}

	D3D11_MAP MapType = D3D11_MAP_WRITE_NO_OVERWRITE;
	if (cursor + totalBufferSize >= MAX_BUFFER_SIZE)
	{
		// Wrap around
		m_currentBuffer = (m_currentBuffer + 1) % MAX_BUFFER_COUNT;
		cursor = 0;
		MapType = D3D11_MAP_WRITE_DISCARD;
	}

	m_vertexDrawOffset = cursor;
	m_indexDrawOffset = cursor + vertexBufferSize;

	D3D::context->Map(m_buffers[m_currentBuffer], 0, MapType, 0, &map);
	u8* mappedData = reinterpret_cast<u8*>(map.pData);
	memcpy(mappedData + m_vertexDrawOffset, s_pBaseBufferPointer, vertexBufferSize);
	memcpy(mappedData + m_indexDrawOffset, GetIndexBuffer(), indexBufferSize);
	D3D::context->Unmap(m_buffers[m_currentBuffer], 0);

	m_bufferCursor = cursor + totalBufferSize;

	ADDSTAT(stats.thisFrame.bytesVertexStreamed, vertexBufferSize);
	ADDSTAT(stats.thisFrame.bytesIndexStreamed, indexBufferSize);
}
コード例 #7
0
ファイル: Character.cpp プロジェクト: WiZFramework/DxBase2015
	void CustomDrawBox::Draw(){
		//デバイスの取得
		auto Dev = App::GetApp()->GetDeviceResources();
		auto pDx11Device = Dev->GetD3DDevice();
		auto pID3D11DeviceContext = Dev->GetD3DDeviceContext();
		//ステータスのポインタ
		auto RenderStatePtr = GetStage()->GetRenderState();

		auto PtrT = GetComponent<Transform>();
		//ステージからカメラを取り出す
		auto PtrCamera = GetStage()->GetTargetCamera();
		//カメラの取得
		Matrix4X4 View, Proj, WorldViewProj;
		View = PtrCamera->GetViewMatrix();
		Proj = PtrCamera->GetProjMatrix();


		//ストライドとオフセット
		UINT stride = sizeof(VertexPositionNormalTexture);
		UINT offset = 0;
		//頂点バッファの設定
		auto PtrMeshResource = App::GetApp()->GetResource<MeshResource>(L"DEFAULT_CUBE");
		pID3D11DeviceContext->IASetVertexBuffers(0, 1, PtrMeshResource->GetVertexBuffer().GetAddressOf(), &stride, &offset);
		//インデックスバッファのセット
		pID3D11DeviceContext->IASetIndexBuffer(PtrMeshResource->GetIndexBuffer().Get(), DXGI_FORMAT_R16_UINT, 0);
		//描画方法(3角形)
		pID3D11DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
		//ステータスのポインタ
		//テクスチャを取得
		ID3D11ShaderResourceView* pNull[1] = { 0 };
		ID3D11SamplerState* pNullSR[1] = { 0 };
		//テクスチャを設定
		auto PtrTextureResource = App::GetApp()->GetResource<TextureResource>(L"TRACE_TX");
		pID3D11DeviceContext->PSSetShaderResources(0, 1, PtrTextureResource->GetShaderResourceView().GetAddressOf());
		//リニアサンプラーを設定
		ID3D11SamplerState* samplerState = RenderStatePtr->GetLinearClamp();
		pID3D11DeviceContext->PSSetSamplers(0, 1, &samplerState);
		//半透明処理
		pID3D11DeviceContext->OMSetBlendState(RenderStatePtr->GetAlphaBlendEx(), nullptr, 0xffffffff);

		//デプスステンシルは使用する
		pID3D11DeviceContext->OMSetDepthStencilState(RenderStatePtr->GetDepthDefault(), 0);
		//シェーダの設定
		pID3D11DeviceContext->VSSetShader(m_VirtexShader->GetShader(), nullptr, 0);
		pID3D11DeviceContext->PSSetShader(m_PixelShader->GetShader(), nullptr, 0);
		//インプットレイアウトの設定
		pID3D11DeviceContext->IASetInputLayout(m_VirtexShader->GetInputLayout());



		//コンスタントバッファの設定
		ConstantBuffer cb1;
		ZeroMemory(&cb1, sizeof(cb1));
		//行列の設定(転置する)
		cb1.World = Matrix4X4EX::Transpose(PtrT->GetWorldMatrix());;
		cb1.View = Matrix4X4EX::Transpose(View);
		cb1.Projection = Matrix4X4EX::Transpose(Proj);
		//ライトの設定
		//ステージから0番目のライトを取り出す
		auto PtrLight = GetStage()->GetTargetLight(0);
		cb1.LightDir = PtrLight->GetDirectional();
		//xとzだけ逆にする
		cb1.LightDir.x *= -1.0f;
		cb1.LightDir.z *= -1.0f;
		cb1.LightDir.w = 1.0f;
		//トータルタイムをコンスタントバッファに渡す
		float ElapsedTime = App::GetApp()->GetElapsedTime();
		m_TotalTime += ElapsedTime;
		if (m_TotalTime >= 1.0f){
			m_TotalTime = 0.0f;
		}
		cb1.Param.x = m_TotalTime;
		//コンスタントバッファの更新
		pID3D11DeviceContext->UpdateSubresource(m_ConstantBuffer->GetBuffer(), 0, nullptr, &cb1, 0, 0);
		//コンスタントバッファの設定
		ID3D11Buffer* pConstantBuffer = m_ConstantBuffer->GetBuffer();
		pID3D11DeviceContext->VSSetConstantBuffers(0, 1, &pConstantBuffer);
		pID3D11DeviceContext->PSSetConstantBuffers(0, 1, &pConstantBuffer);

		//レンダリングステート
		pID3D11DeviceContext->RSSetState(RenderStatePtr->GetCullFront());
		//内側描画
		pID3D11DeviceContext->DrawIndexed(PtrMeshResource->GetNumIndicis(), 0, 0);

		//ライトの向きを変える
		cb1.LightDir = PtrLight->GetDirectional();
		cb1.LightDir.w = 1.0f;

		//コンスタントバッファの更新
		pID3D11DeviceContext->UpdateSubresource(m_ConstantBuffer->GetBuffer(), 0, nullptr, &cb1, 0, 0);
		//コンスタントバッファの設定
		pConstantBuffer = m_ConstantBuffer->GetBuffer();
		pID3D11DeviceContext->VSSetConstantBuffers(0, 1, &pConstantBuffer);
		pID3D11DeviceContext->PSSetConstantBuffers(0, 1, &pConstantBuffer);

		//レンダリングステート
		pID3D11DeviceContext->RSSetState(RenderStatePtr->GetCullBack());
		//描画(外側)
		pID3D11DeviceContext->DrawIndexed(PtrMeshResource->GetNumIndicis(), 0, 0);
		//後始末
		Dev->InitializeStates(RenderStatePtr);


	}
コード例 #8
0
void VertexArrayBuffer::Render()
{
  RenderRange(IndicesRange(0, GetIndexBuffer()->GetCurrentSize()));
}
コード例 #9
0
uint32_t VertexArrayBuffer::GetIndexCount() const
{
  return GetIndexBuffer()->GetCurrentSize();
}
コード例 #10
0
uint32_t VertexArrayBuffer::GetAvailableIndexCount() const
{
  return GetIndexBuffer()->GetAvailableSize();
}
コード例 #11
0
  return m_staticBuffers.begin()->second->GetBuffer()->GetCurrentSize();
}

uint32_t VertexArrayBuffer::GetDynamicBufferOffset(BindingInfo const & bindingInfo)
{
  return GetOrCreateDynamicBuffer(bindingInfo)->GetBuffer()->GetCurrentSize();
}

uint32_t VertexArrayBuffer::GetIndexCount() const
{
  return GetIndexBuffer()->GetCurrentSize();
}

void VertexArrayBuffer::UploadIndexes(void const * data, uint32_t count)
{
  ASSERT(count <= GetIndexBuffer()->GetAvailableSize(), ());
  GetIndexBuffer()->UploadData(data, count);
}

void VertexArrayBuffer::ApplyMutation(ref_ptr<IndexBufferMutator> indexMutator,
                                      ref_ptr<AttributeBufferMutator> attrMutator)
{
  if (indexMutator != nullptr)
  {
    ASSERT(m_indexBuffer != nullptr, ());
    if (indexMutator->GetCapacity() > m_indexBuffer->GetBuffer()->GetCapacity())
    {
      m_indexBuffer = make_unique_dp<IndexBuffer>(indexMutator->GetCapacity());
      m_indexBuffer->MoveToGPU(GPUBuffer::IndexBuffer);
    }
    m_indexBuffer->UpdateData(indexMutator->GetIndexes(), indexMutator->GetIndexCount());
コード例 #12
0
void VertexManager::ResetBuffer(u32 stride)
{
	s_pCurBufferPointer = s_pBaseBufferPointer;
	IndexGenerator::Start(GetIndexBuffer());
}
コード例 #13
0
void VertexManager::PrepareDrawBuffers(u32 stride)
{
	u8* p_vertices_base;
	u8* p_vertices;
	u16* p_indices;
	u16* indices = GetIndexBuffer();
	u32 total_data_size = m_total_num_verts * stride;
	u32 data_size = m_num_verts * stride;
	u16 current_index = m_num_verts;
	if (m_index_len)
	{
		DWORD LockMode = D3DLOCK_NOOVERWRITE;
		m_vertex_buffer_cursor--;
		m_vertex_buffer_cursor = m_vertex_buffer_cursor - (m_vertex_buffer_cursor % stride) + stride;
		if (m_vertex_buffer_cursor > m_vertex_buffer_size - total_data_size)
		{
			LockMode = D3DLOCK_DISCARD;
			m_vertex_buffer_cursor = 0;
			m_current_vertex_buffer = (m_current_vertex_buffer + 1) % m_buffers_count;
		}
		if (FAILED(m_vertex_buffers[m_current_vertex_buffer]->Lock(m_vertex_buffer_cursor, total_data_size, (VOID**)(&p_vertices_base), LockMode)))
		{
			DestroyDeviceObjects();
			return;
		}
		LockMode = D3DLOCK_NOOVERWRITE;
		if (m_index_buffer_cursor > m_index_buffer_size - m_total_index_len)
		{
			LockMode = D3DLOCK_DISCARD;
			m_index_buffer_cursor = 0;
			m_current_index_buffer = (m_current_index_buffer + 1) % m_buffers_count;
		}
		if (FAILED(m_index_buffers[m_current_index_buffer]->Lock(m_index_buffer_cursor * sizeof(u16), m_total_index_len * sizeof(u16), (VOID**)(&p_indices), LockMode)))
		{
			DestroyDeviceObjects();
			return;
		}
		memcpy(p_vertices_base, s_pBaseBufferPointer, data_size);
		p_vertices = p_vertices_base + data_size;
		if (current_primitive_type == PRIMITIVE_TRIANGLES)
		{
			memcpy(p_indices, indices, m_index_len * sizeof(u16));
		}
		else if (current_primitive_type == PRIMITIVE_LINES)
		{
			for (u32 i = 0; i < (m_index_len - 1); i += 2)
			{
				// Get Line Indices
				u16 first_index = indices[i];
				u16 second_index = indices[i + 1];
				// Get the position in the stream o f the first vertex
				u32 currentstride = first_index * stride;
				// Get The first vertex Position data
				Float_2* base_vertex_0 = (Float_2*)(s_pBaseBufferPointer + currentstride);
				// Get The blendindices data
				U8_4* blendindices_vertex_0 = (U8_4*)(p_vertices_base + currentstride + stride - sizeof(U8_4));
				// Get The first vertex Position data
				currentstride = second_index * stride;
				Float_2* base_vertex_1 = (Float_2*)(s_pBaseBufferPointer + currentstride);
				U8_4* blendindices_vertex_1 = (U8_4*)(p_vertices_base + currentstride + stride - sizeof(U8_4));

				// Calculate line orientation
				// mostly a hack because we are in object space but is better than nothing
				float dx = base_vertex_1->x - base_vertex_0->x;
				float dy = base_vertex_1->y - base_vertex_0->y;
				bool horizontal = fabs(dx) > fabs(dy);
				bool positive = horizontal ? dx > 0 : dy > 0;

				// setup offset index acording to line orientation
				u8 idx0 = horizontal ?
					(positive ? PLO_POS_LINE_NEGATIVE_Y : PLO_POS_LINE_POSITIVE_Y) :
					(positive ? PLO_POS_LINE_POSITIVE_X : PLO_POS_LINE_NEGATIVE_X);
				u8 idx1 = horizontal ?
					(positive ? PLO_POS_LINE_POSITIVE_Y : PLO_POS_LINE_NEGATIVE_Y) :
					(positive ? PLO_POS_LINE_NEGATIVE_X : PLO_POS_LINE_POSITIVE_X);


				memcpy(p_vertices, base_vertex_0, stride);
				p_vertices += stride;
				U8_4* blendindices_vertex_2 = (U8_4*)(p_vertices - sizeof(U8_4));
				memcpy(p_vertices, base_vertex_1, stride);
				p_vertices += stride;
				U8_4* blendindices_vertex_3 = (U8_4*)(p_vertices - sizeof(U8_4));

				// Setup Blend Indices
				blendindices_vertex_0->y = PLO_TEX_MASK_LINE_0_3;
				blendindices_vertex_0->z = idx0;
				blendindices_vertex_0->w = PLO_ZERO;

				blendindices_vertex_1->y = PLO_TEX_MASK_LINE_0_3;
				blendindices_vertex_1->z = idx0;
				blendindices_vertex_1->w = PLO_ZERO;

				blendindices_vertex_2->y = PLO_TEX_MASK_LINE_0_3;
				blendindices_vertex_2->z = idx1;
				blendindices_vertex_2->w = PLO_TEX_LINE;

				blendindices_vertex_3->y = PLO_TEX_MASK_LINE_0_3;
				blendindices_vertex_3->z = idx1;
				blendindices_vertex_3->w = PLO_TEX_LINE;


				// Setup new triangle indices
				*p_indices = first_index;
				p_indices++;

				*p_indices = current_index;
				current_index++;
				p_indices++;

				*p_indices = current_index;
				p_indices++;

				*p_indices = current_index;
				current_index++;
				p_indices++;

				*p_indices = second_index;
				p_indices++;

				*p_indices = first_index;
				p_indices++;
			}
		}
		else if (current_primitive_type == PRIMITIVE_POINTS)
		{
			for (u32 i = 0; i < m_index_len; i++)
			{
				// Get point indes
				u16 pointindex = indices[i];
				// Calculate stream Position
				int currentstride = pointindex * stride;
				// Get data Pointer for vertex replication
				u8* base_vertex = s_pBaseBufferPointer + currentstride;
				U8_4* blendindices_vertex_0 = (U8_4*)(p_vertices_base + currentstride + stride - sizeof(U8_4));

				// Generate Extra vertices
				memcpy(p_vertices, base_vertex, stride);
				p_vertices += stride;
				U8_4* blendindices_vertex_1 = (U8_4*)(p_vertices - sizeof(U8_4));
				memcpy(p_vertices, base_vertex, stride);
				p_vertices += stride;
				U8_4* blendindices_vertex_2 = (U8_4*)(p_vertices - sizeof(U8_4));
				memcpy(p_vertices, base_vertex, stride);
				p_vertices += stride;
				U8_4* blendindices_vertex_3 = (U8_4*)(p_vertices - sizeof(U8_4));

				// Setup Blen Indices
				blendindices_vertex_0->y = PLO_TEX_MASK_POINT_0_3;
				blendindices_vertex_0->z = PLO_POS_POINT_LEFT_TOP;
				blendindices_vertex_0->w = PLO_ZERO;

				blendindices_vertex_1->y = PLO_TEX_MASK_POINT_0_3;
				blendindices_vertex_1->z = PLO_POS_POINT_LEFT_BOTTOM;
				blendindices_vertex_1->w = PLO_TEX_POINT_X;

				blendindices_vertex_2->y = PLO_TEX_MASK_POINT_0_3;
				blendindices_vertex_2->z = PLO_POS_POINT_RIGHT_TOP;
				blendindices_vertex_2->w = PLO_TEX_POINT_Y;

				blendindices_vertex_3->y = PLO_TEX_MASK_POINT_0_3;
				blendindices_vertex_3->z = PLO_POS_POINT_RIGHT_BOTTOM;
				blendindices_vertex_3->w = PLO_TEX_POINT_XY;

				// Setup new triangle indices
				*p_indices = pointindex; // Left Top
				p_indices++;

				*p_indices = current_index; // Left Bottom
				current_index++;
				p_indices++;

				*p_indices = current_index; // Right Top
				p_indices++;

				*p_indices = current_index; // Right Top
				p_indices++;

				*p_indices = current_index - 1; // Left Bottom
				p_indices++;
				current_index++;
				*p_indices = current_index; // Right Bottom
				p_indices++;
				current_index++;
			}
		}
		m_vertex_buffers[m_current_vertex_buffer]->Unlock();
		m_index_buffers[m_current_index_buffer]->Unlock();
	}
	if (m_last_stride != stride || m_vertex_buffer_cursor == 0)
	{
		m_last_stride = stride;
		D3D::SetStreamSource(0, m_vertex_buffers[m_current_vertex_buffer], 0, m_last_stride);
	}
	if (m_index_buffer_cursor == 0)
	{
		D3D::SetIndices(m_index_buffers[m_current_index_buffer]);
	}

	ADDSTAT(stats.thisFrame.bytesVertexStreamed, total_data_size);
	ADDSTAT(stats.thisFrame.bytesIndexStreamed, m_total_index_len);
}