Compare commits

...

4 Commits

Author SHA1 Message Date
James Rowe
8bd3d5be2b actually seed rand 2019-03-31 17:59:14 -03:00
James Rowe
a08e07505a move shaggy array to its own file 2019-03-31 17:59:14 -03:00
ReinUsesLisp
69c5966e24 Add UI 2019-03-31 16:40:48 -03:00
ReinUsesLisp
e281a1b75b D3D15 full implementation 2019-03-31 16:11:21 -03:00
9 changed files with 65632 additions and 9 deletions

View File

@@ -422,6 +422,8 @@ struct Values {
std::string yuzu_username;
std::string yuzu_token;
bool shaggie;
// Add-Ons
std::map<u64, std::vector<std::string>> disabled_addons;
} extern values;

View File

@@ -65,6 +65,8 @@ add_library(video_core STATIC
renderer_opengl/maxwell_to_gl.h
renderer_opengl/renderer_opengl.cpp
renderer_opengl/renderer_opengl.h
renderer_opengl/shaggy.cpp
renderer_opengl/shaggy.h
renderer_opengl/utils.cpp
renderer_opengl/utils.h
shader/decode/arithmetic.cpp

View File

@@ -3,6 +3,8 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <optional>
#include <glad/glad.h>
@@ -19,6 +21,7 @@
#include "video_core/morton.h"
#include "video_core/renderer_opengl/gl_rasterizer.h"
#include "video_core/renderer_opengl/gl_rasterizer_cache.h"
#include "video_core/renderer_opengl/shaggy.h"
#include "video_core/renderer_opengl/utils.h"
#include "video_core/surface.h"
#include "video_core/textures/convert.h"
@@ -561,9 +564,11 @@ void RasterizerCacheOpenGL::CopySurface(const Surface& src_surface, const Surfac
dst_surface->MarkAsModified(true, *this);
}
CachedSurface::CachedSurface(const SurfaceParams& params)
: RasterizerCacheObject{params.host_ptr}, params{params},
gl_target{SurfaceTargetToGL(params.target)}, cached_size_in_bytes{params.size_in_bytes} {
CachedSurface::CachedSurface(const SurfaceParams& params, GLuint shaggie_read, GLuint shaggie_draw)
: RasterizerCacheObject{params.host_ptr}, params{params}, gl_target{SurfaceTargetToGL(
params.target)},
cached_size_in_bytes{params.size_in_bytes}, shaggie_read{shaggie_read}, shaggie_draw{
shaggie_draw} {
const auto optional_cpu_addr{
Core::System::GetInstance().GPU().MemoryManager().GpuToCpuAddress(params.gpu_addr)};
@@ -694,6 +699,9 @@ void CachedSurface::FlushGLBuffer() {
}
}
static constexpr GLuint shaggie_width = 512;
static constexpr GLuint shaggie_height = 512;
void CachedSurface::UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle,
GLuint draw_fb_handle) {
const auto& rect{params.GetRect(mip_map)};
@@ -712,6 +720,20 @@ void CachedSurface::UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle,
ASSERT(params.MipWidth(mip_map) * GetBytesPerPixel(params.pixel_format) % 4 == 0);
glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(params.MipWidth(mip_map)));
const auto Shaggizise = [&]() {
OpenGLState prev_state{OpenGLState::GetCurState()};
SCOPE_EXIT({ prev_state.Apply(); });
OpenGLState state;
state.draw.read_framebuffer = shaggie_read;
state.draw.draw_framebuffer = shaggie_draw;
state.Apply();
glFramebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture.handle, mip_map);
glBlitFramebuffer(0, 0, shaggie_width, shaggie_height, x0, y0, x0 + rect.GetWidth(),
y0 + rect.GetHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
};
const auto image_size = static_cast<GLsizei>(params.GetMipmapSizeGL(mip_map, false));
if (tuple.compressed) {
switch (params.target) {
@@ -763,10 +785,15 @@ void CachedSurface::UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle,
tuple.format, tuple.type, &gl_buffer[mip_map][buffer_offset]);
break;
case SurfaceTarget::Texture2D:
glTextureSubImage2D(texture.handle, mip_map, x0, y0,
static_cast<GLsizei>(rect.GetWidth()),
static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type,
&gl_buffer[mip_map][buffer_offset]);
// Only shaggize once every three or so times
if (Settings::values.shaggie && !(rand() % 3)) {
Shaggizise();
} else {
glTextureSubImage2D(texture.handle, mip_map, x0, y0,
static_cast<GLsizei>(rect.GetWidth()),
static_cast<GLsizei>(rect.GetHeight()), tuple.format,
tuple.type, &gl_buffer[mip_map][buffer_offset]);
}
break;
case SurfaceTarget::Texture3D:
glTextureSubImage3D(texture.handle, mip_map, x0, y0, 0,
@@ -857,6 +884,7 @@ RasterizerCacheOpenGL::RasterizerCacheOpenGL(RasterizerOpenGL& rasterizer)
read_framebuffer.Create();
draw_framebuffer.Create();
copy_pbo.Create();
srand(time(NULL));
}
Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextureInfo& config,
@@ -958,10 +986,31 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params, bool pres
}
Surface RasterizerCacheOpenGL::GetUncachedSurface(const SurfaceParams& params) {
if (!shaggied) {
OpenGLState prev_state{OpenGLState::GetCurState()};
SCOPE_EXIT({ prev_state.Apply(); });
glCreateTextures(GL_TEXTURE_2D, 1, &shaggie);
glTextureStorage2D(shaggie, 1, GL_RGBA8, shaggie_width, shaggie_height);
glTextureSubImage2D(shaggie, 0, 0, 0, shaggie_width, shaggie_height, GL_RGBA,
GL_UNSIGNED_BYTE, shaggy_rgba);
// DSA framebuffers are broken on Nvidia
glGenFramebuffers(1, &read_buf);
glGenFramebuffers(1, &draw_buf);
OpenGLState state;
state.draw.read_framebuffer = read_buf;
state.Apply();
glFramebufferTexture(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, shaggie, 0);
shaggied = true;
}
Surface surface{TryGetReservedSurface(params)};
if (!surface) {
// No reserved surface available, create a new one and reserve it
surface = std::make_shared<CachedSurface>(params);
surface = std::make_shared<CachedSurface>(params, read_buf, draw_buf);
ReserveSurface(surface);
}
return surface;

View File

@@ -350,7 +350,7 @@ class RasterizerOpenGL;
class CachedSurface final : public RasterizerCacheObject {
public:
explicit CachedSurface(const SurfaceParams& params);
explicit CachedSurface(const SurfaceParams& params, GLuint shaggie_read, GLuint shaggie_draw);
VAddr GetCpuAddr() const override {
return cpu_addr;
@@ -438,6 +438,9 @@ private:
bool reinterpreted = false;
bool must_reload = false;
VAddr cpu_addr{};
GLuint shaggie_read{};
GLuint shaggie_draw{};
};
class RasterizerCacheOpenGL final : public RasterizerCache<Surface> {
@@ -550,6 +553,11 @@ private:
}
RasterizerCache<Surface>::Unregister(object);
}
bool shaggied{};
GLuint shaggie{};
GLuint read_buf{};
GLuint draw_buf{};
};
} // namespace OpenGL

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
/* Generated by bin2c, do not edit manually */
#ifndef shaggy_h_included
#define shaggy_h_included
/* Contents of file .\shaggy.rgba */
extern const long int shaggy_rgba_size;
extern const unsigned char shaggy_rgba[1048576];
#endif /* __shaggy_h_included */

