holy shit it works????
This commit is contained in:
@@ -25,7 +25,6 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
|||||||
desc->setStoreAction(cast(color.getStoreOp()));
|
desc->setStoreAction(cast(color.getStoreOp()));
|
||||||
desc->setLevel(0);
|
desc->setLevel(0);
|
||||||
if (!layout.resolveAttachments.empty()) {
|
if (!layout.resolveAttachments.empty()) {
|
||||||
const auto& resolve = layout.resolveAttachments[i];
|
|
||||||
desc->setResolveLevel(0);
|
desc->setResolveLevel(0);
|
||||||
// store multisampled attachment as well
|
// store multisampled attachment as well
|
||||||
if(color.getStoreOp() == Gfx::SE_ATTACHMENT_STORE_OP_STORE) {
|
if(color.getStoreOp() == Gfx::SE_ATTACHMENT_STORE_OP_STORE) {
|
||||||
@@ -33,7 +32,6 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
|||||||
} else {
|
} else {
|
||||||
desc->setStoreAction(MTL::StoreActionMultisampleResolve);
|
desc->setStoreAction(MTL::StoreActionMultisampleResolve);
|
||||||
}
|
}
|
||||||
desc->setResolveTexture(resolve.getTexture().cast<TextureBase>()->getImage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||||
@@ -49,7 +47,6 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
|||||||
} else {
|
} else {
|
||||||
depth->setStoreAction(MTL::StoreActionMultisampleResolve);
|
depth->setStoreAction(MTL::StoreActionMultisampleResolve);
|
||||||
}
|
}
|
||||||
depth->setResolveTexture(layout.depthResolveAttachment.getTexture().cast<TextureBase>()->getImage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: stencil
|
// TODO: stencil
|
||||||
@@ -61,9 +58,16 @@ void RenderPass::updateRenderPass() {
|
|||||||
const auto& color = layout.colorAttachments[i];
|
const auto& color = layout.colorAttachments[i];
|
||||||
auto desc = renderPass->colorAttachments()->object(i);
|
auto desc = renderPass->colorAttachments()->object(i);
|
||||||
desc->setTexture(color.getTexture().cast<TextureBase>()->getImage());
|
desc->setTexture(color.getTexture().cast<TextureBase>()->getImage());
|
||||||
|
if (!layout.resolveAttachments.empty()) {
|
||||||
|
const auto& resolve = layout.resolveAttachments[i];
|
||||||
|
desc->setResolveTexture(resolve.getTexture().cast<TextureBase>()->getImage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||||
auto depth = renderPass->depthAttachment();
|
auto depth = renderPass->depthAttachment();
|
||||||
depth->setTexture(layout.depthAttachment.getTexture().cast<TextureBase>()->getImage());
|
depth->setTexture(layout.depthAttachment.getTexture().cast<TextureBase>()->getImage());
|
||||||
|
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
||||||
|
depth->setResolveTexture(layout.depthResolveAttachment.getTexture().cast<TextureBase>()->getImage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class Window : public Gfx::Window {
|
|||||||
CA::MetalLayer* metalLayer;
|
CA::MetalLayer* metalLayer;
|
||||||
CA::MetalDrawable* drawable;
|
CA::MetalDrawable* drawable;
|
||||||
OTexture2D backBuffer;
|
OTexture2D backBuffer;
|
||||||
|
OEvent renderDoneSemaphore;
|
||||||
|
|
||||||
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
|
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
|
||||||
std::function<void(double, double)> mouseMoveCallback;
|
std::function<void(double, double)> mouseMoveCallback;
|
||||||
|
|||||||
@@ -92,9 +92,6 @@ Window::Window(PGraphics graphics, const WindowCreateInfo& createInfo) : graphic
|
|||||||
[[metalWindow contentView] setLayer:(__bridge id)metalLayer];
|
[[metalWindow contentView] setLayer:(__bridge id)metalLayer];
|
||||||
[[metalWindow contentView] setWantsLayer:YES];
|
[[metalWindow contentView] setWantsLayer:YES];
|
||||||
framebufferFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB;
|
framebufferFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB;
|
||||||
|
|
||||||
drawable = metalLayer->nextDrawable();
|
|
||||||
createBackBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window() { glfwDestroyWindow(static_cast<GLFWwindow*>(windowHandle)); }
|
Window::~Window() { glfwDestroyWindow(static_cast<GLFWwindow*>(windowHandle)); }
|
||||||
@@ -104,6 +101,8 @@ void Window::show() { glfwShowWindow(windowHandle); }
|
|||||||
void Window::pollInput() { glfwPollEvents(); }
|
void Window::pollInput() { glfwPollEvents(); }
|
||||||
|
|
||||||
void Window::beginFrame() {
|
void Window::beginFrame() {
|
||||||
|
drawable = metalLayer->nextDrawable();
|
||||||
|
createBackBuffer();
|
||||||
static double start = glfwGetTime();
|
static double start = glfwGetTime();
|
||||||
double end = glfwGetTime();
|
double end = glfwGetTime();
|
||||||
currentFrameDelta = end - start;
|
currentFrameDelta = end - start;
|
||||||
@@ -112,13 +111,10 @@ void Window::beginFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window::endFrame() {
|
void Window::endFrame() {
|
||||||
graphics->waitDeviceIdle();
|
|
||||||
graphics->getQueue()->getCommands()->present(drawable);
|
|
||||||
graphics->getQueue()->submitCommands();
|
graphics->getQueue()->submitCommands();
|
||||||
|
graphics->getQueue()->getCommands()->present(drawable);
|
||||||
currentFrameIndex++;
|
currentFrameIndex++;
|
||||||
drawable->release();
|
drawable->release();
|
||||||
drawable = metalLayer->nextDrawable();
|
|
||||||
createBackBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::onWindowCloseEvent() {}
|
void Window::onWindowCloseEvent() {}
|
||||||
@@ -181,6 +177,7 @@ void Window::createBackBuffer() {
|
|||||||
.samples = static_cast<uint32>(buf->sampleCount()),
|
.samples = static_cast<uint32>(buf->sampleCount()),
|
||||||
},
|
},
|
||||||
buf);
|
buf);
|
||||||
|
renderDoneSemaphore = new Event(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& createInfo) : Gfx::Viewport(owner, createInfo) {
|
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& createInfo) : Gfx::Viewport(owner, createInfo) {
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ void BasePass::publishOutputs() {
|
|||||||
|
|
||||||
depthAttachment =
|
depthAttachment =
|
||||||
Gfx::RenderTargetAttachment(basePassDepth, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
Gfx::RenderTargetAttachment(basePassDepth, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||||
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
||||||
|
|
||||||
msDepthAttachment =
|
msDepthAttachment =
|
||||||
Gfx::RenderTargetAttachment(msBasePassDepth, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
Gfx::RenderTargetAttachment(msBasePassDepth, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||||
@@ -418,7 +418,7 @@ void BasePass::publishOutputs() {
|
|||||||
msDepthAttachment.clear.depthStencil.depth = 0.0f;
|
msDepthAttachment.clear.depthStencil.depth = 0.0f;
|
||||||
|
|
||||||
colorAttachment = Gfx::RenderTargetAttachment(viewport, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
colorAttachment = Gfx::RenderTargetAttachment(viewport, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_DONT_CARE);
|
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE);
|
||||||
|
|
||||||
msColorAttachment =
|
msColorAttachment =
|
||||||
Gfx::RenderTargetAttachment(msBasePassColor, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
Gfx::RenderTargetAttachment(msBasePassColor, Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
|
|||||||
Reference in New Issue
Block a user