glmark2: update to 2021.12, add build options

This commit is contained in:
Piotr Wójcik 2022-01-07 23:56:55 +01:00
parent 00e79c859f
commit ebf9ad1059
2 changed files with 13 additions and 130 deletions

View file

@ -1,122 +0,0 @@
From 2ddc86ff65aa93abc321f98996c2657e9fd2d712 Mon Sep 17 00:00:00 2001
From: Hill Ma <maahiuzeon@gmail.com>
Date: Sun, 11 Apr 2021 08:57:15 -0700
Subject: [PATCH] Fix model loading on big endian.
---
src/model.cpp | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/src/model.cpp b/src/model.cpp
index 944ee2a..eb0e428 100644
--- a/src/model.cpp
+++ b/src/model.cpp
@@ -29,6 +29,7 @@
#include "util.h"
#include "float.h"
#include "math.h"
+#include <algorithm>
#include <fstream>
#include <sstream>
#include <memory>
@@ -39,12 +40,27 @@ using LibMatrix::vec2;
using LibMatrix::vec3;
using LibMatrix::uvec3;
-#define read_or_fail(file, dst, size) do { \
- file.read(reinterpret_cast<char *>((dst)), (size)); \
- if (file.gcount() < (std::streamsize)(size)) { \
+static inline void read_from_file(std::istream& file, void *dst, size_t nmemb, size_t size) {
+ file.read(reinterpret_cast<char *>(dst), nmemb * size);
+#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+ char *p = reinterpret_cast<char *>(dst);
+ for (size_t i = 0; i < nmemb; ++i) {
+ if (size == 2) {
+ std::swap(p[size*i], p[size*i+1]);
+ } else if (size == 4) {
+ std::swap(p[size*i], p[size*i+3]);
+ std::swap(p[size*i+1], p[size*i+2]);
+ }
+ }
+#endif
+}
+
+#define read_or_fail(file, dst, nmemb, size) do { \
+ read_from_file((file), (dst), (nmemb), (size)); \
+ if (file.gcount() < (std::streamsize)((nmemb)*(size))) { \
Log::error("%s: %d: Failed to read %zd bytes from 3ds file (read %zd)\n", \
__FUNCTION__, __LINE__, \
- (size_t)(size), file.gcount()); \
+ (size_t)((nmemb)*(size)), file.gcount()); \
return false; \
} \
} while(0);
@@ -375,7 +391,7 @@ Model::load_3ds(const std::string &filename)
uint32_t chunk_length;
// Read the chunk header
- input_file.read(reinterpret_cast<char *>(&chunk_id), 2);
+ read_from_file(input_file, &chunk_id, 1, 2);
if (input_file.gcount() == 0) {
continue;
}
@@ -386,7 +402,7 @@ Model::load_3ds(const std::string &filename)
}
//Read the length of the chunk
- read_or_fail(input_file, &chunk_length, 4);
+ read_or_fail(input_file, &chunk_length, 1, 4);
switch (chunk_id)
{
@@ -417,7 +433,7 @@ Model::load_3ds(const std::string &filename)
unsigned char c = 1;
for (int i = 0; i < 20 && c != '\0'; i++) {
- read_or_fail(input_file, &c, 1);
+ read_or_fail(input_file, &c, 1, 1);
ss << c;
}
@@ -444,12 +460,12 @@ Model::load_3ds(const std::string &filename)
case 0x4110:
{
uint16_t qty;
- read_or_fail(input_file, &qty, sizeof(uint16_t));
+ read_or_fail(input_file, &qty, 1, sizeof(uint16_t));
object->vertices.resize(qty);
for (uint16_t i = 0; i < qty; i++) {
float f[3];
- read_or_fail(input_file, f, sizeof(float) * 3);
+ read_or_fail(input_file, f, 3, sizeof(float));
vec3& vertex = object->vertices[i].v;
vertex.x(f[0]);
vertex.y(f[1]);
@@ -468,11 +484,11 @@ Model::load_3ds(const std::string &filename)
case 0x4120:
{
uint16_t qty;
- read_or_fail(input_file, &qty, sizeof(uint16_t));
+ read_or_fail(input_file, &qty, 1, sizeof(uint16_t));
object->faces.resize(qty);
for (uint16_t i = 0; i < qty; i++) {
uint16_t f[4];
- read_or_fail(input_file, f, sizeof(uint16_t) * 4);
+ read_or_fail(input_file, f, 4, sizeof(uint16_t));
uvec3& face = object->faces[i].v;
face.x(f[0]);
face.y(f[1]);
@@ -491,10 +507,10 @@ Model::load_3ds(const std::string &filename)
case 0x4140:
{
uint16_t qty;
- read_or_fail(input_file, &qty, sizeof(uint16_t));
+ read_or_fail(input_file, &qty, 1, sizeof(uint16_t));
for (uint16_t i = 0; i < qty; i++) {
float f[2];
- read_or_fail(input_file, f, sizeof(float) * 2);
+ read_or_fail(input_file, f, 2, sizeof(float));
vec2& texcoord = object->vertices[i].t;
texcoord.x(f[0]);
texcoord.y(f[1]);

View file

@ -1,21 +1,26 @@
# Template file for 'glmark2'
pkgname=glmark2
version=2021.02
revision=2
version=2021.12
revision=1
build_style=meson
configure_args="-Dflavors=x11-gl,x11-glesv2,drm-gl,wayland-gl,wayland-glesv2,drm-glesv2"
hostmakedepends="pkg-config wayland-devel"
makedepends="libjpeg-turbo-devel libpng-devel libX11-devel MesaLib-devel wayland-devel
wayland-protocols"
configure_args="-Dflavors=$(vopt_if wayland 'wayland-gl,wayland-glesv2,')$(vopt_if x11 'x11-gl,x11-glesv2,')drm-gl,drm-glesv2"
hostmakedepends="pkg-config $(vopt_if wayland wayland-devel)"
makedepends="libjpeg-turbo-devel libpng-devel MesaLib-devel
$(vopt_if wayland 'wayland-devel wayland-protocols') $(vopt_if x11 libX11-devel)"
short_desc="OpenGL 2.0 and ES 2.0 benchmark"
maintainer="Piotr Wójcik <chocimier@tlen.pl>"
license="GPL-3.0-or-later"
homepage="https://github.com/glmark2/glmark2"
changelog="https://raw.githubusercontent.com/glmark2/glmark2/master/NEWS"
distfiles="https://github.com/glmark2/glmark2/archive/${version}.tar.gz"
checksum=bebadb78c13aea5e88ed892e5563101ccb745b75f1dc86a8fc7229f00d78cbf1
checksum=9f111284b2ef1d3fce91928e249e6ca00796a036831b063a549a0f3b03557a95
build_options="wayland x11"
build_options_default="wayland x11"
pre_build() {
# this file is racey, so pre-generate it ahead of time
ninja -C build src/xdg-shell-client-protocol.h
if [ "$build_option_wayland" ]; then
ninja -C build src/xdg-shell-client-protocol.h
fi
}