mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Test] (BufferTest): add Binding test, and fix compile errors
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
#define MOBILEGL_LOG_FILE_PATH "/sdcard/MG/latest.log"
|
#define MOBILEGL_LOG_FILE_PATH "/sdcard/MG/latest.log"
|
||||||
#elif
|
#else
|
||||||
#define MOBILEGL_LOG_FILE_PATH ""
|
#define MOBILEGL_LOG_FILE_PATH ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+17
-1
@@ -68,6 +68,23 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __ANDROID__
|
||||||
|
// Define a stub for __android_log_print if not on Android
|
||||||
|
#define ANDROID_LOG_UNKNOWN 0
|
||||||
|
#define ANDROID_LOG_DEFAULT 1
|
||||||
|
#define ANDROID_LOG_VERBOSE 2
|
||||||
|
#define ANDROID_LOG_DEBUG 3
|
||||||
|
#define ANDROID_LOG_INFO 4
|
||||||
|
#define ANDROID_LOG_WARN 5
|
||||||
|
#define ANDROID_LOG_ERROR 6
|
||||||
|
#define ANDROID_LOG_FATAL 7
|
||||||
|
#define ANDROID_LOG_SILENT 8
|
||||||
|
|
||||||
|
typedef int android_LogPriority;
|
||||||
|
|
||||||
|
int __android_log_print(int prio, const char *tag, const char *fmt, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glext.h>
|
#include <GL/glext.h>
|
||||||
@@ -90,7 +107,6 @@
|
|||||||
|
|
||||||
#include "MG_Util/Pipelines/PipelineExecutor.hpp"
|
#include "MG_Util/Pipelines/PipelineExecutor.hpp"
|
||||||
|
|
||||||
#include "MG_Util/Pipelines/Shader/GLSLtoSPIRVPipeline.h"
|
|
||||||
#include "MG_Util/Pipelines/ShaderCompilationPipeline.h"
|
#include "MG_Util/Pipelines/ShaderCompilationPipeline.h"
|
||||||
|
|
||||||
#include "MG_State/GLState/BufferState/BufferObject.h"
|
#include "MG_State/GLState/BufferState/BufferObject.h"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace MobileGL {
|
|||||||
m_dirtyRange->Extend(0, m_size);
|
m_dirtyRange->Extend(0, m_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* BufferObject::AquireMemory(Bool markMapped = true, Bool read, Bool write) {
|
void* BufferObject::AquireMemory(Bool markMapped, Bool read, Bool write) {
|
||||||
if (markMapped) {
|
if (markMapped) {
|
||||||
m_isMapped = true;
|
m_isMapped = true;
|
||||||
m_mappingAccess = (read ? BufferMappingAccessBit::Read : BufferMappingAccessBit::Null) |
|
m_mappingAccess = (read ? BufferMappingAccessBit::Read : BufferMappingAccessBit::Null) |
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// Created by Swung 0x48 on 2025/7/17.
|
||||||
|
//
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "Includes.h"
|
||||||
|
|
||||||
|
using namespace MobileGL;
|
||||||
|
|
||||||
|
class BufferTest : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
MG_State::GLState::GLContext glContext;
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(BufferTest, Binding) {
|
||||||
|
auto bufferNames = glContext.GenBufferNames(3);
|
||||||
|
auto& arraySlot = glContext.GetBufferBindingSlot(BufferTarget::Vertex);
|
||||||
|
auto& indexSlot = glContext.GetBufferBindingSlot(BufferTarget::Index);
|
||||||
|
|
||||||
|
auto obj0 = glContext.CreateBufferObject(bufferNames[0]);
|
||||||
|
auto obj1 = glContext.CreateBufferObject(bufferNames[1]);
|
||||||
|
auto obj2 = glContext.CreateBufferObject(bufferNames[2]);
|
||||||
|
|
||||||
|
arraySlot.Bind(obj0);
|
||||||
|
indexSlot.Bind(obj1);
|
||||||
|
|
||||||
|
ASSERT_TRUE(arraySlot.GetBoundObject() == obj0);
|
||||||
|
ASSERT_TRUE(indexSlot.GetBoundObject() == obj1);
|
||||||
|
|
||||||
|
arraySlot.Bind(obj2);
|
||||||
|
indexSlot.Bind(obj2);
|
||||||
|
ASSERT_TRUE(arraySlot.GetBoundObject() == obj2);
|
||||||
|
ASSERT_TRUE(indexSlot.GetBoundObject() == obj2);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
|
||||||
|
add_executable(
|
||||||
|
BufferTest
|
||||||
|
BufferTest.cpp
|
||||||
|
|
||||||
|
${MGL_ROOT}/MobileGL/MG_State/GLState/Core.cpp
|
||||||
|
${MGL_ROOT}/MobileGL/MG_State/GLState/BufferState/BufferState.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(BufferTest PRIVATE
|
||||||
|
${MGL_ROOT}/include
|
||||||
|
${MGL_ROOT}/MobileGL
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
BufferTest
|
||||||
|
GTest::gtest_main
|
||||||
|
)
|
||||||
|
|
||||||
|
include(GoogleTest)
|
||||||
|
gtest_discover_tests(BufferTest)
|
||||||
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.14)
|
|||||||
project(MobileGLTest)
|
project(MobileGLTest)
|
||||||
|
|
||||||
# GoogleTest requires at least C++17
|
# GoogleTest requires at least C++17
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
@@ -15,6 +15,9 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|||||||
FetchContent_MakeAvailable(googletest)
|
FetchContent_MakeAvailable(googletest)
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
|
set(MGL_ROOT ${CMAKE_CURRENT_LIST_DIR}/../..)
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
SanityTest
|
SanityTest
|
||||||
SanityTest.cpp
|
SanityTest.cpp
|
||||||
@@ -25,4 +28,6 @@ target_link_libraries(
|
|||||||
)
|
)
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(SanityTest)
|
gtest_discover_tests(SanityTest)
|
||||||
|
|
||||||
|
add_subdirectory(Buffer)
|
||||||
|
|||||||
Reference in New Issue
Block a user