diff options
| author | 2020-06-25 23:34:37 +0200 | |
|---|---|---|
| committer | 2020-06-25 23:34:37 +0200 | |
| commit | 0f4512291a0504b32fac248f73a68fec34f657fe (patch) | |
| tree | 3c69736a2ac82a9a0076ec3b79673c814e5f1abd /src/video_core/engines | |
| parent | Fix typo 2: electric boogaloo (diff) | |
| parent | Merge pull request #4136 from VolcaEM/mods (diff) | |
| download | yuzu-0f4512291a0504b32fac248f73a68fec34f657fe.tar.gz yuzu-0f4512291a0504b32fac248f73a68fec34f657fe.tar.xz yuzu-0f4512291a0504b32fac248f73a68fec34f657fe.zip | |
Merge branch 'master' into quickstart-faq
Diffstat (limited to 'src/video_core/engines')
| -rw-r--r-- | src/video_core/engines/const_buffer_engine_interface.h | 1 | ||||
| -rw-r--r-- | src/video_core/engines/kepler_compute.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/engines/kepler_compute.h | 2 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 26 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 27 |
5 files changed, 35 insertions, 26 deletions
diff --git a/src/video_core/engines/const_buffer_engine_interface.h b/src/video_core/engines/const_buffer_engine_interface.h index ebe139504..f46e81bb7 100644 --- a/src/video_core/engines/const_buffer_engine_interface.h +++ b/src/video_core/engines/const_buffer_engine_interface.h | |||
| @@ -93,6 +93,7 @@ public: | |||
| 93 | virtual SamplerDescriptor AccessBoundSampler(ShaderType stage, u64 offset) const = 0; | 93 | virtual SamplerDescriptor AccessBoundSampler(ShaderType stage, u64 offset) const = 0; |
| 94 | virtual SamplerDescriptor AccessBindlessSampler(ShaderType stage, u64 const_buffer, | 94 | virtual SamplerDescriptor AccessBindlessSampler(ShaderType stage, u64 const_buffer, |
| 95 | u64 offset) const = 0; | 95 | u64 offset) const = 0; |
| 96 | virtual SamplerDescriptor AccessSampler(u32 handle) const = 0; | ||
| 96 | virtual u32 GetBoundBuffer() const = 0; | 97 | virtual u32 GetBoundBuffer() const = 0; |
| 97 | 98 | ||
| 98 | virtual VideoCore::GuestDriverProfile& AccessGuestDriverProfile() = 0; | 99 | virtual VideoCore::GuestDriverProfile& AccessGuestDriverProfile() = 0; |
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp index f6237fc6a..a82b06a38 100644 --- a/src/video_core/engines/kepler_compute.cpp +++ b/src/video_core/engines/kepler_compute.cpp | |||
| @@ -92,8 +92,11 @@ SamplerDescriptor KeplerCompute::AccessBindlessSampler(ShaderType stage, u64 con | |||
| 92 | ASSERT(stage == ShaderType::Compute); | 92 | ASSERT(stage == ShaderType::Compute); |
| 93 | const auto& tex_info_buffer = launch_description.const_buffer_config[const_buffer]; | 93 | const auto& tex_info_buffer = launch_description.const_buffer_config[const_buffer]; |
| 94 | const GPUVAddr tex_info_address = tex_info_buffer.Address() + offset; | 94 | const GPUVAddr tex_info_address = tex_info_buffer.Address() + offset; |
| 95 | return AccessSampler(memory_manager.Read<u32>(tex_info_address)); | ||
| 96 | } | ||
| 95 | 97 | ||
| 96 | const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(tex_info_address)}; | 98 | SamplerDescriptor KeplerCompute::AccessSampler(u32 handle) const { |
| 99 | const Texture::TextureHandle tex_handle{handle}; | ||
| 97 | const Texture::FullTextureInfo tex_info = GetTextureInfo(tex_handle); | 100 | const Texture::FullTextureInfo tex_info = GetTextureInfo(tex_handle); |
| 98 | SamplerDescriptor result = SamplerDescriptor::FromTIC(tex_info.tic); | 101 | SamplerDescriptor result = SamplerDescriptor::FromTIC(tex_info.tic); |
| 99 | result.is_shadow.Assign(tex_info.tsc.depth_compare_enabled.Value()); | 102 | result.is_shadow.Assign(tex_info.tsc.depth_compare_enabled.Value()); |
diff --git a/src/video_core/engines/kepler_compute.h b/src/video_core/engines/kepler_compute.h index 18ceedfaf..b7f668d88 100644 --- a/src/video_core/engines/kepler_compute.h +++ b/src/video_core/engines/kepler_compute.h | |||
| @@ -219,6 +219,8 @@ public: | |||
| 219 | SamplerDescriptor AccessBindlessSampler(ShaderType stage, u64 const_buffer, | 219 | SamplerDescriptor AccessBindlessSampler(ShaderType stage, u64 const_buffer, |
| 220 | u64 offset) const override; | 220 | u64 offset) const override; |
| 221 | 221 | ||
| 222 | SamplerDescriptor AccessSampler(u32 handle) const override; | ||
| 223 | |||
| 222 | u32 GetBoundBuffer() const override { | 224 | u32 GetBoundBuffer() const override { |
| 223 | return regs.tex_cb_index; | 225 | return regs.tex_cb_index; |
| 224 | } | 226 | } |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 004f6b261..c01436295 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -25,9 +25,8 @@ constexpr u32 MacroRegistersStart = 0xE00; | |||
| 25 | Maxwell3D::Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer, | 25 | Maxwell3D::Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer, |
| 26 | MemoryManager& memory_manager) | 26 | MemoryManager& memory_manager) |
| 27 | : system{system}, rasterizer{rasterizer}, memory_manager{memory_manager}, | 27 | : system{system}, rasterizer{rasterizer}, memory_manager{memory_manager}, |
| 28 | macro_interpreter{*this}, upload_state{memory_manager, regs.upload} { | 28 | macro_engine{GetMacroEngine(*this)}, upload_state{memory_manager, regs.upload} { |
| 29 | dirty.flags.flip(); | 29 | dirty.flags.flip(); |
| 30 | |||
| 31 | InitializeRegisterDefaults(); | 30 | InitializeRegisterDefaults(); |
| 32 | } | 31 | } |
| 33 | 32 | ||
| @@ -106,7 +105,11 @@ void Maxwell3D::InitializeRegisterDefaults() { | |||
| 106 | regs.rasterize_enable = 1; | 105 | regs.rasterize_enable = 1; |
| 107 | regs.rt_separate_frag_data = 1; | 106 | regs.rt_separate_frag_data = 1; |
| 108 | regs.framebuffer_srgb = 1; | 107 | regs.framebuffer_srgb = 1; |
| 108 | regs.line_width_aliased = 1.0f; | ||
| 109 | regs.line_width_smooth = 1.0f; | ||
| 109 | regs.front_face = Maxwell3D::Regs::FrontFace::ClockWise; | 110 | regs.front_face = Maxwell3D::Regs::FrontFace::ClockWise; |
| 111 | regs.polygon_mode_back = Maxwell3D::Regs::PolygonMode::Fill; | ||
| 112 | regs.polygon_mode_front = Maxwell3D::Regs::PolygonMode::Fill; | ||
| 110 | 113 | ||
| 111 | shadow_state = regs; | 114 | shadow_state = regs; |
| 112 | 115 | ||
| @@ -116,7 +119,7 @@ void Maxwell3D::InitializeRegisterDefaults() { | |||
| 116 | mme_inline[MAXWELL3D_REG_INDEX(index_array.count)] = true; | 119 | mme_inline[MAXWELL3D_REG_INDEX(index_array.count)] = true; |
| 117 | } | 120 | } |
| 118 | 121 | ||
| 119 | void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u32* parameters) { | 122 | void Maxwell3D::CallMacroMethod(u32 method, const std::vector<u32>& parameters) { |
| 120 | // Reset the current macro. | 123 | // Reset the current macro. |
| 121 | executing_macro = 0; | 124 | executing_macro = 0; |
| 122 | 125 | ||
| @@ -125,7 +128,7 @@ void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u3 | |||
| 125 | ((method - MacroRegistersStart) >> 1) % static_cast<u32>(macro_positions.size()); | 128 | ((method - MacroRegistersStart) >> 1) % static_cast<u32>(macro_positions.size()); |
| 126 | 129 | ||
| 127 | // Execute the current macro. | 130 | // Execute the current macro. |
| 128 | macro_interpreter.Execute(macro_positions[entry], num_parameters, parameters); | 131 | macro_engine->Execute(*this, macro_positions[entry], parameters); |
| 129 | if (mme_draw.current_mode != MMEDrawMode::Undefined) { | 132 | if (mme_draw.current_mode != MMEDrawMode::Undefined) { |
| 130 | FlushMMEInlineDraw(); | 133 | FlushMMEInlineDraw(); |
| 131 | } | 134 | } |
| @@ -161,7 +164,7 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { | |||
| 161 | 164 | ||
| 162 | // Call the macro when there are no more parameters in the command buffer | 165 | // Call the macro when there are no more parameters in the command buffer |
| 163 | if (is_last_call) { | 166 | if (is_last_call) { |
| 164 | CallMacroMethod(executing_macro, macro_params.size(), macro_params.data()); | 167 | CallMacroMethod(executing_macro, macro_params); |
| 165 | macro_params.clear(); | 168 | macro_params.clear(); |
| 166 | } | 169 | } |
| 167 | return; | 170 | return; |
| @@ -197,7 +200,7 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { | |||
| 197 | break; | 200 | break; |
| 198 | } | 201 | } |
| 199 | case MAXWELL3D_REG_INDEX(macros.data): { | 202 | case MAXWELL3D_REG_INDEX(macros.data): { |
| 200 | ProcessMacroUpload(arg); | 203 | macro_engine->AddCode(regs.macros.upload_address, arg); |
| 201 | break; | 204 | break; |
| 202 | } | 205 | } |
| 203 | case MAXWELL3D_REG_INDEX(macros.bind): { | 206 | case MAXWELL3D_REG_INDEX(macros.bind): { |
| @@ -306,7 +309,7 @@ void Maxwell3D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, | |||
| 306 | 309 | ||
| 307 | // Call the macro when there are no more parameters in the command buffer | 310 | // Call the macro when there are no more parameters in the command buffer |
| 308 | if (amount == methods_pending) { | 311 | if (amount == methods_pending) { |
| 309 | CallMacroMethod(executing_macro, macro_params.size(), macro_params.data()); | 312 | CallMacroMethod(executing_macro, macro_params); |
| 310 | macro_params.clear(); | 313 | macro_params.clear(); |
| 311 | } | 314 | } |
| 312 | return; | 315 | return; |
| @@ -420,9 +423,7 @@ void Maxwell3D::FlushMMEInlineDraw() { | |||
| 420 | } | 423 | } |
| 421 | 424 | ||
| 422 | void Maxwell3D::ProcessMacroUpload(u32 data) { | 425 | void Maxwell3D::ProcessMacroUpload(u32 data) { |
| 423 | ASSERT_MSG(regs.macros.upload_address < macro_memory.size(), | 426 | macro_engine->AddCode(regs.macros.upload_address++, data); |
| 424 | "upload_address exceeded macro_memory size!"); | ||
| 425 | macro_memory[regs.macros.upload_address++] = data; | ||
| 426 | } | 427 | } |
| 427 | 428 | ||
| 428 | void Maxwell3D::ProcessMacroBind(u32 data) { | 429 | void Maxwell3D::ProcessMacroBind(u32 data) { |
| @@ -739,8 +740,11 @@ SamplerDescriptor Maxwell3D::AccessBindlessSampler(ShaderType stage, u64 const_b | |||
| 739 | const auto& shader = state.shader_stages[static_cast<std::size_t>(stage)]; | 740 | const auto& shader = state.shader_stages[static_cast<std::size_t>(stage)]; |
| 740 | const auto& tex_info_buffer = shader.const_buffers[const_buffer]; | 741 | const auto& tex_info_buffer = shader.const_buffers[const_buffer]; |
| 741 | const GPUVAddr tex_info_address = tex_info_buffer.address + offset; | 742 | const GPUVAddr tex_info_address = tex_info_buffer.address + offset; |
| 743 | return AccessSampler(memory_manager.Read<u32>(tex_info_address)); | ||
| 744 | } | ||
| 742 | 745 | ||
| 743 | const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(tex_info_address)}; | 746 | SamplerDescriptor Maxwell3D::AccessSampler(u32 handle) const { |
| 747 | const Texture::TextureHandle tex_handle{handle}; | ||
| 744 | const Texture::FullTextureInfo tex_info = GetTextureInfo(tex_handle); | 748 | const Texture::FullTextureInfo tex_info = GetTextureInfo(tex_handle); |
| 745 | SamplerDescriptor result = SamplerDescriptor::FromTIC(tex_info.tic); | 749 | SamplerDescriptor result = SamplerDescriptor::FromTIC(tex_info.tic); |
| 746 | result.is_shadow.Assign(tex_info.tsc.depth_compare_enabled.Value()); | 750 | result.is_shadow.Assign(tex_info.tsc.depth_compare_enabled.Value()); |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 05dd6b39b..ef1618990 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | #include "video_core/engines/engine_upload.h" | 23 | #include "video_core/engines/engine_upload.h" |
| 24 | #include "video_core/engines/shader_type.h" | 24 | #include "video_core/engines/shader_type.h" |
| 25 | #include "video_core/gpu.h" | 25 | #include "video_core/gpu.h" |
| 26 | #include "video_core/macro_interpreter.h" | 26 | #include "video_core/macro/macro.h" |
| 27 | #include "video_core/textures/texture.h" | 27 | #include "video_core/textures/texture.h" |
| 28 | 28 | ||
| 29 | namespace Core { | 29 | namespace Core { |
| @@ -598,6 +598,7 @@ public: | |||
| 598 | BitField<4, 3, u32> block_height; | 598 | BitField<4, 3, u32> block_height; |
| 599 | BitField<8, 3, u32> block_depth; | 599 | BitField<8, 3, u32> block_depth; |
| 600 | BitField<12, 1, InvMemoryLayout> type; | 600 | BitField<12, 1, InvMemoryLayout> type; |
| 601 | BitField<16, 1, u32> is_3d; | ||
| 601 | } memory_layout; | 602 | } memory_layout; |
| 602 | union { | 603 | union { |
| 603 | BitField<0, 16, u32> layers; | 604 | BitField<0, 16, u32> layers; |
| @@ -1403,6 +1404,8 @@ public: | |||
| 1403 | SamplerDescriptor AccessBindlessSampler(ShaderType stage, u64 const_buffer, | 1404 | SamplerDescriptor AccessBindlessSampler(ShaderType stage, u64 const_buffer, |
| 1404 | u64 offset) const override; | 1405 | u64 offset) const override; |
| 1405 | 1406 | ||
| 1407 | SamplerDescriptor AccessSampler(u32 handle) const override; | ||
| 1408 | |||
| 1406 | u32 GetBoundBuffer() const override { | 1409 | u32 GetBoundBuffer() const override { |
| 1407 | return regs.tex_cb_index; | 1410 | return regs.tex_cb_index; |
| 1408 | } | 1411 | } |
| @@ -1411,17 +1414,16 @@ public: | |||
| 1411 | 1414 | ||
| 1412 | const VideoCore::GuestDriverProfile& AccessGuestDriverProfile() const override; | 1415 | const VideoCore::GuestDriverProfile& AccessGuestDriverProfile() const override; |
| 1413 | 1416 | ||
| 1414 | /// Memory for macro code - it's undetermined how big this is, however 1MB is much larger than | 1417 | bool ShouldExecute() const { |
| 1415 | /// we've seen used. | 1418 | return execute_on; |
| 1416 | using MacroMemory = std::array<u32, 0x40000>; | 1419 | } |
| 1417 | 1420 | ||
| 1418 | /// Gets a reference to macro memory. | 1421 | VideoCore::RasterizerInterface& GetRasterizer() { |
| 1419 | const MacroMemory& GetMacroMemory() const { | 1422 | return rasterizer; |
| 1420 | return macro_memory; | ||
| 1421 | } | 1423 | } |
| 1422 | 1424 | ||
| 1423 | bool ShouldExecute() const { | 1425 | const VideoCore::RasterizerInterface& GetRasterizer() const { |
| 1424 | return execute_on; | 1426 | return rasterizer; |
| 1425 | } | 1427 | } |
| 1426 | 1428 | ||
| 1427 | /// Notify a memory write has happened. | 1429 | /// Notify a memory write has happened. |
| @@ -1468,16 +1470,13 @@ private: | |||
| 1468 | 1470 | ||
| 1469 | std::array<bool, Regs::NUM_REGS> mme_inline{}; | 1471 | std::array<bool, Regs::NUM_REGS> mme_inline{}; |
| 1470 | 1472 | ||
| 1471 | /// Memory for macro code | ||
| 1472 | MacroMemory macro_memory; | ||
| 1473 | |||
| 1474 | /// Macro method that is currently being executed / being fed parameters. | 1473 | /// Macro method that is currently being executed / being fed parameters. |
| 1475 | u32 executing_macro = 0; | 1474 | u32 executing_macro = 0; |
| 1476 | /// Parameters that have been submitted to the macro call so far. | 1475 | /// Parameters that have been submitted to the macro call so far. |
| 1477 | std::vector<u32> macro_params; | 1476 | std::vector<u32> macro_params; |
| 1478 | 1477 | ||
| 1479 | /// Interpreter for the macro codes uploaded to the GPU. | 1478 | /// Interpreter for the macro codes uploaded to the GPU. |
| 1480 | MacroInterpreter macro_interpreter; | 1479 | std::unique_ptr<MacroEngine> macro_engine; |
| 1481 | 1480 | ||
| 1482 | static constexpr u32 null_cb_data = 0xFFFFFFFF; | 1481 | static constexpr u32 null_cb_data = 0xFFFFFFFF; |
| 1483 | struct { | 1482 | struct { |
| @@ -1506,7 +1505,7 @@ private: | |||
| 1506 | * @param num_parameters Number of arguments | 1505 | * @param num_parameters Number of arguments |
| 1507 | * @param parameters Arguments to the method call | 1506 | * @param parameters Arguments to the method call |
| 1508 | */ | 1507 | */ |
| 1509 | void CallMacroMethod(u32 method, std::size_t num_parameters, const u32* parameters); | 1508 | void CallMacroMethod(u32 method, const std::vector<u32>& parameters); |
| 1510 | 1509 | ||
| 1511 | /// Handles writes to the macro uploading register. | 1510 | /// Handles writes to the macro uploading register. |
| 1512 | void ProcessMacroUpload(u32 data); | 1511 | void ProcessMacroUpload(u32 data); |