summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-04-07 08:30:26 -0400
committerGravatar FernandoS272019-04-08 11:36:11 -0400
commit492040bd9ce40f86f9845699d68104d31d272155 (patch)
treed49167082e927cc97e7d6880decd3d26680c7fb9 /src
parentFix bad rebase (diff)
downloadyuzu-492040bd9ce40f86f9845699d68104d31d272155.tar.gz
yuzu-492040bd9ce40f86f9845699d68104d31d272155.tar.xz
yuzu-492040bd9ce40f86f9845699d68104d31d272155.zip
Move ConstBufferAccessor to Maxwell3d, correct mistakes and clang format.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/CMakeLists.txt1
-rw-r--r--src/video_core/const_buffer_accessor.h28
-rw-r--r--src/video_core/engines/maxwell_3d.cpp12
-rw-r--r--src/video_core/engines/maxwell_3d.h2
-rw-r--r--src/video_core/engines/shader_bytecode.h2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp10
-rw-r--r--src/video_core/renderer_opengl/gl_shader_disk_cache.cpp7
-rw-r--r--src/video_core/shader/decode/texture.cpp3
-rw-r--r--src/video_core/shader/shader_ir.h4
9 files changed, 25 insertions, 44 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index c58f51f18..242a0d1cd 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -1,5 +1,4 @@
1add_library(video_core STATIC 1add_library(video_core STATIC
2 const_buffer_accessor.h
3 dma_pusher.cpp 2 dma_pusher.cpp
4 dma_pusher.h 3 dma_pusher.h
5 debug_utils/debug_utils.cpp 4 debug_utils/debug_utils.cpp
diff --git a/src/video_core/const_buffer_accessor.h b/src/video_core/const_buffer_accessor.h
deleted file mode 100644
index 01524673b..000000000
--- a/src/video_core/const_buffer_accessor.h
+++ /dev/null
@@ -1,28 +0,0 @@
1#pragma once
2
3#include <cstring>
4
5#include "common/common_types.h"
6#include "core/core.h"
7#include "video_core/engines/maxwell_3d.h"
8#include "video_core/gpu.h"
9#include "video_core/memory_manager.h"
10
11namespace Tegra {
12
13namespace ConstBufferAccessor {
14
15template <typename T>
16T access(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, u64 const_buffer, u64 offset) {
17 auto& gpu = Core::System::GetInstance().GPU();
18 auto& memory_manager = gpu.MemoryManager();
19 auto& maxwell3d = gpu.Maxwell3D();
20 const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<std::size_t>(stage)];
21 const auto& buffer = shader_stage.const_buffers[const_buffer];
22 T result;
23 std::memcpy(&result, memory_manager.GetPointer(buffer.address + offset), sizeof(T));
24 return result;
25}
26
27} // namespace ConstBufferAccessor
28} // namespace Tegra
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 079132135..b198793bc 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -502,8 +502,8 @@ Texture::FullTextureInfo Maxwell3D::GetTextureInfo(const Texture::TextureHandle
502 502
503Texture::FullTextureInfo Maxwell3D::GetStageTexture(Regs::ShaderStage stage, 503Texture::FullTextureInfo Maxwell3D::GetStageTexture(Regs::ShaderStage stage,
504 std::size_t offset) const { 504 std::size_t offset) const {
505 auto& shader = state.shader_stages[static_cast<std::size_t>(stage)]; 505 const auto& shader = state.shader_stages[static_cast<std::size_t>(stage)];
506 auto& tex_info_buffer = shader.const_buffers[regs.tex_cb_index]; 506 const auto& tex_info_buffer = shader.const_buffers[regs.tex_cb_index];
507 ASSERT(tex_info_buffer.enabled && tex_info_buffer.address != 0); 507 ASSERT(tex_info_buffer.enabled && tex_info_buffer.address != 0);
508 508
509 const GPUVAddr tex_info_address = 509 const GPUVAddr tex_info_address =
@@ -529,4 +529,12 @@ void Maxwell3D::ProcessClearBuffers() {
529 rasterizer.Clear(); 529 rasterizer.Clear();
530} 530}
531 531
532u32 Maxwell3D::AccessConstBuffer32(Regs::ShaderStage stage, u64 const_buffer, u64 offset) const {
533 const auto& shader_stage = state.shader_stages[static_cast<std::size_t>(stage)];
534 const auto& buffer = shader_stage.const_buffers[const_buffer];
535 u32 result;
536 std::memcpy(&result, memory_manager.GetPointer(buffer.address + offset), sizeof(u32));
537 return result;
538}
539
532} // namespace Tegra::Engines 540} // namespace Tegra::Engines
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index fd2c35a01..cc2424d38 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -1141,6 +1141,8 @@ public:
1141 /// Returns the texture information for a specific texture in a specific shader stage. 1141 /// Returns the texture information for a specific texture in a specific shader stage.
1142 Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, std::size_t offset) const; 1142 Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, std::size_t offset) const;
1143 1143
1144 u32 AccessConstBuffer32(Regs::ShaderStage stage, u64 const_buffer, u64 offset) const;
1145
1144 /// Memory for macro code - it's undetermined how big this is, however 1MB is much larger than 1146 /// Memory for macro code - it's undetermined how big this is, however 1MB is much larger than
1145 /// we've seen used. 1147 /// we've seen used.
1146 using MacroMemory = std::array<u32, 0x40000>; 1148 using MacroMemory = std::array<u32, 0x40000>;
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index f7ef9a32a..a7ef5da9a 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -976,7 +976,7 @@ union Instruction {
976 BitField<37, 3, TextureProcessMode> process_mode; 976 BitField<37, 3, TextureProcessMode> process_mode;
977 977
978 bool IsComponentEnabled(std::size_t component) const { 978 bool IsComponentEnabled(std::size_t component) const {
979 return ((1ull << component) & component_mask) != 0; 979 return ((1ULL << component) & component_mask) != 0;
980 } 980 }
981 981
982 TextureProcessMode GetTextureProcessMode() const { 982 TextureProcessMode GetTextureProcessMode() const {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index ed1e97a73..6f3bcccec 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -19,7 +19,6 @@
19#include "core/core.h" 19#include "core/core.h"
20#include "core/hle/kernel/process.h" 20#include "core/hle/kernel/process.h"
21#include "core/settings.h" 21#include "core/settings.h"
22#include "video_core/const_buffer_accessor.h"
23#include "video_core/engines/maxwell_3d.h" 22#include "video_core/engines/maxwell_3d.h"
24#include "video_core/renderer_opengl/gl_rasterizer.h" 23#include "video_core/renderer_opengl/gl_rasterizer.h"
25#include "video_core/renderer_opengl/gl_shader_cache.h" 24#include "video_core/renderer_opengl/gl_shader_cache.h"
@@ -985,14 +984,13 @@ void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& s
985 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { 984 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
986 const auto& entry = entries[bindpoint]; 985 const auto& entry = entries[bindpoint];
987 Tegra::Texture::FullTextureInfo texture; 986 Tegra::Texture::FullTextureInfo texture;
988 if (!entry.IsBindless()) { 987 if (entry.IsBindless()) {
989 texture = maxwell3d.GetStageTexture(stage, entry.GetOffset());
990 } else {
991 const auto cbuf = entry.GetBindlessCBuf(); 988 const auto cbuf = entry.GetBindlessCBuf();
992 Tegra::Texture::TextureHandle tex_handle; 989 Tegra::Texture::TextureHandle tex_handle;
993 tex_handle.raw = 990 tex_handle.raw = maxwell3d.AccessConstBuffer32(stage, cbuf.first, cbuf.second);
994 Tegra::ConstBufferAccessor::access<u32>(stage, cbuf.first, cbuf.second);
995 texture = maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset()); 991 texture = maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset());
992 } else {
993 texture = maxwell3d.GetStageTexture(stage, entry.GetOffset());
996 } 994 }
997 const u32 current_bindpoint = base_bindings.sampler + bindpoint; 995 const u32 current_bindpoint = base_bindings.sampler + bindpoint;
998 996
diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
index e27740383..08603b7a5 100644
--- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp
@@ -328,9 +328,10 @@ std::optional<ShaderDiskCacheDecompiled> ShaderDiskCacheOpenGL::LoadDecompiledEn
328 file.ReadBytes(&is_bindless, sizeof(u8)) != sizeof(u8)) { 328 file.ReadBytes(&is_bindless, sizeof(u8)) != sizeof(u8)) {
329 return {}; 329 return {};
330 } 330 }
331 entry.entries.samplers.emplace_back( 331 entry.entries.samplers.emplace_back(static_cast<std::size_t>(offset),
332 static_cast<std::size_t>(offset), static_cast<std::size_t>(index), 332 static_cast<std::size_t>(index),
333 static_cast<Tegra::Shader::TextureType>(type), is_array != 0, is_shadow != 0, is_bindless != 0); 333 static_cast<Tegra::Shader::TextureType>(type),
334 is_array != 0, is_shadow != 0, is_bindless != 0);
334 } 335 }
335 336
336 u32 global_memory_count{}; 337 u32 global_memory_count{};
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp
index 99385c46e..dd5310c36 100644
--- a/src/video_core/shader/decode/texture.cpp
+++ b/src/video_core/shader/decode/texture.cpp
@@ -153,6 +153,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
153 } 153 }
154 case OpCode::Id::TXQ_B: 154 case OpCode::Id::TXQ_B:
155 is_bindless = true; 155 is_bindless = true;
156 [[fallthrough]];
156 case OpCode::Id::TXQ: { 157 case OpCode::Id::TXQ: {
157 if (instr.txq.UsesMiscMode(TextureMiscMode::NODEP)) { 158 if (instr.txq.UsesMiscMode(TextureMiscMode::NODEP)) {
158 LOG_WARNING(HW_GPU, "TXQ.NODEP implementation is incomplete"); 159 LOG_WARNING(HW_GPU, "TXQ.NODEP implementation is incomplete");
@@ -193,6 +194,7 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
193 } 194 }
194 case OpCode::Id::TMML_B: 195 case OpCode::Id::TMML_B:
195 is_bindless = true; 196 is_bindless = true;
197 [[fallthrough]];
196 case OpCode::Id::TMML: { 198 case OpCode::Id::TMML: {
197 UNIMPLEMENTED_IF_MSG(instr.tmml.UsesMiscMode(Tegra::Shader::TextureMiscMode::NDV), 199 UNIMPLEMENTED_IF_MSG(instr.tmml.UsesMiscMode(Tegra::Shader::TextureMiscMode::NDV),
198 "NDV is not implemented"); 200 "NDV is not implemented");
@@ -285,7 +287,6 @@ const Sampler& ShaderIR::GetSampler(const Tegra::Shader::Sampler& sampler, Textu
285 287
286const Sampler& ShaderIR::GetBindlessSampler(const Tegra::Shader::Register& reg, TextureType type, 288const Sampler& ShaderIR::GetBindlessSampler(const Tegra::Shader::Register& reg, TextureType type,
287 bool is_array, bool is_shadow) { 289 bool is_array, bool is_shadow) {
288
289 const Node sampler_register = GetRegister(reg); 290 const Node sampler_register = GetRegister(reg);
290 const Node base_sampler = 291 const Node base_sampler =
291 TrackCbuf(sampler_register, global_code, static_cast<s64>(global_code.size())); 292 TrackCbuf(sampler_register, global_code, static_cast<s64>(global_code.size()));
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index 11495799f..249024167 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -196,7 +196,7 @@ enum class ExitMethod {
196 196
197class Sampler { 197class Sampler {
198public: 198public:
199 // Use this constructor for binded Samplers 199 // Use this constructor for bounded Samplers
200 explicit Sampler(std::size_t offset, std::size_t index, Tegra::Shader::TextureType type, 200 explicit Sampler(std::size_t offset, std::size_t index, Tegra::Shader::TextureType type,
201 bool is_array, bool is_shadow) 201 bool is_array, bool is_shadow)
202 : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow}, 202 : offset{offset}, index{index}, type{type}, is_array{is_array}, is_shadow{is_shadow},
@@ -239,7 +239,7 @@ public:
239 } 239 }
240 240
241 std::pair<u32, u32> GetBindlessCBuf() const { 241 std::pair<u32, u32> GetBindlessCBuf() const {
242 return {offset >> 32, offset & 0x00000000FFFFFFFFULL}; 242 return {static_cast<u32>(offset >> 32), static_cast<u32>(offset)};
243 } 243 }
244 244
245 bool operator<(const Sampler& rhs) const { 245 bool operator<(const Sampler& rhs) const {