2024-03-18 15:28:56 +01:00
|
|
|
#include "Graphics.h"
|
2024-04-10 09:58:39 +02:00
|
|
|
#include "RenderPass.h"
|
|
|
|
|
#include "Command.h"
|
2024-04-09 16:41:12 +02:00
|
|
|
#include "Window.h"
|
2024-03-18 15:28:56 +01:00
|
|
|
|
|
|
|
|
using namespace Seele;
|
|
|
|
|
using namespace Seele::Metal;
|
|
|
|
|
|
|
|
|
|
Graphics::Graphics()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2024-04-09 16:41:12 +02:00
|
|
|
|
2024-03-18 15:28:56 +01:00
|
|
|
Graphics::~Graphics()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2024-04-09 16:41:12 +02:00
|
|
|
|
|
|
|
|
void Graphics::init(GraphicsInitializer)
|
2024-03-18 15:28:56 +01:00
|
|
|
{
|
2024-03-26 20:34:40 +01:00
|
|
|
device = MTL::CreateSystemDefaultDevice();
|
2024-04-09 16:41:12 +02:00
|
|
|
library = device->newDefaultLibrary();
|
|
|
|
|
assert(library);
|
2024-04-10 09:58:39 +02:00
|
|
|
queue = new CommandQueue(this);
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::OWindow Graphics::createWindow(const WindowCreateInfo &createInfo)
|
|
|
|
|
{
|
2024-04-09 16:41:12 +02:00
|
|
|
return new Window(this, createInfo);
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
2024-04-09 16:41:12 +02:00
|
|
|
|
2024-03-18 15:28:56 +01:00
|
|
|
Gfx::OViewport Graphics::createViewport(Gfx::PWindow owner, const ViewportCreateInfo &createInfo)
|
|
|
|
|
{
|
2024-04-09 16:41:12 +02:00
|
|
|
return new Viewport(owner, createInfo);
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::ORenderPass Graphics::createRenderPass(Gfx::RenderTargetLayout layout, Array<Gfx::SubPassDependency> dependencies, Gfx::PViewport renderArea)
|
|
|
|
|
{
|
2024-04-10 08:43:56 +02:00
|
|
|
return new RenderPass(this, layout, dependencies, renderArea);
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
2024-04-09 16:41:12 +02:00
|
|
|
|
2024-03-18 15:28:56 +01:00
|
|
|
void Graphics::beginRenderPass(Gfx::PRenderPass renderPass)
|
|
|
|
|
{
|
2024-04-10 09:58:39 +02:00
|
|
|
queue->getCommands()->beginRenderPass(renderPass.cast<RenderPass>());
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
2024-04-10 08:43:56 +02:00
|
|
|
|
2024-03-18 15:28:56 +01:00
|
|
|
void Graphics::endRenderPass()
|
|
|
|
|
{
|
2024-04-10 09:58:39 +02:00
|
|
|
queue->getCommands()->endRenderPass();
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
2024-04-10 09:58:39 +02:00
|
|
|
|
2024-03-18 15:28:56 +01:00
|
|
|
void Graphics::waitDeviceIdle()
|
|
|
|
|
{
|
2024-04-10 09:58:39 +02:00
|
|
|
queue->getCommands()->waitDeviceIdle();
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Graphics::executeCommands(const Array<Gfx::PRenderCommand>& commands)
|
|
|
|
|
{
|
2024-04-10 09:58:39 +02:00
|
|
|
queue->getCommands()->executeCommands(commands);
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
2024-04-10 09:58:39 +02:00
|
|
|
|
2024-03-18 15:28:56 +01:00
|
|
|
void Graphics::executeCommands(const Array<Gfx::PComputeCommand>& commands)
|
|
|
|
|
{
|
2024-04-10 09:58:39 +02:00
|
|
|
queue->getCommands()->executeCommands(commands);
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::OTexture2D Graphics::createTexture2D(const TextureCreateInfo &createInfo)
|
|
|
|
|
{
|
2024-04-10 09:58:39 +02:00
|
|
|
return new Texture2D(this, createInfo);
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
|
|
|
|
Gfx::OTexture3D Graphics::createTexture3D(const TextureCreateInfo &createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
2024-04-10 09:58:39 +02:00
|
|
|
return new Texture3D(this, createInfo);
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
|
|
|
|
Gfx::OTextureCube Graphics::createTextureCube(const TextureCreateInfo &createInfo)
|
|
|
|
|
{
|
2024-04-10 09:58:39 +02:00
|
|
|
return new TextureCube(this, createInfo);
|
2024-03-18 15:28:56 +01:00
|
|
|
}
|
|
|
|
|
Gfx::OUniformBuffer Graphics::createUniformBuffer(const UniformBufferCreateInfo &bulkData)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::OShaderBuffer Graphics::createShaderBuffer(const ShaderBufferCreateInfo &bulkData)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::OVertexBuffer Graphics::createVertexBuffer(const VertexBufferCreateInfo &bulkData)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::OIndexBuffer Graphics::createIndexBuffer(const IndexBufferCreateInfo &bulkData)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::PRenderCommand Graphics::createRenderCommand(const std::string& name)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::PComputeCommand Graphics::createComputeCommand(const std::string& name)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::OVertexShader Graphics::createVertexShader(const ShaderCreateInfo& createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::OFragmentShader Graphics::createFragmentShader(const ShaderCreateInfo& createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::OComputeShader Graphics::createComputeShader(const ShaderCreateInfo& createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::OMeshShader Graphics::createMeshShader(const ShaderCreateInfo& createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::OTaskShader Graphics::createTaskShader(const ShaderCreateInfo& createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::PGraphicsPipeline Graphics::createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::PGraphicsPipeline Graphics::createGraphicsPipeline(Gfx::MeshPipelineCreateInfo createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::PComputePipeline Graphics::createComputePipeline(Gfx::ComputePipelineCreateInfo createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::OSampler Graphics::createSampler(const SamplerCreateInfo& createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::ODescriptorLayout Graphics::createDescriptorLayout(const std::string& name)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Gfx::OPipelineLayout Graphics::createPipelineLayout(Gfx::PPipelineLayout baseLayout)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gfx::OVertexInput Graphics::createVertexInput(VertexInputStateCreateInfo createInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Graphics::resolveTexture(Gfx::PTexture source, Gfx::PTexture destination)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|