Skip to content
Snippets Groups Projects
Commit 44d26200 authored by Philip Trettner's avatar Philip Trettner
Browse files

Re-enabled all tests, fixed some issues, update submodules and cmake

parent 9778b437
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -16,11 +16,11 @@ add_subdirectory(glow-extras)
target_link_libraries(GlowTests PUBLIC glow-extras)
# Add GLFW lib (with disabled spam)
set(GLFW_BUILD_EXAMPLES OFF)
set(GLFW_BUILD_TESTS OFF)
set(GLFW_BUILD_DOCS OFF)
set(GLFW_INSTALL OFF)
set(BUILD_SHARED_LIBS ON)
option(GLFW_BUILD_EXAMPLES "" OFF)
option(GLFW_BUILD_TESTS "" OFF)
option(GLFW_BUILD_DOCS "" OFF)
option(GLFW_INSTALL "" OFF)
option(BUILD_SHARED_LIBS "" ON)
add_subdirectory(glfw)
target_link_libraries(GlowTests PUBLIC glfw)
......
glow @ e9b5dd26
Subproject commit 29d05e0d60621ce9c3cdc253e10ee477151e607c
Subproject commit e9b5dd26da3a005ec6ddcfdbfc07fdaed39b1271
glow-extras @ 1ed66566
Subproject commit 4cf8fab1ef08dd3ed39babe9d2637a46da390d4f
Subproject commit 1ed665667ad38bbf63b7844aa1f12fa902ad9567
......@@ -32,9 +32,11 @@ struct Particle140
std140vec3 pos;
std140mat3 frame;
};
const bool extensiveTest = false;
}
GLOW_TEST(DISABLED_RandomVRAM, ComputeSSBO_LocalSize)
GLOW_TEST(RandomVRAM, ComputeSSBO_LocalSize)
{
std::fstream fileRandom(util::pathOf(__FILE__) + "/vram-random-compute-ssbo.csh");
std::fstream fileSerial(util::pathOf(__FILE__) + "/vram-serial-compute-ssbo.csh");
......@@ -44,7 +46,7 @@ GLOW_TEST(DISABLED_RandomVRAM, ComputeSSBO_LocalSize)
const int reps = 10;
const int maxLocalSize = 64;
const int localSizeInc = 2;
const int maxVramMB = 256;
const int maxVramMB = extensiveTest ? 256 : 32;
const int vramInc = 16;
std::vector<int> localSizes;
......@@ -159,7 +161,7 @@ GLOW_TEST(DISABLED_RandomVRAM, ComputeSSBO_LocalSize)
}
}
GLOW_TEST(DISABLED_RandomVRAM, ComputeSSBO_VsSerial)
GLOW_TEST(RandomVRAM, ComputeSSBO_VsSerial)
{
std::fstream fileRandom(util::pathOf(__FILE__) + "/vram-random-compute-ssbo.csh");
std::fstream fileSerial(util::pathOf(__FILE__) + "/vram-serial-compute-ssbo.csh");
......@@ -168,7 +170,7 @@ GLOW_TEST(DISABLED_RandomVRAM, ComputeSSBO_VsSerial)
const int reps = 10;
const int localSize = 4;
const int maxVramMB = 512;
const int maxVramMB = extensiveTest ? 512 : 64;
const int vramInc = 16;
std::vector<std::vector<std::string>> table;
......@@ -269,7 +271,7 @@ GLOW_TEST(DISABLED_RandomVRAM, ComputeSSBO_VsSerial)
}
}
GLOW_TEST(DISABLED_RandomVRAM, Texture)
GLOW_TEST(RandomVRAM, Texture)
{
auto shaderRandom = Program::createFromFiles(
{util::pathOf(__FILE__) + "/vram-random-texture.fsh", util::pathOf(__FILE__) + "/vram-texture.vsh"});
......@@ -279,7 +281,7 @@ GLOW_TEST(DISABLED_RandomVRAM, Texture)
{util::pathOf(__FILE__) + "/vram-texture-fill.fsh", util::pathOf(__FILE__) + "/vram-texture.vsh"});
const int reps = 10;
const int maxTexSize = 4096 + 128 * 8;
const int maxTexSize = extensiveTest ? 4096 + 128 * 8 : 512;
const int texInc = 128;
const int texStart = 128 * 2;
......@@ -383,3 +385,118 @@ GLOW_TEST(DISABLED_RandomVRAM, Texture)
debug() << "Wrote to " << filename;
}
}
GLOW_TEST(RandomVRAM, TextureImage)
{
auto shaderRandom = Program::createFromFiles(
{util::pathOf(__FILE__) + "/vram-random-image.fsh", util::pathOf(__FILE__) + "/vram-texture.vsh"});
auto shaderSerial = Program::createFromFiles(
{util::pathOf(__FILE__) + "/vram-serial-image.fsh", util::pathOf(__FILE__) + "/vram-texture.vsh"});
auto shaderFill = Program::createFromFiles(
{util::pathOf(__FILE__) + "/vram-texture-fill.fsh", util::pathOf(__FILE__) + "/vram-texture.vsh"});
const int reps = 10;
const int maxTexSize = extensiveTest ? 4096 + 128 * 8 : 512;
const int texInc = 128;
const int texStart = 128 * 2;
std::vector<std::vector<std::string>> table;
{ // first col
std::vector<std::string> col;
col.push_back("Buffer Size");
for (auto texSize = texStart; texSize <= maxTexSize; texSize += texInc)
col.push_back(fmt::format("{}", texSize * texSize * sizeof(glm::vec4) / 1024 / 1024));
table.push_back(col);
}
std::vector<std::string> colRandom;
colRandom.push_back("Random");
std::vector<std::string> colSerial;
colSerial.push_back("Serial");
auto quad = glow::geometry::Quad<>().generate();
auto vao = quad->bind();
glow::restoreDefaultOpenGLState();
for (auto texSize = texStart; texSize <= maxTexSize; texSize += texInc)
{
debug() << "VRAM " << texSize << " x " << texSize << " = " << texSize * texSize * sizeof(glm::vec4) / 1024 / 1024 << " MB";
scoped::viewport vp(0, 0, texSize, texSize);
auto texIn = TextureRectangle::createStorageImmutable(texSize, texSize, GL_RGBA32F);
auto texOut = TextureRectangle::createStorageImmutable(texSize, texSize, GL_RGBA32F);
{
auto tf = Framebuffer::create({{"fOut", texIn}});
auto f = tf->bind();
auto s = shaderFill->use();
s.setTexture("uTexIn", texOut);
vao.draw();
}
auto fbo = Framebuffer::create({{"fOut", texOut}});
{
auto s = shaderFill->use();
s.setTexture("uTexIn", texIn);
vao.draw();
}
auto bfbo = fbo->bind();
TimerQuery q;
double timeRandom, timeSerial;
{
auto s = shaderRandom->use();
s.setImage(0, texIn);
vao.draw(); // once
vao.draw(); // twice
q.begin();
for (int i = 0; i < reps; ++i)
vao.draw();
q.end();
timeRandom = TimerQuery::toSeconds(q.getResult64()) / reps;
colRandom.push_back(fmt::format("{}", timeRandom * 1000.));
}
{
auto s = shaderSerial->use();
s.setImage(0, texIn);
vao.draw(); // once
vao.draw(); // twice
q.begin();
for (int i = 0; i < reps; ++i)
vao.draw();
q.end();
timeSerial = TimerQuery::toSeconds(q.getResult64()) / reps;
colSerial.push_back(fmt::format("{}", timeSerial * 1000.));
}
}
table.push_back(colSerial);
table.push_back(colRandom);
// write table
{
auto const filename = "/tmp/ComputeSSBO_Image.csv";
{
std::ofstream file(filename);
for (auto y = 0u; y < table[0].size(); ++y)
{
for (auto x = 0u; x < table.size(); ++x)
{
if (x > 0)
file << ";";
file << table[x][y];
}
file << "\n";
}
}
debug() << "Wrote to " << filename;
}
}
#version 430 core
uniform layout(rgba32f, binding=0) readonly image2DRect uTexIn;
out vec4 fOut;
uint wang_hash(uint seed)
{
seed = (seed ^ 61) ^ (seed >> 16);
seed *= 9;
seed = seed ^ (seed >> 4);
seed *= 0x27d4eb2d;
seed = seed ^ (seed >> 15);
return seed;
}
void main() {
ivec2 size = imageSize(uTexIn);
uint idx = uint(gl_FragCoord.x) + uint(gl_FragCoord.y) * uint(size.x);
idx = wang_hash(idx);
uint x = idx % size.x;
uint y = (idx / size.x) % size.y;
fOut = imageLoad(uTexIn, ivec2(x, y));
}
#version 430 core
uniform layout(rgba32f, binding=0) readonly image2DRect uTexIn;
out vec4 fOut;
void main() {
ivec2 size = imageSize(uTexIn);
uint idx = uint(gl_FragCoord.x) + uint(gl_FragCoord.y) * uint(size.x);
//idx = wang_hash(idx);
uint x = idx % size.x;
uint y = (idx / size.x) % size.y;
fOut = imageLoad(uTexIn, ivec2(x, y));
//fOut = texture(uTexIn, gl_FragCoord.xy);
}
......@@ -2,6 +2,7 @@
#include <glow/data/TextureData.hh>
#include <glow/data/SurfaceData.hh>
#include <glow/common/str_utils.hh>
using namespace glow;
......@@ -16,7 +17,7 @@ TEST(TextureData, STB)
"test-grey.jpg", //
"test-grey.tga"})
{
auto tex = TextureData::createFromFile("textures/" + file);
auto tex = TextureData::createFromFile(util::pathOf(__FILE__) + "/../../bin/textures/" + file);
ASSERT_NE(tex, nullptr);
ASSERT_EQ(tex->getWidth(), 3u);
ASSERT_EQ(tex->getHeight(), 2u);
......@@ -33,7 +34,7 @@ TEST(TextureData, STB)
for (std::string file : {"test-rgba.tga", //
"test-rgb.gif"})
{
auto tex = TextureData::createFromFile("textures/" + file);
auto tex = TextureData::createFromFile(util::pathOf(__FILE__) + "/../../bin/textures/" + file);
ASSERT_NE(tex, nullptr);
ASSERT_EQ(tex->getWidth(), 3u);
ASSERT_EQ(tex->getHeight(), 2u);
......@@ -54,7 +55,7 @@ TEST(TextureData, LodePNG)
"test-rgba.png", //
"test-grey.png"})
{
auto tex = TextureData::createFromFile("textures/" + file);
auto tex = TextureData::createFromFile(util::pathOf(__FILE__) + "/../../bin/textures/" + file);
ASSERT_NE(tex, nullptr);
ASSERT_EQ(tex->getWidth(), 3u);
ASSERT_EQ(tex->getHeight(), 2u);
......
......@@ -2,6 +2,7 @@
#include <glow/objects/Framebuffer.hh>
#include <glow/objects/Texture2D.hh>
#include <glow/objects/TextureRectangle.hh>
GLOW_TEST(Framebuffer, Binding)
{
......@@ -41,3 +42,13 @@ GLOW_TEST(Framebuffer, Attach)
ASSERT_TRUE(bfbo.checkComplete());
}
GLOW_TEST(Framebuffer, StorageImmutable)
{
auto tex = TextureRectangle::createStorageImmutable(4, 4, GL_RGBA32F);
auto fbo = Framebuffer::create();
auto bfbo = fbo->bind();
bfbo.attachColor("A", tex);
ASSERT_TRUE(bfbo.checkComplete());
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment