summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-03-26 19:37:43 +0100
committerFernandoS27 <fsahmkow27@gmail.com>2019-04-08 17:19:34 +0200
commitc4ac05c82c49e678ca78147b2716e0a26b103f8d (patch)
tree788729622f3a608e980a2f705afc71a107d62b14
parentMerge pull request #2300 from FernandoS27/null-shader (diff)
downloadyuzu-c4ac05c82c49e678ca78147b2716e0a26b103f8d.tar
yuzu-c4ac05c82c49e678ca78147b2716e0a26b103f8d.tar.gz
yuzu-c4ac05c82c49e678ca78147b2716e0a26b103f8d.tar.bz2
yuzu-c4ac05c82c49e678ca78147b2716e0a26b103f8d.tar.lz
yuzu-c4ac05c82c49e678ca78147b2716e0a26b103f8d.tar.xz
yuzu-c4ac05c82c49e678ca78147b2716e0a26b103f8d.tar.zst
yuzu-c4ac05c82c49e678ca78147b2716e0a26b103f8d.zip
-rw-r--r--src/video_core/CMakeLists.txt2
-rw-r--r--src/video_core/const_buffer_accessor.cpp35
-rw-r--r--src/video_core/const_buffer_accessor.h21
-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, 65 insertions, 2 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index 242a0d1cd..804395d38 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -1,4 +1,6 @@
add_library(video_core STATIC
+ const_buffer_accessor.cpp
+ const_buffer_accessor.h
dma_pusher.cpp
dma_pusher.h
debug_utils/debug_utils.cpp
diff --git a/src/video_core/const_buffer_accessor.cpp b/src/video_core/const_buffer_accessor.cpp
new file mode 100644
index 000000000..c89ab91c7
--- /dev/null
+++ b/src/video_core/const_buffer_accessor.cpp
@@ -0,0 +1,35 @@
+#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& memory_manager = Core::System::GetInstance().GPU().MemoryManager();
+ 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 * 4), sizeof(u32));
+ return result;
+}
+
+u64 ConstBufferAccessor::access64(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
+ u64 const_buffer, u64 offset) {
+ auto& memory_manager = Core::System::GetInstance().GPU().MemoryManager();
+ 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 * 4), sizeof(u64));
+ return result;
+}
+
+} // namespace Tegra
diff --git a/src/video_core/const_buffer_accessor.h b/src/video_core/const_buffer_accessor.h
new file mode 100644
index 000000000..2410f1483
--- /dev/null
+++ b/src/video_core/const_buffer_accessor.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "common/common_types.h"
+#include "video_core/engines/maxwell_3d.h"
+
+namespace Tegra {
+
+class ConstBufferAccessor {
+public:
+ ConstBufferAccessor(Tegra::Engines::Maxwell3D& maxwell3d) : maxwell3d(maxwell3d) {}
+ ~ConstBufferAccessor() = default;
+
+ u32 access32(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, u64 const_buffer, u64 offset);
+
+ u64 access64(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, u64 const_buffer, u64 offset);
+
+private:
+ Tegra::Engines::Maxwell3D& maxwell3d;
+};
+
+} // namespace Tegra
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 7ff1e6737..f2ac5382d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -98,9 +98,11 @@ struct FramebufferCacheKey {
}
};
-RasterizerOpenGL::RasterizerOpenGL(Core::System& system, ScreenInfo& info)
+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) {
+ screen_info{info}, buffer_cache(*this, STREAM_BUFFER_SIZE),
+ const_buffer_accessor(system.GPU().Maxwell3D()) {
// Create sampler objects
for (std::size_t i = 0; i < texture_samplers.size(); ++i) {
texture_samplers[i].Create();
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 54fbf48aa..886e9c2b5 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -17,6 +17,7 @@
#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"
@@ -229,6 +230,8 @@ 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;