Skip to content

Commit 9989113

Browse files
committed
Fix: Add multiple fixes from LÖVE, compilation fixes
1 parent c34ca45 commit 9989113

23 files changed

Lines changed: 297 additions & 225 deletions

File tree

include/common/luax.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,21 @@ namespace love
366366

367367
// #region Other
368368

369+
template<size_t N>
370+
bool luax_allnil(lua_State* L)
371+
{
372+
if (lua_gettop(L) != N)
373+
return false;
374+
375+
for (size_t i = 1; i <= N; ++i)
376+
{
377+
if (!lua_isnil(L, i))
378+
return false;
379+
}
380+
381+
return true;
382+
}
383+
369384
// #endregion
370385

371386
// #region Debug

include/common/math.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ namespace love
7272
}
7373
};
7474

75+
struct FRect
76+
{
77+
float x, y, w, h;
78+
79+
FRect() : x(0), y(0), w(0), h(0)
80+
{}
81+
82+
FRect(float x, float y, float w, float h) : x(x), y(y), w(w), h(h)
83+
{}
84+
85+
bool operator==(const FRect& other) const
86+
{
87+
return x == other.x && y == other.y && w == other.w && h == other.h;
88+
}
89+
};
90+
7591
/*
7692
** Clamps 3DS textures between min
7793
** and max texture size to prevent

include/modules/graphics/Graphics.tcc

Lines changed: 79 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,22 @@ namespace love
9595

9696
enum Feature
9797
{
98-
FEATURE_MULTI_RENDER_TARGET_FORMATS,
98+
FEATURE_MULTI_RENDER_TARGET_FORMATS, // Deprecated
9999
FEATURE_CLAMP_ZERO,
100100
FEATURE_CLAMP_ONE,
101-
FEATURE_BLEND_MINMAX,
102-
FEATURE_LIGHTEN, // Deprecated
103-
FEATURE_FULL_NPOT,
104-
FEATURE_PIXEL_SHADER_HIGHP,
105-
FEATURE_SHADER_DERIVATIVES,
106-
FEATURE_GLSL3,
101+
FEATURE_LIGHTEN, // Deprecated
102+
FEATURE_FULL_NPOT, // Deprecated
103+
FEATURE_PIXEL_SHADER_HIGHP, // Deprecated
104+
FEATURE_SHADER_DERIVATIVES, // Deprecated
105+
FEATURE_GLSL3, // Deprecated
107106
FEATURE_GLSL4,
108-
FEATURE_INSTANCING,
107+
FEATURE_INSTANCING, // Deprecated
109108
FEATURE_TEXEL_BUFFER,
110-
FEATURE_INDEX_BUFFER_32BIT,
111-
FEATURE_COPY_BUFFER,
112-
FEATURE_COPY_BUFFER_TO_TEXTURE,
113109
FEATURE_COPY_TEXTURE_TO_BUFFER,
114-
FEATURE_COPY_RENDER_TARGET_TO_BUFFER,
115-
FEATURE_MIPMAP_RANGE,
116110
FEATURE_INDIRECT_DRAW,
111+
FEATURE_VERTEX_WRITE,
112+
FEATURE_PIXEL_WRITE,
113+
FEATURE_IMAGE_ATOMICS,
117114
FEATURE_MAX_ENUM
118115
};
119116

@@ -280,6 +277,29 @@ namespace love
280277
}
281278
};
282279

280+
struct BackbufferSettings
281+
{
282+
int width = 0;
283+
int height = 0;
284+
int pixelWidth = 0;
285+
int pixelHeight = 0;
286+
bool stencil = false;
287+
bool depth = false;
288+
int msaa = 0;
289+
290+
bool operator==(const BackbufferSettings& other) const
291+
{
292+
return width == other.width && height == other.height && pixelWidth == other.pixelWidth &&
293+
pixelHeight == other.pixelHeight && stencil == other.stencil && depth == other.depth &&
294+
msaa == other.msaa;
295+
}
296+
297+
bool operator!=(const BackbufferSettings& other) const
298+
{
299+
return !(operator==(other));
300+
}
301+
};
302+
283303
struct RenderTargets
284304
{
285305
std::vector<RenderTarget> colors;
@@ -329,8 +349,8 @@ namespace love
329349

330350
float pointSize = 1.0f;
331351

332-
bool scissor = false;
333-
Rect scissorRect = Rect();
352+
bool scissor = false;
353+
FRect scissorRect = FRect();
334354

335355
StencilState stencil;
336356

@@ -420,17 +440,17 @@ namespace love
420440
this->states.back().defaultSamplerState = state;
421441
}
422442

423-
virtual void setScissor(const Rect& scissor) = 0;
443+
virtual void setScissor(const FRect& scissor) = 0;
424444

425445
virtual void setScissor() = 0;
426446

427447
void setShader();
428448

429449
void setShader(ShaderBase* shader);
430450

431-
void intersectScissor(const Rect& scissor);
451+
void intersectScissor(const FRect& scissor);
432452

433-
bool getScissor(Rect& scissor) const;
453+
bool getScissor(FRect& scissor) const;
434454

435455
void setProjection(const Matrix4& matrix);
436456

@@ -680,10 +700,6 @@ namespace love
680700
this->pixelScaleStack.back() = 1.0;
681701
}
682702

683-
void validateStencilState(const StencilState& state) const;
684-
685-
void validateDepthState(bool depthWrite) const;
686-
687703
int getWidth() const;
688704

689705
int getHeight() const;
@@ -701,6 +717,8 @@ namespace love
701717
this->deviceProjectionMatrix = projection;
702718
}
703719

720+
// virtual void backbufferChanged(const BackbufferSettings& settings) = 0;
721+
704722
void backbufferChanged(int width, int height, double pixelWidth, double pixelHeight);
705723

706724
const Matrix4& getDeviceProjection() const
@@ -839,11 +857,50 @@ namespace love
839857
{ "all", STACK_ALL },
840858
{ "transform", STACK_TRANSFORM }
841859
);
860+
861+
STRINGMAP_DECLARE(Features, Feature,
862+
{ "multicanvasformats", FEATURE_MULTI_RENDER_TARGET_FORMATS },
863+
{ "clampzero", FEATURE_CLAMP_ZERO },
864+
{ "clampone", FEATURE_CLAMP_ONE },
865+
{ "lighten", FEATURE_LIGHTEN },
866+
{ "fullnpot", FEATURE_FULL_NPOT },
867+
{ "pixelshaderhighp", FEATURE_PIXEL_SHADER_HIGHP },
868+
{ "shaderderivatives", FEATURE_SHADER_DERIVATIVES },
869+
{ "glsl3", FEATURE_GLSL3 },
870+
{ "glsl4", FEATURE_GLSL4 },
871+
{ "instancing", FEATURE_INSTANCING },
872+
{ "texelbuffer", FEATURE_TEXEL_BUFFER },
873+
{ "copytexturetobuffer", FEATURE_COPY_TEXTURE_TO_BUFFER },
874+
{ "indirectdraw", FEATURE_INDIRECT_DRAW },
875+
{ "vertexwrite", FEATURE_VERTEX_WRITE },
876+
{ "pixelwrite", FEATURE_PIXEL_WRITE }
877+
);
878+
879+
STRINGMAP_DECLARE(SystemLimits, SystemLimit,
880+
{ "pointsize", LIMIT_POINT_SIZE },
881+
{ "texturesize", LIMIT_TEXTURE_SIZE },
882+
{ "texturelayers", LIMIT_TEXTURE_LAYERS },
883+
{ "volumetexturesize", LIMIT_VOLUME_TEXTURE_SIZE },
884+
{ "cubetexturesize", LIMIT_CUBE_TEXTURE_SIZE },
885+
{ "texelbuffersize", LIMIT_TEXEL_BUFFER_SIZE },
886+
{ "shaderstoragebuffersize", LIMIT_SHADER_STORAGE_BUFFER_SIZE },
887+
{ "threadgroupsx", LIMIT_THREADGROUPS_X },
888+
{ "threadgroupsy", LIMIT_THREADGROUPS_Y },
889+
{ "threadgroupsz", LIMIT_THREADGROUPS_Z },
890+
{ "multicanvas", LIMIT_RENDER_TARGETS },
891+
{ "texturemsaa", LIMIT_TEXTURE_MSAA },
892+
{ "anisotropy", LIMIT_ANISOTROPY },
893+
);
842894
// clang-format on
843895

844896
protected:
845897
int calculateEllipsePoints(float a, float b) const;
846898

899+
void validateStencilState(const StencilState& state) const;
900+
901+
void validateDepthState(bool depthWrite) const;
902+
903+
BackbufferSettings backbufferSettings;
847904
bool created;
848905
bool active;
849906

platform/cafe/include/driver/display/GX2.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,18 @@ namespace love
3434

3535
~GX2();
3636

37-
void initialize();
37+
void init() override;
3838

39-
void deInitialize();
39+
void close() override;
4040

4141
int onForegroundAcquired();
4242

4343
int onForegroundReleased();
4444

45-
void clearColor(const Color& color);
45+
void clearColor(const Color& color) override;
46+
47+
void clear(double depth, int stencil) override
48+
{}
4649

4750
void clear(OptionalInt stencil, OptionalDouble depth, GX2ClearFlags flags);
4851

@@ -82,9 +85,9 @@ namespace love
8285

8386
void bindTextureToUnit(GX2Texture* texture, GX2Sampler* sampler, int unit);
8487

85-
void clearDepth(double value);
88+
void setClearDepth(double value);
8689

87-
void clearStencil(int value);
90+
void setClearStencil(int value) override;
8891

8992
void setMode(int width, int height);
9093

platform/cafe/include/modules/graphics/Graphics.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace love
2222

2323
void present(void* screenshotCallbackData) override;
2424

25-
void setScissor(const Rect& scissor) override;
25+
void setScissor(const FRect& scissor) override;
2626

2727
void setScissor() override;
2828

platform/cafe/source/driver/display/GX2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace love
4242
GX2::~GX2()
4343
{}
4444

45-
void GX2::deInitialize()
45+
void GX2::close()
4646
{
4747
if (this->inForeground)
4848
this->onForegroundReleased();
@@ -103,7 +103,7 @@ namespace love
103103
return gx2.onForegroundReleased();
104104
}
105105

106-
void GX2::initialize()
106+
void GX2::init()
107107
{
108108
if (this->initialized)
109109
return;
@@ -200,13 +200,13 @@ namespace love
200200
GX2WaitForFlip();
201201
}
202202

203-
void GX2::clearDepth(double value)
203+
void GX2::setClearDepth(double value)
204204
{
205205
this->context.depthClear = value;
206206
GX2SetClearDepth(&this->getInternalDepthbuffer(), (float)value);
207207
}
208208

209-
void GX2::clearStencil(int value)
209+
void GX2::setClearStencil(int value)
210210
{
211211
this->context.writeMask = value;
212212
GX2SetClearStencil(&this->getInternalDepthbuffer(), (uint8_t)value);

platform/cafe/source/modules/font/SystemFont.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ namespace love
1212
throw love::Exception("Failed to load system font: {:s}", name);
1313
}
1414

15-
SystemFont::SystemFont(const SystemFont& other) : data(other.data), size(other.size)
15+
SystemFont::SystemFont(const SystemFont& other) :
16+
SystemFontBase(other.type),
17+
data(other.data),
18+
size(other.size)
1619
{}
1720

1821
SystemFont::~SystemFont()

0 commit comments

Comments
 (0)