citra-emu
/
citra-canary
Archived
1
0
Fork 0

specify size of buffer and use openglstate in getteximageoes

This commit is contained in:
Khangaroo 2019-10-12 11:25:27 -04:00 committed by James Rowe
parent a458155f99
commit df99d98240
15 changed files with 49 additions and 86 deletions

2
externals/fmt vendored

@ -1 +1 @@
Subproject commit 7512a55aa3ae309587ca89668ef9ec4074a51a1f
Subproject commit 4b8f8fac96a7819f28f4be523ca10a2d5d8aaaf2

View File

@ -46,12 +46,9 @@ add_executable(citra-qt
configuration/configure_camera.ui
configuration/configure_debug.cpp
configuration/configure_debug.h
<<<<<<< HEAD
configuration/configure_debug.ui
=======
configuration/configure_enhancements.cpp
configuration/configure_enhancements.h
>>>>>>> 76ca777b... reorder graphics tab, move speed to general
configuration/configure_dialog.cpp
configuration/configure_dialog.h
configuration/configure_general.cpp
@ -160,38 +157,6 @@ add_executable(citra-qt
util/spinbox.h
util/util.cpp
util/util.h
<<<<<<< HEAD
=======
compatdb.cpp
compatdb.h
)
set(UIS
configuration/configure.ui
configuration/configure_audio.ui
configuration/configure_camera.ui
configuration/configure_debug.ui
configuration/configure_enhancements.ui
configuration/configure_general.ui
configuration/configure_graphics.ui
configuration/configure_hotkeys.ui
configuration/configure_input.ui
configuration/configure_motion_touch.ui
configuration/configure_system.ui
configuration/configure_ui.ui
configuration/configure_web.ui
debugger/registers.ui
multiplayer/direct_connect.ui
multiplayer/lobby.ui
multiplayer/chat_room.ui
multiplayer/client_room.ui
multiplayer/host_room.ui
multiplayer/moderation_dialog.ui
aboutdialog.ui
cheats.ui
main.ui
compatdb.ui
>>>>>>> 76ca777b... reorder graphics tab, move speed to general
)
file(GLOB COMPAT_LIST

View File

@ -236,6 +236,7 @@ void Config::ReadUtilityValues() {
Settings::values.dump_textures = ReadSetting("dump_textures", false).toBool();
Settings::values.custom_textures = ReadSetting("custom_textures", false).toBool();
Settings::values.preload_textures = ReadSetting("preload_textures", false).toBool();
qt_config->endGroup();
}
@ -708,6 +709,7 @@ void Config::SaveUtilityValues() {
WriteSetting("dump_textures", Settings::values.dump_textures, false);
WriteSetting("custom_textures", Settings::values.custom_textures, false);
WriteSetting("preload_textures", Settings::values.preload_textures, false);
qt_config->endGroup();
}

View File

@ -75,20 +75,11 @@ Q_DECLARE_METATYPE(QList<QWidget*>);
void ConfigureDialog::PopulateSelectionList() {
ui->selectorList->clear();
<<<<<<< HEAD
const std::array<std::pair<QString, QList<QWidget*>>, 4> items{
{{tr("General"), {ui->generalTab, ui->webTab, ui->debugTab, ui->uiTab}},
{tr("System"), {ui->systemTab, ui->audioTab, ui->cameraTab}},
{tr("Graphics"), {ui->graphicsTab}},
{tr("Graphics"), {ui->enhancementsTab, ui->graphicsTab}},
{tr("Controls"), {ui->inputTab, ui->hotkeysTab}}}};
=======
const std::array<std::pair<QString, QStringList>, 4> items{
{{tr("General"),
{QT_TR_NOOP("General"), QT_TR_NOOP("Web"), QT_TR_NOOP("Debug"), QT_TR_NOOP("UI")}},
{tr("System"), {QT_TR_NOOP("System"), QT_TR_NOOP("Audio"), QT_TR_NOOP("Camera")}},
{tr("Graphics"), {QT_TR_NOOP("Enhancements"), QT_TR_NOOP("Advanced")}},
{tr("Controls"), {QT_TR_NOOP("Input"), QT_TR_NOOP("Hotkeys")}}}};
>>>>>>> 76ca777b... reorder graphics tab, move speed to general
for (const auto& entry : items) {
auto* const item = new QListWidgetItem(entry.first);
@ -133,12 +124,17 @@ void ConfigureDialog::UpdateVisibleTabs() {
if (items.isEmpty())
return;
const std::map<QWidget*, QString> widgets = {
{ui->generalTab, tr("General")}, {ui->systemTab, tr("System")},
{ui->inputTab, tr("Input")}, {ui->hotkeysTab, tr("Hotkeys")},
{ui->graphicsTab, tr("Graphics")}, {ui->audioTab, tr("Audio")},
{ui->cameraTab, tr("Camera")}, {ui->debugTab, tr("Debug")},
{ui->webTab, tr("Web")}, {ui->uiTab, tr("UI")}};
const std::map<QWidget*, QString> widgets = {{ui->generalTab, tr("General")},
{ui->systemTab, tr("System")},
{ui->inputTab, tr("Input")},
{ui->hotkeysTab, tr("Hotkeys")},
{ui->enhancementsTab, tr("Enhancements")},
{ui->graphicsTab, tr("Advanced")},
{ui->audioTab, tr("Audio")},
{ui->cameraTab, tr("Camera")},
{ui->debugTab, tr("Debug")},
{ui->webTab, tr("Web")},
{ui->uiTab, tr("UI")}};
ui->tabWidget->clear();

View File

@ -50,8 +50,8 @@
#include "citra_qt/hotkeys.h"
#include "citra_qt/main.h"
#include "citra_qt/multiplayer/state.h"
#include "citra_qt/uisettings.h"
#include "citra_qt/qt_image_interface.h"
#include "citra_qt/uisettings.h"
#include "citra_qt/updater/updater.h"
#include "citra_qt/util/clickable_label.h"
#include "common/common_paths.h"

View File

@ -212,12 +212,6 @@ public:
/// Gets a const reference to the cheat engine
const Cheats::CheatEngine& CheatEngine() const;
/// Gets a reference to the video dumper backend
VideoDumper::Backend& VideoDumper();
/// Gets a const reference to the video dumper backend
const VideoDumper::Backend& VideoDumper() const;
/// Gets a reference to the custom texture cache system
Core::CustomTexCache& CustomTexCache();
@ -233,6 +227,7 @@ public:
/// Gets a const reference to the video dumper backend
const VideoDumper::Backend& VideoDumper() const;
std::unique_ptr<PerfStats> perf_stats;
FrameLimiter frame_limiter;
void SetStatus(ResultStatus new_status, const char* details = nullptr) {

View File

@ -82,8 +82,9 @@ void CustomTexCache::PreloadTextures() {
if (image_interface->DecodePNG(tex_info.tex, tex_info.width, tex_info.height,
path_info.path)) {
// Make sure the texture size is a power of 2
if ((ceil(log2(tex_info.width)) == floor(log2(tex_info.width))) &&
(ceil(log2(tex_info.height)) == floor(log2(tex_info.height)))) {
std::bitset<32> width_bits(tex_info.width);
std::bitset<32> height_bits(tex_info.height);
if (width_bits.count() == 1 && height_bits.count() == 1) {
LOG_DEBUG(Render_OpenGL, "Loaded custom texture from {}", path_info.path);
Common::FlipRGBA8Texture(tex_info.tex, tex_info.width, tex_info.height);
CacheTexture(path_info.hash, tex_info.tex, tex_info.width, tex_info.height);

View File

@ -98,9 +98,12 @@ static const FormatTuple& GetFormatTuple(PixelFormat pixel_format) {
* Originally from https://github.com/apitrace/apitrace/blob/master/retrace/glstate_images.cpp
*/
static inline void GetTexImageOES(GLenum target, GLint level, GLenum format, GLenum type,
GLint height, GLint width, GLint depth, GLubyte* pixels) {
GLint height, GLint width, GLint depth, GLubyte* pixels,
GLuint size) {
memset(pixels, 0x80, size);
memset(pixels, 0x80, height * width * 4);
OpenGLState cur_state = OpenGLState::GetCurState();
OpenGLState state;
GLenum texture_binding = GL_NONE;
switch (target) {
@ -127,11 +130,10 @@ static inline void GetTexImageOES(GLenum target, GLint level, GLenum format, GLe
return;
}
GLint prev_fbo = 0;
GLuint fbo = 0;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prev_fbo);
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
OGLFramebuffer fbo;
fbo.Create();
state.draw.read_framebuffer = fbo.handle;
state.Apply();
switch (target) {
case GL_TEXTURE_2D:
@ -141,8 +143,9 @@ static inline void GetTexImageOES(GLenum target, GLint level, GLenum format, GLe
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, level);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture,
level);
GLenum status = glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE) {
LOG_DEBUG(Render_OpenGL, "Framebuffer is incomplete, status: {:X}", status);
}
@ -151,16 +154,16 @@ static inline void GetTexImageOES(GLenum target, GLint level, GLenum format, GLe
}
case GL_TEXTURE_3D_OES:
for (int i = 0; i < depth; i++) {
glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_3D, texture,
level, i);
glFramebufferTexture3D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_3D,
texture, level, i);
glReadPixels(0, 0, width, height, format, type, pixels + 4 * i * width * height);
}
break;
}
glBindFramebuffer(GL_FRAMEBUFFER, prev_fbo);
cur_state.Apply();
glDeleteFramebuffers(1, &fbo);
fbo.Release();
}
template <typename Map, typename Interval>
@ -869,9 +872,9 @@ bool CachedSurface::LoadCustomTexture(u64 tex_hash, Core::CustomTexInfo& tex_inf
const auto& path_info = custom_tex_cache.LookupTexturePathInfo(tex_hash);
if (image_interface->DecodePNG(tex_info.tex, tex_info.width, tex_info.height,
path_info.path)) {
// Make sure the texture size is a power of 2
if ((ceil(log2(tex_info.width)) == floor(log2(tex_info.width))) &&
(ceil(log2(tex_info.height)) == floor(log2(tex_info.height)))) {
std::bitset<32> width_bits(tex_info.width);
std::bitset<32> height_bits(tex_info.height);
if (width_bits.count() == 1 && height_bits.count() == 1) {
LOG_DEBUG(Render_OpenGL, "Loaded custom texture from {}", path_info.path);
Common::FlipRGBA8Texture(tex_info.tex, tex_info.width, tex_info.height);
custom_tex_cache.CacheTexture(tex_hash, tex_info.tex, tex_info.width,
@ -931,7 +934,7 @@ void CachedSurface::DumpTexture(GLuint target_tex, u64 tex_hash) {
desktop and ES.
*/
GetTexImageOES(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, height, width, 0,
&decoded_texture[0]);
&decoded_texture[0], decoded_texture.size());
glBindTexture(GL_TEXTURE_2D, 0);
Common::FlipRGBA8Texture(decoded_texture, width, height);
if (!image_interface->EncodePNG(dump_path, decoded_texture, width, height))
@ -1086,7 +1089,8 @@ void CachedSurface::DownloadGLTexture(const Common::Rectangle<u32>& rect, GLuint
glActiveTexture(GL_TEXTURE0);
if (GLES) {
GetTexImageOES(GL_TEXTURE_2D, 0, tuple.format, tuple.type, rect.GetHeight(),
rect.GetWidth(), 0, &gl_buffer[buffer_offset]);
rect.GetWidth(), 0, &gl_buffer[buffer_offset],
gl_buffer_size - buffer_offset);
} else {
glGetTexImage(GL_TEXTURE_2D, 0, tuple.format, tuple.type, &gl_buffer[buffer_offset]);
}