Skip to content

Commit cca0f94

Browse files
committed
Fix[unpack]: correctly call glPixelStorei
1 parent 75a964c commit cca0f94

5 files changed

Lines changed: 42 additions & 14 deletions

File tree

ltw/src/main/tinywrapper/egl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ typedef struct {
8585
unordered_map* program_map;
8686
unordered_map* framebuffer_map;
8787
unordered_map* bound_basebuffers[MAX_BOUND_BASEBUFFERS];
88+
unordered_map* texdesc_map;
8889
unpack_state_t unpack, hwunpack;
8990
int proxy_width, proxy_height, proxy_intformat, maxTextureSize;
9091
GLint max_drawbuffers;

ltw/src/main/tinywrapper/es3_overrides.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ GLESOVERRIDE(glTexBuffer)
133133
GLESOVERRIDE(glTexBufferRange)
134134
GLESOVERRIDE(glMapBufferRange)
135135
GLESOVERRIDE(glFlushMappedBufferRange)
136-
GLESOVERRIDE(glBeginQuery)
137-
GLESOVERRIDE(glEndQuery)
136+
//GLESOVERRIDE(glBeginQuery)
137+
//GLESOVERRIDE(glEndQuery)
138138
GLESOVERRIDE(glPixelStorei)
139139
GLESOVERRIDE(glPixelStoref)

ltw/src/main/tinywrapper/glformats.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
#include <android/log.h>
1717

18+
#if defined(__aarch64__) || defined(__arm__)
19+
#include <arm_neon.h>
20+
#define ARM_NEON
21+
#endif
22+
1823
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "LTW", __VA_ARGS__)
1924

2025
static GLint pick_depth_internalformat(GLenum* type, bool* convert) {
@@ -348,12 +353,42 @@ static void convert_##INTYPE##_##INCHANNELS##_to_##OUTTYPE##_##OUTCHANNELS(GLuin
348353
} \
349354
} \
350355

356+
#ifdef ARM_NEON
357+
void
358+
convert_GLubyte_4_to_GLubyte_4(GLuint unpack_row_length, GLuint height, const GLubyte *in,
359+
GLubyte *out, GLuint outw, const unsigned char swizzle[4]) {
360+
GLint s = sizeof(GLubyte);
361+
GLint a = current_context->unpack.alignment;
362+
GLuint k;
363+
if (s >= a)k = unpack_row_length * 4;
364+
else
365+
k = (GLuint) (((double) a / s) * ceil((s * 4.0 * unpack_row_length) / a));
366+
367+
uint64_t swizzle_raw = *(uint32_t*)swizzle;
368+
uint8x8_t index = vadd_u8(vcreate_u8((uint64_t) swizzle_raw | swizzle_raw << 32) , vcreate_u8(0x0404040400000000L));
369+
370+
for (GLuint y = 0; y < height; y++) {
371+
const GLubyte *inrow = &in[k * y];
372+
GLubyte *outrow = &out[outw * y * 4];
373+
374+
for (GLuint x = 0; x < unpack_row_length; x += 2) {
375+
GLuint outbase = x * 4;
376+
GLuint inbase = x * 4;
377+
{
378+
uint8x8_t rowbase = *(uint8x8_t*) &inrow[inbase];
379+
*(uint8x8_t*)&outrow[outbase] = vtbl1_u8(rowbase, index);
380+
}
381+
}
382+
}
383+
}
384+
#else
351385
CONVERT(GLubyte, GLubyte, 4, 4, {
352386
outrow[outbase + 0] = inrow[inbase + swizzle[0]];
353387
outrow[outbase + 1] = inrow[inbase + swizzle[1]];
354388
outrow[outbase + 2] = inrow[inbase + swizzle[2]];
355389
outrow[outbase + 3] = inrow[inbase + swizzle[3]];
356390
})
391+
#endif
357392

358393
CONVERT(GLubyte, GLubyte, 3, 4, {
359394
outrow[outbase + 0] = inrow[inbase + 0];
@@ -363,6 +398,9 @@ CONVERT(GLubyte, GLubyte, 3, 4, {
363398
})
364399

365400
INTERNAL void convert_texture2d(GLenum type, GLenum format, GLuint width, GLuint height, GLvoid const* data, GLenum outtype, GLenum outformat, GLvoid** outdata) {
401+
if(type == GL_UNSIGNED_INT_8_8_8_8_REV && (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT)) {
402+
type = GL_UNSIGNED_BYTE;
403+
}
366404
if(!is_type_basic(type) || !is_type_basic(outtype)) {
367405
LOGI("conversion between non-basic types %x and %x", type, outtype);
368406
return;

ltw/src/main/tinywrapper/unpack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static unpack_state_t default_state = {
2121
INTERNAL void apply_unpack_state_to_hw(unpack_state_t *state) {
2222
#define SET_HW_PARAM(NAME, ENUM) \
2323
if(state->NAME != current_context->hwunpack.NAME) { \
24-
es3_functions.glPixelStorei(GL_UNPACK_ALIGNMENT, state->NAME); \
24+
es3_functions.glPixelStorei(ENUM, state->NAME); \
2525
current_context->hwunpack.NAME = state->NAME; \
2626
}
2727
SET_HW_PARAM(row_length, GL_UNPACK_ROW_LENGTH)

wrapper/src/main/AndroidManifest.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,5 @@
88
android:supportsRtl="true"
99

1010
tools:targetApi="31">
11-
<activity
12-
android:name=".MainActivity"
13-
android:exported="true">
14-
<intent-filter>
15-
<action android:name="android.intent.action.MAIN" />
16-
<category android:name="android.intent.category.LAUNCHER" />
17-
</intent-filter>
18-
</activity>
1911
</application>
20-
<queries>
21-
<package android:name="git.artdeell.mojo.debug"/>
22-
</queries>
2312
</manifest>

0 commit comments

Comments
 (0)