Ejemplo n.º 1
0
void FSlateElementIndexBuffer::FillBuffer( const TArray<SlateIndex>& InIndices, bool bShrinkToFit  )
{
	check( IsInRenderingThread() );

	if( InIndices.Num() )
	{
		uint32 NumIndices = InIndices.Num();

		uint32 RequiredBufferSize = NumIndices*sizeof(SlateIndex);

		// resize if needed
		if( RequiredBufferSize > GetBufferSize() || bShrinkToFit )
		{
			// Use array resize techniques for the vertex buffer
			ResizeBuffer( InIndices.GetAllocatedSize() );
		}

		BufferUsageSize += RequiredBufferSize;

		void* IndicesPtr = RHILockIndexBuffer( IndexBufferRHI, 0, RequiredBufferSize, RLM_WriteOnly );

		FMemory::Memcpy( IndicesPtr, InIndices.GetData(), RequiredBufferSize );

		RHIUnlockIndexBuffer(IndexBufferRHI);
	}
}
Ejemplo n.º 2
0
void FRawIndexBuffer16or32::InitRHI()
{
	uint32 Size = Indices.Num() * sizeof(uint32);
	if( Size > 0 )
	{
		// Create the index buffer.
		FRHIResourceCreateInfo CreateInfo;
		IndexBufferRHI = RHICreateIndexBuffer(sizeof(uint32),Size,BUF_Static,CreateInfo);

		// Initialize the buffer.
		void* Buffer = RHILockIndexBuffer(IndexBufferRHI, 0, Size, RLM_WriteOnly);
		FMemory::Memcpy(Buffer,Indices.GetData(),Size);
		RHIUnlockIndexBuffer(IndexBufferRHI);
	}

	// BSP sample debugging requires CPU access to index buffers
#if !ALLOW_LIGHTMAP_SAMPLE_DEBUGGING
	// Undo/redo can destroy and recreate the render resources for UModels without rebuilding the
	// buffers, so the indices need to be saved when in the editor.
	if (!GIsEditor && !IsRunningCommandlet())
	{
		Indices.Empty();
	}
#endif
}
Ejemplo n.º 3
0
void FStreetMapIndexBuffer::InitRHI()
{
	const int IndexCount = FMath::Max( Indices16.Num(), Indices32.Num() );
	if( IndexCount > 0 )
	{
		const bool b32BitIndices = Indices32.Num() > Indices16.Num();
		const uint8 IndexSize = b32BitIndices ? sizeof( Indices32[ 0 ] ) : sizeof( Indices16[ 0 ] );
		const void* IndexSourceData;
		if( b32BitIndices )
		{
			IndexSourceData = Indices32.GetData();
		}
		else
		{
			IndexSourceData = Indices16.GetData();
		}
		
		// Allocate our index buffer and load it with data
		FRHIResourceCreateInfo CreateInfo;
		IndexBufferRHI = RHICreateIndexBuffer( IndexSize, IndexCount * IndexSize, BUF_Static, CreateInfo );
		void* IndexBufferData = RHILockIndexBuffer( IndexBufferRHI, 0, IndexCount * IndexSize, RLM_WriteOnly );
		FMemory::Memcpy( IndexBufferData, IndexSourceData, IndexCount * IndexSize );
		RHIUnlockIndexBuffer( IndexBufferRHI );
	}
}
	void UpdateRenderData() const
	{
		// Copy the index data into the indices buffer
		void* Buffer = RHILockIndexBuffer(IndexBufferRHI, 0, Indices.Num() * sizeof(int32), RLM_WriteOnly);
		FMemory::Memcpy(Buffer, Indices.GetData(), Indices.Num() * sizeof(int32));
		RHIUnlockIndexBuffer(IndexBufferRHI);
	}