View File

@@ -373,6 +373,7 @@ void Config::ReadValues() {
ReadSetting("use_accurate_gpu_emulation", false).toBool();
Settings::values.use_asynchronous_gpu_emulation =
ReadSetting("use_asynchronous_gpu_emulation", false).toBool();
Settings::values.shaggie = ReadSetting("shaggie", false).toBool();
Settings::values.bg_red = ReadSetting("bg_red", 0.0).toFloat();
Settings::values.bg_green = ReadSetting("bg_green", 0.0).toFloat();
@@ -649,6 +650,7 @@ void Config::SaveValues() {
WriteSetting("use_accurate_gpu_emulation", Settings::values.use_accurate_gpu_emulation, false);
WriteSetting("use_asynchronous_gpu_emulation", Settings::values.use_asynchronous_gpu_emulation,
false);
WriteSetting("shaggie", Settings::values.shaggie, false);
// Cast to double because Qt's written float values are not human-readable
WriteSetting("bg_red", (double)Settings::values.bg_red, 0.0);

View File

@@ -77,6 +77,7 @@ void ConfigureGraphics::setConfiguration() {
ui->use_accurate_gpu_emulation->setChecked(Settings::values.use_accurate_gpu_emulation);
ui->use_asynchronous_gpu_emulation->setEnabled(!Core::System::GetInstance().IsPoweredOn());
ui->use_asynchronous_gpu_emulation->setChecked(Settings::values.use_asynchronous_gpu_emulation);
ui->d3d15->setChecked(Settings::values.shaggie);
UpdateBackgroundColorButton(QColor::fromRgbF(Settings::values.bg_red, Settings::values.bg_green,
Settings::values.bg_blue));
}
@@ -93,6 +94,7 @@ void ConfigureGraphics::applyConfiguration() {
Settings::values.bg_red = static_cast<float>(bg_color.redF());
Settings::values.bg_green = static_cast<float>(bg_color.greenF());
Settings::values.bg_blue = static_cast<float>(bg_color.blueF());
Settings::values.shaggie = ui->d3d15->isChecked();
}
void ConfigureGraphics::UpdateBackgroundColorButton(QColor color) {

View File

@@ -49,6 +49,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="d3d15">
<property name="text">
<string>Enable D3D15 with jaggies</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="use_disk_shader_cache">
<property name="text">