Esempio n. 1
0
GPU_Vulkan::~GPU_Vulkan() {
	SaveCache(shaderCachePath_);
	// Note: We save the cache in DeviceLost
	DestroyDeviceObjects();
	framebufferManagerVulkan_->DestroyAllFBOs();
	vulkan2D_.Shutdown();
	depalShaderCache_.Clear();
	drawEngine_.DeviceLost();
	delete textureCacheVulkan_;
	delete pipelineManager_;
	delete shaderManagerVulkan_;
	delete framebufferManagerVulkan_;
}
Esempio n. 2
0
TransformDrawEngine::~TransformDrawEngine() {
	DestroyDeviceObjects();
	FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
	FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
	FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE);
	FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
	delete [] quadIndices_;

	unregister_gl_resource_holder(this);
	for (auto iter = decoderMap_.begin(); iter != decoderMap_.end(); iter++) {
		delete iter->second;
	}
	delete [] uvScale;
}
void CGrannyModelInstance::Clear()
{
	m_kMtrlPal.Clear();
	
	DestroyDeviceObjects();
	// WORK
	__DestroyMeshBindingVector();
	// END_OF_WORK
	__DestroyMeshMatrices();
	__DestroyModelInstance();
	__DestroyWorldPose();

	__Initialize();
}
Esempio n. 4
0
VertexManager::~VertexManager()
{
  DestroyDeviceObjects();
}
Esempio n. 5
0
void Vulkan2D::Shutdown() {
	DestroyDeviceObjects();
}
Esempio n. 6
0
Vulkan2D::~Vulkan2D() {
	DestroyDeviceObjects();
}
Esempio n. 7
0
void Vulkan2D::DeviceLost() {
	DestroyDeviceObjects();
}
Esempio n. 8
0
void CGraphicTexture::Destroy()
{
	DestroyDeviceObjects();

	Initialize();
}
Esempio n. 9
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);
}
void FramebufferManagerGLES::DeviceLost() {
	DestroyAllFBOs();
	DestroyDeviceObjects();
}
FramebufferManagerGLES::~FramebufferManagerGLES() {
	DestroyDeviceObjects();

	delete [] convBuf_;
}