Skip to content

Commit

Permalink
pull latest from source
Browse files Browse the repository at this point in the history
  • Loading branch information
ellraiser committed Apr 29, 2024
1 parent 106fd80 commit 8dd80bb
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 15 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ on: [push, pull_request, workflow_dispatch]
jobs:
macos-latest:
runs-on: macos-latest
env:
ALSOFT_CONF: resources/alsoft.conf
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Download Love
run: |
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" --output love12.zip --url "https://api.github.com/repos/love2d/love/actions/artifacts/1348650151/zip"
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" --output love12.zip --url "https://api.github.com/repos/love2d/love/actions/artifacts/1452893104/zip"
7z x love12.zip -o*
7z x love12/love-macos.zip -o*
- name: Run Test Suite
Expand Down Expand Up @@ -50,7 +52,7 @@ jobs:
powershell.exe mesa\systemwidedeploy.cmd 1
- name: Download Love
run: |
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" --output love12.zip --url "https://api.github.com/repos/love2d/love/actions/artifacts/1348654247/zip"
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" --output love12.zip --url "https://api.github.com/repos/love2d/love/actions/artifacts/1452898657/zip"
7z x love12.zip -o*
7z x love12/love-12.0-win64.zip -o*
- name: Run Tests (opengl)
Expand Down Expand Up @@ -147,7 +149,7 @@ jobs:
uses: actions/checkout@v4
- name: Download Love
run: |
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" --output love12.zip --url "https://api.github.com/repos/love2d/love/actions/artifacts/1348653725/zip"
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" --output love12.zip --url "https://api.github.com/repos/love2d/love/actions/artifacts/1452894921/zip"
7z x love12.zip -o*
mv love12/love-*.AppImage love12/love12.AppImage
ls love12
Expand Down
5 changes: 3 additions & 2 deletions classes/TestSuite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ TestSuite = {
tr.red { background: #d26666; color: #111; }
tr.yellow { background: slategrey; }
.wrap { max-width: 800px; padding-top: 30px; margin: auto; position: relative; }
.preview-wrap { display: inline-block; height: 80px; padding: 5px 0 0 5px; margin: 5px; background: rgba(0, 0, 0, 0.1); }
.preview-wrap { transition: none; display: inline-block; height: 80px; padding: 5px 0 0 5px; margin: 5px; background: rgba(0, 0, 0, 0.1); }
.preview { width: 64px; height: 80px; float: left; margin-right: 10px; }
.preview:nth-last-child(1) { margin-right: 5px; }
.preview img { width: 100%; image-rendering: pixelated; }
Expand All @@ -207,12 +207,13 @@ TestSuite = {
.summary li:nth-child(1) { background: #2d9966; min-width: 70px; }
.summary li:nth-child(2) { background: #d26666; min-width: 70px; }
.summary li:nth-child(3) { background: slategrey; min-width: 70px; }
.summary li:nth-child(4) { background: #bbb; min-width: 60px; }
.summary li:nth-child(4) { background: #aaa; min-width: 60px; }
.summary li.l0 { opacity: 0.2; }
.renderer { position: absolute; top: 8px; right: 10px; color: #eee; }
h1 { width: 100%; top: 0; position: absolute; height: 50px; left: 0; }
table .icon.pass { position: relative; width: 8px; height: 8px; border-radius: 8px; margin-left: 6px; }
table .icon.pass:after { content: '✓'; top: -3px; position: absolute; color: #2d9966; font-size: 12px; }
.preview-wrap:hover { transform: scale(2); background: #555; }
</style>
<script type="text/javascript">
function toggle(el) {
Expand Down
3 changes: 3 additions & 0 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ love.load = function(args)
resizable = true,
centered = true
})

-- set up some graphics to draw if enabled
if love.graphics ~= nil then
love.graphics.setDefaultFilter("nearest", "nearest")
love.graphics.setLineStyle('rough')
Expand All @@ -54,6 +56,7 @@ love.load = function(args)
TextCommand = 'Loading...'
TextRun = ''
end

end

-- mount for output later
Expand Down
153 changes: 143 additions & 10 deletions tests/graphics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ love.test.graphics.Canvas = function(test)
test:assertEquals(1, canvas:getDepth(), 'check depth is 2d')
test:assertEquals(nil, canvas:getDepthSampleMode(), 'check depth sample nil')

local maxanisotropy = love.graphics.getSystemLimits().anisotropy

-- check fliter
local min1, mag1, ani1 = canvas:getFilter()
test:assertEquals('nearest', min1, 'check filter def min')
Expand All @@ -131,7 +133,7 @@ love.test.graphics.Canvas = function(test)
local min2, mag2, ani2 = canvas:getFilter()
test:assertEquals('linear', min2, 'check filter changed min')
test:assertEquals('linear', mag2, 'check filter changed mag')
test:assertEquals(2, ani2, 'check filter changed ani')
test:assertEquals(math.min(maxanisotropy, 2), ani2, 'check filter changed ani')

-- check layer
test:assertEquals(1, canvas:getLayerCount(), 'check 1 layer for 2d')
Expand Down Expand Up @@ -201,6 +203,40 @@ love.test.graphics.Canvas = function(test)
local imgdata2 = love.graphics.readbackTexture(canvas)
test:compareImg(imgdata2)

-- check y-down
local shader1 = love.graphics.newShader[[
vec4 effect(vec4 c, Image tex, vec2 tc, vec2 pc) {
return tc.y > 0.5 ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 1.0, 0.0, 1.0);
}
]]
local shader2 = love.graphics.newShader[[
vec4 effect(vec4 c, Image tex, vec2 tc, vec2 pc) {
// rounding during quantization from float to unorm8 doesn't seem to be
// totally consistent across devices, lets do it ourselves.
highp vec2 value = pc / love_ScreenSize.xy;
highp vec2 quantized = (floor(255.0 * value + 0.5) + 0.1) / 255.0;
return vec4(quantized, 0.0, 1.0);
}
]]
local img = love.graphics.newImage(love.image.newImageData(1, 1))

love.graphics.push("all")
love.graphics.setCanvas(canvas)
love.graphics.setShader(shader1)
love.graphics.draw(img, 0, 0, 0, canvas:getDimensions())
love.graphics.pop()
local imgdata3 = love.graphics.readbackTexture(canvas)
test:compareImg(imgdata3)

love.graphics.push("all")
love.graphics.setCanvas(canvas)
love.graphics.setShader(shader2)
love.graphics.draw(img, 0, 0, 0, canvas:getDimensions())
love.graphics.pop()
local imgdata4 = love.graphics.readbackTexture(canvas)
test:compareImg(imgdata4)


-- check depth samples
local dcanvas = love.graphics.newCanvas(100, 100, {
type = '2d',
Expand Down Expand Up @@ -311,6 +347,8 @@ love.test.graphics.Image = function(test)
test:assertEquals(1, image:getDepth(), 'check depth is 2d')
test:assertEquals(nil, image:getDepthSampleMode(), 'check depth sample nil')

local maxanisotropy = love.graphics.getSystemLimits().anisotropy

-- check filter
local min1, mag1, ani1 = image:getFilter()
test:assertEquals('nearest', min1, 'check filter def min')
Expand All @@ -320,7 +358,7 @@ love.test.graphics.Image = function(test)
local min2, mag2, ani2 = image:getFilter()
test:assertEquals('linear', min2, 'check filter changed min')
test:assertEquals('linear', mag2, 'check filter changed mag')
test:assertEquals(2, ani2, 'check filter changed ani')
test:assertEquals(math.min(maxanisotropy, 2), ani2, 'check filter changed ani')
image:setFilter('nearest', 'nearest', 1)

-- check layers
Expand Down Expand Up @@ -430,8 +468,8 @@ love.test.graphics.Mesh = function(test)

-- check def vertex format
local format = mesh1:getVertexFormat()
test:assertEquals('floatvec2', format[2][2], 'check def vertex format 2')
test:assertEquals('VertexColor', format[3][1], 'check def vertex format 3')
test:assertEquals('floatvec2', format[2].format, 'check def vertex format 2')
test:assertEquals('VertexColor', format[3].name, 'check def vertex format 3')

-- check vertext attributes
test:assertTrue(mesh1:isAttributeEnabled('VertexPosition'), 'check def attribute VertexPosition')
Expand Down Expand Up @@ -881,16 +919,90 @@ love.test.graphics.Shader = function(test)
sampler2D tex;
};
uniform Data data[3];
uniform Data data;
uniform Data dataArray[3];
vec4 effect(vec4 vcolor, Image tex, vec2 tc, vec2 pc) {
return data[1].boolValue ? Texel(data[0].tex, tc) : vec4(0.0, 0.0, 0.0, 0.0);
return (data.boolValue && dataArray[1].boolValue) ? Texel(dataArray[0].tex, tc) : vec4(0.0, 0.0, 0.0, 0.0);
}
]]

shader6:send("data[1].boolValue", true)
shader6:send("data[0].tex", canvas2)
shader6:send("data.boolValue", true)
shader6:send("dataArray[1].boolValue", true)
shader6:send("dataArray[0].tex", canvas2)

local shader7 = love.graphics.newShader[[
uniform vec3 vec3s[3];
vec4 effect(vec4 vcolor, Image tex, vec2 tc, vec2 pc) {
return vec4(vec3s[1], 1.0);
}
]]

shader7:send("vec3s", {0, 0, 1}, {0, 1, 0}, {1, 0, 0})

local canvas3 = love.graphics.newCanvas(16, 16)
love.graphics.push("all")
love.graphics.setCanvas(canvas3)
love.graphics.setShader(shader7)
love.graphics.rectangle("fill", 0, 0, 16, 16)
love.graphics.pop()
local imgdata2 = love.graphics.readbackTexture(canvas3)
test:compareImg(imgdata2)

if love.graphics.getSupported().glsl3 then
local shader8 = love.graphics.newShader[[
#pragma language glsl3
#ifdef GL_ES
precision highp float;
#endif
varying vec4 VaryingUnused1;
varying mat3 VaryingMatrix;
flat varying ivec4 VaryingInt;
#ifdef VERTEX
in vec4 VertexPosition;
in ivec4 IntAttributeUnused;
void vertexmain()
{
VaryingMatrix = mat3(vec3(1, 0, 0), vec3(0, 1, 0), vec3(0, 0, 1));
VaryingInt = ivec4(1, 1, 1, 1);
love_Position = TransformProjectionMatrix * VertexPosition;
}
#endif
#ifdef PIXEL
out ivec4 outData;
void pixelmain()
{
outData = ivec4(VaryingMatrix[1][1] > 0.0 ? 1 : 0, 1, VaryingInt.x, 1);
}
#endif
]]

local canvas4 = love.graphics.newCanvas(16, 16, {format="rgba8i"})
love.graphics.push("all")
love.graphics.setBlendMode("none")
love.graphics.setCanvas(canvas4)
love.graphics.setShader(shader8)
love.graphics.rectangle("fill", 0, 0, 16, 16)
love.graphics.pop()

local intimagedata = love.graphics.readbackTexture(canvas4)
local imgdata3 = love.image.newImageData(16, 16, "rgba8")
for y=0, 15 do
for x=0, 15 do
local ir, ig, ib, ia = intimagedata:getInt8(4 * (y * 16 + x), 4)
imgdata3:setPixel(x, y, ir, ig, ib, ia)
end
end
test:compareImg(imgdata3)
else
test:assertTrue(true, "skip shader IO test")
end
end


Expand Down Expand Up @@ -2003,7 +2115,7 @@ end
love.test.graphics.setCanvas = function(test)
-- make 2 canvas, set to each, draw one to the other, check output
local canvas1 = love.graphics.newCanvas(16, 16)
local canvas2 = love.graphics.newCanvas(16, 16)
local canvas2 = love.graphics.newCanvas(16, 16, {mipmaps = "auto"})
love.graphics.setCanvas(canvas1)
test:assertEquals(canvas1, love.graphics.getCanvas(), 'check canvas 1 set')
love.graphics.clear(1, 0, 0, 1)
Expand All @@ -2015,6 +2127,8 @@ love.test.graphics.setCanvas = function(test)
test:assertEquals(nil, love.graphics.getCanvas(), 'check no canvas set')
local imgdata = love.graphics.readbackTexture(canvas2)
test:compareImg(imgdata)
local imgdata2 = love.graphics.readbackTexture(canvas2, 1, 2) -- readback mipmap
test:compareImg(imgdata2)
end


Expand Down Expand Up @@ -2123,6 +2237,23 @@ love.test.graphics.setFrontFaceWinding = function(test)
test:assertEquals('ccw', love.graphics.getFrontFaceWinding(), 'check ffw ccw set')
love.graphics.setFrontFaceWinding(original)
-- @TODO better graphics drawing specific test

local shader = love.graphics.newShader[[
vec4 effect(vec4 c, Image tex, vec2 tc, vec2 pc) {
return gl_FrontFacing ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
}
]]
local dummyimg = love.graphics.newImage(love.image.newImageData(1, 1))

local canvas = love.graphics.newCanvas(16, 16)
love.graphics.push("all")
love.graphics.setCanvas(canvas)
love.graphics.setShader(shader)
love.graphics.draw(dummyimg, 0, 0, 0, 16, 16)
love.graphics.pop()

local imgdata = love.graphics.readbackTexture(canvas)
test:compareImg(imgdata)
end


Expand Down Expand Up @@ -2413,6 +2544,7 @@ love.test.graphics.push = function(test)
love.graphics.setColor(1, 0, 0, 1)
love.graphics.rectangle('fill', 0, 0, 1, 1)
love.graphics.setColor(1, 1, 1, 1)
love.graphics.pop()
love.graphics.setCanvas()
local imgdata = love.graphics.readbackTexture(canvas)
test:compareImg(imgdata)
Expand Down Expand Up @@ -2631,7 +2763,8 @@ love.test.graphics.getTextureFormats = function(test)
'rg11b10f', 'ASTC10x8', 'ASTC10x10', 'ASTC12x10', 'ASTC12x12', 'normal',
'srgba8', 'la8', 'ASTC10x6', 'ASTC8x8', 'ASTC6x6', 'ASTC5x5', 'EACrgs',
'EACrs', 'ETC2rgba1', 'ETC2rgb', 'PVR1rgba4', 'PVR1rgb4', 'BC6h',
'BC5', 'BC4', 'DXT3', 'stencil8', 'rgba16ui', 'bgra8srgb'
'BC5', 'BC4', 'DXT3', 'rgba16ui', 'bgra8srgb',
'depth16', 'depth24', 'depth32f', 'depth24stencil8', 'depth32fstencil8', 'stencil8'
}
local supported = love.graphics.getTextureFormats({ canvas = true })
test:assertNotNil(supported)
Expand Down

0 comments on commit 8dd80bb

Please sign in to comment.