Skip to content

Commit 764407f

Browse files
committed
more mesh work on Wii U
1 parent 4fa9f67 commit 764407f

28 files changed

Lines changed: 550 additions & 409 deletions

File tree

include/common/config.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
#pragma once
22

3-
#define LOVE_UNUSED(x) (void)sizeof(x)
3+
namespace love
4+
{
5+
namespace detail
6+
{
7+
template<typename... T>
8+
char unused(T&&...);
9+
} // namespace detail
10+
} // namespace love
11+
12+
#define LOVE_UNUSED(...) (void)sizeof(love::detail::unused(__VA_ARGS__))

include/driver/display/Renderer.tcc

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
#pragma once
22

3-
#include "common/Singleton.tcc"
4-
53
#include "modules/graphics/Graphics.tcc"
6-
#include "modules/graphics/Shader.tcc"
74
#include "modules/graphics/renderstate.hpp"
85

96
#include "modules/graphics/vertex.hpp"
10-
11-
#include <array>
12-
#include <vector>
7+
#include <cstdint>
138

149
namespace love
1510
{
@@ -19,8 +14,33 @@ namespace love
1914
RendererBase()
2015
{}
2116

17+
virtual void init() = 0;
18+
19+
virtual void close() = 0;
20+
21+
virtual void clearColor(const Color& color) = 0;
22+
23+
virtual void clear(double depth, int stencil) = 0;
24+
25+
virtual void setClearDepth(double depth) = 0;
26+
27+
virtual void setClearStencil(int stencil) = 0;
28+
29+
virtual void setStencilState(const StencilState& state) = 0;
30+
31+
virtual void setViewport(const Rect& viewport) = 0;
32+
33+
virtual void setScissor(const Rect& scissor) = 0;
34+
35+
virtual void setCullMode(CullMode mode) = 0;
36+
37+
virtual void setVertexAttributes(const VertexAttributes& attributes,
38+
const BufferBindings& buffers) = 0;
39+
2240
virtual void prepareDraw(GraphicsBase* graphics) = 0;
2341

42+
virtual void present() = 0;
43+
2444
bool isInFrame() const
2545
{
2646
return this->inFrame;
@@ -29,17 +49,23 @@ namespace love
2949
protected:
3050
struct ContextBase
3151
{
32-
bool dirtyProjection;
33-
3452
CullMode cullMode;
3553
ColorChannelMask colorMask;
3654
BlendState blendState;
3755
StencilState stencilState;
3856

3957
Rect scissor;
4058
Rect viewport;
59+
60+
uint8_t currentTextureUnit;
61+
bool depthWrites;
4162
};
4263

64+
struct State
65+
{
66+
uint32_t enabledAttribArrays;
67+
} renderState;
68+
4369
bool initialized = false;
4470
bool inFrame = false;
4571
};

include/modules/data/misc/ZlibCompressor.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ namespace love
8484
{
8585
inflateEnd(&stream);
8686

87-
if (error == Z_NEED_DICT || (error == Z_BUF_ERROR && stream.avail_in == 0))
87+
if (error == Z_NEED_DICT ||
88+
(error == Z_BUF_ERROR && stream.avail_out > 0 && stream.avail_in == 0))
8889
return Z_DATA_ERROR;
8990

9091
return error;

include/modules/graphics/vertex.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ namespace love
423423

424424
size_t getIndexDataSize(IndexDataType type);
425425

426+
size_t getVertexAttributeLocation(BuiltinVertexAttribute attribute);
427+
426428
// clang-format off
427429
STRINGMAP_DECLARE(DataFormats, DataFormat,
428430
{ "float", DATAFORMAT_FLOAT },

platform/cafe/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dkp_track_assets(${PROJECT_NAME}_cafe_content
2020
FILES
2121
color.gsh
2222
texture.gsh
23+
video.gsh
2324
)
2425

2526
dkp_track_assets(${PROJECT_NAME}_cafe_content
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#version 330
2+
3+
layout (location = 0) in vec4 VertexColor;
4+
layout (location = 0) out vec4 VaryingColor;
5+
6+
void main()
7+
{
8+
VaryingColor = VertexColor;
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#version 330
2+
3+
layout (location = 0) in vec4 VertexColor;
4+
layout (location = 1) in vec2 VertexTexCoord;
5+
6+
layout (location = 0) out vec4 VaryingColor;
7+
8+
uniform sampler2D texture0;
9+
10+
void main()
11+
{
12+
VaryingColor = VertexColor * texture(texture0, VertexTexCoord);
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#version 330
2+
3+
layout(location = 0) in vec3 VertexPosition;
4+
layout(location = 1) in vec2 VertexTexCoord;
5+
layout(location = 2) in vec4 VertexColor;
6+
7+
layout(location = 0) out vec4 VaryingColor;
8+
layout(location = 1) out vec2 VaryingTexCoord;
9+
10+
layout(std140) uniform Transformation
11+
{
12+
mat4 mdlvMtx;
13+
mat4 projMtx;
14+
} u;
15+
16+
void main()
17+
{
18+
vec4 pos = u.mdlvMtx * vec4(VertexPosition, 1.0);
19+
gl_Position = u.projMtx * pos;
20+
21+
VaryingColor = VertexColor;
22+
VaryingTexCoord = VertexTexCoord;
23+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#version 330
2+
3+
layout (location = 0) in vec4 VertexColor;
4+
layout (location = 1) in vec2 VertexTexCoord;
5+
6+
layout (location = 0) out vec4 VaryingColor;
7+
8+
uniform sampler2D video_y;
9+
uniform sampler2D video_cb;
10+
uniform sampler2D video_cr;
11+
12+
const vec3 yuv_add = vec3(-0.0627451017, -0.501960814, -0.501960814);
13+
14+
const vec3 yuv_r = vec3(1.164, 0.000, 1.596);
15+
const vec3 yuv_g = vec3(1.164, -0.391, -0.813);
16+
const vec3 yuv_b = vec3(1.164, 2.018, 0.000);
17+
18+
void main()
19+
{
20+
vec3 yuv;
21+
22+
yuv[0] = texture(video_y, VertexTexCoord).r;
23+
yuv[1] = texture(video_cb, VertexTexCoord).r;
24+
yuv[2] = texture(video_cr, VertexTexCoord).r;
25+
26+
yuv += yuv_add;
27+
28+
VaryingColor[0] = dot(yuv, yuv_r);
29+
VaryingColor[1] = dot(yuv, yuv_g);
30+
VaryingColor[2] = dot(yuv, yuv_b);
31+
VaryingColor[3] = 1.0;
32+
}

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

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,48 @@ namespace love
1414
public:
1515
GX2Attribute();
1616

17-
GX2Attribute(bool enabled) : stream {}, enabled(enabled)
18-
{}
19-
2017
GX2Attribute(uint32_t location, int components, GX2AttribFormat format, uint32_t offset);
2118

22-
constexpr std::strong_ordering operator<=>(const GX2Attribute& other) const noexcept = default;
23-
24-
bool operator==(const GX2Attribute& other);
19+
bool operator==(const GX2Attribute& other) const;
2520

2621
operator GX2AttribStream()
2722
{
2823
return this->stream;
2924
}
3025

31-
bool isEnabled() const
26+
GX2Attribute& setLocation(uint32_t location)
3227
{
33-
return this->enabled;
28+
this->stream.location = location;
29+
return *this;
3430
}
3531

36-
void update(uint32_t location, int components, GX2AttribFormat format, uint32_t offset);
32+
GX2Attribute& setFormat(GX2AttribFormat format)
33+
{
34+
this->stream.format = format;
35+
return *this;
36+
}
3737

38-
void setBuffer(uint32_t buffer);
38+
GX2Attribute& setComponents(uint32_t components);
3939

40-
void setEnabled(bool enabled);
40+
GX2Attribute& setOffset(uint32_t offset)
41+
{
42+
this->stream.offset = offset;
43+
return *this;
44+
}
4145

42-
void setDivisor(uint32_t divisor);
46+
GX2Attribute& setBuffer(uint32_t buffer)
47+
{
48+
this->stream.buffer = buffer;
49+
return *this;
50+
}
4351

44-
GX2AttribStream getStream() const
52+
GX2Attribute& setDivisor(uint32_t divisor)
4553
{
46-
return this->stream;
54+
this->stream.aluDivisor = divisor;
55+
return *this;
4756
}
4857

4958
private:
5059
GX2AttribStream stream;
51-
bool enabled;
5260
};
5361
} // namespace love

0 commit comments

Comments
 (0)