|
@@ -10,56 +10,53 @@
|
|
|
|
|
|
-- GraphicsBuffer (love.graphics.newBuffer)
|
|
-- GraphicsBuffer (love.graphics.newBuffer)
|
|
love.test.graphics.Buffer = function(test)
|
|
love.test.graphics.Buffer = function(test)
|
|
|
|
+
|
|
|
|
+ -- setup vertex data and create some buffers
|
|
local vertexformat = {
|
|
local vertexformat = {
|
|
{name="VertexPosition", format="floatvec2"},
|
|
{name="VertexPosition", format="floatvec2"},
|
|
{name="VertexTexCoord", format="floatvec2"},
|
|
{name="VertexTexCoord", format="floatvec2"},
|
|
{name="VertexColor", format="unorm8vec4"},
|
|
{name="VertexColor", format="unorm8vec4"},
|
|
}
|
|
}
|
|
-
|
|
|
|
local vertexdata = {
|
|
local vertexdata = {
|
|
{0, 0, 0, 0, 1, 0, 1, 1},
|
|
{0, 0, 0, 0, 1, 0, 1, 1},
|
|
{10, 0, 1, 0, 0, 1, 1, 1},
|
|
{10, 0, 1, 0, 0, 1, 1, 1},
|
|
{10, 10, 1, 1, 0, 0, 1, 1},
|
|
{10, 10, 1, 1, 0, 0, 1, 1},
|
|
{0, 10, 0, 1, 1, 0, 0, 1},
|
|
{0, 10, 0, 1, 1, 0, 0, 1},
|
|
}
|
|
}
|
|
-
|
|
|
|
local flatvertexdata = {}
|
|
local flatvertexdata = {}
|
|
for i, vert in ipairs(vertexdata) do
|
|
for i, vert in ipairs(vertexdata) do
|
|
for j, v in ipairs(vert) do
|
|
for j, v in ipairs(vert) do
|
|
table.insert(flatvertexdata, v)
|
|
table.insert(flatvertexdata, v)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
-
|
|
|
|
local vertexbuffer1 = love.graphics.newBuffer(vertexformat, 4, {vertex=true, debugname='testvertexbuffer'})
|
|
local vertexbuffer1 = love.graphics.newBuffer(vertexformat, 4, {vertex=true, debugname='testvertexbuffer'})
|
|
local vertexbuffer2 = love.graphics.newBuffer(vertexformat, vertexdata, {vertex=true})
|
|
local vertexbuffer2 = love.graphics.newBuffer(vertexformat, vertexdata, {vertex=true})
|
|
-
|
|
|
|
test:assertObject(vertexbuffer1)
|
|
test:assertObject(vertexbuffer1)
|
|
test:assertObject(vertexbuffer2)
|
|
test:assertObject(vertexbuffer2)
|
|
|
|
|
|
|
|
+ -- check buffer properties
|
|
test:assertEquals(4, vertexbuffer1:getElementCount(), 'check vertex count 1')
|
|
test:assertEquals(4, vertexbuffer1:getElementCount(), 'check vertex count 1')
|
|
test:assertEquals(4, vertexbuffer2:getElementCount(), 'check vertex count 2')
|
|
test:assertEquals(4, vertexbuffer2:getElementCount(), 'check vertex count 2')
|
|
-
|
|
|
|
-- vertex buffers have their elements tightly packed.
|
|
-- vertex buffers have their elements tightly packed.
|
|
test:assertEquals(20, vertexbuffer1:getElementStride(), 'check vertex array stride')
|
|
test:assertEquals(20, vertexbuffer1:getElementStride(), 'check vertex array stride')
|
|
-
|
|
|
|
test:assertEquals(20 * 4, vertexbuffer1:getSize(), 'check vertex buffer size')
|
|
test:assertEquals(20 * 4, vertexbuffer1:getSize(), 'check vertex buffer size')
|
|
-
|
|
|
|
vertexbuffer1:setArrayData(vertexdata)
|
|
vertexbuffer1:setArrayData(vertexdata)
|
|
vertexbuffer1:setArrayData(flatvertexdata)
|
|
vertexbuffer1:setArrayData(flatvertexdata)
|
|
-
|
|
|
|
vertexbuffer1:clear(8, 8) -- partial clear (the first texcoord)
|
|
vertexbuffer1:clear(8, 8) -- partial clear (the first texcoord)
|
|
|
|
|
|
|
|
+ -- check buffer types
|
|
test:assertTrue(vertexbuffer1:isBufferType('vertex'), 'check is vertex buffer')
|
|
test:assertTrue(vertexbuffer1:isBufferType('vertex'), 'check is vertex buffer')
|
|
test:assertFalse(vertexbuffer1:isBufferType('index'), 'check is not index buffer')
|
|
test:assertFalse(vertexbuffer1:isBufferType('index'), 'check is not index buffer')
|
|
test:assertFalse(vertexbuffer1:isBufferType('texel'), 'check is not texel buffer')
|
|
test:assertFalse(vertexbuffer1:isBufferType('texel'), 'check is not texel buffer')
|
|
test:assertFalse(vertexbuffer1:isBufferType('shaderstorage'), 'check is not shader storage buffer')
|
|
test:assertFalse(vertexbuffer1:isBufferType('shaderstorage'), 'check is not shader storage buffer')
|
|
|
|
|
|
|
|
+ -- check debug name
|
|
test:assertEquals('testvertexbuffer', vertexbuffer1:getDebugName(), 'check buffer debug name')
|
|
test:assertEquals('testvertexbuffer', vertexbuffer1:getDebugName(), 'check buffer debug name')
|
|
|
|
|
|
|
|
+ -- check buffer format and format properties
|
|
local format = vertexbuffer1:getFormat()
|
|
local format = vertexbuffer1:getFormat()
|
|
test:assertEquals('table', type(format), 'check buffer format is table')
|
|
test:assertEquals('table', type(format), 'check buffer format is table')
|
|
test:assertEquals(#vertexformat, #format, 'check buffer format length')
|
|
test:assertEquals(#vertexformat, #format, 'check buffer format length')
|
|
-
|
|
|
|
for i, v in ipairs(vertexformat) do
|
|
for i, v in ipairs(vertexformat) do
|
|
test:assertEquals(v.name, format[i].name, string.format('check buffer format %d name', i))
|
|
test:assertEquals(v.name, format[i].name, string.format('check buffer format %d name', i))
|
|
test:assertEquals(v.format, format[i].format, string.format('check buffer format %d format', i))
|
|
test:assertEquals(v.format, format[i].format, string.format('check buffer format %d format', i))
|
|
@@ -67,8 +64,10 @@ love.test.graphics.Buffer = function(test)
|
|
test:assertNotNil(format[i].offset)
|
|
test:assertNotNil(format[i].offset)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+ -- check index buffer
|
|
local indexbuffer = love.graphics.newBuffer('uint16', 128, {index=true})
|
|
local indexbuffer = love.graphics.newBuffer('uint16', 128, {index=true})
|
|
test:assertTrue(indexbuffer:isBufferType('index'), 'check is index buffer')
|
|
test:assertTrue(indexbuffer:isBufferType('index'), 'check is index buffer')
|
|
|
|
+
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -80,22 +79,22 @@ love.test.graphics.ShaderStorageBuffer = function(test)
|
|
return
|
|
return
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+ -- setup buffer
|
|
local format = {
|
|
local format = {
|
|
{ name="1", format="float" },
|
|
{ name="1", format="float" },
|
|
{ name="2", format="floatmat4x4" },
|
|
{ name="2", format="floatmat4x4" },
|
|
{ name="3", format="floatvec2" }
|
|
{ name="3", format="floatvec2" }
|
|
}
|
|
}
|
|
-
|
|
|
|
local buffer = love.graphics.newBuffer(format, 1, {shaderstorage = true})
|
|
local buffer = love.graphics.newBuffer(format, 1, {shaderstorage = true})
|
|
-
|
|
|
|
test:assertEquals(96, buffer:getElementStride(), 'check shader storage buffer element stride')
|
|
test:assertEquals(96, buffer:getElementStride(), 'check shader storage buffer element stride')
|
|
|
|
|
|
|
|
+ -- set new data
|
|
local data = {}
|
|
local data = {}
|
|
for i = 1, 19 do
|
|
for i = 1, 19 do
|
|
data[i] = 0
|
|
data[i] = 0
|
|
end
|
|
end
|
|
-
|
|
|
|
buffer:setArrayData(data)
|
|
buffer:setArrayData(data)
|
|
|
|
+
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -1170,7 +1169,7 @@ love.test.graphics.arc = function(test)
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
love.graphics.setCanvas()
|
|
love.graphics.setCanvas()
|
|
local imgdata3 = love.graphics.readbackTexture(canvas)
|
|
local imgdata3 = love.graphics.readbackTexture(canvas)
|
|
- if GITHUB_RUNNER and love.system.getOS() == 'OS X' then
|
|
|
|
|
|
+ if GITHUB_RUNNER and test:isOS('OS X') then
|
|
-- on macosx runners, the arcs are not drawn as accurately at low res
|
|
-- on macosx runners, the arcs are not drawn as accurately at low res
|
|
-- there's a couple pixels different in the curve of the arc but as we
|
|
-- there's a couple pixels different in the curve of the arc but as we
|
|
-- are at such a low resolution I think that can be expected
|
|
-- are at such a low resolution I think that can be expected
|
|
@@ -1468,7 +1467,7 @@ love.test.graphics.captureScreenshot = function(test)
|
|
TextCommand = prevtextcommand
|
|
TextCommand = prevtextcommand
|
|
test:assertNotNil(cbdata)
|
|
test:assertNotNil(cbdata)
|
|
|
|
|
|
- if love.system.getOS() == "iOS" or love.system.getOS() == "Android" then
|
|
|
|
|
|
+ if test:isOS({'iOS', 'Android'}) then
|
|
-- Mobile operating systems don't let us control the window resolution,
|
|
-- Mobile operating systems don't let us control the window resolution,
|
|
-- so we can't compare the reference image properly.
|
|
-- so we can't compare the reference image properly.
|
|
test:assertTrue(true, 'skip test')
|
|
test:assertTrue(true, 'skip test')
|
|
@@ -1586,7 +1585,7 @@ love.test.graphics.newSpriteBatch = function(test)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
--- love.graphics.newText
|
|
|
|
|
|
+-- love.graphics.newTextBatch
|
|
-- @NOTE this is just basic nil checking, objs have their own test method
|
|
-- @NOTE this is just basic nil checking, objs have their own test method
|
|
love.test.graphics.newTextBatch = function(test)
|
|
love.test.graphics.newTextBatch = function(test)
|
|
local font = love.graphics.newFont('resources/font.ttf')
|
|
local font = love.graphics.newFont('resources/font.ttf')
|
|
@@ -1594,6 +1593,14 @@ love.test.graphics.newTextBatch = function(test)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
+-- love.graphics.newTexture
|
|
|
|
+-- @NOTE this is just basic nil checking, objs have their own test method
|
|
|
|
+love.test.graphics.newTexture = function(test)
|
|
|
|
+ local imgdata = love.image.newImageData('resources/love.png')
|
|
|
|
+ test:assertObject(love.graphics.newTexture(imgdata))
|
|
|
|
+end
|
|
|
|
+
|
|
|
|
+
|
|
-- love.graphics.newVideo
|
|
-- love.graphics.newVideo
|
|
-- @NOTE this is just basic nil checking, objs have their own test method
|
|
-- @NOTE this is just basic nil checking, objs have their own test method
|
|
love.test.graphics.newVideo = function(test)
|
|
love.test.graphics.newVideo = function(test)
|
|
@@ -2167,7 +2174,7 @@ love.test.graphics.setLineStyle = function(test)
|
|
love.graphics.setCanvas()
|
|
love.graphics.setCanvas()
|
|
local imgdata = love.graphics.readbackTexture(canvas)
|
|
local imgdata = love.graphics.readbackTexture(canvas)
|
|
-- linux runner needs a 1/255 tolerance for the blend between a rough line + bg
|
|
-- linux runner needs a 1/255 tolerance for the blend between a rough line + bg
|
|
- if GITHUB_RUNNER and love.system.getOS() == 'Linux' then
|
|
|
|
|
|
+ if GITHUB_RUNNER and test:isOS('Linux') then
|
|
test.rgba_tolerance = 1
|
|
test.rgba_tolerance = 1
|
|
end
|
|
end
|
|
test:compareImg(imgdata)
|
|
test:compareImg(imgdata)
|
|
@@ -2300,7 +2307,7 @@ love.test.graphics.setWireframe = function(test)
|
|
love.graphics.setWireframe(false)
|
|
love.graphics.setWireframe(false)
|
|
local imgdata = love.graphics.readbackTexture(canvas)
|
|
local imgdata = love.graphics.readbackTexture(canvas)
|
|
-- on macOS runners wireframes are drawn 1px off from the target
|
|
-- on macOS runners wireframes are drawn 1px off from the target
|
|
- if GITHUB_RUNNER and love.system.getOS() == 'OS X' then
|
|
|
|
|
|
+ if GITHUB_RUNNER and test:isOS('OS X') then
|
|
test.pixel_tolerance = 1
|
|
test.pixel_tolerance = 1
|
|
end
|
|
end
|
|
test:compareImg(imgdata)
|
|
test:compareImg(imgdata)
|
|
@@ -2667,8 +2674,8 @@ love.test.graphics.getSupported = function(test)
|
|
'clampzero', 'lighten', 'glsl3', 'instancing', 'fullnpot',
|
|
'clampzero', 'lighten', 'glsl3', 'instancing', 'fullnpot',
|
|
'pixelshaderhighp', 'shaderderivatives', 'indirectdraw', 'mipmaprange',
|
|
'pixelshaderhighp', 'shaderderivatives', 'indirectdraw', 'mipmaprange',
|
|
'copyrendertargettobuffer', 'copytexturetobuffer', 'copybuffer',
|
|
'copyrendertargettobuffer', 'copytexturetobuffer', 'copybuffer',
|
|
- 'indexbuffer32bit', 'multirendertargetformats', 'clampone', 'blendminmax',
|
|
|
|
- 'glsl4'
|
|
|
|
|
|
+ 'copybuffertotexture', 'indexbuffer32bit', 'multirendertargetformats',
|
|
|
|
+ 'clampone', 'blendminmax', 'glsl4'
|
|
}
|
|
}
|
|
local features = love.graphics.getSupported()
|
|
local features = love.graphics.getSupported()
|
|
for g=1,#gfs do
|
|
for g=1,#gfs do
|