summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp11
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp15
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.h18
3 files changed, 40 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 0a33868b7..30be38dd4 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -654,7 +654,16 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr
654 buffer_draw_state.bindpoint = current_bindpoint + bindpoint; 654 buffer_draw_state.bindpoint = current_bindpoint + bindpoint;
655 655
656 boost::optional<VAddr> addr = gpu.memory_manager->GpuToCpuAddress(buffer.address); 656 boost::optional<VAddr> addr = gpu.memory_manager->GpuToCpuAddress(buffer.address);
657 std::vector<u8> data(used_buffer.GetSize() * sizeof(float)); 657
658 std::vector<u8> data;
659 if (used_buffer.IsIndirect()) {
660 // Buffer is accessed indirectly, so upload the entire thing
661 data.resize(buffer.size * sizeof(float));
662 } else {
663 // Buffer is accessed directly, upload just what we use
664 data.resize(used_buffer.GetSize() * sizeof(float));
665 }
666
658 Memory::ReadBlock(*addr, data.data(), data.size()); 667 Memory::ReadBlock(*addr, data.data(), data.size());
659 668
660 glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer_draw_state.ssbo); 669 glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer_draw_state.ssbo);
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 94c4858ea..44c8bf4d4 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -377,6 +377,21 @@ public:
377 } 377 }
378 } 378 }
379 379
380 std::string GetUniformIndirect(u64 index, s64 offset, const Register& index_reg,
381 GLSLRegister::Type type) {
382 declr_const_buffers[index].MarkAsUsedIndirect(index, stage);
383 std::string value = 'c' + std::to_string(index) + "[(floatBitsToInt(" +
384 GetRegister(index_reg, 0) + ") + " + std::to_string(offset) + ") / 4]";
385
386 if (type == GLSLRegister::Type::Float) {
387 return value;
388 } else if (type == GLSLRegister::Type::Integer) {
389 return "floatBitsToInt(" + value + ')';
390 } else {
391 UNREACHABLE();
392 }
393 }
394
380 /// Add declarations for registers 395 /// Add declarations for registers
381 void GenerateDeclarations() { 396 void GenerateDeclarations() {
382 for (const auto& reg : regs) { 397 for (const auto& reg : regs) {
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h
index 458032b5c..ad795610c 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.h
+++ b/src/video_core/renderer_opengl/gl_shader_gen.h
@@ -22,17 +22,28 @@ class ConstBufferEntry {
22 using Maxwell = Tegra::Engines::Maxwell3D::Regs; 22 using Maxwell = Tegra::Engines::Maxwell3D::Regs;
23 23
24public: 24public:
25 void MarkAsUsed(unsigned index, unsigned offset, Maxwell::ShaderStage stage) { 25 void MarkAsUsed(u64 index, u64 offset, Maxwell::ShaderStage stage) {
26 is_used = true; 26 is_used = true;
27 this->index = index; 27 this->index = static_cast<unsigned>(index);
28 this->stage = stage;
29 max_offset = std::max(max_offset, static_cast<unsigned>(offset));
30 }
31
32 void MarkAsUsedIndirect(u64 index, Maxwell::ShaderStage stage) {
33 is_used = true;
34 is_indirect = true;
35 this->index = static_cast<unsigned>(index);
28 this->stage = stage; 36 this->stage = stage;
29 max_offset = std::max(max_offset, offset);
30 } 37 }
31 38
32 bool IsUsed() const { 39 bool IsUsed() const {
33 return is_used; 40 return is_used;
34 } 41 }
35 42
43 bool IsIndirect() const {
44 return is_indirect;
45 }
46
36 unsigned GetIndex() const { 47 unsigned GetIndex() const {
37 return index; 48 return index;
38 } 49 }
@@ -51,6 +62,7 @@ private:
51 }; 62 };
52 63
53 bool is_used{}; 64 bool is_used{};
65 bool is_indirect{};
54 unsigned index{}; 66 unsigned index{};
55 unsigned max_offset{}; 67 unsigned max_offset{};
56 Maxwell::ShaderStage stage; 68 Maxwell::ShaderStage stage;