Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] glmark2: big endian model loading patch and revbump.
@ 2021-09-14  4:42 mahiuchun
  2021-09-14  4:43 ` [PR PATCH] [Updated] " mahiuchun
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mahiuchun @ 2021-09-14  4:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1618 bytes --]

There is a new 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: 6186 bytes --]

From 49145752ed8f6c459ac9170613ef3cbfc95fe66f 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"

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-14  7:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14  4:42 [PR PATCH] glmark2: big endian model loading patch and revbump mahiuchun
2021-09-14  4:43 ` [PR PATCH] [Updated] " mahiuchun
2021-09-14  7:37 ` mahiuchun
2021-09-14  7:39 ` [PR PATCH] [Merged]: " q66

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).