Skip to content

Commit

Permalink
fx
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuoya committed Jan 17, 2022
1 parent 718c091 commit ce86294
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public static int SafClose(int fd) {
Log.e("citra", "SafClose error: " + fd, e);
ret = -1;
}
SafFileDescriptorMap.remove(fd);
} else {
ret = -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ public final class GameInfo {
* Game regions
*/
public static final class GameRegion {
public static final int Invalid = -1;
public static final int Japan = 0;
public static final int NorthAmerica = 1;
public static final int Europe = 2;
public static final int Australia = 3;
public static final int China = 4;
public static final int Korea = 5;
public static final int Taiwan = 6;
public static final int Global = 7;
}

public String id;
public String name;
public String path;
public byte[] icon;
public int region = GameRegion.Invalid;
public int region;
}
10 changes: 6 additions & 4 deletions src/android/app/src/main/java/org/citra/emu/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,18 @@ protected void refreshDirectoryLegacy(List<File> dirs) {
if (isInstalled || !dirSet.contains(path)) {
dirs.add(f);
}
} else if (NativeLibrary.isValidFile(path) && NativeLibrary.IsAppVisible(path)) {
} else if (NativeLibrary.isValidFile(path)) {
GameFile game = new GameFile(path, isInstalled);
game.init();
if (isInstalled) {
if (isInstalled && NativeLibrary.IsAppVisible(path)) {
if (game.isInstalledDLC()) {
game.init();
contents.add(game);
} else if (NativeLibrary.IsAppExecutable(path)) {
game.init();
installs.add(game);
}
} else {
} else if (NativeLibrary.IsAppExecutable(path)) {
game.init();
externals.add(game);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,13 @@ public void bind(GameFile model) {
}

public String getAppDesc(GameFile model) {
final int[] regions = {
R.string.region_invalid, R.string.region_japan, R.string.region_north_america,
R.string.region_europe, R.string.region_australia, R.string.region_china,
R.string.region_korea, R.string.region_taiwan,
};
String path = model.getPath();
File appFile = new File(path);

long playtime = 0;
Context context = mTextRegion.getContext();
String regionDesc = context.getString(regions[model.getRegion() + 1]);
String[] regions = context.getResources().getStringArray(R.array.game_regions);
String regionDesc = regions[model.getRegion()];
String desc = "";

if (model.isInstalledDLC()) {
Expand Down
2 changes: 1 addition & 1 deletion src/android/app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
<string name="accurate_mul_fast">快速</string>
<string name="accurate_mul_accurate">准确</string>

<string name="region_invalid">未知</string>
<string name="region_global">全球</string>
<string name="region_japan">日本</string>
<string name="region_north_america">北美</string>
<string name="region_europe">欧洲</string>
Expand Down
11 changes: 11 additions & 0 deletions src/android/app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,15 @@
<item>@string/memory_value_one_byte</item>
</string-array>

<string-array name="game_regions">
<item>@string/region_japan</item>
<item>@string/region_north_america</item>
<item>@string/region_europe</item>
<item>@string/region_australia</item>
<item>@string/region_china</item>
<item>@string/region_korea</item>
<item>@string/region_taiwan</item>
<item>@string/region_global</item>
</string-array>

</resources>
2 changes: 1 addition & 1 deletion src/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
<string name="accurate_mul_fast">Fast</string>
<string name="accurate_mul_accurate">Accurate</string>

<string name="region_invalid">Unknown</string>
<string name="region_global">Global</string>
<string name="region_japan">Japan</string>
<string name="region_north_america">North America</string>
<string name="region_europe">Europe</string>
Expand Down
2 changes: 1 addition & 1 deletion src/android/jni/main_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_citra_emu_NativeLibrary_GetAppIcon(JNIEnv*
JNIEXPORT jint JNICALL Java_org_citra_emu_NativeLibrary_GetAppRegion(JNIEnv* env, jclass obj,
jstring jPath) {
auto& regions = GetGameInfo(JniHelper::Unwrap(jPath)).regions;
return static_cast<jint>(regions[0]);
return regions.size() == 7 ? 7 : static_cast<jint>(regions[0]);
}

JNIEXPORT jboolean JNICALL Java_org_citra_emu_NativeLibrary_IsAppExecutable(JNIEnv* env, jclass obj,
Expand Down
63 changes: 40 additions & 23 deletions src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ static void MortonCopyTile(u32 stride, u8* tile_buffer, u8* gl_buffer) {
if constexpr (format == PixelFormat::D24S8) {
std::memcpy(tile_ptr, gl_ptr + 1, 3);
tile_ptr[3] = gl_ptr[0];
} else if (format == PixelFormat::RGBA8 && GLES) {
// because GLES does not have ABGR format
// so we will do byteswapping here
tile_ptr[0] = gl_ptr[3];
tile_ptr[1] = gl_ptr[2];
tile_ptr[2] = gl_ptr[1];
tile_ptr[3] = gl_ptr[0];
} else if (format == PixelFormat::RGB8 && GLES) {
tile_ptr[0] = gl_ptr[2];
tile_ptr[1] = gl_ptr[1];
tile_ptr[2] = gl_ptr[0];
} else {
std::memcpy(tile_ptr, gl_ptr, bytes_per_pixel);
}
Expand Down Expand Up @@ -507,31 +518,24 @@ void CachedSurface::LoadGLBuffer(PAddr load_start, PAddr load_end) {
if (load_start < Memory::VRAM_VADDR && load_end > Memory::VRAM_VADDR)
load_start = Memory::VRAM_VADDR;

MICROPROFILE_SCOPE(OpenGL_SurfaceLoad);

ASSERT(load_start >= addr && load_end <= end);
const u32 start_offset = load_start - addr;

if (!is_tiled) {
ASSERT(type == SurfaceType::Color);
const bool need_swap =
GLES && (pixel_format == PixelFormat::RGBA8 || pixel_format == PixelFormat::RGB8);
if (need_swap) {
// TODO(liushuyu): check if the byteswap here is 100% correct
// cannot fully test this
if (pixel_format == PixelFormat::RGBA8) {
for (std::size_t i = start_offset; i < load_end - addr; i += 4) {
gl_buffer[i] = texture_src_data[i + 3];
gl_buffer[i + 1] = texture_src_data[i + 2];
gl_buffer[i + 2] = texture_src_data[i + 1];
gl_buffer[i + 3] = texture_src_data[i];
}
} else if (pixel_format == PixelFormat::RGB8) {
for (std::size_t i = start_offset; i < load_end - addr; i += 3) {
gl_buffer[i] = texture_src_data[i + 2];
gl_buffer[i + 1] = texture_src_data[i + 1];
gl_buffer[i + 2] = texture_src_data[i];
}
// TODO(liushuyu): check if the byteswap here is 100% correct, cannot fully test this
if (pixel_format == PixelFormat::RGBA8) {
for (std::size_t i = start_offset; i < load_end - addr; i += 4) {
gl_buffer[i] = texture_src_data[i + 3];
gl_buffer[i + 1] = texture_src_data[i + 2];
gl_buffer[i + 2] = texture_src_data[i + 1];
gl_buffer[i + 3] = texture_src_data[i];
}
} else if (pixel_format == PixelFormat::RGB8) {
for (std::size_t i = start_offset; i < load_end - addr; i += 3) {
gl_buffer[i] = texture_src_data[i + 2];
gl_buffer[i + 1] = texture_src_data[i + 1];
gl_buffer[i + 2] = texture_src_data[i];
}
} else {
std::memcpy(&gl_buffer[start_offset], texture_src_data + start_offset,
Expand Down Expand Up @@ -579,8 +583,6 @@ void CachedSurface::FlushGLBuffer(PAddr flush_start, PAddr flush_end) {
if (flush_start < Memory::VRAM_VADDR && flush_end > Memory::VRAM_VADDR)
flush_start = Memory::VRAM_VADDR;

MICROPROFILE_SCOPE(OpenGL_SurfaceFlush);

ASSERT(flush_start >= addr && flush_end <= end);
const u32 start_offset = flush_start - addr;
const u32 end_offset = flush_end - addr;
Expand All @@ -601,7 +603,22 @@ void CachedSurface::FlushGLBuffer(PAddr flush_start, PAddr flush_end) {
std::memcpy(&dst_buffer[coarse_start_offset], &backup_data[0], backup_bytes);
} else if (!is_tiled) {
ASSERT(type == SurfaceType::Color);
std::memcpy(dst_buffer + start_offset, &gl_buffer[start_offset], flush_end - flush_start);
if (pixel_format == PixelFormat::RGBA8) {
for (std::size_t i = start_offset; i < flush_end - addr; i += 4) {
dst_buffer[i] = gl_buffer[i + 3];
dst_buffer[i + 1] = gl_buffer[i + 2];
dst_buffer[i + 2] = gl_buffer[i + 1];
dst_buffer[i + 3] = gl_buffer[i];
}
} else if (pixel_format == PixelFormat::RGB8) {
for (std::size_t i = start_offset; i < flush_end - addr; i += 3) {
dst_buffer[i] = gl_buffer[i + 2];
dst_buffer[i + 1] = gl_buffer[i + 1];
dst_buffer[i + 2] = gl_buffer[i];
}
} else {
std::memcpy(dst_buffer + start_offset, &gl_buffer[start_offset], flush_end - flush_start);
}
} else {
gl_to_morton_fns[static_cast<std::size_t>(pixel_format)](stride, height, &gl_buffer[0],
addr, flush_start, flush_end);
Expand Down

0 comments on commit ce86294

Please sign in to comment.