summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-07-05 03:10:59 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-07-05 15:46:53 +0200
commit3b9d89839dc62e9e63a3cbe9636cf85276babdfb (patch)
treed99f4a48789f01c671f132c144f2dff2256223aa /src/video_core
parenttexture_cache: Correct Texture Buffer Uploading (diff)
downloadyuzu-3b9d89839dc62e9e63a3cbe9636cf85276babdfb.tar
yuzu-3b9d89839dc62e9e63a3cbe9636cf85276babdfb.tar.gz
yuzu-3b9d89839dc62e9e63a3cbe9636cf85276babdfb.tar.bz2
yuzu-3b9d89839dc62e9e63a3cbe9636cf85276babdfb.tar.lz
yuzu-3b9d89839dc62e9e63a3cbe9636cf85276babdfb.tar.xz
yuzu-3b9d89839dc62e9e63a3cbe9636cf85276babdfb.tar.zst
yuzu-3b9d89839dc62e9e63a3cbe9636cf85276babdfb.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp6
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp6
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.h9
-rw-r--r--src/video_core/texture_cache/surface_base.h4
4 files changed, 13 insertions, 12 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 718703091..1bd182d98 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -103,14 +103,16 @@ constexpr std::tuple<const char*, const char*, u32> GetPrimitiveDescription(GLen
/// Calculates the size of a program stream
std::size_t CalculateProgramSize(const GLShader::ProgramCode& program) {
constexpr std::size_t start_offset = 10;
- constexpr u64 key = 0xE2400FFFFF07000FULL;
+ // This is the encoded version of BRA that jumps to itself. All Nvidia
+ // shaders end with one.
+ constexpr u64 self_jumping_branch = 0xE2400FFFFF07000FULL;
constexpr u64 mask = 0xFFFFFFFFFF7FFFFFULL;
std::size_t offset = start_offset;
std::size_t size = start_offset * sizeof(u64);
while (offset < program.size()) {
const u64 instruction = program[offset];
if (!IsSchedInstruction(offset, start_offset)) {
- if ((instruction & mask) == key) {
+ if ((instruction & mask) == self_jumping_branch) {
// End on Maxwell's "nop" instruction
break;
}
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 780526b66..08ae1a429 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -267,7 +267,7 @@ void CachedSurface::DownloadTexture(std::vector<u8>& staging_buffer) {
}
}
-void CachedSurface::UploadTexture(std::vector<u8>& staging_buffer) {
+void CachedSurface::UploadTexture(const std::vector<u8>& staging_buffer) {
MICROPROFILE_SCOPE(OpenGL_Texture_Upload);
SCOPE_EXIT({ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); });
for (u32 level = 0; level < params.emulated_levels; ++level) {
@@ -275,7 +275,7 @@ void CachedSurface::UploadTexture(std::vector<u8>& staging_buffer) {
}
}
-void CachedSurface::UploadTextureMipmap(u32 level, std::vector<u8>& staging_buffer) {
+void CachedSurface::UploadTextureMipmap(u32 level, const std::vector<u8>& staging_buffer) {
glPixelStorei(GL_UNPACK_ALIGNMENT, std::min(8U, params.GetRowAlignment(level)));
glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(params.GetMipWidth(level)));
@@ -284,7 +284,7 @@ void CachedSurface::UploadTextureMipmap(u32 level, std::vector<u8>& staging_buff
const std::size_t mip_offset = compression_type == SurfaceCompression::Converted
? params.GetConvertedMipmapOffset(level)
: params.GetHostMipmapLevelOffset(level);
- u8* buffer{staging_buffer.data() + mip_offset};
+ const u8* buffer{staging_buffer.data() + mip_offset};
if (is_compressed) {
const auto image_size{static_cast<GLsizei>(params.GetHostMipmapSize(level))};
switch (params.target) {
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h
index e7cc66fbb..ff6ab6988 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.h
+++ b/src/video_core/renderer_opengl/gl_texture_cache.h
@@ -39,7 +39,7 @@ public:
explicit CachedSurface(GPUVAddr gpu_addr, const SurfaceParams& params);
~CachedSurface();
- void UploadTexture(std::vector<u8>& staging_buffer) override;
+ void UploadTexture(const std::vector<u8>& staging_buffer) override;
void DownloadTexture(std::vector<u8>& staging_buffer) override;
GLenum GetTarget() const {
@@ -57,7 +57,7 @@ protected:
View CreateViewInner(const ViewParams& view_key, bool is_proxy);
private:
- void UploadTextureMipmap(u32 level, std::vector<u8>& staging_buffer);
+ void UploadTextureMipmap(u32 level, const std::vector<u8>& staging_buffer);
GLenum internal_format{};
GLenum format{};
@@ -72,14 +72,13 @@ private:
class CachedSurfaceView final : public VideoCommon::ViewBase {
public:
- explicit CachedSurfaceView(CachedSurface& surface, const ViewParams& params,
- const bool is_proxy);
+ explicit CachedSurfaceView(CachedSurface& surface, const ViewParams& params, bool is_proxy);
~CachedSurfaceView();
/// Attaches this texture view to the current bound GL_DRAW_FRAMEBUFFER
void Attach(GLenum attachment, GLenum target) const;
- GLuint GetTexture() {
+ GLuint GetTexture() const {
if (is_proxy) {
return surface.GetTexture();
}
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h
index eaed6545d..8ba386a8a 100644
--- a/src/video_core/texture_cache/surface_base.h
+++ b/src/video_core/texture_cache/surface_base.h
@@ -9,7 +9,7 @@
#include <vector>
#include "common/assert.h"
-#include "common/common_funcs.h"
+#include "common/binary_find.h"
#include "common/common_types.h"
#include "video_core/gpu.h"
#include "video_core/morton.h"
@@ -191,7 +191,7 @@ private:
template <typename TView>
class SurfaceBase : public SurfaceBaseImpl {
public:
- virtual void UploadTexture(std::vector<u8>& staging_buffer) = 0;
+ virtual void UploadTexture(const std::vector<u8>& staging_buffer) = 0;
virtual void DownloadTexture(std::vector<u8>& staging_buffer) = 0;