update metal backend for projection changes.

This commit is contained in:
Alex Szpakowski
2022-01-12 18:31:32 -04:00
parent f93d167a47
commit 5c3f391136
2 changed files with 11 additions and 6 deletions
+2
View File
@@ -65,6 +65,8 @@ public:
love::graphics::Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) override;
love::graphics::Buffer *newBuffer(const Buffer::Settings &settings, const std::vector<Buffer::DataDeclaration> &format, const void *data, size_t size, size_t arraylength) override;
Matrix4 computeDeviceProjection(const Matrix4 &projection, bool rendertotexture) const override;
void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override;
bool setMode(void *context, int width, int height, int pixelwidth, int pixelheight, bool windowhasstencil, int msaa) override;
void unSetMode() override;
+9 -6
View File
@@ -418,6 +418,12 @@ love::graphics::Buffer *Graphics::newBuffer(const Buffer::Settings &settings, co
return new Buffer(this, device, settings, format, data, size, arraylength);
}
Matrix4 Graphics::computeDeviceProjection(const Matrix4 &projection, bool /*rendertotexture*/) const
{
uint32 flags = DEVICE_PROJECTION_FLIP_Y;
return calculateDeviceProjection(projection, flags);
}
void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelheight)
{
this->width = width;
@@ -428,9 +434,7 @@ void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelh
if (!isRenderTargetActive())
{
dirtyRenderState |= STATEBIT_VIEWPORT | STATEBIT_SCISSOR;
// Set up the projection matrix
projectionMatrix = Matrix4::ortho(0.0, (float) width, (float) height, 0.0, -10.0f, 10.0f);
resetProjection();
}
Texture::Settings settings;
@@ -1009,7 +1013,7 @@ void Graphics::applyShaderUniforms(id<MTLRenderCommandEncoder> renderEncoder, lo
auto builtins = (Shader::BuiltinUniformData *) (bufferdata + s->getBuiltinUniformDataOffset());
builtins->transformMatrix = getTransform();
builtins->projectionMatrix = getProjection();
builtins->projectionMatrix = getDeviceProjection();
// The normal matrix is the transpose of the inverse of the rotation portion
// (top-left 3x3) of the transform matrix.
@@ -1299,7 +1303,7 @@ bool Graphics::dispatch(int x, int y, int z)
return true;
}}
void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int w, int h, int /*pixelw*/, int /*pixelh*/, bool /*hasSRGBtexture*/)
void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int /*w*/, int /*h*/, int /*pixelw*/, int /*pixelh*/, bool /*hasSRGBtexture*/)
{ @autoreleasepool {
endPass();
@@ -1336,7 +1340,6 @@ void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int w, int h,
setAttachment(rt, passDesc.stencilAttachment, attachmentStoreActions.stencil);
}
projectionMatrix = Matrix4::ortho(0.0, (float) w, (float) h, 0.0, -10.0f, 10.0f);
dirtyRenderState = STATEBIT_ALL;
lastVertexAttributes = VertexAttributes();
}}