Jump to content

  • Log In with Google      Sign In   
  • Create Account


BMW

Member Since 02 Mar 2013
Offline Last Active Apr 20 2014 02:39 PM

#5121560 [SOLVED]Strange problem with HAL device

Posted by BMW on 05 January 2014 - 11:47 PM

I'd have a look at the device capabilities using IDirect3D9::GetDeviceCaps or the caps viewer tool from the SDK and check if you're not hitting a limit somewhere. In particular, since you're using 32-bit indices, check if MaxVertexIndex is greater than 0xFFFF.

Thank you.

 

MaxVertexIndex was 0xFFFE.

 

Problem Solved.




#5077287 D3D9 CreateDevice crash with D3DCREATE_HARDWARE_VERTEXPROCESSING

Posted by BMW on 13 July 2013 - 02:03 AM

If you are getting a stack overflow, increase the size of the stack.




#5076538 Calling DrawPrimitive Heaps

Posted by BMW on 10 July 2013 - 12:44 AM

You might be much happier doing a DIP call for each block type, so you don't have to mess up to much with shader parameters.

Doing a whole chunk per-DIP is excessive in my opinion and the issues involved in managing the multiple textures have to be carefully considered.

 

edit: oh, I see you're using a texture atlas from the other thread. No problem then, go ahead!

 

WOW WOWOWOWOWOWOWOWOWOWOWOW

 

Using the inferior method as discussed earlier (heaps of draw primitive calls) = 62FPS.

 

Using new method - 1 DIP call per chunk = 320FPS. THATS IT, THREE HUNDRED AND TWENTY FRAMES PER SECOND. (Considering my laptop has integrated graphics, NOT TOO FOUL!!!!)

 

THIS IS THE BEST DAY OF MY LIFE.

 

THANK YOU EVERYONE.

 

I love game development.

 

EDIT: Is updating the entire index buffer for the chunk every time a block changes a good idea? It seems to run ok.

 

This is how I update index buffer:

void Chunk::UpdateIndices()
{
	void* IB = NULL;

	unsigned int* pIBEntry = NULL;

	PrimitiveCount = 0;

	if(g_pIB->Lock(0, BLOCKS_PER_CHUNK * INDICES_PER_BLOCK * 4, &IB, D3DLOCK_DISCARD) != D3D_OK)
		return;

	pIBEntry = (unsigned int*)IB;

	for(unsigned int i = 0; i < BLOCKS_PER_CHUNK; i++)
	{
		if(blocks[i].type == BLOCKTYPE_AIR)
			continue;

		if(blocks[i].FrontFaceVisible)
		{
			*pIBEntry = i * VERTICES_PER_BLOCK;
			*(pIBEntry + 1) = i * VERTICES_PER_BLOCK + 1;
			*(pIBEntry + 2) = i * VERTICES_PER_BLOCK + 2;
			*(pIBEntry + 3) = i * VERTICES_PER_BLOCK + 1;
			*(pIBEntry + 4) = i * VERTICES_PER_BLOCK + 3;
			*(pIBEntry + 5) = i * VERTICES_PER_BLOCK + 2;
			pIBEntry += 6;
			PrimitiveCount += 2;
		}
		if(blocks[i].BackFaceVisible)
		{
			*pIBEntry = i * VERTICES_PER_BLOCK + 4;
			*(pIBEntry + 1) = i * VERTICES_PER_BLOCK + 4 + 1;
			*(pIBEntry + 2) = i * VERTICES_PER_BLOCK + 4 + 2;
			*(pIBEntry + 3) = i * VERTICES_PER_BLOCK + 4 + 1;
			*(pIBEntry + 4) = i * VERTICES_PER_BLOCK + 4 + 3;
			*(pIBEntry + 5) = i * VERTICES_PER_BLOCK + 4 + 2;
			pIBEntry += 6;
			PrimitiveCount += 2;
		}
		if(blocks[i].LeftFaceVisible)
		{
			*pIBEntry = i * VERTICES_PER_BLOCK + 8;
			*(pIBEntry + 1) = i * VERTICES_PER_BLOCK + 8 + 1;
			*(pIBEntry + 2) = i * VERTICES_PER_BLOCK + 8 + 2;
			*(pIBEntry + 3) = i * VERTICES_PER_BLOCK + 8 + 1;
			*(pIBEntry + 4) = i * VERTICES_PER_BLOCK + 8 + 3;
			*(pIBEntry + 5) = i * VERTICES_PER_BLOCK + 8 + 2;
			pIBEntry += 6;
			PrimitiveCount += 2;
		}
		if(blocks[i].RightFaceVisible)
		{
			*pIBEntry = i * VERTICES_PER_BLOCK + 12;
			*(pIBEntry + 1) = i * VERTICES_PER_BLOCK + 12 + 1;
			*(pIBEntry + 2) = i * VERTICES_PER_BLOCK + 12 + 2;
			*(pIBEntry + 3) = i * VERTICES_PER_BLOCK + 12 + 1;
			*(pIBEntry + 4) = i * VERTICES_PER_BLOCK + 12 + 3;
			*(pIBEntry + 5) = i * VERTICES_PER_BLOCK + 12 + 2;
			pIBEntry += 6;
			PrimitiveCount += 2;
		}
		if(blocks[i].TopFaceVisible)
		{
			*pIBEntry = i * VERTICES_PER_BLOCK + 16;
			*(pIBEntry + 1) = i * VERTICES_PER_BLOCK + 16 + 1;
			*(pIBEntry + 2) = i * VERTICES_PER_BLOCK + 16 + 2;
			*(pIBEntry + 3) = i * VERTICES_PER_BLOCK + 16 + 1;
			*(pIBEntry + 4) = i * VERTICES_PER_BLOCK + 16 + 3;
			*(pIBEntry + 5) = i * VERTICES_PER_BLOCK + 16 + 2;
			pIBEntry += 6;
			PrimitiveCount += 2;
		}
		if(blocks[i].BottomFaceVisible)
		{
			*pIBEntry = i * VERTICES_PER_BLOCK + 20;
			*(pIBEntry + 1) = i * VERTICES_PER_BLOCK + 20 + 1;
			*(pIBEntry + 2) = i * VERTICES_PER_BLOCK + 20 + 2;
			*(pIBEntry + 3) = i * VERTICES_PER_BLOCK + 20 + 1;
			*(pIBEntry + 4) = i * VERTICES_PER_BLOCK + 20 + 3;
			*(pIBEntry + 5) = i * VERTICES_PER_BLOCK + 20 + 2;
			pIBEntry += 6;
			PrimitiveCount += 2;
		}
	}

	g_pIB->Unlock();
}



PARTNERS