Ejemplo n.º 5
0
	virtual void InitRHI() override
	{
		const uint32 Size = sizeof(uint16) * 6 * 8;
		const uint32 Stride = sizeof(uint16);
		FRHIResourceCreateInfo CreateInfo;
		IndexBufferRHI = RHICreateIndexBuffer( Stride, Size, BUF_Static, CreateInfo );
		uint16* Indices = (uint16*)RHILockIndexBuffer( IndexBufferRHI, 0, Size, RLM_WriteOnly );
		for (uint32 SpriteIndex = 0; SpriteIndex < 8; ++SpriteIndex)
		{
#if PLATFORM_MAC // Avoid a driver bug on OSX/NV cards that causes driver to generate an unwound index buffer
			Indices[SpriteIndex*6 + 0] = SpriteIndex*6 + 0;
			Indices[SpriteIndex*6 + 1] = SpriteIndex*6 + 1;
			Indices[SpriteIndex*6 + 2] = SpriteIndex*6 + 2;
			Indices[SpriteIndex*6 + 3] = SpriteIndex*6 + 3;
			Indices[SpriteIndex*6 + 4] = SpriteIndex*6 + 4;
			Indices[SpriteIndex*6 + 5] = SpriteIndex*6 + 5;
#else
			Indices[SpriteIndex*6 + 0] = SpriteIndex*4 + 0;
			Indices[SpriteIndex*6 + 1] = SpriteIndex*4 + 3;
			Indices[SpriteIndex*6 + 2] = SpriteIndex*4 + 2;
			Indices[SpriteIndex*6 + 3] = SpriteIndex*4 + 0;
			Indices[SpriteIndex*6 + 4] = SpriteIndex*4 + 1;
			Indices[SpriteIndex*6 + 5] = SpriteIndex*4 + 3;
#endif
		}
		RHIUnlockIndexBuffer( IndexBufferRHI );
	}
	virtual void InitRHI()
	{
		IndexBufferRHI = RHICreateIndexBuffer(sizeof(int32), Indices.Num() * sizeof(int32), NULL, BUF_Static);

		// Write the indices to the index buffer.
		void* Buffer = RHILockIndexBuffer(IndexBufferRHI, 0, Indices.Num() * sizeof(int32), RLM_WriteOnly);
		FMemory::Memcpy(Buffer, Indices.GetTypedData(), Indices.Num() * sizeof(int32));
		RHIUnlockIndexBuffer(IndexBufferRHI);
	}
	virtual void InitRHI() override
	{
		FRHIResourceCreateInfo CreateInfo;
		IndexBufferRHI = RHICreateIndexBuffer(sizeof(int32), Indices.Num() * sizeof(int32), BUF_Static, CreateInfo);
		// Write the indices to the index buffer.
		void* Buffer = RHILockIndexBuffer(IndexBufferRHI, 0, Indices.Num() * sizeof(int32), RLM_WriteOnly);
		FMemory::Memcpy(Buffer, Indices.GetData(), Indices.Num() * sizeof(int32));
		RHIUnlockIndexBuffer(IndexBufferRHI);
	}
	void InitRHI()
	{
		FRHIResourceCreateInfo CreateInfo;
		IndexBufferRHI = RHICreateIndexBuffer(sizeof(uint16), Indices.Num() * sizeof(uint16), BUF_Static, CreateInfo);

		// Copy the index data into the index buffer.
		void* Buffer = RHILockIndexBuffer(IndexBufferRHI, 0, Indices.Num() * sizeof(uint16), RLM_WriteOnly);
		FMemory::Memcpy(Buffer, Indices.GetData(), Indices.Num() * sizeof(uint16));
		RHIUnlockIndexBuffer(IndexBufferRHI);
	}
Ejemplo n.º 9
0
	virtual void InitRHI() override
	{
#if ENGINE_MAJOR_VERSION >= 4 && ENGINE_MINOR_VERSION >= 3
		FRHIResourceCreateInfo CreateInfo;
		IndexBufferRHI = RHICreateIndexBuffer(sizeof(int32), Indices.Num() * sizeof(int32), BUF_Static, CreateInfo);
#else
		IndexBufferRHI = RHICreateIndexBuffer(sizeof(int32), Indices.Num() * sizeof(int32), NULL, BUF_Static);
#endif
		// Write the indices to the index buffer.
		void* Buffer = RHILockIndexBuffer(IndexBufferRHI, 0, Indices.Num() * sizeof(int32), RLM_WriteOnly);
		FMemory::Memcpy(Buffer, Indices.GetData(), Indices.Num() * sizeof(int32));
		RHIUnlockIndexBuffer(IndexBufferRHI);
	}
