mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Fix] (MG_Test|MG_Bench): Fix compilation.
This commit is contained in:
@@ -61,7 +61,7 @@ static void BM_CreateBufferObjectsAndBindBuffer(benchmark::State& state) {
|
|||||||
BENCHMARK(BM_CreateBufferObjectsAndBindBuffer)->Unit(benchmark::kMillisecond)->UseRealTime();
|
BENCHMARK(BM_CreateBufferObjectsAndBindBuffer)->Unit(benchmark::kMillisecond)->UseRealTime();
|
||||||
|
|
||||||
static void BM_DeleteBufferObjects(benchmark::State& state) {
|
static void BM_DeleteBufferObjects(benchmark::State& state) {
|
||||||
MG_Initialize();
|
Initialize();
|
||||||
std::vector<GLuint> buffers(BUFFER_COUNT);
|
std::vector<GLuint> buffers(BUFFER_COUNT);
|
||||||
|
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
@@ -179,7 +179,7 @@ static void BM_UpdateDataPartially(benchmark::State& state) {
|
|||||||
BENCHMARK(BM_UpdateDataPartially)->Unit(benchmark::kMillisecond)->UseRealTime();
|
BENCHMARK(BM_UpdateDataPartially)->Unit(benchmark::kMillisecond)->UseRealTime();
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
MG_Initialize();
|
Initialize();
|
||||||
benchmark ::MaybeReenterWithoutASLR(argc, argv);
|
benchmark ::MaybeReenterWithoutASLR(argc, argv);
|
||||||
char arg0_default[] = "benchmark";
|
char arg0_default[] = "benchmark";
|
||||||
char* args_default = reinterpret_cast<char*>(arg0_default);
|
char* args_default = reinterpret_cast<char*>(arg0_default);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void main(){
|
|||||||
// Use TestMat2 and TestMat3 to prevent optimization
|
// Use TestMat2 and TestMat3 to prevent optimization
|
||||||
vec2 dummy2 = TestMat2[0];
|
vec2 dummy2 = TestMat2[0];
|
||||||
vec3 dummy3 = TestMat3[0];
|
vec3 dummy3 = TestMat3[0];
|
||||||
|
|
||||||
oneTexel = (1.0 * (fIn1 * fIn2 * fIn3 * fIn4 * fIn5 * fIn6)) / InSize;
|
oneTexel = (1.0 * (fIn1 * fIn2 * fIn3 * fIn4 * fIn5 * fIn6)) / InSize;
|
||||||
|
|
||||||
texCoord = Position.xy / OutSize;
|
texCoord = Position.xy / OutSize;
|
||||||
@@ -221,7 +221,7 @@ static void BM_CompileAndLink(benchmark::State& state) {
|
|||||||
BENCHMARK(BM_CompileAndLink)->Unit(benchmark::kMillisecond);
|
BENCHMARK(BM_CompileAndLink)->Unit(benchmark::kMillisecond);
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
MG_Initialize();
|
Initialize();
|
||||||
benchmark ::MaybeReenterWithoutASLR(argc, argv);
|
benchmark ::MaybeReenterWithoutASLR(argc, argv);
|
||||||
char arg0_default[] = "benchmark";
|
char arg0_default[] = "benchmark";
|
||||||
char* args_default = reinterpret_cast<char*>(arg0_default);
|
char* args_default = reinterpret_cast<char*>(arg0_default);
|
||||||
@@ -234,4 +234,4 @@ int main(int argc, char** argv) {
|
|||||||
::benchmark ::RunSpecifiedBenchmarks();
|
::benchmark ::RunSpecifiedBenchmarks();
|
||||||
::benchmark ::Shutdown();
|
::benchmark ::Shutdown();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <GLFW/glfw3native.h>
|
#include <GLFW/glfw3native.h>
|
||||||
@@ -44,8 +44,8 @@
|
|||||||
#undef NO_GL_H
|
#undef NO_GL_H
|
||||||
|
|
||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
void MG_Initialize();
|
void Initialize();
|
||||||
}
|
} // namespace MobileGL
|
||||||
|
|
||||||
static bool CheckShaderCompile(GLuint shader, const char* label) {
|
static bool CheckShaderCompile(GLuint shader, const char* label) {
|
||||||
GLint status = GL_FALSE;
|
GLint status = GL_FALSE;
|
||||||
@@ -94,12 +94,7 @@ static bool CheckProgramLink(GLuint program) {
|
|||||||
int main() {
|
int main() {
|
||||||
glfwInit();
|
glfwInit();
|
||||||
|
|
||||||
static EGLint const attribute_list[] = {
|
static EGLint const attribute_list[] = {EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_NONE};
|
||||||
EGL_RED_SIZE, 8,
|
|
||||||
EGL_GREEN_SIZE, 8,
|
|
||||||
EGL_BLUE_SIZE, 8,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
eglInitialize(display, nullptr, nullptr);
|
eglInitialize(display, nullptr, nullptr);
|
||||||
@@ -134,7 +129,7 @@ int main() {
|
|||||||
EGLSurface surface = eglCreateWindowSurface(display, config, nativewindow, nullptr);
|
EGLSurface surface = eglCreateWindowSurface(display, config, nativewindow, nullptr);
|
||||||
eglMakeCurrent(display, surface, surface, context);
|
eglMakeCurrent(display, surface, surface, context);
|
||||||
|
|
||||||
MobileGL::MG_Initialize();
|
MobileGL::Initialize();
|
||||||
|
|
||||||
GLuint offscreenTex = 0;
|
GLuint offscreenTex = 0;
|
||||||
GLuint offscreenFbo = 0;
|
GLuint offscreenFbo = 0;
|
||||||
@@ -166,12 +161,8 @@ int main() {
|
|||||||
GLuint shapeVbo = 0;
|
GLuint shapeVbo = 0;
|
||||||
glGenBuffers(1, &shapeVbo);
|
glGenBuffers(1, &shapeVbo);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, shapeVbo);
|
glBindBuffer(GL_ARRAY_BUFFER, shapeVbo);
|
||||||
glBufferData(
|
glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>((kMaxSegments + 1) * 5 * sizeof(GLfloat)), nullptr,
|
||||||
GL_ARRAY_BUFFER,
|
GL_DYNAMIC_DRAW);
|
||||||
static_cast<GLsizeiptr>((kMaxSegments + 1) * 5 * sizeof(GLfloat)),
|
|
||||||
nullptr,
|
|
||||||
GL_DYNAMIC_DRAW
|
|
||||||
);
|
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, static_cast<GLsizei>(5 * sizeof(GLfloat)), nullptr);
|
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, static_cast<GLsizei>(5 * sizeof(GLfloat)), nullptr);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, static_cast<GLsizei>(5 * sizeof(GLfloat)),
|
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, static_cast<GLsizei>(5 * sizeof(GLfloat)),
|
||||||
@@ -181,12 +172,8 @@ int main() {
|
|||||||
GLuint shapeIbo = 0;
|
GLuint shapeIbo = 0;
|
||||||
glGenBuffers(1, &shapeIbo);
|
glGenBuffers(1, &shapeIbo);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shapeIbo);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shapeIbo);
|
||||||
glBufferData(
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(kMaxSegments * 3 * sizeof(GLushort)), nullptr,
|
||||||
GL_ELEMENT_ARRAY_BUFFER,
|
GL_DYNAMIC_DRAW);
|
||||||
static_cast<GLsizeiptr>(kMaxSegments * 3 * sizeof(GLushort)),
|
|
||||||
nullptr,
|
|
||||||
GL_DYNAMIC_DRAW
|
|
||||||
);
|
|
||||||
|
|
||||||
static constexpr const char* kVertexShaderSource = R"(#version 330 core
|
static constexpr const char* kVertexShaderSource = R"(#version 330 core
|
||||||
layout(location = 0) in vec2 aPos;
|
layout(location = 0) in vec2 aPos;
|
||||||
@@ -231,7 +218,7 @@ void main() {
|
|||||||
std::vector<GLfloat> dynamicVertices(static_cast<size_t>((kMaxSegments + 1) * 5));
|
std::vector<GLfloat> dynamicVertices(static_cast<size_t>((kMaxSegments + 1) * 5));
|
||||||
std::vector<GLushort> dynamicIndices(static_cast<size_t>(kMaxSegments * 3));
|
std::vector<GLushort> dynamicIndices(static_cast<size_t>(kMaxSegments * 3));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(!glfwWindowShouldClose(window)) {
|
while (!glfwWindowShouldClose(window)) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
GLint framebufferWidth = kWindowWidth;
|
GLint framebufferWidth = kWindowWidth;
|
||||||
@@ -247,7 +234,8 @@ void main() {
|
|||||||
|
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, offscreenFbo);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, offscreenFbo);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
glBlitFramebuffer(0, 0, 256, 256, 0, 0, framebufferWidth, framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
glBlitFramebuffer(0, 0, 256, 256, 0, 0, framebufferWidth, framebufferHeight, GL_COLOR_BUFFER_BIT,
|
||||||
|
GL_NEAREST);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
} else {
|
} else {
|
||||||
const int segmentCount = std::min(kMaxSegments, 3 + (i / 100));
|
const int segmentCount = std::min(kMaxSegments, 3 + (i / 100));
|
||||||
@@ -287,9 +275,11 @@ void main() {
|
|||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, shapeVbo);
|
glBindBuffer(GL_ARRAY_BUFFER, shapeVbo);
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, static_cast<GLsizeiptr>(vertexFloatCount * sizeof(GLfloat)), dynamicVertices.data());
|
glBufferSubData(GL_ARRAY_BUFFER, 0, static_cast<GLsizeiptr>(vertexFloatCount * sizeof(GLfloat)),
|
||||||
|
dynamicVertices.data());
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shapeIbo);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shapeIbo);
|
||||||
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, static_cast<GLsizeiptr>(indexCount * sizeof(GLushort)), dynamicIndices.data());
|
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, static_cast<GLsizeiptr>(indexCount * sizeof(GLushort)),
|
||||||
|
dynamicIndices.data());
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(indexCount), GL_UNSIGNED_SHORT, nullptr);
|
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(indexCount), GL_UNSIGNED_SHORT, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ using namespace MobileGL;
|
|||||||
|
|
||||||
class BufferTest : public ::testing::Test {
|
class BufferTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override { MobileGL::MG_Initialize(); }
|
void SetUp() override { MobileGL::Initialize(); }
|
||||||
|
|
||||||
void TearDown() override {}
|
void TearDown() override {}
|
||||||
};
|
};
|
||||||
@@ -543,4 +543,4 @@ TEST_F(GeneralBufferTest, General_GeneralTest_1) {
|
|||||||
DeleteBuffers(2, toDelete);
|
DeleteBuffers(2, toDelete);
|
||||||
|
|
||||||
EXPECT_EQ(GetError(), GL_NO_ERROR);
|
EXPECT_EQ(GetError(), GL_NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using namespace MobileGL::MG_Impl::GLImpl;
|
|||||||
|
|
||||||
class ProgramTest : public ::testing::Test {
|
class ProgramTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override { MobileGL::MG_Initialize(); }
|
void SetUp() override { MobileGL::Initialize(); }
|
||||||
|
|
||||||
void TearDown() override {}
|
void TearDown() override {}
|
||||||
};
|
};
|
||||||
@@ -54,7 +54,7 @@ void main(){
|
|||||||
// Use TestMat2 and TestMat3 to prevent optimization
|
// Use TestMat2 and TestMat3 to prevent optimization
|
||||||
vec2 dummy2 = TestMat2[0];
|
vec2 dummy2 = TestMat2[0];
|
||||||
vec3 dummy3 = TestMat3[0];
|
vec3 dummy3 = TestMat3[0];
|
||||||
|
|
||||||
oneTexel = (1.0 * (fIn1 * fIn2 * fIn3 * fIn4 * fIn5 * fIn6 * fIn0)) / InSize;
|
oneTexel = (1.0 * (fIn1 * fIn2 * fIn3 * fIn4 * fIn5 * fIn6 * fIn0)) / InSize;
|
||||||
|
|
||||||
texCoord = Position.xy / OutSize;
|
texCoord = Position.xy / OutSize;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ using namespace MobileGL;
|
|||||||
|
|
||||||
class ProgramUtilTest : public ::testing::Test {
|
class ProgramUtilTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
void SetUp() override { MobileGL::MG_Initialize(); }
|
void SetUp() override { MobileGL::Initialize(); }
|
||||||
|
|
||||||
void TearDown() override {}
|
void TearDown() override {}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ protected:
|
|||||||
|
|
||||||
return vbo;
|
return vbo;
|
||||||
}
|
}
|
||||||
void SetUp() override { MobileGL::MG_Initialize(); }
|
void SetUp() override { MobileGL::Initialize(); }
|
||||||
|
|
||||||
void TearDown() override {}
|
void TearDown() override {}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user