From: mahiuchun <mahiuchun@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] glmark2: big endian model loading patch and revbump.
Date: Tue, 14 Sep 2021 06:43:51 +0200 [thread overview]
Message-ID: <20210914044351.r1G1fko0B_FxOWeHZaFuPCoKLFDXwNcxL4EfEdNAyNc@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-32961@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 1623 bytes --]
There is an updated pull request by mahiuchun against master on the void-packages repository
https://github.com/mahiuchun/void-packages glmark2
https://github.com/void-linux/void-packages/pull/32961
glmark2: big endian model loading patch and revbump.
<!-- Mark items with [x] where applicable -->
#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)
#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR
<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!--
#### Does it build and run successfully?
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] I built this PR locally for my native architecture, (ARCH-LIBC)
- [ ] I built this PR locally for these architectures (if supported. mark crossbuilds):
- [ ] aarch64-musl
- [ ] armv7l
- [ ] armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/32961.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-glmark2-32961.patch --]
[-- Type: text/x-diff, Size: 6187 bytes --]
From 1e28ec9763298e67365c31b814b4c8eeff2839d1 Mon Sep 17 00:00:00 2001
From: Hill Ma <maahiuzeon@gmail.com>
Date: Mon, 13 Sep 2021 21:38:38 -0700
Subject: [PATCH] glmark2: big endian model loading patch and revbump.
The patch is already committed in upstream as:
https://github.com/glmark2/glmark2/commit/2ddc86ff65aa93abc321f98996c2657e9fd2d712
---
.../glmark2/patches/model-loading-be.patch | 122 ++++++++++++++++++
srcpkgs/glmark2/template | 2 +-
2 files changed, 123 insertions(+), 1 deletion(-)
create mode 100644 srcpkgs/glmark2/patches/model-loading-be.patch
diff --git a/srcpkgs/glmark2/patches/model-loading-be.patch b/srcpkgs/glmark2/patches/model-loading-be.patch
new file mode 100644
index 000000000000..f9b70162191d
--- /dev/null
+++ b/srcpkgs/glmark2/patches/model-loading-be.patch
@@ -0,0 +1,122 @@
+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]);
diff --git a/srcpkgs/glmark2/template b/srcpkgs/glmark2/template
index cc4ce4a0aa52..42b33d2e9f69 100644
--- a/srcpkgs/glmark2/template
+++ b/srcpkgs/glmark2/template
@@ -1,7 +1,7 @@
# Template file for 'glmark2'
pkgname=glmark2
version=2021.02
-revision=1
+revision=2
build_style=meson
configure_args="-Dflavors=x11-gl,x11-glesv2,drm-gl,wayland-gl,wayland-glesv2,drm-glesv2"
hostmakedepends="pkg-config wayland-devel"
next prev parent reply other threads:[~2021-09-14 4:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-14 4:42 [PR PATCH] " mahiuchun
2021-09-14 4:43 ` mahiuchun [this message]
2021-09-14 7:37 ` [PR PATCH] [Updated] " mahiuchun
2021-09-14 7:39 ` [PR PATCH] [Merged]: " q66
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210914044351.r1G1fko0B_FxOWeHZaFuPCoKLFDXwNcxL4EfEdNAyNc@z \
--to=mahiuchun@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).