Ejemplo n.º 10
0
void FRawIndexBuffer::InitRHI()
{
	uint32 Size = Indices.Num() * sizeof(uint16);
	if( Size > 0 )
	{
		// Create the index buffer.
		FRHIResourceCreateInfo CreateInfo;
		IndexBufferRHI = RHICreateIndexBuffer(sizeof(uint16),Size,BUF_Static,CreateInfo);

		// Initialize the buffer.
		void* Buffer = RHILockIndexBuffer(IndexBufferRHI, 0, Size, RLM_WriteOnly);
		FMemory::Memcpy(Buffer,Indices.GetData(),Size);
		RHIUnlockIndexBuffer(IndexBufferRHI);
	}
}
//
// IndexBuffer 
//
void FSsPartsIndexBuffer::InitRHI()
{
	if(0 < NumIndices)
	{
		FRHIResourceCreateInfo CreateInfo;
		IndexBufferRHI = RHICreateIndexBuffer(sizeof(uint32), NumIndices * sizeof(uint32), BUF_Dynamic, CreateInfo);

		void* IndicesPtr = RHILockIndexBuffer(IndexBufferRHI, 0, NumIndices * sizeof(uint32), RLM_WriteOnly);
		for(uint32 i = 0; i < NumIndices/6; ++i)
		{
			((uint32*)IndicesPtr)[i*6+0] = i*4+0;
			((uint32*)IndicesPtr)[i*6+1] = i*4+1;
			((uint32*)IndicesPtr)[i*6+2] = i*4+3;
			((uint32*)IndicesPtr)[i*6+3] = i*4+0;
			((uint32*)IndicesPtr)[i*6+4] = i*4+3;
			((uint32*)IndicesPtr)[i*6+5] = i*4+2;
		}
		RHIUnlockIndexBuffer(IndexBufferRHI);
	}
}
Ejemplo n.º 12
0
/**
 * Creates an index buffer for drawing an individual sprite.
 */
void FParticleIndexBuffer::InitRHI()
{
	// Instanced path needs only MAX_PARTICLES_PER_INSTANCE,
	// but using the maximum needed for the non-instanced path
	// in prep for future flipping of both instanced and non-instanced at runtime.
	const uint32 MaxParticles = 65536 / 4;
	const uint32 Size = sizeof(uint16) * 6 * MaxParticles;
	const uint32 Stride = sizeof(uint16);
	IndexBufferRHI = RHICreateIndexBuffer( Stride, Size, NULL, BUF_Static );
	uint16* Indices = (uint16*)RHILockIndexBuffer( IndexBufferRHI, 0, Size, RLM_WriteOnly );
	for (uint32 SpriteIndex = 0; SpriteIndex < MaxParticles; ++SpriteIndex)
	{
		Indices[SpriteIndex*6 + 0] = SpriteIndex*4 + 0;
		Indices[SpriteIndex*6 + 1] = SpriteIndex*4 + 2;
		Indices[SpriteIndex*6 + 2] = SpriteIndex*4 + 3;
		Indices[SpriteIndex*6 + 3] = SpriteIndex*4 + 0;
		Indices[SpriteIndex*6 + 4] = SpriteIndex*4 + 1;
		Indices[SpriteIndex*6 + 5] = SpriteIndex*4 + 2;
	}
	RHIUnlockIndexBuffer( IndexBufferRHI );
}
Ejemplo n.º 13
0
FIndexBufferRHIRef FEmptyDynamicRHI::RHICreateIndexBuffer(uint32 Stride, uint32 Size, uint32 InUsage, FRHIResourceCreateInfo& CreateInfo)
{
	// make the RHI object, which will allocate memory
	FEmptyIndexBuffer* IndexBuffer = new FEmptyIndexBuffer(Stride, Size, InUsage);
	
	if(CreateInfo.ResourceArray)
	{
		check(Size == CreateInfo.ResourceArray->GetResourceDataSize());

		// make a buffer usable by CPU
		void* Buffer = RHILockIndexBuffer(IndexBuffer, 0, Size, RLM_WriteOnly);

		// copy the contents of the given data into the buffer
		FMemory::Memcpy(Buffer, CreateInfo.ResourceArray->GetResourceData(), Size);

		RHIUnlockIndexBuffer(IndexBuffer);

		// Discard the resource array's contents.
		CreateInfo.ResourceArray->Discard();
	}

	return IndexBuffer;
}
void* FSlateElementIndexBuffer::LockBuffer_RenderThread(int32 NumIndices)
{
	uint32 RequiredBufferSize = NumIndices*sizeof(SlateIndex);		
	return RHILockIndexBuffer( IndexBufferRHI, 0, RequiredBufferSize, RLM_WriteOnly );
}
Ejemplo n.º 15
0
	void AddElements(TArray<int32> &Elements)
	{
		int32* IndexBufferData = (int32*)RHILockIndexBuffer(IndexBufferRHI, 0, BOSize * sizeof(int32), RLM_WriteOnly);
		FMemory::Memcpy(IndexBufferData, &Elements[0], Elements.Num() * sizeof(int32));
		RHIUnlockIndexBuffer(IndexBufferRHI);
	}