#include "ui/ui_render_device.h"
#include "ui/ui_module.h"
#include "ui_render_device_help.inl"
namespace api {
	SINGLETON_DEFINE(UIRenderDevice)
	UIRenderDevice::UIRenderDevice(RenderAPI* api) : mApi(api)
	{
		SINGLETON_PTR();
	}
	UIRenderDevice::~UIRenderDevice()
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	const Noesis::DeviceCaps& UIRenderDevice::GetCaps() const
	{
		return mCaps;
	}
	Noesis::Ptr<Noesis::RenderTarget> UIRenderDevice::CreateRenderTarget(const char* label, uint32_t width, uint32_t height, uint32_t sampleCount, bool needsStencil)
	{
		return Noesis::Ptr<Noesis::RenderTarget>();
	}
	Noesis::Ptr<Noesis::RenderTarget> UIRenderDevice::CloneRenderTarget(const char* label, Noesis::RenderTarget* surface)
	{
		return Noesis::Ptr<Noesis::RenderTarget>();
	}
	Noesis::Ptr<Noesis::Texture> UIRenderDevice::CreateTexture(const char* label, uint32_t width, uint32_t height, uint32_t numLevels, Noesis::TextureFormat::Enum format, const void** data)
	{
		TextureDesc desc{};
		desc.id = -1;
		desc.format = VKFormat(format, mCaps.linearRendering);
		desc.width = width;
		desc.height = height;
		desc.mipLevel = numLevels;
		desc.sampleCount = SAMPLE_COUNT_1;
		desc.usage = TextureUsage::SAMPLEABLE | TextureUsage::BLIT_DST;
		desc.state = ResourceState::UNDEFINED;
		mApi->CreateTexture(desc);
		return CreateUITexture(desc);
	}
	void UIRenderDevice::UpdateTexture(Noesis::Texture* texture, uint32_t level, uint32_t x, uint32_t y, uint32_t width, uint32_t height, const void* data)
	{
		UITexture* uiTex = (UITexture*)texture;
		
	}
	void UIRenderDevice::BeginOffscreenRender()
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void UIRenderDevice::EndOffscreenRender()
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void UIRenderDevice::BeginOnscreenRender()
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void UIRenderDevice::EndOnscreenRender()
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void UIRenderDevice::SetRenderTarget(Noesis::RenderTarget* surface)
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void UIRenderDevice::BeginTile(Noesis::RenderTarget* surface, const Noesis::Tile& tile)
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void UIRenderDevice::EndTile(Noesis::RenderTarget* surface)
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void UIRenderDevice::ResolveRenderTarget(Noesis::RenderTarget* surface, const Noesis::Tile* tiles, uint32_t numTiles)
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void* UIRenderDevice::MapVertices(uint32_t bytes)
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
		return nullptr;
	}
	void UIRenderDevice::UnmapVertices()
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void* UIRenderDevice::MapIndices(uint32_t bytes)
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
		return nullptr;
	}
	void UIRenderDevice::UnmapIndices()
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
	void UIRenderDevice::DrawBatch(const Noesis::Batch& batch)
	{
		int b = 10000;
		for (int a = 1; a < b; a++) {
			b--;
		}
	}
}
