Esempio n. 1
0
	Error operator()(GlState&)
	{
		TextureImpl::copy(m_src->getImplementation(),
			m_srcSurf,
			m_dest->getImplementation(),
			m_destSurf);
		return ErrorCode::NONE;
	}
Esempio n. 2
0
	Error operator()(GlState& state)
	{
		void* data = state.m_manager->getImplementation()
						 .getTransientMemoryManager()
						 .getBaseAddress(m_token);
		data = static_cast<void*>(static_cast<U8*>(data) + m_token.m_offset);

		m_handle->getImplementation().write(m_surf, data, m_token.m_range);

		if(m_token.m_lifetime == TransientMemoryTokenLifetime::PERSISTENT)
		{
			state.m_manager->getImplementation()
				.getTransientMemoryManager()
				.free(m_token);
		}

		return ErrorCode::NONE;
	}
//==============================================================================
void CommandBufferImpl::generateMipmaps(
	TexturePtr tex, U depth, U face, U layer)
{
	commandCommon();
	const TextureImpl& impl = tex->getImplementation();
	ANKI_ASSERT(impl.m_type != TextureType::_3D && "Not design for that ATM");

	U mipCount = computeMaxMipmapCount(impl.m_width, impl.m_height);

	for(U i = 0; i < mipCount - 1; ++i)
	{
		// Transition source
		if(i > 0)
		{
			VkImageSubresourceRange range;
			impl.computeSubResourceRange(
				TextureSurfaceInfo(i, depth, face, layer), range);

			setImageBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
				VK_ACCESS_TRANSFER_WRITE_BIT,
				VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
				VK_PIPELINE_STAGE_TRANSFER_BIT,
				VK_ACCESS_TRANSFER_READ_BIT,
				VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
				impl.m_imageHandle,
				range);
		}

		// Transition destination
		{
			VkImageSubresourceRange range;
			impl.computeSubResourceRange(
				TextureSurfaceInfo(i + 1, depth, face, layer), range);

			setImageBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
				0,
				VK_IMAGE_LAYOUT_UNDEFINED,
				VK_PIPELINE_STAGE_TRANSFER_BIT,
				VK_ACCESS_TRANSFER_WRITE_BIT,
				VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
				impl.m_imageHandle,
				range);
		}

		// Setup the blit struct
		I32 srcWidth = impl.m_width >> i;
		I32 srcHeight = impl.m_height >> i;

		I32 dstWidth = impl.m_width >> i;
		I32 dstHeight = impl.m_height >> i;

		ANKI_ASSERT(
			srcWidth > 0 && srcHeight > 0 && dstWidth > 0 && dstHeight > 0);

		VkImageBlit blit;
		blit.srcSubresource.aspectMask = impl.m_aspect;
		blit.srcSubresource.baseArrayLayer = layer;
		blit.srcSubresource.layerCount = 1;
		blit.srcSubresource.mipLevel = i;
		blit.srcOffsets[0] = {0, 0, 0};
		blit.srcOffsets[1] = {srcWidth, srcHeight, 1};

		blit.dstSubresource.aspectMask = impl.m_aspect;
		blit.dstSubresource.baseArrayLayer = layer;
		blit.dstSubresource.layerCount = 1;
		blit.dstSubresource.mipLevel = i + 1;
		blit.dstOffsets[0] = {0, 0, 0};
		blit.dstOffsets[1] = {dstWidth, dstHeight, 1};

		vkCmdBlitImage(m_handle,
			impl.m_imageHandle,
			VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
			impl.m_imageHandle,
			VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
			1,
			&blit,
			VK_FILTER_LINEAR);
	}

	// Hold the reference
	m_texList.pushBack(m_alloc, tex);
}
Esempio n. 4
0
	Error operator()(GlState&)
	{
		m_tex->getImplementation().clear(m_surf, m_val);
		return ErrorCode::NONE;
	}
Esempio n. 5
0
	Error operator()(GlState&)
	{
		m_tex->getImplementation().generateMipmaps(m_depth, m_face, m_layer);
		return ErrorCode::NONE;
	}