void FTesselatedScreenRectangleIndexBuffer::InitRHI()
{
	TResourceArray<uint16, INDEXBUFFER_ALIGNMENT> IndexBuffer;

	uint32 NumIndices = NumPrimitives() * 3;
	IndexBuffer.AddUninitialized(NumIndices);
		
	uint16* Out = (uint16*)IndexBuffer.GetData();

	for(uint32 y = 0; y < Height; ++y)
	{
		for(uint32 x = 0; x < Width; ++x)
		{
			// left top to bottom right in reading order
			uint16 Index00 = x  + y * (Width + 1);
			uint16 Index10 = Index00 + 1;
			uint16 Index01 = Index00 + (Width + 1);
			uint16 Index11 = Index01 + 1;

			// todo: diagonal can be flipped on parts of the screen

			// triangle A
			*Out++ = Index00; *Out++ = Index01; *Out++ = Index10;

			// triangle B
			*Out++ = Index11; *Out++ = Index10; *Out++ = Index01;
		}
	}

	// Create index buffer. Fill buffer with initial data upon creation
	FRHIResourceCreateInfo CreateInfo(&IndexBuffer);
	IndexBufferRHI = RHICreateIndexBuffer(sizeof(uint16), IndexBuffer.GetResourceDataSize(), BUF_Static, CreateInfo);
}
	/** Initialize the RHI for this rendering resource */
	void InitRHI() override
	{
		TResourceArray<FFilterVertex, VERTEXBUFFER_ALIGNMENT> Vertices;
		Vertices.SetNumUninitialized(6);

		Vertices[0].Position = FVector4(1,  1,	0,	1);
		Vertices[0].UV = FVector2D(1,	1);

		Vertices[1].Position = FVector4(0,  1,	0,	1);
		Vertices[1].UV = FVector2D(0,	1);

		Vertices[2].Position = FVector4(1,	0,	0,	1);
		Vertices[2].UV = FVector2D(1,	0);

		Vertices[3].Position = FVector4(0,	0,	0,	1);
		Vertices[3].UV = FVector2D(0,	0);

		//The final two vertices are used for the triangle optimization (a single triangle spans the entire viewport )
		Vertices[4].Position = FVector4(-1,  1,	0,	1);
		Vertices[4].UV = FVector2D(-1,	1);

		Vertices[5].Position = FVector4(1,  -1,	0,	1);
		Vertices[5].UV = FVector2D(1, -1);

		// Create vertex buffer. Fill buffer with initial data upon creation
		FRHIResourceCreateInfo CreateInfo(&Vertices);
		VertexBufferRHI = RHICreateVertexBuffer(Vertices.GetResourceDataSize(), BUF_Static, CreateInfo);
	}
	/**
	* Initialize the RHI for this rendering resource
	*/
	void InitRHI() override
	{
		const int32 NumVerts = 8;
		TResourceArray<FVector4, VERTEXBUFFER_ALIGNMENT> Verts;
		Verts.SetNumUninitialized(NumVerts);

		for (uint32 Z = 0; Z < 2; Z++)
		{
			for (uint32 Y = 0; Y < 2; Y++)
			{
				for (uint32 X = 0; X < 2; X++)
				{
					const FVector4 Vertex = FVector4(
					  (X ? -1 : 1),
					  (Y ? -1 : 1),
					  (Z ? -1 : 1),
					  1.0f
					);

					Verts[GetCubeVertexIndex(X, Y, Z)] = Vertex;
				}
			}
		}

		uint32 Size = Verts.GetResourceDataSize();

		// Create vertex buffer. Fill buffer with initial data upon creation
		FRHIResourceCreateInfo CreateInfo(&Verts);
		VertexBufferRHI = RHICreateVertexBuffer(Size, BUF_Static, CreateInfo);
	}
		/** Initialize the RHI for this rendering resource */
		void InitRHI() override
		{
			// Indices 0 - 5 are used for rendering a quad. Indices 6 - 8 are used for triangle optimization. 
			const uint16 Indices[] = { 0, 1, 2, 2, 1, 3, 0, 4, 5 };
		
			TResourceArray<uint16, INDEXBUFFER_ALIGNMENT> IndexBuffer;
			uint32 InternalNumIndices = ARRAY_COUNT(Indices);
			IndexBuffer.AddUninitialized(InternalNumIndices);
			FMemory::Memcpy(IndexBuffer.GetData(), Indices, InternalNumIndices * sizeof(uint16));

			// Create index buffer. Fill buffer with initial data upon creation
			FRHIResourceCreateInfo CreateInfo(&IndexBuffer);
			IndexBufferRHI = RHICreateIndexBuffer(sizeof(uint16), IndexBuffer.GetResourceDataSize(), BUF_Static, CreateInfo);
		}
	/**
	* Initialize the RHI for this rendering resource
	*/
	void InitRHI() override
	{
		TResourceArray<uint16, INDEXBUFFER_ALIGNMENT> Indices;
		
		NumIndices = ARRAY_COUNT(GCubeIndices);
		Indices.AddUninitialized(NumIndices);
		FMemory::Memcpy(Indices.GetData(), GCubeIndices, NumIndices * sizeof(uint16));

		const uint32 Size = Indices.GetResourceDataSize();
		const uint32 Stride = sizeof(uint16);

		// Create index buffer. Fill buffer with initial data upon creation
		FRHIResourceCreateInfo CreateInfo(&Indices);
		IndexBufferRHI = RHICreateIndexBuffer(Stride, Size, BUF_Static, CreateInfo);
	}