summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-03-28 19:54:52 +0100
committerFernandoS27 <fsahmkow27@gmail.com>2019-04-08 17:35:19 +0200
commita77e9a27b0e82192cd17eea255e6b04893ccafa7 (patch)
tree59046137210e4f1a521df694e38813527227c424
parentRefactor GetTextureCode and GetTexCode to use an optional instead of optional parameters (diff)
downloadyuzu-a77e9a27b0e82192cd17eea255e6b04893ccafa7.tar
yuzu-a77e9a27b0e82192cd17eea255e6b04893ccafa7.tar.gz
yuzu-a77e9a27b0e82192cd17eea255e6b04893ccafa7.tar.bz2
yuzu-a77e9a27b0e82192cd17eea255e6b04893ccafa7.tar.lz
yuzu-a77e9a27b0e82192cd17eea255e6b04893ccafa7.tar.xz
yuzu-a77e9a27b0e82192cd17eea255e6b04893ccafa7.tar.zst
yuzu-a77e9a27b0e82192cd17eea255e6b04893ccafa7.zip
-rw-r--r--src/video_core/CMakeLists.txt1
-rw-r--r--src/video_core/const_buffer_accessor.cpp39
-rw-r--r--src/video_core/const_buffer_accessor.h26
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp6
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h3
5 files changed, 22 insertions, 53 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index 804395d38..c58f51f18 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -1,5 +1,4 @@
add_library(video_core STATIC
- const_buffer_accessor.cpp
const_buffer_accessor.h
dma_pusher.cpp
dma_pusher.h
diff --git a/src/video_core/const_buffer_accessor.cpp b/src/video_core/const_buffer_accessor.cpp
deleted file mode 100644
index 0e613e1f9..000000000
--- a/src/video_core/const_buffer_accessor.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#pragma once
-
-#include <cstring>
-
-#include "common/common_types.h"
-#include "core/core.h"
-#include "core/memory.h"
-#include "video_core/const_buffer_accessor.h"
-#include "video_core/engines/maxwell_3d.h"
-#include "video_core/gpu.h"
-#include "video_core/memory_manager.h"
-
-namespace Tegra {
-
-u32 ConstBufferAccessor::access32(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
- u64 const_buffer, u64 offset) {
- auto& gpu = Core::System::GetInstance().GPU();
- auto& memory_manager = gpu.MemoryManager();
- auto& maxwell3d = gpu.Maxwell3D();
- const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<std::size_t>(stage)];
- const auto& buffer = shader_stage.const_buffers[const_buffer];
- u32 result;
- std::memcpy(&result, memory_manager.GetPointer(buffer.address + offset), sizeof(u32));
- return result;
-}
-
-u64 ConstBufferAccessor::access64(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
- u64 const_buffer, u64 offset) {
- auto& gpu = Core::System::GetInstance().GPU();
- auto& memory_manager = gpu.MemoryManager();
- auto& maxwell3d = gpu.Maxwell3D();
- const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<std::size_t>(stage)];
- const auto& buffer = shader_stage.const_buffers[const_buffer];
- u64 result;
- std::memcpy(&result, memory_manager.GetPointer(buffer.address + offset), sizeof(u64));
- return result;
-}
-
-} // namespace Tegra
diff --git a/src/video_core/const_buffer_accessor.h b/src/video_core/const_buffer_accessor.h
index 37d1ca767..01524673b 100644
--- a/src/video_core/const_buffer_accessor.h
+++ b/src/video_core/const_buffer_accessor.h
@@ -1,18 +1,28 @@
#pragma once
+#include <cstring>
+
#include "common/common_types.h"
+#include "core/core.h"
#include "video_core/engines/maxwell_3d.h"
+#include "video_core/gpu.h"
+#include "video_core/memory_manager.h"
namespace Tegra {
-class ConstBufferAccessor {
-public:
- ConstBufferAccessor() {}
- ~ConstBufferAccessor() = default;
-
- u32 access32(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, u64 const_buffer, u64 offset);
+namespace ConstBufferAccessor {
- u64 access64(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, u64 const_buffer, u64 offset);
-};
+template <typename T>
+T access(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, u64 const_buffer, u64 offset) {
+ auto& gpu = Core::System::GetInstance().GPU();
+ auto& memory_manager = gpu.MemoryManager();
+ auto& maxwell3d = gpu.Maxwell3D();
+ const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<std::size_t>(stage)];
+ const auto& buffer = shader_stage.const_buffers[const_buffer];
+ T result;
+ std::memcpy(&result, memory_manager.GetPointer(buffer.address + offset), sizeof(T));
+ return result;
+}
+} // namespace ConstBufferAccessor
} // namespace Tegra
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index e847b75fb..30cad484a 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -19,6 +19,7 @@
#include "core/core.h"
#include "core/hle/kernel/process.h"
#include "core/settings.h"
+#include "video_core/const_buffer_accessor.h"
#include "video_core/engines/maxwell_3d.h"
#include "video_core/renderer_opengl/gl_rasterizer.h"
#include "video_core/renderer_opengl/gl_shader_cache.h"
@@ -101,7 +102,7 @@ struct FramebufferCacheKey {
RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, Core::System& system,
ScreenInfo& info)
: res_cache{*this}, shader_cache{*this, system}, global_cache{*this}, system{system},
- screen_info{info}, buffer_cache(*this, STREAM_BUFFER_SIZE), const_buffer_accessor() {
+ screen_info{info}, buffer_cache(*this, STREAM_BUFFER_SIZE) {
// Create sampler objects
for (std::size_t i = 0; i < texture_samplers.size(); ++i) {
texture_samplers[i].Create();
@@ -990,7 +991,8 @@ void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& s
} else {
const auto cbuf = entry.GetBindlessCBuf();
Tegra::Texture::TextureHandle tex_handle;
- tex_handle.raw = const_buffer_accessor.access32(stage, cbuf.first, cbuf.second);
+ tex_handle.raw =
+ Tegra::ConstBufferAccessor::access<u32>(stage, cbuf.first, cbuf.second);
texture = maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset());
}
const u32 current_bindpoint = base_bindings.sampler + bindpoint;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 886e9c2b5..54fbf48aa 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -17,7 +17,6 @@
#include <glad/glad.h>
#include "common/common_types.h"
-#include "video_core/const_buffer_accessor.h"
#include "video_core/engines/maxwell_3d.h"
#include "video_core/rasterizer_cache.h"
#include "video_core/rasterizer_interface.h"
@@ -230,8 +229,6 @@ private:
PrimitiveAssembler primitive_assembler{buffer_cache};
GLint uniform_buffer_alignment;
- Tegra::ConstBufferAccessor const_buffer_accessor;
-
std::size_t CalculateVertexArraysSize() const;
std::size_t CalculateIndexBufferSize() const;